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
|
@@ -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 : '#F2F2F2', 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 : '#1F2937' }]}>{(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;AAsFD,eAAO,MAAM,cAAc,kFAgKzB,CAAC"}
|
|
@@ -34,9 +34,13 @@ 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");
|
|
42
|
+
const XeboStrings_1 = require("../i18n/XeboStrings");
|
|
43
|
+
const XeboRtl_1 = require("../i18n/XeboRtl");
|
|
40
44
|
// ─── Icon renderers per style ─────────────────────────────────────────────────
|
|
41
45
|
const FLAT_EMOJI_CONFIGS = [
|
|
42
46
|
{ bg: '#E63946', mouth: 'frown' },
|
|
@@ -45,40 +49,46 @@ const FLAT_EMOJI_CONFIGS = [
|
|
|
45
49
|
{ bg: '#8AC926', mouth: 'smile' },
|
|
46
50
|
{ bg: '#21B573', mouth: 'bigSmile' },
|
|
47
51
|
];
|
|
48
|
-
function FlatEmoji({ index, selected, hasSelection }) {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
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);
|
|
54
61
|
const opacity = hasSelection ? (selected ? 1 : 0.35) : 1;
|
|
62
|
+
const fg = featureColor !== null && featureColor !== void 0 ? featureColor : (outline ? conf.bg : '#fff');
|
|
55
63
|
return (<react_native_1.View style={{
|
|
56
64
|
width: size,
|
|
57
65
|
height: size,
|
|
58
66
|
borderRadius: size / 2,
|
|
59
|
-
backgroundColor: conf.bg,
|
|
67
|
+
backgroundColor: outline ? '#fff' : conf.bg,
|
|
68
|
+
borderWidth: outline ? 2 : 0,
|
|
69
|
+
borderColor: conf.bg,
|
|
60
70
|
opacity,
|
|
61
71
|
alignItems: 'center',
|
|
62
72
|
justifyContent: 'center',
|
|
63
73
|
}}>
|
|
64
74
|
{/* Eyes */}
|
|
65
|
-
<react_native_1.View style={{ flexDirection: 'row', gap: 9, marginBottom: 6 }}>
|
|
66
|
-
<react_native_1.View style={{ width: eyeSize, height: eyeSize, borderRadius: eyeSize / 2, backgroundColor:
|
|
67
|
-
<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 }}/>
|
|
68
78
|
</react_native_1.View>
|
|
69
79
|
{/* Mouth */}
|
|
70
|
-
{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' ? (
|
|
71
81
|
// Top half of a ring = arch = frown
|
|
72
82
|
<react_native_1.View style={{ width: mouthW, height: mouthH, overflow: 'hidden' }}>
|
|
73
|
-
<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 }}/>
|
|
74
84
|
</react_native_1.View>) : conf.mouth === 'smile' ? (
|
|
75
85
|
// Bottom half of a ring = U = smile
|
|
76
86
|
<react_native_1.View style={{ width: mouthW, height: mouthH, overflow: 'hidden' }}>
|
|
77
|
-
<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 }}/>
|
|
78
88
|
</react_native_1.View>) : (
|
|
79
89
|
// bigSmile: wider U
|
|
80
|
-
<react_native_1.View style={{ width: 22, height: 11, overflow: 'hidden' }}>
|
|
81
|
-
<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 }}/>
|
|
82
92
|
</react_native_1.View>)}
|
|
83
93
|
</react_native_1.View>);
|
|
84
94
|
}
|
|
@@ -128,6 +138,8 @@ function RatingIcon({ style, index, selected, filled, color, hasSelection, }) {
|
|
|
128
138
|
return <FlatEmoji index={index} selected={selected} hasSelection={hasSelection}/>;
|
|
129
139
|
case '3d_emoji':
|
|
130
140
|
return <FlatEmoji index={index} selected={selected} hasSelection={hasSelection}/>;
|
|
141
|
+
case 'outline_emoji':
|
|
142
|
+
return <FlatEmoji index={index} selected={selected} hasSelection={hasSelection} outline/>;
|
|
131
143
|
case 'star':
|
|
132
144
|
default:
|
|
133
145
|
return (<react_native_1.Text style={{ fontSize: 34, color: filled ? activeColor : '#E5E7EB' }}>
|
|
@@ -135,14 +147,19 @@ function RatingIcon({ style, index, selected, filled, color, hasSelection, }) {
|
|
|
135
147
|
</react_native_1.Text>);
|
|
136
148
|
}
|
|
137
149
|
}
|
|
138
|
-
|
|
150
|
+
exports.XeboRatingView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, onFitHeight, embedded, onSelect }, ref) => {
|
|
139
151
|
var _a, _b, _c, _d;
|
|
140
152
|
const theme = (0, XeboTheme_1.getTheme)();
|
|
153
|
+
const scrollHeights = (0, react_1.useRef)({ layout: 0, content: 0 });
|
|
154
|
+
const reportFit = () => {
|
|
155
|
+
const { layout, content } = scrollHeights.current;
|
|
156
|
+
if (layout > 0 && content > 0)
|
|
157
|
+
onFitHeight === null || onFitHeight === void 0 ? void 0 : onFitHeight(content - layout);
|
|
158
|
+
};
|
|
141
159
|
const ratingStyle = (_a = question.ratingStyle) !== null && _a !== void 0 ? _a : 'star';
|
|
142
160
|
const ratingColor = (_b = question.ratingColor) !== null && _b !== void 0 ? _b : theme.primaryColor;
|
|
143
161
|
const totalSteps = (_d = (_c = question.columns) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 5;
|
|
144
|
-
|
|
145
|
-
const [selected, setSelected] = (0, react_1.useState)(null);
|
|
162
|
+
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); });
|
|
146
163
|
const [followUpText, setFollowUpText] = (0, react_1.useState)('');
|
|
147
164
|
const [error, setError] = (0, react_1.useState)('');
|
|
148
165
|
const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
@@ -160,31 +177,41 @@ const XeboRatingView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
160
177
|
setSelected(index);
|
|
161
178
|
setError('');
|
|
162
179
|
setFollowUpText('');
|
|
180
|
+
// A comment box opens under the rating, so stay put when there is one.
|
|
181
|
+
if (!question.followUpQuestion)
|
|
182
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
|
163
183
|
};
|
|
164
|
-
const
|
|
184
|
+
const collect = () => {
|
|
165
185
|
var _a, _b, _c, _d, _e, _f;
|
|
166
186
|
if (question.isRequired && selected === null) {
|
|
167
|
-
setError('Please select a rating.');
|
|
187
|
+
setError((0, XeboStrings_1.requiredMessage)(question, 'Please select a rating.'));
|
|
168
188
|
shake();
|
|
169
|
-
return;
|
|
189
|
+
return null;
|
|
170
190
|
}
|
|
171
191
|
react_native_1.Keyboard.dismiss();
|
|
172
|
-
|
|
173
|
-
|
|
192
|
+
if (selected === null)
|
|
193
|
+
return { questionId: question.id, value: [] };
|
|
194
|
+
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();
|
|
174
195
|
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';
|
|
175
|
-
|
|
196
|
+
return {
|
|
176
197
|
questionId: question.id,
|
|
177
198
|
value: [{ rowId, colId, text: followUpText || undefined }],
|
|
178
|
-
}
|
|
199
|
+
};
|
|
200
|
+
};
|
|
201
|
+
(0, react_1.useImperativeHandle)(ref, () => ({ collect }));
|
|
202
|
+
const handleNext = () => {
|
|
203
|
+
const answer = collect();
|
|
204
|
+
if (answer)
|
|
205
|
+
onAnswer(answer);
|
|
179
206
|
};
|
|
180
207
|
return (
|
|
181
208
|
// Outer view fills modal content area; button pinned at bottom outside ScrollView
|
|
182
|
-
<react_native_1.View style={styles.outer}>
|
|
183
|
-
<react_native_1.ScrollView style={styles.scroll} contentContainerStyle={styles.scrollContent} showsVerticalScrollIndicator={false} keyboardShouldPersistTaps="handled">
|
|
184
|
-
<react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
|
|
209
|
+
<react_native_1.View style={[styles.outer, embedded && styles.embedded]}>
|
|
210
|
+
<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">
|
|
211
|
+
<react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
185
212
|
{question.title}
|
|
186
213
|
</react_native_1.Text>
|
|
187
|
-
{!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
|
|
214
|
+
{!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
188
215
|
{question.subtitle}
|
|
189
216
|
</react_native_1.Text>)}
|
|
190
217
|
|
|
@@ -213,33 +240,34 @@ const XeboRatingView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
213
240
|
|
|
214
241
|
{/* Follow-up after rating */}
|
|
215
242
|
{selected !== null && !!question.followUpQuestion && (<react_native_1.View style={[styles.followUpCard, { borderRadius: theme.cornerRadius }]}>
|
|
216
|
-
<react_native_1.Text style={[styles.followUpTitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
|
|
243
|
+
<react_native_1.Text style={[styles.followUpTitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
217
244
|
{question.followUpQuestion}
|
|
218
245
|
</react_native_1.Text>
|
|
219
|
-
<react_native_1.TextInput style={[styles.followUpInput, { borderColor: '#E5E7EB', color: theme.textColor, borderRadius: theme.cornerRadius }]} placeholder="Your comment..." placeholderTextColor="#9CA3AF" value={followUpText} onChangeText={setFollowUpText} multiline numberOfLines={3} textAlignVertical="top"/>
|
|
246
|
+
<react_native_1.TextInput style={[styles.followUpInput, { borderColor: '#E5E7EB', color: theme.textColor, borderRadius: theme.cornerRadius }, (0, XeboRtl_1.rtlInput)()]} placeholder="Your comment..." placeholderTextColor="#9CA3AF" value={followUpText} onChangeText={setFollowUpText} multiline numberOfLines={3} textAlignVertical="top"/>
|
|
220
247
|
</react_native_1.View>)}
|
|
221
248
|
</react_native_1.ScrollView>
|
|
222
249
|
|
|
223
250
|
{/* Error + button always visible at bottom, outside scroll */}
|
|
224
|
-
{!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
|
|
225
|
-
<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
251
|
+
{!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
|
|
252
|
+
{!embedded && (<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
253
|
+
<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}>
|
|
254
|
+
<react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
|
|
255
|
+
{(0, XeboStrings_1.actionLabel)(isLastQuestion)}
|
|
256
|
+
</react_native_1.Text>
|
|
257
|
+
</react_native_1.TouchableOpacity>
|
|
258
|
+
</react_native_1.Animated.View>)}
|
|
232
259
|
</react_native_1.View>);
|
|
233
|
-
};
|
|
234
|
-
exports.XeboRatingView = XeboRatingView;
|
|
260
|
+
});
|
|
235
261
|
const styles = react_native_1.StyleSheet.create({
|
|
236
262
|
outer: {
|
|
237
263
|
flex: 1,
|
|
238
264
|
paddingHorizontal: 20,
|
|
239
|
-
paddingBottom:
|
|
265
|
+
paddingBottom: 10,
|
|
240
266
|
justifyContent: 'space-between',
|
|
241
267
|
},
|
|
242
|
-
|
|
268
|
+
// Fills the sheet so its measured height reveals any gap; the sheet itself caps at 75%.
|
|
269
|
+
scroll: { flex: 1 },
|
|
270
|
+
embedded: { flex: 0 },
|
|
243
271
|
scrollContent: { paddingTop: 16, paddingBottom: 8 },
|
|
244
272
|
title: { fontSize: 18, fontWeight: '700', marginBottom: 16 },
|
|
245
273
|
subtitle: { fontSize: 14, opacity: 0.6, marginBottom: 16 },
|
|
@@ -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"}
|
|
@@ -37,10 +37,18 @@ exports.XeboSingleChoiceView = void 0;
|
|
|
37
37
|
const react_1 = __importStar(require("react"));
|
|
38
38
|
const react_native_1 = require("react-native");
|
|
39
39
|
const XeboTheme_1 = require("../theme/XeboTheme");
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const XeboStrings_1 = require("../i18n/XeboStrings");
|
|
41
|
+
const XeboRtl_1 = require("../i18n/XeboRtl");
|
|
42
|
+
exports.XeboSingleChoiceView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, onFitHeight, embedded, onSelect }, ref) => {
|
|
43
|
+
var _a, _b, _c, _d, _e, _f;
|
|
42
44
|
const theme = (0, XeboTheme_1.getTheme)();
|
|
43
|
-
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);
|
|
44
52
|
const [error, setError] = (0, react_1.useState)('');
|
|
45
53
|
const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
|
|
46
54
|
const shake = () => {
|
|
@@ -54,67 +62,72 @@ const XeboSingleChoiceView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
54
62
|
const handleSelect = (choice) => {
|
|
55
63
|
setSelectedId(choice.id);
|
|
56
64
|
setError('');
|
|
65
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect();
|
|
57
66
|
};
|
|
58
|
-
const
|
|
67
|
+
const collect = () => {
|
|
59
68
|
var _a, _b;
|
|
60
69
|
if (question.isRequired && !selectedId) {
|
|
61
|
-
setError('Please select an option.');
|
|
70
|
+
setError((0, XeboStrings_1.requiredMessage)(question, 'Please select an option.'));
|
|
62
71
|
shake();
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
if (!selectedId) {
|
|
66
|
-
onAnswer({ questionId: question.id, value: [] });
|
|
67
|
-
return;
|
|
72
|
+
return null;
|
|
68
73
|
}
|
|
69
|
-
|
|
74
|
+
if (!selectedId)
|
|
75
|
+
return { questionId: question.id, value: [] };
|
|
76
|
+
return {
|
|
70
77
|
questionId: question.id,
|
|
71
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 }],
|
|
72
|
-
}
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
(0, react_1.useImperativeHandle)(ref, () => ({ collect }));
|
|
82
|
+
const handleNext = () => {
|
|
83
|
+
const answer = collect();
|
|
84
|
+
if (answer)
|
|
85
|
+
onAnswer(answer);
|
|
73
86
|
};
|
|
74
|
-
return (<react_native_1.View style={styles.container}>
|
|
75
|
-
<react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
|
|
87
|
+
return (<react_native_1.View style={[styles.container, embedded && styles.embedded]}>
|
|
88
|
+
<react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
76
89
|
{question.title}
|
|
77
90
|
</react_native_1.Text>
|
|
78
|
-
{!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
|
|
91
|
+
{!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
79
92
|
{question.subtitle}
|
|
80
93
|
</react_native_1.Text>)}
|
|
81
94
|
|
|
82
|
-
<react_native_1.ScrollView style={styles.optionsList} showsVerticalScrollIndicator={false}>
|
|
83
|
-
{((
|
|
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 => {
|
|
84
97
|
const selected = selectedId === choice.id;
|
|
85
98
|
return (<react_native_1.TouchableOpacity key={choice.id} style={[
|
|
86
99
|
styles.optionRow,
|
|
87
|
-
|
|
100
|
+
selected
|
|
101
|
+
? { borderColor: theme.primaryColor, backgroundColor: '#F3F4F6' }
|
|
102
|
+
: { borderColor: '#E5E7EB' },
|
|
88
103
|
]} onPress={() => handleSelect(choice)} activeOpacity={0.7}>
|
|
89
|
-
<react_native_1.
|
|
90
|
-
{selected && <react_native_1.View style={[styles.radioDot, { backgroundColor: theme.primaryColor }]}/>}
|
|
91
|
-
</react_native_1.View>
|
|
92
|
-
<react_native_1.Text style={[styles.optionText, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
|
|
104
|
+
<react_native_1.Text style={[styles.optionText, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
93
105
|
{choice.text}
|
|
94
106
|
</react_native_1.Text>
|
|
107
|
+
{selected && <react_native_1.Text style={[styles.checkmark, { color: theme.primaryColor }]}>✓</react_native_1.Text>}
|
|
95
108
|
</react_native_1.TouchableOpacity>);
|
|
96
109
|
})}
|
|
97
110
|
</react_native_1.ScrollView>
|
|
98
111
|
|
|
99
|
-
{!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
|
|
112
|
+
{!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
|
|
100
113
|
|
|
101
|
-
<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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>)}
|
|
108
121
|
</react_native_1.View>);
|
|
109
|
-
};
|
|
110
|
-
exports.XeboSingleChoiceView = XeboSingleChoiceView;
|
|
122
|
+
});
|
|
111
123
|
const styles = react_native_1.StyleSheet.create({
|
|
112
124
|
container: {
|
|
113
125
|
flex: 1,
|
|
114
126
|
paddingHorizontal: 20,
|
|
115
127
|
paddingTop: 16,
|
|
116
|
-
paddingBottom:
|
|
128
|
+
paddingBottom: 10,
|
|
117
129
|
},
|
|
130
|
+
embedded: { flex: 0 },
|
|
118
131
|
title: {
|
|
119
132
|
fontSize: 18,
|
|
120
133
|
fontWeight: '700',
|
|
@@ -137,19 +150,10 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
137
150
|
padding: 14,
|
|
138
151
|
marginBottom: 10,
|
|
139
152
|
},
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
borderWidth: 2,
|
|
145
|
-
alignItems: 'center',
|
|
146
|
-
justifyContent: 'center',
|
|
147
|
-
marginRight: 12,
|
|
148
|
-
},
|
|
149
|
-
radioDot: {
|
|
150
|
-
width: 10,
|
|
151
|
-
height: 10,
|
|
152
|
-
borderRadius: 5,
|
|
153
|
+
checkmark: {
|
|
154
|
+
fontSize: 16,
|
|
155
|
+
fontWeight: '700',
|
|
156
|
+
marginStart: 12,
|
|
153
157
|
},
|
|
154
158
|
optionText: {
|
|
155
159
|
fontSize: 15,
|
|
@@ -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"}
|