biometry-react-components 1.3.4 → 1.3.5

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,18 +1,55 @@
1
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
+ var _a;
2
3
  const [isConfirming, setIsConfirming] = useState(false);
3
4
  const [capturedUrl, setCapturedUrl] = useState(null);
4
5
  const [capturedFile, setCapturedFile] = useState(null);
5
6
  const videoRef = useRef(null);
6
7
  const streamRef = useRef(null);
8
+ const [devices, setDevices] = useState([]);
9
+ const [selectedDeviceId, setSelectedDeviceId] = useState(null);
10
+ const [isFrontCamera, setIsFrontCamera] = useState(false);
11
+ const [capabilities, setCapabilities] = useState({});
12
+ const [torchOn, setTorchOn] = useState(false);
7
13
  const QUALITY_MULTIPLIER = 3;
8
14
  // Crop area (dashed area) as percentages
9
15
  const cropTop = 0.075, cropLeft = 0.075, cropWidth = 0.85, cropHeight = 0.85;
16
+ const getDevices = async () => {
17
+ try {
18
+ const all = await navigator.mediaDevices.enumerateDevices();
19
+ return all.filter((d) => d.kind === "videoinput");
20
+ }
21
+ catch (_a) {
22
+ return [];
23
+ }
24
+ };
25
+ useEffect(() => {
26
+ const handleDeviceChange = async () => {
27
+ const vids = await getDevices();
28
+ setDevices(vids);
29
+ if (selectedDeviceId && !vids.find((d) => d.deviceId === selectedDeviceId)) {
30
+ // Active device disconnected, clear it to fallback to default
31
+ setSelectedDeviceId(null);
32
+ }
33
+ };
34
+ navigator.mediaDevices.addEventListener("devicechange", handleDeviceChange);
35
+ return () => navigator.mediaDevices.removeEventListener("devicechange", handleDeviceChange);
36
+ }, [selectedDeviceId]);
10
37
  useEffect(() => {
11
38
  let isMounted = true;
12
39
  if (!isConfirming) {
13
40
  (async () => {
14
41
  try {
15
- const stream = await navigator.mediaDevices.getUserMedia({ video: { width: rectWidth, height: rectHeight } });
42
+ const videoConstraints = {
43
+ width: rectWidth,
44
+ height: rectHeight,
45
+ };
46
+ if (selectedDeviceId) {
47
+ videoConstraints.deviceId = { exact: selectedDeviceId };
48
+ }
49
+ else {
50
+ videoConstraints.facingMode = "environment";
51
+ }
52
+ const stream = await navigator.mediaDevices.getUserMedia({ video: videoConstraints });
16
53
  if (!isMounted) {
17
54
  stream.getTracks().forEach((track) => track.stop());
18
55
  return;
@@ -25,6 +62,40 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
25
62
  };
26
63
  }
27
64
  streamRef.current = stream;
65
+ const track = stream.getVideoTracks()[0];
66
+ if (track) {
67
+ if (track.getCapabilities) {
68
+ setCapabilities(track.getCapabilities());
69
+ }
70
+ const settings = track.getSettings();
71
+ let isFront = false;
72
+ if (settings.facingMode) {
73
+ isFront = settings.facingMode === "user";
74
+ }
75
+ else {
76
+ const allVids = await getDevices();
77
+ const currDev = allVids.find(d => d.deviceId === settings.deviceId);
78
+ if (currDev)
79
+ isFront = currDev.label.toLowerCase().includes("front");
80
+ }
81
+ if (isMounted)
82
+ setIsFrontCamera(isFront);
83
+ if (!selectedDeviceId) {
84
+ const currentId = track.getSettings().deviceId;
85
+ if (currentId && isMounted)
86
+ setSelectedDeviceId(currentId);
87
+ }
88
+ track.onended = async () => {
89
+ if (!isMounted)
90
+ return;
91
+ const vids = await getDevices();
92
+ setDevices(vids);
93
+ setSelectedDeviceId(null);
94
+ };
95
+ }
96
+ const vids = await getDevices();
97
+ if (isMounted)
98
+ setDevices(vids);
28
99
  }
29
100
  catch (err) {
30
101
  console.error(err);
@@ -38,7 +109,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
38
109
  streamRef.current = null;
39
110
  }
40
111
  };
41
- }, [isConfirming, rectWidth, rectHeight]);
112
+ }, [isConfirming, rectWidth, rectHeight, selectedDeviceId]);
42
113
  const handleCapture = () => {
43
114
  const video = videoRef.current;
44
115
  if (!video)
@@ -53,19 +124,16 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
53
124
  const targetAspect = rectWidth / rectHeight;
54
125
  let sx = 0, sy = 0, sw = video.videoWidth, sh = video.videoHeight;
55
126
  if (videoAspect > targetAspect) {
56
- // Video is wider than target: crop sides
57
127
  sw = video.videoHeight * targetAspect;
58
128
  sx = (video.videoWidth - sw) / 2;
59
129
  }
60
130
  else {
61
- // Video is taller than target: crop top/bottom
62
131
  sh = video.videoWidth / targetAspect;
63
132
  sy = (video.videoHeight - sh) / 2;
64
133
  }
65
134
  ctx.drawImage(video, sx, sy, sw, sh, 0, 0, canvas.width, canvas.height);
66
135
  canvas.toBlob((blob) => {
67
136
  if (blob) {
68
- // Stop the stream immediately — don't wait for useEffect cleanup
69
137
  if (streamRef.current) {
70
138
  streamRef.current.getTracks().forEach((track) => track.stop());
71
139
  streamRef.current = null;
@@ -79,7 +147,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
79
147
  onCapture(file);
80
148
  }
81
149
  catch (err) {
82
- console.error('onCapture callback threw:', err);
150
+ console.error(err);
83
151
  }
84
152
  }
85
153
  }
@@ -99,6 +167,53 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
99
167
  setCapturedFile(null);
100
168
  setIsConfirming(false);
101
169
  };
170
+ const cycleCamera = (e) => {
171
+ e.stopPropagation();
172
+ if (devices.length <= 1)
173
+ return;
174
+ const currentIndex = devices.findIndex((d) => d.deviceId === selectedDeviceId);
175
+ const nextIndex = (currentIndex + 1) % devices.length;
176
+ setSelectedDeviceId(devices[nextIndex].deviceId);
177
+ setTorchOn(false);
178
+ };
179
+ const toggleTorch = async (e) => {
180
+ e.stopPropagation();
181
+ if (!streamRef.current)
182
+ return;
183
+ const track = streamRef.current.getVideoTracks()[0];
184
+ if (track && capabilities.torch) {
185
+ try {
186
+ const nextTorch = !torchOn;
187
+ await track.applyConstraints({ advanced: [{ torch: nextTorch }] });
188
+ setTorchOn(nextTorch);
189
+ }
190
+ catch (err) {
191
+ console.error("Torch toggle failed:", err);
192
+ }
193
+ }
194
+ };
195
+ const handleCameraAreaClick = async (e) => {
196
+ if (!streamRef.current)
197
+ return;
198
+ const track = streamRef.current.getVideoTracks()[0];
199
+ if (track && capabilities.focusMode) {
200
+ const focusType = capabilities.focusMode.includes("single-shot") ? "single-shot" : capabilities.focusMode.includes("manual") ? "manual" : null;
201
+ if (!focusType)
202
+ return;
203
+ const rect = e.currentTarget.getBoundingClientRect();
204
+ let x = (e.clientX - rect.left) / rect.width;
205
+ const y = (e.clientY - rect.top) / rect.height;
206
+ if (isFrontCamera) {
207
+ x = 1 - x;
208
+ }
209
+ try {
210
+ await track.applyConstraints({ advanced: [{ focusMode: focusType, pointsOfInterest: [{ x, y }] }] });
211
+ }
212
+ catch (err) {
213
+ console.error("Focus failed:", err);
214
+ }
215
+ }
216
+ };
102
217
  const wrapperStyle = {
103
218
  background: '#fff',
104
219
  borderRadius: noShadow ? 0 : 10,
@@ -121,6 +236,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
121
236
  display: 'flex',
122
237
  alignItems: 'center',
123
238
  justifyContent: 'center',
239
+ cursor: ((_a = capabilities.focusMode) === null || _a === void 0 ? void 0 : _a.includes("manual")) ? "crosshair" : "default"
124
240
  };
125
241
  const defaultDashedArea = {
126
242
  position: 'absolute',
@@ -136,6 +252,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
136
252
  display: 'flex',
137
253
  flexDirection: 'column',
138
254
  alignItems: 'center',
255
+ pointerEvents: 'none'
139
256
  };
140
257
  const defaultGuidanceText = {
141
258
  color: '#fff',
@@ -187,13 +304,34 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
187
304
  transition: 'background 0.2s',
188
305
  margin: '0 8px',
189
306
  };
190
- return (jsx("div", { className: className, style: wrapperStyle, children: !isConfirming ? (jsxs(Fragment, { children: [jsxs("div", { className: "docscan-camera-area", style: defaultCameraArea, children: [jsx("video", { ref: videoRef, width: rectWidth - 40, height: rectHeight - 40, className: "docscan-video", style: {
307
+ const controlsOverlayStyle = {
308
+ position: 'absolute',
309
+ top: 8,
310
+ right: 8,
311
+ zIndex: 3,
312
+ display: 'flex',
313
+ flexDirection: 'column',
314
+ gap: 12,
315
+ };
316
+ const overlayBtnStyle = {
317
+ background: 'rgba(0,0,0,0.5)',
318
+ border: 'none',
319
+ borderRadius: '50%',
320
+ width: 36,
321
+ height: 36,
322
+ display: 'flex',
323
+ alignItems: 'center',
324
+ justifyContent: 'center',
325
+ cursor: 'pointer',
326
+ color: '#fff',
327
+ };
328
+ return (jsx("div", { className: className, style: wrapperStyle, children: !isConfirming ? (jsxs(Fragment, { children: [jsxs("div", { className: "docscan-camera-area", style: defaultCameraArea, onClick: handleCameraAreaClick, children: [jsxs("div", { style: controlsOverlayStyle, children: [devices.length > 1 && (jsx("button", { type: "button", onClick: cycleCamera, style: overlayBtnStyle, title: "Switch Camera", children: jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsx("path", { d: "M21 12A9 9 0 0 0 6 5.3L3 8" }), jsx("path", { d: "M21 3v5h-5" }), jsx("path", { d: "M3 12a9 9 0 0 0 15 6.7l3-2.7" }), jsx("path", { d: "M3 21v-5h5" })] }) })), capabilities.torch && (jsx("button", { type: "button", onClick: toggleTorch, style: { ...overlayBtnStyle, color: torchOn ? '#ffd700' : '#fff' }, title: "Toggle Flash", children: jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: jsx("polygon", { points: "13 2 3 14 12 14 11 22 21 10 12 10 13 2" }) }) }))] }), jsx("video", { ref: videoRef, width: rectWidth - 40, height: rectHeight - 40, className: "docscan-video", style: {
191
329
  width: rectWidth - 40,
192
330
  height: rectHeight - 40,
193
331
  objectFit: 'cover',
194
332
  borderRadius: noShadow ? 0 : 8,
195
333
  zIndex: 0,
196
- transform: 'scaleX(-1)'
334
+ transform: isFrontCamera ? 'scaleX(-1)' : 'none'
197
335
  }, playsInline: true, muted: true, autoPlay: true }), jsx("div", { className: "docscan-dark-overlay", style: {
198
336
  position: 'absolute',
199
337
  top: 0,
@@ -203,6 +341,7 @@ import {jsx,jsxs,Fragment}from'react/jsx-runtime';import React,{useState,useRef,
203
341
  background: 'rgba(0,0,0,0.4)',
204
342
  zIndex: 1,
205
343
  borderRadius: noShadow ? 0 : 8,
344
+ pointerEvents: 'none'
206
345
  } }), 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" })] }) })] })] })) }));
207
346
  };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onConfirmCapture, onCapture, className, style, noShadow = false, }) => {
208
347
  const [isConfirming, setIsConfirming] = useState(false);
package/dist/index.js CHANGED
@@ -1,18 +1,55 @@
1
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
+ var _a;
2
3
  const [isConfirming, setIsConfirming] = React.useState(false);
3
4
  const [capturedUrl, setCapturedUrl] = React.useState(null);
4
5
  const [capturedFile, setCapturedFile] = React.useState(null);
5
6
  const videoRef = React.useRef(null);
6
7
  const streamRef = React.useRef(null);
8
+ const [devices, setDevices] = React.useState([]);
9
+ const [selectedDeviceId, setSelectedDeviceId] = React.useState(null);
10
+ const [isFrontCamera, setIsFrontCamera] = React.useState(false);
11
+ const [capabilities, setCapabilities] = React.useState({});
12
+ const [torchOn, setTorchOn] = React.useState(false);
7
13
  const QUALITY_MULTIPLIER = 3;
8
14
  // Crop area (dashed area) as percentages
9
15
  const cropTop = 0.075, cropLeft = 0.075, cropWidth = 0.85, cropHeight = 0.85;
16
+ const getDevices = async () => {
17
+ try {
18
+ const all = await navigator.mediaDevices.enumerateDevices();
19
+ return all.filter((d) => d.kind === "videoinput");
20
+ }
21
+ catch (_a) {
22
+ return [];
23
+ }
24
+ };
25
+ React.useEffect(() => {
26
+ const handleDeviceChange = async () => {
27
+ const vids = await getDevices();
28
+ setDevices(vids);
29
+ if (selectedDeviceId && !vids.find((d) => d.deviceId === selectedDeviceId)) {
30
+ // Active device disconnected, clear it to fallback to default
31
+ setSelectedDeviceId(null);
32
+ }
33
+ };
34
+ navigator.mediaDevices.addEventListener("devicechange", handleDeviceChange);
35
+ return () => navigator.mediaDevices.removeEventListener("devicechange", handleDeviceChange);
36
+ }, [selectedDeviceId]);
10
37
  React.useEffect(() => {
11
38
  let isMounted = true;
12
39
  if (!isConfirming) {
13
40
  (async () => {
14
41
  try {
15
- const stream = await navigator.mediaDevices.getUserMedia({ video: { width: rectWidth, height: rectHeight } });
42
+ const videoConstraints = {
43
+ width: rectWidth,
44
+ height: rectHeight,
45
+ };
46
+ if (selectedDeviceId) {
47
+ videoConstraints.deviceId = { exact: selectedDeviceId };
48
+ }
49
+ else {
50
+ videoConstraints.facingMode = "environment";
51
+ }
52
+ const stream = await navigator.mediaDevices.getUserMedia({ video: videoConstraints });
16
53
  if (!isMounted) {
17
54
  stream.getTracks().forEach((track) => track.stop());
18
55
  return;
@@ -25,6 +62,40 @@
25
62
  };
26
63
  }
27
64
  streamRef.current = stream;
65
+ const track = stream.getVideoTracks()[0];
66
+ if (track) {
67
+ if (track.getCapabilities) {
68
+ setCapabilities(track.getCapabilities());
69
+ }
70
+ const settings = track.getSettings();
71
+ let isFront = false;
72
+ if (settings.facingMode) {
73
+ isFront = settings.facingMode === "user";
74
+ }
75
+ else {
76
+ const allVids = await getDevices();
77
+ const currDev = allVids.find(d => d.deviceId === settings.deviceId);
78
+ if (currDev)
79
+ isFront = currDev.label.toLowerCase().includes("front");
80
+ }
81
+ if (isMounted)
82
+ setIsFrontCamera(isFront);
83
+ if (!selectedDeviceId) {
84
+ const currentId = track.getSettings().deviceId;
85
+ if (currentId && isMounted)
86
+ setSelectedDeviceId(currentId);
87
+ }
88
+ track.onended = async () => {
89
+ if (!isMounted)
90
+ return;
91
+ const vids = await getDevices();
92
+ setDevices(vids);
93
+ setSelectedDeviceId(null);
94
+ };
95
+ }
96
+ const vids = await getDevices();
97
+ if (isMounted)
98
+ setDevices(vids);
28
99
  }
29
100
  catch (err) {
30
101
  console.error(err);
@@ -38,7 +109,7 @@
38
109
  streamRef.current = null;
39
110
  }
40
111
  };
41
- }, [isConfirming, rectWidth, rectHeight]);
112
+ }, [isConfirming, rectWidth, rectHeight, selectedDeviceId]);
42
113
  const handleCapture = () => {
43
114
  const video = videoRef.current;
44
115
  if (!video)
@@ -53,19 +124,16 @@
53
124
  const targetAspect = rectWidth / rectHeight;
54
125
  let sx = 0, sy = 0, sw = video.videoWidth, sh = video.videoHeight;
55
126
  if (videoAspect > targetAspect) {
56
- // Video is wider than target: crop sides
57
127
  sw = video.videoHeight * targetAspect;
58
128
  sx = (video.videoWidth - sw) / 2;
59
129
  }
60
130
  else {
61
- // Video is taller than target: crop top/bottom
62
131
  sh = video.videoWidth / targetAspect;
63
132
  sy = (video.videoHeight - sh) / 2;
64
133
  }
65
134
  ctx.drawImage(video, sx, sy, sw, sh, 0, 0, canvas.width, canvas.height);
66
135
  canvas.toBlob((blob) => {
67
136
  if (blob) {
68
- // Stop the stream immediately — don't wait for useEffect cleanup
69
137
  if (streamRef.current) {
70
138
  streamRef.current.getTracks().forEach((track) => track.stop());
71
139
  streamRef.current = null;
@@ -79,7 +147,7 @@
79
147
  onCapture(file);
80
148
  }
81
149
  catch (err) {
82
- console.error('onCapture callback threw:', err);
150
+ console.error(err);
83
151
  }
84
152
  }
85
153
  }
@@ -99,6 +167,53 @@
99
167
  setCapturedFile(null);
100
168
  setIsConfirming(false);
101
169
  };
170
+ const cycleCamera = (e) => {
171
+ e.stopPropagation();
172
+ if (devices.length <= 1)
173
+ return;
174
+ const currentIndex = devices.findIndex((d) => d.deviceId === selectedDeviceId);
175
+ const nextIndex = (currentIndex + 1) % devices.length;
176
+ setSelectedDeviceId(devices[nextIndex].deviceId);
177
+ setTorchOn(false);
178
+ };
179
+ const toggleTorch = async (e) => {
180
+ e.stopPropagation();
181
+ if (!streamRef.current)
182
+ return;
183
+ const track = streamRef.current.getVideoTracks()[0];
184
+ if (track && capabilities.torch) {
185
+ try {
186
+ const nextTorch = !torchOn;
187
+ await track.applyConstraints({ advanced: [{ torch: nextTorch }] });
188
+ setTorchOn(nextTorch);
189
+ }
190
+ catch (err) {
191
+ console.error("Torch toggle failed:", err);
192
+ }
193
+ }
194
+ };
195
+ const handleCameraAreaClick = async (e) => {
196
+ if (!streamRef.current)
197
+ return;
198
+ const track = streamRef.current.getVideoTracks()[0];
199
+ if (track && capabilities.focusMode) {
200
+ const focusType = capabilities.focusMode.includes("single-shot") ? "single-shot" : capabilities.focusMode.includes("manual") ? "manual" : null;
201
+ if (!focusType)
202
+ return;
203
+ const rect = e.currentTarget.getBoundingClientRect();
204
+ let x = (e.clientX - rect.left) / rect.width;
205
+ const y = (e.clientY - rect.top) / rect.height;
206
+ if (isFrontCamera) {
207
+ x = 1 - x;
208
+ }
209
+ try {
210
+ await track.applyConstraints({ advanced: [{ focusMode: focusType, pointsOfInterest: [{ x, y }] }] });
211
+ }
212
+ catch (err) {
213
+ console.error("Focus failed:", err);
214
+ }
215
+ }
216
+ };
102
217
  const wrapperStyle = {
103
218
  background: '#fff',
104
219
  borderRadius: noShadow ? 0 : 10,
@@ -121,6 +236,7 @@
121
236
  display: 'flex',
122
237
  alignItems: 'center',
123
238
  justifyContent: 'center',
239
+ cursor: ((_a = capabilities.focusMode) === null || _a === void 0 ? void 0 : _a.includes("manual")) ? "crosshair" : "default"
124
240
  };
125
241
  const defaultDashedArea = {
126
242
  position: 'absolute',
@@ -136,6 +252,7 @@
136
252
  display: 'flex',
137
253
  flexDirection: 'column',
138
254
  alignItems: 'center',
255
+ pointerEvents: 'none'
139
256
  };
140
257
  const defaultGuidanceText = {
141
258
  color: '#fff',
@@ -187,13 +304,34 @@
187
304
  transition: 'background 0.2s',
188
305
  margin: '0 8px',
189
306
  };
190
- return (jsxRuntime.jsx("div", { className: className, style: wrapperStyle, children: !isConfirming ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "docscan-camera-area", style: defaultCameraArea, children: [jsxRuntime.jsx("video", { ref: videoRef, width: rectWidth - 40, height: rectHeight - 40, className: "docscan-video", style: {
307
+ const controlsOverlayStyle = {
308
+ position: 'absolute',
309
+ top: 8,
310
+ right: 8,
311
+ zIndex: 3,
312
+ display: 'flex',
313
+ flexDirection: 'column',
314
+ gap: 12,
315
+ };
316
+ const overlayBtnStyle = {
317
+ background: 'rgba(0,0,0,0.5)',
318
+ border: 'none',
319
+ borderRadius: '50%',
320
+ width: 36,
321
+ height: 36,
322
+ display: 'flex',
323
+ alignItems: 'center',
324
+ justifyContent: 'center',
325
+ cursor: 'pointer',
326
+ color: '#fff',
327
+ };
328
+ return (jsxRuntime.jsx("div", { className: className, style: wrapperStyle, children: !isConfirming ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: "docscan-camera-area", style: defaultCameraArea, onClick: handleCameraAreaClick, children: [jsxRuntime.jsxs("div", { style: controlsOverlayStyle, children: [devices.length > 1 && (jsxRuntime.jsx("button", { type: "button", onClick: cycleCamera, style: overlayBtnStyle, title: "Switch Camera", children: jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntime.jsx("path", { d: "M21 12A9 9 0 0 0 6 5.3L3 8" }), jsxRuntime.jsx("path", { d: "M21 3v5h-5" }), jsxRuntime.jsx("path", { d: "M3 12a9 9 0 0 0 15 6.7l3-2.7" }), jsxRuntime.jsx("path", { d: "M3 21v-5h5" })] }) })), capabilities.torch && (jsxRuntime.jsx("button", { type: "button", onClick: toggleTorch, style: { ...overlayBtnStyle, color: torchOn ? '#ffd700' : '#fff' }, title: "Toggle Flash", children: jsxRuntime.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: jsxRuntime.jsx("polygon", { points: "13 2 3 14 12 14 11 22 21 10 12 10 13 2" }) }) }))] }), jsxRuntime.jsx("video", { ref: videoRef, width: rectWidth - 40, height: rectHeight - 40, className: "docscan-video", style: {
191
329
  width: rectWidth - 40,
192
330
  height: rectHeight - 40,
193
331
  objectFit: 'cover',
194
332
  borderRadius: noShadow ? 0 : 8,
195
333
  zIndex: 0,
196
- transform: 'scaleX(-1)'
334
+ transform: isFrontCamera ? 'scaleX(-1)' : 'none'
197
335
  }, playsInline: true, muted: true, autoPlay: true }), jsxRuntime.jsx("div", { className: "docscan-dark-overlay", style: {
198
336
  position: 'absolute',
199
337
  top: 0,
@@ -203,6 +341,7 @@
203
341
  background: 'rgba(0,0,0,0.4)',
204
342
  zIndex: 1,
205
343
  borderRadius: noShadow ? 0 : 8,
344
+ pointerEvents: 'none'
206
345
  } }), 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" })] }) })] })] })) }));
207
346
  };const FaceCapture = ({ rectWidth = 360, rectHeight = 576, onConfirmCapture, onCapture, className, style, noShadow = false, }) => {
208
347
  const [isConfirming, setIsConfirming] = React.useState(false);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "biometry-react-components",
3
- "version": "1.3.4",
3
+ "version": "1.3.5",
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",