@exmg/exm-upload 1.2.1 → 1.2.3
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/.rollup.cache/root/repo/packages/exm-upload/dist/exm-upload-base.d.ts +5 -0
- package/.rollup.cache/root/repo/packages/exm-upload/dist/exm-upload-base.js +16 -0
- package/.rollup.cache/root/repo/packages/exm-upload/dist/exm-upload-file-item-base.d.ts +11 -0
- package/.rollup.cache/root/repo/packages/exm-upload/dist/exm-upload-file-item-base.js +47 -0
- package/.rollup.cache/root/repo/packages/exm-upload/dist/exm-upload-file-item.d.ts +9 -0
- package/.rollup.cache/root/repo/packages/exm-upload/dist/exm-upload-file-item.js +12 -0
- package/.rollup.cache/root/repo/packages/exm-upload/dist/utils.d.ts +2 -0
- package/.rollup.cache/root/repo/packages/exm-upload/dist/utils.js +14 -0
- package/dist/exm-upload-base.d.ts +5 -0
- package/dist/exm-upload-base.js +16 -0
- package/dist/exm-upload-file-item-base.d.ts +11 -0
- package/dist/exm-upload-file-item-base.js +50 -0
- package/dist/exm-upload-file-item.d.ts +9 -0
- package/dist/exm-upload-file-item.js +14 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +15 -1
- package/package.json +5 -5
|
@@ -2,6 +2,7 @@ import '@material/web/icon/icon.js';
|
|
|
2
2
|
import { ExmUploadCrop } from './exm-upload-crop.js';
|
|
3
3
|
import { FileData } from './types.js';
|
|
4
4
|
import './exm-upload-item.js';
|
|
5
|
+
import './exm-upload-file-item.js';
|
|
5
6
|
import './exm-upload-crop.js';
|
|
6
7
|
import './exm-upload-drop-area.js';
|
|
7
8
|
import { ExmgElement } from '@exmg/lit-base';
|
|
@@ -52,6 +53,10 @@ export declare class ExmUploadBase extends ExmgElement {
|
|
|
52
53
|
* The upload response type
|
|
53
54
|
*/
|
|
54
55
|
serverType: 'xhr' | 'local' | 'form-data' | 'custom';
|
|
56
|
+
/**
|
|
57
|
+
* The upload response type
|
|
58
|
+
*/
|
|
59
|
+
noUpload: boolean;
|
|
55
60
|
/**
|
|
56
61
|
* The CropperJS config see: https://github.com/fengyuanchen/cropperjs#options
|
|
57
62
|
*/
|
|
@@ -7,6 +7,7 @@ import '@material/web/icon/icon.js';
|
|
|
7
7
|
import { FileUploadError } from './types.js';
|
|
8
8
|
// File upload imports
|
|
9
9
|
import './exm-upload-item.js';
|
|
10
|
+
import './exm-upload-file-item.js';
|
|
10
11
|
import './exm-upload-crop.js';
|
|
11
12
|
import './exm-upload-drop-area.js';
|
|
12
13
|
import { isCorrectResolution, isImage, isSizeValid, isTypeValidExtension } from './utils.js';
|
|
@@ -43,6 +44,10 @@ export class ExmUploadBase extends ExmgElement {
|
|
|
43
44
|
* The upload response type
|
|
44
45
|
*/
|
|
45
46
|
this.serverType = 'xhr';
|
|
47
|
+
/**
|
|
48
|
+
* The upload response type
|
|
49
|
+
*/
|
|
50
|
+
this.noUpload = false;
|
|
46
51
|
/**
|
|
47
52
|
* The CropperJS config see: https://github.com/fengyuanchen/cropperjs#options
|
|
48
53
|
*/
|
|
@@ -231,6 +236,14 @@ export class ExmUploadBase extends ExmgElement {
|
|
|
231
236
|
* Renders the file items
|
|
232
237
|
*/
|
|
233
238
|
renderFileItems() {
|
|
239
|
+
if (this.noUpload) {
|
|
240
|
+
return repeat(this.files || [], (file) => file.id, (item) => html `<exm-upload-file-item
|
|
241
|
+
class="item"
|
|
242
|
+
id=${item.id}
|
|
243
|
+
@remove-item=${this._handleRemove}
|
|
244
|
+
.item=${item}
|
|
245
|
+
></exm-upload-file-item>`);
|
|
246
|
+
}
|
|
234
247
|
return repeat(this.files || [], (file) => file.id, (item) => html `<exm-upload-item
|
|
235
248
|
class="item"
|
|
236
249
|
id=${item.id}
|
|
@@ -337,6 +350,9 @@ __decorate([
|
|
|
337
350
|
__decorate([
|
|
338
351
|
property({ type: String })
|
|
339
352
|
], ExmUploadBase.prototype, "serverType", void 0);
|
|
353
|
+
__decorate([
|
|
354
|
+
property({ type: Boolean })
|
|
355
|
+
], ExmUploadBase.prototype, "noUpload", void 0);
|
|
340
356
|
__decorate([
|
|
341
357
|
property({ type: Object }),
|
|
342
358
|
observer(function (value) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js';
|
|
2
|
+
import '@material/web/iconbutton/icon-button.js';
|
|
3
|
+
import '@material/web/progress/linear-progress.js';
|
|
4
|
+
import { FileData } from './types.js';
|
|
5
|
+
import { ExmgElement } from '@exmg/lit-base';
|
|
6
|
+
export declare class ExmUploadFileItemBase extends ExmgElement {
|
|
7
|
+
item?: FileData;
|
|
8
|
+
private _handleRemoveClick;
|
|
9
|
+
private renderActions;
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
|
+
import '@material/web/icon/icon.js';
|
|
5
|
+
import '@material/web/iconbutton/icon-button.js';
|
|
6
|
+
import '@material/web/progress/linear-progress.js';
|
|
7
|
+
import { formatBytes, getFileExtension, getFileName } from './utils.js';
|
|
8
|
+
import { ExmgElement } from '@exmg/lit-base';
|
|
9
|
+
export class ExmUploadFileItemBase extends ExmgElement {
|
|
10
|
+
_handleRemoveClick() {
|
|
11
|
+
var _a;
|
|
12
|
+
this.fire('remove-item', (_a = this.item) === null || _a === void 0 ? void 0 : _a.id, true);
|
|
13
|
+
}
|
|
14
|
+
renderActions() {
|
|
15
|
+
return html ` <md-icon-button @click=${this._handleRemoveClick}>
|
|
16
|
+
<md-icon>delete</md-icon>
|
|
17
|
+
</md-icon-button>`;
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21
|
+
const fileName = getFileName((_a = this.item) === null || _a === void 0 ? void 0 : _a.file);
|
|
22
|
+
const fileType = getFileExtension((_b = this.item) === null || _b === void 0 ? void 0 : _b.file);
|
|
23
|
+
return html `
|
|
24
|
+
<div class="item">
|
|
25
|
+
<div class="status vertical-center">
|
|
26
|
+
<md-icon class="success-icon">check</md-icon>
|
|
27
|
+
</div>
|
|
28
|
+
<div class="name-container">
|
|
29
|
+
<span class="file-name">${fileName}</span>
|
|
30
|
+
${((_c = this.item) === null || _c === void 0 ? void 0 : _c.error)
|
|
31
|
+
? html ` <span class="file-error">${(_d = this.item) === null || _d === void 0 ? void 0 : _d.error}</span> `
|
|
32
|
+
: html ` <div class="file-details vertical-center">
|
|
33
|
+
<div class="vertical-center">
|
|
34
|
+
<span class="file-size badge">${fileType.toUpperCase()}</span>
|
|
35
|
+
<span class="file-type badge">${formatBytes((_f = (_e = this.item) === null || _e === void 0 ? void 0 : _e.file) === null || _f === void 0 ? void 0 : _f.size)}</span>
|
|
36
|
+
</div>
|
|
37
|
+
</div>`}
|
|
38
|
+
</div>
|
|
39
|
+
<div class="actions vertical-center">${this.renderActions()}</div>
|
|
40
|
+
</div>
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
__decorate([
|
|
45
|
+
property({ type: Object })
|
|
46
|
+
], ExmUploadFileItemBase.prototype, "item", void 0);
|
|
47
|
+
//# sourceMappingURL=exm-upload-file-item-base.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExmUploadFileItemBase } from './exm-upload-file-item-base.js';
|
|
2
|
+
export declare class ExmUploadFileItem extends ExmUploadFileItemBase {
|
|
3
|
+
static styles: import("lit").CSSResult;
|
|
4
|
+
}
|
|
5
|
+
declare global {
|
|
6
|
+
interface HTMLElementTagNameMap {
|
|
7
|
+
'exm-upload-file-item': ExmUploadFileItem;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
|
3
|
+
import { style } from './styles/exm-upload-item-styles-css.js';
|
|
4
|
+
import { ExmUploadFileItemBase } from './exm-upload-file-item-base.js';
|
|
5
|
+
let ExmUploadFileItem = class ExmUploadFileItem extends ExmUploadFileItemBase {
|
|
6
|
+
};
|
|
7
|
+
ExmUploadFileItem.styles = style;
|
|
8
|
+
ExmUploadFileItem = __decorate([
|
|
9
|
+
customElement('exm-upload-file-item')
|
|
10
|
+
], ExmUploadFileItem);
|
|
11
|
+
export { ExmUploadFileItem };
|
|
12
|
+
//# sourceMappingURL=exm-upload-file-item.js.map
|
|
@@ -31,3 +31,5 @@ export declare const formatBytes: (bytes: number) => string;
|
|
|
31
31
|
*/
|
|
32
32
|
export declare const isImage: (file: File) => boolean | undefined;
|
|
33
33
|
export declare const isCorrectResolution: (image: File, resolution: string) => Promise<unknown>;
|
|
34
|
+
export declare const getFileExtension: (file?: File) => string;
|
|
35
|
+
export declare const getFileName: (file?: File) => string;
|
|
@@ -86,4 +86,18 @@ export const isCorrectResolution = (image, resolution) => {
|
|
|
86
86
|
};
|
|
87
87
|
});
|
|
88
88
|
};
|
|
89
|
+
export const getFileExtension = (file) => {
|
|
90
|
+
if (!file) {
|
|
91
|
+
return '';
|
|
92
|
+
}
|
|
93
|
+
const originalName = file.name;
|
|
94
|
+
return originalName.substring(originalName.lastIndexOf('.') + 1, originalName.length);
|
|
95
|
+
};
|
|
96
|
+
export const getFileName = (file) => {
|
|
97
|
+
if (!file) {
|
|
98
|
+
return '';
|
|
99
|
+
}
|
|
100
|
+
const originalName = file === null || file === void 0 ? void 0 : file.name;
|
|
101
|
+
return originalName.substring(0, originalName.lastIndexOf('.'));
|
|
102
|
+
};
|
|
89
103
|
//# sourceMappingURL=utils.js.map
|
|
@@ -2,6 +2,7 @@ import '@material/web/icon/icon.js';
|
|
|
2
2
|
import { ExmUploadCrop } from './exm-upload-crop.js';
|
|
3
3
|
import { FileData } from './types.js';
|
|
4
4
|
import './exm-upload-item.js';
|
|
5
|
+
import './exm-upload-file-item.js';
|
|
5
6
|
import './exm-upload-crop.js';
|
|
6
7
|
import './exm-upload-drop-area.js';
|
|
7
8
|
import { ExmgElement } from '@exmg/lit-base';
|
|
@@ -52,6 +53,10 @@ export declare class ExmUploadBase extends ExmgElement {
|
|
|
52
53
|
* The upload response type
|
|
53
54
|
*/
|
|
54
55
|
serverType: 'xhr' | 'local' | 'form-data' | 'custom';
|
|
56
|
+
/**
|
|
57
|
+
* The upload response type
|
|
58
|
+
*/
|
|
59
|
+
noUpload: boolean;
|
|
55
60
|
/**
|
|
56
61
|
* The CropperJS config see: https://github.com/fengyuanchen/cropperjs#options
|
|
57
62
|
*/
|
package/dist/exm-upload-base.js
CHANGED
|
@@ -6,6 +6,7 @@ import { repeat } from 'lit/directives/repeat.js';
|
|
|
6
6
|
import '@material/web/icon/icon.js';
|
|
7
7
|
import { FileUploadError } from './types.js';
|
|
8
8
|
import './exm-upload-item.js';
|
|
9
|
+
import './exm-upload-file-item.js';
|
|
9
10
|
import './exm-upload-crop.js';
|
|
10
11
|
import './exm-upload-drop-area.js';
|
|
11
12
|
import { isSizeValid, isTypeValidExtension, isImage, isCorrectResolution } from './utils.js';
|
|
@@ -43,6 +44,10 @@ class ExmUploadBase extends ExmgElement {
|
|
|
43
44
|
* The upload response type
|
|
44
45
|
*/
|
|
45
46
|
this.serverType = 'xhr';
|
|
47
|
+
/**
|
|
48
|
+
* The upload response type
|
|
49
|
+
*/
|
|
50
|
+
this.noUpload = false;
|
|
46
51
|
/**
|
|
47
52
|
* The CropperJS config see: https://github.com/fengyuanchen/cropperjs#options
|
|
48
53
|
*/
|
|
@@ -231,6 +236,14 @@ class ExmUploadBase extends ExmgElement {
|
|
|
231
236
|
* Renders the file items
|
|
232
237
|
*/
|
|
233
238
|
renderFileItems() {
|
|
239
|
+
if (this.noUpload) {
|
|
240
|
+
return repeat(this.files || [], (file) => file.id, (item) => html `<exm-upload-file-item
|
|
241
|
+
class="item"
|
|
242
|
+
id=${item.id}
|
|
243
|
+
@remove-item=${this._handleRemove}
|
|
244
|
+
.item=${item}
|
|
245
|
+
></exm-upload-file-item>`);
|
|
246
|
+
}
|
|
234
247
|
return repeat(this.files || [], (file) => file.id, (item) => html `<exm-upload-item
|
|
235
248
|
class="item"
|
|
236
249
|
id=${item.id}
|
|
@@ -337,6 +350,9 @@ __decorate([
|
|
|
337
350
|
__decorate([
|
|
338
351
|
property({ type: String })
|
|
339
352
|
], ExmUploadBase.prototype, "serverType", void 0);
|
|
353
|
+
__decorate([
|
|
354
|
+
property({ type: Boolean })
|
|
355
|
+
], ExmUploadBase.prototype, "noUpload", void 0);
|
|
340
356
|
__decorate([
|
|
341
357
|
property({ type: Object }),
|
|
342
358
|
observer(function (value) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '@material/web/icon/icon.js';
|
|
2
|
+
import '@material/web/iconbutton/icon-button.js';
|
|
3
|
+
import '@material/web/progress/linear-progress.js';
|
|
4
|
+
import { FileData } from './types.js';
|
|
5
|
+
import { ExmgElement } from '@exmg/lit-base';
|
|
6
|
+
export declare class ExmUploadFileItemBase extends ExmgElement {
|
|
7
|
+
item?: FileData;
|
|
8
|
+
private _handleRemoveClick;
|
|
9
|
+
private renderActions;
|
|
10
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { __decorate } from 'tslib';
|
|
2
|
+
import { html } from 'lit';
|
|
3
|
+
import { property } from 'lit/decorators.js';
|
|
4
|
+
import '@material/web/icon/icon.js';
|
|
5
|
+
import '@material/web/iconbutton/icon-button.js';
|
|
6
|
+
import '@material/web/progress/linear-progress.js';
|
|
7
|
+
import { getFileName, getFileExtension, formatBytes } from './utils.js';
|
|
8
|
+
import { ExmgElement } from '@exmg/lit-base';
|
|
9
|
+
|
|
10
|
+
class ExmUploadFileItemBase extends ExmgElement {
|
|
11
|
+
_handleRemoveClick() {
|
|
12
|
+
var _a;
|
|
13
|
+
this.fire('remove-item', (_a = this.item) === null || _a === void 0 ? void 0 : _a.id, true);
|
|
14
|
+
}
|
|
15
|
+
renderActions() {
|
|
16
|
+
return html ` <md-icon-button @click=${this._handleRemoveClick}>
|
|
17
|
+
<md-icon>delete</md-icon>
|
|
18
|
+
</md-icon-button>`;
|
|
19
|
+
}
|
|
20
|
+
render() {
|
|
21
|
+
var _a, _b, _c, _d, _e, _f;
|
|
22
|
+
const fileName = getFileName((_a = this.item) === null || _a === void 0 ? void 0 : _a.file);
|
|
23
|
+
const fileType = getFileExtension((_b = this.item) === null || _b === void 0 ? void 0 : _b.file);
|
|
24
|
+
return html `
|
|
25
|
+
<div class="item">
|
|
26
|
+
<div class="status vertical-center">
|
|
27
|
+
<md-icon class="success-icon">check</md-icon>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="name-container">
|
|
30
|
+
<span class="file-name">${fileName}</span>
|
|
31
|
+
${((_c = this.item) === null || _c === void 0 ? void 0 : _c.error)
|
|
32
|
+
? html ` <span class="file-error">${(_d = this.item) === null || _d === void 0 ? void 0 : _d.error}</span> `
|
|
33
|
+
: html ` <div class="file-details vertical-center">
|
|
34
|
+
<div class="vertical-center">
|
|
35
|
+
<span class="file-size badge">${fileType.toUpperCase()}</span>
|
|
36
|
+
<span class="file-type badge">${formatBytes((_f = (_e = this.item) === null || _e === void 0 ? void 0 : _e.file) === null || _f === void 0 ? void 0 : _f.size)}</span>
|
|
37
|
+
</div>
|
|
38
|
+
</div>`}
|
|
39
|
+
</div>
|
|
40
|
+
<div class="actions vertical-center">${this.renderActions()}</div>
|
|
41
|
+
</div>
|
|
42
|
+
`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
__decorate([
|
|
46
|
+
property({ type: Object })
|
|
47
|
+
], ExmUploadFileItemBase.prototype, "item", void 0);
|
|
48
|
+
|
|
49
|
+
export { ExmUploadFileItemBase };
|
|
50
|
+
//# sourceMappingURL=exm-upload-file-item-base.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ExmUploadFileItemBase } from './exm-upload-file-item-base.js';
|
|
2
|
+
export declare class ExmUploadFileItem extends ExmUploadFileItemBase {
|
|
3
|
+
static styles: import("lit").CSSResult;
|
|
4
|
+
}
|
|
5
|
+
declare global {
|
|
6
|
+
interface HTMLElementTagNameMap {
|
|
7
|
+
'exm-upload-file-item': ExmUploadFileItem;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { __decorate } from 'tslib';
|
|
2
|
+
import { customElement } from 'lit/decorators.js';
|
|
3
|
+
import { style } from './styles/exm-upload-item-styles-css.js';
|
|
4
|
+
import { ExmUploadFileItemBase } from './exm-upload-file-item-base.js';
|
|
5
|
+
|
|
6
|
+
let ExmUploadFileItem = class ExmUploadFileItem extends ExmUploadFileItemBase {
|
|
7
|
+
};
|
|
8
|
+
ExmUploadFileItem.styles = style;
|
|
9
|
+
ExmUploadFileItem = __decorate([
|
|
10
|
+
customElement('exm-upload-file-item')
|
|
11
|
+
], ExmUploadFileItem);
|
|
12
|
+
|
|
13
|
+
export { ExmUploadFileItem };
|
|
14
|
+
//# sourceMappingURL=exm-upload-file-item.js.map
|
package/dist/utils.d.ts
CHANGED
|
@@ -31,3 +31,5 @@ export declare const formatBytes: (bytes: number) => string;
|
|
|
31
31
|
*/
|
|
32
32
|
export declare const isImage: (file: File) => boolean | undefined;
|
|
33
33
|
export declare const isCorrectResolution: (image: File, resolution: string) => Promise<unknown>;
|
|
34
|
+
export declare const getFileExtension: (file?: File) => string;
|
|
35
|
+
export declare const getFileName: (file?: File) => string;
|
package/dist/utils.js
CHANGED
|
@@ -82,6 +82,20 @@ const isCorrectResolution = (image, resolution) => {
|
|
|
82
82
|
};
|
|
83
83
|
});
|
|
84
84
|
};
|
|
85
|
+
const getFileExtension = (file) => {
|
|
86
|
+
if (!file) {
|
|
87
|
+
return '';
|
|
88
|
+
}
|
|
89
|
+
const originalName = file.name;
|
|
90
|
+
return originalName.substring(originalName.lastIndexOf('.') + 1, originalName.length);
|
|
91
|
+
};
|
|
92
|
+
const getFileName = (file) => {
|
|
93
|
+
if (!file) {
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
const originalName = file === null || file === void 0 ? void 0 : file.name;
|
|
97
|
+
return originalName.substring(0, originalName.lastIndexOf('.'));
|
|
98
|
+
};
|
|
85
99
|
|
|
86
|
-
export { formatBytes, isCorrectResolution, isImage, isSizeValid, isTypeValidExtension };
|
|
100
|
+
export { formatBytes, getFileExtension, getFileName, isCorrectResolution, isImage, isSizeValid, isTypeValidExtension };
|
|
87
101
|
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exmg/exm-upload",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@exmg/exm-button": "^1.2.
|
|
6
|
-
"@exmg/exm-collapsed": "^1.2.
|
|
7
|
-
"@exmg/exm-dialogs": "^1.2.
|
|
5
|
+
"@exmg/exm-button": "^1.2.3",
|
|
6
|
+
"@exmg/exm-collapsed": "^1.2.3",
|
|
7
|
+
"@exmg/exm-dialogs": "^1.2.3",
|
|
8
8
|
"cropperjs": "^1.5.13"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "88d4a421d86cfdb2493aa3a54098e92a38e46b51"
|
|
51
51
|
}
|