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.
Files changed (65) hide show
  1. package/dist/components/XeboDropdownView.d.ts +6 -2
  2. package/dist/components/XeboDropdownView.d.ts.map +1 -1
  3. package/dist/components/XeboDropdownView.js +35 -22
  4. package/dist/components/XeboIntroView.d.ts.map +1 -1
  5. package/dist/components/XeboIntroView.js +3 -2
  6. package/dist/components/XeboLanguageView.d.ts +11 -0
  7. package/dist/components/XeboLanguageView.d.ts.map +1 -0
  8. package/dist/components/XeboLanguageView.js +90 -0
  9. package/dist/components/XeboMultiNPSView.d.ts +4 -2
  10. package/dist/components/XeboMultiNPSView.d.ts.map +1 -1
  11. package/dist/components/XeboMultiNPSView.js +32 -23
  12. package/dist/components/XeboMultiRatingView.d.ts +4 -2
  13. package/dist/components/XeboMultiRatingView.d.ts.map +1 -1
  14. package/dist/components/XeboMultiRatingView.js +31 -22
  15. package/dist/components/XeboMultipleChoiceView.d.ts +6 -2
  16. package/dist/components/XeboMultipleChoiceView.d.ts.map +1 -1
  17. package/dist/components/XeboMultipleChoiceView.js +43 -44
  18. package/dist/components/XeboNPSView.d.ts +8 -2
  19. package/dist/components/XeboNPSView.d.ts.map +1 -1
  20. package/dist/components/XeboNPSView.js +315 -55
  21. package/dist/components/XeboPageView.d.ts +33 -0
  22. package/dist/components/XeboPageView.d.ts.map +1 -0
  23. package/dist/components/XeboPageView.js +190 -0
  24. package/dist/components/XeboRatingView.d.ts +20 -2
  25. package/dist/components/XeboRatingView.d.ts.map +1 -1
  26. package/dist/components/XeboRatingView.js +71 -43
  27. package/dist/components/XeboSingleChoiceView.d.ts +8 -2
  28. package/dist/components/XeboSingleChoiceView.d.ts.map +1 -1
  29. package/dist/components/XeboSingleChoiceView.js +50 -46
  30. package/dist/components/XeboSurveyModal.d.ts.map +1 -1
  31. package/dist/components/XeboSurveyModal.js +236 -42
  32. package/dist/components/XeboTextBoxView.d.ts +4 -2
  33. package/dist/components/XeboTextBoxView.d.ts.map +1 -1
  34. package/dist/components/XeboTextBoxView.js +35 -23
  35. package/dist/components/XeboThankYouView.d.ts.map +1 -1
  36. package/dist/components/XeboThankYouView.js +3 -2
  37. package/dist/core/XeboLanguageService.d.ts +28 -0
  38. package/dist/core/XeboLanguageService.d.ts.map +1 -0
  39. package/dist/core/XeboLanguageService.js +267 -0
  40. package/dist/core/XeboNetworkService.d.ts +24 -3
  41. package/dist/core/XeboNetworkService.d.ts.map +1 -1
  42. package/dist/core/XeboNetworkService.js +202 -69
  43. package/dist/core/XeboOfflineQueue.d.ts +2 -1
  44. package/dist/core/XeboOfflineQueue.d.ts.map +1 -1
  45. package/dist/core/XeboOfflineQueue.js +24 -10
  46. package/dist/core/XeboSurveyManager.d.ts +38 -2
  47. package/dist/core/XeboSurveyManager.d.ts.map +1 -1
  48. package/dist/core/XeboSurveyManager.js +246 -72
  49. package/dist/i18n/XeboRtl.d.ts +16 -0
  50. package/dist/i18n/XeboRtl.d.ts.map +1 -0
  51. package/dist/i18n/XeboRtl.js +32 -0
  52. package/dist/i18n/XeboStrings.d.ts +35 -0
  53. package/dist/i18n/XeboStrings.d.ts.map +1 -0
  54. package/dist/i18n/XeboStrings.js +73 -0
  55. package/dist/index.d.ts +3 -1
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/models/XeboAPIModels.d.ts +103 -1
  58. package/dist/models/XeboAPIModels.d.ts.map +1 -1
  59. package/dist/models/XeboLanguageModels.d.ts +62 -0
  60. package/dist/models/XeboLanguageModels.d.ts.map +1 -0
  61. package/dist/models/XeboLanguageModels.js +3 -0
  62. package/dist/models/XeboModels.d.ts +93 -2
  63. package/dist/models/XeboModels.d.ts.map +1 -1
  64. package/dist/models/XeboModels.js +24 -0
  65. package/package.json +5 -5
@@ -1,10 +1,14 @@
1
1
  import React from 'react';
2
- import { XeboQuestion, XeboAnswer } from '../models/XeboModels';
2
+ import { XeboQuestion, XeboAnswer, XeboQuestionHandle } from '../models/XeboModels';
3
3
  interface Props {
4
4
  question: XeboQuestion;
5
5
  isLastQuestion: boolean;
6
6
  onAnswer: (answer: XeboAnswer) => void;
7
+ /** Shown with other questions on one page: no own button. */
8
+ embedded?: boolean;
9
+ /** Fires when an option is picked (drives auto-advance on a shared page). */
10
+ onSelect?: () => void;
7
11
  }
8
- export declare const XeboDropdownView: React.FC<Props>;
12
+ export declare const XeboDropdownView: React.ForwardRefExoticComponent<Props & React.RefAttributes<XeboQuestionHandle>>;
9
13
  export {};
10
14
  //# sourceMappingURL=XeboDropdownView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"XeboDropdownView.d.ts","sourceRoot":"","sources":["../../src/components/XeboDropdownView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAShD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAc,MAAM,sBAAsB,CAAC;AAG5E,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA+G5C,CAAC"}
1
+ {"version":3,"file":"XeboDropdownView.d.ts","sourceRoot":"","sources":["../../src/components/XeboDropdownView.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,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,kFA8H3B,CAAC"}
@@ -37,10 +37,15 @@ exports.XeboDropdownView = 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 XeboDropdownView = ({ question, isLastQuestion, onAnswer }) => {
40
+ const XeboStrings_1 = require("../i18n/XeboStrings");
41
+ const XeboRtl_1 = require("../i18n/XeboRtl");
42
+ exports.XeboDropdownView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, embedded, onSelect }, ref) => {
41
43
  var _a;
42
44
  const theme = (0, XeboTheme_1.getTheme)();
43
- const [selectedChoice, setSelectedChoice] = (0, react_1.useState)(null);
45
+ const [selectedChoice, setSelectedChoice] = (0, react_1.useState)(() => {
46
+ var _a, _b;
47
+ return (_b = (_a = question.options) === null || _a === void 0 ? void 0 : _a.find(o => { var _a, _b, _c, _d; return o.id === ((_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 && _b !== void 0 ? _b : null;
48
+ });
44
49
  const [isOpen, setIsOpen] = (0, react_1.useState)(false);
45
50
  const [error, setError] = (0, react_1.useState)('');
46
51
  const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
@@ -56,23 +61,30 @@ const XeboDropdownView = ({ question, isLastQuestion, onAnswer }) => {
56
61
  setSelectedChoice(choice);
57
62
  setIsOpen(false);
58
63
  setError('');
64
+ onSelect === null || onSelect === void 0 ? void 0 : onSelect();
59
65
  };
60
- const handleNext = () => {
66
+ const collect = () => {
61
67
  if (question.isRequired && !selectedChoice) {
62
- setError('Please select an option.');
68
+ setError((0, XeboStrings_1.requiredMessage)(question, 'Please select an option.'));
63
69
  shake();
64
- return;
70
+ return null;
65
71
  }
66
- onAnswer({
72
+ return {
67
73
  questionId: question.id,
68
74
  value: selectedChoice ? [{ rowId: selectedChoice.id, text: selectedChoice.text }] : [],
69
- });
75
+ };
76
+ };
77
+ (0, react_1.useImperativeHandle)(ref, () => ({ collect }));
78
+ const handleNext = () => {
79
+ const answer = collect();
80
+ if (answer)
81
+ onAnswer(answer);
70
82
  };
71
83
  return (<react_native_1.View style={styles.container}>
72
- <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
84
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
73
85
  {question.title}
74
86
  </react_native_1.Text>
75
- {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
87
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
76
88
  {question.subtitle}
77
89
  </react_native_1.Text>)}
78
90
 
@@ -81,6 +93,7 @@ const XeboDropdownView = ({ question, isLastQuestion, onAnswer }) => {
81
93
  <react_native_1.Text style={[
82
94
  styles.triggerText,
83
95
  { color: selectedChoice ? theme.textColor : '#9CA3AF', fontFamily: theme.fontFamily },
96
+ (0, XeboRtl_1.rtlText)(),
84
97
  ]}>
85
98
  {selectedChoice ? selectedChoice.text : (question.placeholder || 'Select an option')}
86
99
  </react_native_1.Text>
@@ -101,6 +114,7 @@ const XeboDropdownView = ({ question, isLastQuestion, onAnswer }) => {
101
114
  fontFamily: theme.fontFamily,
102
115
  fontWeight: (selectedChoice === null || selectedChoice === void 0 ? void 0 : selectedChoice.id) === choice.id ? '600' : '400',
103
116
  },
117
+ (0, XeboRtl_1.rtlText)(),
104
118
  ]}>
105
119
  {choice.text}
106
120
  </react_native_1.Text>
@@ -108,25 +122,24 @@ const XeboDropdownView = ({ question, isLastQuestion, onAnswer }) => {
108
122
  </react_native_1.ScrollView>
109
123
  </react_native_1.View>)}
110
124
 
111
- {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
125
+ {!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
112
126
 
113
- <react_native_1.TouchableOpacity style={[
114
- styles.button,
115
- { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius },
116
- (question.isRequired && !selectedChoice) && styles.buttonDisabled,
117
- ]} onPress={handleNext} activeOpacity={0.8}>
118
- <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
119
- {isLastQuestion ? 'Submit' : 'Next'}
120
- </react_native_1.Text>
121
- </react_native_1.TouchableOpacity>
127
+ {!embedded && (<react_native_1.TouchableOpacity style={[
128
+ styles.button,
129
+ { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius },
130
+ (question.isRequired && !selectedChoice) && styles.buttonDisabled,
131
+ ]} onPress={handleNext} activeOpacity={0.8}>
132
+ <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
133
+ {(0, XeboStrings_1.actionLabel)(isLastQuestion)}
134
+ </react_native_1.Text>
135
+ </react_native_1.TouchableOpacity>)}
122
136
  </react_native_1.View>);
123
- };
124
- exports.XeboDropdownView = XeboDropdownView;
137
+ });
125
138
  const styles = react_native_1.StyleSheet.create({
126
139
  container: {
127
140
  paddingHorizontal: 20,
128
141
  paddingTop: 16,
129
- paddingBottom: 24,
142
+ paddingBottom: 10,
130
143
  },
131
144
  title: {
132
145
  fontSize: 18,
@@ -1 +1 @@
1
- {"version":3,"file":"XeboIntroView.d.ts","sourceRoot":"","sources":["../../src/components/XeboIntroView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,UAAU,KAAK;IACb,SAAS,EAAE,cAAc,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA4BzC,CAAC"}
1
+ {"version":3,"file":"XeboIntroView.d.ts","sourceRoot":"","sources":["../../src/components/XeboIntroView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,UAAU,KAAK;IACb,SAAS,EAAE,cAAc,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA4BzC,CAAC"}
@@ -7,11 +7,12 @@ exports.XeboIntroView = void 0;
7
7
  const react_1 = __importDefault(require("react"));
8
8
  const react_native_1 = require("react-native");
9
9
  const XeboTheme_1 = require("../theme/XeboTheme");
10
+ const XeboRtl_1 = require("../i18n/XeboRtl");
10
11
  const XeboIntroView = ({ introPage, onStart }) => {
11
12
  const theme = (0, XeboTheme_1.getTheme)();
12
13
  return (<react_native_1.View style={styles.outer}>
13
14
  {!!introPage.content && (<react_native_1.ScrollView style={styles.scroll} showsVerticalScrollIndicator={false} contentContainerStyle={styles.scrollContent}>
14
- <react_native_1.Text style={[styles.content, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
15
+ <react_native_1.Text style={[styles.content, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
15
16
  {introPage.content}
16
17
  </react_native_1.Text>
17
18
  </react_native_1.ScrollView>)}
@@ -28,7 +29,7 @@ const styles = react_native_1.StyleSheet.create({
28
29
  outer: {
29
30
  paddingHorizontal: 20,
30
31
  paddingTop: 8,
31
- paddingBottom: 24,
32
+ paddingBottom: 10,
32
33
  },
33
34
  scroll: {
34
35
  maxHeight: 220,
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { XeboLanguagePageModel } from '../models/XeboLanguageModels';
3
+ interface Props {
4
+ page: XeboLanguagePageModel;
5
+ selectedLangKey: string | null;
6
+ busy: boolean;
7
+ onSelect: (langKey: string) => void;
8
+ }
9
+ export declare const XeboLanguageView: React.FC<Props>;
10
+ export {};
11
+ //# sourceMappingURL=XeboLanguageView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"XeboLanguageView.d.ts","sourceRoot":"","sources":["../../src/components/XeboLanguageView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,UAAU,KAAK;IACb,IAAI,EAAE,qBAAqB,CAAC;IAC5B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAGD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA+D5C,CAAC"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.XeboLanguageView = void 0;
7
+ const react_1 = __importDefault(require("react"));
8
+ const react_native_1 = require("react-native");
9
+ const XeboTheme_1 = require("../theme/XeboTheme");
10
+ // Skip lives in the modal header, so this page only renders the language choices.
11
+ const XeboLanguageView = ({ page, selectedLangKey, busy, onSelect, }) => {
12
+ const theme = (0, XeboTheme_1.getTheme)();
13
+ return (<react_native_1.View style={styles.container}>
14
+ <react_native_1.ScrollView style={styles.prompts} showsVerticalScrollIndicator={false}>
15
+ {page.prompts.map(prompt => (<react_native_1.Text key={`${prompt.langKey}-${prompt.text}`} style={[
16
+ styles.prompt,
17
+ { color: theme.textColor, fontFamily: theme.fontFamily },
18
+ prompt.direction === 'rtl' && styles.promptRtl,
19
+ ]}>
20
+ {prompt.text}
21
+ </react_native_1.Text>))}
22
+ </react_native_1.ScrollView>
23
+
24
+ <react_native_1.View style={styles.buttons}>
25
+ {page.options.map(option => {
26
+ const selected = selectedLangKey === option.langKey;
27
+ const dimmed = busy && !selected;
28
+ return (<react_native_1.TouchableOpacity key={option.langKey} style={[
29
+ styles.button,
30
+ {
31
+ backgroundColor: selected ? theme.primaryColor : 'transparent',
32
+ borderColor: selected ? theme.primaryColor : '#E5E7EB',
33
+ borderRadius: theme.cornerRadius,
34
+ opacity: dimmed ? 0.4 : 1,
35
+ },
36
+ ]} onPress={() => onSelect(option.langKey)} disabled={busy} activeOpacity={0.8}>
37
+ <react_native_1.Text style={[
38
+ styles.buttonText,
39
+ {
40
+ color: selected ? '#FFFFFF' : theme.textColor,
41
+ fontFamily: theme.fontFamily,
42
+ },
43
+ option.direction === 'rtl' && styles.buttonTextRtl,
44
+ ]}>
45
+ {option.nativeText || option.name}
46
+ </react_native_1.Text>
47
+ </react_native_1.TouchableOpacity>);
48
+ })}
49
+ </react_native_1.View>
50
+ </react_native_1.View>);
51
+ };
52
+ exports.XeboLanguageView = XeboLanguageView;
53
+ const styles = react_native_1.StyleSheet.create({
54
+ container: {
55
+ flex: 1,
56
+ paddingHorizontal: 20,
57
+ paddingTop: 8,
58
+ paddingBottom: 8,
59
+ },
60
+ prompts: {
61
+ flexGrow: 0,
62
+ marginBottom: 16,
63
+ },
64
+ prompt: {
65
+ fontSize: 16,
66
+ fontWeight: '600',
67
+ lineHeight: 24,
68
+ marginBottom: 6,
69
+ },
70
+ promptRtl: {
71
+ textAlign: 'right',
72
+ writingDirection: 'rtl',
73
+ },
74
+ buttons: {
75
+ flexShrink: 1,
76
+ },
77
+ button: {
78
+ borderWidth: 1.5,
79
+ paddingVertical: 14,
80
+ alignItems: 'center',
81
+ marginBottom: 10,
82
+ },
83
+ buttonText: {
84
+ fontSize: 16,
85
+ fontWeight: '600',
86
+ },
87
+ buttonTextRtl: {
88
+ writingDirection: 'rtl',
89
+ },
90
+ });
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
- import { XeboQuestion, XeboAnswer } from '../models/XeboModels';
2
+ import { XeboQuestion, XeboAnswer, XeboQuestionHandle } from '../models/XeboModels';
3
3
  interface Props {
4
4
  question: XeboQuestion;
5
5
  isLastQuestion: boolean;
6
6
  onAnswer: (answer: XeboAnswer) => void;
7
+ /** Shown with other questions on one page: no own button, sized to content. */
8
+ embedded?: boolean;
7
9
  }
8
- export declare const XeboMultiNPSView: React.FC<Props>;
10
+ export declare const XeboMultiNPSView: React.ForwardRefExoticComponent<Props & React.RefAttributes<XeboQuestionHandle>>;
9
11
  export {};
10
12
  //# sourceMappingURL=XeboMultiNPSView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"XeboMultiNPSView.d.ts","sourceRoot":"","sources":["../../src/components/XeboMultiNPSView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAShD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGhE,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACxC;AAqBD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAwG5C,CAAC"}
1
+ {"version":3,"file":"XeboMultiNPSView.d.ts","sourceRoot":"","sources":["../../src/components/XeboMultiNPSView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AASjF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAmB,MAAM,sBAAsB,CAAC;AAKrG,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAqBD,eAAO,MAAM,gBAAgB,kFAoH3B,CAAC"}
@@ -36,7 +36,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.XeboMultiNPSView = void 0;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const react_native_1 = require("react-native");
39
+ const XeboModels_1 = require("../models/XeboModels");
39
40
  const XeboTheme_1 = require("../theme/XeboTheme");
41
+ const XeboStrings_1 = require("../i18n/XeboStrings");
42
+ const XeboRtl_1 = require("../i18n/XeboRtl");
40
43
  const DETRACTOR_COLOR = '#F24236';
41
44
  const PASSIVE_COLOR = '#FFC208';
42
45
  const PROMOTER_COLOR = '#2ECC70';
@@ -57,11 +60,11 @@ function isColorDark(hex) {
57
60
  const b = parseInt(m[3], 16) / 255;
58
61
  return 0.299 * r + 0.587 * g + 0.114 * b < 0.5;
59
62
  }
60
- const XeboMultiNPSView = ({ question, isLastQuestion, onAnswer }) => {
63
+ exports.XeboMultiNPSView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, embedded }, ref) => {
61
64
  var _a;
62
65
  const theme = (0, XeboTheme_1.getTheme)();
63
66
  const rows = (_a = question.options) !== null && _a !== void 0 ? _a : [];
64
- const [scores, setScores] = (0, react_1.useState)({});
67
+ const [scores, setScores] = (0, react_1.useState)(() => (0, XeboModels_1.scaleIndexByRow)(question));
65
68
  const [error, setError] = (0, react_1.useState)('');
66
69
  const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
67
70
  const shake = () => {
@@ -76,13 +79,13 @@ const XeboMultiNPSView = ({ question, isLastQuestion, onAnswer }) => {
76
79
  setScores(prev => (Object.assign(Object.assign({}, prev), { [rowId]: score })));
77
80
  setError('');
78
81
  };
79
- const handleNext = () => {
82
+ const collect = () => {
80
83
  if (question.isRequired && rows.some(r => scores[r.id] === undefined)) {
81
- setError('Please rate all items.');
84
+ setError((0, XeboStrings_1.requiredMessage)(question, 'Please rate all items.'));
82
85
  shake();
83
- return;
86
+ return null;
84
87
  }
85
- onAnswer({
88
+ return {
86
89
  questionId: question.id,
87
90
  value: rows
88
91
  .filter(r => scores[r.id] !== undefined)
@@ -93,19 +96,25 @@ const XeboMultiNPSView = ({ question, isLastQuestion, onAnswer }) => {
93
96
  colId: ((_c = (_b = (_a = question.columns) === null || _a === void 0 ? void 0 : _a[scores[r.id]]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : scores[r.id].toString()),
94
97
  });
95
98
  }),
96
- });
99
+ };
100
+ };
101
+ (0, react_1.useImperativeHandle)(ref, () => ({ collect }));
102
+ const handleNext = () => {
103
+ const answer = collect();
104
+ if (answer)
105
+ onAnswer(answer);
97
106
  };
98
- return (<react_native_1.View style={styles.container}>
99
- <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
107
+ return (<react_native_1.View style={[styles.container, embedded && styles.embedded]}>
108
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
100
109
  {question.title}
101
110
  </react_native_1.Text>
102
- {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
111
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
103
112
  {question.subtitle}
104
113
  </react_native_1.Text>)}
105
114
 
106
- <react_native_1.ScrollView style={styles.scroll} showsVerticalScrollIndicator={false}>
115
+ <react_native_1.ScrollView style={[styles.scroll, embedded && styles.embedded]} scrollEnabled={!embedded} showsVerticalScrollIndicator={false}>
107
116
  {rows.map(row => (<react_native_1.View key={row.id} style={styles.rowWrap}>
108
- <react_native_1.Text style={[styles.rowLabel, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
117
+ <react_native_1.Text style={[styles.rowLabel, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
109
118
  {row.text}
110
119
  </react_native_1.Text>
111
120
  {/* Single-row NPS scale with always-visible category colors */}
@@ -133,20 +142,20 @@ const XeboMultiNPSView = ({ question, isLastQuestion, onAnswer }) => {
133
142
  </react_native_1.View>))}
134
143
  </react_native_1.ScrollView>
135
144
 
136
- {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
145
+ {!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
137
146
 
138
- <react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
139
- <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleNext} activeOpacity={0.8}>
140
- <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
141
- {isLastQuestion ? 'Submit' : 'Next'}
142
- </react_native_1.Text>
143
- </react_native_1.TouchableOpacity>
144
- </react_native_1.Animated.View>
147
+ {!embedded && (<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
148
+ <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleNext} activeOpacity={0.8}>
149
+ <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
150
+ {(0, XeboStrings_1.actionLabel)(isLastQuestion)}
151
+ </react_native_1.Text>
152
+ </react_native_1.TouchableOpacity>
153
+ </react_native_1.Animated.View>)}
145
154
  </react_native_1.View>);
146
- };
147
- exports.XeboMultiNPSView = XeboMultiNPSView;
155
+ });
148
156
  const styles = react_native_1.StyleSheet.create({
149
- container: { flex: 1, paddingHorizontal: 20, paddingTop: 16, paddingBottom: 24 },
157
+ container: { flex: 1, paddingHorizontal: 20, paddingTop: 16, paddingBottom: 10 },
158
+ embedded: { flex: 0 },
150
159
  title: { fontSize: 18, fontWeight: '700', marginBottom: 6 },
151
160
  subtitle: { fontSize: 14, opacity: 0.6, marginBottom: 16 },
152
161
  scroll: { flex: 1, minHeight: 0, marginBottom: 12 },
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
- import { XeboQuestion, XeboAnswer } from '../models/XeboModels';
2
+ import { XeboQuestion, XeboAnswer, XeboQuestionHandle } from '../models/XeboModels';
3
3
  interface Props {
4
4
  question: XeboQuestion;
5
5
  isLastQuestion: boolean;
6
6
  onAnswer: (answer: XeboAnswer) => void;
7
+ /** Shown with other questions on one page: no own button, sized to content. */
8
+ embedded?: boolean;
7
9
  }
8
- export declare const XeboMultiRatingView: React.FC<Props>;
10
+ export declare const XeboMultiRatingView: React.ForwardRefExoticComponent<Props & React.RefAttributes<XeboQuestionHandle>>;
9
11
  export {};
10
12
  //# sourceMappingURL=XeboMultiRatingView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"XeboMultiRatingView.d.ts","sourceRoot":"","sources":["../../src/components/XeboMultiRatingView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAShD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGhE,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CA2H/C,CAAC"}
1
+ {"version":3,"file":"XeboMultiRatingView.d.ts","sourceRoot":"","sources":["../../src/components/XeboMultiRatingView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AASjF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,kBAAkB,EAAmB,MAAM,sBAAsB,CAAC;AAKrG,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;IACvC,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,mBAAmB,kFAuI9B,CAAC"}
@@ -36,15 +36,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.XeboMultiRatingView = void 0;
37
37
  const react_1 = __importStar(require("react"));
38
38
  const react_native_1 = require("react-native");
39
+ const XeboModels_1 = require("../models/XeboModels");
39
40
  const XeboTheme_1 = require("../theme/XeboTheme");
40
- const XeboMultiRatingView = ({ question, isLastQuestion, onAnswer }) => {
41
+ const XeboStrings_1 = require("../i18n/XeboStrings");
42
+ const XeboRtl_1 = require("../i18n/XeboRtl");
43
+ exports.XeboMultiRatingView = (0, react_1.forwardRef)(({ question, isLastQuestion, onAnswer, embedded }, ref) => {
41
44
  var _a, _b, _c, _d, _e;
42
45
  const theme = (0, XeboTheme_1.getTheme)();
43
46
  const rows = (_a = question.options) !== null && _a !== void 0 ? _a : [];
44
47
  const totalSteps = (_c = (_b = question.columns) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 5;
45
48
  const ratingColor = (_d = question.ratingColor) !== null && _d !== void 0 ? _d : theme.primaryColor;
46
49
  const ratingStyle = (_e = question.ratingStyle) !== null && _e !== void 0 ? _e : 'star';
47
- const [ratings, setRatings] = (0, react_1.useState)({});
50
+ const [ratings, setRatings] = (0, react_1.useState)(() => (0, XeboModels_1.scaleIndexByRow)(question));
48
51
  const [error, setError] = (0, react_1.useState)('');
49
52
  const shakeAnim = (0, react_1.useRef)(new react_native_1.Animated.Value(0)).current;
50
53
  const shake = () => {
@@ -60,13 +63,13 @@ const XeboMultiRatingView = ({ question, isLastQuestion, onAnswer }) => {
60
63
  setError('');
61
64
  };
62
65
  const isCumulative = ratingStyle === 'star' || ratingStyle === 'heart';
63
- const handleNext = () => {
66
+ const collect = () => {
64
67
  if (question.isRequired && rows.some(r => ratings[r.id] === undefined)) {
65
- setError('Please rate all items.');
68
+ setError((0, XeboStrings_1.requiredMessage)(question, 'Please rate all items.'));
66
69
  shake();
67
- return;
70
+ return null;
68
71
  }
69
- onAnswer({
72
+ return {
70
73
  questionId: question.id,
71
74
  value: rows
72
75
  .filter(r => ratings[r.id] !== undefined)
@@ -77,20 +80,26 @@ const XeboMultiRatingView = ({ question, isLastQuestion, onAnswer }) => {
77
80
  colId: (_c = (_b = (_a = question.columns) === null || _a === void 0 ? void 0 : _a[ratings[r.id]]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : ratings[r.id].toString(),
78
81
  });
79
82
  }),
80
- });
83
+ };
84
+ };
85
+ (0, react_1.useImperativeHandle)(ref, () => ({ collect }));
86
+ const handleNext = () => {
87
+ const answer = collect();
88
+ if (answer)
89
+ onAnswer(answer);
81
90
  };
82
91
  const starIcon = (filled) => ratingStyle === 'heart' ? (filled ? '♥' : '♡') : filled ? '★' : '☆';
83
92
  return (<react_native_1.View style={styles.container}>
84
- <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
93
+ <react_native_1.Text style={[styles.title, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
85
94
  {question.title}
86
95
  </react_native_1.Text>
87
- {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
96
+ {!!question.subtitle && (<react_native_1.Text style={[styles.subtitle, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
88
97
  {question.subtitle}
89
98
  </react_native_1.Text>)}
90
99
 
91
- <react_native_1.ScrollView style={styles.scroll} showsVerticalScrollIndicator={false}>
100
+ <react_native_1.ScrollView style={[styles.scroll, embedded && styles.embeddedScroll]} scrollEnabled={!embedded} showsVerticalScrollIndicator={false}>
92
101
  {rows.map(row => (<react_native_1.View key={row.id} style={styles.rowWrap}>
93
- <react_native_1.Text style={[styles.rowLabel, { color: theme.textColor, fontFamily: theme.fontFamily }]}>
102
+ <react_native_1.Text style={[styles.rowLabel, { color: theme.textColor, fontFamily: theme.fontFamily }, (0, XeboRtl_1.rtlText)()]}>
94
103
  {row.text}
95
104
  </react_native_1.Text>
96
105
  <react_native_1.View style={styles.iconsRow}>
@@ -118,23 +127,23 @@ const XeboMultiRatingView = ({ question, isLastQuestion, onAnswer }) => {
118
127
  </react_native_1.View>))}
119
128
  </react_native_1.ScrollView>
120
129
 
121
- {!!error && <react_native_1.Text style={styles.errorText}>{error}</react_native_1.Text>}
130
+ {!!error && <react_native_1.Text style={[styles.errorText, (0, XeboRtl_1.rtlText)()]}>{error}</react_native_1.Text>}
122
131
 
123
- <react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
124
- <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleNext} activeOpacity={0.8}>
125
- <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
126
- {isLastQuestion ? 'Submit' : 'Next'}
127
- </react_native_1.Text>
128
- </react_native_1.TouchableOpacity>
129
- </react_native_1.Animated.View>
132
+ {!embedded && (<react_native_1.Animated.View style={{ transform: [{ translateX: shakeAnim }] }}>
133
+ <react_native_1.TouchableOpacity style={[styles.button, { backgroundColor: theme.primaryColor, borderRadius: theme.cornerRadius }]} onPress={handleNext} activeOpacity={0.8}>
134
+ <react_native_1.Text style={[styles.buttonText, { fontFamily: theme.fontFamily }]}>
135
+ {(0, XeboStrings_1.actionLabel)(isLastQuestion)}
136
+ </react_native_1.Text>
137
+ </react_native_1.TouchableOpacity>
138
+ </react_native_1.Animated.View>)}
130
139
  </react_native_1.View>);
131
- };
132
- exports.XeboMultiRatingView = XeboMultiRatingView;
140
+ });
133
141
  const styles = react_native_1.StyleSheet.create({
134
- container: { paddingHorizontal: 20, paddingTop: 16, paddingBottom: 24 },
142
+ container: { paddingHorizontal: 20, paddingTop: 16, paddingBottom: 10 },
135
143
  title: { fontSize: 18, fontWeight: '700', marginBottom: 16 },
136
144
  subtitle: { fontSize: 14, opacity: 0.6, marginBottom: 16 },
137
145
  scroll: { maxHeight: 280, marginBottom: 12 },
146
+ embeddedScroll: { maxHeight: undefined },
138
147
  rowWrap: { marginBottom: 24 },
139
148
  rowLabel: { fontSize: 15, fontWeight: '500', marginBottom: 8 },
140
149
  iconsRow: { flexDirection: 'row', flexWrap: 'nowrap', justifyContent: 'space-between' },
@@ -1,10 +1,14 @@
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;
7
11
  }
8
- export declare const XeboMultipleChoiceView: React.FC<Props>;
12
+ export declare const XeboMultipleChoiceView: React.ForwardRefExoticComponent<Props & React.RefAttributes<XeboQuestionHandle>>;
9
13
  export {};
10
14
  //# sourceMappingURL=XeboMultipleChoiceView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"XeboMultipleChoiceView.d.ts","sourceRoot":"","sources":["../../src/components/XeboMultipleChoiceView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAShD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAc,MAAM,sBAAsB,CAAC;AAG5E,UAAU,KAAK;IACb,QAAQ,EAAE,YAAY,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAC;CACxC;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAqGlD,CAAC"}
1
+ {"version":3,"file":"XeboMultipleChoiceView.d.ts","sourceRoot":"","sources":["../../src/components/XeboMultipleChoiceView.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;CACpB;AAED,eAAO,MAAM,sBAAsB,kFAkHjC,CAAC"}