@operato/ocr 0.2.52 → 0.3.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.
- package/CHANGELOG.md +22 -0
- package/dist/src/ox-ocr-helper.d.ts +2 -2
- package/dist/src/ox-ocr-helper.js +9 -11
- package/dist/src/ox-ocr-helper.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -4
- package/src/ox-ocr-helper.ts +10 -12
- package/tsconfig.json +1 -0
- package/dist/src/ox-camera-capturer.d.ts +0 -16
- package/dist/src/ox-camera-capturer.js +0 -191
- package/dist/src/ox-camera-capturer.js.map +0 -1
- package/dist/src/utils/file-drop-helper.d.ts +0 -16
- package/dist/src/utils/file-drop-helper.js +0 -47
- package/dist/src/utils/file-drop-helper.js.map +0 -1
- package/src/ox-camera-capturer.ts +0 -196
- package/src/utils/file-drop-helper.ts +0 -62
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
hideFileList: boolean;
|
|
9
|
-
attachFileList: boolean;
|
|
10
|
-
_files?: File[];
|
|
11
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
12
|
-
firstUpdated(): void;
|
|
13
|
-
fileInput: HTMLInputElement;
|
|
14
|
-
get files(): File[] | undefined;
|
|
15
|
-
reset(): void;
|
|
16
|
-
}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import '@material/mwc-icon';
|
|
3
|
-
import { css, html, LitElement } from 'lit';
|
|
4
|
-
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
5
|
-
import { FileDropHelper } from './utils/file-drop-helper';
|
|
6
|
-
let CameraCapturer = class CameraCapturer extends LitElement {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.hideFileList = false;
|
|
10
|
-
this.attachFileList = false;
|
|
11
|
-
}
|
|
12
|
-
render() {
|
|
13
|
-
var files = this._files || [];
|
|
14
|
-
return html `
|
|
15
|
-
<mwc-icon>camera</mwc-icon>
|
|
16
|
-
<span>Capture image or drop files here!</span>
|
|
17
|
-
<input
|
|
18
|
-
id="input-file"
|
|
19
|
-
type="file"
|
|
20
|
-
accept=${this.accept}
|
|
21
|
-
?multiple=${this.multiple}
|
|
22
|
-
hidden
|
|
23
|
-
capture="environment"
|
|
24
|
-
@change=${(e) => {
|
|
25
|
-
const fileInput = e.currentTarget;
|
|
26
|
-
this._files = this.attachFileList
|
|
27
|
-
? [...files, ...Array.from(fileInput.files)]
|
|
28
|
-
: [...Array.from(fileInput.files)];
|
|
29
|
-
this.dispatchEvent(new CustomEvent('files-change', {
|
|
30
|
-
bubbles: true,
|
|
31
|
-
composed: true,
|
|
32
|
-
detail: {
|
|
33
|
-
files: files
|
|
34
|
-
}
|
|
35
|
-
}));
|
|
36
|
-
// fileInput.value = null
|
|
37
|
-
fileInput.files = null;
|
|
38
|
-
}}
|
|
39
|
-
/>
|
|
40
|
-
<label for="input-file">${this.label || 'capture image'}</label>
|
|
41
|
-
|
|
42
|
-
${!this.hideFileList && (files === null || files === void 0 ? void 0 : files.length)
|
|
43
|
-
? html ` <ul>
|
|
44
|
-
${files.map(file => html `
|
|
45
|
-
<li>
|
|
46
|
-
- ${file.name}
|
|
47
|
-
<mwc-icon
|
|
48
|
-
@click=${(e) => {
|
|
49
|
-
files.splice(files.indexOf(file), 1);
|
|
50
|
-
this._files = [...files];
|
|
51
|
-
this.dispatchEvent(new CustomEvent('files-change', {
|
|
52
|
-
bubbles: true,
|
|
53
|
-
composed: true,
|
|
54
|
-
detail: {
|
|
55
|
-
files: this._files
|
|
56
|
-
}
|
|
57
|
-
}));
|
|
58
|
-
}}
|
|
59
|
-
>delete_outline</mwc-icon
|
|
60
|
-
>
|
|
61
|
-
</li>
|
|
62
|
-
`)}
|
|
63
|
-
</ul>`
|
|
64
|
-
: html ``}
|
|
65
|
-
`;
|
|
66
|
-
}
|
|
67
|
-
firstUpdated() {
|
|
68
|
-
FileDropHelper.set(this);
|
|
69
|
-
this.addEventListener('file-drop', (e) => {
|
|
70
|
-
const detail = e.detail;
|
|
71
|
-
this._files = this.multiple ? detail : detail[0] ? [detail[0]] : [];
|
|
72
|
-
this.dispatchEvent(new CustomEvent('files-change', {
|
|
73
|
-
bubbles: true,
|
|
74
|
-
composed: true,
|
|
75
|
-
detail: {
|
|
76
|
-
files: this._files
|
|
77
|
-
}
|
|
78
|
-
}));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
get files() {
|
|
82
|
-
return this._files;
|
|
83
|
-
}
|
|
84
|
-
reset() {
|
|
85
|
-
this.fileInput.value = '';
|
|
86
|
-
this._files = [];
|
|
87
|
-
this.dispatchEvent(new CustomEvent('files-change', {
|
|
88
|
-
bubbles: true,
|
|
89
|
-
composed: true,
|
|
90
|
-
detail: {
|
|
91
|
-
files: this._files
|
|
92
|
-
}
|
|
93
|
-
}));
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
CameraCapturer.styles = [
|
|
97
|
-
css `
|
|
98
|
-
:host {
|
|
99
|
-
display: flex;
|
|
100
|
-
flex-direction: column;
|
|
101
|
-
border-radius: var(--border-radius);
|
|
102
|
-
align-items: center;
|
|
103
|
-
justify-content: center;
|
|
104
|
-
padding: var(--padding-default, 9px);
|
|
105
|
-
min-height: 100px;
|
|
106
|
-
text-transform: capitalize;
|
|
107
|
-
|
|
108
|
-
border: var(--file-uploader-border);
|
|
109
|
-
background-color: var(--main-section-background-color);
|
|
110
|
-
font: var(--file-uploader-font) !important;
|
|
111
|
-
color: var(--file-uploader-color);
|
|
112
|
-
}
|
|
113
|
-
:host > mwc-icon {
|
|
114
|
-
color: var(--file-uploader-icon-color);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
:host(.candrop) {
|
|
118
|
-
background-color: var(--file-uploader-candrop-background-color);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
#input-file {
|
|
122
|
-
display: none;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
label {
|
|
126
|
-
position: relative;
|
|
127
|
-
width: auto;
|
|
128
|
-
border: none;
|
|
129
|
-
text-transform: capitalize;
|
|
130
|
-
|
|
131
|
-
padding: var(--file-uploader-label-padding);
|
|
132
|
-
border-radius: var(--file-uploader-label-border-radius);
|
|
133
|
-
background-color: var(--file-uploader-label-background-color);
|
|
134
|
-
color: var(--file-uploader-label-color);
|
|
135
|
-
font: var(--file-uploader-label-font) !important;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
ul {
|
|
139
|
-
max-width: 500px;
|
|
140
|
-
list-style: none;
|
|
141
|
-
margin: 5px 0 0 0;
|
|
142
|
-
padding: 0;
|
|
143
|
-
max-height: 46px;
|
|
144
|
-
overflow: auto;
|
|
145
|
-
background-color: rgba(var(--primary-color-rgb), 0.1);
|
|
146
|
-
}
|
|
147
|
-
li {
|
|
148
|
-
text-align: left;
|
|
149
|
-
|
|
150
|
-
padding: 3px 5px 2px 5px;
|
|
151
|
-
border-bottom: var(--file-uploader-li-border-bottom);
|
|
152
|
-
font: normal 14px var(--theme-font);
|
|
153
|
-
}
|
|
154
|
-
li mwc-icon {
|
|
155
|
-
float: right;
|
|
156
|
-
cursor: pointer;
|
|
157
|
-
margin: var(--file-uploader-li-icon-margin);
|
|
158
|
-
font-size: 1em;
|
|
159
|
-
}
|
|
160
|
-
li mwc-icon:hover,
|
|
161
|
-
li mwc-icon:active {
|
|
162
|
-
color: var(--file-uploader-li-icon-focus-color);
|
|
163
|
-
}
|
|
164
|
-
`
|
|
165
|
-
];
|
|
166
|
-
__decorate([
|
|
167
|
-
property({ type: Boolean })
|
|
168
|
-
], CameraCapturer.prototype, "multiple", void 0);
|
|
169
|
-
__decorate([
|
|
170
|
-
property({ type: String })
|
|
171
|
-
], CameraCapturer.prototype, "accept", void 0);
|
|
172
|
-
__decorate([
|
|
173
|
-
property({ type: String })
|
|
174
|
-
], CameraCapturer.prototype, "label", void 0);
|
|
175
|
-
__decorate([
|
|
176
|
-
property({ type: Boolean, reflect: true, attribute: 'hide-filelist' })
|
|
177
|
-
], CameraCapturer.prototype, "hideFileList", void 0);
|
|
178
|
-
__decorate([
|
|
179
|
-
property({ type: Boolean, reflect: true, attribute: 'attach-filelist' })
|
|
180
|
-
], CameraCapturer.prototype, "attachFileList", void 0);
|
|
181
|
-
__decorate([
|
|
182
|
-
state()
|
|
183
|
-
], CameraCapturer.prototype, "_files", void 0);
|
|
184
|
-
__decorate([
|
|
185
|
-
query('#input-file')
|
|
186
|
-
], CameraCapturer.prototype, "fileInput", void 0);
|
|
187
|
-
CameraCapturer = __decorate([
|
|
188
|
-
customElement('ox-camera-capturer')
|
|
189
|
-
], CameraCapturer);
|
|
190
|
-
export { CameraCapturer };
|
|
191
|
-
//# sourceMappingURL=ox-camera-capturer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAEzE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAGzD,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,UAAU;IAA9C;;QA4EE,iBAAY,GAAY,KAAK,CAAA;QAE7B,mBAAc,GAAY,KAAK,CAAA;IA6GjC,CAAC;IAzGC,MAAM;QACJ,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,IAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAmEF;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;AAE1C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;oDAC1C;AAE7B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;sDAC1C;AAEtB;IAAR,KAAK,EAAE;8CAAgB;AAuFF;IAArB,KAAK,CAAC,aAAa,CAAC;iDAA6B;AAvKvC,cAAc;IAD1B,aAAa,CAAC,oBAAoB,CAAC;GACvB,cAAc,CA2L1B;SA3LY,cAAc","sourcesContent":["import '@material/mwc-icon'\n\nimport { css, html, LitElement } from 'lit'\nimport { customElement, property, query, state } 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: Boolean, reflect: true, attribute: 'hide-filelist' })\n hideFileList: boolean = false\n @property({ type: Boolean, reflect: true, attribute: 'attach-filelist' })\n attachFileList: boolean = false\n\n @state() _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 = this.attachFileList\n ? [...files, ...Array.from(fileInput.files as FileList)]\n : [...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 ${!this.hideFileList && 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 : html``}\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,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* judge callback function for FileDropHelper.set
|
|
3
|
-
*/
|
|
4
|
-
declare type JudgeCallback = () => boolean;
|
|
5
|
-
/**
|
|
6
|
-
* file drop assist class
|
|
7
|
-
*/
|
|
8
|
-
export declare class FileDropHelper {
|
|
9
|
-
/**
|
|
10
|
-
* 파일 드롭 영역에서의 file drag&drop과 관련된 이벤트에 대한 처리를 설정한다.
|
|
11
|
-
* @param dropArea file drag&drop target area
|
|
12
|
-
* @param [judge] file drag&drop과 관련된 이벤트에 대한 judge callback function
|
|
13
|
-
*/
|
|
14
|
-
static set(dropArea: HTMLElement, judge?: JudgeCallback): void;
|
|
15
|
-
}
|
|
16
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* file drop assist class
|
|
3
|
-
*/
|
|
4
|
-
export class FileDropHelper {
|
|
5
|
-
/**
|
|
6
|
-
* 파일 드롭 영역에서의 file drag&drop과 관련된 이벤트에 대한 처리를 설정한다.
|
|
7
|
-
* @param dropArea file drag&drop target area
|
|
8
|
-
* @param [judge] file drag&drop과 관련된 이벤트에 대한 judge callback function
|
|
9
|
-
*/
|
|
10
|
-
static set(dropArea, judge) {
|
|
11
|
-
var preventDefaults = (e) => {
|
|
12
|
-
if (!judge || judge()) {
|
|
13
|
-
e.preventDefault();
|
|
14
|
-
e.stopPropagation();
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var highlight = (e) => {
|
|
18
|
-
if (!judge || judge()) {
|
|
19
|
-
dropArea.classList.add('candrop');
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
var unhighlight = (e) => {
|
|
23
|
-
if (!judge || judge()) {
|
|
24
|
-
dropArea.classList.remove('candrop');
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(event => {
|
|
28
|
-
dropArea.addEventListener(event, preventDefaults, false);
|
|
29
|
-
});
|
|
30
|
-
['dragenter', 'dragover'].forEach(event => {
|
|
31
|
-
dropArea.addEventListener(event, highlight, false);
|
|
32
|
-
});
|
|
33
|
-
['dragleave', 'drop'].forEach(event => {
|
|
34
|
-
dropArea.addEventListener(event, unhighlight, false);
|
|
35
|
-
});
|
|
36
|
-
dropArea.addEventListener('drop', e => {
|
|
37
|
-
if (!judge || judge()) {
|
|
38
|
-
let dt = e.dataTransfer;
|
|
39
|
-
let files = dt.files;
|
|
40
|
-
dropArea.dispatchEvent(new CustomEvent('file-drop', {
|
|
41
|
-
detail: [...Array.from(files)]
|
|
42
|
-
}));
|
|
43
|
-
}
|
|
44
|
-
}, false);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=file-drop-helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-drop-helper.js","sourceRoot":"","sources":["../../../src/utils/file-drop-helper.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB;;;;OAIG;IACH,MAAM,CAAC,GAAG,CAAC,QAAqB,EAAE,KAAqB;QACrD,IAAI,eAAe,GAAG,CAAC,CAA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,IAAI,KAAK,GAAG,EAAE,CAAC,KAAK,CAAA;gBAEpB,QAAQ,CAAC,aAAa,CACpB,IAAI,WAAW,CAAC,WAAW,EAAE;oBAC3B,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC/B,CAAC,CACH,CAAA;aACF;QACH,CAAC,EACD,KAAK,CACN,CAAA;IACH,CAAC;CACF","sourcesContent":["/**\n * judge callback function for FileDropHelper.set\n */\ntype JudgeCallback = () => boolean\n\n/**\n * file drop assist class\n */\nexport class FileDropHelper {\n /**\n * 파일 드롭 영역에서의 file drag&drop과 관련된 이벤트에 대한 처리를 설정한다.\n * @param dropArea file drag&drop target area\n * @param [judge] file drag&drop과 관련된 이벤트에 대한 judge callback function\n */\n static set(dropArea: HTMLElement, judge?: JudgeCallback) {\n var preventDefaults = (e: Event) => {\n if (!judge || judge()) {\n e.preventDefault()\n e.stopPropagation()\n }\n }\n\n var highlight = (e: Event) => {\n if (!judge || judge()) {\n dropArea.classList.add('candrop')\n }\n }\n\n var unhighlight = (e: Event) => {\n if (!judge || judge()) {\n dropArea.classList.remove('candrop')\n }\n }\n\n ;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(event => {\n dropArea.addEventListener(event, preventDefaults, false)\n })\n ;['dragenter', 'dragover'].forEach(event => {\n dropArea.addEventListener(event, highlight, false)\n })\n ;['dragleave', 'drop'].forEach(event => {\n dropArea.addEventListener(event, unhighlight, false)\n })\n\n dropArea.addEventListener(\n 'drop',\n e => {\n if (!judge || judge()) {\n let dt = e.dataTransfer!\n let files = dt.files\n\n dropArea.dispatchEvent(\n new CustomEvent('file-drop', {\n detail: [...Array.from(files)]\n })\n )\n }\n },\n false\n )\n }\n}\n"]}
|
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import '@material/mwc-icon'
|
|
2
|
-
|
|
3
|
-
import { css, html, LitElement } from 'lit'
|
|
4
|
-
import { customElement, property, query, state } from 'lit/decorators.js'
|
|
5
|
-
|
|
6
|
-
import { FileDropHelper } from './utils/file-drop-helper'
|
|
7
|
-
|
|
8
|
-
@customElement('ox-camera-capturer')
|
|
9
|
-
export class CameraCapturer extends LitElement {
|
|
10
|
-
static styles = [
|
|
11
|
-
css`
|
|
12
|
-
:host {
|
|
13
|
-
display: flex;
|
|
14
|
-
flex-direction: column;
|
|
15
|
-
border-radius: var(--border-radius);
|
|
16
|
-
align-items: center;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
padding: var(--padding-default, 9px);
|
|
19
|
-
min-height: 100px;
|
|
20
|
-
text-transform: capitalize;
|
|
21
|
-
|
|
22
|
-
border: var(--file-uploader-border);
|
|
23
|
-
background-color: var(--main-section-background-color);
|
|
24
|
-
font: var(--file-uploader-font) !important;
|
|
25
|
-
color: var(--file-uploader-color);
|
|
26
|
-
}
|
|
27
|
-
:host > mwc-icon {
|
|
28
|
-
color: var(--file-uploader-icon-color);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
:host(.candrop) {
|
|
32
|
-
background-color: var(--file-uploader-candrop-background-color);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
#input-file {
|
|
36
|
-
display: none;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
label {
|
|
40
|
-
position: relative;
|
|
41
|
-
width: auto;
|
|
42
|
-
border: none;
|
|
43
|
-
text-transform: capitalize;
|
|
44
|
-
|
|
45
|
-
padding: var(--file-uploader-label-padding);
|
|
46
|
-
border-radius: var(--file-uploader-label-border-radius);
|
|
47
|
-
background-color: var(--file-uploader-label-background-color);
|
|
48
|
-
color: var(--file-uploader-label-color);
|
|
49
|
-
font: var(--file-uploader-label-font) !important;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
ul {
|
|
53
|
-
max-width: 500px;
|
|
54
|
-
list-style: none;
|
|
55
|
-
margin: 5px 0 0 0;
|
|
56
|
-
padding: 0;
|
|
57
|
-
max-height: 46px;
|
|
58
|
-
overflow: auto;
|
|
59
|
-
background-color: rgba(var(--primary-color-rgb), 0.1);
|
|
60
|
-
}
|
|
61
|
-
li {
|
|
62
|
-
text-align: left;
|
|
63
|
-
|
|
64
|
-
padding: 3px 5px 2px 5px;
|
|
65
|
-
border-bottom: var(--file-uploader-li-border-bottom);
|
|
66
|
-
font: normal 14px var(--theme-font);
|
|
67
|
-
}
|
|
68
|
-
li mwc-icon {
|
|
69
|
-
float: right;
|
|
70
|
-
cursor: pointer;
|
|
71
|
-
margin: var(--file-uploader-li-icon-margin);
|
|
72
|
-
font-size: 1em;
|
|
73
|
-
}
|
|
74
|
-
li mwc-icon:hover,
|
|
75
|
-
li mwc-icon:active {
|
|
76
|
-
color: var(--file-uploader-li-icon-focus-color);
|
|
77
|
-
}
|
|
78
|
-
`
|
|
79
|
-
]
|
|
80
|
-
|
|
81
|
-
@property({ type: Boolean }) multiple?: boolean
|
|
82
|
-
@property({ type: String }) accept?: string
|
|
83
|
-
@property({ type: String }) label?: string
|
|
84
|
-
@property({ type: Boolean, reflect: true, attribute: 'hide-filelist' })
|
|
85
|
-
hideFileList: boolean = false
|
|
86
|
-
@property({ type: Boolean, reflect: true, attribute: 'attach-filelist' })
|
|
87
|
-
attachFileList: boolean = false
|
|
88
|
-
|
|
89
|
-
@state() _files?: File[]
|
|
90
|
-
|
|
91
|
-
render() {
|
|
92
|
-
var files = this._files || []
|
|
93
|
-
|
|
94
|
-
return html`
|
|
95
|
-
<mwc-icon>camera</mwc-icon>
|
|
96
|
-
<span>Capture image or drop files here!</span>
|
|
97
|
-
<input
|
|
98
|
-
id="input-file"
|
|
99
|
-
type="file"
|
|
100
|
-
accept=${this.accept}
|
|
101
|
-
?multiple=${this.multiple}
|
|
102
|
-
hidden
|
|
103
|
-
capture="environment"
|
|
104
|
-
@change=${(e: Event) => {
|
|
105
|
-
const fileInput = e.currentTarget as HTMLInputElement
|
|
106
|
-
|
|
107
|
-
this._files = this.attachFileList
|
|
108
|
-
? [...files, ...Array.from(fileInput.files as FileList)]
|
|
109
|
-
: [...Array.from(fileInput.files as FileList)]
|
|
110
|
-
|
|
111
|
-
this.dispatchEvent(
|
|
112
|
-
new CustomEvent('files-change', {
|
|
113
|
-
bubbles: true,
|
|
114
|
-
composed: true,
|
|
115
|
-
detail: {
|
|
116
|
-
files: files
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
// fileInput.value = null
|
|
122
|
-
fileInput.files = null
|
|
123
|
-
}}
|
|
124
|
-
/>
|
|
125
|
-
<label for="input-file">${this.label || 'capture image'}</label>
|
|
126
|
-
|
|
127
|
-
${!this.hideFileList && files?.length
|
|
128
|
-
? html` <ul>
|
|
129
|
-
${files.map(
|
|
130
|
-
file => html`
|
|
131
|
-
<li>
|
|
132
|
-
- ${file.name}
|
|
133
|
-
<mwc-icon
|
|
134
|
-
@click=${(e: Event) => {
|
|
135
|
-
files.splice(files.indexOf(file), 1)
|
|
136
|
-
this._files = [...files]
|
|
137
|
-
this.dispatchEvent(
|
|
138
|
-
new CustomEvent('files-change', {
|
|
139
|
-
bubbles: true,
|
|
140
|
-
composed: true,
|
|
141
|
-
detail: {
|
|
142
|
-
files: this._files
|
|
143
|
-
}
|
|
144
|
-
})
|
|
145
|
-
)
|
|
146
|
-
}}
|
|
147
|
-
>delete_outline</mwc-icon
|
|
148
|
-
>
|
|
149
|
-
</li>
|
|
150
|
-
`
|
|
151
|
-
)}
|
|
152
|
-
</ul>`
|
|
153
|
-
: html``}
|
|
154
|
-
`
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
firstUpdated() {
|
|
158
|
-
FileDropHelper.set(this)
|
|
159
|
-
|
|
160
|
-
this.addEventListener('file-drop', (e: Event) => {
|
|
161
|
-
const detail = (e as CustomEvent).detail
|
|
162
|
-
this._files = this.multiple ? detail : detail[0] ? [detail[0]] : []
|
|
163
|
-
|
|
164
|
-
this.dispatchEvent(
|
|
165
|
-
new CustomEvent('files-change', {
|
|
166
|
-
bubbles: true,
|
|
167
|
-
composed: true,
|
|
168
|
-
detail: {
|
|
169
|
-
files: this._files
|
|
170
|
-
}
|
|
171
|
-
})
|
|
172
|
-
)
|
|
173
|
-
})
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
@query('#input-file') fileInput!: HTMLInputElement
|
|
177
|
-
|
|
178
|
-
get files() {
|
|
179
|
-
return this._files
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
reset() {
|
|
183
|
-
this.fileInput.value = ''
|
|
184
|
-
this._files = []
|
|
185
|
-
|
|
186
|
-
this.dispatchEvent(
|
|
187
|
-
new CustomEvent('files-change', {
|
|
188
|
-
bubbles: true,
|
|
189
|
-
composed: true,
|
|
190
|
-
detail: {
|
|
191
|
-
files: this._files
|
|
192
|
-
}
|
|
193
|
-
})
|
|
194
|
-
)
|
|
195
|
-
}
|
|
196
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* judge callback function for FileDropHelper.set
|
|
3
|
-
*/
|
|
4
|
-
type JudgeCallback = () => boolean
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* file drop assist class
|
|
8
|
-
*/
|
|
9
|
-
export class FileDropHelper {
|
|
10
|
-
/**
|
|
11
|
-
* 파일 드롭 영역에서의 file drag&drop과 관련된 이벤트에 대한 처리를 설정한다.
|
|
12
|
-
* @param dropArea file drag&drop target area
|
|
13
|
-
* @param [judge] file drag&drop과 관련된 이벤트에 대한 judge callback function
|
|
14
|
-
*/
|
|
15
|
-
static set(dropArea: HTMLElement, judge?: JudgeCallback) {
|
|
16
|
-
var preventDefaults = (e: Event) => {
|
|
17
|
-
if (!judge || judge()) {
|
|
18
|
-
e.preventDefault()
|
|
19
|
-
e.stopPropagation()
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
var highlight = (e: Event) => {
|
|
24
|
-
if (!judge || judge()) {
|
|
25
|
-
dropArea.classList.add('candrop')
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var unhighlight = (e: Event) => {
|
|
30
|
-
if (!judge || judge()) {
|
|
31
|
-
dropArea.classList.remove('candrop')
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
;['dragenter', 'dragover', 'dragleave', 'drop'].forEach(event => {
|
|
36
|
-
dropArea.addEventListener(event, preventDefaults, false)
|
|
37
|
-
})
|
|
38
|
-
;['dragenter', 'dragover'].forEach(event => {
|
|
39
|
-
dropArea.addEventListener(event, highlight, false)
|
|
40
|
-
})
|
|
41
|
-
;['dragleave', 'drop'].forEach(event => {
|
|
42
|
-
dropArea.addEventListener(event, unhighlight, false)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
dropArea.addEventListener(
|
|
46
|
-
'drop',
|
|
47
|
-
e => {
|
|
48
|
-
if (!judge || judge()) {
|
|
49
|
-
let dt = e.dataTransfer!
|
|
50
|
-
let files = dt.files
|
|
51
|
-
|
|
52
|
-
dropArea.dispatchEvent(
|
|
53
|
-
new CustomEvent('file-drop', {
|
|
54
|
-
detail: [...Array.from(files)]
|
|
55
|
-
})
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
false
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
}
|