@operato/ocr 0.2.15 → 0.2.19
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/CHANGELOG.md +19 -0
- package/demo/index.html +35 -25
- package/dist/src/camera-capturer.js +2 -2
- package/dist/src/camera-capturer.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-camera-capturer.d.ts +14 -0
- package/dist/src/ox-camera-capturer.js +178 -0
- package/dist/src/ox-camera-capturer.js.map +1 -0
- package/dist/src/{ocr-helper.d.ts → ox-ocr-helper.d.ts} +4 -2
- package/dist/src/{ocr-helper.js → ox-ocr-helper.js} +26 -25
- package/dist/src/ox-ocr-helper.js.map +1 -0
- package/dist/src/ox-ocr-result-image.d.ts +47 -0
- package/dist/src/ox-ocr-result-image.js +921 -0
- package/dist/src/ox-ocr-result-image.js.map +1 -0
- package/dist/src/utils/file-drop-helper.d.ts +16 -0
- package/dist/src/utils/file-drop-helper.js +47 -0
- package/dist/src/utils/file-drop-helper.js.map +1 -0
- package/dist/src/utils/touch-mouse-event.d.ts +0 -0
- package/dist/src/utils/touch-mouse-event.js +2 -0
- package/dist/src/utils/touch-mouse-event.js.map +1 -0
- package/dist/src/utils/touch-to-mouse-event.d.ts +1 -0
- package/dist/src/utils/touch-to-mouse-event.js +34 -0
- package/dist/src/utils/touch-to-mouse-event.js.map +1 -0
- package/dist/stories/index.stories.d.ts +1 -1
- package/dist/stories/index.stories.js +10 -14
- package/dist/stories/index.stories.js.map +1 -1
- package/dist/test/ox-ocr-helper.test.d.ts +1 -0
- package/dist/test/{ocr-helper.test.js → ox-ocr-helper.test.js} +7 -7
- package/dist/test/ox-ocr-helper.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/index.ts +1 -1
- package/src/{camera-capturer.ts → ox-camera-capturer.ts} +18 -10
- package/src/{ocr-helper.ts → ox-ocr-helper.ts} +27 -26
- package/src/ox-ocr-result-image.ts +954 -0
- package/src/{file-drop-helper.ts → utils/file-drop-helper.ts} +0 -0
- package/src/utils/touch-to-mouse-event.ts +39 -0
- package/stories/index.stories.ts +29 -37
- package/test/{ocr-helper.test.ts → ox-ocr-helper.test.ts} +8 -7
- package/dist/src/ocr-helper.js.map +0 -1
- package/dist/test/ocr-helper.test.d.ts +0 -1
- package/dist/test/ocr-helper.test.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
### [0.2.19](https://github.com/hatiolab/operato/compare/v0.2.18...v0.2.19) (2021-11-23)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### :bug: Bug Fix
|
|
10
|
+
|
|
11
|
+
* automatically paste selected text into clipboard ([eb260d3](https://github.com/hatiolab/operato/commit/eb260d3e59bd9799f8d8bb1359608b33790a5939))
|
|
12
|
+
* ocr result style ([f6479a1](https://github.com/hatiolab/operato/commit/f6479a1aa2bc36b87b8aec47caf6ac3853094317))
|
|
13
|
+
* ocr style ([a5a8169](https://github.com/hatiolab/operato/commit/a5a816939872b277c49997f802d191a68f477e38))
|
|
14
|
+
* ocr-helper ..ing ([d7bf7f2](https://github.com/hatiolab/operato/commit/d7bf7f2654f2df83719e0b07c8cd1764e800a8cc))
|
|
15
|
+
* operato/ocr ([dd46fc1](https://github.com/hatiolab/operato/commit/dd46fc1125ef63c745b4b9ece3935cb7c56a8b36))
|
|
16
|
+
* ox-camera-capture bug ([16834ee](https://github.com/hatiolab/operato/commit/16834ee5fbfb213c8cfdb832a60abe188a483728))
|
|
17
|
+
* ox-camera-capture font ([dd994e1](https://github.com/hatiolab/operato/commit/dd994e1cddd238932a3941e9604e6115cc3450c6))
|
|
18
|
+
* ox-ocr-helper modified ([6f474de](https://github.com/hatiolab/operato/commit/6f474de4c79faf12456f7c992fa33784a3590ff7))
|
|
19
|
+
* ox-ocr-helper to issue an event when it submitted ([a0d7209](https://github.com/hatiolab/operato/commit/a0d72091567e22593a114e3eb877ead79d973200))
|
|
20
|
+
* support shiftkey to make path continuously ([758b444](https://github.com/hatiolab/operato/commit/758b44458b32045d4903f18546fbaa9ed2ad2a25))
|
|
21
|
+
* tuned ocr-result-image ([d1b8816](https://github.com/hatiolab/operato/commit/d1b881600e6759cf3620a981a332829b52e8d877))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
### [0.2.15](https://github.com/hatiolab/operato/compare/v0.2.14...v0.2.15) (2021-11-21)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @operato/ocr
|
package/demo/index.html
CHANGED
|
@@ -1,29 +1,39 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!DOCTYPE html>
|
|
2
2
|
<html lang="en-GB">
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
</head>
|
|
11
|
-
<body>
|
|
12
|
-
<div id="demo"></div>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<style>
|
|
6
|
+
body {
|
|
7
|
+
margin: 0;
|
|
8
|
+
padding: 0;
|
|
9
|
+
overflow: hidden;
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
/* This is a font-stack that tries to use the system-default sans-serifs first */
|
|
12
|
+
font-family: Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
13
|
+
line-height: 1.5;
|
|
14
|
+
-webkit-font-smoothing: antialiased;
|
|
15
|
+
}
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
</
|
|
17
|
+
#demo {
|
|
18
|
+
height: 100vh;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
ox-ocr-helper {
|
|
22
|
+
height: 100%;
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
25
|
+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet" />
|
|
26
|
+
<link href="https://fonts.googleapis.com/css?family=Material+Icons&display=block" rel="stylesheet" />
|
|
27
|
+
</head>
|
|
28
|
+
<body>
|
|
29
|
+
<div id="demo"></div>
|
|
30
|
+
|
|
31
|
+
<script type="module">
|
|
32
|
+
import { html, render } from 'lit'
|
|
33
|
+
import '../dist/src/ox-ocr-helper.js'
|
|
34
|
+
|
|
35
|
+
const title = 'Hello owc World!'
|
|
36
|
+
render(html` <ox-ocr-helper .title=${title}> some light-dom </ox-ocr-helper> `, document.querySelector('#demo'))
|
|
37
|
+
</script>
|
|
38
|
+
</body>
|
|
29
39
|
</html>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import '@material/mwc-icon';
|
|
3
|
-
import {
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
4
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
5
5
|
import { FileDropHelper } from './file-drop-helper';
|
|
6
6
|
let CameraCapturer = class CameraCapturer extends LitElement {
|
|
@@ -164,7 +164,7 @@ __decorate([
|
|
|
164
164
|
query('#input-file')
|
|
165
165
|
], CameraCapturer.prototype, "fileInput", void 0);
|
|
166
166
|
CameraCapturer = __decorate([
|
|
167
|
-
customElement('camera-capturer')
|
|
167
|
+
customElement('ox-camera-capturer')
|
|
168
168
|
], CameraCapturer);
|
|
169
169
|
export { CameraCapturer };
|
|
170
170
|
//# sourceMappingURL=camera-capturer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camera-capturer.js","sourceRoot":"","sources":["../../src/camera-capturer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AE,CAAA;QAEhB,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,cAAc,EAAE;YAC9B,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE;gBACN,KAAK,EAAE,IAAI,CAAC,MAAM;aACnB;SACF,CAAC,CACH,CAAA;IACH,CAAC;CACF,CAAA;AA3KQ,qBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4DF;CACF,CAAA;AAE4B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAmB;AACnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAgB;AACf;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAe;AACf;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;8CAAgB;AAoFpB;IAArB,KAAK,CAAC,aAAa,CAAC;iDAA6B;AAxJvC,cAAc;IAD1B,aAAa,CAAC,oBAAoB,CAAC;GACvB,cAAc,CA4K1B;SA5KY,cAAc","sourcesContent":["import '@material/mwc-icon'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { FileDropHelper } from './file-drop-helper'\n\n@customElement('ox-camera-capturer')\nexport class CameraCapturer extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n border-radius: var(--border-radius);\n text-align: center;\n padding-bottom: 5px !important;\n text-transform: capitalize;\n\n border: var(--file-uploader-border);\n background-color: var(--main-section-background-color);\n font: var(--file-uploader-font) !important;\n color: var(--file-uploader-color);\n }\n :host > mwc-icon {\n color: var(--file-uploader-icon-color);\n }\n\n :host(.candrop) {\n background-color: var(--file-uploader-candrop-background-color);\n }\n\n #input-file {\n display: none;\n }\n\n label {\n position: relative;\n width: auto;\n border: none;\n text-transform: capitalize;\n\n padding: var(--file-uploader-label-padding);\n border-radius: var(--file-uploader-label-border-radius);\n background-color: var(--file-uploader-label-background-color);\n color: var(--file-uploader-label-color);\n font: var(--file-uploader-label-font) !important;\n }\n\n ul {\n max-width: 500px;\n list-style: none;\n padding: 0;\n }\n li {\n text-align: left;\n\n padding: var(--file-uploader-li-padding);\n border-bottom: var(--file-uploader-li-border-bottom);\n }\n li mwc-icon {\n float: right;\n cursor: pointer;\n font: var(--file-uploader-li-icon-font);\n margin: var(--file-uploader-li-icon-margin);\n }\n li mwc-icon:hover,\n li mwc-icon:active {\n color: var(--file-uploader-li-icon-focus-color);\n }\n `\n ]\n\n @property({ type: Boolean }) multiple?: boolean\n @property({ type: String }) accept?: string\n @property({ type: String }) label?: string\n @property({ type: Array }) _files?: File[]\n\n render() {\n var files = this._files || []\n\n return html`\n <mwc-icon>camera</mwc-icon>\n <span>Capture image<br />or drop files here!</span>\n <input\n id=\"input-file\"\n type=\"file\"\n accept=${this.accept}\n ?multiple=${this.multiple}\n hidden\n capture=\"environment\"\n @change=${(e: Event) => {\n const fileInput = e.currentTarget as HTMLInputElement\n\n this._files = [...files, ...Array.from(fileInput.files as FileList)]\n\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: files\n }\n })\n )\n\n // fileInput.value = null\n fileInput.files = null\n }}\n />\n <label for=\"input-file\">${this.label || 'capture image'}</label>\n\n ${files?.length\n ? html` <ul>\n ${files.map(\n file => html`\n <li>\n - ${file.name}\n <mwc-icon\n @click=${(e: Event) => {\n this._files = [...files.splice(files.indexOf(file), 1)]\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: this._files\n }\n })\n )\n }}\n >delete_outline</mwc-icon\n >\n </li>\n `\n )}\n </ul>`\n : ''}\n `\n }\n\n firstUpdated() {\n FileDropHelper.set(this)\n\n this.addEventListener('file-drop', (e: Event) => {\n const detail = (e as CustomEvent).detail\n this._files = this.multiple ? detail : detail[0] ? [detail[0]] : []\n\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: this._files\n }\n })\n )\n })\n }\n\n @query('#input-file') fileInput!: HTMLInputElement\n\n get files() {\n return this._files\n }\n\n reset() {\n this.fileInput.value = ''\n this._files = []\n\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: this._files\n }\n })\n )\n }\n}\n"]}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './ocr-helper.js';
|
|
1
|
+
export * from './ox-ocr-helper.js';
|
package/dist/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './ocr-helper.js';
|
|
1
|
+
export * from './ox-ocr-helper.js';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA","sourcesContent":["export * from './ox-ocr-helper.js'\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import '@material/mwc-icon';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
export declare class CameraCapturer extends LitElement {
|
|
4
|
+
static styles: import("lit").CSSResult[];
|
|
5
|
+
multiple?: boolean;
|
|
6
|
+
accept?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
_files?: File[];
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
firstUpdated(): void;
|
|
11
|
+
fileInput: HTMLInputElement;
|
|
12
|
+
get files(): File[] | undefined;
|
|
13
|
+
reset(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@material/mwc-icon';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
import { customElement, property, query } from 'lit/decorators.js';
|
|
5
|
+
import { FileDropHelper } from './utils/file-drop-helper';
|
|
6
|
+
let CameraCapturer = class CameraCapturer extends LitElement {
|
|
7
|
+
render() {
|
|
8
|
+
var files = this._files || [];
|
|
9
|
+
return html `
|
|
10
|
+
<mwc-icon>camera</mwc-icon>
|
|
11
|
+
<span>Capture image or drop files here!</span>
|
|
12
|
+
<input
|
|
13
|
+
id="input-file"
|
|
14
|
+
type="file"
|
|
15
|
+
accept=${this.accept}
|
|
16
|
+
?multiple=${this.multiple}
|
|
17
|
+
hidden
|
|
18
|
+
capture="environment"
|
|
19
|
+
@change=${(e) => {
|
|
20
|
+
const fileInput = e.currentTarget;
|
|
21
|
+
this._files = [...files, ...Array.from(fileInput.files)];
|
|
22
|
+
this.dispatchEvent(new CustomEvent('files-change', {
|
|
23
|
+
bubbles: true,
|
|
24
|
+
composed: true,
|
|
25
|
+
detail: {
|
|
26
|
+
files: files
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
// fileInput.value = null
|
|
30
|
+
fileInput.files = null;
|
|
31
|
+
}}
|
|
32
|
+
/>
|
|
33
|
+
<!-- <label for="input-file">${this.label || 'capture image'}</label> -->
|
|
34
|
+
|
|
35
|
+
${(files === null || files === void 0 ? void 0 : files.length)
|
|
36
|
+
? html ` <ul>
|
|
37
|
+
${files.map(file => html `
|
|
38
|
+
<li>
|
|
39
|
+
- ${file.name}
|
|
40
|
+
<mwc-icon
|
|
41
|
+
@click=${(e) => {
|
|
42
|
+
files.splice(files.indexOf(file), 1);
|
|
43
|
+
this._files = [...files];
|
|
44
|
+
this.dispatchEvent(new CustomEvent('files-change', {
|
|
45
|
+
bubbles: true,
|
|
46
|
+
composed: true,
|
|
47
|
+
detail: {
|
|
48
|
+
files: this._files
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
}}
|
|
52
|
+
>delete_outline</mwc-icon
|
|
53
|
+
>
|
|
54
|
+
</li>
|
|
55
|
+
`)}
|
|
56
|
+
</ul>`
|
|
57
|
+
: ''}
|
|
58
|
+
`;
|
|
59
|
+
}
|
|
60
|
+
firstUpdated() {
|
|
61
|
+
FileDropHelper.set(this);
|
|
62
|
+
this.addEventListener('file-drop', (e) => {
|
|
63
|
+
const detail = e.detail;
|
|
64
|
+
this._files = this.multiple ? detail : detail[0] ? [detail[0]] : [];
|
|
65
|
+
this.dispatchEvent(new CustomEvent('files-change', {
|
|
66
|
+
bubbles: true,
|
|
67
|
+
composed: true,
|
|
68
|
+
detail: {
|
|
69
|
+
files: this._files
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
get files() {
|
|
75
|
+
return this._files;
|
|
76
|
+
}
|
|
77
|
+
reset() {
|
|
78
|
+
this.fileInput.value = '';
|
|
79
|
+
this._files = [];
|
|
80
|
+
this.dispatchEvent(new CustomEvent('files-change', {
|
|
81
|
+
bubbles: true,
|
|
82
|
+
composed: true,
|
|
83
|
+
detail: {
|
|
84
|
+
files: this._files
|
|
85
|
+
}
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
CameraCapturer.styles = [
|
|
90
|
+
css `
|
|
91
|
+
:host {
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
border-radius: var(--border-radius);
|
|
95
|
+
align-items: center;
|
|
96
|
+
justify-content: center;
|
|
97
|
+
padding: var(--padding-default, 9px);
|
|
98
|
+
min-height: 100px;
|
|
99
|
+
text-transform: capitalize;
|
|
100
|
+
|
|
101
|
+
border: var(--file-uploader-border);
|
|
102
|
+
background-color: var(--main-section-background-color);
|
|
103
|
+
font: var(--file-uploader-font) !important;
|
|
104
|
+
color: var(--file-uploader-color);
|
|
105
|
+
}
|
|
106
|
+
:host > mwc-icon {
|
|
107
|
+
color: var(--file-uploader-icon-color);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
:host(.candrop) {
|
|
111
|
+
background-color: var(--file-uploader-candrop-background-color);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#input-file {
|
|
115
|
+
display: none;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
label {
|
|
119
|
+
position: relative;
|
|
120
|
+
width: auto;
|
|
121
|
+
border: none;
|
|
122
|
+
text-transform: capitalize;
|
|
123
|
+
|
|
124
|
+
padding: var(--file-uploader-label-padding);
|
|
125
|
+
border-radius: var(--file-uploader-label-border-radius);
|
|
126
|
+
background-color: var(--file-uploader-label-background-color);
|
|
127
|
+
color: var(--file-uploader-label-color);
|
|
128
|
+
font: var(--file-uploader-label-font) !important;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
ul {
|
|
132
|
+
max-width: 500px;
|
|
133
|
+
list-style: none;
|
|
134
|
+
margin: 5px 0 0 0;
|
|
135
|
+
padding: 0;
|
|
136
|
+
max-height: 46px;
|
|
137
|
+
overflow: auto;
|
|
138
|
+
background-color: rgba(var(--primary-color-rgb), 0.1);
|
|
139
|
+
}
|
|
140
|
+
li {
|
|
141
|
+
text-align: left;
|
|
142
|
+
|
|
143
|
+
padding: 3px 5px 2px 5px;
|
|
144
|
+
border-bottom: var(--file-uploader-li-border-bottom);
|
|
145
|
+
font: normal 14px var(--theme-font);
|
|
146
|
+
}
|
|
147
|
+
li mwc-icon {
|
|
148
|
+
float: right;
|
|
149
|
+
cursor: pointer;
|
|
150
|
+
margin: var(--file-uploader-li-icon-margin);
|
|
151
|
+
font-size: 1em;
|
|
152
|
+
}
|
|
153
|
+
li mwc-icon:hover,
|
|
154
|
+
li mwc-icon:active {
|
|
155
|
+
color: var(--file-uploader-li-icon-focus-color);
|
|
156
|
+
}
|
|
157
|
+
`
|
|
158
|
+
];
|
|
159
|
+
__decorate([
|
|
160
|
+
property({ type: Boolean })
|
|
161
|
+
], CameraCapturer.prototype, "multiple", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
property({ type: String })
|
|
164
|
+
], CameraCapturer.prototype, "accept", void 0);
|
|
165
|
+
__decorate([
|
|
166
|
+
property({ type: String })
|
|
167
|
+
], CameraCapturer.prototype, "label", void 0);
|
|
168
|
+
__decorate([
|
|
169
|
+
property({ type: Array })
|
|
170
|
+
], CameraCapturer.prototype, "_files", void 0);
|
|
171
|
+
__decorate([
|
|
172
|
+
query('#input-file')
|
|
173
|
+
], CameraCapturer.prototype, "fileInput", void 0);
|
|
174
|
+
CameraCapturer = __decorate([
|
|
175
|
+
customElement('ox-camera-capturer')
|
|
176
|
+
], CameraCapturer);
|
|
177
|
+
export { CameraCapturer };
|
|
178
|
+
//# sourceMappingURL=ox-camera-capturer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-camera-capturer.js","sourceRoot":"","sources":["../../src/ox-camera-capturer.ts"],"names":[],"mappings":";AAAA,OAAO,oBAAoB,CAAA;AAE3B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAElE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAGzD,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,UAAU;IA6E5C,MAAM;QACJ,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAA;QAE7B,OAAO,IAAI,CAAA;;;;;;iBAME,IAAI,CAAC,MAAM;oBACR,IAAI,CAAC,QAAQ;;;kBAGf,CAAC,CAAQ,EAAE,EAAE;YACrB,MAAM,SAAS,GAAG,CAAC,CAAC,aAAiC,CAAA;YAErD,IAAI,CAAC,MAAM,GAAG,CAAC,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAi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CAoL1B;SApLY,cAAc","sourcesContent":["import '@material/mwc-icon'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\nimport { FileDropHelper } from './utils/file-drop-helper'\n\n@customElement('ox-camera-capturer')\nexport class CameraCapturer extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n border-radius: var(--border-radius);\n align-items: center;\n justify-content: center;\n padding: var(--padding-default, 9px);\n min-height: 100px;\n text-transform: capitalize;\n\n border: var(--file-uploader-border);\n background-color: var(--main-section-background-color);\n font: var(--file-uploader-font) !important;\n color: var(--file-uploader-color);\n }\n :host > mwc-icon {\n color: var(--file-uploader-icon-color);\n }\n\n :host(.candrop) {\n background-color: var(--file-uploader-candrop-background-color);\n }\n\n #input-file {\n display: none;\n }\n\n label {\n position: relative;\n width: auto;\n border: none;\n text-transform: capitalize;\n\n padding: var(--file-uploader-label-padding);\n border-radius: var(--file-uploader-label-border-radius);\n background-color: var(--file-uploader-label-background-color);\n color: var(--file-uploader-label-color);\n font: var(--file-uploader-label-font) !important;\n }\n\n ul {\n max-width: 500px;\n list-style: none;\n margin: 5px 0 0 0;\n padding: 0;\n max-height: 46px;\n overflow: auto;\n background-color: rgba(var(--primary-color-rgb), 0.1);\n }\n li {\n text-align: left;\n\n padding: 3px 5px 2px 5px;\n border-bottom: var(--file-uploader-li-border-bottom);\n font: normal 14px var(--theme-font);\n }\n li mwc-icon {\n float: right;\n cursor: pointer;\n margin: var(--file-uploader-li-icon-margin);\n font-size: 1em;\n }\n li mwc-icon:hover,\n li mwc-icon:active {\n color: var(--file-uploader-li-icon-focus-color);\n }\n `\n ]\n\n @property({ type: Boolean }) multiple?: boolean\n @property({ type: String }) accept?: string\n @property({ type: String }) label?: string\n @property({ type: Array }) _files?: File[]\n\n render() {\n var files = this._files || []\n\n return html`\n <mwc-icon>camera</mwc-icon>\n <span>Capture image or drop files here!</span>\n <input\n id=\"input-file\"\n type=\"file\"\n accept=${this.accept}\n ?multiple=${this.multiple}\n hidden\n capture=\"environment\"\n @change=${(e: Event) => {\n const fileInput = e.currentTarget as HTMLInputElement\n\n this._files = [...files, ...Array.from(fileInput.files as FileList)]\n\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: files\n }\n })\n )\n\n // fileInput.value = null\n fileInput.files = null\n }}\n />\n <!-- <label for=\"input-file\">${this.label || 'capture image'}</label> -->\n\n ${files?.length\n ? html` <ul>\n ${files.map(\n file => html`\n <li>\n - ${file.name}\n <mwc-icon\n @click=${(e: Event) => {\n files.splice(files.indexOf(file), 1)\n this._files = [...files]\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: this._files\n }\n })\n )\n }}\n >delete_outline</mwc-icon\n >\n </li>\n `\n )}\n </ul>`\n : ''}\n `\n }\n\n firstUpdated() {\n FileDropHelper.set(this)\n\n this.addEventListener('file-drop', (e: Event) => {\n const detail = (e as CustomEvent).detail\n this._files = this.multiple ? detail : detail[0] ? [detail[0]] : []\n\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: this._files\n }\n })\n )\n })\n }\n\n @query('#input-file') fileInput!: HTMLInputElement\n\n get files() {\n return this._files\n }\n\n reset() {\n this.fileInput.value = ''\n this._files = []\n\n this.dispatchEvent(\n new CustomEvent('files-change', {\n bubbles: true,\n composed: true,\n detail: {\n files: this._files\n }\n })\n )\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import './camera-capturer';
|
|
2
1
|
import '@material/mwc-button';
|
|
2
|
+
import './ox-camera-capturer';
|
|
3
|
+
import './ox-ocr-result-image';
|
|
3
4
|
import { LitElement } from 'lit';
|
|
4
5
|
export declare class OcrHelper extends LitElement {
|
|
5
6
|
static styles: import("lit").CSSResult[];
|
|
@@ -10,5 +11,6 @@ export declare class OcrHelper extends LitElement {
|
|
|
10
11
|
render(): import("lit-html").TemplateResult<1>;
|
|
11
12
|
fileschange(e: Event): void;
|
|
12
13
|
reset(): void;
|
|
13
|
-
|
|
14
|
+
onSelected(e: CustomEvent): void;
|
|
15
|
+
submit(): Promise<void>;
|
|
14
16
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import './camera-capturer';
|
|
3
2
|
import '@material/mwc-button';
|
|
4
|
-
import
|
|
3
|
+
import './ox-camera-capturer';
|
|
4
|
+
import './ox-ocr-result-image';
|
|
5
|
+
import { css, html, LitElement } from 'lit';
|
|
5
6
|
import { customElement, property, query } from 'lit/decorators.js';
|
|
6
7
|
let OcrHelper = class OcrHelper extends LitElement {
|
|
7
8
|
constructor() {
|
|
@@ -12,13 +13,9 @@ let OcrHelper = class OcrHelper extends LitElement {
|
|
|
12
13
|
const files = this._files || [];
|
|
13
14
|
const index = this.index || 0;
|
|
14
15
|
const file = files[index];
|
|
15
|
-
const image = file && URL.createObjectURL(file);
|
|
16
|
-
if (image) {
|
|
17
|
-
requestAnimationFrame(() => URL.revokeObjectURL(image));
|
|
18
|
-
}
|
|
19
16
|
return html `
|
|
20
17
|
<div attachment-wrap>
|
|
21
|
-
<camera-capturer
|
|
18
|
+
<ox-camera-capturer
|
|
22
19
|
name="scanner"
|
|
23
20
|
id="capturer"
|
|
24
21
|
label="Capture Images"
|
|
@@ -27,10 +24,10 @@ let OcrHelper = class OcrHelper extends LitElement {
|
|
|
27
24
|
?hidden=${false}
|
|
28
25
|
custom-input
|
|
29
26
|
@files-change=${(e) => this.fileschange(e)}
|
|
30
|
-
></camera-capturer>
|
|
27
|
+
></ox-camera-capturer>
|
|
31
28
|
</div>
|
|
32
29
|
<div buttons>
|
|
33
|
-
<mwc-button @click=${(e) => this.
|
|
30
|
+
<mwc-button @click=${(e) => this.submit()}>submit</mwc-button>
|
|
34
31
|
<mwc-button @click=${(e) => this.reset()}>reset</mwc-button>
|
|
35
32
|
</div>
|
|
36
33
|
<div id="images">
|
|
@@ -47,8 +44,9 @@ let OcrHelper = class OcrHelper extends LitElement {
|
|
|
47
44
|
>
|
|
48
45
|
${files.map((file, idx) => html `<div i ?active=${idx === index}>${idx}</div>`)}
|
|
49
46
|
</div>
|
|
50
|
-
<
|
|
47
|
+
<ox-ocr-result-image .file=${file} @selected=${(e) => this.onSelected(e)}></ox-ocr-result-image>
|
|
51
48
|
</div>
|
|
49
|
+
|
|
52
50
|
<div id="result"></div>
|
|
53
51
|
`;
|
|
54
52
|
}
|
|
@@ -59,7 +57,14 @@ let OcrHelper = class OcrHelper extends LitElement {
|
|
|
59
57
|
this.fileUploader.reset();
|
|
60
58
|
this.result.textContent = '';
|
|
61
59
|
}
|
|
62
|
-
|
|
60
|
+
onSelected(e) {
|
|
61
|
+
navigator.clipboard.writeText(e.detail);
|
|
62
|
+
}
|
|
63
|
+
async submit() {
|
|
64
|
+
var _a;
|
|
65
|
+
this.dispatchEvent(new CustomEvent('attached', {
|
|
66
|
+
detail: (_a = this.fileUploader) === null || _a === void 0 ? void 0 : _a.files
|
|
67
|
+
}));
|
|
63
68
|
// const response = await client.query({
|
|
64
69
|
// query: gql`
|
|
65
70
|
// query ocrRequest($images: [Upload!]!) {
|
|
@@ -93,7 +98,7 @@ OcrHelper.styles = [
|
|
|
93
98
|
|
|
94
99
|
#images {
|
|
95
100
|
flex: 1;
|
|
96
|
-
background-color:
|
|
101
|
+
background-color: var(--main-section-background-color, #f4f7fb);
|
|
97
102
|
color: white;
|
|
98
103
|
|
|
99
104
|
display: flex;
|
|
@@ -107,24 +112,20 @@ OcrHelper.styles = [
|
|
|
107
112
|
|
|
108
113
|
[i] {
|
|
109
114
|
min-width: 50px;
|
|
110
|
-
background-color:
|
|
115
|
+
background-color: var(--secondary-color, #394e64);
|
|
116
|
+
border-right: 1px solid rgba(0, 0, 0, 0.2);
|
|
117
|
+
padding: var(--padding-narrow, 4px);
|
|
111
118
|
text-align: center;
|
|
119
|
+
height: 1.4em;
|
|
112
120
|
}
|
|
113
121
|
|
|
114
122
|
[i][active] {
|
|
115
|
-
background-color:
|
|
123
|
+
background-color: var(--primary-color, #22a6a7);
|
|
124
|
+
font-weight: bold;
|
|
116
125
|
}
|
|
117
126
|
|
|
118
|
-
|
|
127
|
+
ox-ocr-result-image {
|
|
119
128
|
flex: 1;
|
|
120
|
-
|
|
121
|
-
display: flex;
|
|
122
|
-
flex-direction: column;
|
|
123
|
-
justify-content: center;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
img {
|
|
127
|
-
style=width: 100%;
|
|
128
129
|
}
|
|
129
130
|
`
|
|
130
131
|
];
|
|
@@ -141,7 +142,7 @@ __decorate([
|
|
|
141
142
|
query('#result')
|
|
142
143
|
], OcrHelper.prototype, "result", void 0);
|
|
143
144
|
OcrHelper = __decorate([
|
|
144
|
-
customElement('ocr-helper')
|
|
145
|
+
customElement('ox-ocr-helper')
|
|
145
146
|
], OcrHelper);
|
|
146
147
|
export { OcrHelper };
|
|
147
|
-
//# sourceMappingURL=ocr-helper.js.map
|
|
148
|
+
//# sourceMappingURL=ox-ocr-helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ox-ocr-helper.js","sourceRoot":"","sources":["../../src/ox-ocr-helper.ts"],"names":[],"mappings":";AAAA,OAAO,sBAAsB,CAAA;AAC7B,OAAO,sBAAsB,CAAA;AAC7B,OAAO,uBAAuB,CAAA;AAE9B,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAGlE,IAAa,SAAS,GAAtB,MAAa,SAAU,SAAQ,UAAU;IAAzC;;QAiD8B,UAAK,GAAW,CAAC,CAAA;IAmF/C,CAAC;IA9EC,MAAM;QACJ,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,IAAI,EAAE,CAAA;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC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S,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,MAAM;;QACV,IAAI,CAAC,aAAa,CAChB,IAAI,WAAW,CAAC,UAAU,EAAE;YAC1B,MAAM,EAAE,MAAA,IAAI,CAAC,YAAY,0CAAE,KAAK;SACjC,CAAC,CACH,CAAA;QACD,wCAAwC;QACxC,gBAAgB;QAChB,8CAA8C;QAC9C,oCAAoC;QACpC,QAAQ;QACR,OAAO;QACP,iBAAiB;QACjB,uCAAuC;QACvC,OAAO;QACP,iCAAiC;QACjC,KAAK;QACL,0BAA0B;QAC1B,uDAAuD;QACvD,WAAW;QACX,sCAAsC;QACtC,IAAI;IACN,CAAC;CACF,CAAA;AAnIQ,gBAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2CF;CACF,CAAA;AAE0B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;yCAAY;AACV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wCAAkB;AAEzB;IAAnB,KAAK,CAAC,WAAW,CAAC;+CAAmB;AACpB;IAAjB,KAAK,CAAC,SAAS,CAAC;yCAAa;AApDnB,SAAS;IADrB,aAAa,CAAC,eAAe,CAAC;GAClB,SAAS,CAoIrB;SApIY,SAAS","sourcesContent":["import '@material/mwc-button'\nimport './ox-camera-capturer'\nimport './ox-ocr-result-image'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query } from 'lit/decorators.js'\n\n@customElement('ox-ocr-helper')\nexport class OcrHelper extends LitElement {\n static styles = [\n css`\n :host {\n display: flex;\n flex-direction: column;\n min-width: 240px;\n }\n\n [buttons] {\n display: flex;\n flex-direction: row-reverse;\n }\n\n #images {\n flex: 1;\n background-color: var(--main-section-background-color, #f4f7fb);\n color: white;\n\n display: flex;\n flex-direction: column;\n }\n\n [tab] {\n display: flex;\n flex-direction: row;\n }\n\n [i] {\n min-width: 50px;\n background-color: var(--secondary-color, #394e64);\n border-right: 1px solid rgba(0, 0, 0, 0.2);\n padding: var(--padding-narrow, 4px);\n text-align: center;\n height: 1.4em;\n }\n\n [i][active] {\n background-color: var(--primary-color, #22a6a7);\n font-weight: bold;\n }\n\n ox-ocr-result-image {\n flex: 1;\n }\n `\n ]\n\n @property({ type: Array }) _files: any\n @property({ type: Number }) index: number = 0\n\n @query('#capturer') fileUploader!: any\n @query('#result') result!: any\n\n render() {\n const files = this._files || []\n const index = this.index || 0\n const file = files[index]\n\n return html`\n <div attachment-wrap>\n <ox-camera-capturer\n name=\"scanner\"\n id=\"capturer\"\n label=\"Capture Images\"\n accept=\"image/*\"\n multiple=\"true\"\n ?hidden=${false}\n custom-input\n @files-change=${(e: Event) => this.fileschange(e)}\n ></ox-camera-capturer>\n </div>\n <div buttons>\n <mwc-button @click=${(e: Event) => this.submit()}>submit</mwc-button>\n <mwc-button @click=${(e: Event) => this.reset()}>reset</mwc-button>\n </div>\n <div id=\"images\">\n <div\n tab\n @click=${(e: MouseEvent) => {\n const item = (e.target as HTMLElement)?.closest('[i]')\n const children = (e.currentTarget as HTMLElement)?.querySelectorAll('[i]')\n if (item) {\n this.index = Array.from(children).indexOf(item)\n }\n }}\n >\n ${files.map((file: any, idx: number) => html`<div i ?active=${idx === index}>${idx}</div>`)}\n </div>\n <ox-ocr-result-image .file=${file} @selected=${(e: CustomEvent) => this.onSelected(e)}></ox-ocr-result-image>\n </div>\n\n <div id=\"result\"></div>\n `\n }\n\n fileschange(e: Event) {\n this._files = this.fileUploader.files\n }\n\n reset() {\n this.fileUploader.reset()\n this.result.textContent = ''\n }\n\n onSelected(e: CustomEvent) {\n navigator.clipboard.writeText(e.detail)\n }\n\n async submit() {\n this.dispatchEvent(\n new CustomEvent('attached', {\n detail: this.fileUploader?.files\n })\n )\n // const response = await client.query({\n // query: gql`\n // query ocrRequest($images: [Upload!]!) {\n // ocrRequest(images: $images)\n // }\n // `,\n // variables: {\n // images: this.fileUploader?.files\n // },\n // context: { hasUpload: true }\n // })\n // if (!response.errors) {\n // this.result.textContent = response.data.ocrRequest\n // } else {\n // this.result.textContent = 'error'\n // }\n }\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
declare type ScanResult = {
|
|
3
|
+
status_code: number;
|
|
4
|
+
key_values: {
|
|
5
|
+
[key: string]: Array<string>;
|
|
6
|
+
};
|
|
7
|
+
boundaries: Array<Array<{
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
}>>;
|
|
11
|
+
texts: Array<string>;
|
|
12
|
+
};
|
|
13
|
+
export declare class OcrResultImage extends LitElement {
|
|
14
|
+
static styles: import("lit").CSSResult[];
|
|
15
|
+
file: any;
|
|
16
|
+
result: ScanResult;
|
|
17
|
+
_ratio: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
};
|
|
21
|
+
_image: string;
|
|
22
|
+
_resizeObserver: ResizeObserver;
|
|
23
|
+
_trails: Array<Array<{
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
}>>;
|
|
27
|
+
_tracking: boolean;
|
|
28
|
+
_selections: Array<number>;
|
|
29
|
+
_text: string;
|
|
30
|
+
_img: HTMLImageElement;
|
|
31
|
+
_overlay: HTMLCanvasElement;
|
|
32
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
33
|
+
renderOverlay(): void;
|
|
34
|
+
calculateRatio(): Promise<void>;
|
|
35
|
+
connectedCallback(): Promise<void>;
|
|
36
|
+
disconnectedCallback(): void;
|
|
37
|
+
updated(changes: PropertyValues<this>): Promise<void>;
|
|
38
|
+
findIndex(x: number, y: number): number;
|
|
39
|
+
updateTrails(point: {
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
}, started: boolean, attached?: boolean): void;
|
|
43
|
+
onTrailStart(e: MouseEvent): void;
|
|
44
|
+
onTrailEnd(e: MouseEvent): void;
|
|
45
|
+
onTrail(e: MouseEvent): void;
|
|
46
|
+
}
|
|
47
|
+
export {};
|