@visns-studio/visns-components 5.14.0 → 5.14.2

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
@@ -2312,6 +2312,247 @@ The QrCode component fetches QR code data from the specified URL and displays it
2312
2312
  }
2313
2313
  ```
2314
2314
 
2315
+ ### Enhanced OCR Template Component
2316
+
2317
+ #### OcrTemplateEnhanced (v5.14.0+)
2318
+
2319
+ The Enhanced OCR Template component provides a modern, guided journey experience for creating OCR document processing templates. This component transforms the basic OCR template functionality into a comprehensive 5-step workflow for automated document processing.
2320
+
2321
+ ```jsx
2322
+ import { OcrTemplateEnhanced } from '@visns-studio/visns-components';
2323
+
2324
+ <OcrTemplateEnhanced
2325
+ id="customer_job_template"
2326
+ data={formData}
2327
+ setData={setFormData}
2328
+ routeParams={routeParams}
2329
+ urlParam="id"
2330
+ onSave={handleOcrTemplateSave}
2331
+ />
2332
+ ```
2333
+
2334
+ **Key Features:**
2335
+
2336
+ 1. **Guided Journey UX**: 5-step workflow with visual progress tracking
2337
+ 2. **Smart Data Categorization**: Automatic classification of extracted data
2338
+ 3. **Template Matching**: Create unique document signatures for automated detection
2339
+ 4. **Intelligent Filename Generation**: Dynamic filename templates with empty variable handling
2340
+ 5. **Automated Processing Setup**: Configure watch and destination folders
2341
+ 6. **Auto-Resume**: Automatically jumps to latest completed step for existing templates
2342
+
2343
+ #### Workflow Overview
2344
+
2345
+ The Enhanced OCR Template follows a structured 5-step journey:
2346
+
2347
+ **Step 1: Upload Document**
2348
+ - Compact drag-and-drop interface for PDF, JPG, PNG files (up to 10MB)
2349
+ - Real-time processing feedback with progress indicators
2350
+ - File preview with metadata display
2351
+
2352
+ **Step 2: Select Data for Template**
2353
+ - Intelligent data categorization into 5 groups:
2354
+ - 📞 Contact Information (email, phone, names, addresses)
2355
+ - 💰 Financial Data (amounts, prices, costs, currency symbols)
2356
+ - 📅 Dates & Times (dates, timestamps, various formats)
2357
+ - 🔢 Identifiers (IDs, invoice numbers, references, codes)
2358
+ - 📄 Other Data (miscellaneous key-value pairs)
2359
+ - Empty categories automatically hidden
2360
+ - Card-based selection with confidence scoring
2361
+
2362
+ **Step 3: Define Template Signature**
2363
+ - Select text patterns that uniquely identify the document type
2364
+ - Used by OCR system to automatically match documents to templates
2365
+ - Guidance for creating effective document fingerprints
2366
+
2367
+ **Step 4: Craft Filename Template**
2368
+ - Design filename patterns using selected variables
2369
+ - Smart variable handling: empty variables automatically removed
2370
+ - Real-time preview of generated filenames
2371
+ - Template validation and suggestions
2372
+
2373
+ **Step 5: Setup Automation Folders**
2374
+ - Configure watch folder for continuous monitoring
2375
+ - Set destination folder for processed files
2376
+ - Visual workflow preview showing the automation pipeline
2377
+
2378
+ #### Integration in GenericDetail
2379
+
2380
+ The Enhanced OCR Template automatically replaces the original when using `type: 'ocrTemplate'`:
2381
+
2382
+ ```javascript
2383
+ {
2384
+ id: 'document_processor',
2385
+ type: 'ocrTemplate',
2386
+ label: 'Document OCR Processing' // Label automatically hidden
2387
+ }
2388
+ ```
2389
+
2390
+ #### Smart Data Categorization
2391
+
2392
+ The component uses enhanced pattern recognition for intelligent data classification:
2393
+
2394
+ ```javascript
2395
+ // Enhanced categorization patterns
2396
+ const categories = {
2397
+ contact: {
2398
+ patterns: [
2399
+ /email|e-mail|mail/i,
2400
+ /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/,
2401
+ /phone|tel|mobile|cell|fax/i,
2402
+ /^[\+]?[\d\s\-\(\)]{7,15}$/,
2403
+ /name|client|customer|company|organisation/i,
2404
+ /address|street|city|state|country|zip/i
2405
+ ],
2406
+ confidence: 0.8-0.95
2407
+ },
2408
+ financial: {
2409
+ patterns: [
2410
+ /amount|price|cost|total|sum|value|fee|charge/i,
2411
+ /[$€£¥₹]/,
2412
+ /^\d+[.,]\d{2}$/,
2413
+ /^\d+\.?\d*$/
2414
+ ],
2415
+ confidence: 0.85
2416
+ },
2417
+ // ... other categories
2418
+ };
2419
+ ```
2420
+
2421
+ #### Filename Template Logic
2422
+
2423
+ The filename generation intelligently handles empty variables:
2424
+
2425
+ ```javascript
2426
+ // Template examples with smart variable handling
2427
+ template: "{{invoice_number}}_{{date}}_{{amount}}"
2428
+
2429
+ // With all values: "INV001_2025-01-15_1500.00"
2430
+ // Missing amount: "INV001_2025-01-15" (amount automatically removed)
2431
+ // Missing date: "INV001_1500.00" (date automatically removed)
2432
+
2433
+ // Smart cleanup
2434
+ // Multiple separators: "Company__Invoice" → "Company_Invoice"
2435
+ // Leading/trailing: "_Invoice_" → "Invoice"
2436
+ // Adjacent empty variables: "{{a}}_{{empty}}_{{c}}" → "value_a_value_c"
2437
+ ```
2438
+
2439
+ #### Automated Processing Workflow
2440
+
2441
+ Once configured, the system provides fully automated document processing:
2442
+
2443
+ ```
2444
+ 1. New documents → Watch Folder
2445
+ 2. System detects & processes using template signature
2446
+ 3. OCR extracts data using selected variables
2447
+ 4. Generate filename using template pattern
2448
+ 5. Move processed files → Destination Folder
2449
+ ```
2450
+
2451
+ #### API Integration
2452
+
2453
+ The component integrates with backend OCR processing:
2454
+
2455
+ ```javascript
2456
+ // OCR Analysis Endpoint
2457
+ POST /ajax/ocr/analyzeFile
2458
+ Content-Type: multipart/form-data
2459
+
2460
+ {
2461
+ file: [uploaded document],
2462
+ template_id: [template identifier]
2463
+ }
2464
+
2465
+ // Response
2466
+ {
2467
+ keyValuePairs: {
2468
+ "invoice_number": "INV-001",
2469
+ "amount": "1500.00",
2470
+ "date": "2025-01-15",
2471
+ "client_name": "ACME Corp"
2472
+ },
2473
+ allText: [
2474
+ "INVOICE INV-001",
2475
+ "Date: 2025-01-15",
2476
+ "Amount: $1,500.00",
2477
+ "Client: ACME Corp"
2478
+ ]
2479
+ }
2480
+ ```
2481
+
2482
+ #### Auto-Resume Functionality
2483
+
2484
+ The component automatically detects existing template progress and jumps to the appropriate step:
2485
+
2486
+ - **Fully completed template**: Jump to Step 5 (Setup Automation Folders)
2487
+ - **Partially completed**: Jump to next incomplete step
2488
+ - **New template**: Start at Step 1 (Upload Document)
2489
+
2490
+ Shows "↻ Resumed" badge when auto-jumping occurs.
2491
+
2492
+ #### Navigation Features
2493
+
2494
+ - **Smart Step Access**: Users can navigate to any completed step
2495
+ - **Visual Progress**: Clear indication of completed vs pending steps
2496
+ - **Manual Override**: Auto-jump only occurs once, then full manual control
2497
+ - **Breadcrumb Navigation**: Previous/Next buttons with logical flow control
2498
+
2499
+ #### Advanced Features
2500
+
2501
+ **Template Suggestions**: Automatically generated based on detected document patterns
2502
+ ```javascript
2503
+ // Auto-detected patterns
2504
+ {
2505
+ name: "Invoice Template",
2506
+ filename: "INV_{{invoice_number}}_{{date}}",
2507
+ description: "Standard invoice naming convention"
2508
+ }
2509
+ ```
2510
+
2511
+ **Confidence Scoring**: Each extracted data field includes accuracy assessment
2512
+ - **High (80%+)**: Green badge, reliable data
2513
+ - **Medium (60-79%)**: Yellow badge, moderate confidence
2514
+ - **Low (<60%)**: Red badge, requires verification
2515
+
2516
+ **Responsive Design**: Optimized for desktop and mobile with adaptive layouts
2517
+
2518
+ #### Styling Customization
2519
+
2520
+ The component uses CSS modules with customizable variables:
2521
+
2522
+ ```scss
2523
+ .ocrTemplateContainer {
2524
+ --primary-color: #007bff;
2525
+ --success-color: #28a745;
2526
+ --warning-color: #ffc107;
2527
+ min-height: 500px; // Compact design
2528
+ }
2529
+ ```
2530
+
2531
+ #### Migration from Original OCR Template
2532
+
2533
+ The Enhanced OCR Template is a drop-in replacement requiring no configuration changes:
2534
+
2535
+ ```javascript
2536
+ // Before (original)
2537
+ case 'ocrTemplate':
2538
+ return renderOcrTemplate(id);
2539
+
2540
+ // After (enhanced) - automatic replacement
2541
+ case 'ocrTemplate':
2542
+ return (
2543
+ <OcrTemplateEnhanced
2544
+ id={id}
2545
+ data={data}
2546
+ setData={setData}
2547
+ routeParams={routeParams}
2548
+ urlParam={urlParam}
2549
+ onSave={handleOcrTemplateSave}
2550
+ />
2551
+ );
2552
+ ```
2553
+
2554
+ All existing data structures and API endpoints remain compatible.
2555
+
2315
2556
  #### AuditLogs and AuditLog
2316
2557
 
2317
2558
  The AuditLogs component displays a table of system activity logs, showing who made changes, what was changed, and when the changes occurred.
package/package.json CHANGED
@@ -24,13 +24,13 @@
24
24
  "dayjs": "^1.11.13",
25
25
  "fabric": "^6.7.0",
26
26
  "file-saver": "^2.0.5",
27
- "framer-motion": "^12.23.5",
27
+ "framer-motion": "^12.23.6",
28
28
  "html-react-parser": "^5.2.5",
29
29
  "lodash": "^4.17.21",
30
30
  "lodash.debounce": "^4.0.8",
31
31
  "lucide-react": "^0.525.0",
32
32
  "moment": "^2.30.1",
33
- "motion": "^12.23.5",
33
+ "motion": "^12.23.6",
34
34
  "numeral": "^2.0.6",
35
35
  "pluralize": "^8.0.0",
36
36
  "qrcode.react": "^4.2.0",
@@ -88,7 +88,7 @@
88
88
  "react-dom": "^17.0.0 || ^18.0.0"
89
89
  },
90
90
  "name": "@visns-studio/visns-components",
91
- "version": "5.14.0",
91
+ "version": "5.14.2",
92
92
  "description": "Various packages to assist in the development of our Custom Applications.",
93
93
  "main": "src/index.js",
94
94
  "files": [