@velion-la/onboarding-sdk-react-native 1.4.0-beta.1 → 1.4.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +33 -1
- package/lib/commonjs/camera/AddressSearchBar.js +9 -7
- package/lib/commonjs/camera/AddressSearchBar.js.map +1 -1
- package/lib/commonjs/camera/DocumentCapture.js +7 -6
- package/lib/commonjs/camera/DocumentCapture.js.map +1 -1
- package/lib/commonjs/camera/LivenessCamera.js +6 -5
- package/lib/commonjs/camera/LivenessCamera.js.map +1 -1
- package/lib/commonjs/camera/MapAddressPicker.js +2 -1
- package/lib/commonjs/camera/MapAddressPicker.js.map +1 -1
- package/lib/commonjs/core/VelionOnboarding.js +123 -6
- package/lib/commonjs/core/VelionOnboarding.js.map +1 -1
- package/lib/commonjs/core/sessionCancelledCopy.js +25 -0
- package/lib/commonjs/core/sessionCancelledCopy.js.map +1 -0
- package/lib/commonjs/core/sessionStateMapper.js +17 -4
- package/lib/commonjs/core/sessionStateMapper.js.map +1 -1
- package/lib/commonjs/core/sseReasonMessages.js +19 -1
- package/lib/commonjs/core/sseReasonMessages.js.map +1 -1
- package/lib/commonjs/i18n/strings/en.js +5 -1
- package/lib/commonjs/i18n/strings/en.js.map +1 -1
- package/lib/commonjs/i18n/strings/es.js +5 -1
- package/lib/commonjs/i18n/strings/es.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/steps/AddressInfoStep.js +4 -3
- package/lib/commonjs/steps/AddressInfoStep.js.map +1 -1
- package/lib/commonjs/steps/DocumentsOcrStep.js +4 -3
- package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/commonjs/steps/EconomicActivityStep.js +3 -2
- package/lib/commonjs/steps/EconomicActivityStep.js.map +1 -1
- package/lib/commonjs/steps/EmailOtpStep.js +2 -1
- package/lib/commonjs/steps/EmailOtpStep.js.map +1 -1
- package/lib/commonjs/steps/FaceMatchStep.js +3 -2
- package/lib/commonjs/steps/FaceMatchStep.js.map +1 -1
- package/lib/commonjs/steps/LivenessMatchStep.js +3 -2
- package/lib/commonjs/steps/LivenessMatchStep.js.map +1 -1
- package/lib/commonjs/steps/PhoneOtpStep.js +2 -1
- package/lib/commonjs/steps/PhoneOtpStep.js.map +1 -1
- package/lib/commonjs/steps/TermsAndConditionsStep.js +3 -2
- package/lib/commonjs/steps/TermsAndConditionsStep.js.map +1 -1
- package/lib/commonjs/transport/api.js +18 -1
- package/lib/commonjs/transport/api.js.map +1 -1
- package/lib/commonjs/transport/sse.js +2 -2
- package/lib/commonjs/transport/sse.js.map +1 -1
- package/lib/commonjs/types/index.js +18 -6
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/ui/StepShell.js +3 -2
- package/lib/commonjs/ui/StepShell.js.map +1 -1
- package/lib/commonjs/ui/VelionOnboardingScreen.js +5 -4
- package/lib/commonjs/ui/VelionOnboardingScreen.js.map +1 -1
- package/lib/commonjs/ui/icons/StepIcon.js +2 -2
- package/lib/commonjs/ui/icons/StepIcon.js.map +1 -1
- package/lib/commonjs/ui/overlays/AnalyzingOverlay.js +3 -2
- package/lib/commonjs/ui/overlays/AnalyzingOverlay.js.map +1 -1
- package/lib/commonjs/ui/overlays/LoadingOverlay.js +2 -1
- package/lib/commonjs/ui/overlays/LoadingOverlay.js.map +1 -1
- package/lib/commonjs/ui/overlays/RetryDialog.js +4 -3
- package/lib/commonjs/ui/overlays/RetryDialog.js.map +1 -1
- package/lib/commonjs/ui/primitives/BackButton.js +2 -1
- package/lib/commonjs/ui/primitives/BackButton.js.map +1 -1
- package/lib/commonjs/ui/primitives/Banner.js +3 -2
- package/lib/commonjs/ui/primitives/Banner.js.map +1 -1
- package/lib/commonjs/ui/primitives/Button.js +8 -5
- package/lib/commonjs/ui/primitives/Button.js.map +1 -1
- package/lib/commonjs/ui/primitives/Checkbox.js +5 -4
- package/lib/commonjs/ui/primitives/Checkbox.js.map +1 -1
- package/lib/commonjs/ui/primitives/CountrySelect.js +16 -13
- package/lib/commonjs/ui/primitives/CountrySelect.js.map +1 -1
- package/lib/commonjs/ui/primitives/DatePicker.js +4 -3
- package/lib/commonjs/ui/primitives/DatePicker.js.map +1 -1
- package/lib/commonjs/ui/primitives/Input.js +9 -7
- package/lib/commonjs/ui/primitives/Input.js.map +1 -1
- package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js +8 -6
- package/lib/commonjs/ui/primitives/SearchableSingleSelectList.js.map +1 -1
- package/lib/commonjs/ui/primitives/Select.js +11 -9
- package/lib/commonjs/ui/primitives/Select.js.map +1 -1
- package/lib/commonjs/ui/primitives/Text.js +67 -0
- package/lib/commonjs/ui/primitives/Text.js.map +1 -0
- package/lib/commonjs/ui/primitives/index.js +13 -0
- package/lib/commonjs/ui/primitives/index.js.map +1 -1
- package/lib/commonjs/ui/theme/ThemeProvider.js +14 -1
- package/lib/commonjs/ui/theme/ThemeProvider.js.map +1 -1
- package/lib/commonjs/ui/theme/fontLoader.js +77 -0
- package/lib/commonjs/ui/theme/fontLoader.js.map +1 -0
- package/lib/commonjs/ui/theme/fonts.js +200 -0
- package/lib/commonjs/ui/theme/fonts.js.map +1 -0
- package/lib/commonjs/ui/theme/index.js +31 -0
- package/lib/commonjs/ui/theme/index.js.map +1 -1
- package/lib/commonjs/ui/theme/tokens.js +32 -9
- package/lib/commonjs/ui/theme/tokens.js.map +1 -1
- package/lib/module/camera/AddressSearchBar.js +5 -3
- package/lib/module/camera/AddressSearchBar.js.map +1 -1
- package/lib/module/camera/DocumentCapture.js +2 -1
- package/lib/module/camera/DocumentCapture.js.map +1 -1
- package/lib/module/camera/LivenessCamera.js +2 -1
- package/lib/module/camera/LivenessCamera.js.map +1 -1
- package/lib/module/camera/MapAddressPicker.js +2 -1
- package/lib/module/camera/MapAddressPicker.js.map +1 -1
- package/lib/module/core/VelionOnboarding.js +124 -7
- package/lib/module/core/VelionOnboarding.js.map +1 -1
- package/lib/module/core/sessionCancelledCopy.js +21 -0
- package/lib/module/core/sessionCancelledCopy.js.map +1 -0
- package/lib/module/core/sessionStateMapper.js +16 -4
- package/lib/module/core/sessionStateMapper.js.map +1 -1
- package/lib/module/core/sseReasonMessages.js +18 -0
- package/lib/module/core/sseReasonMessages.js.map +1 -1
- package/lib/module/i18n/strings/en.js +5 -1
- package/lib/module/i18n/strings/en.js.map +1 -1
- package/lib/module/i18n/strings/es.js +5 -1
- package/lib/module/i18n/strings/es.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/steps/AddressInfoStep.js +2 -1
- package/lib/module/steps/AddressInfoStep.js.map +1 -1
- package/lib/module/steps/DocumentsOcrStep.js +2 -1
- package/lib/module/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/module/steps/EconomicActivityStep.js +2 -1
- package/lib/module/steps/EconomicActivityStep.js.map +1 -1
- package/lib/module/steps/EmailOtpStep.js +2 -1
- package/lib/module/steps/EmailOtpStep.js.map +1 -1
- package/lib/module/steps/FaceMatchStep.js +2 -1
- package/lib/module/steps/FaceMatchStep.js.map +1 -1
- package/lib/module/steps/LivenessMatchStep.js +2 -1
- package/lib/module/steps/LivenessMatchStep.js.map +1 -1
- package/lib/module/steps/PhoneOtpStep.js +2 -1
- package/lib/module/steps/PhoneOtpStep.js.map +1 -1
- package/lib/module/steps/TermsAndConditionsStep.js +2 -1
- package/lib/module/steps/TermsAndConditionsStep.js.map +1 -1
- package/lib/module/transport/api.js +18 -1
- package/lib/module/transport/api.js.map +1 -1
- package/lib/module/transport/sse.js +2 -2
- package/lib/module/transport/sse.js.map +1 -1
- package/lib/module/types/index.js +18 -6
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/ui/StepShell.js +2 -1
- package/lib/module/ui/StepShell.js.map +1 -1
- package/lib/module/ui/VelionOnboardingScreen.js +2 -1
- package/lib/module/ui/VelionOnboardingScreen.js.map +1 -1
- package/lib/module/ui/icons/StepIcon.js +1 -1
- package/lib/module/ui/icons/StepIcon.js.map +1 -1
- package/lib/module/ui/overlays/AnalyzingOverlay.js +2 -1
- package/lib/module/ui/overlays/AnalyzingOverlay.js.map +1 -1
- package/lib/module/ui/overlays/LoadingOverlay.js +2 -1
- package/lib/module/ui/overlays/LoadingOverlay.js.map +1 -1
- package/lib/module/ui/overlays/RetryDialog.js +2 -1
- package/lib/module/ui/overlays/RetryDialog.js.map +1 -1
- package/lib/module/ui/primitives/BackButton.js +2 -1
- package/lib/module/ui/primitives/BackButton.js.map +1 -1
- package/lib/module/ui/primitives/Banner.js +2 -1
- package/lib/module/ui/primitives/Banner.js.map +1 -1
- package/lib/module/ui/primitives/Button.js +7 -4
- package/lib/module/ui/primitives/Button.js.map +1 -1
- package/lib/module/ui/primitives/Checkbox.js +2 -1
- package/lib/module/ui/primitives/Checkbox.js.map +1 -1
- package/lib/module/ui/primitives/CountrySelect.js +8 -5
- package/lib/module/ui/primitives/CountrySelect.js.map +1 -1
- package/lib/module/ui/primitives/DatePicker.js +2 -1
- package/lib/module/ui/primitives/DatePicker.js.map +1 -1
- package/lib/module/ui/primitives/Input.js +6 -4
- package/lib/module/ui/primitives/Input.js.map +1 -1
- package/lib/module/ui/primitives/SearchableSingleSelectList.js +5 -3
- package/lib/module/ui/primitives/SearchableSingleSelectList.js.map +1 -1
- package/lib/module/ui/primitives/Select.js +5 -3
- package/lib/module/ui/primitives/Select.js.map +1 -1
- package/lib/module/ui/primitives/Text.js +65 -0
- package/lib/module/ui/primitives/Text.js.map +1 -0
- package/lib/module/ui/primitives/index.js +1 -0
- package/lib/module/ui/primitives/index.js.map +1 -1
- package/lib/module/ui/theme/ThemeProvider.js +13 -1
- package/lib/module/ui/theme/ThemeProvider.js.map +1 -1
- package/lib/module/ui/theme/fontLoader.js +70 -0
- package/lib/module/ui/theme/fontLoader.js.map +1 -0
- package/lib/module/ui/theme/fonts.js +191 -0
- package/lib/module/ui/theme/fonts.js.map +1 -0
- package/lib/module/ui/theme/index.js +3 -2
- package/lib/module/ui/theme/index.js.map +1 -1
- package/lib/module/ui/theme/tokens.js +31 -9
- package/lib/module/ui/theme/tokens.js.map +1 -1
- package/lib/typescript/camera/AddressSearchBar.d.ts.map +1 -1
- package/lib/typescript/core/VelionOnboarding.d.ts +24 -0
- package/lib/typescript/core/VelionOnboarding.d.ts.map +1 -1
- package/lib/typescript/core/sessionCancelledCopy.d.ts +14 -0
- package/lib/typescript/core/sessionCancelledCopy.d.ts.map +1 -0
- package/lib/typescript/core/sessionStateMapper.d.ts +11 -3
- package/lib/typescript/core/sessionStateMapper.d.ts.map +1 -1
- package/lib/typescript/core/sseReasonMessages.d.ts +6 -0
- package/lib/typescript/core/sseReasonMessages.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/es.d.ts +2 -0
- package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/steps/AddressInfoStep.d.ts.map +1 -1
- package/lib/typescript/steps/EconomicActivityStep.d.ts.map +1 -1
- package/lib/typescript/steps/EmailOtpStep.d.ts.map +1 -1
- package/lib/typescript/steps/FaceMatchStep.d.ts.map +1 -1
- package/lib/typescript/steps/LivenessMatchStep.d.ts.map +1 -1
- package/lib/typescript/steps/PhoneOtpStep.d.ts.map +1 -1
- package/lib/typescript/steps/TermsAndConditionsStep.d.ts.map +1 -1
- package/lib/typescript/transport/api.d.ts +1 -0
- package/lib/typescript/transport/api.d.ts.map +1 -1
- package/lib/typescript/transport/sse.d.ts.map +1 -1
- package/lib/typescript/types/index.d.ts +58 -12
- package/lib/typescript/types/index.d.ts.map +1 -1
- package/lib/typescript/ui/StepShell.d.ts.map +1 -1
- package/lib/typescript/ui/VelionOnboardingScreen.d.ts.map +1 -1
- package/lib/typescript/ui/overlays/LoadingOverlay.d.ts.map +1 -1
- package/lib/typescript/ui/overlays/RetryDialog.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/BackButton.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Banner.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Button.d.ts +2 -1
- package/lib/typescript/ui/primitives/Button.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Checkbox.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/CountrySelect.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/DatePicker.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Input.d.ts +3 -3
- package/lib/typescript/ui/primitives/Input.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/SearchableSingleSelectList.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Select.d.ts.map +1 -1
- package/lib/typescript/ui/primitives/Text.d.ts +19 -0
- package/lib/typescript/ui/primitives/Text.d.ts.map +1 -0
- package/lib/typescript/ui/primitives/index.d.ts +1 -0
- package/lib/typescript/ui/primitives/index.d.ts.map +1 -1
- package/lib/typescript/ui/theme/ThemeProvider.d.ts +7 -0
- package/lib/typescript/ui/theme/ThemeProvider.d.ts.map +1 -1
- package/lib/typescript/ui/theme/fontLoader.d.ts +28 -0
- package/lib/typescript/ui/theme/fontLoader.d.ts.map +1 -0
- package/lib/typescript/ui/theme/fonts.d.ts +157 -0
- package/lib/typescript/ui/theme/fonts.d.ts.map +1 -0
- package/lib/typescript/ui/theme/index.d.ts +3 -2
- package/lib/typescript/ui/theme/index.d.ts.map +1 -1
- package/lib/typescript/ui/theme/tokens.d.ts +25 -2
- package/lib/typescript/ui/theme/tokens.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/camera/AddressSearchBar.tsx +3 -4
- package/src/camera/DocumentCapture.tsx +1 -1
- package/src/camera/LivenessCamera.tsx +1 -1
- package/src/camera/MapAddressPicker.tsx +1 -1
- package/src/core/VelionOnboarding.ts +118 -5
- package/src/core/sessionCancelledCopy.ts +29 -0
- package/src/core/sessionStateMapper.ts +18 -5
- package/src/core/sseReasonMessages.ts +20 -0
- package/src/i18n/strings/en.ts +5 -0
- package/src/i18n/strings/es.ts +5 -0
- package/src/index.ts +2 -0
- package/src/steps/AddressInfoStep.tsx +6 -1
- package/src/steps/DocumentsOcrStep.tsx +1 -1
- package/src/steps/EconomicActivityStep.tsx +6 -1
- package/src/steps/EmailOtpStep.tsx +6 -1
- package/src/steps/FaceMatchStep.tsx +6 -1
- package/src/steps/LivenessMatchStep.tsx +7 -1
- package/src/steps/PhoneOtpStep.tsx +6 -1
- package/src/steps/TermsAndConditionsStep.tsx +7 -1
- package/src/transport/api.ts +17 -1
- package/src/transport/sse.ts +2 -0
- package/src/types/index.ts +58 -12
- package/src/ui/StepShell.tsx +6 -1
- package/src/ui/VelionOnboardingScreen.tsx +5 -1
- package/src/ui/icons/StepIcon.tsx +1 -1
- package/src/ui/overlays/AnalyzingOverlay.tsx +1 -1
- package/src/ui/overlays/LoadingOverlay.tsx +7 -1
- package/src/ui/overlays/RetryDialog.tsx +5 -1
- package/src/ui/primitives/BackButton.tsx +5 -1
- package/src/ui/primitives/Banner.tsx +5 -1
- package/src/ui/primitives/Button.tsx +5 -4
- package/src/ui/primitives/Checkbox.tsx +5 -1
- package/src/ui/primitives/CountrySelect.tsx +5 -6
- package/src/ui/primitives/DatePicker.tsx +7 -1
- package/src/ui/primitives/Input.tsx +6 -6
- package/src/ui/primitives/SearchableSingleSelectList.tsx +3 -4
- package/src/ui/primitives/Select.tsx +3 -3
- package/src/ui/primitives/Text.tsx +66 -0
- package/src/ui/primitives/index.ts +1 -0
- package/src/ui/theme/ThemeProvider.tsx +15 -2
- package/src/ui/theme/fontLoader.ts +92 -0
- package/src/ui/theme/fonts.ts +220 -0
- package/src/ui/theme/index.ts +9 -0
- package/src/ui/theme/tokens.ts +44 -6
package/src/types/index.ts
CHANGED
|
@@ -299,6 +299,15 @@ export enum SdkErrorCode {
|
|
|
299
299
|
SESSION_FETCH_FAILED = 'SESSION_FETCH_FAILED',
|
|
300
300
|
/** Backend sent SESSION_DECLINED over SSE; session ended before completion. */
|
|
301
301
|
SESSION_DECLINED = 'SESSION_DECLINED',
|
|
302
|
+
/**
|
|
303
|
+
* The backend cancelled the session (`SESSION_CANCELLED` over SSE, or
|
|
304
|
+
* `status: CANCELLED` on `GET /sessions/:id`). Not a verdict on the person:
|
|
305
|
+
* the session was closed on Velion's side (e.g. `WORKFLOW_VERSION_RETIRED`
|
|
306
|
+
* when a new workflow version is published forcing it). The session token
|
|
307
|
+
* is revoked and the SDK sends no further requests; create a new session
|
|
308
|
+
* to let the person start again. `cancelReason` carries the backend reason.
|
|
309
|
+
*/
|
|
310
|
+
SESSION_CANCELLED = 'SESSION_CANCELLED',
|
|
302
311
|
/**
|
|
303
312
|
* A step was completed but the backend did not route the session to the
|
|
304
313
|
* next one within `routingTimeoutMs` (default 120 s): no `ROUTING_COMMAND`
|
|
@@ -384,16 +393,18 @@ export interface SdkError {
|
|
|
384
393
|
*/
|
|
385
394
|
readonly stepCode?: string;
|
|
386
395
|
/**
|
|
387
|
-
* Localized headline resolved by the SDK for SESSION_DECLINED.
|
|
396
|
+
* Localized headline resolved by the SDK for SESSION_DECLINED and SESSION_CANCELLED.
|
|
388
397
|
* Useful when hosts hide the built-in final result screen but still want
|
|
389
398
|
* the same user-facing text in custom UI.
|
|
390
399
|
*/
|
|
391
400
|
readonly declineTitle?: string;
|
|
392
401
|
/**
|
|
393
|
-
* Localized body message resolved by the SDK for SESSION_DECLINED.
|
|
402
|
+
* Localized body message resolved by the SDK for SESSION_DECLINED and SESSION_CANCELLED.
|
|
394
403
|
* Mirrors the text shown in the built-in final result screen.
|
|
395
404
|
*/
|
|
396
405
|
readonly declineMessage?: string;
|
|
406
|
+
/** Present when `code === SdkErrorCode.SESSION_CANCELLED` (backend `reason`, e.g. `WORKFLOW_VERSION_RETIRED`). */
|
|
407
|
+
readonly cancelReason?: string;
|
|
397
408
|
/** Present when `code === SdkErrorCode.CAMERA_ERROR`. Provides camera-specific detail. */
|
|
398
409
|
readonly cameraCode?: CameraErrorCode;
|
|
399
410
|
/** HTTP status code when the error originated from an API call. */
|
|
@@ -410,16 +421,17 @@ export interface SdkError {
|
|
|
410
421
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
411
422
|
|
|
412
423
|
/**
|
|
413
|
-
* White-labeling theme configuration.
|
|
414
|
-
*
|
|
415
|
-
* making all SDK UI elements styleable via `--vl-*` variables.
|
|
424
|
+
* White-labeling theme configuration. Same keys as the web SDK's
|
|
425
|
+
* `VelionTheme`, so one workflow appearance renders alike on web and mobile.
|
|
416
426
|
*
|
|
417
427
|
* @example
|
|
418
428
|
* ```typescript
|
|
419
429
|
* const theme: VelionTheme = {
|
|
420
|
-
* primaryColor: '#0052CC',
|
|
421
|
-
* borderRadius: '12px',
|
|
422
|
-
* fontFamily: '
|
|
430
|
+
* primaryColor: '#0052CC',
|
|
431
|
+
* borderRadius: '12px',
|
|
432
|
+
* fontFamily: 'inter',
|
|
433
|
+
* inputHeight: '48px',
|
|
434
|
+
* buttonHeight: '52px',
|
|
423
435
|
* };
|
|
424
436
|
* ```
|
|
425
437
|
*/
|
|
@@ -436,7 +448,20 @@ export interface VelionTheme {
|
|
|
436
448
|
textSecondaryColor?: string;
|
|
437
449
|
/** Border radius for cards, buttons, and inputs. */
|
|
438
450
|
borderRadius?: string;
|
|
439
|
-
/**
|
|
451
|
+
/**
|
|
452
|
+
* Font every SDK text renders with, by id from the closed catalog:
|
|
453
|
+
* `'system'` (default), `'inter'`, `'roboto'`, `'open-sans'`, `'montserrat'`,
|
|
454
|
+
* `'poppins'`, `'nunito'`, `'source-sans-3'`, `'work-sans'`,
|
|
455
|
+
* `'ibm-plex-sans'`, `'dm-sans'` (see `VELION_FONT_IDS`).
|
|
456
|
+
*
|
|
457
|
+
* The SDK downloads the font with `expo-font`; texts use the system font
|
|
458
|
+
* until it is loaded, and keep it if the download fails. The Google Fonts
|
|
459
|
+
* name works too (`'Open Sans'`), and only the first family of a CSS stack
|
|
460
|
+
* counts. Any other value renders with the system font: the SDK never loads
|
|
461
|
+
* a font from a URL in the configuration.
|
|
462
|
+
*
|
|
463
|
+
* @default 'system'
|
|
464
|
+
*/
|
|
440
465
|
fontFamily?: string;
|
|
441
466
|
/** Color used for error states and destructive actions. */
|
|
442
467
|
errorColor?: string;
|
|
@@ -448,6 +473,20 @@ export interface VelionTheme {
|
|
|
448
473
|
borderColor?: string;
|
|
449
474
|
/** Box shadow definition for elevated elements (cards, modals). */
|
|
450
475
|
cardShadow?: string;
|
|
476
|
+
/**
|
|
477
|
+
* Minimum height of text inputs, selects and search fields, as a pixel
|
|
478
|
+
* length (`'48px'`). Taller content (a wrapped value) still grows the field.
|
|
479
|
+
*
|
|
480
|
+
* @default '44px'
|
|
481
|
+
*/
|
|
482
|
+
inputHeight?: string;
|
|
483
|
+
/**
|
|
484
|
+
* Minimum height of the SDK's buttons (primary, secondary and ghost), as a
|
|
485
|
+
* pixel length (`'48px'`). A label that wraps still grows the button.
|
|
486
|
+
*
|
|
487
|
+
* @default '44px'
|
|
488
|
+
*/
|
|
489
|
+
buttonHeight?: string;
|
|
451
490
|
/**
|
|
452
491
|
* When true, the SDK omits the round colored icon next to each step's
|
|
453
492
|
* title — only the title + subtitle are rendered. Useful for hosts that
|
|
@@ -485,6 +524,8 @@ export interface VelionFinalResultScreenTexts {
|
|
|
485
524
|
rejected?: VelionFinalResultStatusCopy;
|
|
486
525
|
/** Copy when {@link OnboardingResult.status} is `DECLINED`. */
|
|
487
526
|
declined?: VelionFinalResultStatusCopy;
|
|
527
|
+
/** Copy for the screen shown when the backend cancels the session (`SESSION_CANCELLED`). */
|
|
528
|
+
cancelled?: VelionFinalResultStatusCopy;
|
|
488
529
|
/** Primary button label (e.g. "Entendido" / "Got it"). */
|
|
489
530
|
dismissLabel?: string;
|
|
490
531
|
}
|
|
@@ -1021,6 +1062,9 @@ export interface OnboardingResult {
|
|
|
1021
1062
|
* - `MANUAL_REVIEW`: Flagged for human review (common in AML flows). Backend `IN_REVIEW` maps here.
|
|
1022
1063
|
* - `REJECTED`: Automatically rejected (fraud signals, liveness failure, etc.).
|
|
1023
1064
|
* - `DECLINED`: Session ended in a declined state (matches GET session `status: DECLINED`).
|
|
1065
|
+
*
|
|
1066
|
+
* A cancelled session (`CANCELLED`) is not a verdict and never produces an
|
|
1067
|
+
* `OnboardingResult`: it reaches the host as `onError(SESSION_CANCELLED)`.
|
|
1024
1068
|
*/
|
|
1025
1069
|
status: 'APPROVED' | 'MANUAL_REVIEW' | 'REJECTED' | 'DECLINED';
|
|
1026
1070
|
/** An optional tracking reference for support and audit trails. */
|
|
@@ -1275,6 +1319,8 @@ export interface TermsAndConditionsSubmitPayload {
|
|
|
1275
1319
|
* - SESSION_APPROVED — all checks passed; session_status = APPROVED
|
|
1276
1320
|
* - SESSION_MANUAL_REVIEW — manual review required; session_status = MANUAL_REVIEW
|
|
1277
1321
|
* - SESSION_DECLINED — session ended with decline (step_code, session_status DECLINED, reason)
|
|
1322
|
+
* - SESSION_CANCELLED — session cancelled by the backend, not a verdict (session_status CANCELLED,
|
|
1323
|
+
* reason e.g. WORKFLOW_VERSION_RETIRED). The stream closes and the session token is revoked.
|
|
1278
1324
|
*
|
|
1279
1325
|
* Reverse navigation ("back") arrives as a STEP_UPDATED (the re-opened step
|
|
1280
1326
|
* moves to IN_PROGRESS) followed by a ROUTING_COMMAND with action PREVIOUS_STEP
|
|
@@ -1288,13 +1334,13 @@ export interface TermsAndConditionsSubmitPayload {
|
|
|
1288
1334
|
export interface OnboardingSessionEvent {
|
|
1289
1335
|
/** Onboarding session identifier (Long in backend). */
|
|
1290
1336
|
session_id?: number;
|
|
1291
|
-
/** Discriminator: STEP_UPDATED | ROUTING_COMMAND | SESSION_APPROVED | SESSION_MANUAL_REVIEW | SESSION_DECLINED */
|
|
1337
|
+
/** Discriminator: STEP_UPDATED | ROUTING_COMMAND | SESSION_APPROVED | SESSION_MANUAL_REVIEW | SESSION_DECLINED | SESSION_CANCELLED */
|
|
1292
1338
|
event_type?: string;
|
|
1293
1339
|
/** Present for STEP_UPDATED or ROUTING_COMMAND (next step code). */
|
|
1294
1340
|
step_code?: string;
|
|
1295
1341
|
/** Present for STEP_UPDATED; e.g. COMPLETED. */
|
|
1296
1342
|
step_status?: string;
|
|
1297
|
-
/** Present for terminal events; e.g. APPROVED | MANUAL_REVIEW | REJECTED. */
|
|
1343
|
+
/** Present for terminal events; e.g. APPROVED | MANUAL_REVIEW | REJECTED | DECLINED | CANCELLED. */
|
|
1298
1344
|
session_status?: string;
|
|
1299
1345
|
/**
|
|
1300
1346
|
* For ROUTING_COMMAND: NEXT_STEP | PREVIOUS_STEP | RETRY_STEP (render step_code),
|
|
@@ -1302,7 +1348,7 @@ export interface OnboardingSessionEvent {
|
|
|
1302
1348
|
* or TERMINATE (end flow).
|
|
1303
1349
|
*/
|
|
1304
1350
|
action?: string;
|
|
1305
|
-
/** For SESSION_DECLINED / SESSION_MANUAL_REVIEW or ROUTING_COMMAND TERMINATE; e.g. UNREADABLE_DOCUMENT. */
|
|
1351
|
+
/** For SESSION_DECLINED / SESSION_CANCELLED / SESSION_MANUAL_REVIEW or ROUTING_COMMAND TERMINATE; e.g. UNREADABLE_DOCUMENT. */
|
|
1306
1352
|
reason?: string;
|
|
1307
1353
|
/** Step-specific config sent with ROUTING_COMMAND NEXT_STEP / PREVIOUS_STEP. */
|
|
1308
1354
|
step_config?: Record<string, unknown>;
|
package/src/ui/StepShell.tsx
CHANGED
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
import type { ReactNode } from 'react';
|
|
10
10
|
import { useRef } from 'react';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
Animated,
|
|
13
|
+
StyleSheet,
|
|
14
|
+
View,
|
|
15
|
+
} from 'react-native';
|
|
16
|
+
import { Text } from './primitives/Text';
|
|
12
17
|
import Svg, {
|
|
13
18
|
Defs,
|
|
14
19
|
LinearGradient as SvgLinearGradient,
|
|
@@ -15,7 +15,11 @@ import React, {
|
|
|
15
15
|
useState,
|
|
16
16
|
type ReactNode,
|
|
17
17
|
} from 'react';
|
|
18
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
StyleSheet,
|
|
20
|
+
View,
|
|
21
|
+
} from 'react-native';
|
|
22
|
+
import { Text } from './primitives/Text';
|
|
19
23
|
import { VelionOnboarding, type VelionConfig } from '../core/VelionOnboarding';
|
|
20
24
|
import type {
|
|
21
25
|
OnboardingExit,
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
Animated,
|
|
18
18
|
Easing,
|
|
19
19
|
StyleSheet,
|
|
20
|
-
Text,
|
|
21
20
|
useWindowDimensions,
|
|
22
21
|
View,
|
|
23
22
|
} from 'react-native';
|
|
23
|
+
import { Text } from '../primitives/Text';
|
|
24
24
|
import Svg, { Circle, Path } from 'react-native-svg';
|
|
25
25
|
|
|
26
26
|
import { useTheme, withAlpha } from '../theme';
|
|
@@ -14,7 +14,13 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { useEffect, useRef } from 'react';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
Animated,
|
|
19
|
+
Easing,
|
|
20
|
+
StyleSheet,
|
|
21
|
+
View,
|
|
22
|
+
} from 'react-native';
|
|
23
|
+
import { Text } from '../primitives/Text';
|
|
18
24
|
import { useReducedMotion, useTheme } from '../theme';
|
|
19
25
|
|
|
20
26
|
export interface LoadingOverlayProps {
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
* recover without losing their inputs.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
StyleSheet,
|
|
11
|
+
View,
|
|
12
|
+
} from 'react-native';
|
|
13
|
+
import { Text } from '../primitives/Text';
|
|
10
14
|
import { Button } from '../primitives/Button';
|
|
11
15
|
import { mixHex, useTheme, withAlpha } from '../theme';
|
|
12
16
|
|
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
* is unavailable the icon falls back gracefully and only the label shows.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
Pressable,
|
|
16
|
+
StyleSheet,
|
|
17
|
+
} from 'react-native';
|
|
18
|
+
import { Text } from './Text';
|
|
15
19
|
import { useTheme, withAlpha } from '../theme';
|
|
16
20
|
import { StepIcon } from '../icons/StepIcon';
|
|
17
21
|
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
* inline warning icon (single "!" character to keep zero asset dependencies).
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
StyleSheet,
|
|
8
|
+
View,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
import { Text } from './Text';
|
|
7
11
|
import { mixHex, useTheme } from '../theme';
|
|
8
12
|
|
|
9
13
|
export interface BannerProps {
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* - Secondary: filled with `secondaryColor`.
|
|
7
7
|
* - Ghost: transparent with border + text in `textColor`.
|
|
8
8
|
*
|
|
9
|
-
* 44 px
|
|
9
|
+
* Min height from `theme.buttonHeight` (44 px by default, the Apple HIG /
|
|
10
|
+
* WCAG 2.5.5 tap target). Disabled state dims at 0.45
|
|
10
11
|
* opacity (matches `.vl-btn:disabled`).
|
|
11
12
|
*/
|
|
12
13
|
|
|
@@ -15,12 +16,12 @@ import {
|
|
|
15
16
|
ActivityIndicator,
|
|
16
17
|
Pressable,
|
|
17
18
|
StyleSheet,
|
|
18
|
-
Text,
|
|
19
19
|
View,
|
|
20
20
|
type GestureResponderEvent,
|
|
21
21
|
type StyleProp,
|
|
22
22
|
type ViewStyle,
|
|
23
23
|
} from 'react-native';
|
|
24
|
+
import { Text } from './Text';
|
|
24
25
|
import { useTheme, withAlpha } from '../theme';
|
|
25
26
|
|
|
26
27
|
export type ButtonVariant = 'primary' | 'secondary' | 'ghost';
|
|
@@ -66,6 +67,7 @@ export function Button({
|
|
|
66
67
|
testID={testID}
|
|
67
68
|
style={({ pressed }) => [
|
|
68
69
|
styles.base,
|
|
70
|
+
{ minHeight: theme.buttonHeightPx },
|
|
69
71
|
{ borderRadius: theme.borderRadiusPx },
|
|
70
72
|
variantStyles.container,
|
|
71
73
|
fullWidth && styles.fullWidth,
|
|
@@ -136,9 +138,8 @@ function buildVariantStyles(
|
|
|
136
138
|
|
|
137
139
|
const styles = StyleSheet.create({
|
|
138
140
|
base: {
|
|
139
|
-
minHeight: 44,
|
|
140
141
|
paddingHorizontal: 16,
|
|
141
|
-
paddingVertical:
|
|
142
|
+
paddingVertical: 8,
|
|
142
143
|
borderWidth: 1,
|
|
143
144
|
alignItems: 'center',
|
|
144
145
|
justifyContent: 'center',
|
|
@@ -9,7 +9,11 @@
|
|
|
9
9
|
* No external icon dependency: the check is a tinted square with a "✓" glyph.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
StyleSheet,
|
|
14
|
+
View,
|
|
15
|
+
} from 'react-native';
|
|
16
|
+
import { Text } from './Text';
|
|
13
17
|
import { Pressable } from 'react-native';
|
|
14
18
|
import { mixHex, useTheme } from '../theme';
|
|
15
19
|
|
|
@@ -18,12 +18,11 @@ import {
|
|
|
18
18
|
Modal,
|
|
19
19
|
Pressable,
|
|
20
20
|
StyleSheet,
|
|
21
|
-
Text,
|
|
22
|
-
TextInput,
|
|
23
21
|
View,
|
|
24
22
|
type StyleProp,
|
|
25
23
|
type ViewStyle,
|
|
26
24
|
} from 'react-native';
|
|
25
|
+
import { Text, TextInput } from './Text';
|
|
27
26
|
import { useTheme, withAlpha } from '../theme';
|
|
28
27
|
import {
|
|
29
28
|
filterIso3166Countries,
|
|
@@ -116,6 +115,7 @@ export function CountrySelect({
|
|
|
116
115
|
onPress={() => setOpen(true)}
|
|
117
116
|
style={[
|
|
118
117
|
styles.trigger,
|
|
118
|
+
{ minHeight: theme.inputHeightPx },
|
|
119
119
|
{
|
|
120
120
|
backgroundColor: theme.backgroundColor,
|
|
121
121
|
borderColor: hasError ? theme.errorColor : theme.borderColor,
|
|
@@ -179,6 +179,7 @@ export function CountrySelect({
|
|
|
179
179
|
onChangeText={setQuery}
|
|
180
180
|
style={[
|
|
181
181
|
styles.search,
|
|
182
|
+
{ minHeight: theme.inputHeightPx },
|
|
182
183
|
{
|
|
183
184
|
color: theme.textColor,
|
|
184
185
|
backgroundColor: theme.backgroundColor,
|
|
@@ -270,9 +271,8 @@ const styles = StyleSheet.create({
|
|
|
270
271
|
fontWeight: '400',
|
|
271
272
|
},
|
|
272
273
|
trigger: {
|
|
273
|
-
minHeight: 44,
|
|
274
274
|
paddingHorizontal: 12,
|
|
275
|
-
paddingVertical:
|
|
275
|
+
paddingVertical: 8,
|
|
276
276
|
borderWidth: 1,
|
|
277
277
|
flexDirection: 'row',
|
|
278
278
|
alignItems: 'center',
|
|
@@ -316,9 +316,8 @@ const styles = StyleSheet.create({
|
|
|
316
316
|
marginBottom: 8,
|
|
317
317
|
},
|
|
318
318
|
search: {
|
|
319
|
-
minHeight: 44,
|
|
320
319
|
paddingHorizontal: 12,
|
|
321
|
-
paddingVertical:
|
|
320
|
+
paddingVertical: 8,
|
|
322
321
|
fontSize: 15,
|
|
323
322
|
borderWidth: 1,
|
|
324
323
|
marginBottom: 8,
|
|
@@ -22,7 +22,13 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
25
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
StyleSheet,
|
|
27
|
+
View,
|
|
28
|
+
type StyleProp,
|
|
29
|
+
type ViewStyle,
|
|
30
|
+
} from 'react-native';
|
|
31
|
+
import { Text } from './Text';
|
|
26
32
|
import { useTheme } from '../theme';
|
|
27
33
|
import { Select, type SelectOption } from './Select';
|
|
28
34
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Themed text input with optional inline error message.
|
|
3
3
|
*
|
|
4
4
|
* Matches `.vl-hbi__input` semantics:
|
|
5
|
-
* - 44 px
|
|
5
|
+
* - Min height from `theme.inputHeight` (44 px by default, the tap target).
|
|
6
6
|
* - Border switches to `errorColor` and a subtle ring when `errorMessage` is set.
|
|
7
7
|
* - Pairs an externally controlled label rendered above (see `<Field>` helper).
|
|
8
8
|
*/
|
|
@@ -10,13 +10,13 @@
|
|
|
10
10
|
import { forwardRef, useId } from 'react';
|
|
11
11
|
import {
|
|
12
12
|
StyleSheet,
|
|
13
|
-
Text,
|
|
14
|
-
TextInput,
|
|
15
13
|
View,
|
|
16
14
|
type StyleProp,
|
|
15
|
+
type TextInput as RNTextInput,
|
|
17
16
|
type TextInputProps,
|
|
18
17
|
type ViewStyle,
|
|
19
18
|
} from 'react-native';
|
|
19
|
+
import { Text, TextInput } from './Text';
|
|
20
20
|
import { useTheme } from '../theme';
|
|
21
21
|
|
|
22
22
|
export interface InputProps extends Omit<TextInputProps, 'style'> {
|
|
@@ -26,7 +26,7 @@ export interface InputProps extends Omit<TextInputProps, 'style'> {
|
|
|
26
26
|
containerStyle?: StyleProp<ViewStyle>;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export const Input = forwardRef<
|
|
29
|
+
export const Input = forwardRef<RNTextInput, InputProps>(function Input(
|
|
30
30
|
{ label, errorMessage, required, containerStyle, ...rest },
|
|
31
31
|
ref,
|
|
32
32
|
) {
|
|
@@ -55,6 +55,7 @@ export const Input = forwardRef<TextInput, InputProps>(function Input(
|
|
|
55
55
|
{...rest}
|
|
56
56
|
style={[
|
|
57
57
|
styles.input,
|
|
58
|
+
{ minHeight: theme.inputHeightPx },
|
|
58
59
|
{
|
|
59
60
|
color: theme.textColor,
|
|
60
61
|
backgroundColor: theme.backgroundColor,
|
|
@@ -96,9 +97,8 @@ const styles = StyleSheet.create({
|
|
|
96
97
|
fontWeight: '400',
|
|
97
98
|
},
|
|
98
99
|
input: {
|
|
99
|
-
minHeight: 44,
|
|
100
100
|
paddingHorizontal: 12,
|
|
101
|
-
paddingVertical:
|
|
101
|
+
paddingVertical: 8,
|
|
102
102
|
fontSize: 15,
|
|
103
103
|
borderWidth: 1,
|
|
104
104
|
},
|
|
@@ -21,12 +21,11 @@ import {
|
|
|
21
21
|
FlatList,
|
|
22
22
|
Pressable,
|
|
23
23
|
StyleSheet,
|
|
24
|
-
Text,
|
|
25
|
-
TextInput,
|
|
26
24
|
View,
|
|
27
25
|
type StyleProp,
|
|
28
26
|
type ViewStyle,
|
|
29
27
|
} from 'react-native';
|
|
28
|
+
import { Text, TextInput } from './Text';
|
|
30
29
|
import { useTheme, withAlpha } from '../theme';
|
|
31
30
|
import {
|
|
32
31
|
filterSearchableOptions,
|
|
@@ -79,6 +78,7 @@ export function SearchableSingleSelectList({
|
|
|
79
78
|
onChangeText={setQuery}
|
|
80
79
|
style={[
|
|
81
80
|
styles.search,
|
|
81
|
+
{ minHeight: theme.inputHeightPx },
|
|
82
82
|
{
|
|
83
83
|
color: theme.textColor,
|
|
84
84
|
backgroundColor: theme.backgroundColor,
|
|
@@ -155,9 +155,8 @@ const styles = StyleSheet.create({
|
|
|
155
155
|
width: '100%',
|
|
156
156
|
},
|
|
157
157
|
search: {
|
|
158
|
-
minHeight: 44,
|
|
159
158
|
paddingHorizontal: 12,
|
|
160
|
-
paddingVertical:
|
|
159
|
+
paddingVertical: 8,
|
|
161
160
|
fontSize: 15,
|
|
162
161
|
borderWidth: 1,
|
|
163
162
|
marginBottom: 8,
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
Pressable,
|
|
14
14
|
ScrollView,
|
|
15
15
|
StyleSheet,
|
|
16
|
-
Text,
|
|
17
16
|
View,
|
|
18
17
|
type StyleProp,
|
|
19
18
|
type ViewStyle,
|
|
20
19
|
} from 'react-native';
|
|
20
|
+
import { Text } from './Text';
|
|
21
21
|
import { useTheme, withAlpha } from '../theme';
|
|
22
22
|
|
|
23
23
|
export interface SelectOption {
|
|
@@ -78,6 +78,7 @@ export function Select({
|
|
|
78
78
|
onPress={() => setOpen(true)}
|
|
79
79
|
style={[
|
|
80
80
|
styles.trigger,
|
|
81
|
+
{ minHeight: theme.inputHeightPx },
|
|
81
82
|
{
|
|
82
83
|
backgroundColor: theme.backgroundColor,
|
|
83
84
|
borderColor: hasError ? theme.errorColor : theme.borderColor,
|
|
@@ -199,9 +200,8 @@ const styles = StyleSheet.create({
|
|
|
199
200
|
fontWeight: '400',
|
|
200
201
|
},
|
|
201
202
|
trigger: {
|
|
202
|
-
minHeight: 44,
|
|
203
203
|
paddingHorizontal: 12,
|
|
204
|
-
paddingVertical:
|
|
204
|
+
paddingVertical: 8,
|
|
205
205
|
borderWidth: 1,
|
|
206
206
|
flexDirection: 'row',
|
|
207
207
|
alignItems: 'center',
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Themed `Text` and `TextInput` (OSDKR-45).
|
|
3
|
+
*
|
|
4
|
+
* Drop-in replacements for the React Native components that render with the
|
|
5
|
+
* theme's catalog font. Every SDK text goes through them — a test fails if a
|
|
6
|
+
* file imports `Text` or `TextInput` from `react-native` directly — so the
|
|
7
|
+
* font configured in `VelionTheme.fontFamily` reaches all of them.
|
|
8
|
+
*
|
|
9
|
+
* The face is picked from the text's own `fontWeight`, or from the enclosing
|
|
10
|
+
* `Text`'s when a nested one sets none (React Native inherits the weight, but
|
|
11
|
+
* a nested text names its own face, so the weight has to travel with it).
|
|
12
|
+
* With no catalog font
|
|
13
|
+
* loaded (or outside a `ThemeProvider`) they behave exactly like the React
|
|
14
|
+
* Native components.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { createContext, forwardRef, useContext } from 'react';
|
|
18
|
+
import {
|
|
19
|
+
StyleSheet,
|
|
20
|
+
Text as RNText,
|
|
21
|
+
TextInput as RNTextInput,
|
|
22
|
+
type TextInputProps,
|
|
23
|
+
type TextProps,
|
|
24
|
+
} from 'react-native';
|
|
25
|
+
import { fontStyleFor } from '../theme/fonts';
|
|
26
|
+
import { useOptionalTheme } from '../theme/ThemeProvider';
|
|
27
|
+
|
|
28
|
+
/** `fontWeight` of the enclosing `Text`, for nested texts that set none. */
|
|
29
|
+
const InheritedWeight = createContext<unknown>(undefined);
|
|
30
|
+
|
|
31
|
+
export const Text = forwardRef<RNText, TextProps>(function Text(
|
|
32
|
+
{ style, children, ...rest },
|
|
33
|
+
ref,
|
|
34
|
+
) {
|
|
35
|
+
const fontId = useOptionalTheme()?.fontId ?? null;
|
|
36
|
+
const inheritedWeight = useContext(InheritedWeight);
|
|
37
|
+
if (!fontId) {
|
|
38
|
+
return (
|
|
39
|
+
<RNText ref={ref} {...rest} style={style}>
|
|
40
|
+
{children}
|
|
41
|
+
</RNText>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
const weight = StyleSheet.flatten(style)?.fontWeight ?? inheritedWeight;
|
|
45
|
+
return (
|
|
46
|
+
<RNText ref={ref} {...rest} style={[style, fontStyleFor(fontId, weight)]}>
|
|
47
|
+
<InheritedWeight.Provider value={weight}>{children}</InheritedWeight.Provider>
|
|
48
|
+
</RNText>
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export const TextInput = forwardRef<RNTextInput, TextInputProps>(
|
|
53
|
+
function TextInput({ style, ...rest }, ref) {
|
|
54
|
+
const fontId = useOptionalTheme()?.fontId ?? null;
|
|
55
|
+
const fontStyle = fontId
|
|
56
|
+
? fontStyleFor(fontId, StyleSheet.flatten(style)?.fontWeight)
|
|
57
|
+
: undefined;
|
|
58
|
+
return (
|
|
59
|
+
<RNTextInput
|
|
60
|
+
ref={ref}
|
|
61
|
+
{...rest}
|
|
62
|
+
style={fontStyle ? [style, fontStyle] : style}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
);
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
* - `ThemeProvider` resolves tokens from `VelionConfig.theme` + colorMode and
|
|
5
5
|
* exposes them to descendants.
|
|
6
6
|
* - `useTheme()` returns the active `ResolvedTheme`.
|
|
7
|
+
* - The catalog font named by `fontFamily` is loaded here (`useCatalogFont`)
|
|
8
|
+
* and exposed as `theme.fontId` once it is usable.
|
|
7
9
|
* - `useReducedMotion()` honours the OS-level `prefers-reduced-motion` flag —
|
|
8
10
|
* components disable animations when true.
|
|
9
11
|
*/
|
|
@@ -19,6 +21,7 @@ import React, {
|
|
|
19
21
|
import { AccessibilityInfo, useColorScheme } from 'react-native';
|
|
20
22
|
import type { VelionTheme } from '../../types';
|
|
21
23
|
import { resolveTheme, type ResolvedTheme } from './tokens';
|
|
24
|
+
import { useCatalogFont } from './fontLoader';
|
|
22
25
|
|
|
23
26
|
interface ThemeContextValue {
|
|
24
27
|
theme: ResolvedTheme;
|
|
@@ -48,9 +51,11 @@ export function ThemeProvider({
|
|
|
48
51
|
return systemScheme === 'dark' ? 'dark' : 'light';
|
|
49
52
|
}, [colorMode, systemScheme]);
|
|
50
53
|
|
|
54
|
+
const loadedFontId = useCatalogFont(themeOverrides?.fontFamily);
|
|
55
|
+
|
|
51
56
|
const theme = useMemo(
|
|
52
|
-
() => resolveTheme(themeOverrides, resolvedMode),
|
|
53
|
-
[themeOverrides, resolvedMode],
|
|
57
|
+
() => resolveTheme(themeOverrides, resolvedMode, loadedFontId),
|
|
58
|
+
[themeOverrides, resolvedMode, loadedFontId],
|
|
54
59
|
);
|
|
55
60
|
|
|
56
61
|
const value = useMemo<ThemeContextValue>(
|
|
@@ -73,6 +78,14 @@ export function useTheme(): ResolvedTheme {
|
|
|
73
78
|
return ctx.theme;
|
|
74
79
|
}
|
|
75
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Like `useTheme`, but `null` outside a `ThemeProvider` instead of throwing.
|
|
83
|
+
* For primitives that must also render where no provider is mounted.
|
|
84
|
+
*/
|
|
85
|
+
export function useOptionalTheme(): ResolvedTheme | null {
|
|
86
|
+
return useContext(ThemeContext)?.theme ?? null;
|
|
87
|
+
}
|
|
88
|
+
|
|
76
89
|
export function useReducedMotion(): boolean {
|
|
77
90
|
const ctx = useContext(ThemeContext);
|
|
78
91
|
return ctx?.reduceMotion ?? false;
|