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,345 +1,544 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, inject, Injector, input, Directive } from '@angular/core';
3
- import dayjs from 'dayjs';
4
- import * as FileSaver from 'file-saver-es';
5
-
1
+ import * as i0 from "@angular/core";
2
+ import { Directive, Injectable, Injector, inject, input } from "@angular/core";
3
+ import dayjs from "dayjs";
4
+ import * as FileSaver from "file-saver-es";
6
5
  var ExportType;
7
- (function (ExportType) {
8
- ExportType["XLS"] = "xls";
9
- ExportType["XLSX"] = "xlsx";
10
- ExportType["CSV"] = "csv";
11
- ExportType["TXT"] = "txt";
12
- ExportType["JSON"] = "json";
6
+ (function(ExportType) {
7
+ ExportType["XLS"] = "xls";
8
+ ExportType["XLSX"] = "xlsx";
9
+ ExportType["CSV"] = "csv";
10
+ ExportType["TXT"] = "txt";
11
+ ExportType["JSON"] = "json";
13
12
  })(ExportType || (ExportType = {}));
14
-
15
- class Mime {
16
- constructor(extension, contentTypeHeader) {
17
- this.extension = extension;
18
- this.contentTypeHeader = contentTypeHeader;
19
- }
20
- }
21
-
22
- const TYPE_ARRAY = 'array';
23
- const CHAR_SET_UTF = ';charset=utf-';
24
- const CHAR_SET_UTF_8 = CHAR_SET_UTF + '8';
25
- const CONTENT_TYPE_TEXT = ExportType.TXT + '/';
26
- const CONTENT_TYPE_APPLICATION = 'application/';
27
- const CONTENT_TYPE_EXCEL = CONTENT_TYPE_APPLICATION + 'octet-stream';
28
- const CONTENT_TYPE_JSON = CONTENT_TYPE_APPLICATION + 'json';
29
- const DOT = '.';
30
- const COMMA = ',';
31
- const EXTENSION_XLS = DOT + ExportType.XLS;
32
- const EXTENSION_XLSX = DOT + ExportType.XLSX;
33
- const EXTENSION_CSV = DOT + ExportType.CSV;
34
- const EXTENSION_JSON = DOT + ExportType.JSON;
35
- const EXTENSION_TEXT = DOT + ExportType.TXT;
13
+ var Mime = class {
14
+ constructor(extension, contentTypeHeader) {
15
+ this.extension = extension;
16
+ this.contentTypeHeader = contentTypeHeader;
17
+ }
18
+ };
19
+ const TYPE_ARRAY = "array";
20
+ const CHAR_SET_UTF_8 = ";charset=utf-8";
21
+ const CONTENT_TYPE_TEXT = ExportType.TXT + "/";
22
+ const CONTENT_TYPE_EXCEL = "application/octet-stream";
23
+ const EXTENSION_XLS = "." + ExportType.XLS;
24
+ const EXTENSION_XLSX = "." + ExportType.XLSX;
25
+ const EXTENSION_CSV = "." + ExportType.CSV;
26
+ const EXTENSION_JSON = "." + ExportType.JSON;
27
+ const EXTENSION_TEXT = "." + ExportType.TXT;
36
28
  const MIME_EXCEL_XLS = new Mime(EXTENSION_XLS, CONTENT_TYPE_EXCEL + CHAR_SET_UTF_8);
37
29
  const MIME_EXCEL_XLSX = new Mime(EXTENSION_XLSX, CONTENT_TYPE_EXCEL + CHAR_SET_UTF_8);
38
- const MIME_JSON = new Mime(EXTENSION_JSON, CONTENT_TYPE_JSON + CHAR_SET_UTF_8);
30
+ const MIME_JSON = new Mime(EXTENSION_JSON, "application/json;charset=utf-8");
39
31
  const MIME_TXT = new Mime(EXTENSION_TEXT, CONTENT_TYPE_TEXT + ExportType.TXT + CHAR_SET_UTF_8);
40
32
  const MIME_CSV = new Mime(EXTENSION_CSV, CONTENT_TYPE_TEXT + ExportType.CSV + CHAR_SET_UTF_8);
41
- const REF = '!ref';
42
- const XLS_REGEX = DOT + '*.' + ExportType.XLS + '$';
43
- const RETURN = '\n';
44
- const TAB = '\t';
45
- const XLSX_COLS = '!cols';
46
- const BOM = '\uFEFF';
47
-
48
- class FileUtil {
49
- static save(content, mime, options) {
50
- const blob = new Blob([content], { type: mime.contentTypeHeader });
51
- let fileName = '附件';
52
- if (options?.fileName) {
53
- fileName = options.fileName;
54
- }
55
- FileSaver.saveAs(blob, fileName + mime.extension);
56
- }
57
- static isXls(fileName) {
58
- return fileName.toLowerCase().match(XLS_REGEX) != null;
59
- }
60
- static identifyExportType(fileName) {
61
- if (fileName && FileUtil.isXls(fileName)) {
62
- return ExportType.XLS;
63
- }
64
- else {
65
- return ExportType.XLSX;
66
- }
67
- }
68
- static removeExtension(options) {
69
- if (options)
70
- options.fileName = options.fileName?.split(DOT)[0];
71
- }
72
- }
73
-
74
- class FileExporter {
75
- export(rows, options) {
76
- if (!rows) {
77
- throw new Error('Empty json array is provided, rows parameter is mandatory!');
78
- }
79
- const mimeType = this.getMimeType();
80
- void this.createContent(rows, options).then((content) => {
81
- FileUtil.save(content, mimeType, options);
82
- });
83
- }
84
- }
85
-
86
- class WorksheetExporter extends FileExporter {
87
- constructor() {
88
- super();
89
- }
90
- async createContent(rows, options) {
91
- const workSheet = (await import('xlsx')).utils.json_to_sheet(rows, {
92
- skipHeader: true
93
- });
94
- return await this.workSheetToContent(workSheet, options);
95
- }
96
- }
97
-
98
- class CsvExporterService extends WorksheetExporter {
99
- constructor() {
100
- super();
101
- }
102
- async workSheetToContent(worksheet, options) {
103
- // eslint-disable-next-line @typescript-eslint/naming-convention
104
- const content = (await import('xlsx')).utils.sheet_to_csv(worksheet, { FS: options?.delimiter ?? COMMA });
105
- return BOM + content;
106
- }
107
- getMimeType() {
108
- return MIME_CSV;
109
- }
110
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CsvExporterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
111
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CsvExporterService, providedIn: 'root' }); }
112
- }
113
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CsvExporterService, decorators: [{
114
- type: Injectable,
115
- args: [{
116
- providedIn: 'root'
117
- }]
118
- }], ctorParameters: () => [] });
119
-
120
- class JsonExporterService extends FileExporter {
121
- constructor() {
122
- super();
123
- }
124
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
125
- async createContent(rows, options) {
126
- return await new Promise((resolve) => {
127
- resolve(JSON.stringify(rows));
128
- });
129
- ;
130
- }
131
- getMimeType() {
132
- return MIME_JSON;
133
- }
134
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: JsonExporterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
135
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: JsonExporterService, providedIn: 'root' }); }
136
- }
137
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: JsonExporterService, decorators: [{
138
- type: Injectable,
139
- args: [{
140
- providedIn: 'root'
141
- }]
142
- }], ctorParameters: () => [] });
143
-
144
- class TxtExporterService extends FileExporter {
145
- constructor() {
146
- super();
147
- }
148
- async createContent(rows, options) {
149
- return await new Promise((resolve) => {
150
- let content = '';
151
- rows.forEach((element) => {
152
- content += Object.values(element).join(this._getDelimiter(options)) + RETURN;
153
- });
154
- resolve(JSON.stringify(content));
155
- });
156
- }
157
- getMimeType() {
158
- return MIME_TXT;
159
- }
160
- _getDelimiter(options) {
161
- if (options?.delimiter) {
162
- return options.delimiter;
163
- }
164
- else {
165
- return TAB;
166
- }
167
- }
168
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: TxtExporterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
169
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: TxtExporterService, providedIn: 'root' }); }
170
- }
171
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: TxtExporterService, decorators: [{
172
- type: Injectable,
173
- args: [{
174
- providedIn: 'root'
175
- }]
176
- }], ctorParameters: () => [] });
177
-
178
- class XlsExporterService extends WorksheetExporter {
179
- constructor() {
180
- super();
181
- }
182
- async workSheetToContent(worksheet, options = {}) {
183
- const { utils, write } = await import('xlsx');
184
- const workBook = utils.book_new();
185
- this._correctTypes(options);
186
- utils.book_append_sheet(workBook, worksheet, options.sheet);
187
- if (options.columnWidths) {
188
- worksheet[XLSX_COLS] = this._convertToWch(options.columnWidths);
189
- }
190
- else {
191
- const jsonTable = utils.sheet_to_json(worksheet, {
192
- header: 1,
193
- raw: true,
194
- rawNumbers: true,
195
- });
196
- const maxRowSize = Math.max(...jsonTable.map(row => row.length));
197
- const wchArray = Array.from({ length: maxRowSize }).map((_, rowIndex) => {
198
- const row = Array.from({ length: jsonTable.length }).map((_, i) => String(jsonTable[i][rowIndex] ?? '').length);
199
- return { wch: Math.max(...row) * 3 > 40 ? 40 : Math.max(...row) * 3 };
200
- });
201
- worksheet[XLSX_COLS] = wchArray;
202
- }
203
- return write(workBook, options);
204
- }
205
- getMimeType() {
206
- return MIME_EXCEL_XLS;
207
- }
208
- _correctTypes(options) {
209
- options.type ??= TYPE_ARRAY;
210
- options.bookType = this.getMimeType().extension.replace('.', ''); // sheetjs requires bookingType for excel format
211
- }
212
- _convertToWch(columnWidths) {
213
- return columnWidths.map(width => ({ wch: width }));
214
- }
215
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: XlsExporterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
216
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: XlsExporterService, providedIn: 'root' }); }
217
- }
218
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: XlsExporterService, decorators: [{
219
- type: Injectable,
220
- args: [{
221
- providedIn: 'root'
222
- }]
223
- }], ctorParameters: () => [] });
224
-
225
- class XlsxExporterService extends XlsExporterService {
226
- constructor() {
227
- super();
228
- }
229
- getMimeType() {
230
- return MIME_EXCEL_XLSX;
231
- }
232
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: XlsxExporterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
233
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: XlsxExporterService, providedIn: 'root' }); }
234
- }
235
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: XlsxExporterService, decorators: [{
236
- type: Injectable,
237
- args: [{
238
- providedIn: 'root'
239
- }]
240
- }], ctorParameters: () => [] });
241
-
242
- class ServiceLocatorService {
243
- constructor() {
244
- this._injector = inject(Injector);
245
- }
246
- getService(exportType) {
247
- switch (exportType) {
248
- case 'xls':
249
- case ExportType.XLS:
250
- return this._injector.get(XlsExporterService);
251
- case 'xlsx':
252
- case ExportType.XLSX:
253
- return this._injector.get(XlsxExporterService);
254
- case 'json':
255
- case ExportType.JSON:
256
- return this._injector.get(JsonExporterService);
257
- case 'txt':
258
- case ExportType.TXT:
259
- return this._injector.get(TxtExporterService);
260
- case 'csv':
261
- case ExportType.CSV:
262
- return this._injector.get(CsvExporterService);
263
- default:
264
- return this._injector.get(XlsxExporterService);
265
- }
266
- }
267
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ServiceLocatorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
268
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ServiceLocatorService, providedIn: 'root' }); }
269
- }
270
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ServiceLocatorService, decorators: [{
271
- type: Injectable,
272
- args: [{
273
- providedIn: 'root'
274
- }]
275
- }] });
276
-
277
- class CmatDataExporterDirective {
278
- constructor() {
279
- this.dataSource = input([], /* @ts-ignore */
280
- ...(ngDevMode ? [{ debugName: "dataSource" }] : /* istanbul ignore next */ []));
281
- this.exportColumns = input([], /* @ts-ignore */
282
- ...(ngDevMode ? [{ debugName: "exportColumns" }] : /* istanbul ignore next */ []));
283
- this.options = input(/* @ts-ignore */
284
- ...(ngDevMode ? [undefined, { debugName: "options" }] : /* istanbul ignore next */ []));
285
- this.exportType = input('xlsx', /* @ts-ignore */
286
- ...(ngDevMode ? [{ debugName: "exportType" }] : /* istanbul ignore next */ []));
287
- this.transformBoolean = input(true, /* @ts-ignore */
288
- ...(ngDevMode ? [{ debugName: "transformBoolean" }] : /* istanbul ignore next */ []));
289
- this.transformDate = input(true, /* @ts-ignore */
290
- ...(ngDevMode ? [{ debugName: "transformDate" }] : /* istanbul ignore next */ []));
291
- this.dateFormat = input('YYYY-MM-DD', /* @ts-ignore */
292
- ...(ngDevMode ? [{ debugName: "dateFormat" }] : /* istanbul ignore next */ []));
293
- this._serviceLocator = inject(ServiceLocatorService);
294
- }
295
- ngOnChanges(changes) {
296
- if (changes.dataSource) {
297
- if (this.dataSource()?.length > 0) {
298
- this._data = [];
299
- this._loadExporter(this.exportType());
300
- this._data = [
301
- this.exportColumns()
302
- .map(column => ({ [column.code]: column.label }))
303
- .reduce((acc, curr) => ({ ...acc, ...curr }), {}),
304
- ...this.dataSource().map(user => this.exportColumns().reduce((acc, column) => {
305
- let value = user[column.code];
306
- if (this.transformBoolean() && typeof value === 'boolean') {
307
- value = value ? '是' : '否';
308
- }
309
- else if (this.transformDate() &&
310
- (value instanceof Date || typeof value === 'string')) {
311
- const datePattern = /^\d{4}[-/]\d{1,2}[-/]\d{1,2}/;
312
- if (typeof value === 'string' && !datePattern.test(value)) {
313
- return { ...acc, [column.code]: value };
314
- }
315
- const dateValue = dayjs(value);
316
- if (dateValue.isValid()) {
317
- value = dateValue.format(this.dateFormat());
318
- }
319
- }
320
- return { ...acc, [column.code]: value };
321
- }, {})),
322
- ];
323
- this._exporterService.export(this._data, this.options());
324
- }
325
- }
326
- }
327
- _loadExporter(exportType) {
328
- this._exporterService = this._serviceLocator.getService(exportType);
329
- }
330
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatDataExporterDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
331
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: CmatDataExporterDirective, isStandalone: true, selector: "button[cmatDataExporter]", inputs: { dataSource: { classPropertyName: "dataSource", publicName: "dataSource", isSignal: true, isRequired: false, transformFunction: null }, exportColumns: { classPropertyName: "exportColumns", publicName: "exportColumns", isSignal: true, isRequired: false, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: false, transformFunction: null }, exportType: { classPropertyName: "exportType", publicName: "exportType", isSignal: true, isRequired: false, transformFunction: null }, transformBoolean: { classPropertyName: "transformBoolean", publicName: "transformBoolean", isSignal: true, isRequired: false, transformFunction: null }, transformDate: { classPropertyName: "transformDate", publicName: "transformDate", isSignal: true, isRequired: false, transformFunction: null }, dateFormat: { classPropertyName: "dateFormat", publicName: "dateFormat", isSignal: true, isRequired: false, transformFunction: null } }, usesOnChanges: true, ngImport: i0 }); }
332
- }
333
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatDataExporterDirective, decorators: [{
334
- type: Directive,
335
- args: [{
336
- selector: 'button[cmatDataExporter]',
337
- }]
338
- }], propDecorators: { dataSource: [{ type: i0.Input, args: [{ isSignal: true, alias: "dataSource", required: false }] }], exportColumns: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportColumns", required: false }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: false }] }], exportType: [{ type: i0.Input, args: [{ isSignal: true, alias: "exportType", required: false }] }], transformBoolean: [{ type: i0.Input, args: [{ isSignal: true, alias: "transformBoolean", required: false }] }], transformDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "transformDate", required: false }] }], dateFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateFormat", required: false }] }] } });
339
-
340
- /**
341
- * Generated bundle index. Do not edit.
342
- */
343
-
33
+ const XLS_REGEX = ".*." + ExportType.XLS + "$";
34
+ const XLSX_COLS = "!cols";
35
+ var FileUtil = class FileUtil {
36
+ static save(content, mime, options) {
37
+ const blob = new Blob([content], { type: mime.contentTypeHeader });
38
+ let fileName = "附件";
39
+ if (options?.fileName) fileName = options.fileName;
40
+ FileSaver.saveAs(blob, fileName + mime.extension);
41
+ }
42
+ static isXls(fileName) {
43
+ return fileName.toLowerCase().match(XLS_REGEX) != null;
44
+ }
45
+ static identifyExportType(fileName) {
46
+ if (fileName && FileUtil.isXls(fileName)) return ExportType.XLS;
47
+ else return ExportType.XLSX;
48
+ }
49
+ static removeExtension(options) {
50
+ if (options) options.fileName = options.fileName?.split(".")[0];
51
+ }
52
+ };
53
+ var FileExporter = class {
54
+ export(rows, options) {
55
+ if (!rows) throw new Error("Empty json array is provided, rows parameter is mandatory!");
56
+ const mimeType = this.getMimeType();
57
+ this.createContent(rows, options).then((content) => {
58
+ FileUtil.save(content, mimeType, options);
59
+ });
60
+ }
61
+ };
62
+ var WorksheetExporter = class extends FileExporter {
63
+ constructor() {
64
+ super();
65
+ }
66
+ async createContent(rows, options) {
67
+ const workSheet = (await import("xlsx")).utils.json_to_sheet(rows, { skipHeader: true });
68
+ return await this.workSheetToContent(workSheet, options);
69
+ }
70
+ };
71
+ var CsvExporterService = class CsvExporterService extends WorksheetExporter {
72
+ constructor() {
73
+ super();
74
+ }
75
+ async workSheetToContent(worksheet, options) {
76
+ return "" + (await import("xlsx")).utils.sheet_to_csv(worksheet, { FS: options?.delimiter ?? "," });
77
+ }
78
+ getMimeType() {
79
+ return MIME_CSV;
80
+ }
81
+ static {
82
+ this.ɵfac = i0.ɵɵngDeclareFactory({
83
+ minVersion: "12.0.0",
84
+ version: "22.2.3",
85
+ ngImport: i0,
86
+ type: CsvExporterService,
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: CsvExporterService,
97
+ providedIn: "root"
98
+ });
99
+ }
100
+ };
101
+ i0.ɵɵngDeclareClassMetadata({
102
+ minVersion: "12.0.0",
103
+ version: "22.2.3",
104
+ ngImport: i0,
105
+ type: CsvExporterService,
106
+ decorators: [{
107
+ type: Injectable,
108
+ args: [{ providedIn: "root" }]
109
+ }],
110
+ ctorParameters: () => []
111
+ });
112
+ var JsonExporterService = class JsonExporterService extends FileExporter {
113
+ constructor() {
114
+ super();
115
+ }
116
+ async createContent(rows, options) {
117
+ return await new Promise((resolve) => {
118
+ resolve(JSON.stringify(rows));
119
+ });
120
+ }
121
+ getMimeType() {
122
+ return MIME_JSON;
123
+ }
124
+ static {
125
+ this.ɵfac = i0.ɵɵngDeclareFactory({
126
+ minVersion: "12.0.0",
127
+ version: "22.2.3",
128
+ ngImport: i0,
129
+ type: JsonExporterService,
130
+ deps: [],
131
+ target: i0.ɵɵFactoryTarget.Injectable
132
+ });
133
+ }
134
+ static {
135
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
136
+ minVersion: "12.0.0",
137
+ version: "22.2.3",
138
+ ngImport: i0,
139
+ type: JsonExporterService,
140
+ providedIn: "root"
141
+ });
142
+ }
143
+ };
144
+ i0.ɵɵngDeclareClassMetadata({
145
+ minVersion: "12.0.0",
146
+ version: "22.2.3",
147
+ ngImport: i0,
148
+ type: JsonExporterService,
149
+ decorators: [{
150
+ type: Injectable,
151
+ args: [{ providedIn: "root" }]
152
+ }],
153
+ ctorParameters: () => []
154
+ });
155
+ var TxtExporterService = class TxtExporterService extends FileExporter {
156
+ constructor() {
157
+ super();
158
+ }
159
+ async createContent(rows, options) {
160
+ return await new Promise((resolve) => {
161
+ let content = "";
162
+ rows.forEach((element) => {
163
+ content += Object.values(element).join(this._getDelimiter(options)) + "\n";
164
+ });
165
+ resolve(JSON.stringify(content));
166
+ });
167
+ }
168
+ getMimeType() {
169
+ return MIME_TXT;
170
+ }
171
+ _getDelimiter(options) {
172
+ if (options?.delimiter) return options.delimiter;
173
+ else return " ";
174
+ }
175
+ static {
176
+ this.ɵfac = i0.ɵɵngDeclareFactory({
177
+ minVersion: "12.0.0",
178
+ version: "22.2.3",
179
+ ngImport: i0,
180
+ type: TxtExporterService,
181
+ deps: [],
182
+ target: i0.ɵɵFactoryTarget.Injectable
183
+ });
184
+ }
185
+ static {
186
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
187
+ minVersion: "12.0.0",
188
+ version: "22.2.3",
189
+ ngImport: i0,
190
+ type: TxtExporterService,
191
+ providedIn: "root"
192
+ });
193
+ }
194
+ };
195
+ i0.ɵɵngDeclareClassMetadata({
196
+ minVersion: "12.0.0",
197
+ version: "22.2.3",
198
+ ngImport: i0,
199
+ type: TxtExporterService,
200
+ decorators: [{
201
+ type: Injectable,
202
+ args: [{ providedIn: "root" }]
203
+ }],
204
+ ctorParameters: () => []
205
+ });
206
+ var XlsExporterService = class XlsExporterService extends WorksheetExporter {
207
+ constructor() {
208
+ super();
209
+ }
210
+ async workSheetToContent(worksheet, options = {}) {
211
+ const { utils, write } = await import("xlsx");
212
+ const workBook = utils.book_new();
213
+ this._correctTypes(options);
214
+ utils.book_append_sheet(workBook, worksheet, options.sheet);
215
+ if (options.columnWidths) worksheet[XLSX_COLS] = this._convertToWch(options.columnWidths);
216
+ else {
217
+ const jsonTable = utils.sheet_to_json(worksheet, {
218
+ header: 1,
219
+ raw: true,
220
+ rawNumbers: true
221
+ });
222
+ const maxRowSize = Math.max(...jsonTable.map((row) => row.length));
223
+ const wchArray = Array.from({ length: maxRowSize }).map((_, rowIndex) => {
224
+ const row = Array.from({ length: jsonTable.length }).map((_, i) => String(jsonTable[i][rowIndex] ?? "").length);
225
+ return { wch: Math.max(...row) * 3 > 40 ? 40 : Math.max(...row) * 3 };
226
+ });
227
+ worksheet[XLSX_COLS] = wchArray;
228
+ }
229
+ return write(workBook, options);
230
+ }
231
+ getMimeType() {
232
+ return MIME_EXCEL_XLS;
233
+ }
234
+ _correctTypes(options) {
235
+ options.type ??= TYPE_ARRAY;
236
+ options.bookType = this.getMimeType().extension.replace(".", "");
237
+ }
238
+ _convertToWch(columnWidths) {
239
+ return columnWidths.map((width) => ({ wch: width }));
240
+ }
241
+ static {
242
+ this.ɵfac = i0.ɵɵngDeclareFactory({
243
+ minVersion: "12.0.0",
244
+ version: "22.2.3",
245
+ ngImport: i0,
246
+ type: XlsExporterService,
247
+ deps: [],
248
+ target: i0.ɵɵFactoryTarget.Injectable
249
+ });
250
+ }
251
+ static {
252
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
253
+ minVersion: "12.0.0",
254
+ version: "22.2.3",
255
+ ngImport: i0,
256
+ type: XlsExporterService,
257
+ providedIn: "root"
258
+ });
259
+ }
260
+ };
261
+ i0.ɵɵngDeclareClassMetadata({
262
+ minVersion: "12.0.0",
263
+ version: "22.2.3",
264
+ ngImport: i0,
265
+ type: XlsExporterService,
266
+ decorators: [{
267
+ type: Injectable,
268
+ args: [{ providedIn: "root" }]
269
+ }],
270
+ ctorParameters: () => []
271
+ });
272
+ var XlsxExporterService = class XlsxExporterService extends XlsExporterService {
273
+ constructor() {
274
+ super();
275
+ }
276
+ getMimeType() {
277
+ return MIME_EXCEL_XLSX;
278
+ }
279
+ static {
280
+ this.ɵfac = i0.ɵɵngDeclareFactory({
281
+ minVersion: "12.0.0",
282
+ version: "22.2.3",
283
+ ngImport: i0,
284
+ type: XlsxExporterService,
285
+ deps: [],
286
+ target: i0.ɵɵFactoryTarget.Injectable
287
+ });
288
+ }
289
+ static {
290
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
291
+ minVersion: "12.0.0",
292
+ version: "22.2.3",
293
+ ngImport: i0,
294
+ type: XlsxExporterService,
295
+ providedIn: "root"
296
+ });
297
+ }
298
+ };
299
+ i0.ɵɵngDeclareClassMetadata({
300
+ minVersion: "12.0.0",
301
+ version: "22.2.3",
302
+ ngImport: i0,
303
+ type: XlsxExporterService,
304
+ decorators: [{
305
+ type: Injectable,
306
+ args: [{ providedIn: "root" }]
307
+ }],
308
+ ctorParameters: () => []
309
+ });
310
+ var ServiceLocatorService = class ServiceLocatorService {
311
+ constructor() {
312
+ this._injector = inject(Injector);
313
+ }
314
+ getService(exportType) {
315
+ switch (exportType) {
316
+ case "xls":
317
+ case ExportType.XLS: return this._injector.get(XlsExporterService);
318
+ case "xlsx":
319
+ case ExportType.XLSX: return this._injector.get(XlsxExporterService);
320
+ case "json":
321
+ case ExportType.JSON: return this._injector.get(JsonExporterService);
322
+ case "txt":
323
+ case ExportType.TXT: return this._injector.get(TxtExporterService);
324
+ case "csv":
325
+ case ExportType.CSV: return this._injector.get(CsvExporterService);
326
+ default: return this._injector.get(XlsxExporterService);
327
+ }
328
+ }
329
+ static {
330
+ this.ɵfac = i0.ɵɵngDeclareFactory({
331
+ minVersion: "12.0.0",
332
+ version: "22.2.3",
333
+ ngImport: i0,
334
+ type: ServiceLocatorService,
335
+ deps: [],
336
+ target: i0.ɵɵFactoryTarget.Injectable
337
+ });
338
+ }
339
+ static {
340
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
341
+ minVersion: "12.0.0",
342
+ version: "22.2.3",
343
+ ngImport: i0,
344
+ type: ServiceLocatorService,
345
+ providedIn: "root"
346
+ });
347
+ }
348
+ };
349
+ i0.ɵɵngDeclareClassMetadata({
350
+ minVersion: "12.0.0",
351
+ version: "22.2.3",
352
+ ngImport: i0,
353
+ type: ServiceLocatorService,
354
+ decorators: [{
355
+ type: Injectable,
356
+ args: [{ providedIn: "root" }]
357
+ }]
358
+ });
359
+ var CmatDataExporterDirective = class CmatDataExporterDirective {
360
+ constructor() {
361
+ this.dataSource = input([], ...ngDevMode ? [{ debugName: "dataSource" }] : /* istanbul ignore next */ []);
362
+ this.exportColumns = input([], ...ngDevMode ? [{ debugName: "exportColumns" }] : /* istanbul ignore next */ []);
363
+ this.options = input(...ngDevMode ? [void 0, { debugName: "options" }] : /* istanbul ignore next */ []);
364
+ this.exportType = input("xlsx", ...ngDevMode ? [{ debugName: "exportType" }] : /* istanbul ignore next */ []);
365
+ this.transformBoolean = input(true, ...ngDevMode ? [{ debugName: "transformBoolean" }] : /* istanbul ignore next */ []);
366
+ this.transformDate = input(true, ...ngDevMode ? [{ debugName: "transformDate" }] : /* istanbul ignore next */ []);
367
+ this.dateFormat = input("YYYY-MM-DD", ...ngDevMode ? [{ debugName: "dateFormat" }] : /* istanbul ignore next */ []);
368
+ this._serviceLocator = inject(ServiceLocatorService);
369
+ }
370
+ ngOnChanges(changes) {
371
+ if (changes.dataSource) {
372
+ if (this.dataSource()?.length > 0) {
373
+ this._data = [];
374
+ this._loadExporter(this.exportType());
375
+ this._data = [this.exportColumns().map((column) => ({ [column.code]: column.label })).reduce((acc, curr) => ({
376
+ ...acc,
377
+ ...curr
378
+ }), {}), ...this.dataSource().map((user) => this.exportColumns().reduce((acc, column) => {
379
+ let value = user[column.code];
380
+ if (this.transformBoolean() && typeof value === "boolean") value = value ? "是" : "否";
381
+ else if (this.transformDate() && (value instanceof Date || typeof value === "string")) {
382
+ if (typeof value === "string" && !/^\d{4}[-/]\d{1,2}[-/]\d{1,2}/.test(value)) return {
383
+ ...acc,
384
+ [column.code]: value
385
+ };
386
+ const dateValue = dayjs(value);
387
+ if (dateValue.isValid()) value = dateValue.format(this.dateFormat());
388
+ }
389
+ return {
390
+ ...acc,
391
+ [column.code]: value
392
+ };
393
+ }, {}))];
394
+ this._exporterService.export(this._data, this.options());
395
+ }
396
+ }
397
+ }
398
+ _loadExporter(exportType) {
399
+ this._exporterService = this._serviceLocator.getService(exportType);
400
+ }
401
+ static {
402
+ this.ɵfac = i0.ɵɵngDeclareFactory({
403
+ minVersion: "12.0.0",
404
+ version: "22.2.3",
405
+ ngImport: i0,
406
+ type: CmatDataExporterDirective,
407
+ deps: [],
408
+ target: i0.ɵɵFactoryTarget.Directive
409
+ });
410
+ }
411
+ static {
412
+ this.ɵdir = i0.ɵɵngDeclareDirective({
413
+ minVersion: "17.1.0",
414
+ version: "22.2.3",
415
+ type: CmatDataExporterDirective,
416
+ isStandalone: true,
417
+ selector: "button[cmatDataExporter]",
418
+ inputs: {
419
+ dataSource: {
420
+ classPropertyName: "dataSource",
421
+ publicName: "dataSource",
422
+ isSignal: true,
423
+ isRequired: false,
424
+ transformFunction: null
425
+ },
426
+ exportColumns: {
427
+ classPropertyName: "exportColumns",
428
+ publicName: "exportColumns",
429
+ isSignal: true,
430
+ isRequired: false,
431
+ transformFunction: null
432
+ },
433
+ options: {
434
+ classPropertyName: "options",
435
+ publicName: "options",
436
+ isSignal: true,
437
+ isRequired: false,
438
+ transformFunction: null
439
+ },
440
+ exportType: {
441
+ classPropertyName: "exportType",
442
+ publicName: "exportType",
443
+ isSignal: true,
444
+ isRequired: false,
445
+ transformFunction: null
446
+ },
447
+ transformBoolean: {
448
+ classPropertyName: "transformBoolean",
449
+ publicName: "transformBoolean",
450
+ isSignal: true,
451
+ isRequired: false,
452
+ transformFunction: null
453
+ },
454
+ transformDate: {
455
+ classPropertyName: "transformDate",
456
+ publicName: "transformDate",
457
+ isSignal: true,
458
+ isRequired: false,
459
+ transformFunction: null
460
+ },
461
+ dateFormat: {
462
+ classPropertyName: "dateFormat",
463
+ publicName: "dateFormat",
464
+ isSignal: true,
465
+ isRequired: false,
466
+ transformFunction: null
467
+ }
468
+ },
469
+ usesOnChanges: true,
470
+ ngImport: i0
471
+ });
472
+ }
473
+ };
474
+ i0.ɵɵngDeclareClassMetadata({
475
+ minVersion: "12.0.0",
476
+ version: "22.2.3",
477
+ ngImport: i0,
478
+ type: CmatDataExporterDirective,
479
+ decorators: [{
480
+ type: Directive,
481
+ args: [{ selector: "button[cmatDataExporter]" }]
482
+ }],
483
+ propDecorators: {
484
+ dataSource: [{
485
+ type: i0.Input,
486
+ args: [{
487
+ isSignal: true,
488
+ alias: "dataSource",
489
+ required: false
490
+ }]
491
+ }],
492
+ exportColumns: [{
493
+ type: i0.Input,
494
+ args: [{
495
+ isSignal: true,
496
+ alias: "exportColumns",
497
+ required: false
498
+ }]
499
+ }],
500
+ options: [{
501
+ type: i0.Input,
502
+ args: [{
503
+ isSignal: true,
504
+ alias: "options",
505
+ required: false
506
+ }]
507
+ }],
508
+ exportType: [{
509
+ type: i0.Input,
510
+ args: [{
511
+ isSignal: true,
512
+ alias: "exportType",
513
+ required: false
514
+ }]
515
+ }],
516
+ transformBoolean: [{
517
+ type: i0.Input,
518
+ args: [{
519
+ isSignal: true,
520
+ alias: "transformBoolean",
521
+ required: false
522
+ }]
523
+ }],
524
+ transformDate: [{
525
+ type: i0.Input,
526
+ args: [{
527
+ isSignal: true,
528
+ alias: "transformDate",
529
+ required: false
530
+ }]
531
+ }],
532
+ dateFormat: [{
533
+ type: i0.Input,
534
+ args: [{
535
+ isSignal: true,
536
+ alias: "dateFormat",
537
+ required: false
538
+ }]
539
+ }]
540
+ }
541
+ });
344
542
  export { CmatDataExporterDirective, ExportType };
345
- //# sourceMappingURL=cmat-directives-data-exporter.mjs.map
543
+
544
+ //# sourceMappingURL=cmat-directives-data-exporter.mjs.map