cmat 0.0.110 → 0.0.112

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.
Files changed (256) hide show
  1. package/fesm2022/cmat-components-adapter.mjs +531 -536
  2. package/fesm2022/cmat-components-adapter.mjs.map +1 -1
  3. package/fesm2022/cmat-components-breadcrumb.mjs +521 -356
  4. package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
  5. package/fesm2022/cmat-components-card.mjs +150 -42
  6. package/fesm2022/cmat-components-card.mjs.map +1 -1
  7. package/fesm2022/cmat-components-carousel.mjs +1120 -629
  8. package/fesm2022/cmat-components-carousel.mjs.map +1 -1
  9. package/fesm2022/cmat-components-cascade.mjs +861 -441
  10. package/fesm2022/cmat-components-cascade.mjs.map +1 -1
  11. package/fesm2022/cmat-components-chip-input.mjs +580 -335
  12. package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
  13. package/fesm2022/cmat-components-code-editor.mjs +197 -105
  14. package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
  15. package/fesm2022/cmat-components-color-picker.mjs +1762 -825
  16. package/fesm2022/cmat-components-color-picker.mjs.map +1 -1
  17. package/fesm2022/cmat-components-custom-formly.mjs +5196 -2531
  18. package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
  19. package/fesm2022/cmat-components-data-picker.mjs +1901 -1073
  20. package/fesm2022/cmat-components-data-picker.mjs.map +1 -1
  21. package/fesm2022/cmat-components-date-range.mjs +701 -456
  22. package/fesm2022/cmat-components-date-range.mjs.map +1 -1
  23. package/fesm2022/cmat-components-date-time-display.mjs +137 -30
  24. package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
  25. package/fesm2022/cmat-components-drawer.mjs +410 -258
  26. package/fesm2022/cmat-components-drawer.mjs.map +1 -1
  27. package/fesm2022/cmat-components-empty-state.mjs +201 -41
  28. package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
  29. package/fesm2022/cmat-components-file-preview.mjs +198 -35
  30. package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
  31. package/fesm2022/cmat-components-filter-toolbar.mjs +320 -72
  32. package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
  33. package/fesm2022/cmat-components-form-actions.mjs +102 -26
  34. package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
  35. package/fesm2022/cmat-components-fullscreen.mjs +167 -47
  36. package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
  37. package/fesm2022/cmat-components-highlight.mjs +203 -112
  38. package/fesm2022/cmat-components-highlight.mjs.map +1 -1
  39. package/fesm2022/cmat-components-image-viewer.mjs +489 -215
  40. package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
  41. package/fesm2022/cmat-components-inline-loading.mjs +117 -27
  42. package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
  43. package/fesm2022/cmat-components-json-editor.mjs +276 -230
  44. package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
  45. package/fesm2022/cmat-components-knob-input.mjs +615 -420
  46. package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
  47. package/fesm2022/cmat-components-loading-overlay.mjs +53 -25
  48. package/fesm2022/cmat-components-loading-overlay.mjs.map +1 -1
  49. package/fesm2022/cmat-components-masonry.mjs +120 -40
  50. package/fesm2022/cmat-components-masonry.mjs.map +1 -1
  51. package/fesm2022/cmat-components-material-color-picker.mjs +332 -155
  52. package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
  53. package/fesm2022/cmat-components-material-datetimepicker.mjs +4283 -2504
  54. package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
  55. package/fesm2022/cmat-components-navigation.mjs +3080 -1404
  56. package/fesm2022/cmat-components-navigation.mjs.map +1 -1
  57. package/fesm2022/cmat-components-opt-input.mjs +540 -466
  58. package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
  59. package/fesm2022/cmat-components-org-chart.mjs +528 -125
  60. package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
  61. package/fesm2022/cmat-components-page-header.mjs +141 -32
  62. package/fesm2022/cmat-components-page-header.mjs.map +1 -1
  63. package/fesm2022/cmat-components-pagination.mjs +866 -534
  64. package/fesm2022/cmat-components-pagination.mjs.map +1 -1
  65. package/fesm2022/cmat-components-password-strength.mjs +873 -434
  66. package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
  67. package/fesm2022/cmat-components-popover.mjs +1012 -731
  68. package/fesm2022/cmat-components-popover.mjs.map +1 -1
  69. package/fesm2022/cmat-components-progress-bar.mjs +98 -35
  70. package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
  71. package/fesm2022/cmat-components-qrcode.mjs +463 -287
  72. package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
  73. package/fesm2022/cmat-components-rating.mjs +377 -203
  74. package/fesm2022/cmat-components-rating.mjs.map +1 -1
  75. package/fesm2022/cmat-components-rich-text-editor.mjs +153 -39
  76. package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
  77. package/fesm2022/cmat-components-select-search.mjs +926 -496
  78. package/fesm2022/cmat-components-select-search.mjs.map +1 -1
  79. package/fesm2022/cmat-components-select-table.mjs +1280 -842
  80. package/fesm2022/cmat-components-select-table.mjs.map +1 -1
  81. package/fesm2022/cmat-components-select-tree.mjs +998 -690
  82. package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
  83. package/fesm2022/cmat-components-skeleton.mjs +143 -57
  84. package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
  85. package/fesm2022/cmat-components-speed-dial.mjs +457 -303
  86. package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
  87. package/fesm2022/cmat-components-status-tag.mjs +136 -44
  88. package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
  89. package/fesm2022/cmat-components-table-toolbar.mjs +120 -28
  90. package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
  91. package/fesm2022/cmat-components-timeline.mjs +464 -168
  92. package/fesm2022/cmat-components-timeline.mjs.map +1 -1
  93. package/fesm2022/cmat-components-toast.mjs +346 -262
  94. package/fesm2022/cmat-components-toast.mjs.map +1 -1
  95. package/fesm2022/cmat-components-transfer-picker.mjs +1427 -593
  96. package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
  97. package/fesm2022/cmat-components-treetable.mjs +372 -112
  98. package/fesm2022/cmat-components-treetable.mjs.map +1 -1
  99. package/fesm2022/cmat-components-upload.mjs +904 -410
  100. package/fesm2022/cmat-components-upload.mjs.map +1 -1
  101. package/fesm2022/cmat-components-x6-angular-shape.mjs +153 -170
  102. package/fesm2022/cmat-components-x6-angular-shape.mjs.map +1 -1
  103. package/fesm2022/cmat-directives-animate-on-scroll.mjs +220 -138
  104. package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
  105. package/fesm2022/cmat-directives-arrow-cursor.mjs +246 -193
  106. package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
  107. package/fesm2022/cmat-directives-autofocus.mjs +43 -25
  108. package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
  109. package/fesm2022/cmat-directives-data-exporter.mjs +537 -338
  110. package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
  111. package/fesm2022/cmat-directives-debounce.mjs +162 -76
  112. package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
  113. package/fesm2022/cmat-directives-digit-only.mjs +457 -356
  114. package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
  115. package/fesm2022/cmat-directives-equal-validator.mjs +70 -53
  116. package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
  117. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +180 -132
  118. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
  119. package/fesm2022/cmat-lib-mock-api.mjs +207 -195
  120. package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
  121. package/fesm2022/cmat-pipes-bytes.mjs +50 -30
  122. package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
  123. package/fesm2022/cmat-pipes-date-format.mjs +41 -25
  124. package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
  125. package/fesm2022/cmat-pipes-find-by-key.mjs +44 -26
  126. package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
  127. package/fesm2022/cmat-pipes-group-by.mjs +50 -38
  128. package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
  129. package/fesm2022/cmat-pipes-keys.mjs +44 -31
  130. package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
  131. package/fesm2022/cmat-pipes-secure.mjs +60 -49
  132. package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
  133. package/fesm2022/cmat-pipes-uppercase.mjs +39 -22
  134. package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
  135. package/fesm2022/cmat-reports.mjs +2751 -0
  136. package/fesm2022/cmat-reports.mjs.map +1 -0
  137. package/fesm2022/cmat-services-alert.mjs +249 -277
  138. package/fesm2022/cmat-services-alert.mjs.map +1 -1
  139. package/fesm2022/cmat-services-config.mjs +110 -81
  140. package/fesm2022/cmat-services-config.mjs.map +1 -1
  141. package/fesm2022/cmat-services-confirmation.mjs +184 -73
  142. package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
  143. package/fesm2022/cmat-services-data.mjs +136 -125
  144. package/fesm2022/cmat-services-data.mjs.map +1 -1
  145. package/fesm2022/cmat-services-export-as.mjs +165 -183
  146. package/fesm2022/cmat-services-export-as.mjs.map +1 -1
  147. package/fesm2022/cmat-services-loading.mjs +116 -95
  148. package/fesm2022/cmat-services-loading.mjs.map +1 -1
  149. package/fesm2022/cmat-services-local-storage.mjs +75 -66
  150. package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
  151. package/fesm2022/cmat-services-media-watcher.mjs +69 -64
  152. package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
  153. package/fesm2022/cmat-services-platform.mjs +48 -45
  154. package/fesm2022/cmat-services-platform.mjs.map +1 -1
  155. package/fesm2022/cmat-services-print.mjs +985 -669
  156. package/fesm2022/cmat-services-print.mjs.map +1 -1
  157. package/fesm2022/cmat-services-splash-screen.mjs +53 -38
  158. package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
  159. package/fesm2022/cmat-services-title.mjs +57 -47
  160. package/fesm2022/cmat-services-title.mjs.map +1 -1
  161. package/fesm2022/cmat-services-translation.mjs +79 -68
  162. package/fesm2022/cmat-services-translation.mjs.map +1 -1
  163. package/fesm2022/cmat-services-utils.mjs +424 -517
  164. package/fesm2022/cmat-services-utils.mjs.map +1 -1
  165. package/fesm2022/cmat-validators.mjs +23 -33
  166. package/fesm2022/cmat-validators.mjs.map +1 -1
  167. package/fesm2022/cmat-version.mjs +12 -16
  168. package/fesm2022/cmat-version.mjs.map +1 -1
  169. package/fesm2022/cmat.mjs +39806 -22071
  170. package/fesm2022/cmat.mjs.map +1 -1
  171. package/package.json +5 -1
  172. package/types/cmat-components-adapter.d.ts +145 -156
  173. package/types/cmat-components-breadcrumb.d.ts +108 -86
  174. package/types/cmat-components-card.d.ts +34 -18
  175. package/types/cmat-components-carousel.d.ts +251 -134
  176. package/types/cmat-components-cascade.d.ts +158 -117
  177. package/types/cmat-components-chip-input.d.ts +105 -71
  178. package/types/cmat-components-code-editor.d.ts +59 -34
  179. package/types/cmat-components-color-picker.d.ts +378 -236
  180. package/types/cmat-components-custom-formly.d.ts +776 -814
  181. package/types/cmat-components-data-picker.d.ts +502 -360
  182. package/types/cmat-components-date-range.d.ts +106 -77
  183. package/types/cmat-components-date-time-display.d.ts +36 -13
  184. package/types/cmat-components-drawer.d.ts +91 -61
  185. package/types/cmat-components-empty-state.d.ts +47 -17
  186. package/types/cmat-components-file-preview.d.ts +42 -14
  187. package/types/cmat-components-filter-toolbar.d.ts +57 -25
  188. package/types/cmat-components-form-actions.d.ts +18 -10
  189. package/types/cmat-components-fullscreen.d.ts +21 -13
  190. package/types/cmat-components-highlight.d.ts +33 -26
  191. package/types/cmat-components-image-viewer.d.ts +119 -58
  192. package/types/cmat-components-inline-loading.d.ts +24 -11
  193. package/types/cmat-components-json-editor.d.ts +39 -28
  194. package/types/cmat-components-knob-input.d.ts +172 -101
  195. package/types/cmat-components-loading-overlay.d.ts +8 -11
  196. package/types/cmat-components-masonry.d.ts +27 -14
  197. package/types/cmat-components-material-color-picker.d.ts +56 -42
  198. package/types/cmat-components-material-datetimepicker.d.ts +817 -454
  199. package/types/cmat-components-navigation.d.ts +295 -221
  200. package/types/cmat-components-opt-input.d.ts +111 -90
  201. package/types/cmat-components-org-chart.d.ts +53 -35
  202. package/types/cmat-components-page-header.d.ts +37 -14
  203. package/types/cmat-components-pagination.d.ts +144 -107
  204. package/types/cmat-components-password-strength.d.ts +197 -86
  205. package/types/cmat-components-popover.d.ts +264 -166
  206. package/types/cmat-components-progress-bar.d.ts +17 -14
  207. package/types/cmat-components-qrcode.d.ts +111 -42
  208. package/types/cmat-components-rating.d.ts +105 -59
  209. package/types/cmat-components-rich-text-editor.d.ts +39 -16
  210. package/types/cmat-components-select-search.d.ts +195 -99
  211. package/types/cmat-components-select-table.d.ts +241 -142
  212. package/types/cmat-components-select-tree.d.ts +185 -118
  213. package/types/cmat-components-skeleton.d.ts +55 -32
  214. package/types/cmat-components-speed-dial.d.ts +86 -61
  215. package/types/cmat-components-status-tag.d.ts +42 -24
  216. package/types/cmat-components-table-toolbar.d.ts +30 -12
  217. package/types/cmat-components-timeline.d.ts +83 -51
  218. package/types/cmat-components-toast.d.ts +84 -85
  219. package/types/cmat-components-transfer-picker.d.ts +228 -181
  220. package/types/cmat-components-treetable.d.ts +63 -39
  221. package/types/cmat-components-upload.d.ts +205 -106
  222. package/types/cmat-components-x6-angular-shape.d.ts +29 -37
  223. package/types/cmat-directives-animate-on-scroll.d.ts +48 -30
  224. package/types/cmat-directives-arrow-cursor.d.ts +55 -35
  225. package/types/cmat-directives-autofocus.d.ts +8 -11
  226. package/types/cmat-directives-data-exporter.d.ts +71 -40
  227. package/types/cmat-directives-debounce.d.ts +31 -28
  228. package/types/cmat-directives-digit-only.d.ts +90 -53
  229. package/types/cmat-directives-equal-validator.d.ts +11 -14
  230. package/types/cmat-directives-seamless-auto-scroll.d.ts +42 -29
  231. package/types/cmat-lib-mock-api.d.ts +46 -55
  232. package/types/cmat-pipes-bytes.d.ts +7 -10
  233. package/types/cmat-pipes-date-format.d.ts +7 -10
  234. package/types/cmat-pipes-find-by-key.d.ts +8 -12
  235. package/types/cmat-pipes-group-by.d.ts +11 -15
  236. package/types/cmat-pipes-keys.d.ts +10 -13
  237. package/types/cmat-pipes-secure.d.ts +14 -17
  238. package/types/cmat-pipes-uppercase.d.ts +7 -10
  239. package/types/cmat-reports.d.ts +1131 -0
  240. package/types/cmat-services-alert.d.ts +80 -87
  241. package/types/cmat-services-config.d.ts +37 -43
  242. package/types/cmat-services-confirmation.d.ts +31 -37
  243. package/types/cmat-services-data.d.ts +18 -21
  244. package/types/cmat-services-export-as.d.ts +28 -33
  245. package/types/cmat-services-loading.d.ts +27 -31
  246. package/types/cmat-services-local-storage.d.ts +17 -21
  247. package/types/cmat-services-media-watcher.d.ts +14 -18
  248. package/types/cmat-services-platform.d.ts +8 -11
  249. package/types/cmat-services-print.d.ts +97 -92
  250. package/types/cmat-services-splash-screen.d.ts +11 -14
  251. package/types/cmat-services-title.d.ts +9 -12
  252. package/types/cmat-services-translation.d.ts +19 -22
  253. package/types/cmat-services-utils.d.ts +76 -80
  254. package/types/cmat-validators.d.ts +5 -8
  255. package/types/cmat-version.d.ts +8 -10
  256. package/types/cmat.d.ts +7551 -5194
@@ -1,411 +1,905 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, DestroyRef, Injectable, output, input, model, signal, effect, ChangeDetectionStrategy, ViewEncapsulation, Component, viewChildren, ElementRef, computed, HostListener } from '@angular/core';
3
- import * as i2 from '@angular/material/button';
4
- import { MatButtonModule } from '@angular/material/button';
5
- import * as i2$1 from '@angular/material/icon';
6
- import { MatIconModule } from '@angular/material/icon';
7
- import * as i1 from '@angular/material/list';
8
- import { MatListModule } from '@angular/material/list';
9
- import { CmatMediaWatcherService } from 'cmat/services/media-watcher';
10
- import { NgClass } from '@angular/common';
11
- import { HttpClient, HttpEventType } from '@angular/common/http';
12
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
13
- import * as i3 from '@angular/material/progress-bar';
14
- import { MatProgressBarModule } from '@angular/material/progress-bar';
15
- import * as i4 from '@angular/material/tooltip';
16
- import { MatTooltipModule } from '@angular/material/tooltip';
17
- import { CmatBytesPipe } from 'cmat/pipes/bytes';
18
- import { CmatUtilsService } from 'cmat/services/utils';
19
- import { saveAs } from 'file-saver-es';
20
- import { CmatUrlStateConfigService } from 'cmat/services/config';
21
- import { catchError, map, tap } from 'rxjs';
22
-
23
- class CmatFilesUtilService {
24
- constructor() {
25
- this._http = inject(HttpClient);
26
- this._urlStateConfigService = inject(CmatUrlStateConfigService);
27
- this._destroyRef = inject(DestroyRef);
28
- this._config = this._urlStateConfigService.config;
29
- }
30
- downloadFile(fileId, isStream = true) {
31
- return this._http.get(`${this._config().fileUrl}/download/${fileId}`, {
32
- headers: CmatUtilsService.getRequestCryptoHeaders(fileId),
33
- observe: 'response',
34
- reportProgress: true,
35
- responseType: 'blob',
36
- params: {
37
- isStream
38
- }
39
- }).pipe(catchError(CmatUtilsService.handleError));
40
- }
41
- downloadFileZip(fileIds) {
42
- return this._http.post(`${this._config().fileUrl}/download`, fileIds, {
43
- headers: CmatUtilsService.getRequestCryptoHeaders('fileZip'),
44
- observe: 'response',
45
- reportProgress: true,
46
- responseType: 'blob',
47
- }).pipe(catchError(CmatUtilsService.handleError));
48
- }
49
- uploadFile(file) {
50
- return this._http.post(`${this._config().fileUrl}/upload`, file, {
51
- headers: CmatUtilsService.getRequestCryptoHeaders('files'),
52
- observe: 'events',
53
- reportProgress: true,
54
- responseType: 'json'
55
- }).pipe(catchError(CmatUtilsService.handleError));
56
- }
57
- uploadFileToProcessed(file) {
58
- return this._http.post(`${this._config().fileUrl}/upload/finish`, file, {
59
- headers: CmatUtilsService.getRequestCryptoHeaders('files'),
60
- observe: 'events',
61
- reportProgress: true,
62
- responseType: 'json'
63
- }).pipe(catchError(CmatUtilsService.handleError));
64
- }
65
- switchPublic(fileId, isPublic) {
66
- return this._http.patch(`${this._config().fileUrl}/switch-public/${fileId}`, {
67
- id: fileId,
68
- isPublic
69
- }, {
70
- headers: CmatUtilsService.getRequestCryptoHeaders('files-switch-public')
71
- }).pipe(catchError((err) => CmatUtilsService.handleError(err)));
72
- }
73
- deleteFile(fileId) {
74
- return this._http.delete(`${this._config().fileUrl}/${fileId}`, {
75
- headers: CmatUtilsService.getRequestCryptoHeaders(fileId)
76
- }).pipe(catchError((err) => CmatUtilsService.handleError(err)));
77
- }
78
- getFileList(queryData, pageIndex = -1, pageSize = -1) {
79
- if (this._config().enableDataProtect) {
80
- return this._http.post(`${this._config().fileUrl}/${pageIndex}/${pageSize}`, CmatUtilsService.getEncryptData(JSON.stringify(queryData)), {
81
- headers: CmatUtilsService.getRequestCryptoHeaders('fileList'),
82
- responseType: 'text'
83
- })
84
- .pipe(map((res) => JSON.parse(CmatUtilsService.getDecryptData(res))), catchError(err => CmatUtilsService.handleError(err)));
85
- }
86
- else {
87
- return this._http.post(`${this._config().fileUrl}/${pageIndex}/${pageSize}`, queryData, {
88
- headers: CmatUtilsService.getRequestCryptoHeaders('fileList'),
89
- responseType: 'json'
90
- })
91
- .pipe(tap((res) => res), catchError(err => CmatUtilsService.handleError(err)));
92
- }
93
- }
94
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatFilesUtilService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
95
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatFilesUtilService, providedIn: 'root' }); }
96
- }
97
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatFilesUtilService, decorators: [{
98
- type: Injectable,
99
- args: [{
100
- providedIn: 'root'
101
- }]
102
- }] });
103
-
104
- class CmatUploadComponent {
105
- constructor() {
106
- this.removeEvent = output();
107
- this.uploadEvent = output();
108
- this.fileAlias = input('fileData', /* @ts-ignore */
109
- ...(ngDevMode ? [{ debugName: "fileAlias" }] : /* istanbul ignore next */ []));
110
- this.filePath = input('', /* @ts-ignore */
111
- ...(ngDevMode ? [{ debugName: "filePath" }] : /* istanbul ignore next */ []));
112
- this.fileCategory = input('', /* @ts-ignore */
113
- ...(ngDevMode ? [{ debugName: "fileCategory" }] : /* istanbul ignore next */ []));
114
- this.isPublic = input(false, /* @ts-ignore */
115
- ...(ngDevMode ? [{ debugName: "isPublic" }] : /* istanbul ignore next */ []));
116
- this.editMode = input(false, /* @ts-ignore */
117
- ...(ngDevMode ? [{ debugName: "editMode" }] : /* istanbul ignore next */ []));
118
- this.autoUpload = input(true, /* @ts-ignore */
119
- ...(ngDevMode ? [{ debugName: "autoUpload" }] : /* istanbul ignore next */ []));
120
- this.file = model.required(/* @ts-ignore */
121
- ...(ngDevMode ? [{ debugName: "file" }] : /* istanbul ignore next */ []));
122
- this.id = input(null, /* @ts-ignore */
123
- ...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
124
- this.progressPercentage = signal(0, /* @ts-ignore */
125
- ...(ngDevMode ? [{ debugName: "progressPercentage" }] : /* istanbul ignore next */ []));
126
- this.loaded = signal(0, /* @ts-ignore */
127
- ...(ngDevMode ? [{ debugName: "loaded" }] : /* istanbul ignore next */ []));
128
- this.total = signal(0, /* @ts-ignore */
129
- ...(ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []));
130
- this.isUploading = signal(false, /* @ts-ignore */
131
- ...(ngDevMode ? [{ debugName: "isUploading" }] : /* istanbul ignore next */ []));
132
- this.uploadedId = signal(null, /* @ts-ignore */
133
- ...(ngDevMode ? [{ debugName: "uploadedId" }] : /* istanbul ignore next */ []));
134
- this._fileService = inject(CmatFilesUtilService);
135
- this._destroyRef = inject(DestroyRef);
136
- effect(() => {
137
- const file = this.file();
138
- this.total.set(file.size);
139
- });
140
- }
141
- get fileType() {
142
- return CmatUtilsService.getFileType(this.file().type);
143
- }
144
- get fileSize() {
145
- return Number(this.file().size ?? this.file().length);
146
- }
147
- ngOnInit() {
148
- if (this.autoUpload() && this.id() === null) {
149
- this.upload();
150
- }
151
- }
152
- upload() {
153
- this.isUploading.set(true);
154
- const file = this.file();
155
- const fileModel = {
156
- id: null,
157
- fileName: file.name,
158
- length: file.size,
159
- fileCategory: this.fileCategory(),
160
- isPublic: this.isPublic(),
161
- filePath: this.filePath(),
162
- fileType: this.fileType,
163
- data: file.data,
164
- };
165
- const formData = new FormData();
166
- // file.data 优先;若不存在则 file 本身可能是 File/Blob(直接使用时)
167
- const fileBlob = file.data ?? file;
168
- if (fileBlob instanceof Blob) {
169
- formData.set(this.fileAlias(), fileBlob, file.fileName ?? file.name);
170
- }
171
- formData.append('fileInfo', JSON.stringify(fileModel));
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));
179
- this.loaded.set(event.loaded);
180
- this.total.set(event.total);
181
- }
182
- if (event.type === HttpEventType.Response) {
183
- const fileId = typeof event.body?.id === 'string' ? event.body.id : undefined;
184
- if (!fileId) {
185
- this.isUploading.set(false);
186
- return;
187
- }
188
- this.uploadedId.set(fileId);
189
- file.id = fileId;
190
- this.file.set(file);
191
- this.isUploading.set(false);
192
- this.uploadEvent.emit(this.file());
193
- }
194
- });
195
- }
196
- download() {
197
- const id = this.uploadedId() ?? this.id();
198
- if (!id)
199
- return;
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);
207
- });
208
- }
209
- remove() {
210
- this.removeEvent.emit(this);
211
- }
212
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatUploadComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
213
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", 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 items-center gap-3 px-3 py-2\">\r\n <mat-icon class=\"icon-size-5 text-slate-400 dark:text-slate-500 flex-none\" [svgIcon]=\"fileType\"></mat-icon>\r\n <span\r\n matTooltip=\"{{ file().name }}\"\r\n class=\"text-sm flex-auto whitespace-nowrap overflow-hidden text-ellipsis\"\r\n >{{ file().name }}</span>\r\n <span class=\"text-xs text-secondary whitespace-nowrap flex-none\">{{ fileSize | cmatBytes }}</span>\r\n <span class=\"flex flex-row gap-0.5 print:hidden flex-none\">\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 <div class=\"px-3 pb-2\">\r\n <mat-progress-bar [value]=\"progressPercentage()\"></mat-progress-bar>\r\n <div class=\"text-xs text-secondary mt-1\">\r\n {{ progressPercentage() }}% \u00B7 {{ loaded() | cmatBytes }} / {{ total() | cmatBytes }}\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n", dependencies: [{ kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.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$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatProgressBarModule }, { kind: "component", type: i3.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 }); }
214
- }
215
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatUploadComponent, decorators: [{
216
- type: Component,
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 items-center gap-3 px-3 py-2\">\r\n <mat-icon class=\"icon-size-5 text-slate-400 dark:text-slate-500 flex-none\" [svgIcon]=\"fileType\"></mat-icon>\r\n <span\r\n matTooltip=\"{{ file().name }}\"\r\n class=\"text-sm flex-auto whitespace-nowrap overflow-hidden text-ellipsis\"\r\n >{{ file().name }}</span>\r\n <span class=\"text-xs text-secondary whitespace-nowrap flex-none\">{{ fileSize | cmatBytes }}</span>\r\n <span class=\"flex flex-row gap-0.5 print:hidden flex-none\">\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 <div class=\"px-3 pb-2\">\r\n <mat-progress-bar [value]=\"progressPercentage()\"></mat-progress-bar>\r\n <div class=\"text-xs text-secondary mt-1\">\r\n {{ progressPercentage() }}% \u00B7 {{ loaded() | cmatBytes }} / {{ total() | cmatBytes }}\r\n </div>\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 }] }] } });
226
-
227
- class CmatUploadQueueComponent {
228
- constructor() {
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 */ []));
254
- this.id = 'cmatupload-' + crypto.randomUUID().slice(0, 8);
255
- this.fileUploads = viewChildren(CmatUploadComponent, /* @ts-ignore */
256
- ...(ngDevMode ? [{ debugName: "fileUploads" }] : /* istanbul ignore next */ []));
257
- this._cmatMediaWatcherService = inject(CmatMediaWatcherService);
258
- this._elementRef = inject(ElementRef);
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 */ []));
264
- }
265
- onDrop(event) {
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)
275
- return;
276
- for (const file of event.dataTransfer.files) {
277
- if (this.accept()?.includes(file.type))
278
- this.add(file);
279
- }
280
- event.preventDefault();
281
- event.stopPropagation();
282
- }
283
- onDropOver(event) {
284
- // 同样检查是否是 Angular DnD 的内部拖拽
285
- const hasAngularDndData = event.dataTransfer?.types.includes('application/x-ng-dnd');
286
- if (hasAngularDndData) {
287
- return; // 不拦截,让 DnD 库处理
288
- }
289
- event.preventDefault();
290
- }
291
- ngAfterViewInit() {
292
- const fileUpload = this._elementRef.nativeElement.querySelector(`#${this.id}`);
293
- if (!(fileUpload instanceof HTMLInputElement)) {
294
- return;
295
- }
296
- fileUpload.onchange = () => {
297
- for (let index = 0; index < (fileUpload.files?.length ?? 0); index++) {
298
- const file = fileUpload.files[index];
299
- this.add(file);
300
- }
301
- };
302
- }
303
- add(file) {
304
- if (!this.isFileTypeAccepted(file.type)) {
305
- return;
306
- }
307
- const filesData = this.filesData() ?? [];
308
- // 将原生 File 转换为 FileModel,确保 upload 组件能正确读取 data 字段
309
- const fileModel = {
310
- fileName: file.name,
311
- length: file.size,
312
- fileType: 'file',
313
- filePath: '',
314
- isPublic: false,
315
- fileCategory: '',
316
- uploadDate: new Date(),
317
- data: file,
318
- name: file.name,
319
- size: file.size,
320
- type: file.type,
321
- };
322
- let newFilesData;
323
- if (!(!this.multiple() && filesData.length > 0)) {
324
- newFilesData = [...filesData, fileModel];
325
- }
326
- else {
327
- const firstUpload = this.fileUploads()[0];
328
- if (firstUpload?.id() === null) {
329
- newFilesData = [...filesData, fileModel];
330
- firstUpload.remove();
331
- }
332
- else {
333
- return;
334
- }
335
- }
336
- this.filesData.set(newFilesData);
337
- }
338
- upload(event) {
339
- this.outputUploadIdEvent.emit(event.id ?? '');
340
- this.outputFilesDataEvent.emit(this.filesData());
341
- }
342
- remove(event) {
343
- const filesData = this.filesData();
344
- if (filesData) {
345
- const index = filesData.findIndex((j) => j === event.file());
346
- if (index > -1) {
347
- if (event.file().id) {
348
- this.outputRemoveIdEvent.emit(event.file().id);
349
- }
350
- const newData = filesData.filter((j) => j !== event.file());
351
- this.filesData.set(newData);
352
- this.outputFilesDataEvent.emit(newData);
353
- }
354
- }
355
- }
356
- uploadAll() {
357
- this.fileUploads().forEach((fileUpload) => {
358
- if (fileUpload.id() === null) {
359
- fileUpload.upload();
360
- }
361
- });
362
- }
363
- removeAll() {
364
- this.fileUploads().forEach((fileUpload) => {
365
- fileUpload.remove();
366
- });
367
- }
368
- choose() {
369
- this._elementRef.nativeElement
370
- .querySelector(`#${this.id}`)
371
- ?.dispatchEvent(new MouseEvent('click'));
372
- }
373
- isFileTypeAccepted(fileType) {
374
- const accept = this.accept();
375
- if (!accept || accept === '') {
376
- return true;
377
- }
378
- const acceptedTypes = accept.split(',').map(type => type.trim());
379
- return acceptedTypes.some((type) => {
380
- if (type.endsWith('/*')) {
381
- const prefix = type.slice(0, -1);
382
- return fileType.startsWith(prefix);
383
- }
384
- return fileType === type;
385
- });
386
- }
387
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatUploadQueueComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
388
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", 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: "<div class=\"rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden bg-card\">\r\n <div class=\"flex items-center gap-2 px-3 py-2 bg-primary-50 dark:bg-primary-900/30 border-b border-primary-200 dark:border-primary-700\">\r\n <mat-icon class=\"icon-size-5 text-primary-500\" [svgIcon]=\"'heroicons_outline:paper-clip'\"></mat-icon>\r\n <span class=\"text-sm font-semibold text-primary-500\">\r\n {{ title() }}\r\n @if (required()) {\r\n <span>*</span>\r\n }\r\n </span>\r\n </div>\r\n <input type=\"file\" class=\"hidden\" [id]=\"id\" [multiple]=\"multiple()\" [accept]=\"accept()\" />\r\n\r\n @if (editMode()) {\r\n <div class=\"flex flex-row gap-1 p-2 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><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><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 </div>\r\n }\r\n\r\n <div class=\"border-t\">\r\n @if (!filesData() || filesData().length === 0) {\r\n <div class=\"flex flex-col items-center justify-center py-4 text-hint\">\r\n <mat-icon class=\"w-16! h-16! text-4xl! mb-3\" [svgIcon]=\"'heroicons_outline:folder-open'\"></mat-icon>\r\n <span class=\"text-sm\">\u6682\u65E0\u5185\u5BB9</span>\r\n </div>\r\n }@else{\r\n <mat-list>\r\n @for (file of filesData(); track $index) {\r\n <mat-list-item class=\"cmat-upload-file-item h-full\">\r\n <cmat-upload class=\"my-2\" [fileAlias]=\"fileAlias()\" [filePath]=\"filePath()\" [fileCategory]=\"fileCategory()\"\r\n [autoUpload]=\"autoUpload()\" [editMode]=\"editMode()\" [file]=\"file\" [id]=\"file.id || null\"\r\n [isPublic]=\"isPublic()\" (removeEvent)=\"remove($event)\" (uploadEvent)=\"upload($event)\"></cmat-upload>\r\n </mat-list-item>\r\n }\r\n </mat-list>\r\n }\r\n </div>\r\n</div>\r\n", dependencies: [{ kind: "ngmodule", type: MatListModule }, { kind: "component", type: i1.MatList, selector: "mat-list", exportAs: ["matList"] }, { kind: "component", type: i1.MatListItem, selector: "mat-list-item, a[mat-list-item], button[mat-list-item]", inputs: ["activated"], exportAs: ["matListItem"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.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: i2.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$1.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 }); }
389
- }
390
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatUploadQueueComponent, decorators: [{
391
- type: Component,
392
- args: [{ selector: 'cmat-upload-queue', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, exportAs: 'cmatUploadQueue', imports: [
393
- MatListModule,
394
- MatButtonModule,
395
- MatIconModule,
396
- CmatUploadComponent,
397
- ], template: "<div class=\"rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden bg-card\">\r\n <div class=\"flex items-center gap-2 px-3 py-2 bg-primary-50 dark:bg-primary-900/30 border-b border-primary-200 dark:border-primary-700\">\r\n <mat-icon class=\"icon-size-5 text-primary-500\" [svgIcon]=\"'heroicons_outline:paper-clip'\"></mat-icon>\r\n <span class=\"text-sm font-semibold text-primary-500\">\r\n {{ title() }}\r\n @if (required()) {\r\n <span>*</span>\r\n }\r\n </span>\r\n </div>\r\n <input type=\"file\" class=\"hidden\" [id]=\"id\" [multiple]=\"multiple()\" [accept]=\"accept()\" />\r\n\r\n @if (editMode()) {\r\n <div class=\"flex flex-row gap-1 p-2 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><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><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 </div>\r\n }\r\n\r\n <div class=\"border-t\">\r\n @if (!filesData() || filesData().length === 0) {\r\n <div class=\"flex flex-col items-center justify-center py-4 text-hint\">\r\n <mat-icon class=\"w-16! h-16! text-4xl! mb-3\" [svgIcon]=\"'heroicons_outline:folder-open'\"></mat-icon>\r\n <span class=\"text-sm\">\u6682\u65E0\u5185\u5BB9</span>\r\n </div>\r\n }@else{\r\n <mat-list>\r\n @for (file of filesData(); track $index) {\r\n <mat-list-item class=\"cmat-upload-file-item h-full\">\r\n <cmat-upload class=\"my-2\" [fileAlias]=\"fileAlias()\" [filePath]=\"filePath()\" [fileCategory]=\"fileCategory()\"\r\n [autoUpload]=\"autoUpload()\" [editMode]=\"editMode()\" [file]=\"file\" [id]=\"file.id || null\"\r\n [isPublic]=\"isPublic()\" (removeEvent)=\"remove($event)\" (uploadEvent)=\"upload($event)\"></cmat-upload>\r\n </mat-list-item>\r\n }\r\n </mat-list>\r\n }\r\n </div>\r\n</div>\r\n" }]
398
- }], 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: [{
399
- type: HostListener,
400
- args: ['drop', ['$event']]
401
- }], onDropOver: [{
402
- type: HostListener,
403
- args: ['dragover', ['$event']]
404
- }] } });
405
-
406
- /**
407
- * Generated bundle index. Do not edit.
408
- */
409
-
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, HostListener, Injectable, ViewEncapsulation, computed, effect, inject, input, model, output, signal, viewChildren } from "@angular/core";
3
+ import * as i1$1 from "@angular/material/button";
4
+ import { MatButtonModule } from "@angular/material/button";
5
+ import * as i2 from "@angular/material/icon";
6
+ import { MatIconModule } from "@angular/material/icon";
7
+ import * as i1 from "@angular/material/list";
8
+ import { MatListModule } from "@angular/material/list";
9
+ import { CmatMediaWatcherService } from "cmat/services/media-watcher";
10
+ import { NgClass } from "@angular/common";
11
+ import { HttpClient, HttpEventType } from "@angular/common/http";
12
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
13
+ import * as i3 from "@angular/material/progress-bar";
14
+ import { MatProgressBarModule } from "@angular/material/progress-bar";
15
+ import * as i4 from "@angular/material/tooltip";
16
+ import { MatTooltipModule } from "@angular/material/tooltip";
17
+ import { CmatBytesPipe } from "cmat/pipes/bytes";
18
+ import { CmatUtilsService } from "cmat/services/utils";
19
+ import { saveAs } from "file-saver-es";
20
+ import { CmatUrlStateConfigService } from "cmat/services/config";
21
+ import { catchError, map, tap } from "rxjs";
22
+ var CmatFilesUtilService = class CmatFilesUtilService {
23
+ constructor() {
24
+ this._http = inject(HttpClient);
25
+ this._urlStateConfigService = inject(CmatUrlStateConfigService);
26
+ this._destroyRef = inject(DestroyRef);
27
+ this._config = this._urlStateConfigService.config;
28
+ }
29
+ downloadFile(fileId, isStream = true) {
30
+ return this._http.get(`${this._config().fileUrl}/download/${fileId}`, {
31
+ headers: CmatUtilsService.getRequestCryptoHeaders(fileId),
32
+ observe: "response",
33
+ reportDownloadProgress: true,
34
+ responseType: "blob",
35
+ params: { isStream }
36
+ }).pipe(catchError(CmatUtilsService.handleError));
37
+ }
38
+ downloadFileZip(fileIds) {
39
+ return this._http.post(`${this._config().fileUrl}/download`, fileIds, {
40
+ headers: CmatUtilsService.getRequestCryptoHeaders("fileZip"),
41
+ observe: "response",
42
+ reportDownloadProgress: true,
43
+ responseType: "blob"
44
+ }).pipe(catchError(CmatUtilsService.handleError));
45
+ }
46
+ uploadFile(file) {
47
+ return this._http.post(`${this._config().fileUrl}/upload`, file, {
48
+ headers: CmatUtilsService.getRequestCryptoHeaders("files"),
49
+ observe: "events",
50
+ reportUploadProgress: true,
51
+ responseType: "json"
52
+ }).pipe(catchError(CmatUtilsService.handleError));
53
+ }
54
+ uploadFileToProcessed(file) {
55
+ return this._http.post(`${this._config().fileUrl}/upload/finish`, file, {
56
+ headers: CmatUtilsService.getRequestCryptoHeaders("files"),
57
+ observe: "events",
58
+ reportUploadProgress: true,
59
+ responseType: "json"
60
+ }).pipe(catchError(CmatUtilsService.handleError));
61
+ }
62
+ switchPublic(fileId, isPublic) {
63
+ return this._http.patch(`${this._config().fileUrl}/switch-public/${fileId}`, {
64
+ id: fileId,
65
+ isPublic
66
+ }, { headers: CmatUtilsService.getRequestCryptoHeaders("files-switch-public") }).pipe(catchError((err) => CmatUtilsService.handleError(err)));
67
+ }
68
+ deleteFile(fileId) {
69
+ return this._http.delete(`${this._config().fileUrl}/${fileId}`, { headers: CmatUtilsService.getRequestCryptoHeaders(fileId) }).pipe(catchError((err) => CmatUtilsService.handleError(err)));
70
+ }
71
+ getFileList(queryData, pageIndex = -1, pageSize = -1) {
72
+ if (this._config().enableDataProtect) return this._http.post(`${this._config().fileUrl}/${pageIndex}/${pageSize}`, CmatUtilsService.getEncryptData(JSON.stringify(queryData)), {
73
+ headers: CmatUtilsService.getRequestCryptoHeaders("fileList"),
74
+ responseType: "text"
75
+ }).pipe(map((res) => JSON.parse(CmatUtilsService.getDecryptData(res))), catchError((err) => CmatUtilsService.handleError(err)));
76
+ else return this._http.post(`${this._config().fileUrl}/${pageIndex}/${pageSize}`, queryData, {
77
+ headers: CmatUtilsService.getRequestCryptoHeaders("fileList"),
78
+ responseType: "json"
79
+ }).pipe(tap((res) => res), catchError((err) => CmatUtilsService.handleError(err)));
80
+ }
81
+ static {
82
+ this.ɵfac = i0.ɵɵngDeclareFactory({
83
+ minVersion: "12.0.0",
84
+ version: "22.2.3",
85
+ ngImport: i0,
86
+ type: CmatFilesUtilService,
87
+ deps: [],
88
+ target: i0.ɵɵFactoryTarget.Injectable
89
+ });
90
+ }
91
+ static {
92
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
93
+ minVersion: "12.0.0",
94
+ version: "22.2.3",
95
+ ngImport: i0,
96
+ type: CmatFilesUtilService,
97
+ providedIn: "root"
98
+ });
99
+ }
100
+ };
101
+ i0.ɵɵngDeclareClassMetadata({
102
+ minVersion: "12.0.0",
103
+ version: "22.2.3",
104
+ ngImport: i0,
105
+ type: CmatFilesUtilService,
106
+ decorators: [{
107
+ type: Injectable,
108
+ args: [{ providedIn: "root" }]
109
+ }]
110
+ });
111
+ var CmatUploadComponent = class CmatUploadComponent {
112
+ constructor() {
113
+ this.removeEvent = output();
114
+ this.uploadEvent = output();
115
+ this.fileAlias = input("fileData", ...ngDevMode ? [{ debugName: "fileAlias" }] : /* istanbul ignore next */ []);
116
+ this.filePath = input("", ...ngDevMode ? [{ debugName: "filePath" }] : /* istanbul ignore next */ []);
117
+ this.fileCategory = input("", ...ngDevMode ? [{ debugName: "fileCategory" }] : /* istanbul ignore next */ []);
118
+ this.isPublic = input(false, ...ngDevMode ? [{ debugName: "isPublic" }] : /* istanbul ignore next */ []);
119
+ this.editMode = input(false, ...ngDevMode ? [{ debugName: "editMode" }] : /* istanbul ignore next */ []);
120
+ this.autoUpload = input(true, ...ngDevMode ? [{ debugName: "autoUpload" }] : /* istanbul ignore next */ []);
121
+ this.file = model.required(...ngDevMode ? [{ debugName: "file" }] : /* istanbul ignore next */ []);
122
+ this.id = input(null, ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
123
+ this.progressPercentage = signal(0, ...ngDevMode ? [{ debugName: "progressPercentage" }] : /* istanbul ignore next */ []);
124
+ this.loaded = signal(0, ...ngDevMode ? [{ debugName: "loaded" }] : /* istanbul ignore next */ []);
125
+ this.total = signal(0, ...ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []);
126
+ this.isUploading = signal(false, ...ngDevMode ? [{ debugName: "isUploading" }] : /* istanbul ignore next */ []);
127
+ this.uploadedId = signal(null, ...ngDevMode ? [{ debugName: "uploadedId" }] : /* istanbul ignore next */ []);
128
+ this._fileService = inject(CmatFilesUtilService);
129
+ this._destroyRef = inject(DestroyRef);
130
+ effect(() => {
131
+ const file = this.file();
132
+ this.total.set(file.size);
133
+ });
134
+ }
135
+ get fileType() {
136
+ return CmatUtilsService.getFileType(this.file().type);
137
+ }
138
+ get fileSize() {
139
+ return Number(this.file().size ?? this.file().length);
140
+ }
141
+ ngOnInit() {
142
+ if (this.autoUpload() && this.id() === null) this.upload();
143
+ }
144
+ upload() {
145
+ this.isUploading.set(true);
146
+ const file = this.file();
147
+ const fileModel = {
148
+ id: null,
149
+ fileName: file.name,
150
+ length: file.size,
151
+ fileCategory: this.fileCategory(),
152
+ isPublic: this.isPublic(),
153
+ filePath: this.filePath(),
154
+ fileType: this.fileType,
155
+ data: file.data
156
+ };
157
+ const formData = new FormData();
158
+ const fileBlob = file.data ?? file;
159
+ if (fileBlob instanceof Blob) formData.set(this.fileAlias(), fileBlob, file.fileName ?? file.name);
160
+ formData.append("fileInfo", JSON.stringify(fileModel));
161
+ this._fileService.uploadFile(formData).pipe(takeUntilDestroyed(this._destroyRef)).subscribe((event) => {
162
+ if (event.type === HttpEventType.UploadProgress && typeof event.total === "number") {
163
+ this.progressPercentage.set(Math.floor(event.loaded * 100 / event.total));
164
+ this.loaded.set(event.loaded);
165
+ this.total.set(event.total);
166
+ }
167
+ if (event.type === HttpEventType.Response) {
168
+ const fileId = typeof event.body?.id === "string" ? event.body.id : void 0;
169
+ if (!fileId) {
170
+ this.isUploading.set(false);
171
+ return;
172
+ }
173
+ this.uploadedId.set(fileId);
174
+ file.id = fileId;
175
+ this.file.set(file);
176
+ this.isUploading.set(false);
177
+ this.uploadEvent.emit(this.file());
178
+ }
179
+ });
180
+ }
181
+ download() {
182
+ const id = this.uploadedId() ?? this.id();
183
+ if (!id) return;
184
+ this._fileService.downloadFile(id).pipe(takeUntilDestroyed(this._destroyRef)).subscribe((file) => {
185
+ saveAs(new Blob([file.body ?? new Blob()], { type: "text/plain;charset=utf-8" }), this.file().name);
186
+ });
187
+ }
188
+ remove() {
189
+ this.removeEvent.emit(this);
190
+ }
191
+ static {
192
+ this.ɵfac = i0.ɵɵngDeclareFactory({
193
+ minVersion: "12.0.0",
194
+ version: "22.2.3",
195
+ ngImport: i0,
196
+ type: CmatUploadComponent,
197
+ deps: [],
198
+ target: i0.ɵɵFactoryTarget.Component
199
+ });
200
+ }
201
+ static {
202
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
203
+ minVersion: "17.0.0",
204
+ version: "22.2.3",
205
+ type: CmatUploadComponent,
206
+ isStandalone: true,
207
+ selector: "cmat-upload",
208
+ inputs: {
209
+ fileAlias: {
210
+ classPropertyName: "fileAlias",
211
+ publicName: "fileAlias",
212
+ isSignal: true,
213
+ isRequired: false,
214
+ transformFunction: null
215
+ },
216
+ filePath: {
217
+ classPropertyName: "filePath",
218
+ publicName: "filePath",
219
+ isSignal: true,
220
+ isRequired: false,
221
+ transformFunction: null
222
+ },
223
+ fileCategory: {
224
+ classPropertyName: "fileCategory",
225
+ publicName: "fileCategory",
226
+ isSignal: true,
227
+ isRequired: false,
228
+ transformFunction: null
229
+ },
230
+ isPublic: {
231
+ classPropertyName: "isPublic",
232
+ publicName: "isPublic",
233
+ isSignal: true,
234
+ isRequired: false,
235
+ transformFunction: null
236
+ },
237
+ editMode: {
238
+ classPropertyName: "editMode",
239
+ publicName: "editMode",
240
+ isSignal: true,
241
+ isRequired: false,
242
+ transformFunction: null
243
+ },
244
+ autoUpload: {
245
+ classPropertyName: "autoUpload",
246
+ publicName: "autoUpload",
247
+ isSignal: true,
248
+ isRequired: false,
249
+ transformFunction: null
250
+ },
251
+ file: {
252
+ classPropertyName: "file",
253
+ publicName: "file",
254
+ isSignal: true,
255
+ isRequired: true,
256
+ transformFunction: null
257
+ },
258
+ id: {
259
+ classPropertyName: "id",
260
+ publicName: "id",
261
+ isSignal: true,
262
+ isRequired: false,
263
+ transformFunction: null
264
+ }
265
+ },
266
+ outputs: {
267
+ removeEvent: "removeEvent",
268
+ uploadEvent: "uploadEvent",
269
+ file: "fileChange"
270
+ },
271
+ exportAs: ["cmatUpload"],
272
+ ngImport: i0,
273
+ template: "<div class=\"flex flex-col\">\r\n <div class=\"flex items-center gap-3 px-3 py-2\">\r\n <mat-icon class=\"icon-size-5 text-slate-400 dark:text-slate-500 flex-none\" [svgIcon]=\"fileType\"></mat-icon>\r\n <span\r\n matTooltip=\"{{ file().name }}\"\r\n class=\"text-sm flex-auto whitespace-nowrap overflow-hidden text-ellipsis\"\r\n >{{ file().name }}</span>\r\n <span class=\"text-xs text-secondary whitespace-nowrap flex-none\">{{ fileSize | cmatBytes }}</span>\r\n <span class=\"flex flex-row gap-0.5 print:hidden flex-none\">\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 <div class=\"px-3 pb-2\">\r\n <mat-progress-bar [value]=\"progressPercentage()\"></mat-progress-bar>\r\n <div class=\"text-xs text-secondary mt-1\">\r\n {{ progressPercentage() }}% · {{ loaded() | cmatBytes }} / {{ total() | cmatBytes }}\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n",
274
+ dependencies: [
275
+ {
276
+ kind: "ngmodule",
277
+ type: MatButtonModule
278
+ },
279
+ {
280
+ kind: "component",
281
+ type: i1$1.MatIconButton,
282
+ selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
283
+ exportAs: ["matButton", "matAnchor"]
284
+ },
285
+ {
286
+ kind: "ngmodule",
287
+ type: MatIconModule
288
+ },
289
+ {
290
+ kind: "component",
291
+ type: i2.MatIcon,
292
+ selector: "mat-icon",
293
+ inputs: [
294
+ "color",
295
+ "inline",
296
+ "svgIcon",
297
+ "fontSet",
298
+ "fontIcon"
299
+ ],
300
+ exportAs: ["matIcon"]
301
+ },
302
+ {
303
+ kind: "ngmodule",
304
+ type: MatProgressBarModule
305
+ },
306
+ {
307
+ kind: "component",
308
+ type: i3.MatProgressBar,
309
+ selector: "mat-progress-bar",
310
+ inputs: [
311
+ "color",
312
+ "value",
313
+ "bufferValue",
314
+ "mode"
315
+ ],
316
+ outputs: ["animationEnd"],
317
+ exportAs: ["matProgressBar"]
318
+ },
319
+ {
320
+ kind: "ngmodule",
321
+ type: MatTooltipModule
322
+ },
323
+ {
324
+ kind: "directive",
325
+ type: i4.MatTooltip,
326
+ selector: "[matTooltip]",
327
+ inputs: [
328
+ "matTooltipPosition",
329
+ "matTooltipPositionAtOrigin",
330
+ "matTooltipDisabled",
331
+ "matTooltipShowDelay",
332
+ "matTooltipHideDelay",
333
+ "matTooltipTouchGestures",
334
+ "matTooltip",
335
+ "matTooltipClass"
336
+ ],
337
+ exportAs: ["matTooltip"]
338
+ },
339
+ {
340
+ kind: "directive",
341
+ type: NgClass,
342
+ selector: "[ngClass]",
343
+ inputs: ["class", "ngClass"]
344
+ },
345
+ {
346
+ kind: "pipe",
347
+ type: CmatBytesPipe,
348
+ name: "cmatBytes"
349
+ }
350
+ ],
351
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
352
+ encapsulation: i0.ViewEncapsulation.None
353
+ });
354
+ }
355
+ };
356
+ i0.ɵɵngDeclareClassMetadata({
357
+ minVersion: "12.0.0",
358
+ version: "22.2.3",
359
+ ngImport: i0,
360
+ type: CmatUploadComponent,
361
+ decorators: [{
362
+ type: Component,
363
+ args: [{
364
+ selector: "cmat-upload",
365
+ encapsulation: ViewEncapsulation.None,
366
+ changeDetection: ChangeDetectionStrategy.OnPush,
367
+ exportAs: "cmatUpload",
368
+ imports: [
369
+ MatButtonModule,
370
+ MatIconModule,
371
+ MatProgressBarModule,
372
+ MatTooltipModule,
373
+ CmatBytesPipe,
374
+ NgClass
375
+ ],
376
+ template: "<div class=\"flex flex-col\">\r\n <div class=\"flex items-center gap-3 px-3 py-2\">\r\n <mat-icon class=\"icon-size-5 text-slate-400 dark:text-slate-500 flex-none\" [svgIcon]=\"fileType\"></mat-icon>\r\n <span\r\n matTooltip=\"{{ file().name }}\"\r\n class=\"text-sm flex-auto whitespace-nowrap overflow-hidden text-ellipsis\"\r\n >{{ file().name }}</span>\r\n <span class=\"text-xs text-secondary whitespace-nowrap flex-none\">{{ fileSize | cmatBytes }}</span>\r\n <span class=\"flex flex-row gap-0.5 print:hidden flex-none\">\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 <div class=\"px-3 pb-2\">\r\n <mat-progress-bar [value]=\"progressPercentage()\"></mat-progress-bar>\r\n <div class=\"text-xs text-secondary mt-1\">\r\n {{ progressPercentage() }}% · {{ loaded() | cmatBytes }} / {{ total() | cmatBytes }}\r\n </div>\r\n </div>\r\n }\r\n</div>\r\n"
377
+ }]
378
+ }],
379
+ ctorParameters: () => [],
380
+ propDecorators: {
381
+ removeEvent: [{
382
+ type: i0.Output,
383
+ args: ["removeEvent"]
384
+ }],
385
+ uploadEvent: [{
386
+ type: i0.Output,
387
+ args: ["uploadEvent"]
388
+ }],
389
+ fileAlias: [{
390
+ type: i0.Input,
391
+ args: [{
392
+ isSignal: true,
393
+ alias: "fileAlias",
394
+ required: false
395
+ }]
396
+ }],
397
+ filePath: [{
398
+ type: i0.Input,
399
+ args: [{
400
+ isSignal: true,
401
+ alias: "filePath",
402
+ required: false
403
+ }]
404
+ }],
405
+ fileCategory: [{
406
+ type: i0.Input,
407
+ args: [{
408
+ isSignal: true,
409
+ alias: "fileCategory",
410
+ required: false
411
+ }]
412
+ }],
413
+ isPublic: [{
414
+ type: i0.Input,
415
+ args: [{
416
+ isSignal: true,
417
+ alias: "isPublic",
418
+ required: false
419
+ }]
420
+ }],
421
+ editMode: [{
422
+ type: i0.Input,
423
+ args: [{
424
+ isSignal: true,
425
+ alias: "editMode",
426
+ required: false
427
+ }]
428
+ }],
429
+ autoUpload: [{
430
+ type: i0.Input,
431
+ args: [{
432
+ isSignal: true,
433
+ alias: "autoUpload",
434
+ required: false
435
+ }]
436
+ }],
437
+ file: [{
438
+ type: i0.Input,
439
+ args: [{
440
+ isSignal: true,
441
+ alias: "file",
442
+ required: true
443
+ }]
444
+ }, {
445
+ type: i0.Output,
446
+ args: ["fileChange"]
447
+ }],
448
+ id: [{
449
+ type: i0.Input,
450
+ args: [{
451
+ isSignal: true,
452
+ alias: "id",
453
+ required: false
454
+ }]
455
+ }]
456
+ }
457
+ });
458
+ var CmatUploadQueueComponent = class CmatUploadQueueComponent {
459
+ constructor() {
460
+ this.outputRemoveIdEvent = output();
461
+ this.outputUploadIdEvent = output();
462
+ this.outputFilesDataEvent = output();
463
+ this.fileAlias = input("fileData", ...ngDevMode ? [{ debugName: "fileAlias" }] : /* istanbul ignore next */ []);
464
+ this.filePath = input("", ...ngDevMode ? [{ debugName: "filePath" }] : /* istanbul ignore next */ []);
465
+ this.fileCategory = input("", ...ngDevMode ? [{ debugName: "fileCategory" }] : /* istanbul ignore next */ []);
466
+ this.isPublic = input(false, ...ngDevMode ? [{ debugName: "isPublic" }] : /* istanbul ignore next */ []);
467
+ this.required = input(false, ...ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []);
468
+ this.autoUpload = input(true, ...ngDevMode ? [{ debugName: "autoUpload" }] : /* istanbul ignore next */ []);
469
+ this.multiple = input(true, ...ngDevMode ? [{ debugName: "multiple" }] : /* istanbul ignore next */ []);
470
+ this.accept = input("", ...ngDevMode ? [{ debugName: "accept" }] : /* istanbul ignore next */ []);
471
+ this.title = input("附件", ...ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []);
472
+ this.editMode = input(false, ...ngDevMode ? [{ debugName: "editMode" }] : /* istanbul ignore next */ []);
473
+ this.filesData = model([], ...ngDevMode ? [{ debugName: "filesData" }] : /* istanbul ignore next */ []);
474
+ this.id = "cmatupload-" + crypto.randomUUID().slice(0, 8);
475
+ this.fileUploads = viewChildren(CmatUploadComponent, ...ngDevMode ? [{ debugName: "fileUploads" }] : /* istanbul ignore next */ []);
476
+ this._cmatMediaWatcherService = inject(CmatMediaWatcherService);
477
+ this._elementRef = inject(ElementRef);
478
+ this.isHandSet = computed(() => {
479
+ return !this._cmatMediaWatcherService.mediaChange().matchingAliases.includes("lg");
480
+ }, ...ngDevMode ? [{ debugName: "isHandSet" }] : /* istanbul ignore next */ []);
481
+ }
482
+ onDrop(event) {
483
+ const hasFiles = event.dataTransfer?.files && event.dataTransfer.files.length > 0;
484
+ if (event.dataTransfer?.types.includes("application/x-ng-dnd")) return;
485
+ if (!hasFiles) return;
486
+ for (const file of event.dataTransfer.files) if (this.accept()?.includes(file.type)) this.add(file);
487
+ event.preventDefault();
488
+ event.stopPropagation();
489
+ }
490
+ onDropOver(event) {
491
+ if (event.dataTransfer?.types.includes("application/x-ng-dnd")) return;
492
+ event.preventDefault();
493
+ }
494
+ ngAfterViewInit() {
495
+ const fileUpload = this._elementRef.nativeElement.querySelector(`#${this.id}`);
496
+ if (!(fileUpload instanceof HTMLInputElement)) return;
497
+ fileUpload.onchange = () => {
498
+ for (let index = 0; index < (fileUpload.files?.length ?? 0); index++) {
499
+ const file = fileUpload.files[index];
500
+ this.add(file);
501
+ }
502
+ };
503
+ }
504
+ add(file) {
505
+ if (!this.isFileTypeAccepted(file.type)) return;
506
+ const filesData = this.filesData() ?? [];
507
+ const fileModel = {
508
+ fileName: file.name,
509
+ length: file.size,
510
+ fileType: "file",
511
+ filePath: "",
512
+ isPublic: false,
513
+ fileCategory: "",
514
+ uploadDate: /* @__PURE__ */ new Date(),
515
+ data: file,
516
+ name: file.name,
517
+ size: file.size,
518
+ type: file.type
519
+ };
520
+ let newFilesData;
521
+ if (!(!this.multiple() && filesData.length > 0)) newFilesData = [...filesData, fileModel];
522
+ else {
523
+ const firstUpload = this.fileUploads()[0];
524
+ if (firstUpload?.id() === null) {
525
+ newFilesData = [...filesData, fileModel];
526
+ firstUpload.remove();
527
+ } else return;
528
+ }
529
+ this.filesData.set(newFilesData);
530
+ }
531
+ upload(event) {
532
+ this.outputUploadIdEvent.emit(event.id ?? "");
533
+ this.outputFilesDataEvent.emit(this.filesData());
534
+ }
535
+ remove(event) {
536
+ const filesData = this.filesData();
537
+ if (filesData) {
538
+ if (filesData.findIndex((j) => j === event.file()) > -1) {
539
+ if (event.file().id) this.outputRemoveIdEvent.emit(event.file().id);
540
+ const newData = filesData.filter((j) => j !== event.file());
541
+ this.filesData.set(newData);
542
+ this.outputFilesDataEvent.emit(newData);
543
+ }
544
+ }
545
+ }
546
+ uploadAll() {
547
+ this.fileUploads().forEach((fileUpload) => {
548
+ if (fileUpload.id() === null) fileUpload.upload();
549
+ });
550
+ }
551
+ removeAll() {
552
+ this.fileUploads().forEach((fileUpload) => {
553
+ fileUpload.remove();
554
+ });
555
+ }
556
+ choose() {
557
+ this._elementRef.nativeElement.querySelector(`#${this.id}`)?.dispatchEvent(new MouseEvent("click"));
558
+ }
559
+ isFileTypeAccepted(fileType) {
560
+ const accept = this.accept();
561
+ if (!accept || accept === "") return true;
562
+ return accept.split(",").map((type) => type.trim()).some((type) => {
563
+ if (type.endsWith("/*")) {
564
+ const prefix = type.slice(0, -1);
565
+ return fileType.startsWith(prefix);
566
+ }
567
+ return fileType === type;
568
+ });
569
+ }
570
+ static {
571
+ this.ɵfac = i0.ɵɵngDeclareFactory({
572
+ minVersion: "12.0.0",
573
+ version: "22.2.3",
574
+ ngImport: i0,
575
+ type: CmatUploadQueueComponent,
576
+ deps: [],
577
+ target: i0.ɵɵFactoryTarget.Component
578
+ });
579
+ }
580
+ static {
581
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
582
+ minVersion: "17.0.0",
583
+ version: "22.2.3",
584
+ type: CmatUploadQueueComponent,
585
+ isStandalone: true,
586
+ selector: "cmat-upload-queue",
587
+ inputs: {
588
+ fileAlias: {
589
+ classPropertyName: "fileAlias",
590
+ publicName: "fileAlias",
591
+ isSignal: true,
592
+ isRequired: false,
593
+ transformFunction: null
594
+ },
595
+ filePath: {
596
+ classPropertyName: "filePath",
597
+ publicName: "filePath",
598
+ isSignal: true,
599
+ isRequired: false,
600
+ transformFunction: null
601
+ },
602
+ fileCategory: {
603
+ classPropertyName: "fileCategory",
604
+ publicName: "fileCategory",
605
+ isSignal: true,
606
+ isRequired: false,
607
+ transformFunction: null
608
+ },
609
+ isPublic: {
610
+ classPropertyName: "isPublic",
611
+ publicName: "isPublic",
612
+ isSignal: true,
613
+ isRequired: false,
614
+ transformFunction: null
615
+ },
616
+ required: {
617
+ classPropertyName: "required",
618
+ publicName: "required",
619
+ isSignal: true,
620
+ isRequired: false,
621
+ transformFunction: null
622
+ },
623
+ autoUpload: {
624
+ classPropertyName: "autoUpload",
625
+ publicName: "autoUpload",
626
+ isSignal: true,
627
+ isRequired: false,
628
+ transformFunction: null
629
+ },
630
+ multiple: {
631
+ classPropertyName: "multiple",
632
+ publicName: "multiple",
633
+ isSignal: true,
634
+ isRequired: false,
635
+ transformFunction: null
636
+ },
637
+ accept: {
638
+ classPropertyName: "accept",
639
+ publicName: "accept",
640
+ isSignal: true,
641
+ isRequired: false,
642
+ transformFunction: null
643
+ },
644
+ title: {
645
+ classPropertyName: "title",
646
+ publicName: "title",
647
+ isSignal: true,
648
+ isRequired: false,
649
+ transformFunction: null
650
+ },
651
+ editMode: {
652
+ classPropertyName: "editMode",
653
+ publicName: "editMode",
654
+ isSignal: true,
655
+ isRequired: false,
656
+ transformFunction: null
657
+ },
658
+ filesData: {
659
+ classPropertyName: "filesData",
660
+ publicName: "filesData",
661
+ isSignal: true,
662
+ isRequired: false,
663
+ transformFunction: null
664
+ }
665
+ },
666
+ outputs: {
667
+ outputRemoveIdEvent: "outputRemoveIdEvent",
668
+ outputUploadIdEvent: "outputUploadIdEvent",
669
+ outputFilesDataEvent: "outputFilesDataEvent",
670
+ filesData: "filesDataChange"
671
+ },
672
+ host: { listeners: {
673
+ "drop": "onDrop($event)",
674
+ "dragover": "onDropOver($event)"
675
+ } },
676
+ viewQueries: [{
677
+ propertyName: "fileUploads",
678
+ predicate: CmatUploadComponent,
679
+ descendants: true,
680
+ isSignal: true
681
+ }],
682
+ exportAs: ["cmatUploadQueue"],
683
+ ngImport: i0,
684
+ template: "<div class=\"rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden bg-card\">\r\n <div class=\"flex items-center gap-2 px-3 py-2 bg-primary-50 dark:bg-primary-900/30 border-b border-primary-200 dark:border-primary-700\">\r\n <mat-icon class=\"icon-size-5 text-primary-500\" [svgIcon]=\"'heroicons_outline:paper-clip'\"></mat-icon>\r\n <span class=\"text-sm font-semibold text-primary-500\">\r\n {{ title() }}\r\n @if (required()) {\r\n <span>*</span>\r\n }\r\n </span>\r\n </div>\r\n <input type=\"file\" class=\"hidden\" [id]=\"id\" [multiple]=\"multiple()\" [accept]=\"accept()\" />\r\n\r\n @if (editMode()) {\r\n <div class=\"flex flex-row gap-1 p-2 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\">选择</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><span class=\"ml-2\">上传全部</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><span class=\"ml-2\">删除全部</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 </div>\r\n }\r\n\r\n <div class=\"border-t\">\r\n @if (!filesData() || filesData().length === 0) {\r\n <div class=\"flex flex-col items-center justify-center py-4 text-hint\">\r\n <mat-icon class=\"w-16! h-16! text-4xl! mb-3\" [svgIcon]=\"'heroicons_outline:folder-open'\"></mat-icon>\r\n <span class=\"text-sm\">暂无内容</span>\r\n </div>\r\n }@else{\r\n <mat-list>\r\n @for (file of filesData(); track $index) {\r\n <mat-list-item class=\"cmat-upload-file-item h-full\">\r\n <cmat-upload class=\"my-2\" [fileAlias]=\"fileAlias()\" [filePath]=\"filePath()\" [fileCategory]=\"fileCategory()\"\r\n [autoUpload]=\"autoUpload()\" [editMode]=\"editMode()\" [file]=\"file\" [id]=\"file.id || null\"\r\n [isPublic]=\"isPublic()\" (removeEvent)=\"remove($event)\" (uploadEvent)=\"upload($event)\"></cmat-upload>\r\n </mat-list-item>\r\n }\r\n </mat-list>\r\n }\r\n </div>\r\n</div>\r\n",
685
+ dependencies: [
686
+ {
687
+ kind: "ngmodule",
688
+ type: MatListModule
689
+ },
690
+ {
691
+ kind: "component",
692
+ type: i1.MatList,
693
+ selector: "mat-list",
694
+ exportAs: ["matList"]
695
+ },
696
+ {
697
+ kind: "component",
698
+ type: i1.MatListItem,
699
+ selector: "mat-list-item, a[mat-list-item], button[mat-list-item]",
700
+ inputs: ["activated"],
701
+ exportAs: ["matListItem"]
702
+ },
703
+ {
704
+ kind: "ngmodule",
705
+ type: MatButtonModule
706
+ },
707
+ {
708
+ kind: "component",
709
+ type: i1$1.MatButton,
710
+ 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] ",
711
+ inputs: ["matButton"],
712
+ exportAs: ["matButton", "matAnchor"]
713
+ },
714
+ {
715
+ kind: "component",
716
+ type: i1$1.MatIconButton,
717
+ selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
718
+ exportAs: ["matButton", "matAnchor"]
719
+ },
720
+ {
721
+ kind: "ngmodule",
722
+ type: MatIconModule
723
+ },
724
+ {
725
+ kind: "component",
726
+ type: i2.MatIcon,
727
+ selector: "mat-icon",
728
+ inputs: [
729
+ "color",
730
+ "inline",
731
+ "svgIcon",
732
+ "fontSet",
733
+ "fontIcon"
734
+ ],
735
+ exportAs: ["matIcon"]
736
+ },
737
+ {
738
+ kind: "component",
739
+ type: CmatUploadComponent,
740
+ selector: "cmat-upload",
741
+ inputs: [
742
+ "fileAlias",
743
+ "filePath",
744
+ "fileCategory",
745
+ "isPublic",
746
+ "editMode",
747
+ "autoUpload",
748
+ "file",
749
+ "id"
750
+ ],
751
+ outputs: [
752
+ "removeEvent",
753
+ "uploadEvent",
754
+ "fileChange"
755
+ ],
756
+ exportAs: ["cmatUpload"]
757
+ }
758
+ ],
759
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
760
+ encapsulation: i0.ViewEncapsulation.None
761
+ });
762
+ }
763
+ };
764
+ i0.ɵɵngDeclareClassMetadata({
765
+ minVersion: "12.0.0",
766
+ version: "22.2.3",
767
+ ngImport: i0,
768
+ type: CmatUploadQueueComponent,
769
+ decorators: [{
770
+ type: Component,
771
+ args: [{
772
+ selector: "cmat-upload-queue",
773
+ encapsulation: ViewEncapsulation.None,
774
+ changeDetection: ChangeDetectionStrategy.OnPush,
775
+ exportAs: "cmatUploadQueue",
776
+ imports: [
777
+ MatListModule,
778
+ MatButtonModule,
779
+ MatIconModule,
780
+ CmatUploadComponent
781
+ ],
782
+ template: "<div class=\"rounded-xl border border-slate-200 dark:border-slate-700 overflow-hidden bg-card\">\r\n <div class=\"flex items-center gap-2 px-3 py-2 bg-primary-50 dark:bg-primary-900/30 border-b border-primary-200 dark:border-primary-700\">\r\n <mat-icon class=\"icon-size-5 text-primary-500\" [svgIcon]=\"'heroicons_outline:paper-clip'\"></mat-icon>\r\n <span class=\"text-sm font-semibold text-primary-500\">\r\n {{ title() }}\r\n @if (required()) {\r\n <span>*</span>\r\n }\r\n </span>\r\n </div>\r\n <input type=\"file\" class=\"hidden\" [id]=\"id\" [multiple]=\"multiple()\" [accept]=\"accept()\" />\r\n\r\n @if (editMode()) {\r\n <div class=\"flex flex-row gap-1 p-2 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\">选择</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><span class=\"ml-2\">上传全部</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><span class=\"ml-2\">删除全部</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 </div>\r\n }\r\n\r\n <div class=\"border-t\">\r\n @if (!filesData() || filesData().length === 0) {\r\n <div class=\"flex flex-col items-center justify-center py-4 text-hint\">\r\n <mat-icon class=\"w-16! h-16! text-4xl! mb-3\" [svgIcon]=\"'heroicons_outline:folder-open'\"></mat-icon>\r\n <span class=\"text-sm\">暂无内容</span>\r\n </div>\r\n }@else{\r\n <mat-list>\r\n @for (file of filesData(); track $index) {\r\n <mat-list-item class=\"cmat-upload-file-item h-full\">\r\n <cmat-upload class=\"my-2\" [fileAlias]=\"fileAlias()\" [filePath]=\"filePath()\" [fileCategory]=\"fileCategory()\"\r\n [autoUpload]=\"autoUpload()\" [editMode]=\"editMode()\" [file]=\"file\" [id]=\"file.id || null\"\r\n [isPublic]=\"isPublic()\" (removeEvent)=\"remove($event)\" (uploadEvent)=\"upload($event)\"></cmat-upload>\r\n </mat-list-item>\r\n }\r\n </mat-list>\r\n }\r\n </div>\r\n</div>\r\n"
783
+ }]
784
+ }],
785
+ propDecorators: {
786
+ outputRemoveIdEvent: [{
787
+ type: i0.Output,
788
+ args: ["outputRemoveIdEvent"]
789
+ }],
790
+ outputUploadIdEvent: [{
791
+ type: i0.Output,
792
+ args: ["outputUploadIdEvent"]
793
+ }],
794
+ outputFilesDataEvent: [{
795
+ type: i0.Output,
796
+ args: ["outputFilesDataEvent"]
797
+ }],
798
+ fileAlias: [{
799
+ type: i0.Input,
800
+ args: [{
801
+ isSignal: true,
802
+ alias: "fileAlias",
803
+ required: false
804
+ }]
805
+ }],
806
+ filePath: [{
807
+ type: i0.Input,
808
+ args: [{
809
+ isSignal: true,
810
+ alias: "filePath",
811
+ required: false
812
+ }]
813
+ }],
814
+ fileCategory: [{
815
+ type: i0.Input,
816
+ args: [{
817
+ isSignal: true,
818
+ alias: "fileCategory",
819
+ required: false
820
+ }]
821
+ }],
822
+ isPublic: [{
823
+ type: i0.Input,
824
+ args: [{
825
+ isSignal: true,
826
+ alias: "isPublic",
827
+ required: false
828
+ }]
829
+ }],
830
+ required: [{
831
+ type: i0.Input,
832
+ args: [{
833
+ isSignal: true,
834
+ alias: "required",
835
+ required: false
836
+ }]
837
+ }],
838
+ autoUpload: [{
839
+ type: i0.Input,
840
+ args: [{
841
+ isSignal: true,
842
+ alias: "autoUpload",
843
+ required: false
844
+ }]
845
+ }],
846
+ multiple: [{
847
+ type: i0.Input,
848
+ args: [{
849
+ isSignal: true,
850
+ alias: "multiple",
851
+ required: false
852
+ }]
853
+ }],
854
+ accept: [{
855
+ type: i0.Input,
856
+ args: [{
857
+ isSignal: true,
858
+ alias: "accept",
859
+ required: false
860
+ }]
861
+ }],
862
+ title: [{
863
+ type: i0.Input,
864
+ args: [{
865
+ isSignal: true,
866
+ alias: "title",
867
+ required: false
868
+ }]
869
+ }],
870
+ editMode: [{
871
+ type: i0.Input,
872
+ args: [{
873
+ isSignal: true,
874
+ alias: "editMode",
875
+ required: false
876
+ }]
877
+ }],
878
+ filesData: [{
879
+ type: i0.Input,
880
+ args: [{
881
+ isSignal: true,
882
+ alias: "filesData",
883
+ required: false
884
+ }]
885
+ }, {
886
+ type: i0.Output,
887
+ args: ["filesDataChange"]
888
+ }],
889
+ fileUploads: [{
890
+ type: i0.ViewChildren,
891
+ args: [i0.forwardRef(() => CmatUploadComponent), { isSignal: true }]
892
+ }],
893
+ onDrop: [{
894
+ type: HostListener,
895
+ args: ["drop", ["$event"]]
896
+ }],
897
+ onDropOver: [{
898
+ type: HostListener,
899
+ args: ["dragover", ["$event"]]
900
+ }]
901
+ }
902
+ });
410
903
  export { CmatFilesUtilService, CmatUploadComponent, CmatUploadQueueComponent };
411
- //# sourceMappingURL=cmat-components-upload.mjs.map
904
+
905
+ //# sourceMappingURL=cmat-components-upload.mjs.map