biometry-react-components 1.2.8 → 1.2.10

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/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {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, 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);
@@ -279,11 +279,11 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {useState,useRef,useEff
279
279
  };
280
280
  const ovalArea = {
281
281
  position: 'absolute',
282
- top: '18%',
282
+ top: '15%',
283
283
  left: '50%',
284
284
  transform: 'translateX(-50%)',
285
- width: '72%',
286
- height: '68%',
285
+ width: '75%',
286
+ height: '70%',
287
287
  zIndex: 2,
288
288
  display: 'flex',
289
289
  flexDirection: 'column',
@@ -7290,6 +7290,10 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7290
7290
  const [isConfirming, setIsConfirming] = useState(false);
7291
7291
  const videoRef = useRef(null);
7292
7292
  const previewRef = useRef(null);
7293
+ const [micLevel, setMicLevel] = React.useState(0);
7294
+ const analyserRef = React.useRef(null);
7295
+ const audioCtxRef = React.useRef(null);
7296
+ const rafRef = React.useRef(null);
7293
7297
  // Video recorder
7294
7298
  const { startRecording: startVideoRecording, cancelRecording: cancelVideoRecording } = useRecorder(stream, "video", (blob) => {
7295
7299
  if (blob && blob.size > 0) {
@@ -7318,7 +7322,9 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7318
7322
  stopStreamTracks();
7319
7323
  setState('result');
7320
7324
  setIsConfirming(true);
7325
+ stopAudioVisualization();
7321
7326
  });
7327
+ // Attach the video stream to the <video> element
7322
7328
  useEffect(() => {
7323
7329
  let isMounted = true;
7324
7330
  console.log('Camera setup useEffect - state:', state, 'isConfirming:', isConfirming);
@@ -7351,7 +7357,20 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7351
7357
  startAudioRecording();
7352
7358
  }
7353
7359
  }
7354
- }, [state, prepTimer, startVideoRecording, startAudioRecording]);
7360
+ }, [state, prepTimer]);
7361
+ useEffect(() => {
7362
+ if (!stream)
7363
+ return;
7364
+ if (state === 'preparation' || state === 'recording') {
7365
+ startAudioVisualization(stream);
7366
+ }
7367
+ else {
7368
+ stopAudioVisualization();
7369
+ }
7370
+ return () => {
7371
+ stopAudioVisualization();
7372
+ };
7373
+ }, [stream, state]);
7355
7374
  // Recording timer
7356
7375
  useEffect(() => {
7357
7376
  if (state === 'recording') {
@@ -7419,6 +7438,36 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7419
7438
  // Restart the stream for retake
7420
7439
  requestPermissions();
7421
7440
  };
7441
+ function startAudioVisualization(stream) {
7442
+ // Create audio context + analyser
7443
+ audioCtxRef.current = new AudioContext();
7444
+ const source = audioCtxRef.current.createMediaStreamSource(stream);
7445
+ const analyser = audioCtxRef.current.createAnalyser();
7446
+ analyser.fftSize = 256;
7447
+ source.connect(analyser);
7448
+ analyserRef.current = analyser;
7449
+ const bufferLength = analyser.frequencyBinCount;
7450
+ const dataArray = new Uint8Array(bufferLength);
7451
+ function update() {
7452
+ analyser.getByteFrequencyData(dataArray);
7453
+ // Calculate average volume (0–1)
7454
+ const avg = dataArray.reduce((a, b) => a + b, 0) / bufferLength / 255;
7455
+ setMicLevel(avg);
7456
+ rafRef.current = requestAnimationFrame(update);
7457
+ }
7458
+ update();
7459
+ }
7460
+ function stopAudioVisualization() {
7461
+ var _a, _b;
7462
+ if (rafRef.current)
7463
+ cancelAnimationFrame(rafRef.current);
7464
+ rafRef.current = null;
7465
+ (_a = analyserRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
7466
+ (_b = audioCtxRef.current) === null || _b === void 0 ? void 0 : _b.close();
7467
+ audioCtxRef.current = null;
7468
+ analyserRef.current = null;
7469
+ setMicLevel(0);
7470
+ }
7422
7471
  const wrapperStyle = {
7423
7472
  background: '#fff',
7424
7473
  borderRadius: noShadow ? 0 : 10,
@@ -7447,11 +7496,11 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7447
7496
  };
7448
7497
  const ovalArea = {
7449
7498
  position: 'absolute',
7450
- top: '18%',
7499
+ top: '15%',
7451
7500
  left: '50%',
7452
7501
  transform: 'translateX(-50%)',
7453
- width: '80%',
7454
- height: '74%',
7502
+ width: '75%',
7503
+ height: '70%',
7455
7504
  zIndex: 2,
7456
7505
  display: 'flex',
7457
7506
  flexDirection: 'column',
@@ -7504,6 +7553,22 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7504
7553
  flex: '1',
7505
7554
  maxWidth: '28px',
7506
7555
  };
7556
+ const soundwaveStyle = {
7557
+ position: 'absolute',
7558
+ bottom: 12,
7559
+ left: 18,
7560
+ display: 'flex',
7561
+ alignItems: 'flex-end',
7562
+ gap: 3,
7563
+ height: 24,
7564
+ zIndex: 10,
7565
+ };
7566
+ const barBase = {
7567
+ width: 4,
7568
+ background: '#4caf50',
7569
+ borderRadius: 2,
7570
+ transition: 'height 0.1s',
7571
+ };
7507
7572
  const timerStyle = {
7508
7573
  position: 'absolute',
7509
7574
  top: 12,
@@ -7603,7 +7668,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7603
7668
  background: 'rgba(0,0,0,0.4)',
7604
7669
  zIndex: 1,
7605
7670
  borderRadius: noShadow ? 0 : 8,
7606
- } }), 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 }))] }), 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: {
7671
+ } }), 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: {
7607
7672
  display: 'flex',
7608
7673
  flexDirection: 'column',
7609
7674
  alignItems: 'center',
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
- 'use strict';var jsxRuntime=require('react/jsx-runtime'),react=require('react');const DocScan = ({ rectWidth = 640, rectHeight = 400, onCapture, className, style, noShadow = false, }) => {
2
- const [isConfirming, setIsConfirming] = react.useState(false);
3
- const [capturedUrl, setCapturedUrl] = react.useState(null);
4
- const [capturedFile, setCapturedFile] = react.useState(null);
5
- const videoRef = react.useRef(null);
6
- const streamRef = react.useRef(null);
1
+ 'use strict';var jsxRuntime=require('react/jsx-runtime'),React=require('react');const DocScan = ({ rectWidth = 640, rectHeight = 400, onCapture, className, style, noShadow = false, }) => {
2
+ const [isConfirming, setIsConfirming] = React.useState(false);
3
+ const [capturedUrl, setCapturedUrl] = React.useState(null);
4
+ const [capturedFile, setCapturedFile] = React.useState(null);
5
+ const videoRef = React.useRef(null);
6
+ const streamRef = React.useRef(null);
7
7
  const QUALITY_MULTIPLIER = 3;
8
8
  // Crop area (dashed area) as percentages
9
9
  const cropTop = 0.075, cropLeft = 0.075, cropWidth = 0.85, cropHeight = 0.85;
10
- react.useEffect(() => {
10
+ React.useEffect(() => {
11
11
  let isMounted = true;
12
12
  if (!isConfirming) {
13
13
  (async () => {
@@ -187,13 +187,13 @@
187
187
  borderRadius: noShadow ? 0 : 8,
188
188
  } }), 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
189
  };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onCapture, className, style, noShadow = false, }) => {
190
- const [isConfirming, setIsConfirming] = react.useState(false);
191
- const [capturedUrl, setCapturedUrl] = react.useState(null);
192
- const [capturedFile, setCapturedFile] = react.useState(null);
193
- const videoRef = react.useRef(null);
194
- const streamRef = react.useRef(null);
190
+ const [isConfirming, setIsConfirming] = React.useState(false);
191
+ const [capturedUrl, setCapturedUrl] = React.useState(null);
192
+ const [capturedFile, setCapturedFile] = React.useState(null);
193
+ const videoRef = React.useRef(null);
194
+ const streamRef = React.useRef(null);
195
195
  const QUALITY_MULTIPLIER = 3;
196
- react.useEffect(() => {
196
+ React.useEffect(() => {
197
197
  let isMounted = true;
198
198
  if (!isConfirming) {
199
199
  (async () => {
@@ -279,11 +279,11 @@
279
279
  };
280
280
  const ovalArea = {
281
281
  position: 'absolute',
282
- top: '18%',
282
+ top: '15%',
283
283
  left: '50%',
284
284
  transform: 'translateX(-50%)',
285
- width: '72%',
286
- height: '68%',
285
+ width: '75%',
286
+ height: '70%',
287
287
  zIndex: 2,
288
288
  display: 'flex',
289
289
  flexDirection: 'column',
@@ -7061,9 +7061,9 @@ function numberToWord(num) {
7061
7061
  function numbersToPhrase(numbers) {
7062
7062
  return numbers.map(numberToWord).join(' ');
7063
7063
  }const useRecorder = (stream, type, onStopRecording) => {
7064
- const [isRecording, setIsRecording] = react.useState(false);
7065
- const recorderRef = react.useRef(null);
7066
- const timeoutRef = react.useRef(null);
7064
+ const [isRecording, setIsRecording] = React.useState(false);
7065
+ const recorderRef = React.useRef(null);
7066
+ const timeoutRef = React.useRef(null);
7067
7067
  const getAdaptiveRecordingSettings = () => {
7068
7068
  // Detect device capabilities
7069
7069
  const isMobile = /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
@@ -7157,9 +7157,9 @@ function numbersToPhrase(numbers) {
7157
7157
  };
7158
7158
  return { isRecording, startRecording, stopRecording, cancelRecording };
7159
7159
  };const usePermissions = ({ rectWidth = 1920, rectHeight = 1080 } = {}) => {
7160
- const [permission, setPermission] = react.useState(false);
7161
- const [stream, setStream] = react.useState(null);
7162
- const [isLoading, setIsLoading] = react.useState(true);
7160
+ const [permission, setPermission] = React.useState(false);
7161
+ const [stream, setStream] = React.useState(null);
7162
+ const [isLoading, setIsLoading] = React.useState(true);
7163
7163
  const stopStreamTracks = () => {
7164
7164
  if (stream) {
7165
7165
  stream.getTracks().forEach(track => {
@@ -7245,7 +7245,7 @@ function numbersToPhrase(numbers) {
7245
7245
  setIsLoading(false);
7246
7246
  }
7247
7247
  };
7248
- react.useEffect(() => {
7248
+ React.useEffect(() => {
7249
7249
  void requestPermissions();
7250
7250
  }, [rectWidth, rectHeight]);
7251
7251
  return { permission, stream, stopStreamTracks, requestPermissions, isLoading };
@@ -7279,17 +7279,21 @@ function generateRandomDigits$1(count) {
7279
7279
  return digits.slice(0, count);
7280
7280
  }
7281
7281
  const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className, style, noShadow = false, }) => {
7282
- const [state, setState] = react.useState('preparation');
7283
- const [prepTimer, setPrepTimer] = react.useState(PREP_SECONDS$1);
7284
- const [recordTimer, setRecordTimer] = react.useState(RECORD_SECONDS$1);
7285
- const [digits, setDigits] = react.useState(generateRandomDigits$1(DIGITS_NUMBER$1));
7282
+ const [state, setState] = React.useState('preparation');
7283
+ const [prepTimer, setPrepTimer] = React.useState(PREP_SECONDS$1);
7284
+ const [recordTimer, setRecordTimer] = React.useState(RECORD_SECONDS$1);
7285
+ const [digits, setDigits] = React.useState(generateRandomDigits$1(DIGITS_NUMBER$1));
7286
7286
  const { permission, stream, stopStreamTracks, requestPermissions, isLoading } = usePermissions({ rectWidth, rectHeight });
7287
- const [videoBlob, setVideoBlob] = react.useState(null);
7288
- const [audioBlob, setAudioBlob] = react.useState(null);
7289
- const [videoUrl, setVideoUrl] = react.useState(null);
7290
- const [isConfirming, setIsConfirming] = react.useState(false);
7291
- const videoRef = react.useRef(null);
7292
- const previewRef = react.useRef(null);
7287
+ const [videoBlob, setVideoBlob] = React.useState(null);
7288
+ const [audioBlob, setAudioBlob] = React.useState(null);
7289
+ const [videoUrl, setVideoUrl] = React.useState(null);
7290
+ const [isConfirming, setIsConfirming] = React.useState(false);
7291
+ const videoRef = React.useRef(null);
7292
+ const previewRef = React.useRef(null);
7293
+ const [micLevel, setMicLevel] = React.useState(0);
7294
+ const analyserRef = React.useRef(null);
7295
+ const audioCtxRef = React.useRef(null);
7296
+ const rafRef = React.useRef(null);
7293
7297
  // Video recorder
7294
7298
  const { startRecording: startVideoRecording, cancelRecording: cancelVideoRecording } = useRecorder(stream, "video", (blob) => {
7295
7299
  if (blob && blob.size > 0) {
@@ -7318,8 +7322,10 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7318
7322
  stopStreamTracks();
7319
7323
  setState('result');
7320
7324
  setIsConfirming(true);
7325
+ stopAudioVisualization();
7321
7326
  });
7322
- react.useEffect(() => {
7327
+ // Attach the video stream to the <video> element
7328
+ React.useEffect(() => {
7323
7329
  let isMounted = true;
7324
7330
  console.log('Camera setup useEffect - state:', state, 'isConfirming:', isConfirming);
7325
7331
  if (!isConfirming && state !== 'result' && stream) {
@@ -7336,7 +7342,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7336
7342
  }
7337
7343
  }, [isConfirming, state, stream]);
7338
7344
  // Preparation countdown
7339
- react.useEffect(() => {
7345
+ React.useEffect(() => {
7340
7346
  console.log('Countdown useEffect - state:', state, 'prepTimer:', prepTimer);
7341
7347
  if (state === 'countdown') {
7342
7348
  if (prepTimer > 0) {
@@ -7351,9 +7357,22 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7351
7357
  startAudioRecording();
7352
7358
  }
7353
7359
  }
7354
- }, [state, prepTimer, startVideoRecording, startAudioRecording]);
7360
+ }, [state, prepTimer]);
7361
+ React.useEffect(() => {
7362
+ if (!stream)
7363
+ return;
7364
+ if (state === 'preparation' || state === 'recording') {
7365
+ startAudioVisualization(stream);
7366
+ }
7367
+ else {
7368
+ stopAudioVisualization();
7369
+ }
7370
+ return () => {
7371
+ stopAudioVisualization();
7372
+ };
7373
+ }, [stream, state]);
7355
7374
  // Recording timer
7356
- react.useEffect(() => {
7375
+ React.useEffect(() => {
7357
7376
  if (state === 'recording') {
7358
7377
  if (recordTimer > 0) {
7359
7378
  const t = setTimeout(() => setRecordTimer(recordTimer - 1), 1000);
@@ -7419,6 +7438,36 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7419
7438
  // Restart the stream for retake
7420
7439
  requestPermissions();
7421
7440
  };
7441
+ function startAudioVisualization(stream) {
7442
+ // Create audio context + analyser
7443
+ audioCtxRef.current = new AudioContext();
7444
+ const source = audioCtxRef.current.createMediaStreamSource(stream);
7445
+ const analyser = audioCtxRef.current.createAnalyser();
7446
+ analyser.fftSize = 256;
7447
+ source.connect(analyser);
7448
+ analyserRef.current = analyser;
7449
+ const bufferLength = analyser.frequencyBinCount;
7450
+ const dataArray = new Uint8Array(bufferLength);
7451
+ function update() {
7452
+ analyser.getByteFrequencyData(dataArray);
7453
+ // Calculate average volume (0–1)
7454
+ const avg = dataArray.reduce((a, b) => a + b, 0) / bufferLength / 255;
7455
+ setMicLevel(avg);
7456
+ rafRef.current = requestAnimationFrame(update);
7457
+ }
7458
+ update();
7459
+ }
7460
+ function stopAudioVisualization() {
7461
+ var _a, _b;
7462
+ if (rafRef.current)
7463
+ cancelAnimationFrame(rafRef.current);
7464
+ rafRef.current = null;
7465
+ (_a = analyserRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
7466
+ (_b = audioCtxRef.current) === null || _b === void 0 ? void 0 : _b.close();
7467
+ audioCtxRef.current = null;
7468
+ analyserRef.current = null;
7469
+ setMicLevel(0);
7470
+ }
7422
7471
  const wrapperStyle = {
7423
7472
  background: '#fff',
7424
7473
  borderRadius: noShadow ? 0 : 10,
@@ -7447,11 +7496,11 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7447
7496
  };
7448
7497
  const ovalArea = {
7449
7498
  position: 'absolute',
7450
- top: '18%',
7499
+ top: '15%',
7451
7500
  left: '50%',
7452
7501
  transform: 'translateX(-50%)',
7453
- width: '80%',
7454
- height: '74%',
7502
+ width: '75%',
7503
+ height: '70%',
7455
7504
  zIndex: 2,
7456
7505
  display: 'flex',
7457
7506
  flexDirection: 'column',
@@ -7504,6 +7553,22 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7504
7553
  flex: '1',
7505
7554
  maxWidth: '28px',
7506
7555
  };
7556
+ const soundwaveStyle = {
7557
+ position: 'absolute',
7558
+ bottom: 12,
7559
+ left: 18,
7560
+ display: 'flex',
7561
+ alignItems: 'flex-end',
7562
+ gap: 3,
7563
+ height: 24,
7564
+ zIndex: 10,
7565
+ };
7566
+ const barBase = {
7567
+ width: 4,
7568
+ background: '#4caf50',
7569
+ borderRadius: 2,
7570
+ transition: 'height 0.1s',
7571
+ };
7507
7572
  const timerStyle = {
7508
7573
  position: 'absolute',
7509
7574
  top: 12,
@@ -7603,7 +7668,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7603
7668
  background: 'rgba(0,0,0,0.4)',
7604
7669
  zIndex: 1,
7605
7670
  borderRadius: noShadow ? 0 : 8,
7606
- } }), 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 }))] }), 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: {
7671
+ } }), 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: {
7607
7672
  display: 'flex',
7608
7673
  flexDirection: 'column',
7609
7674
  alignItems: 'center',
@@ -7625,9 +7690,9 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7625
7690
  objectFit: 'cover'
7626
7691
  }, onLoadedData: () => console.log('Video loaded successfully'), onError: (e) => console.error('Video error:', e), onLoadStart: () => console.log('Video load started'), onCanPlay: () => console.log('Video can play') })) }), jsxRuntime.jsx("div", { className: "facerecorder-confirm-text", style: confirmText, children: "Do you want to use this video?" }), jsxRuntime.jsxs("div", { className: "facerecorder-confirm-btns", style: { display: 'flex', justifyContent: 'center', gap: 32, marginTop: 16, width: '100%' }, children: [jsxRuntime.jsx("button", { type: "button", "aria-label": "Retake", className: "facerecorder-icon-btn", style: iconButton, 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: "facerecorder-icon-btn", style: iconButton, 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" })] }) })] })] }))] }));
7627
7692
  };const useAudioPermissions = () => {
7628
- const [permission, setPermission] = react.useState(false);
7629
- const [stream, setStream] = react.useState(null);
7630
- const [isLoading, setIsLoading] = react.useState(true);
7693
+ const [permission, setPermission] = React.useState(false);
7694
+ const [stream, setStream] = React.useState(null);
7695
+ const [isLoading, setIsLoading] = React.useState(true);
7631
7696
  const stopStreamTracks = () => {
7632
7697
  if (stream) {
7633
7698
  stream.getTracks().forEach(track => {
@@ -7691,7 +7756,7 @@ const FaceRecorder = ({ rectWidth = 360, rectHeight = 576, onCapture, className,
7691
7756
  setIsLoading(false);
7692
7757
  }
7693
7758
  };
7694
- react.useEffect(() => {
7759
+ React.useEffect(() => {
7695
7760
  void requestPermissions();
7696
7761
  }, []);
7697
7762
  return { permission, stream, stopStreamTracks, requestPermissions, isLoading };
@@ -7720,19 +7785,19 @@ function generateRandomDigits(count) {
7720
7785
  return digits.slice(0, count);
7721
7786
  }
7722
7787
  const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, style, noShadow = false, }) => {
7723
- const [state, setState] = react.useState('preparation');
7724
- const [prepTimer, setPrepTimer] = react.useState(PREP_SECONDS);
7725
- const [recordTimer, setRecordTimer] = react.useState(RECORD_SECONDS);
7726
- const [digits, setDigits] = react.useState(generateRandomDigits(DIGITS_NUMBER));
7727
- const [audioLevel, setAudioLevel] = react.useState(0);
7728
- const [waveformData, setWaveformData] = react.useState([]);
7788
+ const [state, setState] = React.useState('preparation');
7789
+ const [prepTimer, setPrepTimer] = React.useState(PREP_SECONDS);
7790
+ const [recordTimer, setRecordTimer] = React.useState(RECORD_SECONDS);
7791
+ const [digits, setDigits] = React.useState(generateRandomDigits(DIGITS_NUMBER));
7792
+ const [audioLevel, setAudioLevel] = React.useState(0);
7793
+ const [waveformData, setWaveformData] = React.useState([]);
7729
7794
  const { permission, stream, stopStreamTracks, requestPermissions, isLoading } = useAudioPermissions();
7730
- const [audioBlob, setAudioBlob] = react.useState(null);
7731
- const [audioUrl, setAudioUrl] = react.useState(null);
7732
- const [isConfirming, setIsConfirming] = react.useState(false);
7733
- const audioRef = react.useRef(null);
7734
- const analyserRef = react.useRef(null);
7735
- const animationFrameRef = react.useRef(null);
7795
+ const [audioBlob, setAudioBlob] = React.useState(null);
7796
+ const [audioUrl, setAudioUrl] = React.useState(null);
7797
+ const [isConfirming, setIsConfirming] = React.useState(false);
7798
+ const audioRef = React.useRef(null);
7799
+ const analyserRef = React.useRef(null);
7800
+ const animationFrameRef = React.useRef(null);
7736
7801
  const { startRecording: startHookRecording, cancelRecording } = useRecorder(stream, "audio", (blob) => {
7737
7802
  stopStreamTracks();
7738
7803
  if (blob && blob.size > 0) {
@@ -7752,7 +7817,7 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7752
7817
  }
7753
7818
  });
7754
7819
  // Audio visualization setup
7755
- react.useEffect(() => {
7820
+ React.useEffect(() => {
7756
7821
  if (stream && state === 'recording') {
7757
7822
  const audioContext = new (window.AudioContext || window.webkitAudioContext)();
7758
7823
  const analyser = audioContext.createAnalyser();
@@ -7784,7 +7849,7 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7784
7849
  }
7785
7850
  }, [stream, state]);
7786
7851
  // Preparation countdown
7787
- react.useEffect(() => {
7852
+ React.useEffect(() => {
7788
7853
  if (state === 'countdown') {
7789
7854
  if (prepTimer > 0) {
7790
7855
  const t = setTimeout(() => setPrepTimer(prepTimer - 1), 1000);
@@ -7798,7 +7863,7 @@ const VoiceRecorder = ({ rectWidth = 360, rectHeight, onCapture, className, styl
7798
7863
  }
7799
7864
  }, [state, prepTimer, startHookRecording]);
7800
7865
  // Recording timer
7801
- react.useEffect(() => {
7866
+ React.useEffect(() => {
7802
7867
  if (state === 'recording') {
7803
7868
  if (recordTimer > 0) {
7804
7869
  const t = setTimeout(() => setRecordTimer(recordTimer - 1), 1000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biometry-react-components",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
4
4
  "type": "module",
5
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",