@velion-la/onboarding-sdk-react-native 1.0.0-beta.9 → 1.0.1
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 +16 -1
- package/lib/commonjs/camera/DocumentCapture.js +78 -26
- package/lib/commonjs/camera/DocumentCapture.js.map +1 -1
- package/lib/commonjs/i18n/strings/en.js +3 -2
- package/lib/commonjs/i18n/strings/en.js.map +1 -1
- package/lib/commonjs/i18n/strings/es.js +3 -2
- package/lib/commonjs/i18n/strings/es.js.map +1 -1
- package/lib/commonjs/steps/DocumentsOcrStep.js +152 -35
- package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/commonjs/steps/PhoneContactStep.js +10 -4
- package/lib/commonjs/steps/PhoneContactStep.js.map +1 -1
- package/lib/commonjs/steps/PhoneOtpStep.js +17 -6
- package/lib/commonjs/steps/PhoneOtpStep.js.map +1 -1
- package/lib/commonjs/ui/StepShell.js +122 -12
- package/lib/commonjs/ui/StepShell.js.map +1 -1
- package/lib/commonjs/ui/overlays/ProgressBar.js +8 -2
- package/lib/commonjs/ui/overlays/ProgressBar.js.map +1 -1
- package/lib/commonjs/utils/documentCrop.js +136 -0
- package/lib/commonjs/utils/documentCrop.js.map +1 -0
- package/lib/module/camera/DocumentCapture.js +78 -26
- package/lib/module/camera/DocumentCapture.js.map +1 -1
- package/lib/module/i18n/strings/en.js +3 -2
- package/lib/module/i18n/strings/en.js.map +1 -1
- package/lib/module/i18n/strings/es.js +3 -2
- package/lib/module/i18n/strings/es.js.map +1 -1
- package/lib/module/steps/DocumentsOcrStep.js +152 -34
- package/lib/module/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/module/steps/PhoneContactStep.js +10 -4
- package/lib/module/steps/PhoneContactStep.js.map +1 -1
- package/lib/module/steps/PhoneOtpStep.js +17 -6
- package/lib/module/steps/PhoneOtpStep.js.map +1 -1
- package/lib/module/ui/StepShell.js +122 -13
- package/lib/module/ui/StepShell.js.map +1 -1
- package/lib/module/ui/overlays/ProgressBar.js +8 -1
- package/lib/module/ui/overlays/ProgressBar.js.map +1 -1
- package/lib/module/utils/documentCrop.js +129 -0
- package/lib/module/utils/documentCrop.js.map +1 -0
- package/lib/typescript/camera/DocumentCapture.d.ts +20 -8
- package/lib/typescript/camera/DocumentCapture.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/en.d.ts.map +1 -1
- package/lib/typescript/i18n/strings/es.d.ts +1 -0
- package/lib/typescript/i18n/strings/es.d.ts.map +1 -1
- package/lib/typescript/steps/DocumentsOcrStep.d.ts +8 -6
- package/lib/typescript/steps/DocumentsOcrStep.d.ts.map +1 -1
- package/lib/typescript/ui/StepShell.d.ts.map +1 -1
- package/lib/typescript/ui/overlays/ProgressBar.d.ts +6 -0
- package/lib/typescript/ui/overlays/ProgressBar.d.ts.map +1 -1
- package/lib/typescript/utils/documentCrop.d.ts +78 -0
- package/lib/typescript/utils/documentCrop.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/camera/DocumentCapture.tsx +76 -25
- package/src/i18n/strings/en.ts +3 -2
- package/src/i18n/strings/es.ts +3 -2
- package/src/steps/DocumentsOcrStep.tsx +180 -32
- package/src/steps/PhoneContactStep.tsx +9 -3
- package/src/steps/PhoneOtpStep.tsx +14 -4
- package/src/ui/StepShell.tsx +114 -12
- package/src/ui/overlays/ProgressBar.tsx +8 -1
- package/src/utils/documentCrop.ts +159 -0
|
@@ -4,11 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.StepShell = StepShell;
|
|
7
|
+
var _react = require("react");
|
|
7
8
|
var _reactNative = require("react-native");
|
|
9
|
+
var _reactNativeSvg = _interopRequireWildcard(require("react-native-svg"));
|
|
8
10
|
var _theme = require("./theme");
|
|
9
11
|
var _BackButton = require("./primitives/BackButton");
|
|
12
|
+
var _ProgressBar = require("./overlays/ProgressBar");
|
|
10
13
|
var _useSafeAreaInsets = require("../utils/useSafeAreaInsets");
|
|
11
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
16
|
/**
|
|
13
17
|
* @fileoverview Step shell — header + scrollable body.
|
|
14
18
|
*
|
|
@@ -30,23 +34,42 @@ function StepShell({
|
|
|
30
34
|
const theme = (0, _theme.useTheme)();
|
|
31
35
|
const insets = (0, _useSafeAreaInsets.useSafeAreaInsets)();
|
|
32
36
|
const showIconCircle = !theme.hideStepIcons && iconNode != null;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const showBack = onBack != null;
|
|
38
|
+
|
|
39
|
+
// Drive the top-fade opacity from the scroll offset so the gradient is fully
|
|
40
|
+
// invisible at rest (scrollY = 0) — the header/icon reads crisp — and only
|
|
41
|
+
// ramps in as the content scrolls up under the fixed back strip (OSDKR-12).
|
|
42
|
+
const scrollY = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
|
|
43
|
+
const fadeOpacity = scrollY.interpolate({
|
|
44
|
+
inputRange: [0, FADE_RAMP_DISTANCE],
|
|
45
|
+
outputRange: [0, 1],
|
|
46
|
+
extrapolate: 'clamp'
|
|
47
|
+
});
|
|
48
|
+
const scroll = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Animated.ScrollView, {
|
|
49
|
+
style: styles.scroll,
|
|
50
|
+
scrollEventThrottle: 16,
|
|
51
|
+
onScroll: _reactNative.Animated.event([{
|
|
52
|
+
nativeEvent: {
|
|
53
|
+
contentOffset: {
|
|
54
|
+
y: scrollY
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}], {
|
|
58
|
+
useNativeDriver: true
|
|
59
|
+
})
|
|
60
|
+
// When the fixed back strip is present it already clears the status bar +
|
|
61
|
+
// progress bar, so the scroll body only needs its base top padding.
|
|
62
|
+
// Without it, add the device safe-area insets so the header (icon + title)
|
|
63
|
+
// clears the top camera / notch. The bottom inset always clears the
|
|
64
|
+
// navigation bar / gesture area on edge-to-edge Android and on iOS devices
|
|
65
|
+
// with a home indicator.
|
|
39
66
|
,
|
|
40
67
|
contentContainerStyle: [styles.scrollBody, {
|
|
41
|
-
paddingTop: BASE_PADDING_TOP + insets.top,
|
|
68
|
+
paddingTop: showBack ? BASE_PADDING_TOP : BASE_PADDING_TOP + insets.top,
|
|
42
69
|
paddingBottom: BASE_PADDING_BOTTOM + insets.bottom
|
|
43
70
|
}],
|
|
44
71
|
keyboardShouldPersistTaps: "handled",
|
|
45
|
-
children: [
|
|
46
|
-
label: backLabel,
|
|
47
|
-
onPress: onBack,
|
|
48
|
-
disabled: backDisabled
|
|
49
|
-
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
72
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
50
73
|
style: styles.header,
|
|
51
74
|
children: [showIconCircle ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
52
75
|
style: [styles.iconCircle, {
|
|
@@ -72,6 +95,73 @@ function StepShell({
|
|
|
72
95
|
children: children
|
|
73
96
|
})]
|
|
74
97
|
});
|
|
98
|
+
|
|
99
|
+
// The back control lives in a fixed strip OUTSIDE the ScrollView so it stays
|
|
100
|
+
// pinned just below the (fixed) ProgressBar while the form scrolls behind it.
|
|
101
|
+
// `paddingTop` clears the status-bar / notch inset plus the progress bar's
|
|
102
|
+
// own height so "Atrás" never tucks under the bar (OSDKR-12).
|
|
103
|
+
const body = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
104
|
+
style: styles.flex,
|
|
105
|
+
children: [showBack ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
106
|
+
style: [styles.backStrip, {
|
|
107
|
+
paddingTop: insets.top + _ProgressBar.PROGRESS_BAR_HEIGHT
|
|
108
|
+
}],
|
|
109
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_BackButton.BackButton, {
|
|
110
|
+
label: backLabel,
|
|
111
|
+
onPress: onBack,
|
|
112
|
+
disabled: backDisabled
|
|
113
|
+
})
|
|
114
|
+
}) : null, /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
115
|
+
style: styles.scrollWrap,
|
|
116
|
+
children: [scroll, /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.View, {
|
|
117
|
+
pointerEvents: "none",
|
|
118
|
+
style: [styles.topFade, {
|
|
119
|
+
height: TOP_FADE_HEIGHT,
|
|
120
|
+
opacity: fadeOpacity
|
|
121
|
+
}],
|
|
122
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.default, {
|
|
123
|
+
width: "100%",
|
|
124
|
+
height: "100%",
|
|
125
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Defs, {
|
|
126
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeSvg.LinearGradient, {
|
|
127
|
+
id: "stepTopFade",
|
|
128
|
+
x1: "0",
|
|
129
|
+
y1: "0",
|
|
130
|
+
x2: "0",
|
|
131
|
+
y2: "1",
|
|
132
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Stop, {
|
|
133
|
+
offset: "0",
|
|
134
|
+
stopColor: theme.backgroundColor,
|
|
135
|
+
stopOpacity: 1
|
|
136
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Stop, {
|
|
137
|
+
offset: "0.35",
|
|
138
|
+
stopColor: theme.backgroundColor,
|
|
139
|
+
stopOpacity: 0.85
|
|
140
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Stop, {
|
|
141
|
+
offset: "0.6",
|
|
142
|
+
stopColor: theme.backgroundColor,
|
|
143
|
+
stopOpacity: 0.5
|
|
144
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Stop, {
|
|
145
|
+
offset: "0.82",
|
|
146
|
+
stopColor: theme.backgroundColor,
|
|
147
|
+
stopOpacity: 0.18
|
|
148
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Stop, {
|
|
149
|
+
offset: "1",
|
|
150
|
+
stopColor: theme.backgroundColor,
|
|
151
|
+
stopOpacity: 0
|
|
152
|
+
})]
|
|
153
|
+
})
|
|
154
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeSvg.Rect, {
|
|
155
|
+
x: "0",
|
|
156
|
+
y: "0",
|
|
157
|
+
width: "100%",
|
|
158
|
+
height: "100%",
|
|
159
|
+
fill: "url(#stepTopFade)"
|
|
160
|
+
})]
|
|
161
|
+
})
|
|
162
|
+
})]
|
|
163
|
+
})]
|
|
164
|
+
});
|
|
75
165
|
if (avoidKeyboard) {
|
|
76
166
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.KeyboardAvoidingView, {
|
|
77
167
|
style: styles.flex,
|
|
@@ -86,6 +176,14 @@ function StepShell({
|
|
|
86
176
|
// of these at render time (see `contentContainerStyle` above).
|
|
87
177
|
const BASE_PADDING_TOP = 12;
|
|
88
178
|
const BASE_PADDING_BOTTOM = 28;
|
|
179
|
+
// Height of the background-to-transparent gradient masking the ScrollView's
|
|
180
|
+
// top clip edge. Tall on purpose: a long band makes the dissolve a gradual
|
|
181
|
+
// transition rather than a visible line.
|
|
182
|
+
const TOP_FADE_HEIGHT = 120;
|
|
183
|
+
// Scroll distance (px) over which the fade ramps from invisible (at rest) to
|
|
184
|
+
// fully active. Decoupled from TOP_FADE_HEIGHT so the long gradient still kicks
|
|
185
|
+
// in promptly as the user starts scrolling.
|
|
186
|
+
const FADE_RAMP_DISTANCE = 36;
|
|
89
187
|
const styles = _reactNative.StyleSheet.create({
|
|
90
188
|
flex: {
|
|
91
189
|
flex: 1
|
|
@@ -93,6 +191,18 @@ const styles = _reactNative.StyleSheet.create({
|
|
|
93
191
|
scroll: {
|
|
94
192
|
flex: 1
|
|
95
193
|
},
|
|
194
|
+
scrollWrap: {
|
|
195
|
+
flex: 1
|
|
196
|
+
},
|
|
197
|
+
topFade: {
|
|
198
|
+
position: 'absolute',
|
|
199
|
+
top: 0,
|
|
200
|
+
left: 0,
|
|
201
|
+
right: 0
|
|
202
|
+
},
|
|
203
|
+
backStrip: {
|
|
204
|
+
paddingHorizontal: 18
|
|
205
|
+
},
|
|
96
206
|
scrollBody: {
|
|
97
207
|
paddingHorizontal: 18,
|
|
98
208
|
paddingTop: BASE_PADDING_TOP,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_reactNativeSvg","_interopRequireWildcard","_theme","_BackButton","_ProgressBar","_useSafeAreaInsets","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StepShell","title","subtitle","iconNode","children","avoidKeyboard","onBack","backLabel","backDisabled","theme","useTheme","insets","useSafeAreaInsets","showIconCircle","hideStepIcons","showBack","scrollY","useRef","Animated","Value","current","fadeOpacity","interpolate","inputRange","FADE_RAMP_DISTANCE","outputRange","extrapolate","scroll","jsxs","ScrollView","style","styles","scrollEventThrottle","onScroll","event","nativeEvent","contentOffset","y","useNativeDriver","contentContainerStyle","scrollBody","paddingTop","BASE_PADDING_TOP","top","paddingBottom","BASE_PADDING_BOTTOM","bottom","keyboardShouldPersistTaps","View","header","jsx","iconCircle","backgroundColor","primaryColor","shadowColor","withAlpha","accessibilityElementsHidden","importantForAccessibility","Text","color","textColor","textSecondaryColor","column","body","flex","backStrip","PROGRESS_BAR_HEIGHT","BackButton","label","onPress","disabled","scrollWrap","pointerEvents","topFade","height","TOP_FADE_HEIGHT","opacity","width","Defs","LinearGradient","id","x1","y1","x2","y2","Stop","offset","stopColor","stopOpacity","Rect","x","fill","KeyboardAvoidingView","behavior","Platform","OS","undefined","StyleSheet","create","position","left","right","paddingHorizontal","alignItems","marginBottom","borderRadius","justifyContent","shadowOpacity","shadowRadius","shadowOffset","elevation","fontSize","fontWeight","letterSpacing","textAlign","marginTop","lineHeight","maxWidth","alignSelf","gap"],"sourceRoot":"../../../src","sources":["ui/StepShell.tsx"],"mappings":";;;;;;AASA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,eAAA,GAAAC,uBAAA,CAAAH,OAAA;AAMA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,kBAAA,GAAAP,OAAA;AAA+D,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAG,wBAAAM,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,CAAAM,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAA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ty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.PROGRESS_BAR = void 0;
|
|
6
|
+
exports.PROGRESS_BAR_HEIGHT = exports.PROGRESS_BAR = void 0;
|
|
7
7
|
exports.ProgressBar = ProgressBar;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _reactNative = require("react-native");
|
|
@@ -18,6 +18,12 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
18
18
|
* Reanimated yet; respects `useReducedMotion()`.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Height of the progress track, in px. Exported so layout-aware chrome (e.g.
|
|
23
|
+
* `StepShell`'s fixed back-button strip) can sit flush below the bar without
|
|
24
|
+
* duplicating the magic number.
|
|
25
|
+
*/
|
|
26
|
+
const PROGRESS_BAR_HEIGHT = exports.PROGRESS_BAR_HEIGHT = 4;
|
|
21
27
|
function ProgressBar({
|
|
22
28
|
value,
|
|
23
29
|
hidden = false
|
|
@@ -84,7 +90,7 @@ const PROGRESS_BAR = exports.PROGRESS_BAR = {
|
|
|
84
90
|
};
|
|
85
91
|
const styles = _reactNative.StyleSheet.create({
|
|
86
92
|
track: {
|
|
87
|
-
height:
|
|
93
|
+
height: PROGRESS_BAR_HEIGHT,
|
|
88
94
|
width: '100%',
|
|
89
95
|
overflow: 'hidden'
|
|
90
96
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_reactNative","_theme","_jsxRuntime","ProgressBar","value","hidden","theme","useTheme","reduceMotion","useReducedMotion","widthAnim","useRef","Animated","Value","current","opacityAnim","useEffect","timing","toValue","duration","useNativeDriver","start","trackColor","mixHex","borderColor","backgroundColor","jsx","View","accessibilityRole","accessibilityValue","now","Math","round","min","max","style","styles","track","opacity","children","bar","primaryColor","width","interpolate","inputRange","outputRange","STEP_INCREMENT_PCT","SOFT_CAP_PCT","PROGRESS_BAR","
|
|
1
|
+
{"version":3,"names":["_react","require","_reactNative","_theme","_jsxRuntime","PROGRESS_BAR_HEIGHT","exports","ProgressBar","value","hidden","theme","useTheme","reduceMotion","useReducedMotion","widthAnim","useRef","Animated","Value","current","opacityAnim","useEffect","timing","toValue","duration","useNativeDriver","start","trackColor","mixHex","borderColor","backgroundColor","jsx","View","accessibilityRole","accessibilityValue","now","Math","round","min","max","style","styles","track","opacity","children","bar","primaryColor","width","interpolate","inputRange","outputRange","STEP_INCREMENT_PCT","SOFT_CAP_PCT","PROGRESS_BAR","tick","complete","reset","StyleSheet","create","height","overflow"],"sourceRoot":"../../../../src","sources":["ui/overlays/ProgressBar.tsx"],"mappings":";;;;;;;AASA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAA8D,IAAAG,WAAA,GAAAH,OAAA;AAX9D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACO,MAAMI,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,CAAC;AAS7B,SAASE,WAAWA,CAAC;EAAEC,KAAK;EAAEC,MAAM,GAAG;AAAwB,CAAC,EAAE;EACvE,MAAMC,KAAK,GAAG,IAAAC,eAAQ,EAAC,CAAC;EACxB,MAAMC,YAAY,GAAG,IAAAC,uBAAgB,EAAC,CAAC;EACvC,MAAMC,SAAS,GAAG,IAAAC,aAAM,EAAC,IAAIC,qBAAQ,CAACC,KAAK,CAACT,KAAK,CAAC,CAAC,CAACU,OAAO;EAC3D,MAAMC,WAAW,GAAG,IAAAJ,aAAM,EAAC,IAAIC,qBAAQ,CAACC,KAAK,CAACR,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAACS,OAAO;EAEtE,IAAAE,gBAAS,EAAC,MAAM;IACdJ,qBAAQ,CAACK,MAAM,CAACP,SAAS,EAAE;MACzBQ,OAAO,EAAEd,KAAK;MACde,QAAQ,EAAEX,YAAY,GAAG,CAAC,G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C,IAAI,EAAE,MAAM;QAC5B,CAAC;MACH,CAAC;IACD,CACH;EAAC,CACW,CAAC;AAEpB;AAEA,MAAMC,kBAAkB,GAAG,EAAE;AAC7B,MAAMC,YAAY,GAAG,EAAE;;AAEvB;AACA;AACA;AACA;AACA;AACO,MAAMC,YAAY,GAAA9C,OAAA,CAAA8C,YAAA,GAAG;EAC1BC,IAAIA,CAACnC,OAAe,EAAU;IAC5B,OAAOiB,IAAI,CAACE,GAAG,CAACc,YAAY,EAAEjC,OAAO,GAAGgC,kBAAkB,CAAC;EAC7D,CAAC;EACDI,QAAQA,CAAA,EAAW;IACjB,OAAO,GAAG;EACZ,CAAC;EACDC,KAAKA,CAAA,EAAW;IACd,OAAO,CAAC;EACV;AACF,CAAC;AAED,MAAMf,MAAM,GAAGgB,uBAAU,CAACC,MAAM,CAAC;EAC/BhB,KAAK,EAAE;IACLiB,MAAM,EAAErD,mBAAmB;IAC3ByC,KAAK,EAAE,MAAM;IACba,QAAQ,EAAE;EACZ,CAAC;EACDf,GAAG,EAAE;IACHc,MAAM,EAAE;EACV;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DEFAULT_CROP_MARGIN = void 0;
|
|
7
|
+
exports.computeCutout = computeCutout;
|
|
8
|
+
exports.computeGuideCropRect = computeGuideCropRect;
|
|
9
|
+
exports.isGuideSpaceConsistent = isGuideSpaceConsistent;
|
|
10
|
+
/**
|
|
11
|
+
* @fileoverview Geometry for the document capture guide + crop.
|
|
12
|
+
*
|
|
13
|
+
* Two pure helpers, shared between the camera overlay and the post-capture
|
|
14
|
+
* crop so the pixels we keep are *exactly* the rectangle the user framed:
|
|
15
|
+
*
|
|
16
|
+
* - `computeCutout` — the on-screen ID-1 guide rectangle (screen px).
|
|
17
|
+
* - `computeGuideCropRect` — maps that guide rectangle into the captured
|
|
18
|
+
* photo's pixel space, compensating for the camera preview's `cover` fit
|
|
19
|
+
* (the preview center-crops the sensor frame to the screen aspect ratio).
|
|
20
|
+
*
|
|
21
|
+
* This is a *geometric* crop to a fixed guide, NOT edge detection / OpenCV —
|
|
22
|
+
* we never inspect pixels. The backend's Document AI still runs OCR and its
|
|
23
|
+
* own face crop on top, so we keep a safety margin around the guide to avoid
|
|
24
|
+
* clipping the document (or the portrait the backend needs).
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
// ID-1 aspect ratios (width / height). Portrait ≈ 0.625 (held vertically),
|
|
28
|
+
// landscape ≈ 1.586 (the real ID-1 card ratio, 85.6 × 53.98 mm).
|
|
29
|
+
const PORTRAIT_ASPECT = 0.625;
|
|
30
|
+
const LANDSCAPE_ASPECT = 1.586;
|
|
31
|
+
|
|
32
|
+
// The guide is 85% of screen width, but never taller than 62% of screen height
|
|
33
|
+
// (portrait ID-1 on tall phones would otherwise overflow).
|
|
34
|
+
const CUTOUT_WIDTH_RATIO = 0.85;
|
|
35
|
+
const CUTOUT_MAX_HEIGHT_RATIO = 0.62;
|
|
36
|
+
|
|
37
|
+
/** Default crop margin: expand each side of the guide by this fraction of the
|
|
38
|
+
* guide size, so a document slightly overflowing the frame isn't clipped. */
|
|
39
|
+
const DEFAULT_CROP_MARGIN = exports.DEFAULT_CROP_MARGIN = 0.07;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The on-screen guide rectangle, in screen pixels. Mirrors what the mask
|
|
43
|
+
* overlay draws so the crop matches the visible cutout exactly.
|
|
44
|
+
*/
|
|
45
|
+
function computeCutout(screenW, screenH, orientation) {
|
|
46
|
+
const aspectRatio = orientation === 'portrait' ? PORTRAIT_ASPECT : LANDSCAPE_ASPECT;
|
|
47
|
+
let width = screenW * CUTOUT_WIDTH_RATIO;
|
|
48
|
+
let height = width / aspectRatio;
|
|
49
|
+
const maxH = screenH * CUTOUT_MAX_HEIGHT_RATIO;
|
|
50
|
+
if (height > maxH) {
|
|
51
|
+
height = maxH;
|
|
52
|
+
width = height * aspectRatio;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
left: (screenW - width) / 2,
|
|
56
|
+
top: (screenH - height) / 2,
|
|
57
|
+
width,
|
|
58
|
+
height
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Map the on-screen guide rectangle into the captured photo's pixel space.
|
|
64
|
+
*
|
|
65
|
+
* The preview renders the photo with `cover` fit: the sensor frame is scaled
|
|
66
|
+
* up until it fills the screen and the overflow is center-cropped. So a screen
|
|
67
|
+
* point `(sx, sy)` maps to photo pixel `((W_img - W_screen/s)/2 + sx/s, …)`,
|
|
68
|
+
* where `s = max(W_screen/W_img, H_screen/H_img)`.
|
|
69
|
+
*
|
|
70
|
+
* `imageW`/`imageH` MUST be the photo's *display* (orientation-normalized)
|
|
71
|
+
* dimensions — i.e. portrait when the device is portrait — not the raw sensor
|
|
72
|
+
* dimensions, which are often landscape with an EXIF rotation flag.
|
|
73
|
+
*
|
|
74
|
+
* The result is expanded by `margin` (fraction of the mapped guide) and
|
|
75
|
+
* clamped to the image bounds, then rounded to integers (the manipulator
|
|
76
|
+
* rejects fractional crop rects).
|
|
77
|
+
*/
|
|
78
|
+
/**
|
|
79
|
+
* Whether the guide rectangle can be mapped onto the photo at all (OSDKR-13).
|
|
80
|
+
*
|
|
81
|
+
* `computeGuideCropRect` inverts a `cover` fit, which only makes sense when the
|
|
82
|
+
* screen and the photo are in the *same* orientation space — the photo is the
|
|
83
|
+
* preview the guide was drawn over. If the two disagree (a portrait screen and
|
|
84
|
+
* a landscape photo), something upstream rotated the capture and any rect we
|
|
85
|
+
* compute would address the wrong pixels. Callers should skip the crop and
|
|
86
|
+
* upload the full photo instead of shipping a garbage region.
|
|
87
|
+
*/
|
|
88
|
+
function isGuideSpaceConsistent(params) {
|
|
89
|
+
const {
|
|
90
|
+
screenW,
|
|
91
|
+
screenH,
|
|
92
|
+
imageW,
|
|
93
|
+
imageH
|
|
94
|
+
} = params;
|
|
95
|
+
if (imageW <= 0 || imageH <= 0 || screenW <= 0 || screenH <= 0) return false;
|
|
96
|
+
return screenW >= screenH === imageW >= imageH;
|
|
97
|
+
}
|
|
98
|
+
function computeGuideCropRect(params) {
|
|
99
|
+
const {
|
|
100
|
+
screenW,
|
|
101
|
+
screenH,
|
|
102
|
+
imageW,
|
|
103
|
+
imageH,
|
|
104
|
+
cutout,
|
|
105
|
+
margin = DEFAULT_CROP_MARGIN
|
|
106
|
+
} = params;
|
|
107
|
+
const scale = Math.max(screenW / imageW, screenH / imageH);
|
|
108
|
+
// Image pixels hidden off each edge by the cover crop.
|
|
109
|
+
const offsetX = (imageW - screenW / scale) / 2;
|
|
110
|
+
const offsetY = (imageH - screenH / scale) / 2;
|
|
111
|
+
let x = offsetX + cutout.left / scale;
|
|
112
|
+
let y = offsetY + cutout.top / scale;
|
|
113
|
+
let width = cutout.width / scale;
|
|
114
|
+
let height = cutout.height / scale;
|
|
115
|
+
|
|
116
|
+
// Expand by the safety margin.
|
|
117
|
+
const mx = width * margin;
|
|
118
|
+
const my = height * margin;
|
|
119
|
+
x -= mx;
|
|
120
|
+
y -= my;
|
|
121
|
+
width += mx * 2;
|
|
122
|
+
height += my * 2;
|
|
123
|
+
|
|
124
|
+
// Clamp to image bounds.
|
|
125
|
+
x = Math.max(0, x);
|
|
126
|
+
y = Math.max(0, y);
|
|
127
|
+
width = Math.min(width, imageW - x);
|
|
128
|
+
height = Math.min(height, imageH - y);
|
|
129
|
+
return {
|
|
130
|
+
x: Math.round(x),
|
|
131
|
+
y: Math.round(y),
|
|
132
|
+
width: Math.round(width),
|
|
133
|
+
height: Math.round(height)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=documentCrop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["PORTRAIT_ASPECT","LANDSCAPE_ASPECT","CUTOUT_WIDTH_RATIO","CUTOUT_MAX_HEIGHT_RATIO","DEFAULT_CROP_MARGIN","exports","computeCutout","screenW","screenH","orientation","aspectRatio","width","height","maxH","left","top","isGuideSpaceConsistent","params","imageW","imageH","computeGuideCropRect","cutout","margin","scale","Math","max","offsetX","offsetY","x","y","mx","my","min","round"],"sourceRoot":"../../../src","sources":["utils/documentCrop.ts"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA,MAAMA,eAAe,GAAG,KAAK;AAC7B,MAAMC,gBAAgB,GAAG,KAAK;;AAE9B;AACA;AACA,MAAMC,kBAAkB,GAAG,IAAI;AAC/B,MAAMC,uBAAuB,GAAG,IAAI;;AAEpC;AACA;AACO,MAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,IAAI;;AAEvC;AACA;AACA;AACA;AACO,SAASE,aAAaA,CAC3BC,OAAe,EACfC,OAAe,EACfC,WAAgC,EACpB;EACZ,MAAMC,WAAW,GACfD,WAAW,KAAK,UAAU,GAAGT,eAAe,GAAGC,gBAAgB;EAEjE,IAAIU,KAAK,GAAGJ,OAAO,GAAGL,kBAAkB;EACxC,IAAIU,MAAM,GAAGD,KAAK,GAAGD,WAAW;EAChC,MAAMG,IAAI,GAAGL,OAAO,GAAGL,uBAAuB;EAC9C,IAAIS,MAAM,GAAGC,IAAI,EAAE;IACjBD,MAAM,GAAGC,IAAI;IACbF,KAAK,GAAGC,MAAM,GAAGF,WAAW;EAC9B;EACA,OAAO;IACLI,IAAI,EAAE,CAACP,OAAO,GAAGI,KAAK,IAAI,CAAC;IAC3BI,GAAG,EAAE,CAACP,OAAO,GAAGI,MAAM,IAAI,CAAC;IAC3BD,KAAK;IACLC;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA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;EACflB,MAAM,IAAImB,EAAE,GAAG,CAAC;;EAEhB;EACAH,CAAC,GAAGJ,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEG,CAAC,CAAC;EAClBC,CAAC,GAAGL,IAAI,CAACC,GAAG,CAAC,CAAC,EAAEI,CAAC,CAAC;EAClBlB,KAAK,GAAGa,IAAI,CAACQ,GAAG,CAACrB,KAAK,EAAEO,MAAM,GAAGU,CAAC,CAAC;EACnChB,MAAM,GAAGY,IAAI,CAACQ,GAAG,CAACpB,MAAM,EAAEO,MAAM,GAAGU,CAAC,CAAC;EAErC,OAAO;IACLD,CAAC,EAAEJ,IAAI,CAACS,KAAK,CAACL,CAAC,CAAC;IAChBC,CAAC,EAAEL,IAAI,CAACS,KAAK,CAACJ,CAAC,CAAC;IAChBlB,KAAK,EAAEa,IAAI,CAACS,KAAK,CAACtB,KAAK,CAAC;IACxBC,MAAM,EAAEY,IAAI,CAACS,KAAK,CAACrB,MAAM;EAC3B,CAAC;AACH","ignoreList":[]}
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
* triggers `takePhoto()` with `qualityPrioritization: 'balanced'`; the file
|
|
8
8
|
* URI is returned to the caller via `onCaptured`.
|
|
9
9
|
*
|
|
10
|
-
* Visual: dark scrim with a transparent rectangular cutout (ID-1
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
10
|
+
* Visual: dark scrim with a transparent rectangular cutout (ID-1 ratio). The
|
|
11
|
+
* cutout is both the visible guide AND the crop region: on capture we hand the
|
|
12
|
+
* caller the guide rectangle so the photo can be cropped to exactly what the
|
|
13
|
+
* user framed (OSDKR-2). This is a geometric crop to a fixed guide — NOT edge
|
|
14
|
+
* detection / OpenCV; we never inspect pixels. The backend's Document AI still
|
|
15
|
+
* runs OCR and its own face crop on top.
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
@@ -22,6 +22,12 @@ import { Camera, useCameraDevice, useCameraPermission } from 'react-native-visio
|
|
|
22
22
|
import { useTheme, withAlpha } from '../ui/theme';
|
|
23
23
|
import { Button } from '../ui/primitives/Button';
|
|
24
24
|
import { useSafeAreaInsets } from '../utils/useSafeAreaInsets';
|
|
25
|
+
import { computeCutout } from '../utils/documentCrop';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Geometry of the on-screen guide at capture time, handed to `onCaptured` so
|
|
29
|
+
* the photo can be cropped to exactly what the user framed.
|
|
30
|
+
*/
|
|
25
31
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
26
32
|
export function DocumentCapture({
|
|
27
33
|
side,
|
|
@@ -31,11 +37,16 @@ export function DocumentCapture({
|
|
|
31
37
|
permissionDeniedLabel,
|
|
32
38
|
retryLabel,
|
|
33
39
|
cancelLabel,
|
|
40
|
+
processingLabel,
|
|
34
41
|
onCaptured,
|
|
35
42
|
onCancel
|
|
36
43
|
}) {
|
|
37
44
|
const theme = useTheme();
|
|
38
45
|
const insets = useSafeAreaInsets();
|
|
46
|
+
const {
|
|
47
|
+
width: screenW,
|
|
48
|
+
height: screenH
|
|
49
|
+
} = useWindowDimensions();
|
|
39
50
|
const cameraRef = useRef(null);
|
|
40
51
|
// Cross-platform back-camera selection.
|
|
41
52
|
//
|
|
@@ -129,13 +140,23 @@ export function DocumentCapture({
|
|
|
129
140
|
flash: 'off',
|
|
130
141
|
enableShutterSound: false
|
|
131
142
|
});
|
|
132
|
-
|
|
143
|
+
// Await the caller's crop/compress so the processing overlay stays up
|
|
144
|
+
// for the whole capture→preview gap (a few seconds), giving the user
|
|
145
|
+
// feedback instead of an idle camera. On success the parent flips phase
|
|
146
|
+
// and this component unmounts; on failure / "stay on capture" the finally
|
|
147
|
+
// re-enables the shutter.
|
|
148
|
+
const cutout = computeCutout(screenW, screenH, orientation);
|
|
149
|
+
await onCaptured(photo, side, {
|
|
150
|
+
cutout,
|
|
151
|
+
screenW,
|
|
152
|
+
screenH
|
|
153
|
+
});
|
|
133
154
|
} catch (err) {
|
|
134
155
|
setError(err instanceof Error ? err.message : String(err));
|
|
135
156
|
} finally {
|
|
136
157
|
setShooting(false);
|
|
137
158
|
}
|
|
138
|
-
}, [onCaptured, side, shooting]);
|
|
159
|
+
}, [onCaptured, side, shooting, orientation, screenW, screenH]);
|
|
139
160
|
if (!hasPermission) {
|
|
140
161
|
return /*#__PURE__*/_jsxs(View, {
|
|
141
162
|
style: [styles.permission, {
|
|
@@ -204,7 +225,24 @@ export function DocumentCapture({
|
|
|
204
225
|
style: StyleSheet.absoluteFill,
|
|
205
226
|
device: device,
|
|
206
227
|
photo: true,
|
|
207
|
-
photoQualityBalance: "quality"
|
|
228
|
+
photoQualityBalance: "quality"
|
|
229
|
+
// Lock the captured photo to the *preview's* orientation (OSDKR-13).
|
|
230
|
+
// vision-camera defaults to `outputOrientation="device"`, which emits
|
|
231
|
+
// the photo in whatever orientation the phone is physically held —
|
|
232
|
+
// even though this screen is locked to portrait and both the preview
|
|
233
|
+
// and the ID-1 guide stay portrait. A user tilting the phone sideways
|
|
234
|
+
// to frame a landscape card therefore got a photo rotated 90° from
|
|
235
|
+
// what they framed, and the guide→photo crop mapping (which is in
|
|
236
|
+
// screen space) landed on the wrong region. With `preview` the photo
|
|
237
|
+
// always comes back in the orientation the user saw.
|
|
238
|
+
,
|
|
239
|
+
outputOrientation: "preview"
|
|
240
|
+
// Explicit `cover`: the guide-crop math in `computeGuideCropRect`
|
|
241
|
+
// assumes the preview center-crops the sensor frame to the screen
|
|
242
|
+
// aspect ratio. `cover` is vision-camera's default, but we pin it so
|
|
243
|
+
// the crop never silently drifts if that default changes.
|
|
244
|
+
,
|
|
245
|
+
resizeMode: "cover",
|
|
208
246
|
enableZoomGesture: false,
|
|
209
247
|
isActive: true
|
|
210
248
|
}), /*#__PURE__*/_jsx(Pressable, {
|
|
@@ -266,12 +304,19 @@ export function DocumentCapture({
|
|
|
266
304
|
}]
|
|
267
305
|
})
|
|
268
306
|
})]
|
|
269
|
-
})
|
|
307
|
+
}), shooting ? /*#__PURE__*/_jsxs(View, {
|
|
308
|
+
style: styles.processingOverlay,
|
|
309
|
+
children: [/*#__PURE__*/_jsx(ActivityIndicator, {
|
|
310
|
+
color: "#FFFFFF",
|
|
311
|
+
size: "large"
|
|
312
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
313
|
+
style: styles.processingText,
|
|
314
|
+
children: processingLabel
|
|
315
|
+
})]
|
|
316
|
+
}) : null]
|
|
270
317
|
});
|
|
271
318
|
}
|
|
272
319
|
const FOCUS_RING_SIZE = 64;
|
|
273
|
-
const CUTOUT_WIDTH_RATIO = 0.85; // 85% of screen width
|
|
274
|
-
const CUTOUT_MAX_HEIGHT_RATIO = 0.62; // never taller than 62% of screen height
|
|
275
320
|
const CORNER_LENGTH = 28;
|
|
276
321
|
const CORNER_THICKNESS = 3;
|
|
277
322
|
/**
|
|
@@ -288,20 +333,14 @@ function DocumentMaskOverlay({
|
|
|
288
333
|
width: screenW,
|
|
289
334
|
height: screenH
|
|
290
335
|
} = useWindowDimensions();
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (cutoutH > maxH) {
|
|
300
|
-
cutoutH = maxH;
|
|
301
|
-
cutoutW = cutoutH * aspectRatio;
|
|
302
|
-
}
|
|
303
|
-
const left = (screenW - cutoutW) / 2;
|
|
304
|
-
const top = (screenH - cutoutH) / 2;
|
|
336
|
+
// Shared with the post-capture crop (`computeGuideCropRect`) so the dimmed
|
|
337
|
+
// cutout the user sees and the pixels we keep are the exact same rectangle.
|
|
338
|
+
const {
|
|
339
|
+
left,
|
|
340
|
+
top,
|
|
341
|
+
width: cutoutW,
|
|
342
|
+
height: cutoutH
|
|
343
|
+
} = computeCutout(screenW, screenH, orientation);
|
|
305
344
|
const R = CUTOUT_RADIUS;
|
|
306
345
|
|
|
307
346
|
// SVG mask: opaque outer rect minus a rounded inner rect. The mask paints
|
|
@@ -503,6 +542,19 @@ const styles = StyleSheet.create({
|
|
|
503
542
|
borderWidth: 2,
|
|
504
543
|
borderColor: '#FFFFFF',
|
|
505
544
|
backgroundColor: 'transparent'
|
|
545
|
+
},
|
|
546
|
+
processingOverlay: {
|
|
547
|
+
...StyleSheet.absoluteFillObject,
|
|
548
|
+
alignItems: 'center',
|
|
549
|
+
justifyContent: 'center',
|
|
550
|
+
gap: 14,
|
|
551
|
+
backgroundColor: 'rgba(0,0,0,0.6)'
|
|
552
|
+
},
|
|
553
|
+
processingText: {
|
|
554
|
+
color: '#FFFFFF',
|
|
555
|
+
fontSize: 15,
|
|
556
|
+
fontWeight: '600',
|
|
557
|
+
textAlign: 'center'
|
|
506
558
|
}
|
|
507
559
|
});
|
|
508
560
|
//# sourceMappingURL=DocumentCapture.js.map
|