@4efficiency/react-barcode-reader 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/dist/index.js +7 -4
  2. package/package.json +15 -7
package/dist/index.js CHANGED
@@ -124,6 +124,7 @@ function BarcodeScanner(props) {
124
124
  e.preventDefault();
125
125
  }
126
126
  const isStart = code !== undefined && startChar.indexOf(code) !== -1;
127
+ const isPrintable = typeof code !== "undefined" && key.length === 1;
127
128
  if (firstCharTimeRef.current && isEnd) {
128
129
  callIsScannerRef.current = true;
129
130
  }
@@ -132,15 +133,17 @@ function BarcodeScanner(props) {
132
133
  }
133
134
  else {
134
135
  // Append printable chars only
135
- if (typeof code !== "undefined" && key.length === 1) {
136
+ if (isPrintable) {
136
137
  stringWritingRef.current += key;
137
138
  }
138
139
  callIsScannerRef.current = false;
139
140
  }
140
- if (!firstCharTimeRef.current) {
141
- firstCharTimeRef.current = Date.now();
141
+ if (isPrintable || isStart || isEnd) {
142
+ if (!firstCharTimeRef.current) {
143
+ firstCharTimeRef.current = Date.now();
144
+ }
145
+ lastCharTimeRef.current = Date.now();
142
146
  }
143
- lastCharTimeRef.current = Date.now();
144
147
  if (testTimerRef.current)
145
148
  clearTimeout(testTimerRef.current);
146
149
  if (callIsScannerRef.current) {
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "@4efficiency/react-barcode-reader",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A react component for reading barcodes and Qr codes from keybord input devices.",
5
5
  "main": "dist/index.js",
6
- "module":"dist/index.js",
7
- "types":"dist/index.d.ts",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
8
  "files": [
9
9
  "dist"
10
10
  ],
11
11
  "scripts": {
12
12
  "build": "tsc",
13
- "prepublishOnly": "npm run build"
13
+ "prepublishOnly": "npm run build",
14
+ "lint": "eslint -c ./eslint.config.js ./src"
14
15
  },
15
16
  "peerDependencies": {
16
17
  "react": ">=19.2.0"
@@ -20,12 +21,19 @@
20
21
  "url": "https://4ef.visualstudio.com/4EF%20Shared%20Libraries/_git/4ef-react-barcode-reader"
21
22
  },
22
23
  "keywords": [],
23
- "author": "",
24
- "license": "ISC",
24
+ "author": "4EFficicncy Services",
25
+ "license": "MIT",
25
26
  "type": "module",
26
27
  "devDependencies": {
27
28
  "@types/react": "^19.2.7",
28
29
  "@types/react-dom": "^19.2.3",
29
- "typescript": "^5.9.3"
30
+ "typescript": "^5.9.3",
31
+ "eslint": "^9.39.2",
32
+ "eslint-config-prettier": "^10.1.8",
33
+ "eslint-plugin-prettier": "^5.5.4",
34
+ "eslint-plugin-react-hooks": "^7.0.1",
35
+ "eslint-plugin-react-refresh": "^0.4.26",
36
+ "prettier": "^3.7.4",
37
+ "typescript-eslint": "^8.50.0"
30
38
  }
31
39
  }