cmat 0.0.111 → 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 +984 -1109
  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 +39805 -22511
  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 -102
  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 -5204
@@ -1,216 +1,490 @@
1
- import * as i1 from '@angular/common';
2
- import { CommonModule } from '@angular/common';
3
- import * as i0 from '@angular/core';
4
- import { viewChild, input, booleanAttribute, output, signal, computed, inject, DOCUMENT, effect, ElementRef, HostListener, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
5
- import * as i2 from '@angular/material/button';
6
- import { MatButtonModule } from '@angular/material/button';
7
- import * as i3 from '@angular/material/icon';
8
- import { MatIconModule } from '@angular/material/icon';
9
-
10
- class CmatImageComponent {
11
- constructor() {
12
- this.maskRef = viewChild('mask', /* @ts-ignore */
13
- ...(ngDevMode ? [{ debugName: "maskRef" }] : /* istanbul ignore next */ []));
14
- this.previewButtonRef = viewChild('previewButton', /* @ts-ignore */
15
- ...(ngDevMode ? [{ debugName: "previewButtonRef" }] : /* istanbul ignore next */ []));
16
- this.closeButtonRef = viewChild('closeButton', /* @ts-ignore */
17
- ...(ngDevMode ? [{ debugName: "closeButtonRef" }] : /* istanbul ignore next */ []));
18
- this.imageClass = input(undefined, /* @ts-ignore */
19
- ...(ngDevMode ? [{ debugName: "imageClass" }] : /* istanbul ignore next */ []));
20
- this.imageStyle = input(undefined, /* @ts-ignore */
21
- ...(ngDevMode ? [{ debugName: "imageStyle" }] : /* istanbul ignore next */ []));
22
- this.src = input(undefined, /* @ts-ignore */
23
- ...(ngDevMode ? [{ debugName: "src" }] : /* istanbul ignore next */ []));
24
- this.srcSet = input(undefined, /* @ts-ignore */
25
- ...(ngDevMode ? [{ debugName: "srcSet" }] : /* istanbul ignore next */ []));
26
- this.previewImageSrc = input(undefined, /* @ts-ignore */
27
- ...(ngDevMode ? [{ debugName: "previewImageSrc" }] : /* istanbul ignore next */ []));
28
- this.previewImageSrcSet = input(undefined, /* @ts-ignore */
29
- ...(ngDevMode ? [{ debugName: "previewImageSrcSet" }] : /* istanbul ignore next */ []));
30
- this.alt = input(undefined, /* @ts-ignore */
31
- ...(ngDevMode ? [{ debugName: "alt" }] : /* istanbul ignore next */ []));
32
- this.width = input(undefined, /* @ts-ignore */
33
- ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
34
- this.height = input(undefined, /* @ts-ignore */
35
- ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
36
- this.loading = input(undefined, /* @ts-ignore */
37
- ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
38
- this.appendTo = input(undefined, /* @ts-ignore */
39
- ...(ngDevMode ? [{ debugName: "appendTo" }] : /* istanbul ignore next */ []));
40
- this.preview = input(false, { ...(ngDevMode ? { debugName: "preview" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
41
- this.previewShowChange = output();
42
- this.imageErrorEvent = output();
43
- this.maskVisible = signal(false, /* @ts-ignore */
44
- ...(ngDevMode ? [{ debugName: "maskVisible" }] : /* istanbul ignore next */ []));
45
- this.previewVisible = signal(false, /* @ts-ignore */
46
- ...(ngDevMode ? [{ debugName: "previewVisible" }] : /* istanbul ignore next */ []));
47
- this.rotate = signal(0, /* @ts-ignore */
48
- ...(ngDevMode ? [{ debugName: "rotate" }] : /* istanbul ignore next */ []));
49
- this.scale = signal(1, /* @ts-ignore */
50
- ...(ngDevMode ? [{ debugName: "scale" }] : /* istanbul ignore next */ []));
51
- this.isZoomOutDisabled = computed(() => {
52
- return this.scale() - this._zoomSettings.step <= this._zoomSettings.min;
53
- }, /* @ts-ignore */
54
- ...(ngDevMode ? [{ debugName: "isZoomOutDisabled" }] : /* istanbul ignore next */ []));
55
- this.isZoomInDisabled = computed(() => {
56
- return this.scale() + this._zoomSettings.step >= this._zoomSettings.max;
57
- }, /* @ts-ignore */
58
- ...(ngDevMode ? [{ debugName: "isZoomInDisabled" }] : /* istanbul ignore next */ []));
59
- this.imagePreviewStyle = computed(() => {
60
- return {
61
- transform: `rotate(${this.rotate()}deg) scale(${this.scale()})`
62
- };
63
- }, /* @ts-ignore */
64
- ...(ngDevMode ? [{ debugName: "imagePreviewStyle" }] : /* istanbul ignore next */ []));
65
- this._document = inject(DOCUMENT);
66
- this._animationDuration = 150;
67
- this._loadingPreview = false;
68
- this._closePreviewByEscape = false;
69
- this._closePreviewTimeoutId = null;
70
- this._originalOverflow = null;
71
- this._zoomSettings = {
72
- default: 1,
73
- step: 0.1,
74
- max: 1.5,
75
- min: 0.5
76
- };
77
- effect(() => {
78
- const maskEl = this.maskRef();
79
- if (maskEl && this._loadingPreview) {
80
- this.appendContainer(maskEl);
81
- }
82
- });
83
- effect(() => {
84
- const btn = this.previewButtonRef();
85
- if (btn && this._closePreviewByEscape) {
86
- btn.focus();
87
- this._closePreviewByEscape = false;
88
- }
89
- });
90
- effect(() => {
91
- const btn = this.closeButtonRef();
92
- if (btn && this._loadingPreview) {
93
- btn.focus();
94
- this._loadingPreview = false;
95
- }
96
- });
97
- }
98
- onKeydownHandler() {
99
- if (this.previewVisible()) {
100
- this._enableBackgroundScroll();
101
- this.closePreview();
102
- }
103
- }
104
- onImageClick() {
105
- if (this.preview()) {
106
- this._disableBackgroundScroll();
107
- this.maskVisible.set(true);
108
- this._loadingPreview = true;
109
- requestAnimationFrame(() => {
110
- this.previewVisible.set(true);
111
- this.previewShowChange.emit(true);
112
- });
113
- }
114
- }
115
- onMaskKeydown(event) {
116
- switch (event.code) {
117
- case 'Escape':
118
- this.closePreview();
119
- this._closePreviewByEscape = true;
120
- event.preventDefault();
121
- break;
122
- default:
123
- break;
124
- }
125
- }
126
- onPreviewImageClick(event) {
127
- event.stopPropagation();
128
- }
129
- rotateRight() {
130
- // 使用 update 方法基于当前值计算新值
131
- this.rotate.update(r => r + 90);
132
- }
133
- rotateLeft() {
134
- this.rotate.update(r => r - 90);
135
- }
136
- zoomIn() {
137
- this.scale.update(s => s + this._zoomSettings.step);
138
- }
139
- zoomOut() {
140
- this.scale.update(s => s - this._zoomSettings.step);
141
- }
142
- handleToolbarClick(event) {
143
- event.stopPropagation();
144
- }
145
- appendContainer(maskElement) {
146
- const elToAppend = maskElement ?? this.maskRef();
147
- if (!elToAppend)
148
- return;
149
- const target = this.appendTo();
150
- if (target) {
151
- if (target === 'body') {
152
- this._document.body.appendChild(elToAppend);
153
- }
154
- else {
155
- let nativeElement = null;
156
- if (target instanceof HTMLElement) {
157
- nativeElement = target;
158
- }
159
- else if (target instanceof ElementRef) {
160
- nativeElement = target.nativeElement;
161
- }
162
- else if (typeof target === 'object' && target !== null && 'el' in target) {
163
- const customTarget = target;
164
- nativeElement = customTarget.el?.nativeElement ?? null;
165
- }
166
- if (nativeElement) {
167
- nativeElement.appendChild(elToAppend);
168
- }
169
- }
170
- }
171
- }
172
- closePreview() {
173
- if (this._closePreviewTimeoutId !== null) {
174
- clearTimeout(this._closePreviewTimeoutId);
175
- this._closePreviewTimeoutId = null;
176
- }
177
- this._enableBackgroundScroll();
178
- this.previewVisible.set(false);
179
- this._closePreviewTimeoutId = window.setTimeout(() => {
180
- this.maskVisible.set(false);
181
- // 重置 signal 状态
182
- this.rotate.set(0);
183
- this.scale.set(this._zoomSettings.default);
184
- this.previewShowChange.emit(false);
185
- this._closePreviewTimeoutId = null;
186
- }, this._animationDuration);
187
- }
188
- imageError(event) {
189
- this.imageErrorEvent.emit(event);
190
- }
191
- _disableBackgroundScroll() {
192
- const body = this._document.body;
193
- this._originalOverflow = body.style.overflow;
194
- body.style.overflow = 'hidden';
195
- }
196
- _enableBackgroundScroll() {
197
- const body = this._document.body;
198
- body.style.overflow = this._originalOverflow ?? '';
199
- }
200
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatImageComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
201
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: CmatImageComponent, isStandalone: true, selector: "cmat-image", inputs: { imageClass: { classPropertyName: "imageClass", publicName: "imageClass", isSignal: true, isRequired: false, transformFunction: null }, imageStyle: { classPropertyName: "imageStyle", publicName: "imageStyle", isSignal: true, isRequired: false, transformFunction: null }, src: { classPropertyName: "src", publicName: "src", isSignal: true, isRequired: false, transformFunction: null }, srcSet: { classPropertyName: "srcSet", publicName: "srcSet", isSignal: true, isRequired: false, transformFunction: null }, previewImageSrc: { classPropertyName: "previewImageSrc", publicName: "previewImageSrc", isSignal: true, isRequired: false, transformFunction: null }, previewImageSrcSet: { classPropertyName: "previewImageSrcSet", publicName: "previewImageSrcSet", isSignal: true, isRequired: false, transformFunction: null }, alt: { classPropertyName: "alt", publicName: "alt", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, appendTo: { classPropertyName: "appendTo", publicName: "appendTo", isSignal: true, isRequired: false, transformFunction: null }, preview: { classPropertyName: "preview", publicName: "preview", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { previewShowChange: "previewShowChange", imageErrorEvent: "imageErrorEvent" }, host: { listeners: { "document:keydown.escape": "onKeydownHandler($event)" } }, viewQueries: [{ propertyName: "maskRef", first: true, predicate: ["mask"], descendants: true, isSignal: true }, { propertyName: "previewButtonRef", first: true, predicate: ["previewButton"], descendants: true, isSignal: true }, { propertyName: "closeButtonRef", first: true, predicate: ["closeButton"], descendants: true, isSignal: true }], ngImport: i0, template: "<span [ngClass]=\"{ 'cmat-image-preview-container ': preview() }\">\r\n <img \r\n [attr.src]=\"src()\" \r\n [attr.srcset]=\"srcSet()\" \r\n [attr.alt]=\"alt()\" \r\n [attr.width]=\"width()\" \r\n [attr.height]=\"height()\"\r\n [attr.loading]=\"loading()\" \r\n [ngStyle]=\"imageStyle()\" \r\n [class]=\"imageClass()\" \r\n (error)=\"imageError($event)\" />\r\n \r\n @if(preview()){\r\n <div class=\"cmat-image-preview-indicator\" role=\"presentation\" (click)=\"onImageClick()\">\r\n <button #previewButton matIconButton>\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'heroicons_solid:eye'\"></mat-icon>\r\n </button>\r\n </div>\r\n }\r\n\r\n @if(maskVisible()){\r\n <div #mask class=\"cmat-image-mask cmat-image-overlay cmat-image-overlay-enter\" animate.leave=\"cmat-image-overlay-leave\"\r\n role=\"dialog\" [attr.aria-modal]=\"maskVisible()\" (click)=\"closePreview()\" (keydown)=\"onMaskKeydown($event)\">\r\n <div class=\"cmat-image-toolbar\" role=\"presentation\" (click)=\"handleToolbarClick($event)\">\r\n <button matIconButton (click)=\"rotateRight()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:rotate_right'\"></mat-icon>\r\n </button>\r\n <button matIconButton (click)=\"rotateLeft()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:rotate_left'\"></mat-icon>\r\n </button>\r\n <!-- \u7ED1\u5B9A computed signals -->\r\n <button matIconButton [disabled]=\"isZoomOutDisabled()\" (click)=\"zoomOut()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:zoom_out'\"></mat-icon>\r\n </button>\r\n <button matIconButton [disabled]=\"isZoomInDisabled()\" (click)=\"zoomIn()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:zoom_in'\"></mat-icon>\r\n </button>\r\n <button #closeButton matIconButton (click)=\"closePreview()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:close'\"></mat-icon>\r\n </button>\r\n </div>\r\n @if(previewVisible()){\r\n <div role=\"presentation\" class=\"cmat-image-preview-enter\" animate.leave=\"cmat-image-preview-leave\"\r\n (click)=\"onPreviewImageClick($event)\">\r\n <img class=\"cmat-image-preview\" alt=\"image\" \r\n [attr.src]=\"previewImageSrc() ? previewImageSrc() : src()\"\r\n [attr.srcset]=\"previewImageSrcSet()\" \r\n [ngStyle]=\"imagePreviewStyle()\" />\r\n </div>\r\n }\r\n </div>\r\n }\r\n\r\n</span>", styles: [".cmat-image-mask{display:flex;align-items:center;justify-content:center}.cmat-image-preview-container{position:relative;display:inline-block;line-height:0}.cmat-image-preview-indicator{position:absolute;left:0;top:0;width:100%;height:100%;outline:none;border:none;padding:0;display:flex;align-items:center;justify-content:center;opacity:0;will-change:opacity,background-color;pointer-events:none;transition:opacity .3s ease}.cmat-image-preview-container:hover>.cmat-image-preview-indicator{opacity:1;cursor:pointer;background-color:#00000080;pointer-events:auto}.cmat-image-preview-container>img{cursor:pointer}.cmat-image-toolbar{position:absolute;top:0;right:0;display:flex;z-index:1;padding:.5rem}.cmat-image-preview{transition:transform .18s cubic-bezier(.2,0,0,1),opacity .18s cubic-bezier(.2,0,0,1);max-width:100vw;max-height:100vh;will-change:transform,opacity;transform-origin:center center;backface-visibility:hidden;transform:translateZ(0)}.cmat-image-preview-enter{animation:preview-enter-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-preview-leave{animation:preview-leave-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-overlay{background-color:#0006;transition:background-color .18s cubic-bezier(.2,0,0,1),opacity .18s cubic-bezier(.2,0,0,1);will-change:background-color,opacity;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:99}.cmat-image-overlay-enter{animation:image-overlay-enter-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-overlay-leave{z-index:0;animation:image-overlay-leave-animation .18s cubic-bezier(.2,0,0,1)}@keyframes preview-enter-animation{0%{transform:scale(.7);opacity:0}to{transform:scale(1);opacity:1}}@keyframes preview-leave-animation{0%{transform:scale(1);opacity:1}to{transform:scale(.7);opacity:0}}@keyframes image-overlay-enter-animation{0%{background-color:transparent}to{background-color:#000000e6}}@keyframes image-overlay-leave-animation{0%{background-color:#000000e6}to{background-color:transparent}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { 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: i3.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
202
- }
203
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatImageComponent, decorators: [{
204
- type: Component,
205
- args: [{ selector: 'cmat-image', imports: [CommonModule, MatButtonModule, MatIconModule], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<span [ngClass]=\"{ 'cmat-image-preview-container ': preview() }\">\r\n <img \r\n [attr.src]=\"src()\" \r\n [attr.srcset]=\"srcSet()\" \r\n [attr.alt]=\"alt()\" \r\n [attr.width]=\"width()\" \r\n [attr.height]=\"height()\"\r\n [attr.loading]=\"loading()\" \r\n [ngStyle]=\"imageStyle()\" \r\n [class]=\"imageClass()\" \r\n (error)=\"imageError($event)\" />\r\n \r\n @if(preview()){\r\n <div class=\"cmat-image-preview-indicator\" role=\"presentation\" (click)=\"onImageClick()\">\r\n <button #previewButton matIconButton>\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'heroicons_solid:eye'\"></mat-icon>\r\n </button>\r\n </div>\r\n }\r\n\r\n @if(maskVisible()){\r\n <div #mask class=\"cmat-image-mask cmat-image-overlay cmat-image-overlay-enter\" animate.leave=\"cmat-image-overlay-leave\"\r\n role=\"dialog\" [attr.aria-modal]=\"maskVisible()\" (click)=\"closePreview()\" (keydown)=\"onMaskKeydown($event)\">\r\n <div class=\"cmat-image-toolbar\" role=\"presentation\" (click)=\"handleToolbarClick($event)\">\r\n <button matIconButton (click)=\"rotateRight()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:rotate_right'\"></mat-icon>\r\n </button>\r\n <button matIconButton (click)=\"rotateLeft()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:rotate_left'\"></mat-icon>\r\n </button>\r\n <!-- \u7ED1\u5B9A computed signals -->\r\n <button matIconButton [disabled]=\"isZoomOutDisabled()\" (click)=\"zoomOut()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:zoom_out'\"></mat-icon>\r\n </button>\r\n <button matIconButton [disabled]=\"isZoomInDisabled()\" (click)=\"zoomIn()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:zoom_in'\"></mat-icon>\r\n </button>\r\n <button #closeButton matIconButton (click)=\"closePreview()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:close'\"></mat-icon>\r\n </button>\r\n </div>\r\n @if(previewVisible()){\r\n <div role=\"presentation\" class=\"cmat-image-preview-enter\" animate.leave=\"cmat-image-preview-leave\"\r\n (click)=\"onPreviewImageClick($event)\">\r\n <img class=\"cmat-image-preview\" alt=\"image\" \r\n [attr.src]=\"previewImageSrc() ? previewImageSrc() : src()\"\r\n [attr.srcset]=\"previewImageSrcSet()\" \r\n [ngStyle]=\"imagePreviewStyle()\" />\r\n </div>\r\n }\r\n </div>\r\n }\r\n\r\n</span>", styles: [".cmat-image-mask{display:flex;align-items:center;justify-content:center}.cmat-image-preview-container{position:relative;display:inline-block;line-height:0}.cmat-image-preview-indicator{position:absolute;left:0;top:0;width:100%;height:100%;outline:none;border:none;padding:0;display:flex;align-items:center;justify-content:center;opacity:0;will-change:opacity,background-color;pointer-events:none;transition:opacity .3s ease}.cmat-image-preview-container:hover>.cmat-image-preview-indicator{opacity:1;cursor:pointer;background-color:#00000080;pointer-events:auto}.cmat-image-preview-container>img{cursor:pointer}.cmat-image-toolbar{position:absolute;top:0;right:0;display:flex;z-index:1;padding:.5rem}.cmat-image-preview{transition:transform .18s cubic-bezier(.2,0,0,1),opacity .18s cubic-bezier(.2,0,0,1);max-width:100vw;max-height:100vh;will-change:transform,opacity;transform-origin:center center;backface-visibility:hidden;transform:translateZ(0)}.cmat-image-preview-enter{animation:preview-enter-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-preview-leave{animation:preview-leave-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-overlay{background-color:#0006;transition:background-color .18s cubic-bezier(.2,0,0,1),opacity .18s cubic-bezier(.2,0,0,1);will-change:background-color,opacity;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:99}.cmat-image-overlay-enter{animation:image-overlay-enter-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-overlay-leave{z-index:0;animation:image-overlay-leave-animation .18s cubic-bezier(.2,0,0,1)}@keyframes preview-enter-animation{0%{transform:scale(.7);opacity:0}to{transform:scale(1);opacity:1}}@keyframes preview-leave-animation{0%{transform:scale(1);opacity:1}to{transform:scale(.7);opacity:0}}@keyframes image-overlay-enter-animation{0%{background-color:transparent}to{background-color:#000000e6}}@keyframes image-overlay-leave-animation{0%{background-color:#000000e6}to{background-color:transparent}}\n"] }]
206
- }], ctorParameters: () => [], propDecorators: { maskRef: [{ type: i0.ViewChild, args: ['mask', { isSignal: true }] }], previewButtonRef: [{ type: i0.ViewChild, args: ['previewButton', { isSignal: true }] }], closeButtonRef: [{ type: i0.ViewChild, args: ['closeButton', { isSignal: true }] }], imageClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "imageClass", required: false }] }], imageStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "imageStyle", required: false }] }], src: [{ type: i0.Input, args: [{ isSignal: true, alias: "src", required: false }] }], srcSet: [{ type: i0.Input, args: [{ isSignal: true, alias: "srcSet", required: false }] }], previewImageSrc: [{ type: i0.Input, args: [{ isSignal: true, alias: "previewImageSrc", required: false }] }], previewImageSrcSet: [{ type: i0.Input, args: [{ isSignal: true, alias: "previewImageSrcSet", required: false }] }], alt: [{ type: i0.Input, args: [{ isSignal: true, alias: "alt", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], appendTo: [{ type: i0.Input, args: [{ isSignal: true, alias: "appendTo", required: false }] }], preview: [{ type: i0.Input, args: [{ isSignal: true, alias: "preview", required: false }] }], previewShowChange: [{ type: i0.Output, args: ["previewShowChange"] }], imageErrorEvent: [{ type: i0.Output, args: ["imageErrorEvent"] }], onKeydownHandler: [{
207
- type: HostListener,
208
- args: ['document:keydown.escape', ['$event']]
209
- }] } });
210
-
211
- /**
212
- * Generated bundle index. Do not edit.
213
- */
214
-
1
+ import * as i1 from "@angular/common";
2
+ import { CommonModule } from "@angular/common";
3
+ import * as i0 from "@angular/core";
4
+ import { ChangeDetectionStrategy, Component, DOCUMENT, ElementRef, HostListener, ViewEncapsulation, booleanAttribute, computed, effect, inject, input, output, signal, viewChild } from "@angular/core";
5
+ import * as i2 from "@angular/material/button";
6
+ import { MatButtonModule } from "@angular/material/button";
7
+ import * as i3 from "@angular/material/icon";
8
+ import { MatIconModule } from "@angular/material/icon";
9
+ var CmatImageComponent = class CmatImageComponent {
10
+ constructor() {
11
+ this.maskRef = viewChild("mask", ...ngDevMode ? [{ debugName: "maskRef" }] : /* istanbul ignore next */ []);
12
+ this.previewButtonRef = viewChild("previewButton", ...ngDevMode ? [{ debugName: "previewButtonRef" }] : /* istanbul ignore next */ []);
13
+ this.closeButtonRef = viewChild("closeButton", ...ngDevMode ? [{ debugName: "closeButtonRef" }] : /* istanbul ignore next */ []);
14
+ this.imageClass = input(void 0, ...ngDevMode ? [{ debugName: "imageClass" }] : /* istanbul ignore next */ []);
15
+ this.imageStyle = input(void 0, ...ngDevMode ? [{ debugName: "imageStyle" }] : /* istanbul ignore next */ []);
16
+ this.src = input(void 0, ...ngDevMode ? [{ debugName: "src" }] : /* istanbul ignore next */ []);
17
+ this.srcSet = input(void 0, ...ngDevMode ? [{ debugName: "srcSet" }] : /* istanbul ignore next */ []);
18
+ this.previewImageSrc = input(void 0, ...ngDevMode ? [{ debugName: "previewImageSrc" }] : /* istanbul ignore next */ []);
19
+ this.previewImageSrcSet = input(void 0, ...ngDevMode ? [{ debugName: "previewImageSrcSet" }] : /* istanbul ignore next */ []);
20
+ this.alt = input(void 0, ...ngDevMode ? [{ debugName: "alt" }] : /* istanbul ignore next */ []);
21
+ this.width = input(void 0, ...ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []);
22
+ this.height = input(void 0, ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
23
+ this.loading = input(void 0, ...ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []);
24
+ this.appendTo = input(void 0, ...ngDevMode ? [{ debugName: "appendTo" }] : /* istanbul ignore next */ []);
25
+ this.preview = input(false, {
26
+ ...ngDevMode ? { debugName: "preview" } : /* istanbul ignore next */ {},
27
+ transform: booleanAttribute
28
+ });
29
+ this.previewShowChange = output();
30
+ this.imageErrorEvent = output();
31
+ this.maskVisible = signal(false, ...ngDevMode ? [{ debugName: "maskVisible" }] : /* istanbul ignore next */ []);
32
+ this.previewVisible = signal(false, ...ngDevMode ? [{ debugName: "previewVisible" }] : /* istanbul ignore next */ []);
33
+ this.rotate = signal(0, ...ngDevMode ? [{ debugName: "rotate" }] : /* istanbul ignore next */ []);
34
+ this.scale = signal(1, ...ngDevMode ? [{ debugName: "scale" }] : /* istanbul ignore next */ []);
35
+ this.isZoomOutDisabled = computed(() => {
36
+ return this.scale() - this._zoomSettings.step <= this._zoomSettings.min;
37
+ }, ...ngDevMode ? [{ debugName: "isZoomOutDisabled" }] : /* istanbul ignore next */ []);
38
+ this.isZoomInDisabled = computed(() => {
39
+ return this.scale() + this._zoomSettings.step >= this._zoomSettings.max;
40
+ }, ...ngDevMode ? [{ debugName: "isZoomInDisabled" }] : /* istanbul ignore next */ []);
41
+ this.imagePreviewStyle = computed(() => {
42
+ return { transform: `rotate(${this.rotate()}deg) scale(${this.scale()})` };
43
+ }, ...ngDevMode ? [{ debugName: "imagePreviewStyle" }] : /* istanbul ignore next */ []);
44
+ this._document = inject(DOCUMENT);
45
+ this._animationDuration = 150;
46
+ this._loadingPreview = false;
47
+ this._closePreviewByEscape = false;
48
+ this._closePreviewTimeoutId = null;
49
+ this._originalOverflow = null;
50
+ this._zoomSettings = {
51
+ default: 1,
52
+ step: .1,
53
+ max: 1.5,
54
+ min: .5
55
+ };
56
+ effect(() => {
57
+ const maskEl = this.maskRef();
58
+ if (maskEl && this._loadingPreview) this.appendContainer(maskEl);
59
+ });
60
+ effect(() => {
61
+ const btn = this.previewButtonRef();
62
+ if (btn && this._closePreviewByEscape) {
63
+ btn.focus();
64
+ this._closePreviewByEscape = false;
65
+ }
66
+ });
67
+ effect(() => {
68
+ const btn = this.closeButtonRef();
69
+ if (btn && this._loadingPreview) {
70
+ btn.focus();
71
+ this._loadingPreview = false;
72
+ }
73
+ });
74
+ }
75
+ onKeydownHandler() {
76
+ if (this.previewVisible()) {
77
+ this._enableBackgroundScroll();
78
+ this.closePreview();
79
+ }
80
+ }
81
+ onImageClick() {
82
+ if (this.preview()) {
83
+ this._disableBackgroundScroll();
84
+ this.maskVisible.set(true);
85
+ this._loadingPreview = true;
86
+ requestAnimationFrame(() => {
87
+ this.previewVisible.set(true);
88
+ this.previewShowChange.emit(true);
89
+ });
90
+ }
91
+ }
92
+ onMaskKeydown(event) {
93
+ switch (event.code) {
94
+ case "Escape":
95
+ this.closePreview();
96
+ this._closePreviewByEscape = true;
97
+ event.preventDefault();
98
+ }
99
+ }
100
+ onPreviewImageClick(event) {
101
+ event.stopPropagation();
102
+ }
103
+ rotateRight() {
104
+ this.rotate.update((r) => r + 90);
105
+ }
106
+ rotateLeft() {
107
+ this.rotate.update((r) => r - 90);
108
+ }
109
+ zoomIn() {
110
+ this.scale.update((s) => s + this._zoomSettings.step);
111
+ }
112
+ zoomOut() {
113
+ this.scale.update((s) => s - this._zoomSettings.step);
114
+ }
115
+ handleToolbarClick(event) {
116
+ event.stopPropagation();
117
+ }
118
+ appendContainer(maskElement) {
119
+ const elToAppend = maskElement ?? this.maskRef();
120
+ if (!elToAppend) return;
121
+ const target = this.appendTo();
122
+ if (target) {
123
+ if (target === "body") this._document.body.appendChild(elToAppend);
124
+ else {
125
+ let nativeElement = null;
126
+ if (target instanceof HTMLElement) nativeElement = target;
127
+ else if (target instanceof ElementRef) nativeElement = target.nativeElement;
128
+ else if (typeof target === "object" && target !== null && "el" in target) nativeElement = target.el?.nativeElement ?? null;
129
+ if (nativeElement) nativeElement.appendChild(elToAppend);
130
+ }
131
+ }
132
+ }
133
+ closePreview() {
134
+ if (this._closePreviewTimeoutId !== null) {
135
+ clearTimeout(this._closePreviewTimeoutId);
136
+ this._closePreviewTimeoutId = null;
137
+ }
138
+ this._enableBackgroundScroll();
139
+ this.previewVisible.set(false);
140
+ this._closePreviewTimeoutId = window.setTimeout(() => {
141
+ this.maskVisible.set(false);
142
+ this.rotate.set(0);
143
+ this.scale.set(this._zoomSettings.default);
144
+ this.previewShowChange.emit(false);
145
+ this._closePreviewTimeoutId = null;
146
+ }, this._animationDuration);
147
+ }
148
+ imageError(event) {
149
+ this.imageErrorEvent.emit(event);
150
+ }
151
+ _disableBackgroundScroll() {
152
+ const body = this._document.body;
153
+ this._originalOverflow = body.style.overflow;
154
+ body.style.overflow = "hidden";
155
+ }
156
+ _enableBackgroundScroll() {
157
+ const body = this._document.body;
158
+ body.style.overflow = this._originalOverflow ?? "";
159
+ }
160
+ static {
161
+ this.ɵfac = i0.ɵɵngDeclareFactory({
162
+ minVersion: "12.0.0",
163
+ version: "22.2.3",
164
+ ngImport: i0,
165
+ type: CmatImageComponent,
166
+ deps: [],
167
+ target: i0.ɵɵFactoryTarget.Component
168
+ });
169
+ }
170
+ static {
171
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
172
+ minVersion: "17.0.0",
173
+ version: "22.2.3",
174
+ type: CmatImageComponent,
175
+ isStandalone: true,
176
+ selector: "cmat-image",
177
+ inputs: {
178
+ imageClass: {
179
+ classPropertyName: "imageClass",
180
+ publicName: "imageClass",
181
+ isSignal: true,
182
+ isRequired: false,
183
+ transformFunction: null
184
+ },
185
+ imageStyle: {
186
+ classPropertyName: "imageStyle",
187
+ publicName: "imageStyle",
188
+ isSignal: true,
189
+ isRequired: false,
190
+ transformFunction: null
191
+ },
192
+ src: {
193
+ classPropertyName: "src",
194
+ publicName: "src",
195
+ isSignal: true,
196
+ isRequired: false,
197
+ transformFunction: null
198
+ },
199
+ srcSet: {
200
+ classPropertyName: "srcSet",
201
+ publicName: "srcSet",
202
+ isSignal: true,
203
+ isRequired: false,
204
+ transformFunction: null
205
+ },
206
+ previewImageSrc: {
207
+ classPropertyName: "previewImageSrc",
208
+ publicName: "previewImageSrc",
209
+ isSignal: true,
210
+ isRequired: false,
211
+ transformFunction: null
212
+ },
213
+ previewImageSrcSet: {
214
+ classPropertyName: "previewImageSrcSet",
215
+ publicName: "previewImageSrcSet",
216
+ isSignal: true,
217
+ isRequired: false,
218
+ transformFunction: null
219
+ },
220
+ alt: {
221
+ classPropertyName: "alt",
222
+ publicName: "alt",
223
+ isSignal: true,
224
+ isRequired: false,
225
+ transformFunction: null
226
+ },
227
+ width: {
228
+ classPropertyName: "width",
229
+ publicName: "width",
230
+ isSignal: true,
231
+ isRequired: false,
232
+ transformFunction: null
233
+ },
234
+ height: {
235
+ classPropertyName: "height",
236
+ publicName: "height",
237
+ isSignal: true,
238
+ isRequired: false,
239
+ transformFunction: null
240
+ },
241
+ loading: {
242
+ classPropertyName: "loading",
243
+ publicName: "loading",
244
+ isSignal: true,
245
+ isRequired: false,
246
+ transformFunction: null
247
+ },
248
+ appendTo: {
249
+ classPropertyName: "appendTo",
250
+ publicName: "appendTo",
251
+ isSignal: true,
252
+ isRequired: false,
253
+ transformFunction: null
254
+ },
255
+ preview: {
256
+ classPropertyName: "preview",
257
+ publicName: "preview",
258
+ isSignal: true,
259
+ isRequired: false,
260
+ transformFunction: null
261
+ }
262
+ },
263
+ outputs: {
264
+ previewShowChange: "previewShowChange",
265
+ imageErrorEvent: "imageErrorEvent"
266
+ },
267
+ host: { listeners: { "document:keydown.escape": "onKeydownHandler($event)" } },
268
+ viewQueries: [
269
+ {
270
+ propertyName: "maskRef",
271
+ first: true,
272
+ predicate: ["mask"],
273
+ descendants: true,
274
+ isSignal: true
275
+ },
276
+ {
277
+ propertyName: "previewButtonRef",
278
+ first: true,
279
+ predicate: ["previewButton"],
280
+ descendants: true,
281
+ isSignal: true
282
+ },
283
+ {
284
+ propertyName: "closeButtonRef",
285
+ first: true,
286
+ predicate: ["closeButton"],
287
+ descendants: true,
288
+ isSignal: true
289
+ }
290
+ ],
291
+ ngImport: i0,
292
+ template: "<span [ngClass]=\"{ 'cmat-image-preview-container ': preview() }\">\r\n <img \r\n [attr.src]=\"src()\" \r\n [attr.srcset]=\"srcSet()\" \r\n [attr.alt]=\"alt()\" \r\n [attr.width]=\"width()\" \r\n [attr.height]=\"height()\"\r\n [attr.loading]=\"loading()\" \r\n [ngStyle]=\"imageStyle()\" \r\n [class]=\"imageClass()\" \r\n (error)=\"imageError($event)\" />\r\n \r\n @if(preview()){\r\n <div class=\"cmat-image-preview-indicator\" role=\"presentation\" (click)=\"onImageClick()\">\r\n <button #previewButton matIconButton>\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'heroicons_solid:eye'\"></mat-icon>\r\n </button>\r\n </div>\r\n }\r\n\r\n @if(maskVisible()){\r\n <div #mask class=\"cmat-image-mask cmat-image-overlay cmat-image-overlay-enter\" animate.leave=\"cmat-image-overlay-leave\"\r\n role=\"dialog\" [attr.aria-modal]=\"maskVisible()\" (click)=\"closePreview()\" (keydown)=\"onMaskKeydown($event)\">\r\n <div class=\"cmat-image-toolbar\" role=\"presentation\" (click)=\"handleToolbarClick($event)\">\r\n <button matIconButton (click)=\"rotateRight()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:rotate_right'\"></mat-icon>\r\n </button>\r\n <button matIconButton (click)=\"rotateLeft()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:rotate_left'\"></mat-icon>\r\n </button>\r\n <!-- 绑定 computed signals -->\r\n <button matIconButton [disabled]=\"isZoomOutDisabled()\" (click)=\"zoomOut()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:zoom_out'\"></mat-icon>\r\n </button>\r\n <button matIconButton [disabled]=\"isZoomInDisabled()\" (click)=\"zoomIn()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:zoom_in'\"></mat-icon>\r\n </button>\r\n <button #closeButton matIconButton (click)=\"closePreview()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:close'\"></mat-icon>\r\n </button>\r\n </div>\r\n @if(previewVisible()){\r\n <div role=\"presentation\" class=\"cmat-image-preview-enter\" animate.leave=\"cmat-image-preview-leave\"\r\n (click)=\"onPreviewImageClick($event)\">\r\n <img class=\"cmat-image-preview\" alt=\"image\" \r\n [attr.src]=\"previewImageSrc() ? previewImageSrc() : src()\"\r\n [attr.srcset]=\"previewImageSrcSet()\" \r\n [ngStyle]=\"imagePreviewStyle()\" />\r\n </div>\r\n }\r\n </div>\r\n }\r\n\r\n</span>",
293
+ styles: [".cmat-image-mask{display:flex;align-items:center;justify-content:center}.cmat-image-preview-container{position:relative;display:inline-block;line-height:0}.cmat-image-preview-indicator{position:absolute;left:0;top:0;width:100%;height:100%;outline:none;border:none;padding:0;display:flex;align-items:center;justify-content:center;opacity:0;will-change:opacity,background-color;pointer-events:none;transition:opacity .3s ease}.cmat-image-preview-container:hover>.cmat-image-preview-indicator{opacity:1;cursor:pointer;background-color:#00000080;pointer-events:auto}.cmat-image-preview-container>img{cursor:pointer}.cmat-image-toolbar{position:absolute;top:0;right:0;display:flex;z-index:1;padding:.5rem}.cmat-image-preview{transition:transform .18s cubic-bezier(.2,0,0,1),opacity .18s cubic-bezier(.2,0,0,1);max-width:100vw;max-height:100vh;will-change:transform,opacity;transform-origin:center center;backface-visibility:hidden;transform:translateZ(0)}.cmat-image-preview-enter{animation:preview-enter-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-preview-leave{animation:preview-leave-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-overlay{background-color:#0006;transition:background-color .18s cubic-bezier(.2,0,0,1),opacity .18s cubic-bezier(.2,0,0,1);will-change:background-color,opacity;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:99}.cmat-image-overlay-enter{animation:image-overlay-enter-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-overlay-leave{z-index:0;animation:image-overlay-leave-animation .18s cubic-bezier(.2,0,0,1)}@keyframes preview-enter-animation{0%{transform:scale(.7);opacity:0}to{transform:scale(1);opacity:1}}@keyframes preview-leave-animation{0%{transform:scale(1);opacity:1}to{transform:scale(.7);opacity:0}}@keyframes image-overlay-enter-animation{0%{background-color:transparent}to{background-color:#000000e6}}@keyframes image-overlay-leave-animation{0%{background-color:#000000e6}to{background-color:transparent}}\n"],
294
+ dependencies: [
295
+ {
296
+ kind: "ngmodule",
297
+ type: CommonModule
298
+ },
299
+ {
300
+ kind: "directive",
301
+ type: i1.NgClass,
302
+ selector: "[ngClass]",
303
+ inputs: ["class", "ngClass"]
304
+ },
305
+ {
306
+ kind: "directive",
307
+ type: i1.NgStyle,
308
+ selector: "[ngStyle]",
309
+ inputs: ["ngStyle"]
310
+ },
311
+ {
312
+ kind: "ngmodule",
313
+ type: MatButtonModule
314
+ },
315
+ {
316
+ kind: "component",
317
+ type: i2.MatIconButton,
318
+ selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
319
+ exportAs: ["matButton", "matAnchor"]
320
+ },
321
+ {
322
+ kind: "ngmodule",
323
+ type: MatIconModule
324
+ },
325
+ {
326
+ kind: "component",
327
+ type: i3.MatIcon,
328
+ selector: "mat-icon",
329
+ inputs: [
330
+ "color",
331
+ "inline",
332
+ "svgIcon",
333
+ "fontSet",
334
+ "fontIcon"
335
+ ],
336
+ exportAs: ["matIcon"]
337
+ }
338
+ ],
339
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
340
+ encapsulation: i0.ViewEncapsulation.None
341
+ });
342
+ }
343
+ };
344
+ i0.ɵɵngDeclareClassMetadata({
345
+ minVersion: "12.0.0",
346
+ version: "22.2.3",
347
+ ngImport: i0,
348
+ type: CmatImageComponent,
349
+ decorators: [{
350
+ type: Component,
351
+ args: [{
352
+ selector: "cmat-image",
353
+ imports: [
354
+ CommonModule,
355
+ MatButtonModule,
356
+ MatIconModule
357
+ ],
358
+ changeDetection: ChangeDetectionStrategy.OnPush,
359
+ encapsulation: ViewEncapsulation.None,
360
+ template: "<span [ngClass]=\"{ 'cmat-image-preview-container ': preview() }\">\r\n <img \r\n [attr.src]=\"src()\" \r\n [attr.srcset]=\"srcSet()\" \r\n [attr.alt]=\"alt()\" \r\n [attr.width]=\"width()\" \r\n [attr.height]=\"height()\"\r\n [attr.loading]=\"loading()\" \r\n [ngStyle]=\"imageStyle()\" \r\n [class]=\"imageClass()\" \r\n (error)=\"imageError($event)\" />\r\n \r\n @if(preview()){\r\n <div class=\"cmat-image-preview-indicator\" role=\"presentation\" (click)=\"onImageClick()\">\r\n <button #previewButton matIconButton>\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'heroicons_solid:eye'\"></mat-icon>\r\n </button>\r\n </div>\r\n }\r\n\r\n @if(maskVisible()){\r\n <div #mask class=\"cmat-image-mask cmat-image-overlay cmat-image-overlay-enter\" animate.leave=\"cmat-image-overlay-leave\"\r\n role=\"dialog\" [attr.aria-modal]=\"maskVisible()\" (click)=\"closePreview()\" (keydown)=\"onMaskKeydown($event)\">\r\n <div class=\"cmat-image-toolbar\" role=\"presentation\" (click)=\"handleToolbarClick($event)\">\r\n <button matIconButton (click)=\"rotateRight()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:rotate_right'\"></mat-icon>\r\n </button>\r\n <button matIconButton (click)=\"rotateLeft()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:rotate_left'\"></mat-icon>\r\n </button>\r\n <!-- 绑定 computed signals -->\r\n <button matIconButton [disabled]=\"isZoomOutDisabled()\" (click)=\"zoomOut()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:zoom_out'\"></mat-icon>\r\n </button>\r\n <button matIconButton [disabled]=\"isZoomInDisabled()\" (click)=\"zoomIn()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:zoom_in'\"></mat-icon>\r\n </button>\r\n <button #closeButton matIconButton (click)=\"closePreview()\">\r\n <mat-icon class=\"text-white\" [svgIcon]=\"'mat_solid:close'\"></mat-icon>\r\n </button>\r\n </div>\r\n @if(previewVisible()){\r\n <div role=\"presentation\" class=\"cmat-image-preview-enter\" animate.leave=\"cmat-image-preview-leave\"\r\n (click)=\"onPreviewImageClick($event)\">\r\n <img class=\"cmat-image-preview\" alt=\"image\" \r\n [attr.src]=\"previewImageSrc() ? previewImageSrc() : src()\"\r\n [attr.srcset]=\"previewImageSrcSet()\" \r\n [ngStyle]=\"imagePreviewStyle()\" />\r\n </div>\r\n }\r\n </div>\r\n }\r\n\r\n</span>",
361
+ styles: [".cmat-image-mask{display:flex;align-items:center;justify-content:center}.cmat-image-preview-container{position:relative;display:inline-block;line-height:0}.cmat-image-preview-indicator{position:absolute;left:0;top:0;width:100%;height:100%;outline:none;border:none;padding:0;display:flex;align-items:center;justify-content:center;opacity:0;will-change:opacity,background-color;pointer-events:none;transition:opacity .3s ease}.cmat-image-preview-container:hover>.cmat-image-preview-indicator{opacity:1;cursor:pointer;background-color:#00000080;pointer-events:auto}.cmat-image-preview-container>img{cursor:pointer}.cmat-image-toolbar{position:absolute;top:0;right:0;display:flex;z-index:1;padding:.5rem}.cmat-image-preview{transition:transform .18s cubic-bezier(.2,0,0,1),opacity .18s cubic-bezier(.2,0,0,1);max-width:100vw;max-height:100vh;will-change:transform,opacity;transform-origin:center center;backface-visibility:hidden;transform:translateZ(0)}.cmat-image-preview-enter{animation:preview-enter-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-preview-leave{animation:preview-leave-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-overlay{background-color:#0006;transition:background-color .18s cubic-bezier(.2,0,0,1),opacity .18s cubic-bezier(.2,0,0,1);will-change:background-color,opacity;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:99}.cmat-image-overlay-enter{animation:image-overlay-enter-animation .18s cubic-bezier(.2,0,0,1)}.cmat-image-overlay-leave{z-index:0;animation:image-overlay-leave-animation .18s cubic-bezier(.2,0,0,1)}@keyframes preview-enter-animation{0%{transform:scale(.7);opacity:0}to{transform:scale(1);opacity:1}}@keyframes preview-leave-animation{0%{transform:scale(1);opacity:1}to{transform:scale(.7);opacity:0}}@keyframes image-overlay-enter-animation{0%{background-color:transparent}to{background-color:#000000e6}}@keyframes image-overlay-leave-animation{0%{background-color:#000000e6}to{background-color:transparent}}\n"]
362
+ }]
363
+ }],
364
+ ctorParameters: () => [],
365
+ propDecorators: {
366
+ maskRef: [{
367
+ type: i0.ViewChild,
368
+ args: ["mask", { isSignal: true }]
369
+ }],
370
+ previewButtonRef: [{
371
+ type: i0.ViewChild,
372
+ args: ["previewButton", { isSignal: true }]
373
+ }],
374
+ closeButtonRef: [{
375
+ type: i0.ViewChild,
376
+ args: ["closeButton", { isSignal: true }]
377
+ }],
378
+ imageClass: [{
379
+ type: i0.Input,
380
+ args: [{
381
+ isSignal: true,
382
+ alias: "imageClass",
383
+ required: false
384
+ }]
385
+ }],
386
+ imageStyle: [{
387
+ type: i0.Input,
388
+ args: [{
389
+ isSignal: true,
390
+ alias: "imageStyle",
391
+ required: false
392
+ }]
393
+ }],
394
+ src: [{
395
+ type: i0.Input,
396
+ args: [{
397
+ isSignal: true,
398
+ alias: "src",
399
+ required: false
400
+ }]
401
+ }],
402
+ srcSet: [{
403
+ type: i0.Input,
404
+ args: [{
405
+ isSignal: true,
406
+ alias: "srcSet",
407
+ required: false
408
+ }]
409
+ }],
410
+ previewImageSrc: [{
411
+ type: i0.Input,
412
+ args: [{
413
+ isSignal: true,
414
+ alias: "previewImageSrc",
415
+ required: false
416
+ }]
417
+ }],
418
+ previewImageSrcSet: [{
419
+ type: i0.Input,
420
+ args: [{
421
+ isSignal: true,
422
+ alias: "previewImageSrcSet",
423
+ required: false
424
+ }]
425
+ }],
426
+ alt: [{
427
+ type: i0.Input,
428
+ args: [{
429
+ isSignal: true,
430
+ alias: "alt",
431
+ required: false
432
+ }]
433
+ }],
434
+ width: [{
435
+ type: i0.Input,
436
+ args: [{
437
+ isSignal: true,
438
+ alias: "width",
439
+ required: false
440
+ }]
441
+ }],
442
+ height: [{
443
+ type: i0.Input,
444
+ args: [{
445
+ isSignal: true,
446
+ alias: "height",
447
+ required: false
448
+ }]
449
+ }],
450
+ loading: [{
451
+ type: i0.Input,
452
+ args: [{
453
+ isSignal: true,
454
+ alias: "loading",
455
+ required: false
456
+ }]
457
+ }],
458
+ appendTo: [{
459
+ type: i0.Input,
460
+ args: [{
461
+ isSignal: true,
462
+ alias: "appendTo",
463
+ required: false
464
+ }]
465
+ }],
466
+ preview: [{
467
+ type: i0.Input,
468
+ args: [{
469
+ isSignal: true,
470
+ alias: "preview",
471
+ required: false
472
+ }]
473
+ }],
474
+ previewShowChange: [{
475
+ type: i0.Output,
476
+ args: ["previewShowChange"]
477
+ }],
478
+ imageErrorEvent: [{
479
+ type: i0.Output,
480
+ args: ["imageErrorEvent"]
481
+ }],
482
+ onKeydownHandler: [{
483
+ type: HostListener,
484
+ args: ["document:keydown.escape", ["$event"]]
485
+ }]
486
+ }
487
+ });
215
488
  export { CmatImageComponent };
216
- //# sourceMappingURL=cmat-components-image-viewer.mjs.map
489
+
490
+ //# sourceMappingURL=cmat-components-image-viewer.mjs.map