@uziee/document-scanner 1.1.6 → 1.1.8

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
@@ -20,7 +20,16 @@ npm install @uziee/document-scanner
20
20
 
21
21
  ## 📖 Usage
22
22
 
23
- Import the `DocumentScanner` component into your React application and provide an `onCapture` callback to handle the scanned images.
23
+ Import the `DocumentScanner` component into your React application and provide the callback props to handle scanning events.
24
+
25
+ ### Props
26
+
27
+ | Prop | Type | Required | Description |
28
+ |------|------|----------|-------------|
29
+ | `onCapture` | `(images: string[]) => void` | Yes | Callback fired when user finishes scanning. Receives an array of base64 image data URLs. |
30
+ | `onClose` | `() => void` | No | Callback fired when user taps the close button (X) to exit the scanner without capturing. |
31
+
32
+ ### Example
24
33
 
25
34
  ```jsx
26
35
  import React, { useState } from 'react';
@@ -28,18 +37,33 @@ import DocumentScanner from '@uziee/document-scanner';
28
37
 
29
38
  function App() {
30
39
  const [showScanner, setShowScanner] = useState(false);
40
+ const [scannedImages, setScannedImages] = useState([]);
31
41
 
32
42
  const handleCapture = (images) => {
33
- images.forEach((image, index) => {
34
- console.log(`Captured image ${index + 1}:`, image);
35
- });
43
+ console.log(`Captured ${images.length} document(s)`);
44
+ setScannedImages(images);
45
+ setShowScanner(false);
46
+ };
47
+
48
+ const handleClose = () => {
49
+ // User closed the scanner without capturing
36
50
  setShowScanner(false);
37
51
  };
38
52
 
39
53
  return (
40
54
  <div>
41
55
  <button onClick={() => setShowScanner(true)}>Scan Document</button>
42
- {showScanner && <DocumentScanner onCapture={handleCapture} />}
56
+
57
+ {showScanner && (
58
+ <DocumentScanner
59
+ onCapture={handleCapture}
60
+ onClose={handleClose}
61
+ />
62
+ )}
63
+
64
+ {scannedImages.map((img, i) => (
65
+ <img key={i} src={img} alt={`Scanned ${i + 1}`} />
66
+ ))}
43
67
  </div>
44
68
  );
45
69
  }
@@ -47,4 +71,13 @@ function App() {
47
71
  export default App;
48
72
  ```
49
73
 
50
- The component renders a full-screen camera interface for document scanning. It detects documents in real-time, applies stability filtering, and captures high-resolution images with perspective correction. Ensure your application has camera permissions enabled for the component to function properly.
74
+ The component renders a full-screen camera interface for document scanning. It detects documents in real-time, applies stability filtering, and captures high-resolution images with perspective correction.
75
+
76
+ ### UI Controls
77
+
78
+ - **Close Button (X)**: Located in the top-right corner. Calls `onClose` to exit without capturing.
79
+ - **Status Indicator**: Shows "POSITION DOCUMENT" or "READY TO SCAN" based on detection state.
80
+ - **Shutter Button**: Captures the current document when detection is stable.
81
+ - **Thumbnail/Done**: Shows captured images count; tap to finish and return all images via `onCapture`.
82
+
83
+ Ensure your application has camera permissions enabled for the component to function properly.