@velion-la/onboarding-sdk-react-native 1.0.0-beta.6 → 1.0.0-beta.8

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 (76) hide show
  1. package/lib/commonjs/core/VelionOnboarding.js +72 -6
  2. package/lib/commonjs/core/VelionOnboarding.js.map +1 -1
  3. package/lib/commonjs/core/retryStepCopy.js +43 -0
  4. package/lib/commonjs/core/retryStepCopy.js.map +1 -0
  5. package/lib/commonjs/i18n/strings/en.js +38 -0
  6. package/lib/commonjs/i18n/strings/en.js.map +1 -1
  7. package/lib/commonjs/i18n/strings/es.js +38 -0
  8. package/lib/commonjs/i18n/strings/es.js.map +1 -1
  9. package/lib/commonjs/index.js +12 -0
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/commonjs/steps/EconomicActivityStep.js +214 -0
  12. package/lib/commonjs/steps/EconomicActivityStep.js.map +1 -0
  13. package/lib/commonjs/steps/FaceMatchStep.js +16 -13
  14. package/lib/commonjs/steps/FaceMatchStep.js.map +1 -1
  15. package/lib/commonjs/types/index.js +37 -5
  16. package/lib/commonjs/types/index.js.map +1 -1
  17. package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js +162 -0
  18. package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js.map +1 -0
  19. package/lib/commonjs/ui/primitives/index.js +13 -0
  20. package/lib/commonjs/ui/primitives/index.js.map +1 -1
  21. package/lib/commonjs/ui/primitives/searchableSingleSelectFilter.js +31 -0
  22. package/lib/commonjs/ui/primitives/searchableSingleSelectFilter.js.map +1 -0
  23. package/lib/module/core/VelionOnboarding.js +72 -6
  24. package/lib/module/core/VelionOnboarding.js.map +1 -1
  25. package/lib/module/core/retryStepCopy.js +39 -0
  26. package/lib/module/core/retryStepCopy.js.map +1 -0
  27. package/lib/module/i18n/strings/en.js +38 -0
  28. package/lib/module/i18n/strings/en.js.map +1 -1
  29. package/lib/module/i18n/strings/es.js +38 -0
  30. package/lib/module/i18n/strings/es.js.map +1 -1
  31. package/lib/module/index.js +1 -1
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/module/steps/EconomicActivityStep.js +209 -0
  34. package/lib/module/steps/EconomicActivityStep.js.map +1 -0
  35. package/lib/module/steps/FaceMatchStep.js +16 -13
  36. package/lib/module/steps/FaceMatchStep.js.map +1 -1
  37. package/lib/module/types/index.js +41 -5
  38. package/lib/module/types/index.js.map +1 -1
  39. package/lib/module/ui/primitives/SearchableSingleSelectList.js +153 -0
  40. package/lib/module/ui/primitives/SearchableSingleSelectList.js.map +1 -0
  41. package/lib/module/ui/primitives/index.js +1 -0
  42. package/lib/module/ui/primitives/index.js.map +1 -1
  43. package/lib/module/ui/primitives/searchableSingleSelectFilter.js +27 -0
  44. package/lib/module/ui/primitives/searchableSingleSelectFilter.js.map +1 -0
  45. package/lib/typescript/core/VelionOnboarding.d.ts +15 -4
  46. package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -1
  47. package/lib/typescript/core/retryStepCopy.d.ts +27 -0
  48. package/lib/typescript/core/retryStepCopy.d.ts.map +1 -0
  49. package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
  50. package/lib/typescript/i18n/strings/es.d.ts +35 -0
  51. package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
  52. package/lib/typescript/index.d.ts +2 -2
  53. package/lib/typescript/index.d.ts.map +1 -1
  54. package/lib/typescript/steps/EconomicActivityStep.d.ts +29 -0
  55. package/lib/typescript/steps/EconomicActivityStep.d.ts.map +1 -0
  56. package/lib/typescript/steps/FaceMatchStep.d.ts.map +1 -1
  57. package/lib/typescript/types/index.d.ts +65 -12
  58. package/lib/typescript/types/index.d.ts.map +1 -1
  59. package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts +33 -0
  60. package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts.map +1 -0
  61. package/lib/typescript/ui/primitives/index.d.ts +1 -0
  62. package/lib/typescript/ui/primitives/index.d.ts.map +1 -1
  63. package/lib/typescript/ui/primitives/searchableSingleSelectFilter.d.ts +25 -0
  64. package/lib/typescript/ui/primitives/searchableSingleSelectFilter.d.ts.map +1 -0
  65. package/package.json +1 -1
  66. package/src/core/VelionOnboarding.ts +83 -8
  67. package/src/core/retryStepCopy.ts +54 -0
  68. package/src/i18n/strings/en.ts +44 -0
  69. package/src/i18n/strings/es.ts +44 -0
  70. package/src/index.ts +8 -0
  71. package/src/steps/EconomicActivityStep.tsx +230 -0
  72. package/src/steps/FaceMatchStep.tsx +18 -19
  73. package/src/types/index.ts +73 -11
  74. package/src/ui/primitives/SearchableSingleSelectList.tsx +195 -0
  75. package/src/ui/primitives/index.ts +6 -0
  76. package/src/ui/primitives/searchableSingleSelectFilter.ts +38 -0
@@ -22,6 +22,7 @@
22
22
  * - `LEGAL_BASIC_INFO`: Legal-entity identification data (LEGAL only).
23
23
  * - `EMAIL_CONTACT` / `PHONE_CONTACT`: contact collection without OTP.
24
24
  * - `TAX_INFO`, `HUMAN_EXTENDED_INFO`, `LEGAL_EXTENDED_INFO`, `ADDRESS_INFO`, `SWORN_DECLARATION`: form steps.
25
+ * - `ECONOMIC_ACTIVITY_DECLARATION`: pick exactly one economic activity from a searchable list.
25
26
  * - `TERMS_AND_CONDITIONS`: accept configured T&C items.
26
27
  * - `FACE_MATCH`: server-side face comparison after liveness (no user input; SDK waits).
27
28
  */
@@ -38,6 +39,7 @@ export type OnboardingStep =
38
39
  | 'LEGAL_EXTENDED_INFO'
39
40
  | 'ADDRESS_INFO'
40
41
  | 'SWORN_DECLARATION'
42
+ | 'ECONOMIC_ACTIVITY_DECLARATION'
41
43
  | 'DOCUMENTS_OCR'
42
44
  | 'LIVENESS_MATCH'
43
45
  | 'FACE_MATCH'
@@ -173,6 +175,25 @@ export interface SwornDeclarationStepConfig {
173
175
  on_declared_ocde?: string;
174
176
  }
175
177
 
178
+ /**
179
+ * A single selectable economic activity presented in the
180
+ * `ECONOMIC_ACTIVITY_DECLARATION` step. Mirrors the backend `EconomicActivityItem`
181
+ * (`code` + `display_name`); `code` is unique within the list and is what the SDK
182
+ * submits. There is no global catalog — each workflow declares its own list.
183
+ */
184
+ export interface EconomicActivityItem {
185
+ /** Machine-readable activity code (e.g. an AFIP/CLAE code) — unique within the list. */
186
+ code: string;
187
+ /** Human-readable label shown to the user. */
188
+ display_name: string;
189
+ }
190
+
191
+ /** STEP config for ECONOMIC_ACTIVITY_DECLARATION (`current_step.config`). */
192
+ export interface EconomicActivityStepConfig {
193
+ /** Selectable activities; always non-empty when the step is active. */
194
+ items?: EconomicActivityItem[];
195
+ }
196
+
176
197
  /** STEP config for DOCUMENTS_OCR. */
177
198
  export interface DocumentsOcrStepConfig {
178
199
  country_allow?: string[];
@@ -469,6 +490,21 @@ export type VelionSessionDeclinedReasonTexts = Record<
469
490
  VelionSessionDeclinedReasonMessages
470
491
  >;
471
492
 
493
+ /**
494
+ * Per-step overrides for the retry dialog shown when the backend emits a
495
+ * `ROUTING_COMMAND / RETRY_STEP` (the step failed but the retry quota is not
496
+ * exhausted). Keyed by step code (e.g. `LIVENESS_MATCH`, `DOCUMENTS_OCR`).
497
+ * Unspecified steps fall back to SDK per-step defaults, then generic copy.
498
+ *
499
+ * Note: the SDK intentionally ignores the backend `reason` for this dialog —
500
+ * it is a diagnostic string (e.g. `"STEP_FAILED_RETRY_ALLOWED (attempt 1/3)"`),
501
+ * not user-facing localized copy. The copy is derived from the step instead.
502
+ */
503
+ export type VelionRetryStepTexts = Record<
504
+ string,
505
+ VelionSessionDeclinedReasonMessages
506
+ >;
507
+
472
508
  // ─────────────────────────────────────────────────────────────────────────────
473
509
  // CALLBACKS
474
510
  // ─────────────────────────────────────────────────────────────────────────────
@@ -533,11 +569,11 @@ export interface VelionCallbacks {
533
569
  onFinalResultScreenDismiss?: () => void;
534
570
 
535
571
  /**
536
- * Fires when the user leaves the flow without a verdict — currently only when
537
- * they tap "back" on the first reversible step (`ROUTING_COMMAND / BACK_EXIT`).
538
- * The SDK has already torn down its UI; the host should dismiss the SDK screen
539
- * and return the user to the previous context. Neither `onSuccess` nor
540
- * `onError` fires in this case.
572
+ * Fires when the user leaves the flow without a verdict — either by tapping
573
+ * "back" on the first reversible step (`BACK_EXIT`) or "Cancel" on the retry
574
+ * dialog after a `RETRY_STEP` (`RETRY_CANCELLED`). The SDK has already torn
575
+ * down its UI; the host should dismiss the SDK screen and return the user to
576
+ * the previous context. Neither `onSuccess` nor `onError` fires in this case.
541
577
  *
542
578
  * @param exit - Why the flow ended and, when available, the step exited from.
543
579
  */
@@ -670,6 +706,13 @@ export interface VelionConfig extends VelionCallbacks {
670
706
  */
671
707
  sessionDeclinedReasonTexts?: VelionSessionDeclinedReasonTexts;
672
708
 
709
+ /**
710
+ * Optional copy for the retry dialog (`ROUTING_COMMAND / RETRY_STEP`), keyed by
711
+ * step code (e.g. `LIVENESS_MATCH`). Merged with SDK per-step defaults for
712
+ * `locale` `en` / `es`; unspecified steps fall back to generic retry copy.
713
+ */
714
+ retryStepTexts?: VelionRetryStepTexts;
715
+
673
716
  /**
674
717
  * When `true` (default), shows the Velion preparation screen (face icon, tips,
675
718
  * "Start verification") before connecting to Iris. When `false`, skips it and
@@ -885,15 +928,21 @@ export interface SessionState {
885
928
  /**
886
929
  * Emitted when the user leaves the onboarding flow without a backend verdict.
887
930
  *
888
- * Currently the only trigger is `BACK_EXIT`: the user tapped "back" on the
889
- * first reversible step, where there is no earlier step to return to, so the
890
- * backend instructs the SDK to exit. This is neither success nor error — the
891
- * host should dismiss the SDK screen and return the user to wherever they came
892
- * from. See {@link VelionCallbacks.onExit}.
931
+ * Triggers:
932
+ * - `BACK_EXIT`: the user tapped "back" on the first reversible step, where
933
+ * there is no earlier step to return to, so the backend instructs the SDK to
934
+ * exit.
935
+ * - `RETRY_CANCELLED`: the user tapped "Cancel" on the retry dialog shown after
936
+ * a `ROUTING_COMMAND / RETRY_STEP`. The backend session stays `IN_PROGRESS`
937
+ * (there is no cancellation endpoint); the host may re-open it later via
938
+ * `GET /sessions/:id`.
939
+ *
940
+ * This is neither success nor error — the host should dismiss the SDK screen and
941
+ * return the user to wherever they came from. See {@link VelionCallbacks.onExit}.
893
942
  */
894
943
  export interface OnboardingExit {
895
944
  /** Why the flow ended without a verdict. */
896
- reason: 'BACK_EXIT';
945
+ reason: 'BACK_EXIT' | 'RETRY_CANCELLED';
897
946
  /** The step the user exited from (SSE `step_code`), when the backend provides it. */
898
947
  step?: OnboardingStep;
899
948
  }
@@ -1119,6 +1168,19 @@ export interface SwornDeclarationPayload {
1119
1168
  is_ocde: boolean;
1120
1169
  }
1121
1170
 
1171
+ /**
1172
+ * POST /sessions/:id/economic-activity — EconomicActivitySelectionDto.
1173
+ *
1174
+ * Fire-and-forget on the backend: the POST returns 200 immediately and the Worker
1175
+ * validates `code` asynchronously against the configured items. An invalid code is
1176
+ * reported back over SSE as `RETRY_STEP` (or `SESSION_DECLINED` once retries are
1177
+ * exhausted), not as an HTTP error.
1178
+ */
1179
+ export interface EconomicActivitySelectionPayload {
1180
+ /** `code` of the selected EconomicActivityItem. */
1181
+ code: string;
1182
+ }
1183
+
1122
1184
  /** POST /sessions/:id/contact/email — SubmitEmailContactRequestDto. */
1123
1185
  export interface EmailContactPayload {
1124
1186
  email: string;
@@ -0,0 +1,195 @@
1
+ /**
2
+ * SearchableSingleSelectList — inline searchable list with single selection.
3
+ *
4
+ * Unlike {@link CountrySelect} (a modal combobox), this primitive renders the
5
+ * search field and the option list *inline*, filling the space it's given. The
6
+ * search bar stays fixed at the top while only the `FlatList` scrolls, so it
7
+ * virtualizes large lists without extra work and the keyboard never hides it.
8
+ *
9
+ * Selection semantics:
10
+ * - Exactly one option is selected, identified by its `id`.
11
+ * - A radio indicator + highlight mark the active row.
12
+ * - Search matches `label` OR `sublabel`, case-insensitive, contains.
13
+ *
14
+ * The host is expected to wrap this with its own fixed header (title/subtitle)
15
+ * above and a fixed footer (e.g. a "Continue" button) below, giving the
16
+ * primitive `flex: 1` so the list takes the remaining height.
17
+ */
18
+
19
+ import { useMemo, useState } from 'react';
20
+ import {
21
+ FlatList,
22
+ Pressable,
23
+ StyleSheet,
24
+ Text,
25
+ TextInput,
26
+ View,
27
+ type StyleProp,
28
+ type ViewStyle,
29
+ } from 'react-native';
30
+ import { useTheme, withAlpha } from '../theme';
31
+ import {
32
+ filterSearchableOptions,
33
+ type SearchableListOption,
34
+ } from './searchableSingleSelectFilter';
35
+
36
+ export {
37
+ filterSearchableOptions,
38
+ type SearchableListOption,
39
+ } from './searchableSingleSelectFilter';
40
+
41
+ export interface SearchableSingleSelectListProps {
42
+ items: ReadonlyArray<SearchableListOption>;
43
+ /** Currently-selected `id`, or `null` when nothing is selected. */
44
+ value: string | null;
45
+ onChange: (id: string) => void;
46
+ searchPlaceholder?: string | undefined;
47
+ /** Shown when the query matches no item. */
48
+ emptyText?: string | undefined;
49
+ disabled?: boolean | undefined;
50
+ style?: StyleProp<ViewStyle> | undefined;
51
+ }
52
+
53
+ export function SearchableSingleSelectList({
54
+ items,
55
+ value,
56
+ onChange,
57
+ searchPlaceholder,
58
+ emptyText,
59
+ disabled = false,
60
+ style,
61
+ }: SearchableSingleSelectListProps) {
62
+ const theme = useTheme();
63
+ const [query, setQuery] = useState('');
64
+
65
+ const visible = useMemo(
66
+ () => filterSearchableOptions(items, query),
67
+ [items, query],
68
+ );
69
+
70
+ return (
71
+ <View style={[styles.wrap, style]}>
72
+ <TextInput
73
+ autoCapitalize="none"
74
+ autoCorrect={false}
75
+ editable={!disabled}
76
+ placeholder={searchPlaceholder ?? ''}
77
+ placeholderTextColor={theme.textSecondaryColor}
78
+ value={query}
79
+ onChangeText={setQuery}
80
+ style={[
81
+ styles.search,
82
+ {
83
+ color: theme.textColor,
84
+ backgroundColor: theme.backgroundColor,
85
+ borderColor: theme.borderColor,
86
+ borderRadius: theme.borderRadiusPx,
87
+ },
88
+ ]}
89
+ />
90
+ <FlatList
91
+ data={visible}
92
+ keyExtractor={(item) => item.id}
93
+ keyboardShouldPersistTaps="handled"
94
+ keyboardDismissMode="on-drag"
95
+ style={styles.list}
96
+ contentContainerStyle={visible.length === 0 ? styles.emptyContainer : undefined}
97
+ ListEmptyComponent={
98
+ <Text style={[styles.empty, { color: theme.textSecondaryColor }]}>
99
+ {emptyText ?? ''}
100
+ </Text>
101
+ }
102
+ renderItem={({ item }) => {
103
+ const isSelected = item.id === value;
104
+ return (
105
+ <Pressable
106
+ accessibilityRole="radio"
107
+ accessibilityState={{ selected: isSelected, disabled }}
108
+ disabled={disabled}
109
+ onPress={() => onChange(item.id)}
110
+ style={({ pressed }) => [
111
+ styles.option,
112
+ {
113
+ borderColor: isSelected ? theme.primaryColor : theme.borderColor,
114
+ borderRadius: theme.borderRadiusPx,
115
+ },
116
+ isSelected && {
117
+ backgroundColor: withAlpha(theme.primaryColor, 0.12),
118
+ },
119
+ pressed && {
120
+ backgroundColor: withAlpha(theme.primaryColor, 0.18),
121
+ },
122
+ ]}
123
+ >
124
+ <Text
125
+ numberOfLines={2}
126
+ style={[
127
+ styles.optionLabel,
128
+ {
129
+ color: isSelected ? theme.primaryColor : theme.textColor,
130
+ fontWeight: isSelected ? '600' : '400',
131
+ },
132
+ ]}
133
+ >
134
+ {item.label}
135
+ </Text>
136
+ {item.sublabel ? (
137
+ <Text
138
+ numberOfLines={1}
139
+ style={[styles.optionSublabel, { color: theme.textSecondaryColor }]}
140
+ >
141
+ {item.sublabel}
142
+ </Text>
143
+ ) : null}
144
+ </Pressable>
145
+ );
146
+ }}
147
+ />
148
+ </View>
149
+ );
150
+ }
151
+
152
+ const styles = StyleSheet.create({
153
+ wrap: {
154
+ flex: 1,
155
+ width: '100%',
156
+ },
157
+ search: {
158
+ minHeight: 44,
159
+ paddingHorizontal: 12,
160
+ paddingVertical: 10,
161
+ fontSize: 15,
162
+ borderWidth: 1,
163
+ marginBottom: 8,
164
+ },
165
+ list: {
166
+ flex: 1,
167
+ },
168
+ emptyContainer: {
169
+ flexGrow: 1,
170
+ alignItems: 'center',
171
+ justifyContent: 'center',
172
+ paddingVertical: 32,
173
+ },
174
+ empty: {
175
+ fontSize: 14,
176
+ textAlign: 'center',
177
+ },
178
+ option: {
179
+ flexDirection: 'column',
180
+ justifyContent: 'center',
181
+ minHeight: 52,
182
+ paddingHorizontal: 14,
183
+ paddingVertical: 12,
184
+ marginBottom: 8,
185
+ borderWidth: 1,
186
+ },
187
+ optionLabel: {
188
+ fontSize: 15,
189
+ },
190
+ optionSublabel: {
191
+ fontSize: 12,
192
+ marginTop: 2,
193
+ fontVariant: ['tabular-nums'],
194
+ },
195
+ });
@@ -8,3 +8,9 @@ export { Spinner, type SpinnerProps } from './Spinner';
8
8
  export { Checkbox, type CheckboxProps } from './Checkbox';
9
9
  export { DatePicker, type DatePickerProps } from './DatePicker';
10
10
  export { CountrySelect, type CountrySelectProps } from './CountrySelect';
11
+ export {
12
+ SearchableSingleSelectList,
13
+ filterSearchableOptions,
14
+ type SearchableSingleSelectListProps,
15
+ type SearchableListOption,
16
+ } from './SearchableSingleSelectList';
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Pure search logic for {@link SearchableSingleSelectList}, kept in a JSX-free
3
+ * `.ts` module so it can be unit-tested in the `node` test environment without
4
+ * pulling React Native into the import graph.
5
+ */
6
+
7
+ /** One selectable row. `id` is the value the list reports on selection. */
8
+ export interface SearchableListOption {
9
+ id: string;
10
+ label: string;
11
+ /** Optional secondary line rendered under the label; also matched by search. */
12
+ sublabel?: string | undefined;
13
+ /**
14
+ * Extra search terms folded into matching but never rendered — e.g. an
15
+ * internal activity code the user can search by without it cluttering the row.
16
+ */
17
+ keywords?: string | undefined;
18
+ }
19
+
20
+ /**
21
+ * Filters options by a free-text query: case-insensitive `contains` over the
22
+ * `label`, the (rendered) `sublabel`, and the (hidden) `keywords`. An
23
+ * empty/whitespace query returns the list unchanged (a fresh array — the input
24
+ * is never mutated).
25
+ */
26
+ export function filterSearchableOptions(
27
+ items: ReadonlyArray<SearchableListOption>,
28
+ query: string,
29
+ ): SearchableListOption[] {
30
+ const q = query.trim().toLowerCase();
31
+ if (q.length === 0) return [...items];
32
+ return items.filter((item) => {
33
+ const label = item.label.toLowerCase();
34
+ const sublabel = item.sublabel?.toLowerCase() ?? '';
35
+ const keywords = item.keywords?.toLowerCase() ?? '';
36
+ return label.includes(q) || sublabel.includes(q) || keywords.includes(q);
37
+ });
38
+ }