CameraScannerPanel
CameraScannerPanel is the inline, resizable camera barcode scanner, with a close button, status text and a flash on each accepted scan.
Import
import { CameraScannerPanel } from '@tallyui/components';
import type { CameraDecoder } from '@tallyui/pos';Usage
<CameraScannerPanel
onClose={() => setScannerOpen(false)}
height={scannerHeight}
onHeightChange={setScannerHeight}
onDetected={camera.offer}
onOpen={camera.reset}
scanCount={camera.scanCount}
/>The inline camera scanner, ported from WCPOS v2. It calls no POS hook: the app owns useCameraScan (and its ScanHubProvider) and passes its offer, reset and scanCount, so accepted decodes reach the app's useBarcodeScanner like any device scan. Mounting the panel calls onOpen once, and each change of scanCount after mount flashes a border around the view.
The camera view is ScannerViewfinder by default, which works on the web only. A native app passes its own viewfinder (for example one built on expo-camera) and a permission; while permission.granted is false the panel shows an "Allow camera" button that calls permission.request instead of the camera. On the web, leave permission out: the browser asks when the camera opens.
Status text from the viewfinder (starting, access denied, camera unavailable, decoding failing) and the readiness note are shown over the bottom of the view. A handle under the view resizes it: by pointer drag on the web, reported to onHeightChange once when the drag ends if the height changed, and by the accessibility increment and decrement actions, 16 points a step, reported on each step.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
onClose | () => void | required | Called by the close button |
height | number | SCANNER_DEFAULT_HEIGHT | Height of the camera view, clamped to the min and max below |
onHeightChange | (height: number) => void | — | Called with the new height after a resize; the app persists it |
permission | { granted: boolean; request: () => void } | — | Native permission flow; omit on web |
viewfinder | ComponentType<ViewfinderProps> | ScannerViewfinder | The camera view component |
decoder | CameraDecoder | — | Passed to the viewfinder |
readiness | string | — | A note such as storage or sync starting; the app picks the copy |
onDetected | (code: string, symbology?: string) => void | required | Each decode, passed straight to the viewfinder |
onOpen | () => void | — | Called once on mount |
scanCount | number | — | Each change after mount flashes the panel |
Constants
| Constant | Value | Meaning |
|---|---|---|
SCANNER_MIN_HEIGHT | 96 | Smallest height of the camera view |
SCANNER_MAX_HEIGHT | 480 | Largest height of the camera view |
SCANNER_DEFAULT_HEIGHT | 176 | Height when height is not passed |
FLASH_DURATION_MS | 350 | How long the scan flash stays on; a new scan restarts it |