@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
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import './camera-capturer'
|
|
2
1
|
import '@material/mwc-button'
|
|
2
|
+
import './ox-camera-capturer'
|
|
3
|
+
import './ox-ocr-result-image'
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
+
import { css, html, LitElement } from 'lit'
|
|
5
6
|
import { customElement, property, query } from 'lit/decorators.js'
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@customElement('ocr-helper')
|
|
8
|
+
@customElement('ox-ocr-helper')
|
|
10
9
|
export class OcrHelper extends LitElement {
|
|
11
10
|
static styles = [
|
|
12
11
|
css`
|
|
@@ -23,7 +22,7 @@ export class OcrHelper extends LitElement {
|
|
|
23
22
|
|
|
24
23
|
#images {
|
|
25
24
|
flex: 1;
|
|
26
|
-
background-color:
|
|
25
|
+
background-color: var(--main-section-background-color, #f4f7fb);
|
|
27
26
|
color: white;
|
|
28
27
|
|
|
29
28
|
display: flex;
|
|
@@ -37,24 +36,20 @@ export class OcrHelper extends LitElement {
|
|
|
37
36
|
|
|
38
37
|
[i] {
|
|
39
38
|
min-width: 50px;
|
|
40
|
-
background-color:
|
|
39
|
+
background-color: var(--secondary-color, #394e64);
|
|
40
|
+
border-right: 1px solid rgba(0, 0, 0, 0.2);
|
|
41
|
+
padding: var(--padding-narrow, 4px);
|
|
41
42
|
text-align: center;
|
|
43
|
+
height: 1.4em;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
[i][active] {
|
|
45
|
-
background-color:
|
|
47
|
+
background-color: var(--primary-color, #22a6a7);
|
|
48
|
+
font-weight: bold;
|
|
46
49
|
}
|
|
47
50
|
|
|
48
|
-
|
|
51
|
+
ox-ocr-result-image {
|
|
49
52
|
flex: 1;
|
|
50
|
-
|
|
51
|
-
display: flex;
|
|
52
|
-
flex-direction: column;
|
|
53
|
-
justify-content: center;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
img {
|
|
57
|
-
style=width: 100%;
|
|
58
53
|
}
|
|
59
54
|
`
|
|
60
55
|
]
|
|
@@ -69,14 +64,10 @@ export class OcrHelper extends LitElement {
|
|
|
69
64
|
const files = this._files || []
|
|
70
65
|
const index = this.index || 0
|
|
71
66
|
const file = files[index]
|
|
72
|
-
const image = file && URL.createObjectURL(file)
|
|
73
|
-
if (image) {
|
|
74
|
-
requestAnimationFrame(() => URL.revokeObjectURL(image))
|
|
75
|
-
}
|
|
76
67
|
|
|
77
68
|
return html`
|
|
78
69
|
<div attachment-wrap>
|
|
79
|
-
<camera-capturer
|
|
70
|
+
<ox-camera-capturer
|
|
80
71
|
name="scanner"
|
|
81
72
|
id="capturer"
|
|
82
73
|
label="Capture Images"
|
|
@@ -85,10 +76,10 @@ export class OcrHelper extends LitElement {
|
|
|
85
76
|
?hidden=${false}
|
|
86
77
|
custom-input
|
|
87
78
|
@files-change=${(e: Event) => this.fileschange(e)}
|
|
88
|
-
></camera-capturer>
|
|
79
|
+
></ox-camera-capturer>
|
|
89
80
|
</div>
|
|
90
81
|
<div buttons>
|
|
91
|
-
<mwc-button @click=${(e: Event) => this.
|
|
82
|
+
<mwc-button @click=${(e: Event) => this.submit()}>submit</mwc-button>
|
|
92
83
|
<mwc-button @click=${(e: Event) => this.reset()}>reset</mwc-button>
|
|
93
84
|
</div>
|
|
94
85
|
<div id="images">
|
|
@@ -104,8 +95,9 @@ export class OcrHelper extends LitElement {
|
|
|
104
95
|
>
|
|
105
96
|
${files.map((file: any, idx: number) => html`<div i ?active=${idx === index}>${idx}</div>`)}
|
|
106
97
|
</div>
|
|
107
|
-
<
|
|
98
|
+
<ox-ocr-result-image .file=${file} @selected=${(e: CustomEvent) => this.onSelected(e)}></ox-ocr-result-image>
|
|
108
99
|
</div>
|
|
100
|
+
|
|
109
101
|
<div id="result"></div>
|
|
110
102
|
`
|
|
111
103
|
}
|
|
@@ -119,7 +111,16 @@ export class OcrHelper extends LitElement {
|
|
|
119
111
|
this.result.textContent = ''
|
|
120
112
|
}
|
|
121
113
|
|
|
122
|
-
|
|
114
|
+
onSelected(e: CustomEvent) {
|
|
115
|
+
navigator.clipboard.writeText(e.detail)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async submit() {
|
|
119
|
+
this.dispatchEvent(
|
|
120
|
+
new CustomEvent('attached', {
|
|
121
|
+
detail: this.fileUploader?.files
|
|
122
|
+
})
|
|
123
|
+
)
|
|
123
124
|
// const response = await client.query({
|
|
124
125
|
// query: gql`
|
|
125
126
|
// query ocrRequest($images: [Upload!]!) {
|