Skip to content

Commit aa6e995

Browse files
committed
Initial commit
0 parents  commit aa6e995

19 files changed

+28239
-0
lines changed

.babelrc

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"presets": [
3+
"@babel/preset-env",
4+
"@babel/preset-react"
5+
],
6+
"plugins": [
7+
"@babel/plugin-syntax-dynamic-import",
8+
"@babel/plugin-syntax-import-meta",
9+
"@babel/plugin-proposal-class-properties",
10+
"@babel/plugin-proposal-json-strings",
11+
[
12+
"@babel/plugin-proposal-decorators",
13+
{
14+
"legacy": true
15+
}
16+
],
17+
"@babel/plugin-proposal-function-sent",
18+
"@babel/plugin-proposal-export-namespace-from",
19+
"@babel/plugin-proposal-numeric-separator",
20+
"@babel/plugin-proposal-throw-expressions",
21+
"@babel/plugin-proposal-export-default-from",
22+
"@babel/plugin-proposal-logical-assignment-operators",
23+
"@babel/plugin-proposal-optional-chaining",
24+
[
25+
"@babel/plugin-proposal-pipeline-operator",
26+
{
27+
"proposal": "minimal"
28+
}
29+
],
30+
"@babel/plugin-proposal-nullish-coalescing-operator",
31+
"@babel/plugin-proposal-do-expressions",
32+
"@babel/plugin-proposal-function-bind"
33+
]
34+
}

.eslintrc.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"parser": "babel-eslint",
3+
"env": {
4+
"es6": true,
5+
"node": true,
6+
"browser": true
7+
},
8+
"extends": "eslint:recommended",
9+
"parserOptions": {
10+
"ecmaVersion": 7,
11+
"sourceType": "module",
12+
"ecmaFeatures": {
13+
"jsx": true,
14+
"experimentalObjectRestSpread": true,
15+
"classes": true
16+
}
17+
},
18+
"plugins": [
19+
"react"
20+
],
21+
"rules": {
22+
"indent": [
23+
"error",
24+
2
25+
],
26+
"quotes": [
27+
"error",
28+
"single"
29+
],
30+
"linebreak-style": [
31+
"error",
32+
"unix"
33+
],
34+
"semi": [
35+
"error",
36+
"never"
37+
],
38+
"comma-dangle": [
39+
"warn",
40+
"always-multiline"
41+
],
42+
"constructor-super": "error",
43+
"no-confusing-arrow": "error",
44+
"no-constant-condition": "error",
45+
"no-class-assign": "error",
46+
"no-const-assign": "error",
47+
"no-dupe-class-members": "error",
48+
"no-var": "warn",
49+
"no-this-before-super": "error",
50+
"no-extra-boolean-cast": "off",
51+
"object-shorthand": [
52+
"error",
53+
"always"
54+
],
55+
"prefer-spread": "warn",
56+
"prefer-template": "warn",
57+
"require-yield": "error",
58+
"jsx-quotes": "warn",
59+
"react/jsx-boolean-value": "warn",
60+
"react/jsx-curly-spacing": "warn",
61+
"react/jsx-no-duplicate-props": "warn",
62+
"react/jsx-no-undef": "warn",
63+
"react/jsx-uses-react": "warn",
64+
"react/jsx-uses-vars": "warn",
65+
"react/no-danger": "warn",
66+
"react/no-did-mount-set-state": "warn",
67+
"react/no-did-update-set-state": "warn",
68+
"react/no-direct-mutation-state": "warn",
69+
"react/no-multi-comp": "warn",
70+
"react/no-set-state": "warn",
71+
"react/no-unknown-property": "warn",
72+
"react/prefer-es6-class": "warn",
73+
"react/prop-types": "warn",
74+
"react/react-in-jsx-scope": "warn",
75+
"react/require-extension": "warn",
76+
"react/self-closing-comp": "warn",
77+
"react/sort-comp": "warn",
78+
"react/wrap-multilines": "warn"
79+
}
80+
}

.gitignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
18+
.grunt
19+
20+
# node-waf configuration
21+
.lock-wscript
22+
23+
# Compiled binary addons (http://nodejs.org/api/addons.html)
24+
build/Release
25+
26+
# Dependency directory
27+
node_modules
28+
29+
# Optional npm cache directory
30+
.npm
31+
32+
# Optional REPL history
33+
.node_repl_history
34+
35+
36+
lib/worker.js

.storybook/config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { configure } from '@storybook/react'
2+
3+
function loadStories() {
4+
require('../story.js')
5+
}
6+
7+
configure(loadStories, module)

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Thomas Billiet
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
[![npm version](https://badge.fury.io/js/react-barcode-reader.svg)](https://badge.fury.io/js/react-barcode-reader)
2+
3+
## Introduction
4+
A [React](https://facebook.github.io/react/) component for reading barcode an QR codes from devices that are represent as keyboard to the system.
5+
6+
## Demo
7+
[kybarg.github.io/react-barcode-reader/](https://kybarg.github.io/react-barcode-reader/)
8+
9+
## Install
10+
`npm install --save react-barcode-reader`
11+
12+
## Example
13+
14+
```js
15+
import React, { Component } from 'react'
16+
import BarcodeReader from 'react-barcode-reader'
17+
18+
class Test extends Component {
19+
constructor(props){
20+
super(props)
21+
this.state = {
22+
result: 'No result',
23+
}
24+
25+
this.handleScan = this.handleScan.bind(this)
26+
}
27+
handleScan(data){
28+
this.setState({
29+
result: data,
30+
})
31+
}
32+
handleError(err){
33+
console.error(err)
34+
}
35+
render(){
36+
37+
return(
38+
<div>
39+
<BarcodeReader
40+
onError={this.handleError}
41+
onScan={this.handleScan}
42+
/>
43+
<p>{this.state.result}</p>
44+
</div>
45+
)
46+
}
47+
}
48+
```
49+
50+
## Props
51+
| Prop | Type | Default Value | Description |
52+
|---|---|---|---|---|
53+
| onScan | func | | Callback after detection of a successfull scanning (scanned string in parameter) |
54+
| onError | func | | Callback after detection of a unsuccessfull scanning (scanned string in parameter) |
55+
| HonReceive | func | | Callback after receiving and processing a char (scanned char in parameter)
56+
| onKeyDetect | func | | Callback after detecting a keyDown (key char in parameter) - in contrast to onReceive, this fires for non-character keys like tab, arrows, etc. too!
57+
| timeBeforeScanTest | number | 100 | Wait duration (ms) after keypress event to check if scanning is finished
58+
| avgTimeByChar | number | 30 | Average time (ms) between 2 chars. Used to do difference between keyboard typing and scanning
59+
| minLength | number | 6 | Minimum length for a scanning
60+
| endChar | [number] | [9, 13] | Chars to remove and means end of scanning
61+
| startChar | [number] | [] | Chars to remove and means start of scanning
62+
| scanButtonKeyCode | number | | Key code of the scanner hardware button (if the scanner button a acts as a key itself)
63+
| scanButtonLongPressThreshold | number | 3 | How many times the hardware button should issue a pressed event before a barcode is read to detect a longpress
64+
| onScanButtonLongPressed | func | | Callback after detection of a successfull scan while the scan button was pressed and held down
65+
| stopPropagation | bool | false | Stop immediate propagation on keypress event
66+
| preventDefault | bool | false | Prevent default action on keypress event
67+
| testCode | string | | Test string for simulating
68+
69+
## Dev
70+
71+
### Install dependencies
72+
`npm install`
73+
74+
### Build
75+
`npm run build`
76+
77+
### Demo
78+
`npm run storybook`
79+
80+
### Test
81+
`npm test`
82+
83+
### Linting
84+
`npm run lint`
85+
86+
## License
87+
The MIT License (MIT)
88+
89+
Copyright (c) 2017 Thomas Billiet
90+
91+
Permission is hereby granted, free of charge, to any person obtaining a copy
92+
of this software and associated documentation files (the "Software"), to deal
93+
in the Software without restriction, including without limitation the rights
94+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
95+
copies of the Software, and to permit persons to whom the Software is
96+
furnished to do so, subject to the following conditions:
97+
98+
The above copyright notice and this permission notice shall be included in all
99+
copies or substantial portions of the Software.
100+
101+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
104+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
105+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107+
SOFTWARE.

docs/favicon.ico

5.3 KB
Binary file not shown.

docs/iframe.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
8+
<base target="_parent">
9+
<script>
10+
if (window.parent !== window) {
11+
try {
12+
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__;
13+
} catch (error) {
14+
// The above line can throw if we do not have access to the parent frame -- i.e. cross origin
15+
}
16+
}
17+
</script>
18+
<title>Storybook</title>
19+
20+
</head>
21+
22+
<body>
23+
<div id="root"></div>
24+
<div id="error-display"></div>
25+
<script type="text/javascript" src="static/preview.0a5ded0c6d25ea84b872.bundle.js"></script></body>
26+
27+
</html>

docs/index.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<meta name="storybook-version" content="3.4.11">
7+
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
8+
<title>Storybook</title>
9+
<style>
10+
/*
11+
When resizing panels, the drag event breaks if the cursor
12+
moves over the iframe. Add the 'dragging' class to the body
13+
at drag start and remove it when the drag ends.
14+
*/
15+
.dragging iframe {
16+
pointer-events: none;
17+
}
18+
19+
/* Styling the fuzzy search box placeholders */
20+
.searchBox::-webkit-input-placeholder { /* Chrome/Opera/Safari */
21+
color: #ddd;
22+
font-size: 16px;
23+
}
24+
25+
.searchBox::-moz-placeholder { /* Firefox 19+ */
26+
color: #ddd;
27+
font-size: 16px;
28+
}
29+
30+
.searchBox:focus{
31+
border-color: #EEE !important;
32+
}
33+
34+
.btn:hover{
35+
background-color: #eee
36+
}
37+
</style>
38+
39+
40+
</head>
41+
<body style="margin: 0;">
42+
<div id="root"></div>
43+
<script type="text/javascript" src="static/manager.590dac8efce4bda4401d.bundle.js"></script></body>
44+
</html>

docs/static/manager.590dac8efce4bda4401d.bundle.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)