@velion-la/onboarding-sdk-react-native 1.0.0-beta.7 → 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 (62) hide show
  1. package/lib/commonjs/core/VelionOnboarding.js +3 -0
  2. package/lib/commonjs/core/VelionOnboarding.js.map +1 -1
  3. package/lib/commonjs/i18n/strings/en.js +11 -0
  4. package/lib/commonjs/i18n/strings/en.js.map +1 -1
  5. package/lib/commonjs/i18n/strings/es.js +11 -0
  6. package/lib/commonjs/i18n/strings/es.js.map +1 -1
  7. package/lib/commonjs/index.js +12 -0
  8. package/lib/commonjs/index.js.map +1 -1
  9. package/lib/commonjs/steps/EconomicActivityStep.js +214 -0
  10. package/lib/commonjs/steps/EconomicActivityStep.js.map +1 -0
  11. package/lib/commonjs/types/index.js +16 -0
  12. package/lib/commonjs/types/index.js.map +1 -1
  13. package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js +162 -0
  14. package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js.map +1 -0
  15. package/lib/commonjs/ui/primitives/index.js +13 -0
  16. package/lib/commonjs/ui/primitives/index.js.map +1 -1
  17. package/lib/commonjs/ui/primitives/searchableSingleSelectFilter.js +31 -0
  18. package/lib/commonjs/ui/primitives/searchableSingleSelectFilter.js.map +1 -0
  19. package/lib/module/core/VelionOnboarding.js +3 -0
  20. package/lib/module/core/VelionOnboarding.js.map +1 -1
  21. package/lib/module/i18n/strings/en.js +11 -0
  22. package/lib/module/i18n/strings/en.js.map +1 -1
  23. package/lib/module/i18n/strings/es.js +11 -0
  24. package/lib/module/i18n/strings/es.js.map +1 -1
  25. package/lib/module/index.js +1 -1
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/steps/EconomicActivityStep.js +209 -0
  28. package/lib/module/steps/EconomicActivityStep.js.map +1 -0
  29. package/lib/module/types/index.js +19 -0
  30. package/lib/module/types/index.js.map +1 -1
  31. package/lib/module/ui/primitives/SearchableSingleSelectList.js +153 -0
  32. package/lib/module/ui/primitives/SearchableSingleSelectList.js.map +1 -0
  33. package/lib/module/ui/primitives/index.js +1 -0
  34. package/lib/module/ui/primitives/index.js.map +1 -1
  35. package/lib/module/ui/primitives/searchableSingleSelectFilter.js +27 -0
  36. package/lib/module/ui/primitives/searchableSingleSelectFilter.js.map +1 -0
  37. package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -1
  38. package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
  39. package/lib/typescript/i18n/strings/es.d.ts +11 -0
  40. package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
  41. package/lib/typescript/index.d.ts +2 -2
  42. package/lib/typescript/index.d.ts.map +1 -1
  43. package/lib/typescript/steps/EconomicActivityStep.d.ts +29 -0
  44. package/lib/typescript/steps/EconomicActivityStep.d.ts.map +1 -0
  45. package/lib/typescript/types/index.d.ts +31 -1
  46. package/lib/typescript/types/index.d.ts.map +1 -1
  47. package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts +33 -0
  48. package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts.map +1 -0
  49. package/lib/typescript/ui/primitives/index.d.ts +1 -0
  50. package/lib/typescript/ui/primitives/index.d.ts.map +1 -1
  51. package/lib/typescript/ui/primitives/searchableSingleSelectFilter.d.ts +25 -0
  52. package/lib/typescript/ui/primitives/searchableSingleSelectFilter.d.ts.map +1 -0
  53. package/package.json +1 -1
  54. package/src/core/VelionOnboarding.ts +3 -0
  55. package/src/i18n/strings/en.ts +12 -0
  56. package/src/i18n/strings/es.ts +12 -0
  57. package/src/index.ts +7 -0
  58. package/src/steps/EconomicActivityStep.tsx +230 -0
  59. package/src/types/index.ts +34 -0
  60. package/src/ui/primitives/SearchableSingleSelectList.tsx +195 -0
  61. package/src/ui/primitives/index.ts +6 -0
  62. 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[];
@@ -1147,6 +1168,19 @@ export interface SwornDeclarationPayload {
1147
1168
  is_ocde: boolean;
1148
1169
  }
1149
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
+
1150
1184
  /** POST /sessions/:id/contact/email — SubmitEmailContactRequestDto. */
1151
1185
  export interface EmailContactPayload {
1152
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
+ }