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
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.XeboPageView = void 0;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const react_native_1 = require("react-native");
|
|
39
|
+
const XeboTheme_1 = require("../theme/XeboTheme");
|
|
40
|
+
const XeboStrings_1 = require("../i18n/XeboStrings");
|
|
41
|
+
const XeboRtl_1 = require("../i18n/XeboRtl");
|
|
42
|
+
/** One page of the survey: its questions, then Ok / Previous / Next-or-Submit like the web. */
|
|
43
|
+
exports.XeboPageView = (0, react_1.forwardRef)(({ questions, isLastPage, onOk, onNext, onFitHeight, previousLabel, previousIconOnly, canGoBack, onPreviousPage, buttonColors, }, ref) => {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
const theme = (0, XeboTheme_1.getTheme)();
|
|
46
|
+
const scrollRef = (0, react_1.useRef)(null);
|
|
47
|
+
const offsets = (0, react_1.useRef)([]);
|
|
48
|
+
const heights = (0, react_1.useRef)({ layout: 0, content: 0 });
|
|
49
|
+
const reportFit = () => {
|
|
50
|
+
const { layout, content } = heights.current;
|
|
51
|
+
if (layout > 0 && content > 0)
|
|
52
|
+
onFitHeight === null || onFitHeight === void 0 ? void 0 : onFitHeight(content - layout);
|
|
53
|
+
};
|
|
54
|
+
// Theme colours: Ok and Next fall back to the survey's primary button, then to the SDK theme.
|
|
55
|
+
const okColor = (_a = buttonColors === null || buttonColors === void 0 ? void 0 : buttonColors.ok) !== null && _a !== void 0 ? _a : buttonColors === null || buttonColors === void 0 ? void 0 : buttonColors.primary;
|
|
56
|
+
const nextColor = (_b = buttonColors === null || buttonColors === void 0 ? void 0 : buttonColors.next) !== null && _b !== void 0 ? _b : buttonColors === null || buttonColors === void 0 ? void 0 : buttonColors.primary;
|
|
57
|
+
const prevColor = buttonColors === null || buttonColors === void 0 ? void 0 : buttonColors.previous;
|
|
58
|
+
const scrollToQuestion = (index) => {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
(_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollTo({ y: (_b = offsets.current[index]) !== null && _b !== void 0 ? _b : 0, animated: true });
|
|
61
|
+
};
|
|
62
|
+
// Ok checks the question it belongs to, then scrolls the next one into view.
|
|
63
|
+
const handleOk = (index) => {
|
|
64
|
+
if (!onOk(questions[index].id))
|
|
65
|
+
return;
|
|
66
|
+
scrollToQuestion(index + 1);
|
|
67
|
+
};
|
|
68
|
+
// Previous goes to the question above, or from the page's first question back to the last page.
|
|
69
|
+
const handlePrevious = (index) => {
|
|
70
|
+
if (index > 0)
|
|
71
|
+
scrollToQuestion(index - 1);
|
|
72
|
+
else
|
|
73
|
+
onPreviousPage();
|
|
74
|
+
};
|
|
75
|
+
const hasPrevious = (index) => !!previousLabel && (index > 0 || canGoBack);
|
|
76
|
+
// The bottom row belongs to the page's last question.
|
|
77
|
+
const last = questions.length - 1;
|
|
78
|
+
// The web drops Ok / Next for an auto-advancing NPS only when Previous sits beside it, so a row
|
|
79
|
+
// is never empty (e.g. the survey's first question keeps Ok). Submit always stays.
|
|
80
|
+
const hidesForward = (index) => { var _a; return !!((_a = questions[index]) === null || _a === void 0 ? void 0 : _a.hidesButtons) && hasPrevious(index); };
|
|
81
|
+
const hidesNext = !isLastPage && hidesForward(last);
|
|
82
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
83
|
+
// Only called for auto-advancing questions: scroll to the next one, or from the last go to the next page.
|
|
84
|
+
scrollToNext: (questionId) => {
|
|
85
|
+
const index = questions.findIndex(q => q.id === questionId);
|
|
86
|
+
if (index < 0)
|
|
87
|
+
return;
|
|
88
|
+
// Short pause so the respondent sees their pick before the page moves.
|
|
89
|
+
if (index < last)
|
|
90
|
+
setTimeout(() => scrollToQuestion(index + 1), 300);
|
|
91
|
+
else if (!isLastPage)
|
|
92
|
+
setTimeout(onNext, 300);
|
|
93
|
+
},
|
|
94
|
+
}), [questions, last, isLastPage, onNext]);
|
|
95
|
+
// In the bottom row Previous takes the same size as Next/Submit, like the web.
|
|
96
|
+
const previousButton = (index, bottom = false) => {
|
|
97
|
+
var _a, _b, _c;
|
|
98
|
+
return previousIconOnly ? (<react_native_1.TouchableOpacity style={[styles.iconButton, { backgroundColor: (_a = prevColor === null || prevColor === void 0 ? void 0 : prevColor.background) !== null && _a !== void 0 ? _a : theme.selectedSurfaceColor, borderRadius: theme.cornerRadius }]} onPress={() => handlePrevious(index)} activeOpacity={0.8} accessibilityLabel={previousLabel}>
|
|
99
|
+
<react_native_1.Text style={[styles.iconText, { color: (_b = prevColor === null || prevColor === void 0 ? void 0 : prevColor.text) !== null && _b !== void 0 ? _b : theme.textColor }]}>{(0, XeboRtl_1.isRtl)() ? '›' : '‹'}</react_native_1.Text>
|
|
100
|
+
</react_native_1.TouchableOpacity>) : (<react_native_1.TouchableOpacity style={[
|
|
101
|
+
bottom ? styles.button : styles.pairButton,
|
|
102
|
+
{ borderRadius: theme.cornerRadius },
|
|
103
|
+
prevColor
|
|
104
|
+
? { backgroundColor: prevColor.background }
|
|
105
|
+
: [styles.previousOutline, { borderColor: theme.primaryColor }],
|
|
106
|
+
]} onPress={() => handlePrevious(index)} activeOpacity={0.8}>
|
|
107
|
+
<react_native_1.Text style={[styles.buttonText, bottom && styles.nextText, { color: prevColor ? (_c = prevColor.text) !== null && _c !== void 0 ? _c : '#FFFFFF' : theme.primaryColor, fontFamily: theme.fontFamily }]}>
|
|
108
|
+
{previousLabel}
|
|
109
|
+
</react_native_1.Text>
|
|
110
|
+
</react_native_1.TouchableOpacity>);
|
|
111
|
+
};
|
|
112
|
+
return (<react_native_1.View style={styles.container}>
|
|
113
|
+
<react_native_1.ScrollView ref={scrollRef} style={styles.scroll} keyboardShouldPersistTaps="handled" showsVerticalScrollIndicator={false} onLayout={e => { heights.current.layout = e.nativeEvent.layout.height; reportFit(); }} onContentSizeChange={(_, h) => { heights.current.content = h; reportFit(); }}>
|
|
114
|
+
{questions.map((q, i) => {
|
|
115
|
+
var _a, _b, _c, _d;
|
|
116
|
+
return (<react_native_1.View key={q.id} onLayout={e => { offsets.current[i] = e.nativeEvent.layout.y; }}>
|
|
117
|
+
{q.view}
|
|
118
|
+
{/* Like the web, the last question's buttons sit under it and scroll with the page. */}
|
|
119
|
+
{i === last && (hasPrevious(last) || !hidesNext) && (<react_native_1.View style={styles.bottomRow}>
|
|
120
|
+
{hasPrevious(last) && previousButton(last, true)}
|
|
121
|
+
{!hidesNext && (<react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: (_a = nextColor === null || nextColor === void 0 ? void 0 : nextColor.background) !== null && _a !== void 0 ? _a : theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={onNext} activeOpacity={0.8}>
|
|
122
|
+
<react_native_1.Text style={[styles.buttonText, styles.nextText, { color: (_b = nextColor === null || nextColor === void 0 ? void 0 : nextColor.text) !== null && _b !== void 0 ? _b : '#FFFFFF', fontFamily: theme.fontFamily }]}>
|
|
123
|
+
{(0, XeboStrings_1.actionLabel)(isLastPage)}
|
|
124
|
+
</react_native_1.Text>
|
|
125
|
+
</react_native_1.TouchableOpacity>)}
|
|
126
|
+
</react_native_1.View>)}
|
|
127
|
+
{i < last && (<react_native_1.View style={styles.okRow}>
|
|
128
|
+
{hasPrevious(i) && previousButton(i)}
|
|
129
|
+
{!hidesForward(i) && (<react_native_1.TouchableOpacity style={[styles.pairButton, { backgroundColor: (_c = okColor === null || okColor === void 0 ? void 0 : okColor.background) !== null && _c !== void 0 ? _c : theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={() => handleOk(i)} activeOpacity={0.8}>
|
|
130
|
+
<react_native_1.Text style={[styles.buttonText, { color: (_d = okColor === null || okColor === void 0 ? void 0 : okColor.text) !== null && _d !== void 0 ? _d : '#FFFFFF', fontFamily: theme.fontFamily }]}>
|
|
131
|
+
{(0, XeboStrings_1.getStrings)().ok} ✓
|
|
132
|
+
</react_native_1.Text>
|
|
133
|
+
</react_native_1.TouchableOpacity>)}
|
|
134
|
+
</react_native_1.View>)}
|
|
135
|
+
</react_native_1.View>);
|
|
136
|
+
})}
|
|
137
|
+
</react_native_1.ScrollView>
|
|
138
|
+
</react_native_1.View>);
|
|
139
|
+
});
|
|
140
|
+
const styles = react_native_1.StyleSheet.create({
|
|
141
|
+
container: {
|
|
142
|
+
flex: 1,
|
|
143
|
+
paddingBottom: 10,
|
|
144
|
+
},
|
|
145
|
+
scroll: {
|
|
146
|
+
flex: 1,
|
|
147
|
+
},
|
|
148
|
+
okRow: {
|
|
149
|
+
flexDirection: 'row',
|
|
150
|
+
justifyContent: 'center',
|
|
151
|
+
gap: 12,
|
|
152
|
+
marginBottom: 16,
|
|
153
|
+
},
|
|
154
|
+
pairButton: {
|
|
155
|
+
paddingVertical: 10,
|
|
156
|
+
paddingHorizontal: 24,
|
|
157
|
+
justifyContent: 'center',
|
|
158
|
+
},
|
|
159
|
+
previousOutline: {
|
|
160
|
+
borderWidth: 1.5,
|
|
161
|
+
},
|
|
162
|
+
iconButton: {
|
|
163
|
+
width: 44,
|
|
164
|
+
alignItems: 'center',
|
|
165
|
+
justifyContent: 'center',
|
|
166
|
+
},
|
|
167
|
+
iconText: {
|
|
168
|
+
fontSize: 24,
|
|
169
|
+
lineHeight: 26,
|
|
170
|
+
},
|
|
171
|
+
bottomRow: {
|
|
172
|
+
flexDirection: 'row',
|
|
173
|
+
gap: 12,
|
|
174
|
+
marginTop: 4,
|
|
175
|
+
marginBottom: 8,
|
|
176
|
+
marginHorizontal: 20,
|
|
177
|
+
},
|
|
178
|
+
button: {
|
|
179
|
+
flex: 1,
|
|
180
|
+
paddingVertical: 14,
|
|
181
|
+
alignItems: 'center',
|
|
182
|
+
},
|
|
183
|
+
buttonText: {
|
|
184
|
+
fontSize: 15,
|
|
185
|
+
fontWeight: '600',
|
|
186
|
+
},
|
|
187
|
+
nextText: {
|
|
188
|
+
fontSize: 16,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
@@ -1,10 +1,28 @@
|
|
|
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
|
+
/** Reports how much taller (or shorter) the sheet must be to fit the content without a gap. */
|
|
8
|
+
onFitHeight?: (delta: number) => void;
|
|
9
|
+
/** Shown with other questions on one page: no own button, sized to content. */
|
|
10
|
+
embedded?: boolean;
|
|
11
|
+
/** Fires when a rating is picked (drives auto-advance on a shared page). */
|
|
12
|
+
onSelect?: () => void;
|
|
7
13
|
}
|
|
8
|
-
export declare
|
|
14
|
+
export declare function FlatEmoji({ index, selected, hasSelection, outline, size, color, featureColor, }: {
|
|
15
|
+
/** 0 (saddest) to 4 (happiest). */
|
|
16
|
+
index: number;
|
|
17
|
+
selected: boolean;
|
|
18
|
+
hasSelection: boolean;
|
|
19
|
+
/** Coloured ring and features on a white face instead of a filled face. */
|
|
20
|
+
outline?: boolean;
|
|
21
|
+
size?: number;
|
|
22
|
+
/** Overrides the face colour and the eye/mouth colour (used by the NPS arc). */
|
|
23
|
+
color?: string;
|
|
24
|
+
featureColor?: string;
|
|
25
|
+
}): React.JSX.Element;
|
|
26
|
+
export declare const XeboRatingView: React.ForwardRefExoticComponent<Props & React.RefAttributes<XeboQuestionHandle>>;
|
|
9
27
|
export {};
|
|
10
28
|
//# sourceMappingURL=XeboRatingView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XeboRatingView.d.ts","sourceRoot":"","sources":["../../src/components/XeboRatingView.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"XeboRatingView.d.ts","sourceRoot":"","sources":["../../src/components/XeboRatingView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAWjF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAc,MAAM,sBAAsB,CAAC;AAKhG,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,+FAA+F;IAC/F,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAYD,wBAAgB,SAAS,CAAC,EACxB,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAe,EAAE,IAAS,EAAE,KAAK,EAAE,YAAY,GAC/E,EAAE;IACD,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,qBAmDA;AAuFD,eAAO,MAAM,cAAc,kFAgKzB,CAAC"}
|
|
@@ -34,8 +34,10 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.XeboRatingView = void 0;
|
|
37
|
+
exports.FlatEmoji = FlatEmoji;
|
|
37
38
|
const react_1 = __importStar(require("react"));
|
|
38
39
|
const react_native_1 = require("react-native");
|
|
40
|
+
const XeboModels_1 = require("../models/XeboModels");
|
|
39
41
|
const XeboTheme_1 = require("../theme/XeboTheme");
|
|
40
42
|
const XeboStrings_1 = require("../i18n/XeboStrings");
|
|
41
43
|
const XeboRtl_1 = require("../i18n/XeboRtl");
|
|
@@ -47,48 +49,55 @@ const FLAT_EMOJI_CONFIGS = [
|
|
|
47
49
|
{ bg: '#8AC926', mouth: 'smile' },
|
|
48
50
|
{ bg: '#21B573', mouth: 'bigSmile' },
|
|
49
51
|
];
|
|
50
|
-
function FlatEmoji({ index, selected, hasSelection }) {
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
const
|
|
52
|
+
function FlatEmoji({ index, selected, hasSelection, outline = false, size = 44, color, featureColor, }) {
|
|
53
|
+
const base = FLAT_EMOJI_CONFIGS[Math.min(index, FLAT_EMOJI_CONFIGS.length - 1)];
|
|
54
|
+
const conf = color ? Object.assign(Object.assign({}, base), { bg: color }) : base;
|
|
55
|
+
// Features are drawn for a 44pt face and scaled to the requested size.
|
|
56
|
+
const k = size / 44;
|
|
57
|
+
const eyeSize = 5 * k;
|
|
58
|
+
const mouthW = 18 * k;
|
|
59
|
+
const mouthH = 9 * k;
|
|
60
|
+
const stroke = Math.max(1.5, 2.5 * k);
|
|
56
61
|
const opacity = hasSelection ? (selected ? 1 : 0.35) : 1;
|
|
62
|
+
const fg = featureColor !== null && featureColor !== void 0 ? featureColor : (outline ? conf.bg : '#fff');
|
|
57
63
|
return (<react_native_1.View style={{
|
|
58
64
|
width: size,
|
|
59
65
|
height: size,
|
|
60
66
|
borderRadius: size / 2,
|
|
61
|
-
backgroundColor: conf.bg,
|
|
67
|
+
backgroundColor: outline ? (0, XeboTheme_1.getTheme)().surfaceColor : conf.bg,
|
|
68
|
+
borderWidth: outline ? 2 : 0,
|
|
69
|
+
borderColor: conf.bg,
|
|
62
70
|
opacity,
|
|
63
71
|
alignItems: 'center',
|
|
64
72
|
justifyContent: 'center',
|
|
65
73
|
}}>
|
|
66
74
|
{/* Eyes */}
|
|
67
|
-
<react_native_1.View style={{ flexDirection: 'row', gap: 9, marginBottom: 6 }}>
|
|
68
|
-
<react_native_1.View style={{ width: eyeSize, height: eyeSize, borderRadius: eyeSize / 2, backgroundColor:
|
|
69
|
-
<react_native_1.View style={{ width: eyeSize, height: eyeSize, borderRadius: eyeSize / 2, backgroundColor:
|
|
75
|
+
<react_native_1.View style={{ flexDirection: 'row', gap: 9 * k, marginBottom: 6 * k }}>
|
|
76
|
+
<react_native_1.View style={{ width: eyeSize, height: eyeSize, borderRadius: eyeSize / 2, backgroundColor: fg }}/>
|
|
77
|
+
<react_native_1.View style={{ width: eyeSize, height: eyeSize, borderRadius: eyeSize / 2, backgroundColor: fg }}/>
|
|
70
78
|
</react_native_1.View>
|
|
71
79
|
{/* Mouth */}
|
|
72
|
-
{conf.mouth === 'neutral' ? (<react_native_1.View style={{ width: mouthW, height:
|
|
80
|
+
{conf.mouth === 'neutral' ? (<react_native_1.View style={{ width: mouthW, height: stroke, borderRadius: 2, backgroundColor: fg }}/>) : conf.mouth === 'frown' ? (
|
|
73
81
|
// Top half of a ring = arch = frown
|
|
74
82
|
<react_native_1.View style={{ width: mouthW, height: mouthH, overflow: 'hidden' }}>
|
|
75
|
-
<react_native_1.View style={{ width: mouthW, height: mouthW, borderRadius: mouthW / 2, borderWidth:
|
|
83
|
+
<react_native_1.View style={{ width: mouthW, height: mouthW, borderRadius: mouthW / 2, borderWidth: stroke, borderColor: fg }}/>
|
|
76
84
|
</react_native_1.View>) : conf.mouth === 'smile' ? (
|
|
77
85
|
// Bottom half of a ring = U = smile
|
|
78
86
|
<react_native_1.View style={{ width: mouthW, height: mouthH, overflow: 'hidden' }}>
|
|
79
|
-
<react_native_1.View style={{ width: mouthW, height: mouthW, borderRadius: mouthW / 2, borderWidth:
|
|
87
|
+
<react_native_1.View style={{ width: mouthW, height: mouthW, borderRadius: mouthW / 2, borderWidth: stroke, borderColor: fg, marginTop: -mouthH }}/>
|
|
80
88
|
</react_native_1.View>) : (
|
|
81
89
|
// bigSmile: wider U
|
|
82
|
-
<react_native_1.View style={{ width: 22, height: 11, overflow: 'hidden' }}>
|
|
83
|
-
<react_native_1.View style={{ width: 22, height: 22, borderRadius: 11, borderWidth: 3, borderColor:
|
|
90
|
+
<react_native_1.View style={{ width: 22 * k, height: 11 * k, overflow: 'hidden' }}>
|
|
91
|
+
<react_native_1.View style={{ width: 22 * k, height: 22 * k, borderRadius: 11 * k, borderWidth: Math.max(1.5, 3 * k), borderColor: fg, marginTop: -11 * k }}/>
|
|
84
92
|
</react_native_1.View>)}
|
|
85
93
|
</react_native_1.View>);
|
|
86
94
|
}
|
|
87
95
|
function RatingIcon({ style, index, selected, filled, color, hasSelection, }) {
|
|
88
96
|
const activeColor = color || '#F59E0B';
|
|
97
|
+
const theme = (0, XeboTheme_1.getTheme)();
|
|
89
98
|
switch (style) {
|
|
90
99
|
case 'heart':
|
|
91
|
-
return (<react_native_1.Text style={{ fontSize: 34, color: filled ? activeColor :
|
|
100
|
+
return (<react_native_1.Text style={{ fontSize: 34, color: filled ? activeColor : theme.borderColor }}>
|
|
92
101
|
{filled ? '♥' : '♡'}
|
|
93
102
|
</react_native_1.Text>);
|
|
94
103
|
case 'circle':
|
|
@@ -98,11 +107,11 @@ function RatingIcon({ style, index, selected, filled, color, hasSelection, }) {
|
|
|
98
107
|
borderRadius: 21,
|
|
99
108
|
backgroundColor: 'transparent',
|
|
100
109
|
borderWidth: filled ? 3 : 1.5,
|
|
101
|
-
borderColor: filled ? activeColor :
|
|
110
|
+
borderColor: filled ? activeColor : theme.strongBorderColor,
|
|
102
111
|
alignItems: 'center',
|
|
103
112
|
justifyContent: 'center',
|
|
104
113
|
}}>
|
|
105
|
-
<react_native_1.Text style={{ fontSize: 16, fontWeight: '600', color: filled ? activeColor :
|
|
114
|
+
<react_native_1.Text style={{ fontSize: 16, fontWeight: '600', color: filled ? activeColor : theme.mutedTextColor }}>
|
|
106
115
|
{index + 1}
|
|
107
116
|
</react_native_1.Text>
|
|
108
117
|
</react_native_1.View>);
|
|
@@ -111,13 +120,13 @@ function RatingIcon({ style, index, selected, filled, color, hasSelection, }) {
|
|
|
111
120
|
width: 44,
|
|
112
121
|
height: 44,
|
|
113
122
|
borderRadius: 8,
|
|
114
|
-
backgroundColor: filled ? activeColor :
|
|
123
|
+
backgroundColor: filled ? activeColor : theme.selectedSurfaceColor,
|
|
115
124
|
borderWidth: filled ? 0 : 1.5,
|
|
116
|
-
borderColor:
|
|
125
|
+
borderColor: theme.strongBorderColor,
|
|
117
126
|
alignItems: 'center',
|
|
118
127
|
justifyContent: 'center',
|
|
119
128
|
}}>
|
|
120
|
-
<react_native_1.Text style={{ fontSize: 15, fontWeight: '700', color: filled ? '#FFF' :
|
|
129
|
+
<react_native_1.Text style={{ fontSize: 15, fontWeight: '700', color: filled ? '#FFF' : theme.mutedTextColor }}>
|
|
121
130
|
{index + 1}
|
|
122
131
|
</react_native_1.Text>
|
|
123
132
|
</react_native_1.View>);
|
|
@@ -130,21 +139,28 @@ function RatingIcon({ style, index, selected, filled, color, hasSelection, }) {
|
|
|
130
139
|
return <FlatEmoji index={index} selected={selected} hasSelection={hasSelection}/>;
|
|
131
140
|
case '3d_emoji':
|
|
132
141
|
return <FlatEmoji index={index} selected={selected} hasSelection={hasSelection}/>;
|
|
142
|
+
case 'outline_emoji':
|
|
143
|
+
return <FlatEmoji index={index} selected={selected} hasSelection={hasSelection} outline/>;
|
|
133
144
|
case 'star':
|
|
134
145
|
default:
|
|
135
|
-
return (<react_native_1.Text style={{ fontSize: 34, color: filled ? activeColor :
|
|
146
|
+
return (<react_native_1.Text style={{ fontSize: 34, color: filled ? activeColor : theme.borderColor }}>
|
|
136
147
|
{filled ? '★' : '☆'}
|
|
137
148
|
</react_native_1.Text>);
|
|
138
149
|
}
|
|
139
150
|
}
|
|
140
|
-
|
|
151
|
+
exports.XeboRatingView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, onFitHeight, embedded, onSelect }, ref) => {
|
|
141
152
|
var _a, _b, _c, _d;
|
|
142
153
|
const theme = (0, XeboTheme_1.getTheme)();
|
|
154
|
+
const scrollHeights = (0, react_1.useRef)({ layout: 0, content: 0 });
|
|
155
|
+
const reportFit = () => {
|
|
156
|
+
const { layout, content } = scrollHeights.current;
|
|
157
|
+
if (layout > 0 && content > 0)
|
|
158
|
+
onFitHeight === null || onFitHeight === void 0 ? void 0 : onFitHeight(content - layout);
|
|
159
|
+
};
|
|
143
160
|
const ratingStyle = (_a = question.ratingStyle) !== null && _a !== void 0 ? _a : 'star';
|
|
144
161
|
const ratingColor = (_b = question.ratingColor) !== null && _b !== void 0 ? _b : theme.primaryColor;
|
|
145
162
|
const totalSteps = (_d = (_c = question.columns) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 5;
|
|
146
|
-
|
|
147
|
-
const [selected, setSelected] = (0, react_1.useState)(null);
|
|
163
|
+
const [selected, setSelected] = (0, react_1.useState)(() => { var _a, _b; return (0, XeboModels_1.scaleIndex)(question, (_b = (_a = question.previousAnswer) === null || _a === void 0 ? void 0 : _a.value[0]) === null || _b === void 0 ? void 0 : _b.colId); });
|
|
148
164
|
const [followUpText, setFollowUpText] = (0, react_1.useState)('');
|
|
149
165
|
const [error, setError] = (0, react_1.useState)('');
|
|
150
166
|
const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
@@ -162,27 +178,37 @@ const XeboRatingView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
162
178
|
setSelected(index);
|
|
163
179
|
setError('');
|
|
164
180
|
setFollowUpText('');
|
|
181
|
+
// A comment box opens under the rating, so stay put when there is one.
|
|
182
|
+
if (!question.followUpQuestion)
|
|
183
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
|
165
184
|
};
|
|
166
|
-
const
|
|
185
|
+
const collect = () => {
|
|
167
186
|
var _a, _b, _c, _d, _e, _f;
|
|
168
187
|
if (question.isRequired && selected === null) {
|
|
169
188
|
setError((0, XeboStrings_1.requiredMessage)(question, 'Please select a rating.'));
|
|
170
189
|
shake();
|
|
171
|
-
return;
|
|
190
|
+
return null;
|
|
172
191
|
}
|
|
173
192
|
react_native_1.Keyboard.dismiss();
|
|
174
|
-
|
|
175
|
-
|
|
193
|
+
if (selected === null)
|
|
194
|
+
return { questionId: question.id, value: [] };
|
|
195
|
+
const colId = (_c = (_b = (_a = question.columns) === null || _a === void 0 ? void 0 : _a[selected]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : selected.toString();
|
|
176
196
|
const rowId = (_f = (_e = (_d = question.options) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : 'rating';
|
|
177
|
-
|
|
197
|
+
return {
|
|
178
198
|
questionId: question.id,
|
|
179
199
|
value: [{ rowId, colId, text: followUpText || undefined }],
|
|
180
|
-
}
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
(0, react_1.useImperativeHandle)(ref, () => ({ collect }));
|
|
203
|
+
const handleNext = () => {
|
|
204
|
+
const answer = collect();
|
|
205
|
+
if (answer)
|
|
206
|
+
onAnswer(answer);
|
|
181
207
|
};
|
|
182
208
|
return (
|
|
183
209
|
// Outer view fills modal content area; button pinned at bottom outside ScrollView
|
|
184
|
-
<react_native_1.View style={styles.outer}>
|
|
185
|
-
<react_native_1.ScrollView style={styles.scroll} contentContainerStyle={styles.scrollContent} showsVerticalScrollIndicator={false} keyboardShouldPersistTaps="handled">
|
|
210
|
+
<react_native_1.View style={[styles.outer, embedded && styles.embedded]}>
|
|
211
|
+
<react_native_1.ScrollView style={[styles.scroll, embedded && styles.embedded]} scrollEnabled={!embedded} onLayout={e => { scrollHeights.current.layout = e.nativeEvent.layout.height; reportFit(); }} onContentSizeChange={(_, h) => { scrollHeights.current.content = h; reportFit(); }} contentContainerStyle={styles.scrollContent} showsVerticalScrollIndicator={false} keyboardShouldPersistTaps="handled">
|
|
186
212
|
<react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
187
213
|
{question.title}
|
|
188
214
|
</react_native_1.Text>
|
|
@@ -214,26 +240,25 @@ const XeboRatingView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
214
240
|
</react_native_1.View>
|
|
215
241
|
|
|
216
242
|
{/* Follow-up after rating */}
|
|
217
|
-
{selected !== null && !!question.followUpQuestion && (<react_native_1.View style={[styles.followUpCard, { borderRadius: theme.cornerRadius }]}>
|
|
243
|
+
{selected !== null && !!question.followUpQuestion && (<react_native_1.View style={[styles.followUpCard, { borderColor: theme.borderColor, borderRadius: theme.cornerRadius }]}>
|
|
218
244
|
<react_native_1.Text style={[styles.followUpTitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
219
245
|
{question.followUpQuestion}
|
|
220
246
|
</react_native_1.Text>
|
|
221
|
-
<react_native_1.TextInput style={[styles.followUpInput, { borderColor:
|
|
247
|
+
<react_native_1.TextInput style={[styles.followUpInput, { borderColor: theme.borderColor, color: theme.textColor, borderRadius: theme.cornerRadius }, (0, XeboRtl_1.rtlInput)()]} placeholder="Your comment..." placeholderTextColor="#9CA3AF" value={followUpText} onChangeText={setFollowUpText} multiline numberOfLines={3} textAlignVertical="top"/>
|
|
222
248
|
</react_native_1.View>)}
|
|
223
249
|
</react_native_1.ScrollView>
|
|
224
250
|
|
|
225
251
|
{/* Error + button always visible at bottom, outside scroll */}
|
|
226
252
|
{!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
|
|
227
|
-
<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
253
|
+
{!embedded && (<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
254
|
+
<react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius, opacity: selected === null ? 0.4 : 1 }]} onPress={handleNext} disabled={selected === null} activeOpacity={0.8}>
|
|
255
|
+
<react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
|
|
256
|
+
{(0, XeboStrings_1.actionLabel)(isLastQuestion)}
|
|
257
|
+
</react_native_1.Text>
|
|
258
|
+
</react_native_1.TouchableOpacity>
|
|
259
|
+
</react_native_1.Animated.View>)}
|
|
234
260
|
</react_native_1.View>);
|
|
235
|
-
};
|
|
236
|
-
exports.XeboRatingView = XeboRatingView;
|
|
261
|
+
});
|
|
237
262
|
const styles = react_native_1.StyleSheet.create({
|
|
238
263
|
outer: {
|
|
239
264
|
flex: 1,
|
|
@@ -241,7 +266,9 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
241
266
|
paddingBottom: 10,
|
|
242
267
|
justifyContent: 'space-between',
|
|
243
268
|
},
|
|
244
|
-
|
|
269
|
+
// Fills the sheet so its measured height reveals any gap; the sheet itself caps at 75%.
|
|
270
|
+
scroll: { flex: 1 },
|
|
271
|
+
embedded: { flex: 0 },
|
|
245
272
|
scrollContent: { paddingTop: 16, paddingBottom: 8 },
|
|
246
273
|
title: { fontSize: 18, fontWeight: '700', marginBottom: 16 },
|
|
247
274
|
subtitle: { fontSize: 14, opacity: 0.6, marginBottom: 16 },
|
|
@@ -255,7 +282,6 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
255
282
|
colLabel: { fontSize: 11, opacity: 0.6, textAlign: 'center', marginTop: 6 },
|
|
256
283
|
followUpCard: {
|
|
257
284
|
borderWidth: 1.5,
|
|
258
|
-
borderColor: '#E5E7EB',
|
|
259
285
|
padding: 14,
|
|
260
286
|
marginBottom: 16,
|
|
261
287
|
},
|
|
@@ -1,10 +1,16 @@
|
|
|
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
|
+
/** Reports how much taller (or shorter) the sheet must be to fit every option without scrolling. */
|
|
8
|
+
onFitHeight?: (delta: number) => void;
|
|
9
|
+
/** Shown with other questions on one page: no own button, sized to content. */
|
|
10
|
+
embedded?: boolean;
|
|
11
|
+
/** Fires when an option is picked (drives auto-advance on a shared page). */
|
|
12
|
+
onSelect?: () => void;
|
|
7
13
|
}
|
|
8
|
-
export declare const XeboSingleChoiceView: React.
|
|
14
|
+
export declare const XeboSingleChoiceView: React.ForwardRefExoticComponent<Props & React.RefAttributes<XeboQuestionHandle>>;
|
|
9
15
|
export {};
|
|
10
16
|
//# sourceMappingURL=XeboSingleChoiceView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XeboSingleChoiceView.d.ts","sourceRoot":"","sources":["../../src/components/XeboSingleChoiceView.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"XeboSingleChoiceView.d.ts","sourceRoot":"","sources":["../../src/components/XeboSingleChoiceView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AASjF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAc,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAKhG,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,oGAAoG;IACpG,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,oBAAoB,kFAyG/B,CAAC"}
|
|
@@ -39,10 +39,16 @@ const react_native_1 = require("react-native");
|
|
|
39
39
|
const XeboTheme_1 = require("../theme/XeboTheme");
|
|
40
40
|
const XeboStrings_1 = require("../i18n/XeboStrings");
|
|
41
41
|
const XeboRtl_1 = require("../i18n/XeboRtl");
|
|
42
|
-
|
|
43
|
-
var _a;
|
|
42
|
+
exports.XeboSingleChoiceView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, onFitHeight, embedded, onSelect }, ref) => {
|
|
43
|
+
var _a, _b, _c, _d, _e, _f;
|
|
44
44
|
const theme = (0, XeboTheme_1.getTheme)();
|
|
45
|
-
const
|
|
45
|
+
const listHeights = (0, react_1.useRef)({ layout: 0, content: 0 });
|
|
46
|
+
const reportFit = () => {
|
|
47
|
+
const { layout, content } = listHeights.current;
|
|
48
|
+
if (layout > 0 && content > 0)
|
|
49
|
+
onFitHeight === null || onFitHeight === void 0 ? void 0 : onFitHeight(content - layout);
|
|
50
|
+
};
|
|
51
|
+
const [selectedId, setSelectedId] = (0, react_1.useState)((_e = (_c = (_b = (_a = question.previousAnswer) === null || _a === void 0 ? void 0 : _a.value[0]) === null || _b === void 0 ? void 0 : _b.rowId) !== null && _c !== void 0 ? _c : (_d = question.autoSelectOptionIds) === null || _d === void 0 ? void 0 : _d[0]) !== null && _e !== void 0 ? _e : null);
|
|
46
52
|
const [error, setError] = (0, react_1.useState)('');
|
|
47
53
|
const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
48
54
|
const shake = () => {
|
|
@@ -56,24 +62,29 @@ const XeboSingleChoiceView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
56
62
|
const handleSelect = (choice) => {
|
|
57
63
|
setSelectedId(choice.id);
|
|
58
64
|
setError('');
|
|
65
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
|
59
66
|
};
|
|
60
|
-
const
|
|
67
|
+
const collect = () => {
|
|
61
68
|
var _a, _b;
|
|
62
69
|
if (question.isRequired && !selectedId) {
|
|
63
70
|
setError((0, XeboStrings_1.requiredMessage)(question, 'Please select an option.'));
|
|
64
71
|
shake();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
if (!selectedId) {
|
|
68
|
-
onAnswer({ questionId: question.id, value: [] });
|
|
69
|
-
return;
|
|
72
|
+
return null;
|
|
70
73
|
}
|
|
71
|
-
|
|
74
|
+
if (!selectedId)
|
|
75
|
+
return { questionId: question.id, value: [] };
|
|
76
|
+
return {
|
|
72
77
|
questionId: question.id,
|
|
73
78
|
value: [{ rowId: selectedId, text: (_b = (_a = question.options) === null || _a === void 0 ? void 0 : _a.find(o => o.id === selectedId)) === null || _b === void 0 ? void 0 : _b.text }],
|
|
74
|
-
}
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
(0, react_1.useImperativeHandle)(ref, () => ({ collect }));
|
|
82
|
+
const handleNext = () => {
|
|
83
|
+
const answer = collect();
|
|
84
|
+
if (answer)
|
|
85
|
+
onAnswer(answer);
|
|
75
86
|
};
|
|
76
|
-
return (<react_native_1.View style={styles.container}>
|
|
87
|
+
return (<react_native_1.View style={[styles.container, embedded && styles.embedded]}>
|
|
77
88
|
<react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
78
89
|
{question.title}
|
|
79
90
|
</react_native_1.Text>
|
|
@@ -81,35 +92,34 @@ const XeboSingleChoiceView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
81
92
|
{question.subtitle}
|
|
82
93
|
</react_native_1.Text>)}
|
|
83
94
|
|
|
84
|
-
<react_native_1.ScrollView style={styles.optionsList} showsVerticalScrollIndicator={false}>
|
|
85
|
-
{((
|
|
95
|
+
<react_native_1.ScrollView style={[styles.optionsList, embedded && styles.embedded]} scrollEnabled={!embedded} showsVerticalScrollIndicator={false} onLayout={e => { listHeights.current.layout = e.nativeEvent.layout.height; reportFit(); }} onContentSizeChange={(_, h) => { listHeights.current.content = h; reportFit(); }}>
|
|
96
|
+
{((_f = question.options) !== null && _f !== void 0 ? _f : []).map(choice => {
|
|
86
97
|
const selected = selectedId === choice.id;
|
|
87
98
|
return (<react_native_1.TouchableOpacity key={choice.id} style={[
|
|
88
99
|
styles.optionRow,
|
|
89
|
-
|
|
100
|
+
selected
|
|
101
|
+
? { borderColor: theme.primaryColor, backgroundColor: theme.selectedSurfaceColor }
|
|
102
|
+
: { borderColor: theme.borderColor },
|
|
90
103
|
]} onPress={() => handleSelect(choice)} activeOpacity={0.7}>
|
|
91
|
-
<react_native_1.View style={[styles.radio, { borderColor: selected ? theme.primaryColor : '#9CA3AF' }]}>
|
|
92
|
-
{selected && <react_native_1.View style={[styles.radioDot, { backgroundColor: theme.primaryColor }]}/>}
|
|
93
|
-
</react_native_1.View>
|
|
94
104
|
<react_native_1.Text style={[styles.optionText, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
95
105
|
{choice.text}
|
|
96
106
|
</react_native_1.Text>
|
|
107
|
+
{selected && <react_native_1.Text style={[styles.checkmark, { color: theme.primaryColor }]}>✓</react_native_1.Text>}
|
|
97
108
|
</react_native_1.TouchableOpacity>);
|
|
98
109
|
})}
|
|
99
110
|
</react_native_1.ScrollView>
|
|
100
111
|
|
|
101
112
|
{!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
|
|
102
113
|
|
|
103
|
-
<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
114
|
+
{!embedded && (<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
115
|
+
<react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleNext} activeOpacity={0.8}>
|
|
116
|
+
<react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
|
|
117
|
+
{(0, XeboStrings_1.actionLabel)(isLastQuestion)}
|
|
118
|
+
</react_native_1.Text>
|
|
119
|
+
</react_native_1.TouchableOpacity>
|
|
120
|
+
</react_native_1.Animated.View>)}
|
|
110
121
|
</react_native_1.View>);
|
|
111
|
-
};
|
|
112
|
-
exports.XeboSingleChoiceView = XeboSingleChoiceView;
|
|
122
|
+
});
|
|
113
123
|
const styles = react_native_1.StyleSheet.create({
|
|
114
124
|
container: {
|
|
115
125
|
flex: 1,
|
|
@@ -117,6 +127,7 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
117
127
|
paddingTop: 16,
|
|
118
128
|
paddingBottom: 10,
|
|
119
129
|
},
|
|
130
|
+
embedded: { flex: 0 },
|
|
120
131
|
title: {
|
|
121
132
|
fontSize: 18,
|
|
122
133
|
fontWeight: '700',
|
|
@@ -139,19 +150,10 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
139
150
|
padding: 14,
|
|
140
151
|
marginBottom: 10,
|
|
141
152
|
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
borderWidth: 2,
|
|
147
|
-
alignItems: 'center',
|
|
148
|
-
justifyContent: 'center',
|
|
149
|
-
marginEnd: 12,
|
|
150
|
-
},
|
|
151
|
-
radioDot: {
|
|
152
|
-
width: 10,
|
|
153
|
-
height: 10,
|
|
154
|
-
borderRadius: 5,
|
|
153
|
+
checkmark: {
|
|
154
|
+
fontSize: 16,
|
|
155
|
+
fontWeight: '700',
|
|
156
|
+
marginStart: 12,
|
|
155
157
|
},
|
|
156
158
|
optionText: {
|
|
157
159
|
fontSize: 15,
|