biometry-react-components 1.2.17 → 1.3.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/README.md CHANGED
@@ -31,14 +31,14 @@ Captures ID documents, driver license and etc. Suitable component for Biometry's
31
31
  import { DocScan } from 'biometry-react-components';
32
32
 
33
33
  function DocumentCapture() {
34
- const handleCapture = (file: File) => {
35
- console.log('Captured document:', file);
34
+ const handleConfirmCapture = (file: File) => {
35
+ console.log('Confirmed captured document:', file);
36
36
  // Send file to your endpoint that will process DocAuth (we recommend this way, because you will not expose the API key on client side)
37
37
  // or
38
38
  // const response = await sdk.checkDocAuth(file, userFullName, { sessionId });
39
39
  };
40
40
 
41
- return <DocScan onCapture={handleCapture} />;
41
+ return <DocScan onConfirmCapture={handleConfirmCapture} />;
42
42
  }
43
43
  ```
44
44
 
@@ -46,7 +46,8 @@ function DocumentCapture() {
46
46
 
47
47
  | Prop | Type | Default | Description |
48
48
  |------|------|---------|-------------|
49
- | `onCapture` | `(file: File) => void` | **required** | Callback with captured image file |
49
+ | `onConfirmCapture` | `(file: File) => void` | **required** | Callback with captured image file. Triggered when the user confirms the captured image/document |
50
+ | `onCapture` | `(file: File) => void` | *optional* | Callback with captured image file. Triggered automatically when image/document capture finishes. |
50
51
  | `rectWidth` | `number` | `640` | Width of camera area |
51
52
  | `rectHeight` | `number` | `400` | Height of camera area |
52
53
  | `className` | `string` | - | Custom CSS class |
@@ -61,14 +62,12 @@ Captures facial images with an oval guidance overlay. Ideal for [Face Match](htt
61
62
  import { FaceCapture } from 'biometry-react-components';
62
63
 
63
64
  function FaceCapture() {
64
- const handleCapture = (file: File) => {
65
- console.log('Captured face:', file);
66
- // Send file to your endpoint that will process DocAuth (we recommend this way, because you will not expose the API key on client side)
67
- // or
65
+ const handleConfirmCapture = (file: File) => {
66
+ console.log('Confirmed captured face:', file);
68
67
  // const response = await sdk.enrollFace(file, 'John Doe');
69
68
  };
70
69
 
71
- return <FaceCapture onCapture={handleCapture} />;
70
+ return <FaceCapture onConfirmCapture={handleConfirmCapture} />;
72
71
  }
73
72
  ```
74
73
 
@@ -76,7 +75,8 @@ function FaceCapture() {
76
75
 
77
76
  | Prop | Type | Default | Description |
78
77
  |------|------|---------|-------------|
79
- | `onCapture` | `(file: File) => void` | **required** | Callback with captured image file |
78
+ | `onConfirmCapture` | `(file: File) => void` | **required** | Callback with captured image file. Triggered when the user confirms the captured image |
79
+ | `onCapture` | `(file: File) => void` | *optional* | Callback with captured image file. Triggered automatically when user captures the image. |
80
80
  | `rectWidth` | `number` | `360` | Width of camera area |
81
81
  | `rectHeight` | `number` | `576` | Height of camera area |
82
82
  | `className` | `string` | - | Custom CSS class |
@@ -110,7 +110,7 @@ function FaceRecorder() {
110
110
  | Prop | Type | Default | Description |
111
111
  |------|------|---------|-------------|
112
112
  | `onConfirmRecording` | `(video: File, audio: File, phrase: string) => void` | **required** | Triggered when the user confirms they want to use the recorded video. Provides both media files and the spoken phrase. |
113
- | `onRecordingComplete` | `(video: File, audio: File, phrase: string) => void` | - | Triggered automatically right after recording finishes. Useful for pre-uploading or background processing. *Optional* |
113
+ | `onRecorded` | `(video: File, audio: File, phrase: string) => void` | *optional* | Triggered automatically right after recording finishes. Useful for pre-uploading or background processing. |
114
114
  | `rectWidth` | `number` | `360` | Width of camera area |
115
115
  | `rectHeight` | `number` | `576` | Height of camera area |
116
116
  | `className` | `string` | - | Custom CSS class |
@@ -125,15 +125,13 @@ Records audio with real-time waveform visualization and adaptive quality setting
125
125
  import { VoiceRecorder } from 'biometry-react-components';
126
126
 
127
127
  function VoiceRecorder() {
128
- const handleCapture = (file: File, phrase: string) => {
129
- console.log('Captured audio:', file);
128
+ const handleConfirm = (file: File, phrase: string) => {
129
+ console.log('Confirmed audio:', file);
130
130
  console.log('Phrase:', phrase);
131
- // Send file to your endpoint that will process DocAuth (we recommend this way, because you will not expose the API key on client side)
132
- // or
133
131
  // const response = await sdk.enrollVoice(file, 'John Doe');
134
132
  };
135
133
 
136
- return <VoiceRecorder onCapture={handleCapture} />;
134
+ return <VoiceRecorder onConfirmRecording={handleConfirm} />;
137
135
  }
138
136
  ```
139
137
 
@@ -141,7 +139,8 @@ function VoiceRecorder() {
141
139
 
142
140
  | Prop | Type | Default | Description |
143
141
  |------|------|---------|-------------|
144
- | `onCapture` | `(file: File, phrase: string) => void` | **required** | Callback with captured audio file and phrase |
142
+ | `onConfirmRecording` | `(file: File, phrase: string) => void` | **required** | Callback with captured audio file and phrase. Triggered when the user confirms the recorded media |
143
+ | `onRecorded` | `(file: File, phrase: string) => void` | *optional* | Callback with captured audio file and phrase. Triggered automatically when recording finishes |
145
144
  | `rectWidth` | `number` | `360` | Width of component area |
146
145
  | `rectHeight` | `number` | `undefined` | Height of component area (optional) |
147
146
  | `className` | `string` | - | Custom CSS class |
package/dist/index.d.ts CHANGED
@@ -3,7 +3,8 @@ import React from 'react';
3
3
  interface DocScanProps {
4
4
  rectWidth?: number;
5
5
  rectHeight?: number;
6
- onCapture: (file: File) => void;
6
+ onConfirmCapture: (file: File) => void;
7
+ onCapture?: (file: File) => void;
7
8
  className?: string;
8
9
  style?: React.CSSProperties;
9
10
  noShadow?: boolean;
@@ -13,7 +14,8 @@ declare const DocScan: React.FC<DocScanProps>;
13
14
  interface FaceCaptureProps {
14
15
  rectWidth?: number;
15
16
  rectHeight?: number;
16
- onCapture: (file: File) => void;
17
+ onConfirmCapture: (file: File) => void;
18
+ onCapture?: (file: File) => void;
17
19
  className?: string;
18
20
  style?: React.CSSProperties;
19
21
  noShadow?: boolean;
@@ -24,7 +26,7 @@ interface FaceRecorderProps {
24
26
  rectWidth?: number;
25
27
  rectHeight?: number;
26
28
  onConfirmRecording: (file: File, audio: File, phrase: string) => void;
27
- onRecordingComplete?: (video: File, audio: File, phrase: string) => void;
29
+ onRecorded?: (video: File, audio: File, phrase: string) => void;
28
30
  className?: string;
29
31
  style?: React.CSSProperties;
30
32
  noShadow?: boolean;
@@ -34,7 +36,8 @@ declare const FaceRecorder: React.FC<FaceRecorderProps>;
34
36
  interface VoiceRecorderProps {
35
37
  rectWidth?: number;
36
38
  rectHeight?: number | undefined;
37
- onCapture: (file: File, phrase: string) => void;
39
+ onConfirmRecording: (file: File, phrase: string) => void;
40
+ onRecorded?: (file: File, phrase: string) => void;
38
41
  className?: string;
39
42
  style?: React.CSSProperties;
40
43
  noShadow?: boolean;
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,useEffect}from'react';const DocScan = ({ rectWidth = 640, rectHeight = 400, onCapture, className, style, noShadow = false, }) => {
1
+ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,useEffect}from'react';const DocScan = ({ rectWidth = 640, rectHeight = 400, onConfirmCapture, onCapture, className, style, noShadow = false, }) => {
2
2
  const [isConfirming, setIsConfirming] = useState(false);
3
3
  const [capturedUrl, setCapturedUrl] = useState(null);
4
4
  const [capturedFile, setCapturedFile] = useState(null);
@@ -65,13 +65,21 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
65
65
  setCapturedFile(file);
66
66
  setCapturedUrl(URL.createObjectURL(blob));
67
67
  setIsConfirming(true);
68
+ if (onCapture) {
69
+ try {
70
+ onCapture(file);
71
+ }
72
+ catch (err) {
73
+ console.error('onCapture callback threw:', err);
74
+ }
75
+ }
68
76
  }
69
77
  }, "image/jpeg", 0.98);
70
78
  }
71
79
  };
72
80
  const handleConfirm = () => {
73
81
  if (capturedFile) {
74
- onCapture(capturedFile);
82
+ onConfirmCapture(capturedFile);
75
83
  }
76
84
  };
77
85
  const handleDecline = () => {
@@ -176,6 +184,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
176
184
  objectFit: 'cover',
177
185
  borderRadius: noShadow ? 0 : 8,
178
186
  zIndex: 0,
187
+ transform: 'scaleX(-1)'
179
188
  }, playsInline: true, muted: true, autoPlay: true }), jsx("div", { className: "docscan-dark-overlay", style: {
180
189
  position: 'absolute',
181
190
  top: 0,
@@ -186,7 +195,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
186
195
  zIndex: 1,
187
196
  borderRadius: noShadow ? 0 : 8,
188
197
  } }), jsx("div", { className: "docscan-dashed-area", style: defaultDashedArea, children: jsx("span", { className: "docscan-guidance-text", style: defaultGuidanceText, children: "Place your document here" }) })] }), jsx("button", { type: "button", className: "docscan-capture-btn", style: defaultCaptureButton, onClick: handleCapture, children: "Capture" })] })) : (jsxs(Fragment, { children: [jsx("div", { className: "docscan-preview", style: defaultPreview, children: capturedUrl && (jsx("img", { src: capturedUrl, alt: "Captured document", className: "docscan-preview-img", style: { maxWidth: '100%', maxHeight: '100%', borderRadius: 8 } })) }), jsx("div", { className: "docscan-confirm-text", style: defaultConfirmText, children: "Do you want to use this photo?" }), jsxs("div", { className: "docscan-confirm-btns", style: { display: 'flex', justifyContent: 'center', gap: 32, marginTop: 16, width: '100%' }, children: [jsx("button", { type: "button", "aria-label": "Retake", className: "docscan-icon-btn", style: defaultIconButton, onClick: handleDecline, onMouseOver: e => (e.currentTarget.style.background = 'rgba(211,47,47,0.12)'), onMouseOut: e => (e.currentTarget.style.background = 'none'), children: jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("circle", { cx: "18", cy: "18", r: "18", fill: "#fff", fillOpacity: "0.15" }), jsx("path", { d: "M12 12L24 24", stroke: "#d32f2f", strokeWidth: "3", strokeLinecap: "round" }), jsx("path", { d: "M24 12L12 24", stroke: "#d32f2f", strokeWidth: "3", strokeLinecap: "round" })] }) }), jsx("button", { type: "button", "aria-label": "Confirm", className: "docscan-icon-btn", style: defaultIconButton, onClick: handleConfirm, onMouseOver: e => (e.currentTarget.style.background = 'rgba(56,142,60,0.12)'), onMouseOut: e => (e.currentTarget.style.background = 'none'), children: jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsx("circle", { cx: "18", cy: "18", r: "18", fill: "#fff", fillOpacity: "0.15" }), jsx("path", { d: "M10 19L16 25L26 13", stroke: "#388e3c", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" })] }) })] })] })) }));
189
- };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onCapture, className, style, noShadow = false, }) => {
198
+ };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onConfirmCapture, onCapture, className, style, noShadow = false, }) => {
190
199
  const [isConfirming, setIsConfirming] = useState(false);
191
200
  const [capturedUrl, setCapturedUrl] = useState(null);
192
201
  const [capturedFile, setCapturedFile] = useState(null);
@@ -237,13 +246,21 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
237
246
  setCapturedFile(file);
238
247
  setCapturedUrl(URL.createObjectURL(blob));
239
248
  setIsConfirming(true);
249
+ if (onCapture) {
250
+ try {
251
+ onCapture(file);
252
+ }
253
+ catch (err) {
254
+ console.error('onCapture callback threw:', err);
255
+ }
256
+ }
240
257
  }
241
258
  }, "image/jpeg", 0.98);
242
259
  }
243
260
  };
244
261
  const handleConfirm = () => {
245
262
  if (capturedFile) {
246
- onCapture(capturedFile);
263
+ onConfirmCapture(capturedFile);
247
264
  }
248
265
  };
249
266
  const handleDecline = () => {
@@ -325,8 +342,8 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
325
342
  display: 'block',
326
343
  };
327
344
  const preview = {
328
- width: rectWidth - 25,
329
- height: rectHeight - 25,
345
+ width: '100%',
346
+ height: '100%',
330
347
  display: 'flex',
331
348
  alignItems: 'center',
332
349
  justifyContent: 'center',
@@ -357,6 +374,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
357
374
  objectFit: 'cover',
358
375
  borderRadius: noShadow ? 0 : 8,
359
376
  zIndex: 0,
377
+ transform: 'scaleX(-1)'
360
378
  }, playsInline: true, muted: true, autoPlay: true }), jsx("div", { className: "facecapture-dark-overlay", style: {
361
379
  position: 'absolute',
362
380
  top: 0,
@@ -7279,7 +7297,7 @@ function generateRandomDigits$1(count) {
7279
7297
  }
7280
7298
  return digits.slice(0, count);
7281
7299
  }
7282
- const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, onRecordingComplete, className, style, noShadow = false, }) => {
7300
+ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, onRecorded, className, style, noShadow = false, }) => {
7283
7301
  const [state, setState] = useState('preparation');
7284
7302
  const [prepTimer, setPrepTimer] = useState(PREP_SECONDS$1);
7285
7303
  const [recordTimer, setRecordTimer] = useState(RECORD_SECONDS$1);
@@ -7330,20 +7348,20 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7330
7348
  // If we already notified for this recording, skip
7331
7349
  if (hasNotifiedRef.current)
7332
7350
  return;
7333
- if (videoBlob && audioBlob && onRecordingComplete) {
7351
+ if (videoBlob && audioBlob && onRecorded) {
7334
7352
  hasNotifiedRef.current = true; // prevent double-calls
7335
7353
  const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
7336
7354
  const audioFile = new File([audioBlob], 'face-audio.webm', { type: audioBlob.type });
7337
7355
  const phrase = numbersToPhrase(digits);
7338
7356
  try {
7339
- onRecordingComplete(videoFile, audioFile, phrase);
7357
+ onRecorded(videoFile, audioFile, phrase);
7340
7358
  }
7341
7359
  catch (err) {
7342
7360
  // swallow errors from consumer callback to avoid breaking SDK logic
7343
- console.error('onRecordingComplete callback threw:', err);
7361
+ console.error('onRecorded callback threw:', err);
7344
7362
  }
7345
7363
  }
7346
- }, [videoBlob, audioBlob, digits, onRecordingComplete]);
7364
+ }, [videoBlob, audioBlob, digits, onRecorded]);
7347
7365
  // Attach the video stream to the <video> element
7348
7366
  useEffect(() => {
7349
7367
  let isMounted = true;
@@ -7504,7 +7522,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7504
7522
  alignItems: 'center',
7505
7523
  justifyContent: 'center',
7506
7524
  width: rectWidth,
7507
- height: rectHeight + 120,
7525
+ height: rectHeight + 80,
7508
7526
  margin: '0 auto',
7509
7527
  ...style,
7510
7528
  };
@@ -7555,26 +7573,28 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7555
7573
  alignSelf: 'center',
7556
7574
  };
7557
7575
  const numberRow = {
7576
+ position: 'absolute',
7577
+ top: 10,
7578
+ left: 12,
7579
+ right: 12,
7558
7580
  display: 'flex',
7559
7581
  justifyContent: 'center',
7560
- gap: 4,
7561
- margin: '16px 0 24px 0',
7562
- width: '100%',
7563
- maxWidth: rectWidth - 40,
7582
+ gap: 5,
7583
+ zIndex: 10,
7564
7584
  };
7565
7585
  const numberBox = {
7566
7586
  minWidth: 24,
7567
7587
  minHeight: 32,
7568
- background: '#f5f5f5',
7569
- border: '2px solid #333',
7588
+ background: 'rgba(0, 0, 0, 0.6)',
7589
+ border: '1.5px solid rgba(255, 255, 255, 0.5)',
7570
7590
  borderRadius: 4,
7571
7591
  fontSize: 16,
7572
7592
  fontWeight: 600,
7573
- color: '#333',
7593
+ color: '#fff',
7574
7594
  display: 'flex',
7575
7595
  alignItems: 'center',
7576
7596
  justifyContent: 'center',
7577
- boxShadow: '0 1px 4px rgba(0,0,0,0.08)',
7597
+ backdropFilter: 'blur(4px)',
7578
7598
  transition: 'background 0.3s',
7579
7599
  flex: '1',
7580
7600
  maxWidth: '28px',
@@ -7694,7 +7714,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7694
7714
  background: 'rgba(0,0,0,0.4)',
7695
7715
  zIndex: 1,
7696
7716
  borderRadius: noShadow ? 0 : 8,
7697
- } }), jsxs("div", { className: "facerecorder-oval-area", style: ovalArea, children: [jsx("span", { className: "facerecorder-guidance-text", style: guidanceText, children: "Place your face in the oval" }), jsx("div", { className: "facerecorder-oval-dashed", style: ovalDashed })] }), state === 'countdown' && (jsx("div", { style: prepTimerStyle, children: prepTimer })), state === 'recording' && (jsx("div", { style: timerStyle, children: recordTimer })), (state === 'recording' || state === 'preparation') && (jsxs("div", { style: soundwaveStyle, children: [jsx("div", { style: { ...barBase, height: `${8 + micLevel * 30}px` } }), jsx("div", { style: { ...barBase, height: `${4 + micLevel * 40}px` } }), jsx("div", { style: { ...barBase, height: `${10 + micLevel * 20}px` } })] }))] }), jsx("div", { style: numberRow, children: (state === 'recording' ? digits : Array(DIGITS_NUMBER$1).fill('*')).map((num, i) => (jsx("div", { style: numberBox, children: num }, i))) }), state === 'preparation' && (jsx("button", { type: "button", style: actionButton, onClick: startRecording, children: "Start recording" })), state === 'recording' && (jsx("button", { type: "button", style: { ...actionButton, background: '#d32f2f' }, onClick: handleCancel, children: "Cancel" }))] })), state === 'processing' && (jsx(Fragment, { children: jsx("div", { className: "facerecorder-processing", style: preview, children: jsxs("div", { style: {
7717
+ } }), jsxs("div", { className: "facerecorder-oval-area", style: ovalArea, children: [jsx("span", { className: "facerecorder-guidance-text", style: guidanceText, children: "Place your face in the oval" }), jsx("div", { className: "facerecorder-oval-dashed", style: ovalDashed })] }), state === 'countdown' && (jsx("div", { style: prepTimerStyle, children: prepTimer })), state === 'recording' && (jsx("div", { style: timerStyle, children: recordTimer })), (state === 'recording' || state === 'preparation') && (jsxs("div", { style: soundwaveStyle, children: [jsx("div", { style: { ...barBase, height: `${8 + micLevel * 30}px` } }), jsx("div", { style: { ...barBase, height: `${4 + micLevel * 40}px` } }), jsx("div", { style: { ...barBase, height: `${10 + micLevel * 20}px` } })] })), jsx("div", { style: numberRow, children: (state === 'recording' ? digits : Array(DIGITS_NUMBER$1).fill('*')).map((num, i) => (jsx("div", { style: numberBox, children: num }, i))) })] }), state === 'preparation' && (jsx("button", { type: "button", style: actionButton, onClick: startRecording, children: "Start recording" })), state === 'recording' && (jsx("button", { type: "button", style: { ...actionButton, background: '#d32f2f' }, onClick: handleCancel, children: "Cancel" }))] })), state === 'processing' && (jsx(Fragment, { children: jsx("div", { className: "facerecorder-processing", style: preview, children: jsxs("div", { style: {
7698
7718
  display: 'flex',
7699
7719
  flexDirection: 'column',
7700
7720
  alignItems: 'center',
@@ -7810,7 +7830,7 @@ function generateRandomDigits(count) {
7810
7830
  }
7811
7831
  return digits.slice(0, count);
7812
7832
  }
7813
- const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, style, noShadow = false, }) => {
7833
+ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onConfirmRecording, onRecorded, className, style, noShadow = false, }) => {
7814
7834
  const [state, setState] = useState('preparation');
7815
7835
  const [prepTimer, setPrepTimer] = useState(PREP_SECONDS);
7816
7836
  const [recordTimer, setRecordTimer] = useState(RECORD_SECONDS);
@@ -7832,6 +7852,15 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7832
7852
  setAudioUrl(url);
7833
7853
  setState('result');
7834
7854
  setIsConfirming(true);
7855
+ if (onRecorded) {
7856
+ try {
7857
+ const file = new File([blob], 'voice-recording.webm', { type: blob.type });
7858
+ onRecorded(file, numbersToPhrase(digits));
7859
+ }
7860
+ catch (err) {
7861
+ console.error('onRecorded callback threw:', err);
7862
+ }
7863
+ }
7835
7864
  }
7836
7865
  else {
7837
7866
  const dummyBlob = new Blob(['dummy audio data'], { type: 'audio/webm' });
@@ -7922,7 +7951,9 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7922
7951
  const handleConfirm = () => {
7923
7952
  if (audioBlob) {
7924
7953
  const file = new File([audioBlob], 'voice-recording.webm', { type: audioBlob.type });
7925
- onCapture(file, numbersToPhrase(digits));
7954
+ // required callback in parent app
7955
+ onConfirmRecording(file, numbersToPhrase(digits));
7956
+ // Clean up and reset state
7926
7957
  if (audioUrl)
7927
7958
  URL.revokeObjectURL(audioUrl);
7928
7959
  setAudioUrl(null);
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var jsxRuntime=require('react/jsx-runtime'),React=require('react');const DocScan = ({ rectWidth = 640, rectHeight = 400, onCapture, className, style, noShadow = false, }) => {
1
+ 'use strict';var jsxRuntime=require('react/jsx-runtime'),React=require('react');const DocScan = ({ rectWidth = 640, rectHeight = 400, onConfirmCapture, onCapture, className, style, noShadow = false, }) => {
2
2
  const [isConfirming, setIsConfirming] = React.useState(false);
3
3
  const [capturedUrl, setCapturedUrl] = React.useState(null);
4
4
  const [capturedFile, setCapturedFile] = React.useState(null);
@@ -65,13 +65,21 @@
65
65
  setCapturedFile(file);
66
66
  setCapturedUrl(URL.createObjectURL(blob));
67
67
  setIsConfirming(true);
68
+ if (onCapture) {
69
+ try {
70
+ onCapture(file);
71
+ }
72
+ catch (err) {
73
+ console.error('onCapture callback threw:', err);
74
+ }
75
+ }
68
76
  }
69
77
  }, "image/jpeg", 0.98);
70
78
  }
71
79
  };
72
80
  const handleConfirm = () => {
73
81
  if (capturedFile) {
74
- onCapture(capturedFile);
82
+ onConfirmCapture(capturedFile);
75
83
  }
76
84
  };
77
85
  const handleDecline = () => {
@@ -176,6 +184,7 @@
176
184
  objectFit: 'cover',
177
185
  borderRadius: noShadow ? 0 : 8,
178
186
  zIndex: 0,
187
+ transform: 'scaleX(-1)'
179
188
  }, playsInline: true, muted: true, autoPlay: true }), jsxRuntime.jsx("div", { className: "docscan-dark-overlay", style: {
180
189
  position: 'absolute',
181
190
  top: 0,
@@ -186,7 +195,7 @@
186
195
  zIndex: 1,
187
196
  borderRadius: noShadow ? 0 : 8,
188
197
  } }), jsxRuntime.jsx("div", { className: "docscan-dashed-area", style: defaultDashedArea, children: jsxRuntime.jsx("span", { className: "docscan-guidance-text", style: defaultGuidanceText, children: "Place your document here" }) })] }), jsxRuntime.jsx("button", { type: "button", className: "docscan-capture-btn", style: defaultCaptureButton, onClick: handleCapture, children: "Capture" })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: "docscan-preview", style: defaultPreview, children: capturedUrl && (jsxRuntime.jsx("img", { src: capturedUrl, alt: "Captured document", className: "docscan-preview-img", style: { maxWidth: '100%', maxHeight: '100%', borderRadius: 8 } })) }), jsxRuntime.jsx("div", { className: "docscan-confirm-text", style: defaultConfirmText, children: "Do you want to use this photo?" }), jsxRuntime.jsxs("div", { className: "docscan-confirm-btns", style: { display: 'flex', justifyContent: 'center', gap: 32, marginTop: 16, width: '100%' }, children: [jsxRuntime.jsx("button", { type: "button", "aria-label": "Retake", className: "docscan-icon-btn", style: defaultIconButton, onClick: handleDecline, onMouseOver: e => (e.currentTarget.style.background = 'rgba(211,47,47,0.12)'), onMouseOut: e => (e.currentTarget.style.background = 'none'), children: jsxRuntime.jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("circle", { cx: "18", cy: "18", r: "18", fill: "#fff", fillOpacity: "0.15" }), jsxRuntime.jsx("path", { d: "M12 12L24 24", stroke: "#d32f2f", strokeWidth: "3", strokeLinecap: "round" }), jsxRuntime.jsx("path", { d: "M24 12L12 24", stroke: "#d32f2f", strokeWidth: "3", strokeLinecap: "round" })] }) }), jsxRuntime.jsx("button", { type: "button", "aria-label": "Confirm", className: "docscan-icon-btn", style: defaultIconButton, onClick: handleConfirm, onMouseOver: e => (e.currentTarget.style.background = 'rgba(56,142,60,0.12)'), onMouseOut: e => (e.currentTarget.style.background = 'none'), children: jsxRuntime.jsxs("svg", { width: "36", height: "36", viewBox: "0 0 36 36", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [jsxRuntime.jsx("circle", { cx: "18", cy: "18", r: "18", fill: "#fff", fillOpacity: "0.15" }), jsxRuntime.jsx("path", { d: "M10 19L16 25L26 13", stroke: "#388e3c", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round" })] }) })] })] })) }));
189
- };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onCapture, className, style, noShadow = false, }) => {
198
+ };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onConfirmCapture, onCapture, className, style, noShadow = false, }) => {
190
199
  const [isConfirming, setIsConfirming] = React.useState(false);
191
200
  const [capturedUrl, setCapturedUrl] = React.useState(null);
192
201
  const [capturedFile, setCapturedFile] = React.useState(null);
@@ -237,13 +246,21 @@
237
246
  setCapturedFile(file);
238
247
  setCapturedUrl(URL.createObjectURL(blob));
239
248
  setIsConfirming(true);
249
+ if (onCapture) {
250
+ try {
251
+ onCapture(file);
252
+ }
253
+ catch (err) {
254
+ console.error('onCapture callback threw:', err);
255
+ }
256
+ }
240
257
  }
241
258
  }, "image/jpeg", 0.98);
242
259
  }
243
260
  };
244
261
  const handleConfirm = () => {
245
262
  if (capturedFile) {
246
- onCapture(capturedFile);
263
+ onConfirmCapture(capturedFile);
247
264
  }
248
265
  };
249
266
  const handleDecline = () => {
@@ -325,8 +342,8 @@
325
342
  display: 'block',
326
343
  };
327
344
  const preview = {
328
- width: rectWidth - 25,
329
- height: rectHeight - 25,
345
+ width: '100%',
346
+ height: '100%',
330
347
  display: 'flex',
331
348
  alignItems: 'center',
332
349
  justifyContent: 'center',
@@ -357,6 +374,7 @@
357
374
  objectFit: 'cover',
358
375
  borderRadius: noShadow ? 0 : 8,
359
376
  zIndex: 0,
377
+ transform: 'scaleX(-1)'
360
378
  }, playsInline: true, muted: true, autoPlay: true }), jsxRuntime.jsx("div", { className: "facecapture-dark-overlay", style: {
361
379
  position: 'absolute',
362
380
  top: 0,
@@ -7279,7 +7297,7 @@ function generateRandomDigits$1(count) {
7279
7297
  }
7280
7298
  return digits.slice(0, count);
7281
7299
  }
7282
- const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, onRecordingComplete, className, style, noShadow = false, }) => {
7300
+ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, onRecorded, className, style, noShadow = false, }) => {
7283
7301
  const [state, setState] = React.useState('preparation');
7284
7302
  const [prepTimer, setPrepTimer] = React.useState(PREP_SECONDS$1);
7285
7303
  const [recordTimer, setRecordTimer] = React.useState(RECORD_SECONDS$1);
@@ -7330,20 +7348,20 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7330
7348
  // If we already notified for this recording, skip
7331
7349
  if (hasNotifiedRef.current)
7332
7350
  return;
7333
- if (videoBlob && audioBlob && onRecordingComplete) {
7351
+ if (videoBlob && audioBlob && onRecorded) {
7334
7352
  hasNotifiedRef.current = true; // prevent double-calls
7335
7353
  const videoFile = new File([videoBlob], 'face-video.webm', { type: videoBlob.type });
7336
7354
  const audioFile = new File([audioBlob], 'face-audio.webm', { type: audioBlob.type });
7337
7355
  const phrase = numbersToPhrase(digits);
7338
7356
  try {
7339
- onRecordingComplete(videoFile, audioFile, phrase);
7357
+ onRecorded(videoFile, audioFile, phrase);
7340
7358
  }
7341
7359
  catch (err) {
7342
7360
  // swallow errors from consumer callback to avoid breaking SDK logic
7343
- console.error('onRecordingComplete callback threw:', err);
7361
+ console.error('onRecorded callback threw:', err);
7344
7362
  }
7345
7363
  }
7346
- }, [videoBlob, audioBlob, digits, onRecordingComplete]);
7364
+ }, [videoBlob, audioBlob, digits, onRecorded]);
7347
7365
  // Attach the video stream to the <video> element
7348
7366
  React.useEffect(() => {
7349
7367
  let isMounted = true;
@@ -7504,7 +7522,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7504
7522
  alignItems: 'center',
7505
7523
  justifyContent: 'center',
7506
7524
  width: rectWidth,
7507
- height: rectHeight + 120,
7525
+ height: rectHeight + 80,
7508
7526
  margin: '0 auto',
7509
7527
  ...style,
7510
7528
  };
@@ -7555,26 +7573,28 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7555
7573
  alignSelf: 'center',
7556
7574
  };
7557
7575
  const numberRow = {
7576
+ position: 'absolute',
7577
+ top: 10,
7578
+ left: 12,
7579
+ right: 12,
7558
7580
  display: 'flex',
7559
7581
  justifyContent: 'center',
7560
- gap: 4,
7561
- margin: '16px 0 24px 0',
7562
- width: '100%',
7563
- maxWidth: rectWidth - 40,
7582
+ gap: 5,
7583
+ zIndex: 10,
7564
7584
  };
7565
7585
  const numberBox = {
7566
7586
  minWidth: 24,
7567
7587
  minHeight: 32,
7568
- background: '#f5f5f5',
7569
- border: '2px solid #333',
7588
+ background: 'rgba(0, 0, 0, 0.6)',
7589
+ border: '1.5px solid rgba(255, 255, 255, 0.5)',
7570
7590
  borderRadius: 4,
7571
7591
  fontSize: 16,
7572
7592
  fontWeight: 600,
7573
- color: '#333',
7593
+ color: '#fff',
7574
7594
  display: 'flex',
7575
7595
  alignItems: 'center',
7576
7596
  justifyContent: 'center',
7577
- boxShadow: '0 1px 4px rgba(0,0,0,0.08)',
7597
+ backdropFilter: 'blur(4px)',
7578
7598
  transition: 'background 0.3s',
7579
7599
  flex: '1',
7580
7600
  maxWidth: '28px',
@@ -7694,7 +7714,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onConfirmRecording, o
7694
7714
  background: 'rgba(0,0,0,0.4)',
7695
7715
  zIndex: 1,
7696
7716
  borderRadius: noShadow ? 0 : 8,
7697
- } }), jsxRuntime.jsxs("div", { className: "facerecorder-oval-area", style: ovalArea, children: [jsxRuntime.jsx("span", { className: "facerecorder-guidance-text", style: guidanceText, children: "Place your face in the oval" }), jsxRuntime.jsx("div", { className: "facerecorder-oval-dashed", style: ovalDashed })] }), state === 'countdown' && (jsxRuntime.jsx("div", { style: prepTimerStyle, children: prepTimer })), state === 'recording' && (jsxRuntime.jsx("div", { style: timerStyle, children: recordTimer })), (state === 'recording' || state === 'preparation') && (jsxRuntime.jsxs("div", { style: soundwaveStyle, children: [jsxRuntime.jsx("div", { style: { ...barBase, height: `${8 + micLevel * 30}px` } }), jsxRuntime.jsx("div", { style: { ...barBase, height: `${4 + micLevel * 40}px` } }), jsxRuntime.jsx("div", { style: { ...barBase, height: `${10 + micLevel * 20}px` } })] }))] }), jsxRuntime.jsx("div", { style: numberRow, children: (state === 'recording' ? digits : Array(DIGITS_NUMBER$1).fill('*')).map((num, i) => (jsxRuntime.jsx("div", { style: numberBox, children: num }, i))) }), state === 'preparation' && (jsxRuntime.jsx("button", { type: "button", style: actionButton, onClick: startRecording, children: "Start recording" })), state === 'recording' && (jsxRuntime.jsx("button", { type: "button", style: { ...actionButton, background: '#d32f2f' }, onClick: handleCancel, children: "Cancel" }))] })), state === 'processing' && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { className: "facerecorder-processing", style: preview, children: jsxRuntime.jsxs("div", { style: {
7717
+ } }), jsxRuntime.jsxs("div", { className: "facerecorder-oval-area", style: ovalArea, children: [jsxRuntime.jsx("span", { className: "facerecorder-guidance-text", style: guidanceText, children: "Place your face in the oval" }), jsxRuntime.jsx("div", { className: "facerecorder-oval-dashed", style: ovalDashed })] }), state === 'countdown' && (jsxRuntime.jsx("div", { style: prepTimerStyle, children: prepTimer })), state === 'recording' && (jsxRuntime.jsx("div", { style: timerStyle, children: recordTimer })), (state === 'recording' || state === 'preparation') && (jsxRuntime.jsxs("div", { style: soundwaveStyle, children: [jsxRuntime.jsx("div", { style: { ...barBase, height: `${8 + micLevel * 30}px` } }), jsxRuntime.jsx("div", { style: { ...barBase, height: `${4 + micLevel * 40}px` } }), jsxRuntime.jsx("div", { style: { ...barBase, height: `${10 + micLevel * 20}px` } })] })), jsxRuntime.jsx("div", { style: numberRow, children: (state === 'recording' ? digits : Array(DIGITS_NUMBER$1).fill('*')).map((num, i) => (jsxRuntime.jsx("div", { style: numberBox, children: num }, i))) })] }), state === 'preparation' && (jsxRuntime.jsx("button", { type: "button", style: actionButton, onClick: startRecording, children: "Start recording" })), state === 'recording' && (jsxRuntime.jsx("button", { type: "button", style: { ...actionButton, background: '#d32f2f' }, onClick: handleCancel, children: "Cancel" }))] })), state === 'processing' && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx("div", { className: "facerecorder-processing", style: preview, children: jsxRuntime.jsxs("div", { style: {
7698
7718
  display: 'flex',
7699
7719
  flexDirection: 'column',
7700
7720
  alignItems: 'center',
@@ -7810,7 +7830,7 @@ function generateRandomDigits(count) {
7810
7830
  }
7811
7831
  return digits.slice(0, count);
7812
7832
  }
7813
- const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, style, noShadow = false, }) => {
7833
+ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onConfirmRecording, onRecorded, className, style, noShadow = false, }) => {
7814
7834
  const [state, setState] = React.useState('preparation');
7815
7835
  const [prepTimer, setPrepTimer] = React.useState(PREP_SECONDS);
7816
7836
  const [recordTimer, setRecordTimer] = React.useState(RECORD_SECONDS);
@@ -7832,6 +7852,15 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7832
7852
  setAudioUrl(url);
7833
7853
  setState('result');
7834
7854
  setIsConfirming(true);
7855
+ if (onRecorded) {
7856
+ try {
7857
+ const file = new File([blob], 'voice-recording.webm', { type: blob.type });
7858
+ onRecorded(file, numbersToPhrase(digits));
7859
+ }
7860
+ catch (err) {
7861
+ console.error('onRecorded callback threw:', err);
7862
+ }
7863
+ }
7835
7864
  }
7836
7865
  else {
7837
7866
  const dummyBlob = new Blob(['dummy audio data'], { type: 'audio/webm' });
@@ -7922,7 +7951,9 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7922
7951
  const handleConfirm = () => {
7923
7952
  if (audioBlob) {
7924
7953
  const file = new File([audioBlob], 'voice-recording.webm', { type: audioBlob.type });
7925
- onCapture(file, numbersToPhrase(digits));
7954
+ // required callback in parent app
7955
+ onConfirmRecording(file, numbersToPhrase(digits));
7956
+ // Clean up and reset state
7926
7957
  if (audioUrl)
7927
7958
  URL.revokeObjectURL(audioUrl);
7928
7959
  setAudioUrl(null);
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "biometry-react-components",
3
- "version": "1.2.17",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
- "description": "React UI component library for capturing high-quality biometric data (voice, face, documents, video) to facilitate integration with Biometry services",
5
+ "description": "React UI component library for capturing high-quality biometric data (voice, face, documents, video) to facilitate integration with 'Biometry' services",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.esm.js",
8
8
  "types": "dist/index.d.ts",