1.0.13 • Published 9 months ago

@browser.style/barcode-scanner v1.0.13

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

BarcodeScanner

A web component that works with most barcode scanners, supporting both automatic and manual barcode entry.

Installation

npm install @browser.style/barcode-scanner

Basic Usage

import '@browser.style/barcode-scanner';
<barcode-scanner></barcode-scanner>

Click the icon to start scanning, or add the auto attribute to start automatically.

Attributes

  • auto: Start scanning immediately when page loads
  • clear: Display duration in ms (default: 2000)
  • debug: Show scan history in console
  • input: Show input field for manual entry
  • maxlength: Max digits in barcode (default: 14, min: 8)
  • minlength: Min digits in barcode (default: 8)
  • terminate-char: Scanner termination char (default: '\n')
  • styles: Use default component styles

Events

The component emits two events:

  • bs:entry: Triggered on successful scan
scanner.addEventListener('bs:entry', event => {
  console.log('Barcode:', event.detail.value);
});
  • bs:clear: Can be dispatched to clear display

Form Integration

<form>
  <barcode-scanner name="scanner"></barcode-scanner>
</form>

Access values:

const form = document.querySelector('form');
const scanner = form.elements.scanner;
console.log(scanner.value); // Last scanned barcode

Debug Mode

With debug attribute, scan history shows:

  • Timestamp
  • Barcode value
  • Source (scanner/manual)

Manual Entry

Enable manual input with the input attribute:

<barcode-scanner input></barcode-scanner>
1.0.13

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago