cmat 0.0.86 → 0.0.88
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/fesm2022/cmat-components-adapter.mjs +9 -9
- package/fesm2022/cmat-components-adapter.mjs.map +1 -1
- package/fesm2022/cmat-components-breadcrumb.mjs +98 -80
- package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/cmat-components-card.mjs +26 -34
- package/fesm2022/cmat-components-card.mjs.map +1 -1
- package/fesm2022/cmat-components-carousel.mjs +467 -556
- package/fesm2022/cmat-components-carousel.mjs.map +1 -1
- package/fesm2022/cmat-components-cascade.mjs +270 -259
- package/fesm2022/cmat-components-cascade.mjs.map +1 -1
- package/fesm2022/cmat-components-chip-input.mjs +200 -116
- package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
- package/fesm2022/cmat-components-code-editor.mjs +85 -38
- package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-color-picker.mjs +841 -0
- package/fesm2022/cmat-components-color-picker.mjs.map +1 -0
- package/fesm2022/cmat-components-custom-formly.mjs +1395 -838
- package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
- package/fesm2022/cmat-components-data-picker.mjs +996 -0
- package/fesm2022/cmat-components-data-picker.mjs.map +1 -0
- package/fesm2022/cmat-components-date-range.mjs +310 -264
- package/fesm2022/cmat-components-date-range.mjs.map +1 -1
- package/fesm2022/cmat-components-date-time-display.mjs +16 -20
- package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
- package/fesm2022/cmat-components-drawer.mjs +120 -137
- package/fesm2022/cmat-components-drawer.mjs.map +1 -1
- package/fesm2022/cmat-components-empty-state.mjs +17 -24
- package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
- package/fesm2022/cmat-components-file-preview.mjs +18 -24
- package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
- package/fesm2022/cmat-components-filter-toolbar.mjs +30 -39
- package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-form-actions.mjs +12 -12
- package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
- package/fesm2022/cmat-components-fullscreen.mjs +10 -10
- package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
- package/fesm2022/cmat-components-highlight.mjs +48 -41
- package/fesm2022/cmat-components-highlight.mjs.map +1 -1
- package/fesm2022/cmat-components-image-viewer.mjs +104 -107
- package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
- package/fesm2022/cmat-components-inline-loading.mjs +12 -15
- package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
- package/fesm2022/cmat-components-json-editor.mjs +118 -75
- package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-knob-input.mjs +196 -178
- package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
- package/fesm2022/cmat-components-masonry.mjs +26 -41
- package/fesm2022/cmat-components-masonry.mjs.map +1 -1
- package/fesm2022/cmat-components-material-color-picker.mjs +81 -80
- package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-material-datetimepicker.mjs +1212 -1287
- package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
- package/fesm2022/cmat-components-navigation.mjs +467 -450
- package/fesm2022/cmat-components-navigation.mjs.map +1 -1
- package/fesm2022/cmat-components-opt-input.mjs +143 -132
- package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
- package/fesm2022/cmat-components-org-chart.mjs +68 -83
- package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
- package/fesm2022/cmat-components-page-header.mjs +18 -24
- package/fesm2022/cmat-components-page-header.mjs.map +1 -1
- package/fesm2022/cmat-components-pagination.mjs +220 -136
- package/fesm2022/cmat-components-pagination.mjs.map +1 -1
- package/fesm2022/cmat-components-password-strength.mjs +262 -215
- package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
- package/fesm2022/cmat-components-popover.mjs +227 -195
- package/fesm2022/cmat-components-popover.mjs.map +1 -1
- package/fesm2022/cmat-components-progress-bar.mjs +15 -34
- package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
- package/fesm2022/cmat-components-qrcode.mjs +95 -88
- package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
- package/fesm2022/cmat-components-rating.mjs +70 -67
- package/fesm2022/cmat-components-rating.mjs.map +1 -1
- package/fesm2022/cmat-components-rich-text-editor.mjs +23 -26
- package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-select-search.mjs +190 -159
- package/fesm2022/cmat-components-select-search.mjs.map +1 -1
- package/fesm2022/cmat-components-select-table.mjs +276 -213
- package/fesm2022/cmat-components-select-table.mjs.map +1 -1
- package/fesm2022/cmat-components-select-tree.mjs +178 -128
- package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
- package/fesm2022/cmat-components-skeleton.mjs +44 -28
- package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
- package/fesm2022/cmat-components-speed-dial.mjs +107 -163
- package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
- package/fesm2022/cmat-components-status-tag.mjs +29 -36
- package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
- package/fesm2022/cmat-components-table-toolbar.mjs +14 -18
- package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-timeline.mjs +111 -118
- package/fesm2022/cmat-components-timeline.mjs.map +1 -1
- package/fesm2022/cmat-components-toast.mjs +65 -66
- package/fesm2022/cmat-components-toast.mjs.map +1 -1
- package/fesm2022/cmat-components-transfer-picker.mjs +130 -160
- package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-treetable.mjs +32 -39
- package/fesm2022/cmat-components-treetable.mjs.map +1 -1
- package/fesm2022/cmat-components-upload.mjs +186 -176
- package/fesm2022/cmat-components-upload.mjs.map +1 -1
- package/fesm2022/cmat-directives-animate-on-scroll.mjs +25 -28
- package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
- package/fesm2022/cmat-directives-arrow-cursor.mjs +85 -92
- package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
- package/fesm2022/cmat-directives-autofocus.mjs +3 -3
- package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
- package/fesm2022/cmat-directives-data-exporter.mjs +49 -50
- package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
- package/fesm2022/cmat-directives-debounce.mjs +16 -19
- package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
- package/fesm2022/cmat-directives-digit-only.mjs +60 -69
- package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
- package/fesm2022/cmat-directives-equal-validator.mjs +3 -3
- package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +31 -30
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
- package/fesm2022/cmat-lib-mock-api.mjs +6 -6
- package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
- package/fesm2022/cmat-pipes-bytes.mjs +3 -3
- package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
- package/fesm2022/cmat-pipes-date-format.mjs +3 -3
- package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
- package/fesm2022/cmat-pipes-find-by-key.mjs +3 -3
- package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
- package/fesm2022/cmat-pipes-group-by.mjs +3 -3
- package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
- package/fesm2022/cmat-pipes-keys.mjs +3 -3
- package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
- package/fesm2022/cmat-pipes-secure.mjs +7 -13
- package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
- package/fesm2022/cmat-pipes-uppercase.mjs +3 -3
- package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
- package/fesm2022/cmat-services-alert.mjs +26 -27
- package/fesm2022/cmat-services-alert.mjs.map +1 -1
- package/fesm2022/cmat-services-config.mjs +14 -23
- package/fesm2022/cmat-services-config.mjs.map +1 -1
- package/fesm2022/cmat-services-confirmation.mjs +8 -8
- package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
- package/fesm2022/cmat-services-data.mjs +6 -10
- package/fesm2022/cmat-services-data.mjs.map +1 -1
- package/fesm2022/cmat-services-export-as.mjs +3 -3
- package/fesm2022/cmat-services-export-as.mjs.map +1 -1
- package/fesm2022/cmat-services-loading.mjs +30 -47
- package/fesm2022/cmat-services-loading.mjs.map +1 -1
- package/fesm2022/cmat-services-local-storage.mjs +3 -3
- package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
- package/fesm2022/cmat-services-media-watcher.mjs +43 -34
- package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
- package/fesm2022/cmat-services-platform.mjs +3 -3
- package/fesm2022/cmat-services-platform.mjs.map +1 -1
- package/fesm2022/cmat-services-splash-screen.mjs +3 -3
- package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
- package/fesm2022/cmat-services-title.mjs +3 -3
- package/fesm2022/cmat-services-title.mjs.map +1 -1
- package/fesm2022/cmat-services-translation.mjs +11 -11
- package/fesm2022/cmat-services-translation.mjs.map +1 -1
- package/fesm2022/cmat-services-utils.mjs +4 -4
- package/fesm2022/cmat-services-utils.mjs.map +1 -1
- package/fesm2022/cmat.mjs +9229 -7508
- package/fesm2022/cmat.mjs.map +1 -1
- package/icons/material-icons/heroicons-outline.svg +3 -0
- package/icons/material-icons/heroicons-solid.svg +3 -0
- package/package.json +10 -1
- package/styles/components/bundle.scss +21 -0
- package/styles/overrides/angular-material.scss +22 -1
- package/tailwind/plugins/theming.js +183 -183
- package/types/cmat-components-breadcrumb.d.ts +40 -37
- package/types/cmat-components-card.d.ts +11 -13
- package/types/cmat-components-carousel.d.ts +87 -113
- package/types/cmat-components-cascade.d.ts +84 -65
- package/types/cmat-components-chip-input.d.ts +29 -24
- package/types/cmat-components-code-editor.d.ts +28 -12
- package/types/cmat-components-color-picker.d.ts +236 -0
- package/types/cmat-components-custom-formly.d.ts +316 -184
- package/types/cmat-components-data-picker.d.ts +372 -0
- package/types/cmat-components-date-range.d.ts +31 -36
- package/types/cmat-components-date-time-display.d.ts +8 -8
- package/types/cmat-components-drawer.d.ts +30 -32
- package/types/cmat-components-empty-state.d.ts +9 -10
- package/types/cmat-components-file-preview.d.ts +9 -9
- package/types/cmat-components-filter-toolbar.d.ts +15 -15
- package/types/cmat-components-form-actions.d.ts +5 -5
- package/types/cmat-components-fullscreen.d.ts +5 -5
- package/types/cmat-components-highlight.d.ts +13 -14
- package/types/cmat-components-image-viewer.d.ts +29 -33
- package/types/cmat-components-inline-loading.d.ts +6 -6
- package/types/cmat-components-json-editor.d.ts +15 -17
- package/types/cmat-components-knob-input.d.ts +58 -55
- package/types/cmat-components-masonry.d.ts +9 -12
- package/types/cmat-components-material-color-picker.d.ts +16 -21
- package/types/cmat-components-material-datetimepicker.d.ts +174 -216
- package/types/cmat-components-navigation.d.ts +34 -39
- package/types/cmat-components-opt-input.d.ts +35 -33
- package/types/cmat-components-org-chart.d.ts +8 -9
- package/types/cmat-components-page-header.d.ts +9 -9
- package/types/cmat-components-pagination.d.ts +36 -40
- package/types/cmat-components-password-strength.d.ts +58 -64
- package/types/cmat-components-popover.d.ts +22 -32
- package/types/cmat-components-progress-bar.d.ts +7 -10
- package/types/cmat-components-qrcode.d.ts +22 -22
- package/types/cmat-components-rating.d.ts +17 -19
- package/types/cmat-components-rich-text-editor.d.ts +11 -12
- package/types/cmat-components-select-search.d.ts +48 -36
- package/types/cmat-components-select-table.d.ts +38 -34
- package/types/cmat-components-select-tree.d.ts +17 -15
- package/types/cmat-components-skeleton.d.ts +27 -10
- package/types/cmat-components-speed-dial.d.ts +24 -33
- package/types/cmat-components-status-tag.d.ts +19 -9
- package/types/cmat-components-table-toolbar.d.ts +7 -7
- package/types/cmat-components-timeline.d.ts +33 -34
- package/types/cmat-components-toast.d.ts +26 -30
- package/types/cmat-components-transfer-picker.d.ts +51 -56
- package/types/cmat-components-treetable.d.ts +12 -13
- package/types/cmat-components-upload.d.ts +33 -38
- package/types/cmat-components-x6-angular-shape.d.ts +1 -1
- package/types/cmat-directives-animate-on-scroll.d.ts +7 -7
- package/types/cmat-directives-arrow-cursor.d.ts +18 -20
- package/types/cmat-directives-data-exporter.d.ts +10 -10
- package/types/cmat-directives-debounce.d.ts +5 -5
- package/types/cmat-directives-digit-only.d.ts +13 -13
- package/types/cmat-directives-seamless-auto-scroll.d.ts +7 -7
- package/types/cmat-pipes-secure.d.ts +1 -3
- package/types/cmat-services-alert.d.ts +11 -12
- package/types/cmat-services-config.d.ts +2 -7
- package/types/cmat-services-confirmation.d.ts +2 -2
- package/types/cmat-services-data.d.ts +0 -1
- package/types/cmat-services-loading.d.ts +14 -22
- package/types/cmat-services-media-watcher.d.ts +5 -5
- package/types/cmat-services-translation.d.ts +4 -5
- package/types/cmat.d.ts +2167 -1746
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, DestroyRef, Injectable,
|
|
3
|
-
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
2
|
+
import { inject, DestroyRef, Injectable, output, input, model, signal, effect, ChangeDetectionStrategy, ViewEncapsulation, Component, viewChildren, ElementRef, computed, HostListener } from '@angular/core';
|
|
4
3
|
import * as i3 from '@angular/material/button';
|
|
5
4
|
import { MatButtonModule } from '@angular/material/button';
|
|
6
5
|
import * as i1 from '@angular/material/card';
|
|
@@ -12,6 +11,7 @@ import { MatListModule } from '@angular/material/list';
|
|
|
12
11
|
import { CmatMediaWatcherService } from 'cmat/services/media-watcher';
|
|
13
12
|
import { NgClass } from '@angular/common';
|
|
14
13
|
import { HttpClient, HttpEventType } from '@angular/common/http';
|
|
14
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
15
15
|
import * as i3$1 from '@angular/material/progress-bar';
|
|
16
16
|
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
17
17
|
import * as i4 from '@angular/material/tooltip';
|
|
@@ -27,14 +27,10 @@ class CmatFilesUtilService {
|
|
|
27
27
|
this._http = inject(HttpClient);
|
|
28
28
|
this._urlStateConfigService = inject(CmatUrlStateConfigService);
|
|
29
29
|
this._destroyRef = inject(DestroyRef);
|
|
30
|
-
this._urlStateConfigService.config
|
|
31
|
-
.pipe(takeUntilDestroyed(this._destroyRef))
|
|
32
|
-
.subscribe((config) => {
|
|
33
|
-
this._config = config;
|
|
34
|
-
});
|
|
30
|
+
this._config = this._urlStateConfigService.config;
|
|
35
31
|
}
|
|
36
32
|
downloadFile(fileId, isStream = true) {
|
|
37
|
-
return this._http.get(`${this._config.fileUrl}/download/${fileId}`, {
|
|
33
|
+
return this._http.get(`${this._config().fileUrl}/download/${fileId}`, {
|
|
38
34
|
headers: CmatUtilsService.getRequestCryptoHeaders(fileId),
|
|
39
35
|
observe: 'response',
|
|
40
36
|
reportProgress: true,
|
|
@@ -45,7 +41,7 @@ class CmatFilesUtilService {
|
|
|
45
41
|
}).pipe(catchError(CmatUtilsService.handleError));
|
|
46
42
|
}
|
|
47
43
|
downloadFileZip(fileIds) {
|
|
48
|
-
return this._http.post(`${this._config.fileUrl}/download`, fileIds, {
|
|
44
|
+
return this._http.post(`${this._config().fileUrl}/download`, fileIds, {
|
|
49
45
|
headers: CmatUtilsService.getRequestCryptoHeaders('fileZip'),
|
|
50
46
|
observe: 'response',
|
|
51
47
|
reportProgress: true,
|
|
@@ -53,7 +49,7 @@ class CmatFilesUtilService {
|
|
|
53
49
|
}).pipe(catchError(CmatUtilsService.handleError));
|
|
54
50
|
}
|
|
55
51
|
uploadFile(file) {
|
|
56
|
-
return this._http.post(`${this._config.fileUrl}/upload`, file, {
|
|
52
|
+
return this._http.post(`${this._config().fileUrl}/upload`, file, {
|
|
57
53
|
headers: CmatUtilsService.getRequestCryptoHeaders('files'),
|
|
58
54
|
observe: 'events',
|
|
59
55
|
reportProgress: true,
|
|
@@ -61,7 +57,7 @@ class CmatFilesUtilService {
|
|
|
61
57
|
}).pipe(catchError(CmatUtilsService.handleError));
|
|
62
58
|
}
|
|
63
59
|
uploadFileToProcessed(file) {
|
|
64
|
-
return this._http.post(`${this._config.fileUrl}/upload/finish`, file, {
|
|
60
|
+
return this._http.post(`${this._config().fileUrl}/upload/finish`, file, {
|
|
65
61
|
headers: CmatUtilsService.getRequestCryptoHeaders('files'),
|
|
66
62
|
observe: 'events',
|
|
67
63
|
reportProgress: true,
|
|
@@ -69,7 +65,7 @@ class CmatFilesUtilService {
|
|
|
69
65
|
}).pipe(catchError(CmatUtilsService.handleError));
|
|
70
66
|
}
|
|
71
67
|
switchPublic(fileId, isPublic) {
|
|
72
|
-
return this._http.patch(`${this._config.fileUrl}/switch-public/${fileId}`, {
|
|
68
|
+
return this._http.patch(`${this._config().fileUrl}/switch-public/${fileId}`, {
|
|
73
69
|
id: fileId,
|
|
74
70
|
isPublic
|
|
75
71
|
}, {
|
|
@@ -77,94 +73,109 @@ class CmatFilesUtilService {
|
|
|
77
73
|
}).pipe(catchError((err) => CmatUtilsService.handleError(err)));
|
|
78
74
|
}
|
|
79
75
|
deleteFile(fileId) {
|
|
80
|
-
return this._http.delete(`${this._config.fileUrl}/${fileId}`, {
|
|
76
|
+
return this._http.delete(`${this._config().fileUrl}/${fileId}`, {
|
|
81
77
|
headers: CmatUtilsService.getRequestCryptoHeaders(fileId)
|
|
82
78
|
}).pipe(catchError((err) => CmatUtilsService.handleError(err)));
|
|
83
79
|
}
|
|
84
80
|
getFileList(queryData, pageIndex = -1, pageSize = -1) {
|
|
85
|
-
if (this._config.enableDataProtect) {
|
|
86
|
-
return this._http.post(`${this._config.fileUrl}/${pageIndex}/${pageSize}`, CmatUtilsService.getEncryptData(JSON.stringify(queryData)), {
|
|
81
|
+
if (this._config().enableDataProtect) {
|
|
82
|
+
return this._http.post(`${this._config().fileUrl}/${pageIndex}/${pageSize}`, CmatUtilsService.getEncryptData(JSON.stringify(queryData)), {
|
|
87
83
|
headers: CmatUtilsService.getRequestCryptoHeaders('fileList'),
|
|
88
84
|
responseType: 'text'
|
|
89
85
|
})
|
|
90
86
|
.pipe(map((res) => JSON.parse(CmatUtilsService.getDecryptData(res))), catchError(err => CmatUtilsService.handleError(err)));
|
|
91
87
|
}
|
|
92
88
|
else {
|
|
93
|
-
return this._http.post(`${this._config.fileUrl}/${pageIndex}/${pageSize}`, queryData, {
|
|
89
|
+
return this._http.post(`${this._config().fileUrl}/${pageIndex}/${pageSize}`, queryData, {
|
|
94
90
|
headers: CmatUtilsService.getRequestCryptoHeaders('fileList'),
|
|
95
91
|
responseType: 'json'
|
|
96
92
|
})
|
|
97
93
|
.pipe(tap((res) => res), catchError(err => CmatUtilsService.handleError(err)));
|
|
98
94
|
}
|
|
99
95
|
}
|
|
100
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
101
|
-
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
96
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatFilesUtilService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
97
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatFilesUtilService, providedIn: 'root' }); }
|
|
102
98
|
}
|
|
103
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
99
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatFilesUtilService, decorators: [{
|
|
104
100
|
type: Injectable,
|
|
105
101
|
args: [{
|
|
106
102
|
providedIn: 'root'
|
|
107
103
|
}]
|
|
108
|
-
}]
|
|
104
|
+
}] });
|
|
109
105
|
|
|
110
106
|
class CmatUploadComponent {
|
|
111
107
|
constructor() {
|
|
112
|
-
this.
|
|
113
|
-
this.
|
|
114
|
-
this.
|
|
115
|
-
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
this.
|
|
119
|
-
|
|
120
|
-
this.
|
|
121
|
-
|
|
122
|
-
this.
|
|
123
|
-
|
|
124
|
-
this.
|
|
108
|
+
this.removeEvent = output();
|
|
109
|
+
this.uploadEvent = output();
|
|
110
|
+
this.fileAlias = input('fileData', /* @ts-ignore */
|
|
111
|
+
...(ngDevMode ? [{ debugName: "fileAlias" }] : /* istanbul ignore next */ []));
|
|
112
|
+
this.filePath = input('', /* @ts-ignore */
|
|
113
|
+
...(ngDevMode ? [{ debugName: "filePath" }] : /* istanbul ignore next */ []));
|
|
114
|
+
this.fileCategory = input('', /* @ts-ignore */
|
|
115
|
+
...(ngDevMode ? [{ debugName: "fileCategory" }] : /* istanbul ignore next */ []));
|
|
116
|
+
this.isPublic = input(false, /* @ts-ignore */
|
|
117
|
+
...(ngDevMode ? [{ debugName: "isPublic" }] : /* istanbul ignore next */ []));
|
|
118
|
+
this.editMode = input(false, /* @ts-ignore */
|
|
119
|
+
...(ngDevMode ? [{ debugName: "editMode" }] : /* istanbul ignore next */ []));
|
|
120
|
+
this.autoUpload = input(true, /* @ts-ignore */
|
|
121
|
+
...(ngDevMode ? [{ debugName: "autoUpload" }] : /* istanbul ignore next */ []));
|
|
122
|
+
this.file = model.required(/* @ts-ignore */
|
|
123
|
+
...(ngDevMode ? [{ debugName: "file" }] : /* istanbul ignore next */ []));
|
|
124
|
+
this.id = input(null, /* @ts-ignore */
|
|
125
|
+
...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
|
|
126
|
+
this.progressPercentage = signal(0, /* @ts-ignore */
|
|
127
|
+
...(ngDevMode ? [{ debugName: "progressPercentage" }] : /* istanbul ignore next */ []));
|
|
128
|
+
this.loaded = signal(0, /* @ts-ignore */
|
|
129
|
+
...(ngDevMode ? [{ debugName: "loaded" }] : /* istanbul ignore next */ []));
|
|
130
|
+
this.total = signal(0, /* @ts-ignore */
|
|
131
|
+
...(ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []));
|
|
132
|
+
this.isUploading = signal(false, /* @ts-ignore */
|
|
133
|
+
...(ngDevMode ? [{ debugName: "isUploading" }] : /* istanbul ignore next */ []));
|
|
134
|
+
this.uploadedId = signal(null, /* @ts-ignore */
|
|
135
|
+
...(ngDevMode ? [{ debugName: "uploadedId" }] : /* istanbul ignore next */ []));
|
|
125
136
|
this._fileService = inject(CmatFilesUtilService);
|
|
126
137
|
this._destroyRef = inject(DestroyRef);
|
|
138
|
+
effect(() => {
|
|
139
|
+
const file = this.file();
|
|
140
|
+
this.total.set(file.size);
|
|
141
|
+
});
|
|
127
142
|
}
|
|
128
|
-
get file() {
|
|
129
|
-
return this._file;
|
|
130
|
-
}
|
|
131
|
-
set file(file) {
|
|
132
|
-
this._file = file;
|
|
133
|
-
this.total.set(this._file.size);
|
|
134
|
-
}
|
|
135
|
-
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
136
143
|
get fileType() {
|
|
137
|
-
return CmatUtilsService.getFileType(this.file.type);
|
|
144
|
+
return CmatUtilsService.getFileType(this.file().type);
|
|
138
145
|
}
|
|
139
|
-
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
140
146
|
get fileSize() {
|
|
141
|
-
return Number(this.file.size);
|
|
147
|
+
return Number(this.file().size);
|
|
142
148
|
}
|
|
143
149
|
ngOnInit() {
|
|
144
|
-
if (this.autoUpload && this.id === null) {
|
|
150
|
+
if (this.autoUpload() && this.id() === null) {
|
|
145
151
|
this.upload();
|
|
146
152
|
}
|
|
147
153
|
}
|
|
148
154
|
upload() {
|
|
149
155
|
this.isUploading.set(true);
|
|
156
|
+
const file = this.file();
|
|
150
157
|
const fileModel = {
|
|
151
158
|
id: null,
|
|
152
|
-
fileName:
|
|
153
|
-
length:
|
|
154
|
-
fileCategory: this.fileCategory,
|
|
155
|
-
isPublic: this.isPublic,
|
|
156
|
-
filePath: this.filePath,
|
|
159
|
+
fileName: file.name,
|
|
160
|
+
length: file.size,
|
|
161
|
+
fileCategory: this.fileCategory(),
|
|
162
|
+
isPublic: this.isPublic(),
|
|
163
|
+
filePath: this.filePath(),
|
|
157
164
|
fileType: this.fileType,
|
|
158
|
-
data:
|
|
165
|
+
data: file.data,
|
|
159
166
|
};
|
|
160
167
|
const formData = new FormData();
|
|
161
|
-
if (
|
|
162
|
-
formData.set(this.fileAlias,
|
|
168
|
+
if (file.data) {
|
|
169
|
+
formData.set(this.fileAlias(), file.data, file.fileName);
|
|
163
170
|
}
|
|
164
171
|
formData.append('fileInfo', JSON.stringify(fileModel));
|
|
165
|
-
this._fileService
|
|
166
|
-
|
|
167
|
-
|
|
172
|
+
this._fileService
|
|
173
|
+
.uploadFile(formData)
|
|
174
|
+
.pipe(takeUntilDestroyed(this._destroyRef))
|
|
175
|
+
.subscribe((event) => {
|
|
176
|
+
if (event.type === HttpEventType.UploadProgress &&
|
|
177
|
+
typeof event.total === 'number') {
|
|
178
|
+
this.progressPercentage.set(Math.floor((event.loaded * 100) / event.total));
|
|
168
179
|
this.loaded.set(event.loaded);
|
|
169
180
|
this.total.set(event.total);
|
|
170
181
|
}
|
|
@@ -174,96 +185,108 @@ class CmatUploadComponent {
|
|
|
174
185
|
this.isUploading.set(false);
|
|
175
186
|
return;
|
|
176
187
|
}
|
|
177
|
-
this.
|
|
178
|
-
|
|
188
|
+
this.uploadedId.set(fileId);
|
|
189
|
+
file.id = fileId;
|
|
190
|
+
this.file.set(file);
|
|
179
191
|
this.isUploading.set(false);
|
|
180
|
-
this.uploadEvent.emit(this.file);
|
|
192
|
+
this.uploadEvent.emit(this.file());
|
|
181
193
|
}
|
|
182
194
|
});
|
|
183
195
|
}
|
|
184
196
|
download() {
|
|
185
|
-
|
|
197
|
+
const id = this.uploadedId() ?? this.id();
|
|
198
|
+
if (!id)
|
|
186
199
|
return;
|
|
187
|
-
this._fileService
|
|
188
|
-
|
|
200
|
+
this._fileService
|
|
201
|
+
.downloadFile(id)
|
|
202
|
+
.pipe(takeUntilDestroyed(this._destroyRef))
|
|
203
|
+
.subscribe((file) => {
|
|
204
|
+
saveAs(new Blob([file.body ?? new Blob()], {
|
|
205
|
+
type: 'text/plain;charset=utf-8',
|
|
206
|
+
}), this.file().name);
|
|
189
207
|
});
|
|
190
208
|
}
|
|
191
209
|
remove() {
|
|
192
210
|
this.removeEvent.emit(this);
|
|
193
211
|
}
|
|
194
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
195
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
212
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatUploadComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
213
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.2", type: CmatUploadComponent, isStandalone: true, selector: "cmat-upload", inputs: { fileAlias: { classPropertyName: "fileAlias", publicName: "fileAlias", isSignal: true, isRequired: false, transformFunction: null }, filePath: { classPropertyName: "filePath", publicName: "filePath", isSignal: true, isRequired: false, transformFunction: null }, fileCategory: { classPropertyName: "fileCategory", publicName: "fileCategory", isSignal: true, isRequired: false, transformFunction: null }, isPublic: { classPropertyName: "isPublic", publicName: "isPublic", isSignal: true, isRequired: false, transformFunction: null }, editMode: { classPropertyName: "editMode", publicName: "editMode", isSignal: true, isRequired: false, transformFunction: null }, autoUpload: { classPropertyName: "autoUpload", publicName: "autoUpload", isSignal: true, isRequired: false, transformFunction: null }, file: { classPropertyName: "file", publicName: "file", isSignal: true, isRequired: true, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { removeEvent: "removeEvent", uploadEvent: "uploadEvent", file: "fileChange" }, exportAs: ["cmatUpload"], ngImport: i0, template: "<div class=\"flex flex-col\">\r\n <div class=\"flex flex-row items-center\">\r\n <span class=\"flex items-center px-1\">\r\n <mat-icon class=\"icon-size-6 text-hint\" [svgIcon]=\"fileType\"></mat-icon>\r\n </span>\r\n <span\r\n matTooltip=\"{{ file().name }}\"\r\n class=\"text-sm flex flex-auto whitespace-nowrap overflow-x-hidden text-ellipsis\"\r\n >{{ file().name }}({{ fileSize | cmatBytes }})</span\r\n >\r\n <span class=\"flex flex-row gap-1 print:hidden\">\r\n @if (id() === null) {\r\n <button\r\n matIconButton\r\n color=\"primary\"\r\n class=\"w-8 min-h-8 h-8 max-w-8\"\r\n [ngClass]=\"{ disabled: isUploading() }\"\r\n (click)=\"upload()\"\r\n >\r\n <mat-icon\r\n class=\"icon-size-5\"\r\n [svgIcon]=\"'mat_outline:file_upload'\"\r\n ></mat-icon>\r\n </button>\r\n }\r\n\r\n @if (id() !== null) {\r\n <button\r\n matIconButton\r\n color=\"primary\"\r\n class=\"w-8 min-h-8 h-8 max-w-8\"\r\n (click)=\"download()\"\r\n >\r\n <mat-icon\r\n class=\"icon-size-5\"\r\n [svgIcon]=\"'mat_outline:file_download'\"\r\n ></mat-icon>\r\n </button>\r\n }\r\n\r\n @if (editMode()) {\r\n <button\r\n matIconButton\r\n color=\"warn\"\r\n class=\"w-8 min-h-8 h-8 max-w-8\"\r\n (click)=\"remove()\"\r\n >\r\n <mat-icon\r\n class=\"icon-size-5\"\r\n [svgIcon]=\"'heroicons_solid:trash'\"\r\n ></mat-icon>\r\n </button>\r\n }\r\n </span>\r\n </div>\r\n @if (id() === null) {\r\n <mat-progress-bar [value]=\"progressPercentage()\"></mat-progress-bar>\r\n <div\r\n class=\"text-sm block whitespace-nowrap overflow-x-hidden text-ellipsis\"\r\n >\r\n <span>{{ progressPercentage() }}%</span\r\n ><span> {{ loaded() | cmatBytes }} of {{ total() | cmatBytes }}</span>\r\n </div>\r\n }\r\n</div>\r\n", dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i3.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i3$1.MatProgressBar, selector: "mat-progress-bar", inputs: ["color", "value", "bufferValue", "mode"], outputs: ["animationEnd"], exportAs: ["matProgressBar"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i4.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "pipe", type: CmatBytesPipe, name: "cmatBytes" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
196
214
|
}
|
|
197
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
215
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatUploadComponent, decorators: [{
|
|
198
216
|
type: Component,
|
|
199
|
-
args: [{ selector: 'cmat-upload', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'cmatUpload', imports: [
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}]
|
|
207
|
-
|
|
208
|
-
}], editMode: [{
|
|
209
|
-
type: Input
|
|
210
|
-
}], autoUpload: [{
|
|
211
|
-
type: Input
|
|
212
|
-
}], id: [{
|
|
213
|
-
type: Input
|
|
214
|
-
}], removeEvent: [{
|
|
215
|
-
type: Output
|
|
216
|
-
}], uploadEvent: [{
|
|
217
|
-
type: Output
|
|
218
|
-
}], file: [{
|
|
219
|
-
type: Input
|
|
220
|
-
}] } });
|
|
217
|
+
args: [{ selector: 'cmat-upload', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'cmatUpload', imports: [
|
|
218
|
+
MatButtonModule,
|
|
219
|
+
MatIconModule,
|
|
220
|
+
MatProgressBarModule,
|
|
221
|
+
MatTooltipModule,
|
|
222
|
+
CmatBytesPipe,
|
|
223
|
+
NgClass,
|
|
224
|
+
], template: "<div class=\"flex flex-col\">\r\n <div class=\"flex flex-row items-center\">\r\n <span class=\"flex items-center px-1\">\r\n <mat-icon class=\"icon-size-6 text-hint\" [svgIcon]=\"fileType\"></mat-icon>\r\n </span>\r\n <span\r\n matTooltip=\"{{ file().name }}\"\r\n class=\"text-sm flex flex-auto whitespace-nowrap overflow-x-hidden text-ellipsis\"\r\n >{{ file().name }}({{ fileSize | cmatBytes }})</span\r\n >\r\n <span class=\"flex flex-row gap-1 print:hidden\">\r\n @if (id() === null) {\r\n <button\r\n matIconButton\r\n color=\"primary\"\r\n class=\"w-8 min-h-8 h-8 max-w-8\"\r\n [ngClass]=\"{ disabled: isUploading() }\"\r\n (click)=\"upload()\"\r\n >\r\n <mat-icon\r\n class=\"icon-size-5\"\r\n [svgIcon]=\"'mat_outline:file_upload'\"\r\n ></mat-icon>\r\n </button>\r\n }\r\n\r\n @if (id() !== null) {\r\n <button\r\n matIconButton\r\n color=\"primary\"\r\n class=\"w-8 min-h-8 h-8 max-w-8\"\r\n (click)=\"download()\"\r\n >\r\n <mat-icon\r\n class=\"icon-size-5\"\r\n [svgIcon]=\"'mat_outline:file_download'\"\r\n ></mat-icon>\r\n </button>\r\n }\r\n\r\n @if (editMode()) {\r\n <button\r\n matIconButton\r\n color=\"warn\"\r\n class=\"w-8 min-h-8 h-8 max-w-8\"\r\n (click)=\"remove()\"\r\n >\r\n <mat-icon\r\n class=\"icon-size-5\"\r\n [svgIcon]=\"'heroicons_solid:trash'\"\r\n ></mat-icon>\r\n </button>\r\n }\r\n </span>\r\n </div>\r\n @if (id() === null) {\r\n <mat-progress-bar [value]=\"progressPercentage()\"></mat-progress-bar>\r\n <div\r\n class=\"text-sm block whitespace-nowrap overflow-x-hidden text-ellipsis\"\r\n >\r\n <span>{{ progressPercentage() }}%</span\r\n ><span> {{ loaded() | cmatBytes }} of {{ total() | cmatBytes }}</span>\r\n </div>\r\n }\r\n</div>\r\n" }]
|
|
225
|
+
}], ctorParameters: () => [], propDecorators: { removeEvent: [{ type: i0.Output, args: ["removeEvent"] }], uploadEvent: [{ type: i0.Output, args: ["uploadEvent"] }], fileAlias: [{ type: i0.Input, args: [{ isSignal: true, alias: "fileAlias", required: false }] }], filePath: [{ type: i0.Input, args: [{ isSignal: true, alias: "filePath", required: false }] }], fileCategory: [{ type: i0.Input, args: [{ isSignal: true, alias: "fileCategory", required: false }] }], isPublic: [{ type: i0.Input, args: [{ isSignal: true, alias: "isPublic", required: false }] }], editMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "editMode", required: false }] }], autoUpload: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoUpload", required: false }] }], file: [{ type: i0.Input, args: [{ isSignal: true, alias: "file", required: true }] }, { type: i0.Output, args: ["fileChange"] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }] } });
|
|
221
226
|
|
|
222
227
|
class CmatUploadQueueComponent {
|
|
223
228
|
constructor() {
|
|
224
|
-
this.
|
|
225
|
-
this.
|
|
226
|
-
this.
|
|
227
|
-
this.
|
|
228
|
-
|
|
229
|
-
this.
|
|
230
|
-
|
|
231
|
-
this.
|
|
232
|
-
|
|
233
|
-
this.
|
|
234
|
-
|
|
235
|
-
this.
|
|
236
|
-
|
|
229
|
+
this.outputRemoveIdEvent = output();
|
|
230
|
+
this.outputUploadIdEvent = output();
|
|
231
|
+
this.outputFilesDataEvent = output();
|
|
232
|
+
this.fileAlias = input('fileData', /* @ts-ignore */
|
|
233
|
+
...(ngDevMode ? [{ debugName: "fileAlias" }] : /* istanbul ignore next */ []));
|
|
234
|
+
this.filePath = input('', /* @ts-ignore */
|
|
235
|
+
...(ngDevMode ? [{ debugName: "filePath" }] : /* istanbul ignore next */ []));
|
|
236
|
+
this.fileCategory = input('', /* @ts-ignore */
|
|
237
|
+
...(ngDevMode ? [{ debugName: "fileCategory" }] : /* istanbul ignore next */ []));
|
|
238
|
+
this.isPublic = input(false, /* @ts-ignore */
|
|
239
|
+
...(ngDevMode ? [{ debugName: "isPublic" }] : /* istanbul ignore next */ []));
|
|
240
|
+
this.required = input(false, /* @ts-ignore */
|
|
241
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
242
|
+
this.autoUpload = input(true, /* @ts-ignore */
|
|
243
|
+
...(ngDevMode ? [{ debugName: "autoUpload" }] : /* istanbul ignore next */ []));
|
|
244
|
+
this.multiple = input(true, /* @ts-ignore */
|
|
245
|
+
...(ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []));
|
|
246
|
+
this.accept = input('', /* @ts-ignore */
|
|
247
|
+
...(ngDevMode ? [{ debugName: "accept" }] : /* istanbul ignore next */ []));
|
|
248
|
+
this.title = input('附件', /* @ts-ignore */
|
|
249
|
+
...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
|
|
250
|
+
this.editMode = input(false, /* @ts-ignore */
|
|
251
|
+
...(ngDevMode ? [{ debugName: "editMode" }] : /* istanbul ignore next */ []));
|
|
252
|
+
this.filesData = model([], /* @ts-ignore */
|
|
253
|
+
...(ngDevMode ? [{ debugName: "filesData" }] : /* istanbul ignore next */ []));
|
|
237
254
|
this.id = 'cmatupload-' + crypto.randomUUID().slice(0, 8);
|
|
238
|
-
this.
|
|
239
|
-
|
|
255
|
+
this.fileUploads = viewChildren(CmatUploadComponent, /* @ts-ignore */
|
|
256
|
+
...(ngDevMode ? [{ debugName: "fileUploads" }] : /* istanbul ignore next */ []));
|
|
240
257
|
this._cmatMediaWatcherService = inject(CmatMediaWatcherService);
|
|
241
258
|
this._elementRef = inject(ElementRef);
|
|
242
|
-
|
|
243
|
-
this.
|
|
244
|
-
.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
});
|
|
259
|
+
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
260
|
+
this.isHandSet = computed(() => {
|
|
261
|
+
return !this._cmatMediaWatcherService.mediaChange().matchingAliases.includes('lg');
|
|
262
|
+
}, /* @ts-ignore */
|
|
263
|
+
...(ngDevMode ? [{ debugName: "isHandSet" }] : /* istanbul ignore next */ []));
|
|
248
264
|
}
|
|
249
265
|
onDrop(event) {
|
|
250
|
-
|
|
251
|
-
|
|
266
|
+
// 检查是否是文件拖拽(来自操作系统),而不是 Angular DnD 的内部拖拽
|
|
267
|
+
const hasFiles = event.dataTransfer?.files && event.dataTransfer.files.length > 0;
|
|
268
|
+
const hasAngularDndData = event.dataTransfer?.types.includes('application/x-ng-dnd');
|
|
269
|
+
// 如果是 Angular DnD 的内部拖拽,不要拦截,让 DnD 库处理
|
|
270
|
+
if (hasAngularDndData) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
// 只有真正的文件拖拽才处理
|
|
274
|
+
if (!hasFiles)
|
|
252
275
|
return;
|
|
253
|
-
for (const file of files) {
|
|
254
|
-
if (this.accept?.includes(file.type))
|
|
276
|
+
for (const file of event.dataTransfer.files) {
|
|
277
|
+
if (this.accept()?.includes(file.type))
|
|
255
278
|
this.add(file);
|
|
256
279
|
}
|
|
257
280
|
event.preventDefault();
|
|
258
281
|
event.stopPropagation();
|
|
259
282
|
}
|
|
260
283
|
onDropOver(event) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
this.fileDataSource.set(this.filesData);
|
|
284
|
+
// 同样检查是否是 Angular DnD 的内部拖拽
|
|
285
|
+
const hasAngularDndData = event.dataTransfer?.types.includes('application/x-ng-dnd');
|
|
286
|
+
if (hasAngularDndData) {
|
|
287
|
+
return; // 不拦截,让 DnD 库处理
|
|
266
288
|
}
|
|
289
|
+
event.preventDefault();
|
|
267
290
|
}
|
|
268
291
|
ngAfterViewInit() {
|
|
269
292
|
const fileUpload = this._elementRef.nativeElement.querySelector(`#${this.id}`);
|
|
@@ -281,54 +304,66 @@ class CmatUploadQueueComponent {
|
|
|
281
304
|
if (!this.isFileTypeAccepted(file.type)) {
|
|
282
305
|
return;
|
|
283
306
|
}
|
|
284
|
-
|
|
285
|
-
|
|
307
|
+
const filesData = this.filesData();
|
|
308
|
+
if (!Array.isArray(filesData)) {
|
|
309
|
+
return;
|
|
286
310
|
}
|
|
287
|
-
|
|
288
|
-
|
|
311
|
+
let newFilesData;
|
|
312
|
+
if (!(!this.multiple() && filesData.length > 0)) {
|
|
313
|
+
newFilesData = [...filesData, file];
|
|
289
314
|
}
|
|
290
|
-
else
|
|
291
|
-
|
|
292
|
-
|
|
315
|
+
else {
|
|
316
|
+
const firstUpload = this.fileUploads()[0];
|
|
317
|
+
if (firstUpload?.id() === null) {
|
|
318
|
+
newFilesData = [...filesData, file];
|
|
319
|
+
firstUpload.remove();
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
293
324
|
}
|
|
294
|
-
this.
|
|
325
|
+
this.filesData.set(newFilesData);
|
|
295
326
|
}
|
|
296
327
|
upload(event) {
|
|
297
328
|
this.outputUploadIdEvent.emit(event.id ?? '');
|
|
298
|
-
this.outputFilesDataEvent.emit(this.filesData);
|
|
299
|
-
this.fileDataSource.set(this.filesData);
|
|
329
|
+
this.outputFilesDataEvent.emit(this.filesData());
|
|
300
330
|
}
|
|
301
331
|
remove(event) {
|
|
302
|
-
|
|
303
|
-
|
|
332
|
+
const filesData = this.filesData();
|
|
333
|
+
if (filesData) {
|
|
334
|
+
const index = filesData.findIndex((j) => j === event.file());
|
|
304
335
|
if (index > -1) {
|
|
305
|
-
|
|
306
|
-
if (event.file.id) {
|
|
307
|
-
this.outputRemoveIdEvent.emit(event.file.id);
|
|
336
|
+
filesData.splice(index, 1);
|
|
337
|
+
if (event.file().id) {
|
|
338
|
+
this.outputRemoveIdEvent.emit(event.file().id);
|
|
308
339
|
}
|
|
309
|
-
this.outputFilesDataEvent.emit(
|
|
310
|
-
this.fileDataSource.set(this.filesData);
|
|
340
|
+
this.outputFilesDataEvent.emit(filesData);
|
|
311
341
|
}
|
|
312
342
|
}
|
|
313
343
|
}
|
|
314
344
|
uploadAll() {
|
|
315
|
-
this.fileUploads.forEach((fileUpload) => {
|
|
316
|
-
if (fileUpload.id === null) {
|
|
345
|
+
this.fileUploads().forEach((fileUpload) => {
|
|
346
|
+
if (fileUpload.id() === null) {
|
|
317
347
|
fileUpload.upload();
|
|
318
348
|
}
|
|
319
349
|
});
|
|
320
350
|
}
|
|
321
351
|
removeAll() {
|
|
322
|
-
this.fileUploads.forEach((fileUpload) => {
|
|
352
|
+
this.fileUploads().forEach((fileUpload) => {
|
|
353
|
+
fileUpload.remove();
|
|
354
|
+
});
|
|
323
355
|
}
|
|
324
356
|
choose() {
|
|
325
|
-
this._elementRef.nativeElement
|
|
357
|
+
this._elementRef.nativeElement
|
|
358
|
+
.querySelector(`#${this.id}`)
|
|
359
|
+
?.dispatchEvent(new MouseEvent('click'));
|
|
326
360
|
}
|
|
327
361
|
isFileTypeAccepted(fileType) {
|
|
328
|
-
|
|
362
|
+
const accept = this.accept();
|
|
363
|
+
if (!accept || accept === '') {
|
|
329
364
|
return true;
|
|
330
365
|
}
|
|
331
|
-
const acceptedTypes =
|
|
366
|
+
const acceptedTypes = accept.split(',').map(type => type.trim());
|
|
332
367
|
return acceptedTypes.some((type) => {
|
|
333
368
|
if (type.endsWith('/*')) {
|
|
334
369
|
const prefix = type.slice(0, -1);
|
|
@@ -337,44 +372,19 @@ class CmatUploadQueueComponent {
|
|
|
337
372
|
return fileType === type;
|
|
338
373
|
});
|
|
339
374
|
}
|
|
340
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
341
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
375
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatUploadQueueComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
376
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.2", type: CmatUploadQueueComponent, isStandalone: true, selector: "cmat-upload-queue", inputs: { fileAlias: { classPropertyName: "fileAlias", publicName: "fileAlias", isSignal: true, isRequired: false, transformFunction: null }, filePath: { classPropertyName: "filePath", publicName: "filePath", isSignal: true, isRequired: false, transformFunction: null }, fileCategory: { classPropertyName: "fileCategory", publicName: "fileCategory", isSignal: true, isRequired: false, transformFunction: null }, isPublic: { classPropertyName: "isPublic", publicName: "isPublic", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, autoUpload: { classPropertyName: "autoUpload", publicName: "autoUpload", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, editMode: { classPropertyName: "editMode", publicName: "editMode", isSignal: true, isRequired: false, transformFunction: null }, filesData: { classPropertyName: "filesData", publicName: "filesData", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { outputRemoveIdEvent: "outputRemoveIdEvent", outputUploadIdEvent: "outputUploadIdEvent", outputFilesDataEvent: "outputFilesDataEvent", filesData: "filesDataChange" }, host: { listeners: { "drop": "onDrop($event)", "dragover": "onDropOver($event)" } }, viewQueries: [{ propertyName: "fileUploads", predicate: CmatUploadComponent, descendants: true, isSignal: true }], exportAs: ["cmatUploadQueue"], ngImport: i0, template: "<mat-card>\r\n <mat-card-header>\r\n <mat-card-title>\r\n <legend class=\"text-lg\">\r\n {{ title() }}\r\n @if (required()) {\r\n <span>*</span>\r\n }\r\n </legend>\r\n </mat-card-title>\r\n </mat-card-header>\r\n <input\r\n type=\"file\"\r\n class=\"hidden\"\r\n [id]=\"id\"\r\n [multiple]=\"multiple()\"\r\n [accept]=\"accept()\"\r\n />\r\n\r\n @if (editMode()) {\r\n <mat-card-actions class=\"flex flex-row gap-1 print:hidden\">\r\n @if (!isHandSet()) {\r\n <button matButton=\"filled\" color=\"primary\" (click)=\"choose()\">\r\n @if (autoUpload()) {\r\n <mat-icon [svgIcon]=\"'mat_outline:file_upload'\"></mat-icon>\r\n } @else {\r\n <mat-icon [svgIcon]=\"'mat_outline:add_box'\"></mat-icon>\r\n }\r\n <span class=\"ml-2\">\u9009\u62E9</span>\r\n </button>\r\n @if (filesData() && multiple() && filesData().length > 0) {\r\n @if (!autoUpload()) {\r\n <button matButton=\"filled\" color=\"accent\" (click)=\"uploadAll()\">\r\n <mat-icon [svgIcon]=\"'mat_outline:file_upload'\"></mat-icon\r\n ><span class=\"ml-2\">\u4E0A\u4F20\u5168\u90E8</span>\r\n </button>\r\n }\r\n\r\n <button matButton=\"filled\" color=\"warn\" (click)=\"removeAll()\">\r\n <mat-icon [svgIcon]=\"'heroicons_solid:trash'\"></mat-icon\r\n ><span class=\"ml-2\">\u5220\u9664\u5168\u90E8</span>\r\n </button>\r\n }\r\n } @else {\r\n <button matIconButton color=\"primary\" (click)=\"choose()\">\r\n @if (autoUpload()) {\r\n <mat-icon [svgIcon]=\"'mat_outline:file_upload'\"></mat-icon>\r\n } @else {\r\n <mat-icon [svgIcon]=\"'mat_outline:add_box'\"></mat-icon>\r\n }\r\n </button>\r\n\r\n @if (filesData() && multiple() && filesData().length > 0) {\r\n @if (!autoUpload()) {\r\n <button matIconButton color=\"accent\" (click)=\"uploadAll()\">\r\n <mat-icon [svgIcon]=\"'mat_outline:file_upload'\"></mat-icon>\r\n </button>\r\n }\r\n\r\n <button matIconButton color=\"warn\" (click)=\"removeAll()\">\r\n <mat-icon [svgIcon]=\"'heroicons_solid:trash'\"></mat-icon>\r\n </button>\r\n }\r\n }\r\n </mat-card-actions>\r\n }\r\n\r\n <mat-card-content>\r\n <mat-list class=\"border-t\">\r\n @for (file of filesData(); track $index) {\r\n <mat-list-item class=\"cmat-upload-file-item h-full\">\r\n <cmat-upload\r\n class=\"my-2\"\r\n [fileAlias]=\"fileAlias()\"\r\n [filePath]=\"filePath()\"\r\n [fileCategory]=\"fileCategory()\"\r\n [autoUpload]=\"autoUpload()\"\r\n [editMode]=\"editMode()\"\r\n [file]=\"file\"\r\n [id]=\"file.id || null\"\r\n [isPublic]=\"isPublic()\"\r\n (removeEvent)=\"remove($event)\"\r\n (uploadEvent)=\"upload($event)\"\r\n ></cmat-upload>\r\n </mat-list-item>\r\n }\r\n </mat-list>\r\n </mat-card-content>\r\n</mat-card>\r\n", dependencies: [{ kind: "ngmodule", type: MatCardModule }, { kind: "component", type: i1.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "directive", type: i1.MatCardActions, selector: "mat-card-actions", inputs: ["align"], exportAs: ["matCardActions"] }, { kind: "directive", type: i1.MatCardContent, selector: "mat-card-content" }, { kind: "component", type: i1.MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: i1.MatCardTitle, selector: "mat-card-title, [mat-card-title], [matCardTitle]" }, { kind: "ngmodule", type: MatListModule }, { kind: "component", type: i2$1.MatList, selector: "mat-list", exportAs: ["matList"] }, { kind: "component", type: i2$1.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["activated"], exportAs: ["matListItem"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i3.MatButton, selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ", inputs: ["matButton"], exportAs: ["matButton", "matAnchor"] }, { kind: "component", type: i3.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i2.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: CmatUploadComponent, selector: "cmat-upload", inputs: ["fileAlias", "filePath", "fileCategory", "isPublic", "editMode", "autoUpload", "file", "id"], outputs: ["removeEvent", "uploadEvent", "fileChange"], exportAs: ["cmatUpload"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
342
377
|
}
|
|
343
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
378
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: CmatUploadQueueComponent, decorators: [{
|
|
344
379
|
type: Component,
|
|
345
|
-
args: [{ selector: 'cmat-upload-queue', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'cmatUploadQueue', imports: [
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}]
|
|
352
|
-
|
|
353
|
-
}], fileCategory: [{
|
|
354
|
-
type: Input
|
|
355
|
-
}], isPublic: [{
|
|
356
|
-
type: Input
|
|
357
|
-
}], required: [{
|
|
358
|
-
type: Input
|
|
359
|
-
}], autoUpload: [{
|
|
360
|
-
type: Input
|
|
361
|
-
}], multiple: [{
|
|
362
|
-
type: Input
|
|
363
|
-
}], accept: [{
|
|
364
|
-
type: Input
|
|
365
|
-
}], title: [{
|
|
366
|
-
type: Input
|
|
367
|
-
}], editMode: [{
|
|
368
|
-
type: Input
|
|
369
|
-
}], filesData: [{
|
|
370
|
-
type: Input
|
|
371
|
-
}], outputRemoveIdEvent: [{
|
|
372
|
-
type: Output
|
|
373
|
-
}], outputUploadIdEvent: [{
|
|
374
|
-
type: Output
|
|
375
|
-
}], outputFilesDataEvent: [{
|
|
376
|
-
type: Output
|
|
377
|
-
}], onDrop: [{
|
|
380
|
+
args: [{ selector: 'cmat-upload-queue', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'cmatUploadQueue', imports: [
|
|
381
|
+
MatCardModule,
|
|
382
|
+
MatListModule,
|
|
383
|
+
MatButtonModule,
|
|
384
|
+
MatIconModule,
|
|
385
|
+
CmatUploadComponent,
|
|
386
|
+
], template: "<mat-card>\r\n <mat-card-header>\r\n <mat-card-title>\r\n <legend class=\"text-lg\">\r\n {{ title() }}\r\n @if (required()) {\r\n <span>*</span>\r\n }\r\n </legend>\r\n </mat-card-title>\r\n </mat-card-header>\r\n <input\r\n type=\"file\"\r\n class=\"hidden\"\r\n [id]=\"id\"\r\n [multiple]=\"multiple()\"\r\n [accept]=\"accept()\"\r\n />\r\n\r\n @if (editMode()) {\r\n <mat-card-actions class=\"flex flex-row gap-1 print:hidden\">\r\n @if (!isHandSet()) {\r\n <button matButton=\"filled\" color=\"primary\" (click)=\"choose()\">\r\n @if (autoUpload()) {\r\n <mat-icon [svgIcon]=\"'mat_outline:file_upload'\"></mat-icon>\r\n } @else {\r\n <mat-icon [svgIcon]=\"'mat_outline:add_box'\"></mat-icon>\r\n }\r\n <span class=\"ml-2\">\u9009\u62E9</span>\r\n </button>\r\n @if (filesData() && multiple() && filesData().length > 0) {\r\n @if (!autoUpload()) {\r\n <button matButton=\"filled\" color=\"accent\" (click)=\"uploadAll()\">\r\n <mat-icon [svgIcon]=\"'mat_outline:file_upload'\"></mat-icon\r\n ><span class=\"ml-2\">\u4E0A\u4F20\u5168\u90E8</span>\r\n </button>\r\n }\r\n\r\n <button matButton=\"filled\" color=\"warn\" (click)=\"removeAll()\">\r\n <mat-icon [svgIcon]=\"'heroicons_solid:trash'\"></mat-icon\r\n ><span class=\"ml-2\">\u5220\u9664\u5168\u90E8</span>\r\n </button>\r\n }\r\n } @else {\r\n <button matIconButton color=\"primary\" (click)=\"choose()\">\r\n @if (autoUpload()) {\r\n <mat-icon [svgIcon]=\"'mat_outline:file_upload'\"></mat-icon>\r\n } @else {\r\n <mat-icon [svgIcon]=\"'mat_outline:add_box'\"></mat-icon>\r\n }\r\n </button>\r\n\r\n @if (filesData() && multiple() && filesData().length > 0) {\r\n @if (!autoUpload()) {\r\n <button matIconButton color=\"accent\" (click)=\"uploadAll()\">\r\n <mat-icon [svgIcon]=\"'mat_outline:file_upload'\"></mat-icon>\r\n </button>\r\n }\r\n\r\n <button matIconButton color=\"warn\" (click)=\"removeAll()\">\r\n <mat-icon [svgIcon]=\"'heroicons_solid:trash'\"></mat-icon>\r\n </button>\r\n }\r\n }\r\n </mat-card-actions>\r\n }\r\n\r\n <mat-card-content>\r\n <mat-list class=\"border-t\">\r\n @for (file of filesData(); track $index) {\r\n <mat-list-item class=\"cmat-upload-file-item h-full\">\r\n <cmat-upload\r\n class=\"my-2\"\r\n [fileAlias]=\"fileAlias()\"\r\n [filePath]=\"filePath()\"\r\n [fileCategory]=\"fileCategory()\"\r\n [autoUpload]=\"autoUpload()\"\r\n [editMode]=\"editMode()\"\r\n [file]=\"file\"\r\n [id]=\"file.id || null\"\r\n [isPublic]=\"isPublic()\"\r\n (removeEvent)=\"remove($event)\"\r\n (uploadEvent)=\"upload($event)\"\r\n ></cmat-upload>\r\n </mat-list-item>\r\n }\r\n </mat-list>\r\n </mat-card-content>\r\n</mat-card>\r\n" }]
|
|
387
|
+
}], propDecorators: { outputRemoveIdEvent: [{ type: i0.Output, args: ["outputRemoveIdEvent"] }], outputUploadIdEvent: [{ type: i0.Output, args: ["outputUploadIdEvent"] }], outputFilesDataEvent: [{ type: i0.Output, args: ["outputFilesDataEvent"] }], fileAlias: [{ type: i0.Input, args: [{ isSignal: true, alias: "fileAlias", required: false }] }], filePath: [{ type: i0.Input, args: [{ isSignal: true, alias: "filePath", required: false }] }], fileCategory: [{ type: i0.Input, args: [{ isSignal: true, alias: "fileCategory", required: false }] }], isPublic: [{ type: i0.Input, args: [{ isSignal: true, alias: "isPublic", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], autoUpload: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoUpload", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], accept: [{ type: i0.Input, args: [{ isSignal: true, alias: "accept", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], editMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "editMode", required: false }] }], filesData: [{ type: i0.Input, args: [{ isSignal: true, alias: "filesData", required: false }] }, { type: i0.Output, args: ["filesDataChange"] }], fileUploads: [{ type: i0.ViewChildren, args: [i0.forwardRef(() => CmatUploadComponent), { isSignal: true }] }], onDrop: [{
|
|
378
388
|
type: HostListener,
|
|
379
389
|
args: ['drop', ['$event']]
|
|
380
390
|
}], onDropOver: [{
|