cmat 0.0.110 → 0.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (256) hide show
  1. package/fesm2022/cmat-components-adapter.mjs +531 -536
  2. package/fesm2022/cmat-components-adapter.mjs.map +1 -1
  3. package/fesm2022/cmat-components-breadcrumb.mjs +521 -356
  4. package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
  5. package/fesm2022/cmat-components-card.mjs +150 -42
  6. package/fesm2022/cmat-components-card.mjs.map +1 -1
  7. package/fesm2022/cmat-components-carousel.mjs +1120 -629
  8. package/fesm2022/cmat-components-carousel.mjs.map +1 -1
  9. package/fesm2022/cmat-components-cascade.mjs +861 -441
  10. package/fesm2022/cmat-components-cascade.mjs.map +1 -1
  11. package/fesm2022/cmat-components-chip-input.mjs +580 -335
  12. package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
  13. package/fesm2022/cmat-components-code-editor.mjs +197 -105
  14. package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
  15. package/fesm2022/cmat-components-color-picker.mjs +1762 -825
  16. package/fesm2022/cmat-components-color-picker.mjs.map +1 -1
  17. package/fesm2022/cmat-components-custom-formly.mjs +5196 -2531
  18. package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
  19. package/fesm2022/cmat-components-data-picker.mjs +1901 -1073
  20. package/fesm2022/cmat-components-data-picker.mjs.map +1 -1
  21. package/fesm2022/cmat-components-date-range.mjs +701 -456
  22. package/fesm2022/cmat-components-date-range.mjs.map +1 -1
  23. package/fesm2022/cmat-components-date-time-display.mjs +137 -30
  24. package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
  25. package/fesm2022/cmat-components-drawer.mjs +410 -258
  26. package/fesm2022/cmat-components-drawer.mjs.map +1 -1
  27. package/fesm2022/cmat-components-empty-state.mjs +201 -41
  28. package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
  29. package/fesm2022/cmat-components-file-preview.mjs +198 -35
  30. package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
  31. package/fesm2022/cmat-components-filter-toolbar.mjs +320 -72
  32. package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
  33. package/fesm2022/cmat-components-form-actions.mjs +102 -26
  34. package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
  35. package/fesm2022/cmat-components-fullscreen.mjs +167 -47
  36. package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
  37. package/fesm2022/cmat-components-highlight.mjs +203 -112
  38. package/fesm2022/cmat-components-highlight.mjs.map +1 -1
  39. package/fesm2022/cmat-components-image-viewer.mjs +489 -215
  40. package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
  41. package/fesm2022/cmat-components-inline-loading.mjs +117 -27
  42. package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
  43. package/fesm2022/cmat-components-json-editor.mjs +276 -230
  44. package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
  45. package/fesm2022/cmat-components-knob-input.mjs +615 -420
  46. package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
  47. package/fesm2022/cmat-components-loading-overlay.mjs +53 -25
  48. package/fesm2022/cmat-components-loading-overlay.mjs.map +1 -1
  49. package/fesm2022/cmat-components-masonry.mjs +120 -40
  50. package/fesm2022/cmat-components-masonry.mjs.map +1 -1
  51. package/fesm2022/cmat-components-material-color-picker.mjs +332 -155
  52. package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
  53. package/fesm2022/cmat-components-material-datetimepicker.mjs +4283 -2504
  54. package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
  55. package/fesm2022/cmat-components-navigation.mjs +3080 -1404
  56. package/fesm2022/cmat-components-navigation.mjs.map +1 -1
  57. package/fesm2022/cmat-components-opt-input.mjs +540 -466
  58. package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
  59. package/fesm2022/cmat-components-org-chart.mjs +528 -125
  60. package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
  61. package/fesm2022/cmat-components-page-header.mjs +141 -32
  62. package/fesm2022/cmat-components-page-header.mjs.map +1 -1
  63. package/fesm2022/cmat-components-pagination.mjs +866 -534
  64. package/fesm2022/cmat-components-pagination.mjs.map +1 -1
  65. package/fesm2022/cmat-components-password-strength.mjs +873 -434
  66. package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
  67. package/fesm2022/cmat-components-popover.mjs +1012 -731
  68. package/fesm2022/cmat-components-popover.mjs.map +1 -1
  69. package/fesm2022/cmat-components-progress-bar.mjs +98 -35
  70. package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
  71. package/fesm2022/cmat-components-qrcode.mjs +463 -287
  72. package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
  73. package/fesm2022/cmat-components-rating.mjs +377 -203
  74. package/fesm2022/cmat-components-rating.mjs.map +1 -1
  75. package/fesm2022/cmat-components-rich-text-editor.mjs +153 -39
  76. package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
  77. package/fesm2022/cmat-components-select-search.mjs +926 -496
  78. package/fesm2022/cmat-components-select-search.mjs.map +1 -1
  79. package/fesm2022/cmat-components-select-table.mjs +1280 -842
  80. package/fesm2022/cmat-components-select-table.mjs.map +1 -1
  81. package/fesm2022/cmat-components-select-tree.mjs +998 -690
  82. package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
  83. package/fesm2022/cmat-components-skeleton.mjs +143 -57
  84. package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
  85. package/fesm2022/cmat-components-speed-dial.mjs +457 -303
  86. package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
  87. package/fesm2022/cmat-components-status-tag.mjs +136 -44
  88. package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
  89. package/fesm2022/cmat-components-table-toolbar.mjs +120 -28
  90. package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
  91. package/fesm2022/cmat-components-timeline.mjs +464 -168
  92. package/fesm2022/cmat-components-timeline.mjs.map +1 -1
  93. package/fesm2022/cmat-components-toast.mjs +346 -262
  94. package/fesm2022/cmat-components-toast.mjs.map +1 -1
  95. package/fesm2022/cmat-components-transfer-picker.mjs +1427 -593
  96. package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
  97. package/fesm2022/cmat-components-treetable.mjs +372 -112
  98. package/fesm2022/cmat-components-treetable.mjs.map +1 -1
  99. package/fesm2022/cmat-components-upload.mjs +904 -410
  100. package/fesm2022/cmat-components-upload.mjs.map +1 -1
  101. package/fesm2022/cmat-components-x6-angular-shape.mjs +153 -170
  102. package/fesm2022/cmat-components-x6-angular-shape.mjs.map +1 -1
  103. package/fesm2022/cmat-directives-animate-on-scroll.mjs +220 -138
  104. package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
  105. package/fesm2022/cmat-directives-arrow-cursor.mjs +246 -193
  106. package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
  107. package/fesm2022/cmat-directives-autofocus.mjs +43 -25
  108. package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
  109. package/fesm2022/cmat-directives-data-exporter.mjs +537 -338
  110. package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
  111. package/fesm2022/cmat-directives-debounce.mjs +162 -76
  112. package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
  113. package/fesm2022/cmat-directives-digit-only.mjs +457 -356
  114. package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
  115. package/fesm2022/cmat-directives-equal-validator.mjs +70 -53
  116. package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
  117. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +180 -132
  118. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
  119. package/fesm2022/cmat-lib-mock-api.mjs +207 -195
  120. package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
  121. package/fesm2022/cmat-pipes-bytes.mjs +50 -30
  122. package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
  123. package/fesm2022/cmat-pipes-date-format.mjs +41 -25
  124. package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
  125. package/fesm2022/cmat-pipes-find-by-key.mjs +44 -26
  126. package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
  127. package/fesm2022/cmat-pipes-group-by.mjs +50 -38
  128. package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
  129. package/fesm2022/cmat-pipes-keys.mjs +44 -31
  130. package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
  131. package/fesm2022/cmat-pipes-secure.mjs +60 -49
  132. package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
  133. package/fesm2022/cmat-pipes-uppercase.mjs +39 -22
  134. package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
  135. package/fesm2022/cmat-reports.mjs +2751 -0
  136. package/fesm2022/cmat-reports.mjs.map +1 -0
  137. package/fesm2022/cmat-services-alert.mjs +249 -277
  138. package/fesm2022/cmat-services-alert.mjs.map +1 -1
  139. package/fesm2022/cmat-services-config.mjs +110 -81
  140. package/fesm2022/cmat-services-config.mjs.map +1 -1
  141. package/fesm2022/cmat-services-confirmation.mjs +184 -73
  142. package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
  143. package/fesm2022/cmat-services-data.mjs +136 -125
  144. package/fesm2022/cmat-services-data.mjs.map +1 -1
  145. package/fesm2022/cmat-services-export-as.mjs +165 -183
  146. package/fesm2022/cmat-services-export-as.mjs.map +1 -1
  147. package/fesm2022/cmat-services-loading.mjs +116 -95
  148. package/fesm2022/cmat-services-loading.mjs.map +1 -1
  149. package/fesm2022/cmat-services-local-storage.mjs +75 -66
  150. package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
  151. package/fesm2022/cmat-services-media-watcher.mjs +69 -64
  152. package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
  153. package/fesm2022/cmat-services-platform.mjs +48 -45
  154. package/fesm2022/cmat-services-platform.mjs.map +1 -1
  155. package/fesm2022/cmat-services-print.mjs +985 -669
  156. package/fesm2022/cmat-services-print.mjs.map +1 -1
  157. package/fesm2022/cmat-services-splash-screen.mjs +53 -38
  158. package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
  159. package/fesm2022/cmat-services-title.mjs +57 -47
  160. package/fesm2022/cmat-services-title.mjs.map +1 -1
  161. package/fesm2022/cmat-services-translation.mjs +79 -68
  162. package/fesm2022/cmat-services-translation.mjs.map +1 -1
  163. package/fesm2022/cmat-services-utils.mjs +424 -517
  164. package/fesm2022/cmat-services-utils.mjs.map +1 -1
  165. package/fesm2022/cmat-validators.mjs +23 -33
  166. package/fesm2022/cmat-validators.mjs.map +1 -1
  167. package/fesm2022/cmat-version.mjs +12 -16
  168. package/fesm2022/cmat-version.mjs.map +1 -1
  169. package/fesm2022/cmat.mjs +39806 -22071
  170. package/fesm2022/cmat.mjs.map +1 -1
  171. package/package.json +5 -1
  172. package/types/cmat-components-adapter.d.ts +145 -156
  173. package/types/cmat-components-breadcrumb.d.ts +108 -86
  174. package/types/cmat-components-card.d.ts +34 -18
  175. package/types/cmat-components-carousel.d.ts +251 -134
  176. package/types/cmat-components-cascade.d.ts +158 -117
  177. package/types/cmat-components-chip-input.d.ts +105 -71
  178. package/types/cmat-components-code-editor.d.ts +59 -34
  179. package/types/cmat-components-color-picker.d.ts +378 -236
  180. package/types/cmat-components-custom-formly.d.ts +776 -814
  181. package/types/cmat-components-data-picker.d.ts +502 -360
  182. package/types/cmat-components-date-range.d.ts +106 -77
  183. package/types/cmat-components-date-time-display.d.ts +36 -13
  184. package/types/cmat-components-drawer.d.ts +91 -61
  185. package/types/cmat-components-empty-state.d.ts +47 -17
  186. package/types/cmat-components-file-preview.d.ts +42 -14
  187. package/types/cmat-components-filter-toolbar.d.ts +57 -25
  188. package/types/cmat-components-form-actions.d.ts +18 -10
  189. package/types/cmat-components-fullscreen.d.ts +21 -13
  190. package/types/cmat-components-highlight.d.ts +33 -26
  191. package/types/cmat-components-image-viewer.d.ts +119 -58
  192. package/types/cmat-components-inline-loading.d.ts +24 -11
  193. package/types/cmat-components-json-editor.d.ts +39 -28
  194. package/types/cmat-components-knob-input.d.ts +172 -101
  195. package/types/cmat-components-loading-overlay.d.ts +8 -11
  196. package/types/cmat-components-masonry.d.ts +27 -14
  197. package/types/cmat-components-material-color-picker.d.ts +56 -42
  198. package/types/cmat-components-material-datetimepicker.d.ts +817 -454
  199. package/types/cmat-components-navigation.d.ts +295 -221
  200. package/types/cmat-components-opt-input.d.ts +111 -90
  201. package/types/cmat-components-org-chart.d.ts +53 -35
  202. package/types/cmat-components-page-header.d.ts +37 -14
  203. package/types/cmat-components-pagination.d.ts +144 -107
  204. package/types/cmat-components-password-strength.d.ts +197 -86
  205. package/types/cmat-components-popover.d.ts +264 -166
  206. package/types/cmat-components-progress-bar.d.ts +17 -14
  207. package/types/cmat-components-qrcode.d.ts +111 -42
  208. package/types/cmat-components-rating.d.ts +105 -59
  209. package/types/cmat-components-rich-text-editor.d.ts +39 -16
  210. package/types/cmat-components-select-search.d.ts +195 -99
  211. package/types/cmat-components-select-table.d.ts +241 -142
  212. package/types/cmat-components-select-tree.d.ts +185 -118
  213. package/types/cmat-components-skeleton.d.ts +55 -32
  214. package/types/cmat-components-speed-dial.d.ts +86 -61
  215. package/types/cmat-components-status-tag.d.ts +42 -24
  216. package/types/cmat-components-table-toolbar.d.ts +30 -12
  217. package/types/cmat-components-timeline.d.ts +83 -51
  218. package/types/cmat-components-toast.d.ts +84 -85
  219. package/types/cmat-components-transfer-picker.d.ts +228 -181
  220. package/types/cmat-components-treetable.d.ts +63 -39
  221. package/types/cmat-components-upload.d.ts +205 -106
  222. package/types/cmat-components-x6-angular-shape.d.ts +29 -37
  223. package/types/cmat-directives-animate-on-scroll.d.ts +48 -30
  224. package/types/cmat-directives-arrow-cursor.d.ts +55 -35
  225. package/types/cmat-directives-autofocus.d.ts +8 -11
  226. package/types/cmat-directives-data-exporter.d.ts +71 -40
  227. package/types/cmat-directives-debounce.d.ts +31 -28
  228. package/types/cmat-directives-digit-only.d.ts +90 -53
  229. package/types/cmat-directives-equal-validator.d.ts +11 -14
  230. package/types/cmat-directives-seamless-auto-scroll.d.ts +42 -29
  231. package/types/cmat-lib-mock-api.d.ts +46 -55
  232. package/types/cmat-pipes-bytes.d.ts +7 -10
  233. package/types/cmat-pipes-date-format.d.ts +7 -10
  234. package/types/cmat-pipes-find-by-key.d.ts +8 -12
  235. package/types/cmat-pipes-group-by.d.ts +11 -15
  236. package/types/cmat-pipes-keys.d.ts +10 -13
  237. package/types/cmat-pipes-secure.d.ts +14 -17
  238. package/types/cmat-pipes-uppercase.d.ts +7 -10
  239. package/types/cmat-reports.d.ts +1131 -0
  240. package/types/cmat-services-alert.d.ts +80 -87
  241. package/types/cmat-services-config.d.ts +37 -43
  242. package/types/cmat-services-confirmation.d.ts +31 -37
  243. package/types/cmat-services-data.d.ts +18 -21
  244. package/types/cmat-services-export-as.d.ts +28 -33
  245. package/types/cmat-services-loading.d.ts +27 -31
  246. package/types/cmat-services-local-storage.d.ts +17 -21
  247. package/types/cmat-services-media-watcher.d.ts +14 -18
  248. package/types/cmat-services-platform.d.ts +8 -11
  249. package/types/cmat-services-print.d.ts +97 -92
  250. package/types/cmat-services-splash-screen.d.ts +11 -14
  251. package/types/cmat-services-title.d.ts +9 -12
  252. package/types/cmat-services-translation.d.ts +19 -22
  253. package/types/cmat-services-utils.d.ts +76 -80
  254. package/types/cmat-validators.d.ts +5 -8
  255. package/types/cmat-version.d.ts +8 -10
  256. package/types/cmat.d.ts +7551 -5194
@@ -1,357 +1,458 @@
1
- import * as i0 from '@angular/core';
2
- import { input, inject, ElementRef, HostListener, Directive } from '@angular/core';
3
-
4
- class CmatDigitOnlyDirective {
5
- constructor() {
6
- this.decimal = input(false, /* @ts-ignore */
7
- ...(ngDevMode ? [{ debugName: "decimal" }] : /* istanbul ignore next */ []));
8
- this.decimalSeparator = input('.', /* @ts-ignore */
9
- ...(ngDevMode ? [{ debugName: "decimalSeparator" }] : /* istanbul ignore next */ []));
10
- this.allowNegatives = input(false, /* @ts-ignore */
11
- ...(ngDevMode ? [{ debugName: "allowNegatives" }] : /* istanbul ignore next */ []));
12
- this.allowPaste = input(true, /* @ts-ignore */
13
- ...(ngDevMode ? [{ debugName: "allowPaste" }] : /* istanbul ignore next */ []));
14
- this.negativeSign = input('-', /* @ts-ignore */
15
- ...(ngDevMode ? [{ debugName: "negativeSign" }] : /* istanbul ignore next */ []));
16
- this.min = input(-Infinity, /* @ts-ignore */
17
- ...(ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []));
18
- this.max = input(Infinity, /* @ts-ignore */
19
- ...(ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []));
20
- this.pattern = input(/* @ts-ignore */
21
- ...(ngDevMode ? [undefined, { debugName: "pattern" }] : /* istanbul ignore next */ []));
22
- this.value = '';
23
- this.el = inject(ElementRef);
24
- this._regex = null;
25
- this._hasDecimalPoint = false;
26
- this._hasNegativeSign = false;
27
- this._navigationKeys = [
28
- 'Backspace',
29
- 'Delete',
30
- 'Tab',
31
- 'Escape',
32
- 'Enter',
33
- 'Home',
34
- 'End',
35
- 'ArrowLeft',
36
- 'ArrowRight',
37
- 'Clear',
38
- 'Copy',
39
- 'Paste',
40
- ];
41
- const el = this.el;
42
- this.inputElement = el.nativeElement;
43
- }
44
- onBeforeInput(e) {
45
- if (isNaN(Number(e.data))) {
46
- if (e.data === this.decimalSeparator() ||
47
- (e.data === this.negativeSign() && this.allowNegatives())) {
48
- return; // go on
49
- }
50
- e.preventDefault();
51
- e.stopPropagation();
52
- }
53
- }
54
- onInputChange(event) {
55
- const reg = /^-?(0|[1-9][0-9]*)(\.[0-9]*)?$/;
56
- const value = event.target?.value ?? '';
57
- if ((!isNaN(+value) && reg.test(value)) || value === '' || value === '-') {
58
- this.value = value;
59
- }
60
- this.inputElement.value = this.value;
61
- }
62
- onKeyDown(e) {
63
- if (e.key === 'Process') {
64
- e.preventDefault();
65
- return;
66
- }
67
- if (this._navigationKeys.includes(e.key) || // Allow: navigation keys: backspace, delete, arrows etc.
68
- ((e.key === 'a' || e.code === 'KeyA') && e.ctrlKey === true) || // Allow: Ctrl+A
69
- ((e.key === 'c' || e.code === 'KeyC') && e.ctrlKey === true) || // Allow: Ctrl+C
70
- ((e.key === 'v' || e.code === 'KeyV') && e.ctrlKey === true) || // Allow: Ctrl+V
71
- ((e.key === 'x' || e.code === 'KeyX') && e.ctrlKey === true) || // Allow: Ctrl+X
72
- ((e.key === 'a' || e.code === 'KeyA') && e.metaKey === true) || // Allow: Cmd+A (Mac)
73
- ((e.key === 'c' || e.code === 'KeyC') && e.metaKey === true) || // Allow: Cmd+C (Mac)
74
- ((e.key === 'v' || e.code === 'KeyV') && e.metaKey === true) || // Allow: Cmd+V (Mac)
75
- ((e.key === 'x' || e.code === 'KeyX') && e.metaKey === true) // Allow: Cmd+X (Mac)
76
- ) {
77
- return;
78
- }
79
- let newValue = '';
80
- const decimalSeparator = this.decimalSeparator();
81
- if (this.decimal() && e.key === decimalSeparator) {
82
- newValue = this._forecastValue(e.key);
83
- if (newValue.split(decimalSeparator).length > 2) {
84
- e.preventDefault();
85
- return;
86
- }
87
- else {
88
- this._hasDecimalPoint = newValue.includes(decimalSeparator);
89
- return; // Allow: only one decimal point
90
- }
91
- }
92
- const negativeSign = this.negativeSign();
93
- if (e.key === negativeSign && this.allowNegatives()) {
94
- newValue = this._forecastValue(e.key);
95
- if (newValue.startsWith(negativeSign) ||
96
- newValue.split(negativeSign).length > 2) {
97
- e.preventDefault();
98
- return;
99
- }
100
- else {
101
- this._hasNegativeSign = newValue.split(negativeSign).length > -1;
102
- return;
103
- }
104
- }
105
- if (e.key === ' ' || isNaN(Number(e.key))) {
106
- e.preventDefault();
107
- return;
108
- }
109
- newValue = newValue || this._forecastValue(e.key);
110
- if (this._regex) {
111
- if (!this._regex.test(newValue)) {
112
- e.preventDefault();
113
- return;
114
- }
115
- }
116
- const newNumber = Number(newValue);
117
- const min = Number(this.min());
118
- const max = Number(this.max());
119
- if (newNumber > max || newNumber < min) {
120
- e.preventDefault();
121
- }
122
- }
123
- onPaste(event) {
124
- if (this.allowPaste() === true) {
125
- let pastedInput = '';
126
- const legacyWindow = window;
127
- if (legacyWindow.clipboardData) {
128
- pastedInput = legacyWindow.clipboardData.getData('text');
129
- }
130
- else if (event.clipboardData?.getData) {
131
- pastedInput = event.clipboardData.getData('text/plain');
132
- }
133
- this._pasteData(pastedInput);
134
- event.preventDefault();
135
- }
136
- else {
137
- event.preventDefault();
138
- event.stopPropagation();
139
- }
140
- }
141
- onDrop(event) {
142
- const textData = event.dataTransfer?.getData('text') ?? '';
143
- this.inputElement.focus();
144
- this._pasteData(textData);
145
- event.preventDefault();
146
- }
147
- ngOnChanges(changes) {
148
- if (changes['pattern']) {
149
- const pattern = this.pattern();
150
- this._regex = pattern ? RegExp(pattern) : null;
151
- }
152
- }
153
- _pasteData(pastedContent) {
154
- const sanitizedContent = this._sanitizeInput(pastedContent);
155
- const negativeSign = this.negativeSign();
156
- if (sanitizedContent.includes(negativeSign) &&
157
- this._hasNegativeSign &&
158
- !this._getSelection().includes(negativeSign)) {
159
- return;
160
- }
161
- if (this.inputElement.setRangeText) {
162
- const { selectionStart: start, selectionEnd: end } = this.inputElement;
163
- this.inputElement.setRangeText(sanitizedContent, start ?? 0, end ?? 0, 'end');
164
- this.inputElement.dispatchEvent(new Event('input', { cancelable: true }));
165
- }
166
- else {
167
- this._insertAtCursor(this.inputElement, sanitizedContent);
168
- }
169
- if (this.decimal()) {
170
- this._hasDecimalPoint = this.inputElement.value.includes(this.decimalSeparator());
171
- }
172
- this._hasNegativeSign = this.inputElement.value.includes(negativeSign);
173
- }
174
- _insertAtCursor(myField, myValue) {
175
- const startPos = myField.selectionStart ?? 0;
176
- const endPos = myField.selectionEnd ?? 0;
177
- myField.value =
178
- myField.value.substring(0, startPos) +
179
- myValue +
180
- myField.value.substring(endPos, myField.value.length);
181
- const pos = startPos + myValue.length;
182
- myField.focus();
183
- myField.setSelectionRange(pos, pos);
184
- this._triggerEvent(myField, 'input');
185
- }
186
- _triggerEvent(el, type) {
187
- if ('createEvent' in document) {
188
- const e = document.createEvent('HTMLEvents');
189
- // eslint-disable-next-line @typescript-eslint/no-deprecated
190
- e.initEvent(type, false, true);
191
- el.dispatchEvent(e);
192
- }
193
- }
194
- _sanitizeInput(input) {
195
- let result;
196
- let regex;
197
- if (this.decimal() && this._isValidDecimal(input)) {
198
- regex = new RegExp(`${this._getNegativeSignRegExp()}[^0-9${this.decimalSeparator()}]`, 'g');
199
- }
200
- else {
201
- regex = new RegExp(`${this._getNegativeSignRegExp()}[^0-9]`, 'g');
202
- }
203
- result = input.replace(regex, '');
204
- const maxLength = this.inputElement.maxLength;
205
- if (maxLength > 0) {
206
- const allowedLength = maxLength -
207
- this.inputElement.value.length +
208
- (result.includes(`${this.negativeSign()}`) ? 1 : 0);
209
- result = allowedLength > 0 ? result.substring(0, allowedLength) : '';
210
- }
211
- return result;
212
- }
213
- _getNegativeSignRegExp() {
214
- const negativeSign = this.negativeSign();
215
- return this.allowNegatives() &&
216
- (!this._hasNegativeSign || this._getSelection().includes(negativeSign))
217
- ? `(?!^${negativeSign})`
218
- : '';
219
- }
220
- _isValidDecimal(str) {
221
- if (!this._hasDecimalPoint) {
222
- return str.split(this.decimalSeparator()).length <= 2;
223
- }
224
- else {
225
- const selectedText = this._getSelection();
226
- const decimalSeparator = this.decimalSeparator();
227
- if (selectedText?.includes(decimalSeparator)) {
228
- return str.split(decimalSeparator).length <= 2;
229
- }
230
- else {
231
- return !str.includes(decimalSeparator);
232
- }
233
- }
234
- }
235
- _getSelection() {
236
- return this.inputElement.value.substring(this.inputElement.selectionStart ?? 0, this.inputElement.selectionEnd ?? 0);
237
- }
238
- _forecastValue(key) {
239
- const selectionStart = this.inputElement.selectionStart ?? 0;
240
- const selectionEnd = this.inputElement.selectionEnd ?? 0;
241
- const oldValue = this.inputElement.value;
242
- return (oldValue.substring(0, selectionStart) +
243
- key +
244
- oldValue.substring(selectionEnd));
245
- }
246
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatDigitOnlyDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
247
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: CmatDigitOnlyDirective, isStandalone: true, selector: "[cmatDigitOnly]", inputs: { decimal: { classPropertyName: "decimal", publicName: "decimal", isSignal: true, isRequired: false, transformFunction: null }, decimalSeparator: { classPropertyName: "decimalSeparator", publicName: "decimalSeparator", isSignal: true, isRequired: false, transformFunction: null }, allowNegatives: { classPropertyName: "allowNegatives", publicName: "allowNegatives", isSignal: true, isRequired: false, transformFunction: null }, allowPaste: { classPropertyName: "allowPaste", publicName: "allowPaste", isSignal: true, isRequired: false, transformFunction: null }, negativeSign: { classPropertyName: "negativeSign", publicName: "negativeSign", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, pattern: { classPropertyName: "pattern", publicName: "pattern", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "beforeinput": "onBeforeInput($event)", "input": "onInputChange($event)", "keydown": "onKeyDown($event)", "paste": "onPaste($event)", "drop": "onDrop($event)" } }, usesOnChanges: true, ngImport: i0 }); }
248
- }
249
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatDigitOnlyDirective, decorators: [{
250
- type: Directive,
251
- args: [{
252
- selector: '[cmatDigitOnly]',
253
- }]
254
- }], ctorParameters: () => [], propDecorators: { decimal: [{ type: i0.Input, args: [{ isSignal: true, alias: "decimal", required: false }] }], decimalSeparator: [{ type: i0.Input, args: [{ isSignal: true, alias: "decimalSeparator", required: false }] }], allowNegatives: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowNegatives", required: false }] }], allowPaste: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowPaste", required: false }] }], negativeSign: [{ type: i0.Input, args: [{ isSignal: true, alias: "negativeSign", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], pattern: [{ type: i0.Input, args: [{ isSignal: true, alias: "pattern", required: false }] }], onBeforeInput: [{
255
- type: HostListener,
256
- args: ['beforeinput', ['$event']]
257
- }], onInputChange: [{
258
- type: HostListener,
259
- args: ['input', ['$event']]
260
- }], onKeyDown: [{
261
- type: HostListener,
262
- args: ['keydown', ['$event']]
263
- }], onPaste: [{
264
- type: HostListener,
265
- args: ['paste', ['$event']]
266
- }], onDrop: [{
267
- type: HostListener,
268
- args: ['drop', ['$event']]
269
- }] } });
270
-
271
- class CmatMaskDirective {
272
- constructor() {
273
- this.el = inject(ElementRef);
274
- this.value = '';
275
- this.regex = new RegExp('');
276
- this._navigationKeys = [
277
- 'Backspace',
278
- 'Delete',
279
- 'Tab',
280
- 'Escape',
281
- 'Enter',
282
- 'Home',
283
- 'End',
284
- 'ArrowLeft',
285
- 'ArrowRight',
286
- 'Clear',
287
- 'Copy',
288
- 'Paste',
289
- ];
290
- const el = this.el;
291
- this.inputElement = el.nativeElement;
292
- }
293
- onInputChange(event) {
294
- const value = event.target?.value ?? '';
295
- if (this.regex.test(value)) {
296
- this.value = value;
297
- }
298
- this.inputElement.value = this.value;
299
- }
300
- onKeyDown(e) {
301
- if (e.key === 'Process') {
302
- e.preventDefault();
303
- return;
304
- }
305
- if (this._navigationKeys.includes(e.key) || // Allow: navigation keys: backspace, delete, arrows etc.
306
- ((e.key === 'a' || e.code === 'KeyA') && e.ctrlKey === true) || // Allow: Ctrl+A
307
- ((e.key === 'c' || e.code === 'KeyC') && e.ctrlKey === true) || // Allow: Ctrl+C
308
- ((e.key === 'v' || e.code === 'KeyV') && e.ctrlKey === true) || // Allow: Ctrl+V
309
- ((e.key === 'x' || e.code === 'KeyX') && e.ctrlKey === true) || // Allow: Ctrl+X
310
- ((e.key === 'a' || e.code === 'KeyA') && e.metaKey === true) || // Allow: Cmd+A (Mac)
311
- ((e.key === 'c' || e.code === 'KeyC') && e.metaKey === true) || // Allow: Cmd+C (Mac)
312
- ((e.key === 'v' || e.code === 'KeyV') && e.metaKey === true) || // Allow: Cmd+V (Mac)
313
- ((e.key === 'x' || e.code === 'KeyX') && e.metaKey === true) // Allow: Cmd+X (Mac)
314
- ) {
315
- return;
316
- }
317
- const newValue = this._forecastValue(e.key);
318
- if (!this.regex.test(newValue)) {
319
- e.preventDefault();
320
- }
321
- }
322
- ngOnInit() {
323
- this.regex = new RegExp(this.inputElement.pattern);
324
- }
325
- _forecastValue(key) {
326
- const selectionStart = this.inputElement.selectionStart ?? 0;
327
- const selectionEnd = this.inputElement.selectionEnd ?? 0;
328
- const oldValue = this.inputElement.value;
329
- const selection = oldValue.substring(selectionStart, selectionEnd);
330
- return selection
331
- ? oldValue.replace(selection, key)
332
- : oldValue.substring(0, selectionStart) +
333
- key +
334
- oldValue.substring(selectionStart);
335
- }
336
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatMaskDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
337
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.2.0", type: CmatMaskDirective, isStandalone: true, selector: "[cmatMask]", host: { listeners: { "input": "onInputChange($event)", "keydown": "onKeyDown($event)" } }, ngImport: i0 }); }
338
- }
339
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatMaskDirective, decorators: [{
340
- type: Directive,
341
- args: [{
342
- selector: '[cmatMask]'
343
- }]
344
- }], ctorParameters: () => [], propDecorators: { onInputChange: [{
345
- type: HostListener,
346
- args: ['input', ['$event']]
347
- }], onKeyDown: [{
348
- type: HostListener,
349
- args: ['keydown', ['$event']]
350
- }] } });
351
-
352
- /**
353
- * Generated bundle index. Do not edit.
354
- */
355
-
1
+ import * as i0 from "@angular/core";
2
+ import { Directive, ElementRef, HostListener, inject, input } from "@angular/core";
3
+ var CmatDigitOnlyDirective = class CmatDigitOnlyDirective {
4
+ constructor() {
5
+ this.decimal = input(false, ...ngDevMode ? [{ debugName: "decimal" }] : /* istanbul ignore next */ []);
6
+ this.decimalSeparator = input(".", ...ngDevMode ? [{ debugName: "decimalSeparator" }] : /* istanbul ignore next */ []);
7
+ this.allowNegatives = input(false, ...ngDevMode ? [{ debugName: "allowNegatives" }] : /* istanbul ignore next */ []);
8
+ this.allowPaste = input(true, ...ngDevMode ? [{ debugName: "allowPaste" }] : /* istanbul ignore next */ []);
9
+ this.negativeSign = input("-", ...ngDevMode ? [{ debugName: "negativeSign" }] : /* istanbul ignore next */ []);
10
+ this.min = input(-Infinity, ...ngDevMode ? [{ debugName: "min" }] : /* istanbul ignore next */ []);
11
+ this.max = input(Infinity, ...ngDevMode ? [{ debugName: "max" }] : /* istanbul ignore next */ []);
12
+ this.pattern = input(...ngDevMode ? [void 0, { debugName: "pattern" }] : /* istanbul ignore next */ []);
13
+ this.value = "";
14
+ this.el = inject(ElementRef);
15
+ this._regex = null;
16
+ this._hasDecimalPoint = false;
17
+ this._hasNegativeSign = false;
18
+ this._navigationKeys = [
19
+ "Backspace",
20
+ "Delete",
21
+ "Tab",
22
+ "Escape",
23
+ "Enter",
24
+ "Home",
25
+ "End",
26
+ "ArrowLeft",
27
+ "ArrowRight",
28
+ "Clear",
29
+ "Copy",
30
+ "Paste"
31
+ ];
32
+ const el = this.el;
33
+ this.inputElement = el.nativeElement;
34
+ }
35
+ onBeforeInput(e) {
36
+ if (isNaN(Number(e.data))) {
37
+ if (e.data === this.decimalSeparator() || e.data === this.negativeSign() && this.allowNegatives()) return;
38
+ e.preventDefault();
39
+ e.stopPropagation();
40
+ }
41
+ }
42
+ onInputChange(event) {
43
+ const reg = /^-?(0|[1-9][0-9]*)(\.[0-9]*)?$/;
44
+ const value = event.target?.value ?? "";
45
+ if (!isNaN(+value) && reg.test(value) || value === "" || value === "-") this.value = value;
46
+ this.inputElement.value = this.value;
47
+ }
48
+ onKeyDown(e) {
49
+ if (e.key === "Process") {
50
+ e.preventDefault();
51
+ return;
52
+ }
53
+ if (this._navigationKeys.includes(e.key) || (e.key === "a" || e.code === "KeyA") && e.ctrlKey === true || (e.key === "c" || e.code === "KeyC") && e.ctrlKey === true || (e.key === "v" || e.code === "KeyV") && e.ctrlKey === true || (e.key === "x" || e.code === "KeyX") && e.ctrlKey === true || (e.key === "a" || e.code === "KeyA") && e.metaKey === true || (e.key === "c" || e.code === "KeyC") && e.metaKey === true || (e.key === "v" || e.code === "KeyV") && e.metaKey === true || (e.key === "x" || e.code === "KeyX") && e.metaKey === true) return;
54
+ let newValue = "";
55
+ const decimalSeparator = this.decimalSeparator();
56
+ if (this.decimal() && e.key === decimalSeparator) {
57
+ newValue = this._forecastValue(e.key);
58
+ if (newValue.split(decimalSeparator).length > 2) {
59
+ e.preventDefault();
60
+ return;
61
+ } else {
62
+ this._hasDecimalPoint = newValue.includes(decimalSeparator);
63
+ return;
64
+ }
65
+ }
66
+ const negativeSign = this.negativeSign();
67
+ if (e.key === negativeSign && this.allowNegatives()) {
68
+ newValue = this._forecastValue(e.key);
69
+ if (newValue.startsWith(negativeSign) || newValue.split(negativeSign).length > 2) {
70
+ e.preventDefault();
71
+ return;
72
+ } else {
73
+ this._hasNegativeSign = newValue.split(negativeSign).length > -1;
74
+ return;
75
+ }
76
+ }
77
+ if (e.key === " " || isNaN(Number(e.key))) {
78
+ e.preventDefault();
79
+ return;
80
+ }
81
+ newValue = newValue || this._forecastValue(e.key);
82
+ if (this._regex) {
83
+ if (!this._regex.test(newValue)) {
84
+ e.preventDefault();
85
+ return;
86
+ }
87
+ }
88
+ const newNumber = Number(newValue);
89
+ const min = Number(this.min());
90
+ if (newNumber > Number(this.max()) || newNumber < min) e.preventDefault();
91
+ }
92
+ onPaste(event) {
93
+ if (this.allowPaste() === true) {
94
+ let pastedInput = "";
95
+ const legacyWindow = window;
96
+ if (legacyWindow.clipboardData) pastedInput = legacyWindow.clipboardData.getData("text");
97
+ else if (event.clipboardData?.getData) pastedInput = event.clipboardData.getData("text/plain");
98
+ this._pasteData(pastedInput);
99
+ event.preventDefault();
100
+ } else {
101
+ event.preventDefault();
102
+ event.stopPropagation();
103
+ }
104
+ }
105
+ onDrop(event) {
106
+ const textData = event.dataTransfer?.getData("text") ?? "";
107
+ this.inputElement.focus();
108
+ this._pasteData(textData);
109
+ event.preventDefault();
110
+ }
111
+ ngOnChanges(changes) {
112
+ if (changes["pattern"]) {
113
+ const pattern = this.pattern();
114
+ this._regex = pattern ? RegExp(pattern) : null;
115
+ }
116
+ }
117
+ _pasteData(pastedContent) {
118
+ const sanitizedContent = this._sanitizeInput(pastedContent);
119
+ const negativeSign = this.negativeSign();
120
+ if (sanitizedContent.includes(negativeSign) && this._hasNegativeSign && !this._getSelection().includes(negativeSign)) return;
121
+ if (this.inputElement.setRangeText) {
122
+ const { selectionStart: start, selectionEnd: end } = this.inputElement;
123
+ this.inputElement.setRangeText(sanitizedContent, start ?? 0, end ?? 0, "end");
124
+ this.inputElement.dispatchEvent(new Event("input", { cancelable: true }));
125
+ } else this._insertAtCursor(this.inputElement, sanitizedContent);
126
+ if (this.decimal()) this._hasDecimalPoint = this.inputElement.value.includes(this.decimalSeparator());
127
+ this._hasNegativeSign = this.inputElement.value.includes(negativeSign);
128
+ }
129
+ _insertAtCursor(myField, myValue) {
130
+ const startPos = myField.selectionStart ?? 0;
131
+ const endPos = myField.selectionEnd ?? 0;
132
+ myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
133
+ const pos = startPos + myValue.length;
134
+ myField.focus();
135
+ myField.setSelectionRange(pos, pos);
136
+ this._triggerEvent(myField, "input");
137
+ }
138
+ _triggerEvent(el, type) {
139
+ if ("createEvent" in document) {
140
+ const e = document.createEvent("HTMLEvents");
141
+ e.initEvent(type, false, true);
142
+ el.dispatchEvent(e);
143
+ }
144
+ }
145
+ _sanitizeInput(input) {
146
+ let result;
147
+ let regex;
148
+ if (this.decimal() && this._isValidDecimal(input)) regex = new RegExp(`${this._getNegativeSignRegExp()}[^0-9${this.decimalSeparator()}]`, "g");
149
+ else regex = new RegExp(`${this._getNegativeSignRegExp()}[^0-9]`, "g");
150
+ result = input.replace(regex, "");
151
+ const maxLength = this.inputElement.maxLength;
152
+ if (maxLength > 0) {
153
+ const allowedLength = maxLength - this.inputElement.value.length + (result.includes(`${this.negativeSign()}`) ? 1 : 0);
154
+ result = allowedLength > 0 ? result.substring(0, allowedLength) : "";
155
+ }
156
+ return result;
157
+ }
158
+ _getNegativeSignRegExp() {
159
+ const negativeSign = this.negativeSign();
160
+ return this.allowNegatives() && (!this._hasNegativeSign || this._getSelection().includes(negativeSign)) ? `(?!^${negativeSign})` : "";
161
+ }
162
+ _isValidDecimal(str) {
163
+ if (!this._hasDecimalPoint) return str.split(this.decimalSeparator()).length <= 2;
164
+ else {
165
+ const selectedText = this._getSelection();
166
+ const decimalSeparator = this.decimalSeparator();
167
+ if (selectedText?.includes(decimalSeparator)) return str.split(decimalSeparator).length <= 2;
168
+ else return !str.includes(decimalSeparator);
169
+ }
170
+ }
171
+ _getSelection() {
172
+ return this.inputElement.value.substring(this.inputElement.selectionStart ?? 0, this.inputElement.selectionEnd ?? 0);
173
+ }
174
+ _forecastValue(key) {
175
+ const selectionStart = this.inputElement.selectionStart ?? 0;
176
+ const selectionEnd = this.inputElement.selectionEnd ?? 0;
177
+ const oldValue = this.inputElement.value;
178
+ return oldValue.substring(0, selectionStart) + key + oldValue.substring(selectionEnd);
179
+ }
180
+ static {
181
+ this.ɵfac = i0.ɵɵngDeclareFactory({
182
+ minVersion: "12.0.0",
183
+ version: "22.2.3",
184
+ ngImport: i0,
185
+ type: CmatDigitOnlyDirective,
186
+ deps: [],
187
+ target: i0.ɵɵFactoryTarget.Directive
188
+ });
189
+ }
190
+ static {
191
+ this.ɵdir = i0.ɵɵngDeclareDirective({
192
+ minVersion: "17.1.0",
193
+ version: "22.2.3",
194
+ type: CmatDigitOnlyDirective,
195
+ isStandalone: true,
196
+ selector: "[cmatDigitOnly]",
197
+ inputs: {
198
+ decimal: {
199
+ classPropertyName: "decimal",
200
+ publicName: "decimal",
201
+ isSignal: true,
202
+ isRequired: false,
203
+ transformFunction: null
204
+ },
205
+ decimalSeparator: {
206
+ classPropertyName: "decimalSeparator",
207
+ publicName: "decimalSeparator",
208
+ isSignal: true,
209
+ isRequired: false,
210
+ transformFunction: null
211
+ },
212
+ allowNegatives: {
213
+ classPropertyName: "allowNegatives",
214
+ publicName: "allowNegatives",
215
+ isSignal: true,
216
+ isRequired: false,
217
+ transformFunction: null
218
+ },
219
+ allowPaste: {
220
+ classPropertyName: "allowPaste",
221
+ publicName: "allowPaste",
222
+ isSignal: true,
223
+ isRequired: false,
224
+ transformFunction: null
225
+ },
226
+ negativeSign: {
227
+ classPropertyName: "negativeSign",
228
+ publicName: "negativeSign",
229
+ isSignal: true,
230
+ isRequired: false,
231
+ transformFunction: null
232
+ },
233
+ min: {
234
+ classPropertyName: "min",
235
+ publicName: "min",
236
+ isSignal: true,
237
+ isRequired: false,
238
+ transformFunction: null
239
+ },
240
+ max: {
241
+ classPropertyName: "max",
242
+ publicName: "max",
243
+ isSignal: true,
244
+ isRequired: false,
245
+ transformFunction: null
246
+ },
247
+ pattern: {
248
+ classPropertyName: "pattern",
249
+ publicName: "pattern",
250
+ isSignal: true,
251
+ isRequired: false,
252
+ transformFunction: null
253
+ }
254
+ },
255
+ host: { listeners: {
256
+ "beforeinput": "onBeforeInput($event)",
257
+ "input": "onInputChange($event)",
258
+ "keydown": "onKeyDown($event)",
259
+ "paste": "onPaste($event)",
260
+ "drop": "onDrop($event)"
261
+ } },
262
+ usesOnChanges: true,
263
+ ngImport: i0
264
+ });
265
+ }
266
+ };
267
+ i0.ɵɵngDeclareClassMetadata({
268
+ minVersion: "12.0.0",
269
+ version: "22.2.3",
270
+ ngImport: i0,
271
+ type: CmatDigitOnlyDirective,
272
+ decorators: [{
273
+ type: Directive,
274
+ args: [{ selector: "[cmatDigitOnly]" }]
275
+ }],
276
+ ctorParameters: () => [],
277
+ propDecorators: {
278
+ decimal: [{
279
+ type: i0.Input,
280
+ args: [{
281
+ isSignal: true,
282
+ alias: "decimal",
283
+ required: false
284
+ }]
285
+ }],
286
+ decimalSeparator: [{
287
+ type: i0.Input,
288
+ args: [{
289
+ isSignal: true,
290
+ alias: "decimalSeparator",
291
+ required: false
292
+ }]
293
+ }],
294
+ allowNegatives: [{
295
+ type: i0.Input,
296
+ args: [{
297
+ isSignal: true,
298
+ alias: "allowNegatives",
299
+ required: false
300
+ }]
301
+ }],
302
+ allowPaste: [{
303
+ type: i0.Input,
304
+ args: [{
305
+ isSignal: true,
306
+ alias: "allowPaste",
307
+ required: false
308
+ }]
309
+ }],
310
+ negativeSign: [{
311
+ type: i0.Input,
312
+ args: [{
313
+ isSignal: true,
314
+ alias: "negativeSign",
315
+ required: false
316
+ }]
317
+ }],
318
+ min: [{
319
+ type: i0.Input,
320
+ args: [{
321
+ isSignal: true,
322
+ alias: "min",
323
+ required: false
324
+ }]
325
+ }],
326
+ max: [{
327
+ type: i0.Input,
328
+ args: [{
329
+ isSignal: true,
330
+ alias: "max",
331
+ required: false
332
+ }]
333
+ }],
334
+ pattern: [{
335
+ type: i0.Input,
336
+ args: [{
337
+ isSignal: true,
338
+ alias: "pattern",
339
+ required: false
340
+ }]
341
+ }],
342
+ onBeforeInput: [{
343
+ type: HostListener,
344
+ args: ["beforeinput", ["$event"]]
345
+ }],
346
+ onInputChange: [{
347
+ type: HostListener,
348
+ args: ["input", ["$event"]]
349
+ }],
350
+ onKeyDown: [{
351
+ type: HostListener,
352
+ args: ["keydown", ["$event"]]
353
+ }],
354
+ onPaste: [{
355
+ type: HostListener,
356
+ args: ["paste", ["$event"]]
357
+ }],
358
+ onDrop: [{
359
+ type: HostListener,
360
+ args: ["drop", ["$event"]]
361
+ }]
362
+ }
363
+ });
364
+ var CmatMaskDirective = class CmatMaskDirective {
365
+ constructor() {
366
+ this.el = inject(ElementRef);
367
+ this.value = "";
368
+ this.regex = /* @__PURE__ */ new RegExp("");
369
+ this._navigationKeys = [
370
+ "Backspace",
371
+ "Delete",
372
+ "Tab",
373
+ "Escape",
374
+ "Enter",
375
+ "Home",
376
+ "End",
377
+ "ArrowLeft",
378
+ "ArrowRight",
379
+ "Clear",
380
+ "Copy",
381
+ "Paste"
382
+ ];
383
+ const el = this.el;
384
+ this.inputElement = el.nativeElement;
385
+ }
386
+ onInputChange(event) {
387
+ const value = event.target?.value ?? "";
388
+ if (this.regex.test(value)) this.value = value;
389
+ this.inputElement.value = this.value;
390
+ }
391
+ onKeyDown(e) {
392
+ if (e.key === "Process") {
393
+ e.preventDefault();
394
+ return;
395
+ }
396
+ if (this._navigationKeys.includes(e.key) || (e.key === "a" || e.code === "KeyA") && e.ctrlKey === true || (e.key === "c" || e.code === "KeyC") && e.ctrlKey === true || (e.key === "v" || e.code === "KeyV") && e.ctrlKey === true || (e.key === "x" || e.code === "KeyX") && e.ctrlKey === true || (e.key === "a" || e.code === "KeyA") && e.metaKey === true || (e.key === "c" || e.code === "KeyC") && e.metaKey === true || (e.key === "v" || e.code === "KeyV") && e.metaKey === true || (e.key === "x" || e.code === "KeyX") && e.metaKey === true) return;
397
+ const newValue = this._forecastValue(e.key);
398
+ if (!this.regex.test(newValue)) e.preventDefault();
399
+ }
400
+ ngOnInit() {
401
+ this.regex = new RegExp(this.inputElement.pattern);
402
+ }
403
+ _forecastValue(key) {
404
+ const selectionStart = this.inputElement.selectionStart ?? 0;
405
+ const selectionEnd = this.inputElement.selectionEnd ?? 0;
406
+ const oldValue = this.inputElement.value;
407
+ const selection = oldValue.substring(selectionStart, selectionEnd);
408
+ return selection ? oldValue.replace(selection, key) : oldValue.substring(0, selectionStart) + key + oldValue.substring(selectionStart);
409
+ }
410
+ static {
411
+ this.ɵfac = i0.ɵɵngDeclareFactory({
412
+ minVersion: "12.0.0",
413
+ version: "22.2.3",
414
+ ngImport: i0,
415
+ type: CmatMaskDirective,
416
+ deps: [],
417
+ target: i0.ɵɵFactoryTarget.Directive
418
+ });
419
+ }
420
+ static {
421
+ this.ɵdir = i0.ɵɵngDeclareDirective({
422
+ minVersion: "14.0.0",
423
+ version: "22.2.3",
424
+ type: CmatMaskDirective,
425
+ isStandalone: true,
426
+ selector: "[cmatMask]",
427
+ host: { listeners: {
428
+ "input": "onInputChange($event)",
429
+ "keydown": "onKeyDown($event)"
430
+ } },
431
+ ngImport: i0
432
+ });
433
+ }
434
+ };
435
+ i0.ɵɵngDeclareClassMetadata({
436
+ minVersion: "12.0.0",
437
+ version: "22.2.3",
438
+ ngImport: i0,
439
+ type: CmatMaskDirective,
440
+ decorators: [{
441
+ type: Directive,
442
+ args: [{ selector: "[cmatMask]" }]
443
+ }],
444
+ ctorParameters: () => [],
445
+ propDecorators: {
446
+ onInputChange: [{
447
+ type: HostListener,
448
+ args: ["input", ["$event"]]
449
+ }],
450
+ onKeyDown: [{
451
+ type: HostListener,
452
+ args: ["keydown", ["$event"]]
453
+ }]
454
+ }
455
+ });
356
456
  export { CmatDigitOnlyDirective, CmatMaskDirective };
357
- //# sourceMappingURL=cmat-directives-digit-only.mjs.map
457
+
458
+ //# sourceMappingURL=cmat-directives-digit-only.mjs.map