@velion-la/onboarding-sdk-react-native 1.0.0-beta.7 → 1.0.0-beta.9

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 (99) hide show
  1. package/lib/commonjs/camera/DocumentCapture.js +11 -3
  2. package/lib/commonjs/camera/DocumentCapture.js.map +1 -1
  3. package/lib/commonjs/camera/LivenessCamera.js +18 -3
  4. package/lib/commonjs/camera/LivenessCamera.js.map +1 -1
  5. package/lib/commonjs/camera/MapAddressPicker.js +12 -22
  6. package/lib/commonjs/camera/MapAddressPicker.js.map +1 -1
  7. package/lib/commonjs/core/VelionOnboarding.js +3 -0
  8. package/lib/commonjs/core/VelionOnboarding.js.map +1 -1
  9. package/lib/commonjs/i18n/strings/en.js +11 -0
  10. package/lib/commonjs/i18n/strings/en.js.map +1 -1
  11. package/lib/commonjs/i18n/strings/es.js +11 -0
  12. package/lib/commonjs/i18n/strings/es.js.map +1 -1
  13. package/lib/commonjs/index.js +12 -0
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/steps/EconomicActivityStep.js +214 -0
  16. package/lib/commonjs/steps/EconomicActivityStep.js.map +1 -0
  17. package/lib/commonjs/types/index.js +16 -0
  18. package/lib/commonjs/types/index.js.map +1 -1
  19. package/lib/commonjs/ui/StepShell.js +19 -4
  20. package/lib/commonjs/ui/StepShell.js.map +1 -1
  21. package/lib/commonjs/ui/VelionOnboardingScreen.js +52 -13
  22. package/lib/commonjs/ui/VelionOnboardingScreen.js.map +1 -1
  23. package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js +162 -0
  24. package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js.map +1 -0
  25. package/lib/commonjs/ui/primitives/index.js +13 -0
  26. package/lib/commonjs/ui/primitives/index.js.map +1 -1
  27. package/lib/commonjs/ui/primitives/searchableSingleSelectFilter.js +31 -0
  28. package/lib/commonjs/ui/primitives/searchableSingleSelectFilter.js.map +1 -0
  29. package/lib/commonjs/utils/useSafeAreaInsets.js +41 -0
  30. package/lib/commonjs/utils/useSafeAreaInsets.js.map +1 -0
  31. package/lib/module/camera/DocumentCapture.js +11 -3
  32. package/lib/module/camera/DocumentCapture.js.map +1 -1
  33. package/lib/module/camera/LivenessCamera.js +18 -3
  34. package/lib/module/camera/LivenessCamera.js.map +1 -1
  35. package/lib/module/camera/MapAddressPicker.js +12 -23
  36. package/lib/module/camera/MapAddressPicker.js.map +1 -1
  37. package/lib/module/core/VelionOnboarding.js +3 -0
  38. package/lib/module/core/VelionOnboarding.js.map +1 -1
  39. package/lib/module/i18n/strings/en.js +11 -0
  40. package/lib/module/i18n/strings/en.js.map +1 -1
  41. package/lib/module/i18n/strings/es.js +11 -0
  42. package/lib/module/i18n/strings/es.js.map +1 -1
  43. package/lib/module/index.js +1 -1
  44. package/lib/module/index.js.map +1 -1
  45. package/lib/module/steps/EconomicActivityStep.js +209 -0
  46. package/lib/module/steps/EconomicActivityStep.js.map +1 -0
  47. package/lib/module/types/index.js +19 -0
  48. package/lib/module/types/index.js.map +1 -1
  49. package/lib/module/ui/StepShell.js +19 -4
  50. package/lib/module/ui/StepShell.js.map +1 -1
  51. package/lib/module/ui/VelionOnboardingScreen.js +55 -14
  52. package/lib/module/ui/VelionOnboardingScreen.js.map +1 -1
  53. package/lib/module/ui/primitives/SearchableSingleSelectList.js +153 -0
  54. package/lib/module/ui/primitives/SearchableSingleSelectList.js.map +1 -0
  55. package/lib/module/ui/primitives/index.js +1 -0
  56. package/lib/module/ui/primitives/index.js.map +1 -1
  57. package/lib/module/ui/primitives/searchableSingleSelectFilter.js +27 -0
  58. package/lib/module/ui/primitives/searchableSingleSelectFilter.js.map +1 -0
  59. package/lib/module/utils/useSafeAreaInsets.js +37 -0
  60. package/lib/module/utils/useSafeAreaInsets.js.map +1 -0
  61. package/lib/typescript/camera/DocumentCapture.d.ts.map +1 -1
  62. package/lib/typescript/camera/LivenessCamera.d.ts.map +1 -1
  63. package/lib/typescript/camera/MapAddressPicker.d.ts.map +1 -1
  64. package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -1
  65. package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
  66. package/lib/typescript/i18n/strings/es.d.ts +11 -0
  67. package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
  68. package/lib/typescript/index.d.ts +2 -2
  69. package/lib/typescript/index.d.ts.map +1 -1
  70. package/lib/typescript/steps/EconomicActivityStep.d.ts +29 -0
  71. package/lib/typescript/steps/EconomicActivityStep.d.ts.map +1 -0
  72. package/lib/typescript/types/index.d.ts +31 -1
  73. package/lib/typescript/types/index.d.ts.map +1 -1
  74. package/lib/typescript/ui/StepShell.d.ts.map +1 -1
  75. package/lib/typescript/ui/VelionOnboardingScreen.d.ts.map +1 -1
  76. package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts +33 -0
  77. package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts.map +1 -0
  78. package/lib/typescript/ui/primitives/index.d.ts +1 -0
  79. package/lib/typescript/ui/primitives/index.d.ts.map +1 -1
  80. package/lib/typescript/ui/primitives/searchableSingleSelectFilter.d.ts +25 -0
  81. package/lib/typescript/ui/primitives/searchableSingleSelectFilter.d.ts.map +1 -0
  82. package/lib/typescript/utils/useSafeAreaInsets.d.ts +26 -0
  83. package/lib/typescript/utils/useSafeAreaInsets.d.ts.map +1 -0
  84. package/package.json +2 -1
  85. package/src/camera/DocumentCapture.tsx +12 -3
  86. package/src/camera/LivenessCamera.tsx +10 -3
  87. package/src/camera/MapAddressPicker.tsx +12 -18
  88. package/src/core/VelionOnboarding.ts +3 -0
  89. package/src/i18n/strings/en.ts +12 -0
  90. package/src/i18n/strings/es.ts +12 -0
  91. package/src/index.ts +7 -0
  92. package/src/steps/EconomicActivityStep.tsx +230 -0
  93. package/src/types/index.ts +34 -0
  94. package/src/ui/StepShell.tsx +20 -3
  95. package/src/ui/VelionOnboardingScreen.tsx +53 -13
  96. package/src/ui/primitives/SearchableSingleSelectList.tsx +195 -0
  97. package/src/ui/primitives/index.ts +6 -0
  98. package/src/ui/primitives/searchableSingleSelectFilter.ts +38 -0
  99. package/src/utils/useSafeAreaInsets.ts +37 -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;
@@ -17,6 +17,7 @@ import {
17
17
  } from 'react-native';
18
18
  import { useTheme, withAlpha } from './theme';
19
19
  import { BackButton } from './primitives/BackButton';
20
+ import { useSafeAreaInsets } from '../utils/useSafeAreaInsets';
20
21
 
21
22
  export interface StepShellProps {
22
23
  title: string;
@@ -49,13 +50,24 @@ export function StepShell({
49
50
  backDisabled = false,
50
51
  }: StepShellProps) {
51
52
  const theme = useTheme();
53
+ const insets = useSafeAreaInsets();
52
54
 
53
55
  const showIconCircle = !theme.hideStepIcons && iconNode != null;
54
56
 
55
57
  const body = (
56
58
  <ScrollView
57
59
  style={styles.scroll}
58
- contentContainerStyle={styles.scrollBody}
60
+ // Add the device safe-area insets to the base padding so the header
61
+ // (icon + title) clears the top camera / notch and the trailing CTA
62
+ // clears the bottom navigation bar / gesture area on edge-to-edge
63
+ // Android and on iOS devices with a home indicator.
64
+ contentContainerStyle={[
65
+ styles.scrollBody,
66
+ {
67
+ paddingTop: BASE_PADDING_TOP + insets.top,
68
+ paddingBottom: BASE_PADDING_BOTTOM + insets.bottom,
69
+ },
70
+ ]}
59
71
  keyboardShouldPersistTaps="handled"
60
72
  >
61
73
  {onBack ? (
@@ -103,6 +115,11 @@ export function StepShell({
103
115
  return body;
104
116
  }
105
117
 
118
+ // Base vertical padding for the scroll body. Safe-area insets are added on top
119
+ // of these at render time (see `contentContainerStyle` above).
120
+ const BASE_PADDING_TOP = 12;
121
+ const BASE_PADDING_BOTTOM = 28;
122
+
106
123
  const styles = StyleSheet.create({
107
124
  flex: {
108
125
  flex: 1,
@@ -112,8 +129,8 @@ const styles = StyleSheet.create({
112
129
  },
113
130
  scrollBody: {
114
131
  paddingHorizontal: 18,
115
- paddingTop: 12,
116
- paddingBottom: 28,
132
+ paddingTop: BASE_PADDING_TOP,
133
+ paddingBottom: BASE_PADDING_BOTTOM,
117
134
  },
118
135
  header: {
119
136
  alignItems: 'center',
@@ -31,6 +31,27 @@ import {
31
31
  activateScreenKeepAwake,
32
32
  deactivateScreenKeepAwake,
33
33
  } from '../utils/keepAwake';
34
+ import { useSafeAreaInsets } from '../utils/useSafeAreaInsets';
35
+
36
+ /**
37
+ * Mounts `react-native-safe-area-context`'s `SafeAreaProvider` so descendant
38
+ * `useSafeAreaInsets()` calls resolve real device insets (notch / nav bar). The
39
+ * library is loaded dynamically with a fail-safe: hosts that strip it (or that
40
+ * already mount their own provider higher up) still render — a nested provider
41
+ * returns correct insets, and a missing module degrades to zero insets.
42
+ */
43
+ function SafeAreaBoundary({ children }: { children: ReactNode }) {
44
+ try {
45
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
46
+ const mod = require('react-native-safe-area-context');
47
+ const Provider = mod.SafeAreaProvider;
48
+ return (
49
+ <Provider initialMetrics={mod.initialWindowMetrics}>{children}</Provider>
50
+ );
51
+ } catch {
52
+ return <>{children}</>;
53
+ }
54
+ }
34
55
 
35
56
  export interface VelionOnboardingScreenProps {
36
57
  config: VelionConfig;
@@ -69,17 +90,19 @@ export function VelionOnboardingScreen({
69
90
  onExit,
70
91
  }: VelionOnboardingScreenProps) {
71
92
  return (
72
- <ThemeProvider
73
- themeOverrides={config.theme}
74
- colorMode={config.colorMode ?? 'auto'}
75
- >
76
- <VelionOnboardingInner
77
- config={config}
78
- onComplete={onComplete}
79
- onFail={onFail}
80
- onExit={onExit}
81
- />
82
- </ThemeProvider>
93
+ <SafeAreaBoundary>
94
+ <ThemeProvider
95
+ themeOverrides={config.theme}
96
+ colorMode={config.colorMode ?? 'auto'}
97
+ >
98
+ <VelionOnboardingInner
99
+ config={config}
100
+ onComplete={onComplete}
101
+ onFail={onFail}
102
+ onExit={onExit}
103
+ />
104
+ </ThemeProvider>
105
+ </SafeAreaBoundary>
83
106
  );
84
107
  }
85
108
 
@@ -90,6 +113,7 @@ function VelionOnboardingInner({
90
113
  onExit,
91
114
  }: VelionOnboardingScreenProps) {
92
115
  const theme = useTheme();
116
+ const insets = useSafeAreaInsets();
93
117
  const t = getStrings(config.locale);
94
118
  const [state, setState] = useState<ViewState>(INITIAL_STATE);
95
119
  const [progress, setProgress] = useState(0);
@@ -214,10 +238,20 @@ function VelionOnboardingInner({
214
238
 
215
239
  return (
216
240
  <View style={[styles.root, { backgroundColor: theme.backgroundColor }]}>
241
+ {/* Content fills the screen edge-to-edge so camera / map steps stay
242
+ full-bleed. The progress bar floats on top, pushed below the top
243
+ safe-area inset (status bar / notch / punch-hole). Form steps offset
244
+ their own header via StepShell, and camera steps offset their chrome
245
+ internally — so we never inset the content container here. */}
246
+ <View style={styles.content}>{renderBody()}</View>
217
247
  {showProgress ? (
218
- <ProgressBar value={progress} hidden={progressHidden} />
248
+ <View
249
+ pointerEvents="none"
250
+ style={[styles.progressOverlay, { paddingTop: insets.top }]}
251
+ >
252
+ <ProgressBar value={progress} hidden={progressHidden} />
253
+ </View>
219
254
  ) : null}
220
- <View style={styles.content}>{renderBody()}</View>
221
255
  {showLoadingOverlay ? <LoadingOverlay message={loadingText} /> : null}
222
256
  </View>
223
257
  );
@@ -231,6 +265,12 @@ const styles = StyleSheet.create({
231
265
  flex: 1,
232
266
  overflow: 'hidden',
233
267
  },
268
+ progressOverlay: {
269
+ position: 'absolute',
270
+ top: 0,
271
+ left: 0,
272
+ right: 0,
273
+ },
234
274
  message: {
235
275
  flex: 1,
236
276
  alignItems: 'center',
@@ -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
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @fileoverview Shared safe-area inset hook with a dynamic, fail-safe loader.
3
+ *
4
+ * `react-native-safe-area-context` is a transitive peer of Expo SDK 54+ (and is
5
+ * declared as a peerDependency of this SDK), but we never import it statically:
6
+ * hosts that strip optional native deps, or render the SDK outside a
7
+ * `SafeAreaProvider`, must still get a usable layout. So the hook is loaded with
8
+ * a `require` inside a try/catch and falls back to zero insets.
9
+ *
10
+ * The `require` result is deterministic for the lifetime of the bundle (the
11
+ * module is either installed or not), so the conditional hook call below does
12
+ * not change across renders — it does not violate the rules of hooks. Callers
13
+ * MUST still invoke this hook unconditionally (before any early return).
14
+ *
15
+ * Insets are applied to UI chrome (headers, CTAs, camera controls) — never to
16
+ * the full-bleed `<Camera>` / `<MapView>` preview, which must keep covering the
17
+ * whole screen so OCR / liveness framing is not cropped.
18
+ */
19
+
20
+ export interface EdgeInsets {
21
+ top: number;
22
+ bottom: number;
23
+ left: number;
24
+ right: number;
25
+ }
26
+
27
+ const ZERO_INSETS: EdgeInsets = { top: 0, bottom: 0, left: 0, right: 0 };
28
+
29
+ export function useSafeAreaInsets(): EdgeInsets {
30
+ try {
31
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
32
+ const mod = require('react-native-safe-area-context');
33
+ return mod.useSafeAreaInsets() as EdgeInsets;
34
+ } catch {
35
+ return ZERO_INSETS;
36
+ }
37
+ }