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
|
@@ -37,10 +37,18 @@ exports.XeboMultipleChoiceView = 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
|
|
40
|
+
const XeboStrings_1 = require("../i18n/XeboStrings");
|
|
41
|
+
const XeboRtl_1 = require("../i18n/XeboRtl");
|
|
42
|
+
exports.XeboMultipleChoiceView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, onFitHeight, embedded }, ref) => {
|
|
41
43
|
var _a;
|
|
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 [selectedIds, setSelectedIds] = (0, react_1.useState)(() => new Set(question.previousAnswer ? question.previousAnswer.value.map(v => v.rowId) : question.autoSelectOptionIds));
|
|
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 = () => {
|
|
@@ -64,13 +72,13 @@ const XeboMultipleChoiceView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
64
72
|
});
|
|
65
73
|
setError('');
|
|
66
74
|
};
|
|
67
|
-
const
|
|
75
|
+
const collect = () => {
|
|
68
76
|
if (question.isRequired && selectedIds.size === 0) {
|
|
69
|
-
setError('Please select at least one option.');
|
|
77
|
+
setError((0, XeboStrings_1.requiredMessage)(question, 'Please select at least one option.'));
|
|
70
78
|
shake();
|
|
71
|
-
return;
|
|
79
|
+
return null;
|
|
72
80
|
}
|
|
73
|
-
|
|
81
|
+
return {
|
|
74
82
|
questionId: question.id,
|
|
75
83
|
value: Array.from(selectedIds).map(id => {
|
|
76
84
|
var _a, _b;
|
|
@@ -79,58 +87,58 @@ const XeboMultipleChoiceView = ({ question, isLastQuestion, onAnswer }) => {
|
|
|
79
87
|
text: (_b = (_a = question.options) === null || _a === void 0 ? void 0 : _a.find((o) => o.id === id)) === null || _b === void 0 ? void 0 : _b.text,
|
|
80
88
|
});
|
|
81
89
|
}),
|
|
82
|
-
}
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
(0, react_1.useImperativeHandle)(ref, () => ({ collect }));
|
|
93
|
+
const handleNext = () => {
|
|
94
|
+
const answer = collect();
|
|
95
|
+
if (answer)
|
|
96
|
+
onAnswer(answer);
|
|
83
97
|
};
|
|
84
|
-
return (<react_native_1.View style={styles.container}>
|
|
85
|
-
<react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
|
|
98
|
+
return (<react_native_1.View style={[styles.container, embedded && styles.embedded]}>
|
|
99
|
+
<react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
86
100
|
{question.title}
|
|
87
101
|
</react_native_1.Text>
|
|
88
|
-
{!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
|
|
102
|
+
{!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
89
103
|
{question.subtitle}
|
|
90
104
|
</react_native_1.Text>)}
|
|
91
105
|
|
|
92
|
-
<react_native_1.ScrollView style={styles.optionsList} showsVerticalScrollIndicator={false}>
|
|
106
|
+
<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(); }}>
|
|
93
107
|
{((_a = question.options) !== null && _a !== void 0 ? _a : []).map((choice) => {
|
|
94
108
|
const selected = selectedIds.has(choice.id);
|
|
95
109
|
return (<react_native_1.TouchableOpacity key={choice.id} style={[
|
|
96
110
|
styles.optionRow,
|
|
97
|
-
|
|
111
|
+
selected
|
|
112
|
+
? { borderColor: theme.primaryColor, backgroundColor: '#F3F4F6' }
|
|
113
|
+
: { borderColor: '#E5E7EB' },
|
|
98
114
|
]} onPress={() => toggleChoice(choice)} activeOpacity={0.7}>
|
|
99
|
-
<react_native_1.
|
|
100
|
-
styles.checkbox,
|
|
101
|
-
{
|
|
102
|
-
borderColor: selected ? theme.primaryColor : '#9CA3AF',
|
|
103
|
-
backgroundColor: selected ? theme.primaryColor : 'transparent',
|
|
104
|
-
},
|
|
105
|
-
]}>
|
|
106
|
-
{selected && <react_native_1.Text style={styles.checkmark}>✓</react_native_1.Text>}
|
|
107
|
-
</react_native_1.View>
|
|
108
|
-
<react_native_1.Text style={[styles.optionText, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
|
|
115
|
+
<react_native_1.Text style={[styles.optionText, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
|
|
109
116
|
{choice.text}
|
|
110
117
|
</react_native_1.Text>
|
|
118
|
+
{selected && <react_native_1.Text style={[styles.checkmark, { color: theme.primaryColor }]}>✓</react_native_1.Text>}
|
|
111
119
|
</react_native_1.TouchableOpacity>);
|
|
112
120
|
})}
|
|
113
121
|
</react_native_1.ScrollView>
|
|
114
122
|
|
|
115
|
-
{!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
|
|
123
|
+
{!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
|
|
116
124
|
|
|
117
|
-
<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
{!embedded && (<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
|
|
126
|
+
<react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleNext} activeOpacity={0.8}>
|
|
127
|
+
<react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
|
|
128
|
+
{(0, XeboStrings_1.actionLabel)(isLastQuestion)}
|
|
129
|
+
</react_native_1.Text>
|
|
130
|
+
</react_native_1.TouchableOpacity>
|
|
131
|
+
</react_native_1.Animated.View>)}
|
|
124
132
|
</react_native_1.View>);
|
|
125
|
-
};
|
|
126
|
-
exports.XeboMultipleChoiceView = XeboMultipleChoiceView;
|
|
133
|
+
});
|
|
127
134
|
const styles = react_native_1.StyleSheet.create({
|
|
128
135
|
container: {
|
|
129
136
|
flex: 1,
|
|
130
137
|
paddingHorizontal: 20,
|
|
131
138
|
paddingTop: 16,
|
|
132
|
-
paddingBottom:
|
|
139
|
+
paddingBottom: 10,
|
|
133
140
|
},
|
|
141
|
+
embedded: { flex: 0 },
|
|
134
142
|
title: {
|
|
135
143
|
fontSize: 18,
|
|
136
144
|
fontWeight: '700',
|
|
@@ -153,19 +161,10 @@ const styles = react_native_1.StyleSheet.create({
|
|
|
153
161
|
padding: 14,
|
|
154
162
|
marginBottom: 10,
|
|
155
163
|
},
|
|
156
|
-
checkbox: {
|
|
157
|
-
width: 20,
|
|
158
|
-
height: 20,
|
|
159
|
-
borderRadius: 4,
|
|
160
|
-
borderWidth: 2,
|
|
161
|
-
alignItems: 'center',
|
|
162
|
-
justifyContent: 'center',
|
|
163
|
-
marginRight: 12,
|
|
164
|
-
},
|
|
165
164
|
checkmark: {
|
|
166
|
-
|
|
167
|
-
fontSize: 13,
|
|
165
|
+
fontSize: 16,
|
|
168
166
|
fontWeight: '700',
|
|
167
|
+
marginStart: 12,
|
|
169
168
|
},
|
|
170
169
|
optionText: {
|
|
171
170
|
fontSize: 15,
|
|
@@ -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 | 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 score is picked (drives auto-advance on a shared page). */
|
|
12
|
+
onSelect?: () => void;
|
|
7
13
|
}
|
|
8
|
-
export declare const XeboNPSView: React.
|
|
14
|
+
export declare const XeboNPSView: React.ForwardRefExoticComponent<Props & React.RefAttributes<XeboQuestionHandle>>;
|
|
9
15
|
export {};
|
|
10
16
|
//# sourceMappingURL=XeboNPSView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"XeboNPSView.d.ts","sourceRoot":"","sources":["../../src/components/XeboNPSView.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"XeboNPSView.d.ts","sourceRoot":"","sources":["../../src/components/XeboNPSView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAYjF,OAAO,EAAE,YAAY,EAAE,UAAU,EAA6C,kBAAkB,EAAc,MAAM,sBAAsB,CAAC;AAM3I,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,KAAK,IAAI,CAAC;IACtD,+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,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAyDD,eAAO,MAAM,WAAW,kFAydtB,CAAC"}
|