react-native-my-survey-sdk 3.1.3 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/XeboDropdownView.d.ts +6 -2
- package/dist/components/XeboDropdownView.d.ts.map +1 -1
- package/dist/components/XeboDropdownView.js +28 -19
- package/dist/components/XeboLanguageView.js +1 -1
- package/dist/components/XeboMultiNPSView.d.ts +4 -2
- package/dist/components/XeboMultiNPSView.d.ts.map +1 -1
- package/dist/components/XeboMultiNPSView.js +25 -27
- package/dist/components/XeboMultiRatingView.d.ts +4 -2
- package/dist/components/XeboMultiRatingView.d.ts.map +1 -1
- package/dist/components/XeboMultiRatingView.js +27 -20
- package/dist/components/XeboMultipleChoiceView.d.ts +6 -2
- package/dist/components/XeboMultipleChoiceView.d.ts.map +1 -1
- package/dist/components/XeboMultipleChoiceView.js +35 -38
- package/dist/components/XeboNPSView.d.ts +8 -2
- package/dist/components/XeboNPSView.d.ts.map +1 -1
- package/dist/components/XeboNPSView.js +307 -59
- 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 +72 -46
- package/dist/components/XeboSingleChoiceView.d.ts +8 -2
- package/dist/components/XeboSingleChoiceView.d.ts.map +1 -1
- package/dist/components/XeboSingleChoiceView.js +42 -40
- package/dist/components/XeboSurveyModal.d.ts.map +1 -1
- package/dist/components/XeboSurveyModal.js +152 -37
- package/dist/components/XeboTextBoxView.d.ts +4 -2
- package/dist/components/XeboTextBoxView.d.ts.map +1 -1
- package/dist/components/XeboTextBoxView.js +28 -19
- package/dist/core/XeboLanguageService.d.ts.map +1 -1
- package/dist/core/XeboLanguageService.js +6 -0
- package/dist/core/XeboNetworkService.d.ts +12 -1
- package/dist/core/XeboNetworkService.d.ts.map +1 -1
- package/dist/core/XeboNetworkService.js +181 -64
- 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 +16 -1
- package/dist/core/XeboSurveyManager.d.ts.map +1 -1
- package/dist/core/XeboSurveyManager.js +120 -47
- package/dist/i18n/XeboRtl.d.ts +5 -0
- package/dist/i18n/XeboRtl.d.ts.map +1 -1
- package/dist/i18n/XeboRtl.js +11 -0
- package/dist/i18n/XeboStrings.d.ts +6 -0
- package/dist/i18n/XeboStrings.d.ts.map +1 -1
- package/dist/i18n/XeboStrings.js +19 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/models/XeboAPIModels.d.ts +93 -0
- package/dist/models/XeboAPIModels.d.ts.map +1 -1
- package/dist/models/XeboModels.d.ts +86 -2
- package/dist/models/XeboModels.d.ts.map +1 -1
- package/dist/models/XeboModels.js +24 -0
- package/dist/theme/XeboTheme.d.ts +7 -0
- package/dist/theme/XeboTheme.d.ts.map +1 -1
- package/dist/theme/XeboTheme.js +27 -13
- package/package.json +3 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XeboSurveyModal.d.ts","sourceRoot":"","sources":["../../src/components/XeboSurveyModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"XeboSurveyModal.d.ts","sourceRoot":"","sources":["../../src/components/XeboSurveyModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAgHjF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAqbnC,CAAC"}
|
|
@@ -40,6 +40,7 @@ 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");
|
|
@@ -56,7 +57,8 @@ const XeboNPSView_1 = require("./XeboNPSView");
|
|
|
56
57
|
const XeboMultiNPSView_1 = require("./XeboMultiNPSView");
|
|
57
58
|
const XeboRatingView_1 = require("./XeboRatingView");
|
|
58
59
|
const XeboMultiRatingView_1 = require("./XeboMultiRatingView");
|
|
59
|
-
|
|
60
|
+
const XeboPageView_1 = require("./XeboPageView");
|
|
61
|
+
function computeSheetHeight(question, screen, sh, languagePage, bottomInset) {
|
|
60
62
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
61
63
|
if (screen === 'language') {
|
|
62
64
|
const rows = (_a = languagePage === null || languagePage === void 0 ? void 0 : languagePage.options.length) !== null && _a !== void 0 ? _a : 2;
|
|
@@ -91,15 +93,37 @@ function computeSheetHeight(question, screen, sh, languagePage) {
|
|
|
91
93
|
return sh * 0.62;
|
|
92
94
|
case XeboModels_1.XeboQuestionType.singleChoice:
|
|
93
95
|
case XeboModels_1.XeboQuestionType.multipleChoice: {
|
|
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.
|
|
94
98
|
const optCount = (_k = (_j = question.options) === null || _j === void 0 ? void 0 : _j.length) !== null && _k !== void 0 ? _k : 0;
|
|
95
|
-
|
|
99
|
+
const subtitle = question.subtitle ? 36 : 0;
|
|
100
|
+
return Math.min(sh * 0.75, 200 + subtitle + optCount * 61 + bottomInset);
|
|
96
101
|
}
|
|
97
102
|
default:
|
|
98
103
|
return sh * 0.45;
|
|
99
104
|
}
|
|
100
105
|
}
|
|
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) {
|
|
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
|
+
}
|
|
101
125
|
const XeboSurveyModal = () => {
|
|
102
|
-
var _a, _b;
|
|
126
|
+
var _a, _b, _c, _d;
|
|
103
127
|
const theme = (0, XeboTheme_1.getTheme)();
|
|
104
128
|
// Always get the live window dimensions — fixes stale height on Android first open
|
|
105
129
|
const { height: windowHeight } = (0, react_native_1.useWindowDimensions)();
|
|
@@ -109,16 +133,22 @@ const XeboSurveyModal = () => {
|
|
|
109
133
|
const androidNavBar = react_native_1.Platform.OS === 'android'
|
|
110
134
|
? Math.max(0, screenDims.height - windowHeight - statusBarHeight)
|
|
111
135
|
: 0;
|
|
112
|
-
|
|
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);
|
|
113
140
|
// Android edge-to-edge: the modal window spans the whole screen, but RN (0.77) can lay
|
|
114
141
|
// its content out shorter (screen minus status bar), leaving a gap under the sheet.
|
|
115
142
|
// Measure the real content height and pull the sheet down by the difference.
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
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)
|
|
119
147
|
: 0;
|
|
120
|
-
// Slides the sheet above the keyboard when any TextInput is focused.
|
|
148
|
+
// Slides the sheet above the keyboard when any TextInput is focused (iOS).
|
|
121
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);
|
|
122
152
|
const sheetHeightRef = (0, react_1.useRef)(0);
|
|
123
153
|
const [visible, setVisible] = (0, react_1.useState)(false);
|
|
124
154
|
const [survey, setSurvey] = (0, react_1.useState)(null);
|
|
@@ -127,26 +157,57 @@ const XeboSurveyModal = () => {
|
|
|
127
157
|
const [languagePage, setLanguagePage] = (0, react_1.useState)(null);
|
|
128
158
|
const [selectedLangKey, setSelectedLangKey] = (0, react_1.useState)(null);
|
|
129
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);
|
|
130
165
|
const strings = (0, XeboStrings_1.getStrings)();
|
|
131
|
-
const
|
|
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]);
|
|
132
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
|
+
}, []);
|
|
133
186
|
// ─── Keyboard: slide sheet above keyboard when any TextInput focuses ──────
|
|
134
187
|
(0, react_1.useEffect)(() => {
|
|
135
188
|
const showEvent = react_native_1.Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';
|
|
136
189
|
const hideEvent = react_native_1.Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';
|
|
137
190
|
const onShow = (e) => {
|
|
138
191
|
const kh = e.endCoordinates.height;
|
|
192
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
193
|
+
setAndroidKeyboardHeight(kh);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
139
196
|
const maxShift = Math.max(0, windowHeight - sheetHeightRef.current);
|
|
140
197
|
react_native_1.Animated.timing(shiftAnim, {
|
|
141
198
|
toValue: -Math.min(kh, maxShift),
|
|
142
|
-
duration:
|
|
199
|
+
duration: 250,
|
|
143
200
|
useNativeDriver: true,
|
|
144
201
|
}).start();
|
|
145
202
|
};
|
|
146
203
|
const onHide = () => {
|
|
204
|
+
if (react_native_1.Platform.OS === 'android') {
|
|
205
|
+
setAndroidKeyboardHeight(0);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
147
208
|
react_native_1.Animated.timing(shiftAnim, {
|
|
148
209
|
toValue: 0,
|
|
149
|
-
duration:
|
|
210
|
+
duration: 200,
|
|
150
211
|
useNativeDriver: true,
|
|
151
212
|
}).start();
|
|
152
213
|
};
|
|
@@ -176,6 +237,8 @@ const XeboSurveyModal = () => {
|
|
|
176
237
|
setSurvey(s);
|
|
177
238
|
setLanguagePage(null);
|
|
178
239
|
setLanguageBusy(false);
|
|
240
|
+
setDisqualified(false);
|
|
241
|
+
setQuestionNumber(1);
|
|
179
242
|
if ((_a = s === null || s === void 0 ? void 0 : s.introPage) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
180
243
|
setScreen('intro');
|
|
181
244
|
}
|
|
@@ -227,39 +290,75 @@ const XeboSurveyModal = () => {
|
|
|
227
290
|
// NPS Pro sends [npsAnswer, followUpAnswer] — record each separately
|
|
228
291
|
const answers = Array.isArray(answer) ? answer : [answer];
|
|
229
292
|
answers.forEach(a => XeboSurveyManager_1.XeboSurveyManager.recordAnswer(a));
|
|
293
|
+
const answeredCount = XeboSurveyManager_1.XeboSurveyManager.currentPage.length || 1;
|
|
230
294
|
XeboSurveyManager_1.XeboSurveyManager.nextQuestion();
|
|
295
|
+
if (XeboSurveyManager_1.XeboSurveyManager.disqualified) {
|
|
296
|
+
setDisqualified(true);
|
|
297
|
+
setScreen('thankYou');
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
231
300
|
const s = XeboSurveyManager_1.XeboSurveyManager.survey;
|
|
232
301
|
const newIdx = XeboSurveyManager_1.XeboSurveyManager.currentQuestionIndex;
|
|
233
302
|
if (s && ((_a = s.questions[newIdx]) === null || _a === void 0 ? void 0 : _a.id) === 'thank_you_auto') {
|
|
234
303
|
setScreen('thankYou');
|
|
235
304
|
}
|
|
305
|
+
else {
|
|
306
|
+
setQuestionNumber(n => n + answeredCount);
|
|
307
|
+
}
|
|
236
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
|
+
};
|
|
237
326
|
// ─── Question renderer ────────────────────────────────────────────────────
|
|
238
|
-
const renderQuestion = (question) => {
|
|
327
|
+
const renderQuestion = (question, number, isLast, embedded = false) => {
|
|
239
328
|
var _a;
|
|
240
|
-
const questions = (_a = survey === null || survey === void 0 ? void 0 : survey.questions) !== null && _a !== void 0 ? _a : [];
|
|
241
|
-
const lastRealIndex = questions.findIndex(q => q.id === 'thank_you_auto') - 1;
|
|
242
|
-
const isLast = questionIndex === lastRealIndex;
|
|
243
329
|
// key must be passed directly (not via spread) — forces unmount/remount on question change,
|
|
244
330
|
// resetting all component state (selected score, text, etc.)
|
|
245
|
-
const
|
|
246
|
-
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;
|
|
247
346
|
switch (question.type) {
|
|
248
347
|
case XeboModels_1.XeboQuestionType.singleChoice:
|
|
249
|
-
return <XeboSingleChoiceView_1.XeboSingleChoiceView key={question.id} {...commonProps}/>;
|
|
348
|
+
return <XeboSingleChoiceView_1.XeboSingleChoiceView key={question.id} {...commonProps} onFitHeight={onFitHeight} onSelect={onSelect}/>;
|
|
250
349
|
case XeboModels_1.XeboQuestionType.multipleChoice:
|
|
251
|
-
return <XeboMultipleChoiceView_1.XeboMultipleChoiceView key={question.id} {...commonProps}/>;
|
|
350
|
+
return <XeboMultipleChoiceView_1.XeboMultipleChoiceView key={question.id} {...commonProps} onFitHeight={onFitHeight}/>;
|
|
252
351
|
case XeboModels_1.XeboQuestionType.dropdown:
|
|
253
|
-
return <XeboDropdownView_1.XeboDropdownView key={question.id} {...commonProps}/>;
|
|
352
|
+
return <XeboDropdownView_1.XeboDropdownView key={question.id} {...commonProps} onSelect={onSelect}/>;
|
|
254
353
|
case XeboModels_1.XeboQuestionType.singleTextBox:
|
|
255
354
|
case XeboModels_1.XeboQuestionType.multipleTextBox:
|
|
256
355
|
return <XeboTextBoxView_1.XeboTextBoxView key={question.id} {...commonProps}/>;
|
|
257
356
|
case XeboModels_1.XeboQuestionType.nps:
|
|
258
|
-
return <XeboNPSView_1.XeboNPSView key={question.id} {...commonProps}/>;
|
|
357
|
+
return <XeboNPSView_1.XeboNPSView key={question.id} {...commonProps} onFitHeight={onFitHeight} onSelect={onSelect}/>;
|
|
259
358
|
case XeboModels_1.XeboQuestionType.multiNps:
|
|
260
359
|
return <XeboMultiNPSView_1.XeboMultiNPSView key={question.id} {...commonProps}/>;
|
|
261
360
|
case XeboModels_1.XeboQuestionType.rating:
|
|
262
|
-
return <XeboRatingView_1.XeboRatingView key={question.id} {...commonProps}/>;
|
|
361
|
+
return <XeboRatingView_1.XeboRatingView key={question.id} {...commonProps} onFitHeight={onFitHeight} onSelect={onSelect}/>;
|
|
263
362
|
case XeboModels_1.XeboQuestionType.multiRating:
|
|
264
363
|
return <XeboMultiRatingView_1.XeboMultiRatingView key={question.id} {...commonProps}/>;
|
|
265
364
|
default:
|
|
@@ -267,6 +366,7 @@ const XeboSurveyModal = () => {
|
|
|
267
366
|
}
|
|
268
367
|
};
|
|
269
368
|
const renderContent = () => {
|
|
369
|
+
var _a, _b;
|
|
270
370
|
if (screen === 'language') {
|
|
271
371
|
if (!languagePage)
|
|
272
372
|
return null;
|
|
@@ -278,7 +378,14 @@ const XeboSurveyModal = () => {
|
|
|
278
378
|
return <XeboIntroView_1.XeboIntroView introPage={survey.introPage} onStart={handleIntroStart}/>;
|
|
279
379
|
}
|
|
280
380
|
if (screen === 'thankYou') {
|
|
281
|
-
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');
|
|
282
389
|
if (tyQuestion) {
|
|
283
390
|
return <XeboThankYouView_1.XeboThankYouView question={tyQuestion} onDismiss={handleSkip}/>;
|
|
284
391
|
}
|
|
@@ -287,7 +394,15 @@ const XeboSurveyModal = () => {
|
|
|
287
394
|
const question = survey.questions[questionIndex];
|
|
288
395
|
if (!question)
|
|
289
396
|
return null;
|
|
290
|
-
|
|
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)}/>);
|
|
291
406
|
}
|
|
292
407
|
return null;
|
|
293
408
|
};
|
|
@@ -303,12 +418,19 @@ const XeboSurveyModal = () => {
|
|
|
303
418
|
setLanguagePage(null);
|
|
304
419
|
setSelectedLangKey(null);
|
|
305
420
|
setLanguageBusy(false);
|
|
421
|
+
setDisqualified(false);
|
|
422
|
+
setFitHeight(null);
|
|
306
423
|
shiftAnim.setValue(0); // reset in case keyboard was open when modal closed
|
|
424
|
+
setAndroidKeyboardHeight(0);
|
|
425
|
+
setModalRoot({ full: 0, current: 0 });
|
|
307
426
|
}}>
|
|
308
427
|
{/* Animated.View handles ONLY the keyboard shift (transform).
|
|
309
428
|
The inner View owns height/layout so flex children compute correctly. */}
|
|
310
|
-
<react_native_1.View pointerEvents="none" style={react_native_1.StyleSheet.absoluteFill} onLayout={e =>
|
|
311
|
-
|
|
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 }] }}>
|
|
312
434
|
<react_native_1.View style={[
|
|
313
435
|
styles.sheet,
|
|
314
436
|
{
|
|
@@ -319,27 +441,25 @@ const XeboSurveyModal = () => {
|
|
|
319
441
|
]}>
|
|
320
442
|
{/* Handle bar */}
|
|
321
443
|
<react_native_1.View style={styles.handleWrap}>
|
|
322
|
-
<react_native_1.View style={styles.handle}/>
|
|
444
|
+
<react_native_1.View style={[styles.handle, { backgroundColor: theme.strongBorderColor }]}/>
|
|
323
445
|
</react_native_1.View>
|
|
324
446
|
|
|
325
|
-
{/* Header row: Survey name /
|
|
447
|
+
{/* Header row: Survey name / X close on the thank-you page */}
|
|
326
448
|
<react_native_1.View style={styles.headerRow}>
|
|
327
449
|
<react_native_1.Text style={[
|
|
328
450
|
styles.surveyName,
|
|
329
451
|
{ color: theme.textColor, fontFamily: theme.fontFamily },
|
|
330
452
|
(0, XeboRtl_1.rtlText)(),
|
|
331
453
|
]} numberOfLines={1} ellipsizeMode="tail">
|
|
332
|
-
{(
|
|
454
|
+
{(_d = survey === null || survey === void 0 ? void 0 : survey.name) !== null && _d !== void 0 ? _d : ''}
|
|
333
455
|
</react_native_1.Text>
|
|
334
|
-
{screen === 'thankYou'
|
|
456
|
+
{screen === 'thankYou' && (<react_native_1.TouchableOpacity onPress={handleSkip} style={styles.closeButton} activeOpacity={0.7}>
|
|
335
457
|
<react_native_1.Text style={[
|
|
336
458
|
strings.localized ? styles.skipText : styles.closeText,
|
|
337
459
|
{ color: theme.textColor },
|
|
338
460
|
]}>
|
|
339
461
|
{strings.localized ? strings.close : '✕'}
|
|
340
462
|
</react_native_1.Text>
|
|
341
|
-
</react_native_1.TouchableOpacity>) : (<react_native_1.TouchableOpacity onPress={handleSkip} style={styles.skipButton} activeOpacity={0.7}>
|
|
342
|
-
<react_native_1.Text style={[styles.skipText, { color: theme.textColor }]}>{strings.skip}</react_native_1.Text>
|
|
343
463
|
</react_native_1.TouchableOpacity>)}
|
|
344
464
|
</react_native_1.View>
|
|
345
465
|
|
|
@@ -381,7 +501,6 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
381
501
|
width: 36,
|
|
382
502
|
height: 4,
|
|
383
503
|
borderRadius: 2,
|
|
384
|
-
backgroundColor: '#D1D5DB',
|
|
385
504
|
},
|
|
386
505
|
headerRow: {
|
|
387
506
|
flexDirection: 'row',
|
|
@@ -400,10 +519,6 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
400
519
|
opacity: 0.5,
|
|
401
520
|
marginEnd: 8,
|
|
402
521
|
},
|
|
403
|
-
skipButton: {
|
|
404
|
-
paddingHorizontal: 12,
|
|
405
|
-
paddingVertical: 6,
|
|
406
|
-
},
|
|
407
522
|
skipText: {
|
|
408
523
|
fontSize: 14,
|
|
409
524
|
fontWeight: '500',
|
|
@@ -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"}
|
|
@@ -40,11 +40,14 @@ const XeboModels_1 = require("../models/XeboModels");
|
|
|
40
40
|
const XeboTheme_1 = require("../theme/XeboTheme");
|
|
41
41
|
const XeboStrings_1 = require("../i18n/XeboStrings");
|
|
42
42
|
const XeboRtl_1 = require("../i18n/XeboRtl");
|
|
43
|
-
|
|
43
|
+
exports.XeboTextBoxView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, embedded }, ref) => {
|
|
44
44
|
const theme = (0, XeboTheme_1.getTheme)();
|
|
45
45
|
const isMulti = question.type === XeboModels_1.XeboQuestionType.multipleTextBox;
|
|
46
46
|
const fields = question.options && question.options.length > 0 ? question.options : [{ id: 'default', text: '', value: '' }];
|
|
47
|
-
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
|
+
});
|
|
48
51
|
const [error, setError] = (0, react_1.useState)('');
|
|
49
52
|
const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
50
53
|
const scrollRef = (0, react_1.useRef)(null);
|
|
@@ -67,25 +70,31 @@ const XeboTextBoxView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
67
70
|
setValues(prev => (Object.assign(Object.assign({}, prev), { [fieldId]: text })));
|
|
68
71
|
setError('');
|
|
69
72
|
};
|
|
70
|
-
const
|
|
73
|
+
const collect = () => {
|
|
71
74
|
if (question.isRequired) {
|
|
72
75
|
const empty = fields.some(f => { var _a; return !((_a = values[f.id]) !== null && _a !== void 0 ? _a : '').trim(); });
|
|
73
76
|
if (empty) {
|
|
74
77
|
setError((0, XeboStrings_1.requiredMessage)(question, 'Please fill in all fields.'));
|
|
75
78
|
shake();
|
|
76
|
-
return;
|
|
79
|
+
return null;
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
react_native_1.Keyboard.dismiss();
|
|
80
|
-
|
|
83
|
+
return {
|
|
81
84
|
questionId: question.id,
|
|
82
85
|
value: fields
|
|
83
86
|
.filter(f => { var _a; return ((_a = values[f.id]) !== null && _a !== void 0 ? _a : '').trim(); })
|
|
84
87
|
.map(f => { var _a; return ({ rowId: f.id, text: (_a = values[f.id]) !== null && _a !== void 0 ? _a : '' }); }),
|
|
85
|
-
}
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
(0, react_1.useImperativeHandle)(ref, () => ({ collect }));
|
|
91
|
+
const handleSubmit = () => {
|
|
92
|
+
const answer = collect();
|
|
93
|
+
if (answer)
|
|
94
|
+
onAnswer(answer);
|
|
86
95
|
};
|
|
87
96
|
return (<react_native_1.View style={styles.outer}>
|
|
88
|
-
<react_native_1.ScrollView ref={scrollRef} style={styles.scroll} contentContainerStyle={styles.scrollContent} keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>
|
|
97
|
+
<react_native_1.ScrollView ref={scrollRef} style={[styles.scroll, embedded && styles.embeddedScroll]} scrollEnabled={!embedded} contentContainerStyle={styles.scrollContent} keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false}>
|
|
89
98
|
<react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
90
99
|
{question.title}
|
|
91
100
|
</react_native_1.Text>
|
|
@@ -102,30 +111,29 @@ const XeboTextBoxView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
102
111
|
<react_native_1.TextInput style={[
|
|
103
112
|
styles.input,
|
|
104
113
|
{
|
|
105
|
-
borderColor:
|
|
114
|
+
borderColor: theme.borderColor,
|
|
106
115
|
color: theme.textColor,
|
|
107
116
|
fontFamily: theme.fontFamily,
|
|
108
117
|
borderRadius: theme.cornerRadius,
|
|
109
118
|
minHeight: 48,
|
|
110
119
|
},
|
|
111
|
-
(0, XeboRtl_1.
|
|
112
|
-
]} placeholder={isMulti ?
|
|
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'}/>
|
|
113
122
|
</react_native_1.View>);
|
|
114
123
|
})}
|
|
115
124
|
</react_native_1.ScrollView>
|
|
116
125
|
|
|
117
126
|
{/* Error + button always visible at bottom, outside scroll */}
|
|
118
127
|
{!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
|
|
119
|
-
<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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>)}
|
|
126
135
|
</react_native_1.View>);
|
|
127
|
-
};
|
|
128
|
-
exports.XeboTextBoxView = XeboTextBoxView;
|
|
136
|
+
});
|
|
129
137
|
const styles = react_native_1.StyleSheet.create({
|
|
130
138
|
outer: {
|
|
131
139
|
paddingHorizontal: 20,
|
|
@@ -134,6 +142,7 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
134
142
|
scroll: {
|
|
135
143
|
maxHeight: 340,
|
|
136
144
|
},
|
|
145
|
+
embeddedScroll: { maxHeight: undefined },
|
|
137
146
|
scrollContent: {
|
|
138
147
|
paddingTop: 16,
|
|
139
148
|
paddingBottom: 8,
|
|
@@ -1 +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,GA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,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;AAiGD,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,eAAe,GAAG,CAAC,CA+BlG"}
|
|
@@ -226,6 +226,12 @@ function applySurveyTranslation(data, entry) {
|
|
|
226
226
|
if (content !== undefined)
|
|
227
227
|
data.thankYouPage.content = content;
|
|
228
228
|
}
|
|
229
|
+
const rules = data.completionRules;
|
|
230
|
+
if (isPlainObject(rules) && isPlainObject(rules.logicMeet)) {
|
|
231
|
+
const logicMeet = translatedText(entry.logicMeet);
|
|
232
|
+
if (logicMeet !== undefined)
|
|
233
|
+
rules.logicMeet.value = logicMeet;
|
|
234
|
+
}
|
|
229
235
|
}
|
|
230
236
|
/** Merge a textMapping into a copy of the raw survey, matching nodes by uuid. */
|
|
231
237
|
function applyTranslation(data, textMapping) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { XeboSurvey, XeboAnswer, XeboUserData, XeboQualityFlags, XeboGeolocation, XeboDeviceInfo } from '../models/XeboModels';
|
|
1
|
+
import { XeboSurvey, XeboQuestion, XeboChoice, XeboSkipRule, XeboDelayedBranchRule, XeboCriteria, XeboAnswer, XeboUserData, XeboQualityFlags, XeboGeolocation, XeboDeviceInfo, XeboQueuedResponse } from '../models/XeboModels';
|
|
2
2
|
import { APISurveyResponse, APISurveyData, APIQuestion } from '../models/XeboAPIModels';
|
|
3
3
|
export declare function resolveZone(zone: string): string;
|
|
4
4
|
export declare function buildBaseURL(resolvedZone: string): string;
|
|
@@ -8,6 +8,8 @@ export declare function verifyApiKey(verifyURL: string, zone: string, apiKey: st
|
|
|
8
8
|
export declare function stripHTML(raw: string | undefined): string;
|
|
9
9
|
/** Placeholders live on the question or under settings, as an object or a plain string. */
|
|
10
10
|
export declare function resolvePlaceholder(q: APIQuestion): string;
|
|
11
|
+
/** The survey's own button text, used for its primary language. */
|
|
12
|
+
export declare function primaryButtonLabels(data: APISurveyData): Record<'next' | 'submit' | 'ok' | 'previous', string | undefined>;
|
|
11
13
|
export interface ParseOptions {
|
|
12
14
|
/** Only true once a translation is merged in, so English output is unchanged. */
|
|
13
15
|
localized?: boolean;
|
|
@@ -15,6 +17,14 @@ export interface ParseOptions {
|
|
|
15
17
|
direction?: 'ltr' | 'rtl';
|
|
16
18
|
}
|
|
17
19
|
export declare function parseSurvey(data: APISurveyResponse['data'], opts?: ParseOptions): XeboSurvey;
|
|
20
|
+
/** The skip rule matching this answer, or the "any other answer" rule. */
|
|
21
|
+
export declare function resolveSkipRule(question: XeboQuestion | undefined, answer: XeboAnswer | undefined): XeboSkipRule | undefined;
|
|
22
|
+
/** The delayed-branching rule whose criteria all answers so far meet, or the "otherwise" rule. */
|
|
23
|
+
export declare function resolveDelayedBranch(question: XeboQuestion | undefined, criteria: XeboCriteria[] | undefined, answers: XeboAnswer[]): XeboDelayedBranchRule | undefined;
|
|
24
|
+
/** False when the question has display logic and none of its criteria is met. */
|
|
25
|
+
export declare function isQuestionDisplayed(question: XeboQuestion, criteria: XeboCriteria[] | undefined, answers: XeboAnswer[]): boolean;
|
|
26
|
+
/** The options to show: one named by options display logic needs one of its rules' criteria met. */
|
|
27
|
+
export declare function visibleOptions(question: XeboQuestion, criteria: XeboCriteria[] | undefined, answers: XeboAnswer[]): XeboChoice[] | undefined;
|
|
18
28
|
export interface CollectorInfo {
|
|
19
29
|
surveyId: string;
|
|
20
30
|
uuid: string;
|
|
@@ -39,6 +49,7 @@ export interface SubmitMeta {
|
|
|
39
49
|
qualityFlags?: XeboQualityFlags;
|
|
40
50
|
geolocation?: XeboGeolocation;
|
|
41
51
|
deviceInfo?: XeboDeviceInfo;
|
|
52
|
+
status?: XeboQueuedResponse['status'];
|
|
42
53
|
}
|
|
43
54
|
export declare function submitResponse(feedbackBaseURL: string, surveyId: string, collectorUUID: string, bearerToken: string, answers: XeboAnswer[], meta?: SubmitMeta): Promise<SubmitResult>;
|
|
44
55
|
//# sourceMappingURL=XeboNetworkService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XeboNetworkService.d.ts","sourceRoot":"","sources":["../../src/core/XeboNetworkService.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,
|
|
1
|
+
{"version":3,"file":"XeboNetworkService.d.ts","sourceRoot":"","sources":["../../src/core/XeboNetworkService.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EAEZ,UAAU,EAEV,YAAY,EACZ,qBAAqB,EACrB,YAAY,EAEZ,UAAU,EACV,YAAY,EACZ,gBA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