@operato/ocr 0.2.19 → 0.2.20
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 +10 -0
- package/demo/index.html +666 -2
- package/dist/src/ox-ocr-helper.d.ts +4 -2
- package/dist/src/ox-ocr-helper.js +22 -27
- package/dist/src/ox-ocr-helper.js.map +1 -1
- package/dist/src/ox-ocr-result-image.d.ts +2 -12
- package/dist/src/ox-ocr-result-image.js +31 -673
- package/dist/src/ox-ocr-result-image.js.map +1 -1
- package/dist/src/type.d.ts +15 -0
- package/dist/src/type.js +6 -0
- package/dist/src/type.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/ox-ocr-helper.ts +18 -25
- package/src/ox-ocr-result-image.ts +35 -686
- package/src/type.ts +13 -0
- package/dist/src/camera-capturer.d.ts +0 -14
- package/dist/src/camera-capturer.js +0 -170
- package/dist/src/camera-capturer.js.map +0 -1
- package/dist/src/file-drop-helper.d.ts +0 -16
- package/dist/src/file-drop-helper.js +0 -47
- package/dist/src/file-drop-helper.js.map +0 -1
- package/dist/src/utils/touch-mouse-event.d.ts +0 -0
- package/dist/src/utils/touch-mouse-event.js +0 -2
- package/dist/src/utils/touch-mouse-event.js.map +0 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Webcomponent ocr following open-wc recommendations",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "heartyoh@hatiolab.com",
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.20",
|
|
7
7
|
"main": "dist/src/index.js",
|
|
8
8
|
"module": "dist/src/index.js",
|
|
9
9
|
"publishConfig": {
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"prettier --write"
|
|
69
69
|
]
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "7142b87dbb0923c5f0efb95fedf3363a336092d8"
|
|
72
72
|
}
|
package/src/ox-ocr-helper.ts
CHANGED
|
@@ -3,7 +3,9 @@ import './ox-camera-capturer'
|
|
|
3
3
|
import './ox-ocr-result-image'
|
|
4
4
|
|
|
5
5
|
import { css, html, LitElement } from 'lit'
|
|
6
|
-
import { customElement, property, query } from 'lit/decorators.js'
|
|
6
|
+
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
7
|
+
|
|
8
|
+
import { NOTHING_RESULT, ScanResult } from './type'
|
|
7
9
|
|
|
8
10
|
@customElement('ox-ocr-helper')
|
|
9
11
|
export class OcrHelper extends LitElement {
|
|
@@ -54,16 +56,19 @@ export class OcrHelper extends LitElement {
|
|
|
54
56
|
`
|
|
55
57
|
]
|
|
56
58
|
|
|
57
|
-
@property({ type: Array })
|
|
58
|
-
|
|
59
|
+
@property({ type: Array }) result: ScanResult[] = []
|
|
60
|
+
|
|
61
|
+
@state() _files: any
|
|
62
|
+
@state() _index: number = 0
|
|
59
63
|
|
|
60
64
|
@query('#capturer') fileUploader!: any
|
|
61
|
-
@query('#
|
|
65
|
+
@query('#copied') copied!: HTMLElement
|
|
62
66
|
|
|
63
67
|
render() {
|
|
64
68
|
const files = this._files || []
|
|
65
|
-
const index = this.
|
|
69
|
+
const index = this._index || 0
|
|
66
70
|
const file = files[index]
|
|
71
|
+
const result = this.result?.[index] || NOTHING_RESULT
|
|
67
72
|
|
|
68
73
|
return html`
|
|
69
74
|
<div attachment-wrap>
|
|
@@ -89,16 +94,20 @@ export class OcrHelper extends LitElement {
|
|
|
89
94
|
const item = (e.target as HTMLElement)?.closest('[i]')
|
|
90
95
|
const children = (e.currentTarget as HTMLElement)?.querySelectorAll('[i]')
|
|
91
96
|
if (item) {
|
|
92
|
-
this.
|
|
97
|
+
this._index = Array.from(children).indexOf(item)
|
|
93
98
|
}
|
|
94
99
|
}}
|
|
95
100
|
>
|
|
96
101
|
${files.map((file: any, idx: number) => html`<div i ?active=${idx === index}>${idx}</div>`)}
|
|
97
102
|
</div>
|
|
98
|
-
<ox-ocr-result-image
|
|
103
|
+
<ox-ocr-result-image
|
|
104
|
+
.file=${file}
|
|
105
|
+
@selected=${(e: CustomEvent) => this.onSelected(e)}
|
|
106
|
+
.result=${result}
|
|
107
|
+
></ox-ocr-result-image>
|
|
99
108
|
</div>
|
|
100
109
|
|
|
101
|
-
<div id="
|
|
110
|
+
<div id="copied"></div>
|
|
102
111
|
`
|
|
103
112
|
}
|
|
104
113
|
|
|
@@ -108,7 +117,7 @@ export class OcrHelper extends LitElement {
|
|
|
108
117
|
|
|
109
118
|
reset() {
|
|
110
119
|
this.fileUploader.reset()
|
|
111
|
-
this.
|
|
120
|
+
this.copied.textContent = ''
|
|
112
121
|
}
|
|
113
122
|
|
|
114
123
|
onSelected(e: CustomEvent) {
|
|
@@ -121,21 +130,5 @@ export class OcrHelper extends LitElement {
|
|
|
121
130
|
detail: this.fileUploader?.files
|
|
122
131
|
})
|
|
123
132
|
)
|
|
124
|
-
// const response = await client.query({
|
|
125
|
-
// query: gql`
|
|
126
|
-
// query ocrRequest($images: [Upload!]!) {
|
|
127
|
-
// ocrRequest(images: $images)
|
|
128
|
-
// }
|
|
129
|
-
// `,
|
|
130
|
-
// variables: {
|
|
131
|
-
// images: this.fileUploader?.files
|
|
132
|
-
// },
|
|
133
|
-
// context: { hasUpload: true }
|
|
134
|
-
// })
|
|
135
|
-
// if (!response.errors) {
|
|
136
|
-
// this.result.textContent = response.data.ocrRequest
|
|
137
|
-
// } else {
|
|
138
|
-
// this.result.textContent = 'error'
|
|
139
|
-
// }
|
|
140
133
|
}
|
|
141
134
|
}
|