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,841 +1,1778 @@
1
- import { DOCUMENT, NgStyle, NgClass } from '@angular/common';
2
- import * as i0 from '@angular/core';
3
- import { input, output, inject, ElementRef, Directive, signal, effect, untracked, ChangeDetectionStrategy, ViewEncapsulation, Component, model, forwardRef } from '@angular/core';
4
- import * as i1 from '@angular/forms';
5
- import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
6
- import { TinyColor } from '@ctrl/tinycolor';
7
- import { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
8
- import * as i2 from '@angular/material/input';
9
- import { MatInputModule } from '@angular/material/input';
10
-
11
- class CmatColorCoordinates {
12
- constructor() {
13
- this.percentX = input(0, /* @ts-ignore */
14
- ...(ngDevMode ? [{ debugName: "percentX" }] : /* istanbul ignore next */ []));
15
- this.percentY = input(0, /* @ts-ignore */
16
- ...(ngDevMode ? [{ debugName: "percentY" }] : /* istanbul ignore next */ []));
17
- this.coordinatesChange = output();
18
- this._document = inject(DOCUMENT);
19
- this._el = inject(ElementRef);
20
- this.onDrag = (e) => {
21
- e.preventDefault();
22
- this._handleChange(e);
23
- };
24
- this.onDragEnd = () => {
25
- this._document.removeEventListener('pointermove', this.onDrag);
26
- this._document.removeEventListener('pointerup', this.onDragEnd);
27
- };
28
- }
29
- onDragStart(e) {
30
- this._document.addEventListener('pointermove', this.onDrag, { passive: false });
31
- this._document.addEventListener('pointerup', this.onDragEnd, { passive: false });
32
- e.preventDefault();
33
- this._handleChange(e);
34
- }
35
- onKeyDown(e) {
36
- const arrowKeys = ['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'];
37
- if (!arrowKeys.includes(e.key))
38
- return;
39
- e.preventDefault();
40
- const rect = this._el.nativeElement.getBoundingClientRect();
41
- const multiplier = e.shiftKey ? 10 : 1;
42
- const stepX = (rect.width / 100) * multiplier;
43
- const stepY = (rect.height / 100) * multiplier;
44
- let vX = 0;
45
- let vY = 0;
46
- if (this.percentX != null && this.percentY != null) {
47
- vX = rect.left + rect.width * (this.percentX() / 100);
48
- vY = rect.top + rect.height * (this.percentY() / 100);
49
- switch (e.key) {
50
- case 'ArrowLeft':
51
- vX -= stepX;
52
- break;
53
- case 'ArrowRight':
54
- vX += stepX;
55
- break;
56
- case 'ArrowUp':
57
- vY -= stepY;
58
- break;
59
- case 'ArrowDown':
60
- vY += stepY;
61
- break;
62
- }
63
- }
64
- else if (this.percentX != null) {
65
- vX = rect.left + rect.width * (this.percentX() / 100);
66
- switch (e.key) {
67
- case 'ArrowLeft':
68
- case 'ArrowDown':
69
- vX -= stepX;
70
- break;
71
- case 'ArrowRight':
72
- case 'ArrowUp':
73
- vX += stepX;
74
- break;
75
- }
76
- }
77
- else if (this.percentY != null) {
78
- vY = rect.top + rect.height * (this.percentY() / 100);
79
- switch (e.key) {
80
- case 'ArrowLeft':
81
- case 'ArrowDown':
82
- vY += stepY;
83
- break;
84
- case 'ArrowRight':
85
- case 'ArrowUp':
86
- vY -= stepY;
87
- break;
88
- }
89
- }
90
- this._handleChange({ clientX: vX, clientY: vY });
91
- }
92
- _handleChange(e) {
93
- const containerRect = this._el.nativeElement.getBoundingClientRect();
94
- const containerWidth = containerRect.width;
95
- const containerHeight = containerRect.height;
96
- const { clientX, clientY } = e;
97
- const left = clientX - containerRect.left;
98
- const top = clientY - containerRect.top;
99
- this.coordinatesChange.emit({
100
- containerWidth,
101
- containerHeight,
102
- left,
103
- top,
104
- });
105
- }
106
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorCoordinates, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
107
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.2.0", type: CmatColorCoordinates, isStandalone: true, selector: "[cmat-color-coordinates], [cmatColorCoordinates]", inputs: { percentX: { classPropertyName: "percentX", publicName: "percentX", isSignal: true, isRequired: false, transformFunction: null }, percentY: { classPropertyName: "percentY", publicName: "percentY", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { coordinatesChange: "coordinatesChange" }, host: { listeners: { "pointerdown": "onDragStart($event)", "keydown": "onKeyDown($event)" } }, ngImport: i0 }); }
108
- }
109
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorCoordinates, decorators: [{
110
- type: Directive,
111
- args: [{
112
- selector: '[cmat-color-coordinates], [cmatColorCoordinates]',
113
- host: {
114
- // eslint-disable-next-line @typescript-eslint/naming-convention
115
- '(pointerdown)': 'onDragStart($event)',
116
- // eslint-disable-next-line @typescript-eslint/naming-convention
117
- '(keydown)': 'onKeyDown($event)',
118
- },
119
- }]
120
- }], propDecorators: { percentX: [{ type: i0.Input, args: [{ isSignal: true, alias: "percentX", required: false }] }], percentY: [{ type: i0.Input, args: [{ isSignal: true, alias: "percentY", required: false }] }], coordinatesChange: [{ type: i0.Output, args: ["coordinatesChange"] }] } });
121
-
122
- class CmatColorAlphaSlider {
123
- constructor() {
124
- this.color = input.required(/* @ts-ignore */
125
- ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
126
- this.direction = input('horizontal', /* @ts-ignore */
127
- ...(ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []));
128
- this.change = output();
129
- this.hsl = signal(null, /* @ts-ignore */
130
- ...(ngDevMode ? [{ debugName: "hsl" }] : /* istanbul ignore next */ []));
131
- this.rgb = signal(null, /* @ts-ignore */
132
- ...(ngDevMode ? [{ debugName: "rgb" }] : /* istanbul ignore next */ []));
133
- this.gradient = signal('', /* @ts-ignore */
134
- ...(ngDevMode ? [{ debugName: "gradient" }] : /* istanbul ignore next */ []));
135
- this.posX = signal(0, /* @ts-ignore */
136
- ...(ngDevMode ? [{ debugName: "posX" }] : /* istanbul ignore next */ []));
137
- this.posY = signal(0, /* @ts-ignore */
138
- ...(ngDevMode ? [{ debugName: "posY" }] : /* istanbul ignore next */ []));
139
- effect(() => {
140
- const color = this.color();
141
- this.hsl.set(color.hsl);
142
- this.rgb.set(color.rgb);
143
- const rgb = this.rgb();
144
- if (rgb) {
145
- if (this.direction() === 'vertical') {
146
- untracked(() => {
147
- this.gradient.set(`linear-gradient(to top, rgba(${rgb.r},${rgb.g},${rgb.b}, 0) 0%, rgba(${rgb.r},${rgb.g},${rgb.b}, 1) 100%)`);
148
- this.posX.set(0);
149
- this.posY.set((1 - rgb.a) * 100);
150
- });
151
- }
152
- else {
153
- untracked(() => {
154
- this.gradient.set(`linear-gradient(to right, rgba(${rgb.r},${rgb.g},${rgb.b}, 0) 0%, rgba(${rgb.r},${rgb.g},${rgb.b}, 1) 100%)`);
155
- this.posY.set(0);
156
- this.posX.set(rgb.a * 100);
157
- });
158
- }
159
- }
160
- });
161
- }
162
- handleChange(e) {
163
- const { top, left, containerHeight, containerWidth } = e;
164
- const isVertical = this.direction() === 'vertical';
165
- const pos = isVertical ? top : left;
166
- const size = isVertical ? containerHeight : containerWidth;
167
- const ratio = Math.max(0, Math.min(pos, size)) / size;
168
- const alpha = isVertical ? 1 - ratio : ratio;
169
- const a = Math.round(alpha * 100) / 100;
170
- const hsl = this.hsl();
171
- if (hsl && hsl.a !== a) {
172
- this.change.emit({ ...hsl, a, source: 'rgb' });
173
- }
174
- }
175
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorAlphaSlider, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
176
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: CmatColorAlphaSlider, isStandalone: true, selector: "cmat-color-alpha-slider", inputs: { color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: true, transformFunction: null }, direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { change: "change" }, host: { properties: { "class.cmat-color-alpha-vertical": "direction()=== \"vertical\"", "class.cmat-color-alpha-horizontal": "direction() === \"horizontal\"" }, classAttribute: "cmat-color-alpha-slider" }, ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-alpha-slider-track\" cmatColorCoordinates [style.background-image]=\"gradient()\" [percentX]=\"posX()\"\r\n [percentY]=\"posY()\" (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-alpha-slider-pointer\" [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-alpha-slider-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>", styles: [".cmat-color-alpha-slider{position:relative;display:block;width:var(--cp-slider-width, auto);height:var(--cp-slider-height, 10px);border-radius:var(--cp-slider-shape, 2px);background-color:#fff;background-image:conic-gradient(transparent 25%,#ccc 25% 50%,transparent 50% 75%,#ccc 75%);background-size:10px 10px}.cmat-color-alpha-slider.cmat-color-alpha-vertical{width:var(--cp-slider-width, 10px);height:var(--cp-slider-height, auto)}.cmat-color-alpha-slider-track{position:relative;width:100%;height:100%;border-radius:var(--cp-slider-shape, 2px);touch-action:none}.cmat-color-alpha-slider-pointer{position:absolute}.cmat-color-alpha-slider-thumb{display:block;width:var(--cp-slider-thumb-width, 12px);height:var(--cp-slider-thumb-height, 12px);padding:0;border:none;border-radius:var(--cp-slider-thumb-shape, 6px);transform:translate(-50%,calc((var(--cp-slider-thumb-height, 12px) - var(--cp-slider-height, 10px)) / -2));background-color:var(--cp-slider-thumb-background-color, #f2f2f2);outline:1px solid var(--cp-slider-thumb-outline-color, rgba(0, 0, 0, .04));box-shadow:var(--cp-slider-thumb-shadow, 0 1px 4px 0 rgba(0, 0, 0, .32), 0 2px 8px 0 rgba(0, 0, 0, .16))}.cmat-color-alpha-slider-thumb:focus-visible{outline-color:var(--cp-slider-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}.cmat-color-alpha-vertical .cmat-color-alpha-slider-thumb{transform:translate(calc((var(--cp-slider-thumb-width, 12px) - var(--cp-slider-width, 10px)) / -2),-50%)}\n"], dependencies: [{ kind: "directive", type: CmatColorCoordinates, selector: "[cmat-color-coordinates], [cmatColorCoordinates]", inputs: ["percentX", "percentY"], outputs: ["coordinatesChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
177
- }
178
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorAlphaSlider, decorators: [{
179
- type: Component,
180
- args: [{ selector: 'cmat-color-alpha-slider', imports: [CmatColorCoordinates], host: {
181
- 'class': 'cmat-color-alpha-slider',
182
- // eslint-disable-next-line @typescript-eslint/naming-convention
183
- '[class.cmat-color-alpha-vertical]': 'direction()=== "vertical"',
184
- // eslint-disable-next-line @typescript-eslint/naming-convention
185
- '[class.cmat-color-alpha-horizontal]': 'direction() === "horizontal"',
186
- }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-alpha-slider-track\" cmatColorCoordinates [style.background-image]=\"gradient()\" [percentX]=\"posX()\"\r\n [percentY]=\"posY()\" (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-alpha-slider-pointer\" [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-alpha-slider-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>", styles: [".cmat-color-alpha-slider{position:relative;display:block;width:var(--cp-slider-width, auto);height:var(--cp-slider-height, 10px);border-radius:var(--cp-slider-shape, 2px);background-color:#fff;background-image:conic-gradient(transparent 25%,#ccc 25% 50%,transparent 50% 75%,#ccc 75%);background-size:10px 10px}.cmat-color-alpha-slider.cmat-color-alpha-vertical{width:var(--cp-slider-width, 10px);height:var(--cp-slider-height, auto)}.cmat-color-alpha-slider-track{position:relative;width:100%;height:100%;border-radius:var(--cp-slider-shape, 2px);touch-action:none}.cmat-color-alpha-slider-pointer{position:absolute}.cmat-color-alpha-slider-thumb{display:block;width:var(--cp-slider-thumb-width, 12px);height:var(--cp-slider-thumb-height, 12px);padding:0;border:none;border-radius:var(--cp-slider-thumb-shape, 6px);transform:translate(-50%,calc((var(--cp-slider-thumb-height, 12px) - var(--cp-slider-height, 10px)) / -2));background-color:var(--cp-slider-thumb-background-color, #f2f2f2);outline:1px solid var(--cp-slider-thumb-outline-color, rgba(0, 0, 0, .04));box-shadow:var(--cp-slider-thumb-shadow, 0 1px 4px 0 rgba(0, 0, 0, .32), 0 2px 8px 0 rgba(0, 0, 0, .16))}.cmat-color-alpha-slider-thumb:focus-visible{outline-color:var(--cp-slider-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}.cmat-color-alpha-vertical .cmat-color-alpha-slider-thumb{transform:translate(calc((var(--cp-slider-thumb-width, 12px) - var(--cp-slider-width, 10px)) / -2),-50%)}\n"] }]
187
- }], ctorParameters: () => [], propDecorators: { color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: true }] }], direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "direction", required: false }] }], change: [{ type: i0.Output, args: ["change"] }] } });
188
-
189
- class CmatColorHueSlider {
190
- constructor() {
191
- this.color = input.required(/* @ts-ignore */
192
- ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
193
- this.direction = input('horizontal', /* @ts-ignore */
194
- ...(ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []));
195
- this.change = output();
196
- this.hsl = signal(null, /* @ts-ignore */
197
- ...(ngDevMode ? [{ debugName: "hsl" }] : /* istanbul ignore next */ []));
198
- this.posX = signal(0, /* @ts-ignore */
199
- ...(ngDevMode ? [{ debugName: "posX" }] : /* istanbul ignore next */ []));
200
- this.posY = signal(0, /* @ts-ignore */
201
- ...(ngDevMode ? [{ debugName: "posY" }] : /* istanbul ignore next */ []));
202
- effect(() => {
203
- const color = this.color();
204
- this.hsl.set(color.hsl);
205
- if (!color.hsl) {
206
- return;
207
- }
208
- if (this.direction() === 'vertical') {
209
- untracked(() => {
210
- this.posX.set(0);
211
- this.posY.set(100 - (this.hsl().h * 100) / 360);
212
- });
213
- }
214
- else {
215
- untracked(() => {
216
- this.posY.set(0);
217
- this.posX.set((this.hsl().h * 100) / 360);
218
- });
219
- }
220
- });
221
- }
222
- handleChange(e) {
223
- const { top, left, containerHeight, containerWidth } = e;
224
- const isVertical = this.direction() === 'vertical';
225
- const pos = isVertical ? top : left;
226
- const size = isVertical ? containerHeight : containerWidth;
227
- const ratio = Math.max(0, Math.min(pos, size)) / size;
228
- const hue = isVertical ? (1 - ratio) * 360 : ratio * 360;
229
- const h = hue >= 360 ? 359 : hue;
230
- const hsl = this.hsl();
231
- if (hsl && hsl.h !== h) {
232
- this.change.emit({ ...hsl, h, source: 'rgb' });
233
- }
234
- }
235
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorHueSlider, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
236
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: CmatColorHueSlider, isStandalone: true, selector: "cmat-color-hue-slider", inputs: { color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: true, transformFunction: null }, direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { change: "change" }, host: { properties: { "class.cmat-color-hue-vertical": "direction() === \"vertical\"", "class.cmat-color-hue-horizontal": "direction() === \"horizontal\"" }, classAttribute: "cmat-color-hue-slider" }, ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-hue-slider-track\" cmatColorCoordinates [percentX]=\"posX()\" [percentY]=\"posY()\"\r\n (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-hue-slider-pointer\" [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-hue-slider-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>", styles: [".cmat-color-hue-slider{position:relative;display:block;width:var(--cp-slider-width, auto);height:var(--cp-slider-height, 10px);border-radius:var(--cp-slider-shape, 2px);background-image:linear-gradient(to right,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red)}.cmat-color-hue-slider.cmat-color-hue-vertical{width:var(--cp-slider-width, 10px);height:var(--cp-slider-height, auto);background-image:linear-gradient(to top,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red)}.cmat-color-hue-slider-track{position:relative;width:100%;height:100%;border-radius:var(--cp-slider-shape, 2px);touch-action:none}.cmat-color-hue-slider-pointer{position:absolute}.cmat-color-hue-slider-thumb{display:block;width:var(--cp-slider-thumb-width, 12px);height:var(--cp-slider-thumb-height, 12px);padding:0;border:none;border-radius:var(--cp-slider-thumb-shape, 6px);transform:translate(-50%,calc((var(--cp-slider-thumb-height, 12px) - var(--cp-slider-height, 10px)) / -2));background-color:var(--cp-slider-thumb-background-color, #f2f2f2);outline:1px solid var(--cp-slider-thumb-outline-color, rgba(0, 0, 0, .04));box-shadow:var(--cp-slider-thumb-shadow, 0 1px 4px 0 rgba(0, 0, 0, .32), 0 2px 8px 0 rgba(0, 0, 0, .16))}.cmat-color-hue-slider-thumb:focus-visible{outline-color:var(--cp-slider-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}.cmat-color-hue-vertical .cmat-color-hue-slider-thumb{transform:translate(calc((var(--cp-slider-thumb-width, 12px) - var(--cp-slider-width, 10px)) / -2),-50%)}\n"], dependencies: [{ kind: "directive", type: CmatColorCoordinates, selector: "[cmat-color-coordinates], [cmatColorCoordinates]", inputs: ["percentX", "percentY"], outputs: ["coordinatesChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
237
- }
238
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorHueSlider, decorators: [{
239
- type: Component,
240
- args: [{ selector: 'cmat-color-hue-slider', imports: [CmatColorCoordinates], host: {
241
- 'class': 'cmat-color-hue-slider',
242
- // eslint-disable-next-line @typescript-eslint/naming-convention
243
- '[class.cmat-color-hue-vertical]': 'direction() === "vertical"',
244
- // eslint-disable-next-line @typescript-eslint/naming-convention
245
- '[class.cmat-color-hue-horizontal]': 'direction() === "horizontal"',
246
- }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-hue-slider-track\" cmatColorCoordinates [percentX]=\"posX()\" [percentY]=\"posY()\"\r\n (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-hue-slider-pointer\" [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-hue-slider-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>", styles: [".cmat-color-hue-slider{position:relative;display:block;width:var(--cp-slider-width, auto);height:var(--cp-slider-height, 10px);border-radius:var(--cp-slider-shape, 2px);background-image:linear-gradient(to right,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red)}.cmat-color-hue-slider.cmat-color-hue-vertical{width:var(--cp-slider-width, 10px);height:var(--cp-slider-height, auto);background-image:linear-gradient(to top,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red)}.cmat-color-hue-slider-track{position:relative;width:100%;height:100%;border-radius:var(--cp-slider-shape, 2px);touch-action:none}.cmat-color-hue-slider-pointer{position:absolute}.cmat-color-hue-slider-thumb{display:block;width:var(--cp-slider-thumb-width, 12px);height:var(--cp-slider-thumb-height, 12px);padding:0;border:none;border-radius:var(--cp-slider-thumb-shape, 6px);transform:translate(-50%,calc((var(--cp-slider-thumb-height, 12px) - var(--cp-slider-height, 10px)) / -2));background-color:var(--cp-slider-thumb-background-color, #f2f2f2);outline:1px solid var(--cp-slider-thumb-outline-color, rgba(0, 0, 0, .04));box-shadow:var(--cp-slider-thumb-shadow, 0 1px 4px 0 rgba(0, 0, 0, .32), 0 2px 8px 0 rgba(0, 0, 0, .16))}.cmat-color-hue-slider-thumb:focus-visible{outline-color:var(--cp-slider-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}.cmat-color-hue-vertical .cmat-color-hue-slider-thumb{transform:translate(calc((var(--cp-slider-thumb-width, 12px) - var(--cp-slider-width, 10px)) / -2),-50%)}\n"] }]
247
- }], ctorParameters: () => [], propDecorators: { color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: true }] }], direction: [{ type: i0.Input, args: [{ isSignal: true, alias: "direction", required: false }] }], change: [{ type: i0.Output, args: ["change"] }] } });
248
-
249
- class CmatColorIconButton {
250
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorIconButton, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
251
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.2.0", type: CmatColorIconButton, isStandalone: true, selector: "cmat-color-icon-button", host: { classAttribute: "cmat-color-icon-button" }, ngImport: i0, template: `
252
- <ng-content />
253
- `, isInline: true, styles: [".cmat-color-icon-button{display:inline-block;width:24px;height:24px}.cmat-color-icon-button button{width:100%;height:100%;padding:2px;color:var(--cp-icon-button-text-color, inherit);background-color:var(--cp-icon-button-background-color, transparent);border:none;border-radius:var(--cp-icon-button-shape, 4px)}.cmat-color-icon-button button:hover{background-color:var(--cp-icon-button-hover-background-color, rgba(0, 0, 0, .06))}.cmat-color-icon-button button:active{background-color:var(--cp-icon-button-active-background-color, rgba(0, 0, 0, .12))}.cmat-color-icon-button button:focus-visible{background-color:var(--cp-icon-button-focus-background-color, transparent);outline:1px solid var(--cp-icon-button-focus-outline-color, #0d99ff);outline-offset:-1px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
254
- }
255
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorIconButton, decorators: [{
256
- type: Component,
257
- args: [{ selector: 'cmat-color-icon-button', imports: [], template: `
258
- <ng-content />
259
- `, host: {
260
- class: 'cmat-color-icon-button',
261
- }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".cmat-color-icon-button{display:inline-block;width:24px;height:24px}.cmat-color-icon-button button{width:100%;height:100%;padding:2px;color:var(--cp-icon-button-text-color, inherit);background-color:var(--cp-icon-button-background-color, transparent);border:none;border-radius:var(--cp-icon-button-shape, 4px)}.cmat-color-icon-button button:hover{background-color:var(--cp-icon-button-hover-background-color, rgba(0, 0, 0, .06))}.cmat-color-icon-button button:active{background-color:var(--cp-icon-button-active-background-color, rgba(0, 0, 0, .12))}.cmat-color-icon-button button:focus-visible{background-color:var(--cp-icon-button-focus-background-color, transparent);outline:1px solid var(--cp-icon-button-focus-outline-color, #0d99ff);outline-offset:-1px}\n"] }]
262
- }] });
263
-
1
+ import { DOCUMENT, NgClass, NgStyle } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { ChangeDetectionStrategy, Component, Directive, ElementRef, ViewEncapsulation, effect, forwardRef, inject, input, model, output, signal, untracked } from "@angular/core";
4
+ import * as i1 from "@angular/forms";
5
+ import { FormsModule, NG_VALUE_ACCESSOR, ReactiveFormsModule } from "@angular/forms";
6
+ import { TinyColor } from "@ctrl/tinycolor";
7
+ import { CdkConnectedOverlay, CdkOverlayOrigin } from "@angular/cdk/overlay";
8
+ import * as i2 from "@angular/material/input";
9
+ import { MatInputModule } from "@angular/material/input";
10
+ var CmatColorCoordinates = class CmatColorCoordinates {
11
+ constructor() {
12
+ this.percentX = input(0, ...ngDevMode ? [{ debugName: "percentX" }] : /* istanbul ignore next */ []);
13
+ this.percentY = input(0, ...ngDevMode ? [{ debugName: "percentY" }] : /* istanbul ignore next */ []);
14
+ this.coordinatesChange = output();
15
+ this._document = inject(DOCUMENT);
16
+ this._el = inject(ElementRef);
17
+ this.onDrag = (e) => {
18
+ e.preventDefault();
19
+ this._handleChange(e);
20
+ };
21
+ this.onDragEnd = () => {
22
+ this._document.removeEventListener("pointermove", this.onDrag);
23
+ this._document.removeEventListener("pointerup", this.onDragEnd);
24
+ };
25
+ }
26
+ onDragStart(e) {
27
+ this._document.addEventListener("pointermove", this.onDrag, { passive: false });
28
+ this._document.addEventListener("pointerup", this.onDragEnd, { passive: false });
29
+ e.preventDefault();
30
+ this._handleChange(e);
31
+ }
32
+ onKeyDown(e) {
33
+ if (![
34
+ "ArrowUp",
35
+ "ArrowDown",
36
+ "ArrowLeft",
37
+ "ArrowRight"
38
+ ].includes(e.key)) return;
39
+ e.preventDefault();
40
+ const rect = this._el.nativeElement.getBoundingClientRect();
41
+ const multiplier = e.shiftKey ? 10 : 1;
42
+ const stepX = rect.width / 100 * multiplier;
43
+ const stepY = rect.height / 100 * multiplier;
44
+ let vX = 0;
45
+ let vY = 0;
46
+ if (this.percentX != null && this.percentY != null) {
47
+ vX = rect.left + rect.width * (this.percentX() / 100);
48
+ vY = rect.top + rect.height * (this.percentY() / 100);
49
+ switch (e.key) {
50
+ case "ArrowLeft":
51
+ vX -= stepX;
52
+ break;
53
+ case "ArrowRight":
54
+ vX += stepX;
55
+ break;
56
+ case "ArrowUp":
57
+ vY -= stepY;
58
+ break;
59
+ case "ArrowDown": vY += stepY;
60
+ }
61
+ } else if (this.percentX != null) {
62
+ vX = rect.left + rect.width * (this.percentX() / 100);
63
+ switch (e.key) {
64
+ case "ArrowLeft":
65
+ case "ArrowDown":
66
+ vX -= stepX;
67
+ break;
68
+ case "ArrowRight":
69
+ case "ArrowUp": vX += stepX;
70
+ }
71
+ } else if (this.percentY != null) {
72
+ vY = rect.top + rect.height * (this.percentY() / 100);
73
+ switch (e.key) {
74
+ case "ArrowLeft":
75
+ case "ArrowDown":
76
+ vY += stepY;
77
+ break;
78
+ case "ArrowRight":
79
+ case "ArrowUp": vY -= stepY;
80
+ }
81
+ }
82
+ this._handleChange({
83
+ clientX: vX,
84
+ clientY: vY
85
+ });
86
+ }
87
+ _handleChange(e) {
88
+ const containerRect = this._el.nativeElement.getBoundingClientRect();
89
+ const containerWidth = containerRect.width;
90
+ const containerHeight = containerRect.height;
91
+ const { clientX, clientY } = e;
92
+ const left = clientX - containerRect.left;
93
+ const top = clientY - containerRect.top;
94
+ this.coordinatesChange.emit({
95
+ containerWidth,
96
+ containerHeight,
97
+ left,
98
+ top
99
+ });
100
+ }
101
+ static {
102
+ this.ɵfac = i0.ɵɵngDeclareFactory({
103
+ minVersion: "12.0.0",
104
+ version: "22.2.3",
105
+ ngImport: i0,
106
+ type: CmatColorCoordinates,
107
+ deps: [],
108
+ target: i0.ɵɵFactoryTarget.Directive
109
+ });
110
+ }
111
+ static {
112
+ this.ɵdir = i0.ɵɵngDeclareDirective({
113
+ minVersion: "17.1.0",
114
+ version: "22.2.3",
115
+ type: CmatColorCoordinates,
116
+ isStandalone: true,
117
+ selector: "[cmat-color-coordinates], [cmatColorCoordinates]",
118
+ inputs: {
119
+ percentX: {
120
+ classPropertyName: "percentX",
121
+ publicName: "percentX",
122
+ isSignal: true,
123
+ isRequired: false,
124
+ transformFunction: null
125
+ },
126
+ percentY: {
127
+ classPropertyName: "percentY",
128
+ publicName: "percentY",
129
+ isSignal: true,
130
+ isRequired: false,
131
+ transformFunction: null
132
+ }
133
+ },
134
+ outputs: { coordinatesChange: "coordinatesChange" },
135
+ host: { listeners: {
136
+ "pointerdown": "onDragStart($event)",
137
+ "keydown": "onKeyDown($event)"
138
+ } },
139
+ ngImport: i0
140
+ });
141
+ }
142
+ };
143
+ i0.ɵɵngDeclareClassMetadata({
144
+ minVersion: "12.0.0",
145
+ version: "22.2.3",
146
+ ngImport: i0,
147
+ type: CmatColorCoordinates,
148
+ decorators: [{
149
+ type: Directive,
150
+ args: [{
151
+ selector: "[cmat-color-coordinates], [cmatColorCoordinates]",
152
+ host: {
153
+ "(pointerdown)": "onDragStart($event)",
154
+ "(keydown)": "onKeyDown($event)"
155
+ }
156
+ }]
157
+ }],
158
+ propDecorators: {
159
+ percentX: [{
160
+ type: i0.Input,
161
+ args: [{
162
+ isSignal: true,
163
+ alias: "percentX",
164
+ required: false
165
+ }]
166
+ }],
167
+ percentY: [{
168
+ type: i0.Input,
169
+ args: [{
170
+ isSignal: true,
171
+ alias: "percentY",
172
+ required: false
173
+ }]
174
+ }],
175
+ coordinatesChange: [{
176
+ type: i0.Output,
177
+ args: ["coordinatesChange"]
178
+ }]
179
+ }
180
+ });
181
+ var CmatColorAlphaSlider = class CmatColorAlphaSlider {
182
+ constructor() {
183
+ this.color = input.required(...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
184
+ this.direction = input("horizontal", ...ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []);
185
+ this.change = output();
186
+ this.hsl = signal(null, ...ngDevMode ? [{ debugName: "hsl" }] : /* istanbul ignore next */ []);
187
+ this.rgb = signal(null, ...ngDevMode ? [{ debugName: "rgb" }] : /* istanbul ignore next */ []);
188
+ this.gradient = signal("", ...ngDevMode ? [{ debugName: "gradient" }] : /* istanbul ignore next */ []);
189
+ this.posX = signal(0, ...ngDevMode ? [{ debugName: "posX" }] : /* istanbul ignore next */ []);
190
+ this.posY = signal(0, ...ngDevMode ? [{ debugName: "posY" }] : /* istanbul ignore next */ []);
191
+ effect(() => {
192
+ const color = this.color();
193
+ this.hsl.set(color.hsl);
194
+ this.rgb.set(color.rgb);
195
+ const rgb = this.rgb();
196
+ if (rgb) {
197
+ if (this.direction() === "vertical") untracked(() => {
198
+ this.gradient.set(`linear-gradient(to top, rgba(${rgb.r},${rgb.g},${rgb.b}, 0) 0%, rgba(${rgb.r},${rgb.g},${rgb.b}, 1) 100%)`);
199
+ this.posX.set(0);
200
+ this.posY.set((1 - rgb.a) * 100);
201
+ });
202
+ else untracked(() => {
203
+ this.gradient.set(`linear-gradient(to right, rgba(${rgb.r},${rgb.g},${rgb.b}, 0) 0%, rgba(${rgb.r},${rgb.g},${rgb.b}, 1) 100%)`);
204
+ this.posY.set(0);
205
+ this.posX.set(rgb.a * 100);
206
+ });
207
+ }
208
+ });
209
+ }
210
+ handleChange(e) {
211
+ const { top, left, containerHeight, containerWidth } = e;
212
+ const isVertical = this.direction() === "vertical";
213
+ const pos = isVertical ? top : left;
214
+ const size = isVertical ? containerHeight : containerWidth;
215
+ const ratio = Math.max(0, Math.min(pos, size)) / size;
216
+ const alpha = isVertical ? 1 - ratio : ratio;
217
+ const a = Math.round(alpha * 100) / 100;
218
+ const hsl = this.hsl();
219
+ if (hsl && hsl.a !== a) this.change.emit({
220
+ ...hsl,
221
+ a,
222
+ source: "rgb"
223
+ });
224
+ }
225
+ static {
226
+ this.ɵfac = i0.ɵɵngDeclareFactory({
227
+ minVersion: "12.0.0",
228
+ version: "22.2.3",
229
+ ngImport: i0,
230
+ type: CmatColorAlphaSlider,
231
+ deps: [],
232
+ target: i0.ɵɵFactoryTarget.Component
233
+ });
234
+ }
235
+ static {
236
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
237
+ minVersion: "17.1.0",
238
+ version: "22.2.3",
239
+ type: CmatColorAlphaSlider,
240
+ isStandalone: true,
241
+ selector: "cmat-color-alpha-slider",
242
+ inputs: {
243
+ color: {
244
+ classPropertyName: "color",
245
+ publicName: "color",
246
+ isSignal: true,
247
+ isRequired: true,
248
+ transformFunction: null
249
+ },
250
+ direction: {
251
+ classPropertyName: "direction",
252
+ publicName: "direction",
253
+ isSignal: true,
254
+ isRequired: false,
255
+ transformFunction: null
256
+ }
257
+ },
258
+ outputs: { change: "change" },
259
+ host: {
260
+ properties: {
261
+ "class.cmat-color-alpha-vertical": "direction()=== \"vertical\"",
262
+ "class.cmat-color-alpha-horizontal": "direction() === \"horizontal\""
263
+ },
264
+ classAttribute: "cmat-color-alpha-slider"
265
+ },
266
+ ngImport: i0,
267
+ template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-alpha-slider-track\" cmatColorCoordinates [style.background-image]=\"gradient()\" [percentX]=\"posX()\"\r\n [percentY]=\"posY()\" (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-alpha-slider-pointer\" [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-alpha-slider-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>",
268
+ styles: [".cmat-color-alpha-slider{position:relative;display:block;width:var(--cp-slider-width, auto);height:var(--cp-slider-height, 10px);border-radius:var(--cp-slider-shape, 2px);background-color:#fff;background-image:conic-gradient(transparent 25%,#ccc 25% 50%,transparent 50% 75%,#ccc 75%);background-size:10px 10px}.cmat-color-alpha-slider.cmat-color-alpha-vertical{width:var(--cp-slider-width, 10px);height:var(--cp-slider-height, auto)}.cmat-color-alpha-slider-track{position:relative;width:100%;height:100%;border-radius:var(--cp-slider-shape, 2px);touch-action:none}.cmat-color-alpha-slider-pointer{position:absolute}.cmat-color-alpha-slider-thumb{display:block;width:var(--cp-slider-thumb-width, 12px);height:var(--cp-slider-thumb-height, 12px);padding:0;border:none;border-radius:var(--cp-slider-thumb-shape, 6px);transform:translate(-50%,calc((var(--cp-slider-thumb-height, 12px) - var(--cp-slider-height, 10px)) / -2));background-color:var(--cp-slider-thumb-background-color, #f2f2f2);outline:1px solid var(--cp-slider-thumb-outline-color, rgba(0, 0, 0, .04));box-shadow:var(--cp-slider-thumb-shadow, 0 1px 4px 0 rgba(0, 0, 0, .32), 0 2px 8px 0 rgba(0, 0, 0, .16))}.cmat-color-alpha-slider-thumb:focus-visible{outline-color:var(--cp-slider-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}.cmat-color-alpha-vertical .cmat-color-alpha-slider-thumb{transform:translate(calc((var(--cp-slider-thumb-width, 12px) - var(--cp-slider-width, 10px)) / -2),-50%)}\n"],
269
+ dependencies: [{
270
+ kind: "directive",
271
+ type: CmatColorCoordinates,
272
+ selector: "[cmat-color-coordinates], [cmatColorCoordinates]",
273
+ inputs: ["percentX", "percentY"],
274
+ outputs: ["coordinatesChange"]
275
+ }],
276
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
277
+ encapsulation: i0.ViewEncapsulation.None
278
+ });
279
+ }
280
+ };
281
+ i0.ɵɵngDeclareClassMetadata({
282
+ minVersion: "12.0.0",
283
+ version: "22.2.3",
284
+ ngImport: i0,
285
+ type: CmatColorAlphaSlider,
286
+ decorators: [{
287
+ type: Component,
288
+ args: [{
289
+ selector: "cmat-color-alpha-slider",
290
+ imports: [CmatColorCoordinates],
291
+ host: {
292
+ "class": "cmat-color-alpha-slider",
293
+ "[class.cmat-color-alpha-vertical]": "direction()=== \"vertical\"",
294
+ "[class.cmat-color-alpha-horizontal]": "direction() === \"horizontal\""
295
+ },
296
+ encapsulation: ViewEncapsulation.None,
297
+ changeDetection: ChangeDetectionStrategy.OnPush,
298
+ template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-alpha-slider-track\" cmatColorCoordinates [style.background-image]=\"gradient()\" [percentX]=\"posX()\"\r\n [percentY]=\"posY()\" (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-alpha-slider-pointer\" [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-alpha-slider-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>",
299
+ styles: [".cmat-color-alpha-slider{position:relative;display:block;width:var(--cp-slider-width, auto);height:var(--cp-slider-height, 10px);border-radius:var(--cp-slider-shape, 2px);background-color:#fff;background-image:conic-gradient(transparent 25%,#ccc 25% 50%,transparent 50% 75%,#ccc 75%);background-size:10px 10px}.cmat-color-alpha-slider.cmat-color-alpha-vertical{width:var(--cp-slider-width, 10px);height:var(--cp-slider-height, auto)}.cmat-color-alpha-slider-track{position:relative;width:100%;height:100%;border-radius:var(--cp-slider-shape, 2px);touch-action:none}.cmat-color-alpha-slider-pointer{position:absolute}.cmat-color-alpha-slider-thumb{display:block;width:var(--cp-slider-thumb-width, 12px);height:var(--cp-slider-thumb-height, 12px);padding:0;border:none;border-radius:var(--cp-slider-thumb-shape, 6px);transform:translate(-50%,calc((var(--cp-slider-thumb-height, 12px) - var(--cp-slider-height, 10px)) / -2));background-color:var(--cp-slider-thumb-background-color, #f2f2f2);outline:1px solid var(--cp-slider-thumb-outline-color, rgba(0, 0, 0, .04));box-shadow:var(--cp-slider-thumb-shadow, 0 1px 4px 0 rgba(0, 0, 0, .32), 0 2px 8px 0 rgba(0, 0, 0, .16))}.cmat-color-alpha-slider-thumb:focus-visible{outline-color:var(--cp-slider-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}.cmat-color-alpha-vertical .cmat-color-alpha-slider-thumb{transform:translate(calc((var(--cp-slider-thumb-width, 12px) - var(--cp-slider-width, 10px)) / -2),-50%)}\n"]
300
+ }]
301
+ }],
302
+ ctorParameters: () => [],
303
+ propDecorators: {
304
+ color: [{
305
+ type: i0.Input,
306
+ args: [{
307
+ isSignal: true,
308
+ alias: "color",
309
+ required: true
310
+ }]
311
+ }],
312
+ direction: [{
313
+ type: i0.Input,
314
+ args: [{
315
+ isSignal: true,
316
+ alias: "direction",
317
+ required: false
318
+ }]
319
+ }],
320
+ change: [{
321
+ type: i0.Output,
322
+ args: ["change"]
323
+ }]
324
+ }
325
+ });
326
+ var CmatColorHueSlider = class CmatColorHueSlider {
327
+ constructor() {
328
+ this.color = input.required(...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
329
+ this.direction = input("horizontal", ...ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []);
330
+ this.change = output();
331
+ this.hsl = signal(null, ...ngDevMode ? [{ debugName: "hsl" }] : /* istanbul ignore next */ []);
332
+ this.posX = signal(0, ...ngDevMode ? [{ debugName: "posX" }] : /* istanbul ignore next */ []);
333
+ this.posY = signal(0, ...ngDevMode ? [{ debugName: "posY" }] : /* istanbul ignore next */ []);
334
+ effect(() => {
335
+ const color = this.color();
336
+ this.hsl.set(color.hsl);
337
+ if (!color.hsl) return;
338
+ if (this.direction() === "vertical") untracked(() => {
339
+ this.posX.set(0);
340
+ this.posY.set(100 - this.hsl().h * 100 / 360);
341
+ });
342
+ else untracked(() => {
343
+ this.posY.set(0);
344
+ this.posX.set(this.hsl().h * 100 / 360);
345
+ });
346
+ });
347
+ }
348
+ handleChange(e) {
349
+ const { top, left, containerHeight, containerWidth } = e;
350
+ const isVertical = this.direction() === "vertical";
351
+ const pos = isVertical ? top : left;
352
+ const size = isVertical ? containerHeight : containerWidth;
353
+ const ratio = Math.max(0, Math.min(pos, size)) / size;
354
+ const hue = isVertical ? (1 - ratio) * 360 : ratio * 360;
355
+ const h = hue >= 360 ? 359 : hue;
356
+ const hsl = this.hsl();
357
+ if (hsl && hsl.h !== h) this.change.emit({
358
+ ...hsl,
359
+ h,
360
+ source: "rgb"
361
+ });
362
+ }
363
+ static {
364
+ this.ɵfac = i0.ɵɵngDeclareFactory({
365
+ minVersion: "12.0.0",
366
+ version: "22.2.3",
367
+ ngImport: i0,
368
+ type: CmatColorHueSlider,
369
+ deps: [],
370
+ target: i0.ɵɵFactoryTarget.Component
371
+ });
372
+ }
373
+ static {
374
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
375
+ minVersion: "17.1.0",
376
+ version: "22.2.3",
377
+ type: CmatColorHueSlider,
378
+ isStandalone: true,
379
+ selector: "cmat-color-hue-slider",
380
+ inputs: {
381
+ color: {
382
+ classPropertyName: "color",
383
+ publicName: "color",
384
+ isSignal: true,
385
+ isRequired: true,
386
+ transformFunction: null
387
+ },
388
+ direction: {
389
+ classPropertyName: "direction",
390
+ publicName: "direction",
391
+ isSignal: true,
392
+ isRequired: false,
393
+ transformFunction: null
394
+ }
395
+ },
396
+ outputs: { change: "change" },
397
+ host: {
398
+ properties: {
399
+ "class.cmat-color-hue-vertical": "direction() === \"vertical\"",
400
+ "class.cmat-color-hue-horizontal": "direction() === \"horizontal\""
401
+ },
402
+ classAttribute: "cmat-color-hue-slider"
403
+ },
404
+ ngImport: i0,
405
+ template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-hue-slider-track\" cmatColorCoordinates [percentX]=\"posX()\" [percentY]=\"posY()\"\r\n (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-hue-slider-pointer\" [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-hue-slider-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>",
406
+ styles: [".cmat-color-hue-slider{position:relative;display:block;width:var(--cp-slider-width, auto);height:var(--cp-slider-height, 10px);border-radius:var(--cp-slider-shape, 2px);background-image:linear-gradient(to right,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red)}.cmat-color-hue-slider.cmat-color-hue-vertical{width:var(--cp-slider-width, 10px);height:var(--cp-slider-height, auto);background-image:linear-gradient(to top,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red)}.cmat-color-hue-slider-track{position:relative;width:100%;height:100%;border-radius:var(--cp-slider-shape, 2px);touch-action:none}.cmat-color-hue-slider-pointer{position:absolute}.cmat-color-hue-slider-thumb{display:block;width:var(--cp-slider-thumb-width, 12px);height:var(--cp-slider-thumb-height, 12px);padding:0;border:none;border-radius:var(--cp-slider-thumb-shape, 6px);transform:translate(-50%,calc((var(--cp-slider-thumb-height, 12px) - var(--cp-slider-height, 10px)) / -2));background-color:var(--cp-slider-thumb-background-color, #f2f2f2);outline:1px solid var(--cp-slider-thumb-outline-color, rgba(0, 0, 0, .04));box-shadow:var(--cp-slider-thumb-shadow, 0 1px 4px 0 rgba(0, 0, 0, .32), 0 2px 8px 0 rgba(0, 0, 0, .16))}.cmat-color-hue-slider-thumb:focus-visible{outline-color:var(--cp-slider-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}.cmat-color-hue-vertical .cmat-color-hue-slider-thumb{transform:translate(calc((var(--cp-slider-thumb-width, 12px) - var(--cp-slider-width, 10px)) / -2),-50%)}\n"],
407
+ dependencies: [{
408
+ kind: "directive",
409
+ type: CmatColorCoordinates,
410
+ selector: "[cmat-color-coordinates], [cmatColorCoordinates]",
411
+ inputs: ["percentX", "percentY"],
412
+ outputs: ["coordinatesChange"]
413
+ }],
414
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
415
+ encapsulation: i0.ViewEncapsulation.None
416
+ });
417
+ }
418
+ };
419
+ i0.ɵɵngDeclareClassMetadata({
420
+ minVersion: "12.0.0",
421
+ version: "22.2.3",
422
+ ngImport: i0,
423
+ type: CmatColorHueSlider,
424
+ decorators: [{
425
+ type: Component,
426
+ args: [{
427
+ selector: "cmat-color-hue-slider",
428
+ imports: [CmatColorCoordinates],
429
+ host: {
430
+ "class": "cmat-color-hue-slider",
431
+ "[class.cmat-color-hue-vertical]": "direction() === \"vertical\"",
432
+ "[class.cmat-color-hue-horizontal]": "direction() === \"horizontal\""
433
+ },
434
+ encapsulation: ViewEncapsulation.None,
435
+ changeDetection: ChangeDetectionStrategy.OnPush,
436
+ template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-hue-slider-track\" cmatColorCoordinates [percentX]=\"posX()\" [percentY]=\"posY()\"\r\n (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-hue-slider-pointer\" [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-hue-slider-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>",
437
+ styles: [".cmat-color-hue-slider{position:relative;display:block;width:var(--cp-slider-width, auto);height:var(--cp-slider-height, 10px);border-radius:var(--cp-slider-shape, 2px);background-image:linear-gradient(to right,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red)}.cmat-color-hue-slider.cmat-color-hue-vertical{width:var(--cp-slider-width, 10px);height:var(--cp-slider-height, auto);background-image:linear-gradient(to top,red,#ff0 17%,#0f0 33%,#0ff,#00f 67%,#f0f 83%,red)}.cmat-color-hue-slider-track{position:relative;width:100%;height:100%;border-radius:var(--cp-slider-shape, 2px);touch-action:none}.cmat-color-hue-slider-pointer{position:absolute}.cmat-color-hue-slider-thumb{display:block;width:var(--cp-slider-thumb-width, 12px);height:var(--cp-slider-thumb-height, 12px);padding:0;border:none;border-radius:var(--cp-slider-thumb-shape, 6px);transform:translate(-50%,calc((var(--cp-slider-thumb-height, 12px) - var(--cp-slider-height, 10px)) / -2));background-color:var(--cp-slider-thumb-background-color, #f2f2f2);outline:1px solid var(--cp-slider-thumb-outline-color, rgba(0, 0, 0, .04));box-shadow:var(--cp-slider-thumb-shadow, 0 1px 4px 0 rgba(0, 0, 0, .32), 0 2px 8px 0 rgba(0, 0, 0, .16))}.cmat-color-hue-slider-thumb:focus-visible{outline-color:var(--cp-slider-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}.cmat-color-hue-vertical .cmat-color-hue-slider-thumb{transform:translate(calc((var(--cp-slider-thumb-width, 12px) - var(--cp-slider-width, 10px)) / -2),-50%)}\n"]
438
+ }]
439
+ }],
440
+ ctorParameters: () => [],
441
+ propDecorators: {
442
+ color: [{
443
+ type: i0.Input,
444
+ args: [{
445
+ isSignal: true,
446
+ alias: "color",
447
+ required: true
448
+ }]
449
+ }],
450
+ direction: [{
451
+ type: i0.Input,
452
+ args: [{
453
+ isSignal: true,
454
+ alias: "direction",
455
+ required: false
456
+ }]
457
+ }],
458
+ change: [{
459
+ type: i0.Output,
460
+ args: ["change"]
461
+ }]
462
+ }
463
+ });
464
+ var CmatColorIconButton = class CmatColorIconButton {
465
+ static {
466
+ this.ɵfac = i0.ɵɵngDeclareFactory({
467
+ minVersion: "12.0.0",
468
+ version: "22.2.3",
469
+ ngImport: i0,
470
+ type: CmatColorIconButton,
471
+ deps: [],
472
+ target: i0.ɵɵFactoryTarget.Component
473
+ });
474
+ }
475
+ static {
476
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
477
+ minVersion: "14.0.0",
478
+ version: "22.2.3",
479
+ type: CmatColorIconButton,
480
+ isStandalone: true,
481
+ selector: "cmat-color-icon-button",
482
+ host: { classAttribute: "cmat-color-icon-button" },
483
+ ngImport: i0,
484
+ template: `
485
+ <ng-content />
486
+ `,
487
+ isInline: true,
488
+ styles: [".cmat-color-icon-button{display:inline-block;width:24px;height:24px}.cmat-color-icon-button button{width:100%;height:100%;padding:2px;color:var(--cp-icon-button-text-color, inherit);background-color:var(--cp-icon-button-background-color, transparent);border:none;border-radius:var(--cp-icon-button-shape, 4px)}.cmat-color-icon-button button:hover{background-color:var(--cp-icon-button-hover-background-color, rgba(0, 0, 0, .06))}.cmat-color-icon-button button:active{background-color:var(--cp-icon-button-active-background-color, rgba(0, 0, 0, .12))}.cmat-color-icon-button button:focus-visible{background-color:var(--cp-icon-button-focus-background-color, transparent);outline:1px solid var(--cp-icon-button-focus-outline-color, #0d99ff);outline-offset:-1px}\n"],
489
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
490
+ encapsulation: i0.ViewEncapsulation.None
491
+ });
492
+ }
493
+ };
494
+ i0.ɵɵngDeclareClassMetadata({
495
+ minVersion: "12.0.0",
496
+ version: "22.2.3",
497
+ ngImport: i0,
498
+ type: CmatColorIconButton,
499
+ decorators: [{
500
+ type: Component,
501
+ args: [{
502
+ selector: "cmat-color-icon-button",
503
+ imports: [],
504
+ template: `
505
+ <ng-content />
506
+ `,
507
+ host: { class: "cmat-color-icon-button" },
508
+ encapsulation: ViewEncapsulation.None,
509
+ changeDetection: ChangeDetectionStrategy.OnPush,
510
+ styles: [".cmat-color-icon-button{display:inline-block;width:24px;height:24px}.cmat-color-icon-button button{width:100%;height:100%;padding:2px;color:var(--cp-icon-button-text-color, inherit);background-color:var(--cp-icon-button-background-color, transparent);border:none;border-radius:var(--cp-icon-button-shape, 4px)}.cmat-color-icon-button button:hover{background-color:var(--cp-icon-button-hover-background-color, rgba(0, 0, 0, .06))}.cmat-color-icon-button button:active{background-color:var(--cp-icon-button-active-background-color, rgba(0, 0, 0, .12))}.cmat-color-icon-button button:focus-visible{background-color:var(--cp-icon-button-focus-background-color, transparent);outline:1px solid var(--cp-icon-button-focus-outline-color, #0d99ff);outline-offset:-1px}\n"]
511
+ }]
512
+ }]
513
+ });
264
514
  let nextUniqueId = 0;
265
- class CmatColorInputField {
266
- constructor() {
267
- this.label = input('', /* @ts-ignore */
268
- ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
269
- this.step = input(1, /* @ts-ignore */
270
- ...(ngDevMode ? [{ debugName: "step" }] : /* istanbul ignore next */ []));
271
- this.placeholder = input('', /* @ts-ignore */
272
- ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
273
- this.value = input('', /* @ts-ignore */
274
- ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
275
- this.valueChange = output();
276
- this.uniqueId = `cmat-color-input-${++nextUniqueId}`;
277
- this.focus = signal(false, /* @ts-ignore */
278
- ...(ngDevMode ? [{ debugName: "focus" }] : /* istanbul ignore next */ []));
279
- this.currentValue = signal('', /* @ts-ignore */
280
- ...(ngDevMode ? [{ debugName: "currentValue" }] : /* istanbul ignore next */ []));
281
- this.blurValue = signal('', /* @ts-ignore */
282
- ...(ngDevMode ? [{ debugName: "blurValue" }] : /* istanbul ignore next */ []));
283
- effect(() => {
284
- if (!this.focus()) {
285
- this.currentValue.set(String(this.value()));
286
- this.blurValue.set(String(this.value()));
287
- }
288
- else {
289
- this.blurValue.set(String(this.value()));
290
- }
291
- });
292
- }
293
- handleFocus(e) {
294
- this.focus.set(true);
295
- e.preventDefault();
296
- }
297
- handleFocusOut(e) {
298
- this.focus.set(false);
299
- this.currentValue.set(this.blurValue());
300
- e.preventDefault();
301
- }
302
- handleKeydown(e) {
303
- const target = e.target;
304
- const inputValue = String(target.value);
305
- const isPercentage = inputValue.includes('%');
306
- const num = Number(inputValue.replace(/%/g, ''));
307
- if (isNaN(num)) {
308
- return;
309
- }
310
- const step = this.step() || 1;
311
- if (e.key === 'ArrowUp') {
312
- if (this.label()) {
313
- this.valueChange.emit({ [this.label()]: num + step });
314
- }
315
- else {
316
- this.valueChange.emit(num + step);
317
- }
318
- if (isPercentage) {
319
- this.currentValue.set(`${num + step}%`);
320
- }
321
- else {
322
- this.currentValue.set(num + step);
323
- }
324
- }
325
- if (e.key === 'ArrowDown') {
326
- if (this.label()) {
327
- this.valueChange.emit({ [this.label()]: num - step });
328
- }
329
- else {
330
- this.valueChange.emit(num - step);
331
- }
332
- if (isPercentage) {
333
- this.currentValue.set(`${num - step}%`);
334
- }
335
- else {
336
- this.currentValue.set(num - step);
337
- }
338
- }
339
- }
340
- handleKeyup(e) {
341
- const target = e.target;
342
- if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
343
- return;
344
- }
345
- if (`${this.currentValue()}` === target.value) {
346
- return;
347
- }
348
- if (this.label()) {
349
- this.valueChange.emit({ [this.label()]: target.value });
350
- }
351
- else {
352
- this.valueChange.emit(target.value);
353
- }
354
- }
355
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorInputField, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
356
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: CmatColorInputField, isStandalone: true, selector: "cmat-color-input-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, step: { classPropertyName: "step", publicName: "step", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { classAttribute: "cmat-color-input-field" }, ngImport: i0, template: "<input spellCheck=\"false\" [value]=\"currentValue()\" [placeholder]=\"placeholder()\" [attr.aria-labelledby]=\"uniqueId\"\r\n (keydown)=\"handleKeydown($event)\" (keyup)=\"handleKeyup($event)\" (focus)=\"handleFocus($event)\"\r\n (focusout)=\"handleFocusOut($event)\" />\r\n@if (label()) {\r\n<span [id]=\"uniqueId\">{{ label() }}</span>\r\n}", styles: [".cmat-color-input-field{font-size:11px;text-align:center}.cmat-color-input-field input{box-sizing:border-box;width:100%;height:24px;border:none;border-radius:var(--cp-input-shape, 4px);background-color:var(--cp-input-background-color, transparent);outline:1px solid var(--cp-input-outline-color, #e6e6e6);font-family:var(--cp-input-text-font, monospace);font-size:inherit;text-align:inherit}.cmat-color-input-field input:hover{outline-color:var(--cp-input-hover-outline-color, #d6d6d6)}.cmat-color-input-field input:focus{outline-color:var(--cp-input-focus-outline-color, #0d99ff)}.cmat-color-input-field span{display:block;margin-top:8px;color:#969696;text-transform:uppercase}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
357
- }
358
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorInputField, decorators: [{
359
- type: Component,
360
- args: [{ selector: 'cmat-color-input-field', host: {
361
- class: 'cmat-color-input-field',
362
- }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<input spellCheck=\"false\" [value]=\"currentValue()\" [placeholder]=\"placeholder()\" [attr.aria-labelledby]=\"uniqueId\"\r\n (keydown)=\"handleKeydown($event)\" (keyup)=\"handleKeyup($event)\" (focus)=\"handleFocus($event)\"\r\n (focusout)=\"handleFocusOut($event)\" />\r\n@if (label()) {\r\n<span [id]=\"uniqueId\">{{ label() }}</span>\r\n}", styles: [".cmat-color-input-field{font-size:11px;text-align:center}.cmat-color-input-field input{box-sizing:border-box;width:100%;height:24px;border:none;border-radius:var(--cp-input-shape, 4px);background-color:var(--cp-input-background-color, transparent);outline:1px solid var(--cp-input-outline-color, #e6e6e6);font-family:var(--cp-input-text-font, monospace);font-size:inherit;text-align:inherit}.cmat-color-input-field input:hover{outline-color:var(--cp-input-hover-outline-color, #d6d6d6)}.cmat-color-input-field input:focus{outline-color:var(--cp-input-focus-outline-color, #0d99ff)}.cmat-color-input-field span{display:block;margin-top:8px;color:#969696;text-transform:uppercase}\n"] }]
363
- }], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], step: [{ type: i0.Input, args: [{ isSignal: true, alias: "step", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }] } });
364
-
365
- /* eslint-disable @typescript-eslint/no-unsafe-member-access */
515
+ var CmatColorInputField = class CmatColorInputField {
516
+ constructor() {
517
+ this.label = input("", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
518
+ this.step = input(1, ...ngDevMode ? [{ debugName: "step" }] : /* istanbul ignore next */ []);
519
+ this.placeholder = input("", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
520
+ this.value = input("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
521
+ this.valueChange = output();
522
+ this.uniqueId = `cmat-color-input-${++nextUniqueId}`;
523
+ this.focus = signal(false, ...ngDevMode ? [{ debugName: "focus" }] : /* istanbul ignore next */ []);
524
+ this.currentValue = signal("", ...ngDevMode ? [{ debugName: "currentValue" }] : /* istanbul ignore next */ []);
525
+ this.blurValue = signal("", ...ngDevMode ? [{ debugName: "blurValue" }] : /* istanbul ignore next */ []);
526
+ effect(() => {
527
+ if (!this.focus()) {
528
+ this.currentValue.set(String(this.value()));
529
+ this.blurValue.set(String(this.value()));
530
+ } else this.blurValue.set(String(this.value()));
531
+ });
532
+ }
533
+ handleFocus(e) {
534
+ this.focus.set(true);
535
+ e.preventDefault();
536
+ }
537
+ handleFocusOut(e) {
538
+ this.focus.set(false);
539
+ this.currentValue.set(this.blurValue());
540
+ e.preventDefault();
541
+ }
542
+ handleKeydown(e) {
543
+ const target = e.target;
544
+ const inputValue = String(target.value);
545
+ const isPercentage = inputValue.includes("%");
546
+ const num = Number(inputValue.replace(/%/g, ""));
547
+ if (isNaN(num)) return;
548
+ const step = this.step() || 1;
549
+ if (e.key === "ArrowUp") {
550
+ if (this.label()) this.valueChange.emit({ [this.label()]: num + step });
551
+ else this.valueChange.emit(num + step);
552
+ if (isPercentage) this.currentValue.set(`${num + step}%`);
553
+ else this.currentValue.set(num + step);
554
+ }
555
+ if (e.key === "ArrowDown") {
556
+ if (this.label()) this.valueChange.emit({ [this.label()]: num - step });
557
+ else this.valueChange.emit(num - step);
558
+ if (isPercentage) this.currentValue.set(`${num - step}%`);
559
+ else this.currentValue.set(num - step);
560
+ }
561
+ }
562
+ handleKeyup(e) {
563
+ const target = e.target;
564
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") return;
565
+ if (`${this.currentValue()}` === target.value) return;
566
+ if (this.label()) this.valueChange.emit({ [this.label()]: target.value });
567
+ else this.valueChange.emit(target.value);
568
+ }
569
+ static {
570
+ this.ɵfac = i0.ɵɵngDeclareFactory({
571
+ minVersion: "12.0.0",
572
+ version: "22.2.3",
573
+ ngImport: i0,
574
+ type: CmatColorInputField,
575
+ deps: [],
576
+ target: i0.ɵɵFactoryTarget.Component
577
+ });
578
+ }
579
+ static {
580
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
581
+ minVersion: "17.0.0",
582
+ version: "22.2.3",
583
+ type: CmatColorInputField,
584
+ isStandalone: true,
585
+ selector: "cmat-color-input-field",
586
+ inputs: {
587
+ label: {
588
+ classPropertyName: "label",
589
+ publicName: "label",
590
+ isSignal: true,
591
+ isRequired: false,
592
+ transformFunction: null
593
+ },
594
+ step: {
595
+ classPropertyName: "step",
596
+ publicName: "step",
597
+ isSignal: true,
598
+ isRequired: false,
599
+ transformFunction: null
600
+ },
601
+ placeholder: {
602
+ classPropertyName: "placeholder",
603
+ publicName: "placeholder",
604
+ isSignal: true,
605
+ isRequired: false,
606
+ transformFunction: null
607
+ },
608
+ value: {
609
+ classPropertyName: "value",
610
+ publicName: "value",
611
+ isSignal: true,
612
+ isRequired: false,
613
+ transformFunction: null
614
+ }
615
+ },
616
+ outputs: { valueChange: "valueChange" },
617
+ host: { classAttribute: "cmat-color-input-field" },
618
+ ngImport: i0,
619
+ template: "<input spellCheck=\"false\" [value]=\"currentValue()\" [placeholder]=\"placeholder()\" [attr.aria-labelledby]=\"uniqueId\"\r\n (keydown)=\"handleKeydown($event)\" (keyup)=\"handleKeyup($event)\" (focus)=\"handleFocus($event)\"\r\n (focusout)=\"handleFocusOut($event)\" />\r\n@if (label()) {\r\n<span [id]=\"uniqueId\">{{ label() }}</span>\r\n}",
620
+ styles: [".cmat-color-input-field{font-size:11px;text-align:center}.cmat-color-input-field input{box-sizing:border-box;width:100%;height:24px;border:none;border-radius:var(--cp-input-shape, 4px);background-color:var(--cp-input-background-color, transparent);outline:1px solid var(--cp-input-outline-color, #e6e6e6);font-family:var(--cp-input-text-font, monospace);font-size:inherit;text-align:inherit}.cmat-color-input-field input:hover{outline-color:var(--cp-input-hover-outline-color, #d6d6d6)}.cmat-color-input-field input:focus{outline-color:var(--cp-input-focus-outline-color, #0d99ff)}.cmat-color-input-field span{display:block;margin-top:8px;color:#969696;text-transform:uppercase}\n"],
621
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
622
+ encapsulation: i0.ViewEncapsulation.None
623
+ });
624
+ }
625
+ };
626
+ i0.ɵɵngDeclareClassMetadata({
627
+ minVersion: "12.0.0",
628
+ version: "22.2.3",
629
+ ngImport: i0,
630
+ type: CmatColorInputField,
631
+ decorators: [{
632
+ type: Component,
633
+ args: [{
634
+ selector: "cmat-color-input-field",
635
+ host: { class: "cmat-color-input-field" },
636
+ encapsulation: ViewEncapsulation.None,
637
+ changeDetection: ChangeDetectionStrategy.OnPush,
638
+ template: "<input spellCheck=\"false\" [value]=\"currentValue()\" [placeholder]=\"placeholder()\" [attr.aria-labelledby]=\"uniqueId\"\r\n (keydown)=\"handleKeydown($event)\" (keyup)=\"handleKeyup($event)\" (focus)=\"handleFocus($event)\"\r\n (focusout)=\"handleFocusOut($event)\" />\r\n@if (label()) {\r\n<span [id]=\"uniqueId\">{{ label() }}</span>\r\n}",
639
+ styles: [".cmat-color-input-field{font-size:11px;text-align:center}.cmat-color-input-field input{box-sizing:border-box;width:100%;height:24px;border:none;border-radius:var(--cp-input-shape, 4px);background-color:var(--cp-input-background-color, transparent);outline:1px solid var(--cp-input-outline-color, #e6e6e6);font-family:var(--cp-input-text-font, monospace);font-size:inherit;text-align:inherit}.cmat-color-input-field input:hover{outline-color:var(--cp-input-hover-outline-color, #d6d6d6)}.cmat-color-input-field input:focus{outline-color:var(--cp-input-focus-outline-color, #0d99ff)}.cmat-color-input-field span{display:block;margin-top:8px;color:#969696;text-transform:uppercase}\n"]
640
+ }]
641
+ }],
642
+ ctorParameters: () => [],
643
+ propDecorators: {
644
+ label: [{
645
+ type: i0.Input,
646
+ args: [{
647
+ isSignal: true,
648
+ alias: "label",
649
+ required: false
650
+ }]
651
+ }],
652
+ step: [{
653
+ type: i0.Input,
654
+ args: [{
655
+ isSignal: true,
656
+ alias: "step",
657
+ required: false
658
+ }]
659
+ }],
660
+ placeholder: [{
661
+ type: i0.Input,
662
+ args: [{
663
+ isSignal: true,
664
+ alias: "placeholder",
665
+ required: false
666
+ }]
667
+ }],
668
+ value: [{
669
+ type: i0.Input,
670
+ args: [{
671
+ isSignal: true,
672
+ alias: "value",
673
+ required: false
674
+ }]
675
+ }],
676
+ valueChange: [{
677
+ type: i0.Output,
678
+ args: ["valueChange"]
679
+ }]
680
+ }
681
+ });
366
682
  function simpleCheckForValidColor(data) {
367
- const keysToCheck = ['r', 'g', 'b', 'a', 'h', 's', 'l', 'v'];
368
- let checked = 0;
369
- let passed = 0;
370
- keysToCheck.forEach((letter) => {
371
- if (!(letter in data)) {
372
- return;
373
- }
374
- checked += 1;
375
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
376
- const value = data[letter];
377
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
378
- if (!isNaN(value)) {
379
- passed += 1;
380
- }
381
- if (letter === 's' || letter === 'l') {
382
- const percentPatt = /^\d+%$/;
383
- if (percentPatt.test(String(value))) {
384
- passed += 1;
385
- }
386
- }
387
- });
388
- return checked === passed;
683
+ const keysToCheck = [
684
+ "r",
685
+ "g",
686
+ "b",
687
+ "a",
688
+ "h",
689
+ "s",
690
+ "l",
691
+ "v"
692
+ ];
693
+ let checked = 0;
694
+ let passed = 0;
695
+ keysToCheck.forEach((letter) => {
696
+ if (!(letter in data)) return;
697
+ checked += 1;
698
+ const value = data[letter];
699
+ if (!isNaN(value)) passed += 1;
700
+ if (letter === "s" || letter === "l") {
701
+ if (/^\d+%$/.test(String(value))) passed += 1;
702
+ }
703
+ });
704
+ return checked === passed;
389
705
  }
390
706
  function parseColor(data, oldHue = 0, hideAlpha = false) {
391
- const color = data && typeof data !== 'string' && 'hex' in data
392
- ? new TinyColor(data.hex)
393
- : new TinyColor(data);
394
- if (hideAlpha) {
395
- color.setAlpha(1);
396
- }
397
- const rgb = color.toRgb();
398
- let hsl;
399
- let hsv;
400
- // Check if data is HSLAsource
401
- if (data && typeof data === 'object' && 's' in data && 'l' in data) {
402
- hsl = {
403
- h: data.h ?? oldHue,
404
- s: data.s,
405
- l: data.l,
406
- a: data.a ?? 1,
407
- };
408
- hsv = hslToHsv(hsl.h, hsl.s, hsl.l, hsl.a);
409
- }
410
- else if (data && typeof data === 'object' && 's' in data && 'v' in data) {
411
- // Check if data is HSVAsource
412
- hsv = {
413
- h: data.h ?? oldHue,
414
- s: data.s,
415
- v: data.v,
416
- a: data.a ?? 1,
417
- };
418
- hsl = hsvToHsl(hsv.h, hsv.s, hsv.v, hsv.a);
419
- }
420
- else {
421
- hsl = color.toHsl();
422
- hsv = color.toHsv();
423
- }
424
- if (hsl.s === 0) {
425
- hsl.h = oldHue;
426
- hsv.h = oldHue;
427
- }
428
- return {
429
- hsl,
430
- hslString: toHslString(hsl),
431
- hsv,
432
- hsvString: toHsvString(hsv),
433
- rgb,
434
- rgbString: color.toRgbString(),
435
- hex: rgb.a === 1 ? color.toHexString() : color.toHex8String(),
436
- oldHue: data && typeof data === 'object' && 'h' in data ? (data.h ?? oldHue ?? hsl.h) : (oldHue ?? hsl.h),
437
- source: data && typeof data === 'object' ? data.source : '',
438
- };
707
+ const color = data && typeof data !== "string" && "hex" in data ? new TinyColor(data.hex) : new TinyColor(data);
708
+ if (hideAlpha) color.setAlpha(1);
709
+ const rgb = color.toRgb();
710
+ let hsl;
711
+ let hsv;
712
+ if (data && typeof data === "object" && "s" in data && "l" in data) {
713
+ hsl = {
714
+ h: data.h ?? oldHue,
715
+ s: data.s,
716
+ l: data.l,
717
+ a: data.a ?? 1
718
+ };
719
+ hsv = hslToHsv(hsl.h, hsl.s, hsl.l, hsl.a);
720
+ } else if (data && typeof data === "object" && "s" in data && "v" in data) {
721
+ hsv = {
722
+ h: data.h ?? oldHue,
723
+ s: data.s,
724
+ v: data.v,
725
+ a: data.a ?? 1
726
+ };
727
+ hsl = hsvToHsl(hsv.h, hsv.s, hsv.v, hsv.a);
728
+ } else {
729
+ hsl = color.toHsl();
730
+ hsv = color.toHsv();
731
+ }
732
+ if (hsl.s === 0) {
733
+ hsl.h = oldHue;
734
+ hsv.h = oldHue;
735
+ }
736
+ return {
737
+ hsl,
738
+ hslString: toHslString(hsl),
739
+ hsv,
740
+ hsvString: toHsvString(hsv),
741
+ rgb,
742
+ rgbString: color.toRgbString(),
743
+ hex: rgb.a === 1 ? color.toHexString() : color.toHex8String(),
744
+ oldHue: data && typeof data === "object" && "h" in data ? data.h ?? oldHue ?? hsl.h : oldHue ?? hsl.h,
745
+ source: data && typeof data === "object" ? data.source : ""
746
+ };
439
747
  }
440
748
  function hslToHsv(h, s, l, a) {
441
- const v = l + s * Math.min(l, 1 - l);
442
- const sv = v === 0 ? 0 : 2 * (1 - l / v);
443
- return { h, s: sv, v, a };
749
+ const v = l + s * Math.min(l, 1 - l);
750
+ return {
751
+ h,
752
+ s: v === 0 ? 0 : 2 * (1 - l / v),
753
+ v,
754
+ a
755
+ };
444
756
  }
445
757
  function hsvToHsl(h, s, v, a) {
446
- const l = v * (1 - s / 2);
447
- const sl = l === 0 || l === 1 ? 0 : (v - l) / Math.min(l, 1 - l);
448
- return { h, s: sl, l, a };
758
+ const l = v * (1 - s / 2);
759
+ return {
760
+ h,
761
+ s: l === 0 || l === 1 ? 0 : (v - l) / Math.min(l, 1 - l),
762
+ l,
763
+ a
764
+ };
449
765
  }
450
766
  function toHslString(hsl) {
451
- const h = Math.round(hsl.h);
452
- const s = Math.round(hsl.s * 100);
453
- const l = Math.round(hsl.l * 100);
454
- return hsl.a === 1 ? `hsl(${h}, ${s}%, ${l}%)` : `hsla(${h}, ${s}%, ${l}%, ${hsl.a})`;
767
+ const h = Math.round(hsl.h);
768
+ const s = Math.round(hsl.s * 100);
769
+ const l = Math.round(hsl.l * 100);
770
+ return hsl.a === 1 ? `hsl(${h}, ${s}%, ${l}%)` : `hsla(${h}, ${s}%, ${l}%, ${hsl.a})`;
455
771
  }
456
772
  function toHsvString(hsv) {
457
- const h = Math.round(hsv.h);
458
- const s = Math.round(hsv.s * 100);
459
- const v = Math.round(hsv.v * 100);
460
- return hsv.a === 1 ? `hsv(${h}, ${s}%, ${v}%)` : `hsva(${h}, ${s}%, ${v}%, ${hsv.a})`;
773
+ const h = Math.round(hsv.h);
774
+ const s = Math.round(hsv.s * 100);
775
+ const v = Math.round(hsv.v * 100);
776
+ return hsv.a === 1 ? `hsv(${h}, ${s}%, ${v}%)` : `hsva(${h}, ${s}%, ${v}%, ${hsv.a})`;
461
777
  }
462
778
  function isValidHex(hex) {
463
- const tinyColor = new TinyColor(hex);
464
- return tinyColor.isValid;
779
+ return new TinyColor(hex).isValid;
465
780
  }
466
-
467
- class CmatColorInputFields {
468
- constructor() {
469
- this.color = input.required(/* @ts-ignore */
470
- ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
471
- this.format = model('hex', /* @ts-ignore */
472
- ...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
473
- this.hideAlpha = input(false, /* @ts-ignore */
474
- ...(ngDevMode ? [{ debugName: "hideAlpha" }] : /* istanbul ignore next */ []));
475
- this.formatChanged = output();
476
- this.valueChange = output();
477
- this.hsl = signal(null, /* @ts-ignore */
478
- ...(ngDevMode ? [{ debugName: "hsl" }] : /* istanbul ignore next */ []));
479
- this.rgb = signal(null, /* @ts-ignore */
480
- ...(ngDevMode ? [{ debugName: "rgb" }] : /* istanbul ignore next */ []));
481
- this.hex = signal('', /* @ts-ignore */
482
- ...(ngDevMode ? [{ debugName: "hex" }] : /* istanbul ignore next */ []));
483
- effect(() => {
484
- const color = this.color();
485
- this.hsl.set(color.hsl);
486
- this.rgb.set(color.rgb);
487
- this.hex.set(color.hex);
488
- untracked(() => {
489
- if (!this.format()) {
490
- this.format.set('hex');
491
- }
492
- else if (this.format() === 'hsv') {
493
- this.format.set('hsl');
494
- }
495
- });
496
- });
497
- }
498
- round(value) {
499
- return Math.round(value);
500
- }
501
- toggleColorFormat() {
502
- let format;
503
- let fieldVal = {};
504
- if (this.format() === 'hex') {
505
- format = 'rgb';
506
- fieldVal = { ...this.rgb() };
507
- }
508
- else if (this.format() === 'rgb') {
509
- format = 'hsl';
510
- fieldVal = { ...this.hsl(), s: this.hsl().s * 100, l: this.hsl().l * 100 };
511
- }
512
- else if (this.format() === 'hsl') {
513
- format = 'hex';
514
- fieldVal = { hex: this.hex() };
515
- }
516
- this.format.set(format);
517
- this.formatChanged.emit(format);
518
- this.handleChange(fieldVal);
519
- }
520
- handleChange(e) {
521
- if (typeof e === 'string' || typeof e === 'number') {
522
- return;
523
- }
524
- if (e.hex) {
525
- if (isValidHex(e.hex)) {
526
- const color = new TinyColor(e.hex);
527
- this.valueChange.emit({
528
- hex: this.hideAlpha() ? color.toHex() : color.toHex8(),
529
- source: 'hex',
530
- });
531
- }
532
- }
533
- else if (e.r || e.g || e.b) {
534
- this.valueChange.emit({
535
- r: e.r ?? this.rgb().r,
536
- g: e.g ?? this.rgb().g,
537
- b: e.b ?? this.rgb().b,
538
- a: Math.round((e.a ?? this.rgb().a) * 100) / 100,
539
- source: 'rgb',
540
- });
541
- }
542
- else if (e.h || e.s || e.l) {
543
- const s = (typeof e.s === 'string' ? Number(e.s.replace('%', '')) : e.s ?? 0) / 100;
544
- const l = (typeof e.l === 'string' ? Number(e.l.replace('%', '')) : e.l ?? 0) / 100;
545
- this.valueChange.emit({
546
- h: e.h ?? this.hsl().h,
547
- s: s ?? this.hsl().s,
548
- l: l ?? this.hsl().l,
549
- a: Math.round((e.a ?? this.hsl().a) * 100) / 100,
550
- source: 'hsl',
551
- });
552
- }
553
- else if (e.a) {
554
- let a = Math.max(0, Math.min(1, e.a));
555
- if (this.hideAlpha()) {
556
- a = 1;
557
- }
558
- this.valueChange.emit({
559
- h: this.hsl().h,
560
- s: this.hsl().s,
561
- l: this.hsl().l,
562
- a: Math.round(a * 100) / 100,
563
- source: 'rgb',
564
- });
565
- }
566
- }
567
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorInputFields, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
568
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: CmatColorInputFields, isStandalone: true, selector: "cmat-color-input-fields", inputs: { color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: true, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, hideAlpha: { classPropertyName: "hideAlpha", publicName: "hideAlpha", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { format: "formatChange", formatChanged: "formatChanged", valueChange: "valueChange" }, host: { classAttribute: "cmat-color-input-fields" }, ngImport: i0, template: "<div class=\"cmat-color-input-field-wrapper\">\r\n @if (format() === 'hex') {\r\n <cmat-color-input-field label=\"hex\" [value]=\"hex()\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n @if (format() === 'rgb') {\r\n <cmat-color-input-field label=\"r\" [value]=\"rgb()!.r\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"g\" [value]=\"rgb()!.g\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"b\" [value]=\"rgb()!.b\" (valueChange)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-input-field label=\"a\" [step]=\"0.01\" [value]=\"rgb()!.a\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n }\r\n @if (format() === 'hsl') {\r\n <cmat-color-input-field label=\"h\" [value]=\"round(hsl()!.h)\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"s\" [value]=\"round(hsl()!.s * 100) + '%'\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"l\" [value]=\"round(hsl()!.l * 100) + '%'\" (valueChange)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-input-field label=\"a\" [step]=\"0.01\" [value]=\"hsl()!.a\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n }\r\n</div>\r\n\r\n<cmat-color-icon-button>\r\n <button type=\"button\" (click)=\"toggleColorFormat()\">\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z\" />\r\n </svg>\r\n </button>\r\n</cmat-color-icon-button>", styles: [".cmat-color-input-fields{display:flex;align-items:center;gap:8px;width:100%}.cmat-color-input-field-wrapper{flex:1;display:flex;gap:8px}.cmat-color-input-field-wrapper .cmat-color-input-field{flex:1}\n"], dependencies: [{ kind: "component", type: CmatColorInputField, selector: "cmat-color-input-field", inputs: ["label", "step", "placeholder", "value"], outputs: ["valueChange"] }, { kind: "component", type: CmatColorIconButton, selector: "cmat-color-icon-button" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
569
- }
570
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorInputFields, decorators: [{
571
- type: Component,
572
- args: [{ selector: 'cmat-color-input-fields', imports: [CmatColorInputField, CmatColorIconButton], host: {
573
- class: 'cmat-color-input-fields',
574
- }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"cmat-color-input-field-wrapper\">\r\n @if (format() === 'hex') {\r\n <cmat-color-input-field label=\"hex\" [value]=\"hex()\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n @if (format() === 'rgb') {\r\n <cmat-color-input-field label=\"r\" [value]=\"rgb()!.r\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"g\" [value]=\"rgb()!.g\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"b\" [value]=\"rgb()!.b\" (valueChange)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-input-field label=\"a\" [step]=\"0.01\" [value]=\"rgb()!.a\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n }\r\n @if (format() === 'hsl') {\r\n <cmat-color-input-field label=\"h\" [value]=\"round(hsl()!.h)\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"s\" [value]=\"round(hsl()!.s * 100) + '%'\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"l\" [value]=\"round(hsl()!.l * 100) + '%'\" (valueChange)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-input-field label=\"a\" [step]=\"0.01\" [value]=\"hsl()!.a\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n }\r\n</div>\r\n\r\n<cmat-color-icon-button>\r\n <button type=\"button\" (click)=\"toggleColorFormat()\">\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z\" />\r\n </svg>\r\n </button>\r\n</cmat-color-icon-button>", styles: [".cmat-color-input-fields{display:flex;align-items:center;gap:8px;width:100%}.cmat-color-input-field-wrapper{flex:1;display:flex;gap:8px}.cmat-color-input-field-wrapper .cmat-color-input-field{flex:1}\n"] }]
575
- }], ctorParameters: () => [], propDecorators: { color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: true }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }, { type: i0.Output, args: ["formatChange"] }], hideAlpha: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideAlpha", required: false }] }], formatChanged: [{ type: i0.Output, args: ["formatChanged"] }], valueChange: [{ type: i0.Output, args: ["valueChange"] }] } });
576
-
577
- class CmatColorSaturationPicker {
578
- constructor() {
579
- this.color = input.required(/* @ts-ignore */
580
- ...(ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []));
581
- this.change = output();
582
- this.hsl = signal(null, /* @ts-ignore */
583
- ...(ngDevMode ? [{ debugName: "hsl" }] : /* istanbul ignore next */ []));
584
- this.hsv = signal(null, /* @ts-ignore */
585
- ...(ngDevMode ? [{ debugName: "hsv" }] : /* istanbul ignore next */ []));
586
- this.bgColor = signal('', /* @ts-ignore */
587
- ...(ngDevMode ? [{ debugName: "bgColor" }] : /* istanbul ignore next */ []));
588
- this.posX = signal(0, /* @ts-ignore */
589
- ...(ngDevMode ? [{ debugName: "posX" }] : /* istanbul ignore next */ []));
590
- this.posY = signal(0, /* @ts-ignore */
591
- ...(ngDevMode ? [{ debugName: "posY" }] : /* istanbul ignore next */ []));
592
- this._el = inject(ElementRef);
593
- effect(() => {
594
- const color = this.color();
595
- this.hsl.set(color.hsl);
596
- this.hsv.set(color.hsv);
597
- untracked(() => {
598
- if (this.hsl()) {
599
- this.bgColor.set(`hsl(${this.hsl().h}, 100%, 50%)`);
600
- }
601
- if (this.hsv()) {
602
- this.posX.set(this.hsv().s * 100);
603
- this.posY.set(100 - this.hsv().v * 100);
604
- }
605
- });
606
- });
607
- }
608
- handleChange(e) {
609
- const { top, left, containerHeight, containerWidth } = e;
610
- const s = Math.max(0, Math.min(left, containerWidth)) / containerWidth;
611
- const v = 1 - Math.max(0, Math.min(top, containerHeight)) / containerHeight;
612
- const hsv = this.hsv();
613
- if (hsv) {
614
- this.change.emit({ ...hsv, s, v, source: 'hsva' });
615
- }
616
- }
617
- onScroll() {
618
- const el = this._el.nativeElement;
619
- if (el.scrollTop !== 0 || el.scrollLeft !== 0) {
620
- el.scrollTop = 0;
621
- el.scrollLeft = 0;
622
- }
623
- }
624
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorSaturationPicker, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
625
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: CmatColorSaturationPicker, isStandalone: true, selector: "cmat-color-saturation-picker", inputs: { color: { classPropertyName: "color", publicName: "color", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { change: "change" }, host: { listeners: { "scroll": "onScroll()" }, classAttribute: "cmat-color-saturation-picker" }, ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-saturation-picker-content\" cmatColorCoordinates [percentX]=\"posX()\" [percentY]=\"posY()\"\r\n [style.background-color]=\"bgColor()\" (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-saturation-picker-pointer\"\r\n [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-saturation-picker-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>", styles: [".cmat-color-saturation-picker{position:relative;display:block;width:100%;padding-bottom:55%;border-radius:var(--cp-saturation-picker-shape, 4px);overflow:hidden;box-shadow:0 0 0 1px #ffffff1f,0 0 0 1px #0000001f}.cmat-color-saturation-picker-content{position:absolute;inset:0;touch-action:none;background-image:linear-gradient(to top,#000,#0000),linear-gradient(to right,#fff,#fff0)}.cmat-color-saturation-picker-pointer{position:absolute}.cmat-color-saturation-picker-thumb{display:block;width:var(--cp-saturation-picker-thumb-size, 12px);height:var(--cp-saturation-picker-thumb-size, 12px);padding:0;border-radius:var(--cp-saturation-picker-thumb-shape, 6px);border:none;background:none;outline:1px solid var(--cp-saturation-picker-thumb-outline-color, #fff);outline-offset:-1px;transform:translate(-50%,-50%);box-shadow:var(--cp-saturation-picker-thumb-shadow, 0 2px 6px 0 rgba(0, 0, 0, .32))}.cmat-color-saturation-picker-thumb:focus-visible{outline-color:var(--cp-saturation-picker-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}\n"], dependencies: [{ kind: "directive", type: CmatColorCoordinates, selector: "[cmat-color-coordinates], [cmatColorCoordinates]", inputs: ["percentX", "percentY"], outputs: ["coordinatesChange"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
626
- }
627
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorSaturationPicker, decorators: [{
628
- type: Component,
629
- args: [{ selector: 'cmat-color-saturation-picker', imports: [CmatColorCoordinates], host: {
630
- 'class': 'cmat-color-saturation-picker',
631
- // eslint-disable-next-line @typescript-eslint/naming-convention
632
- '(scroll)': 'onScroll()',
633
- }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-saturation-picker-content\" cmatColorCoordinates [percentX]=\"posX()\" [percentY]=\"posY()\"\r\n [style.background-color]=\"bgColor()\" (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-saturation-picker-pointer\"\r\n [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-saturation-picker-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>", styles: [".cmat-color-saturation-picker{position:relative;display:block;width:100%;padding-bottom:55%;border-radius:var(--cp-saturation-picker-shape, 4px);overflow:hidden;box-shadow:0 0 0 1px #ffffff1f,0 0 0 1px #0000001f}.cmat-color-saturation-picker-content{position:absolute;inset:0;touch-action:none;background-image:linear-gradient(to top,#000,#0000),linear-gradient(to right,#fff,#fff0)}.cmat-color-saturation-picker-pointer{position:absolute}.cmat-color-saturation-picker-thumb{display:block;width:var(--cp-saturation-picker-thumb-size, 12px);height:var(--cp-saturation-picker-thumb-size, 12px);padding:0;border-radius:var(--cp-saturation-picker-thumb-shape, 6px);border:none;background:none;outline:1px solid var(--cp-saturation-picker-thumb-outline-color, #fff);outline-offset:-1px;transform:translate(-50%,-50%);box-shadow:var(--cp-saturation-picker-thumb-shadow, 0 2px 6px 0 rgba(0, 0, 0, .32))}.cmat-color-saturation-picker-thumb:focus-visible{outline-color:var(--cp-saturation-picker-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}\n"] }]
634
- }], ctorParameters: () => [], propDecorators: { color: [{ type: i0.Input, args: [{ isSignal: true, alias: "color", required: true }] }], change: [{ type: i0.Output, args: ["change"] }] } });
635
-
636
- class CmatColorPickerComponent {
637
- constructor() {
638
- this.format = model('hex', /* @ts-ignore */
639
- ...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
640
- this.value = model('#000', /* @ts-ignore */
641
- ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
642
- this.hideAlpha = input(false, /* @ts-ignore */
643
- ...(ngDevMode ? [{ debugName: "hideAlpha" }] : /* istanbul ignore next */ []));
644
- this.disabled = model(false, /* @ts-ignore */
645
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
646
- this.formatChanged = output();
647
- this.valueChanged = output();
648
- this.colorChanged = output();
649
- this.parsedColor = signal(null, /* @ts-ignore */
650
- ...(ngDevMode ? [{ debugName: "parsedColor" }] : /* istanbul ignore next */ []));
651
- this.isCopied = signal(false, /* @ts-ignore */
652
- ...(ngDevMode ? [{ debugName: "isCopied" }] : /* istanbul ignore next */ []));
653
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/naming-convention, @typescript-eslint/no-unsafe-member-access
654
- this.EyeDropper = window.EyeDropper;
655
- this.supportEyeDropper = !!this.EyeDropper;
656
- this._oldHue = signal(0, /* @ts-ignore */
657
- ...(ngDevMode ? [{ debugName: "_oldHue" }] : /* istanbul ignore next */ []));
658
- this._oldValue = signal('', /* @ts-ignore */
659
- ...(ngDevMode ? [{ debugName: "_oldValue" }] : /* istanbul ignore next */ []));
660
- this.onChange = () => {
661
- };
662
- this.onTouched = () => {
663
- };
664
- effect(() => {
665
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
666
- const format = this.format();
667
- untracked(() => {
668
- this.getColorFormat();
669
- });
670
- });
671
- effect(() => {
672
- const value = this.value();
673
- untracked(() => {
674
- if (value !== this._oldValue()) {
675
- this.getParsedColor(this.value(), this._oldHue());
676
- }
677
- });
678
- });
679
- }
680
- ngOnInit() {
681
- this.getParsedColor(this.value());
682
- }
683
- writeValue(value) {
684
- if (value) {
685
- this.value.set(value);
686
- this.getColorFormat();
687
- this.getParsedColor(value, this._oldHue());
688
- }
689
- }
690
- registerOnChange(fn) {
691
- this.onChange = fn;
692
- }
693
- registerOnTouched(fn) {
694
- this.onTouched = fn;
695
- }
696
- setDisabledState(isDisabled) {
697
- this.disabled.set(isDisabled);
698
- }
699
- getParsedColor(data, oldHue = 0) {
700
- this.parsedColor.set(parseColor(data, oldHue, this.hideAlpha()));
701
- this._oldHue.set(this.parsedColor().oldHue);
702
- }
703
- handleChange(e) {
704
- const isValidColor = simpleCheckForValidColor(e);
705
- if (isValidColor) {
706
- this.getParsedColor(e, e.h || this._oldHue());
707
- this.getColorString(this.parsedColor());
708
- this.onChange(this.value());
709
- this.valueChanged.emit(this.value());
710
- this.colorChanged.emit({ value: this.value(), color: this.parsedColor() });
711
- }
712
- }
713
- getColorFormat() {
714
- if (!this.format()) {
715
- const color = new TinyColor(this.value());
716
- if (color.format === 'rgb' || color.format === 'hsl' || color.format === 'hsv') {
717
- this.format.set(color.format);
718
- }
719
- else {
720
- this.format.set('hex');
721
- }
722
- }
723
- }
724
- getColorString(color) {
725
- switch (this.format()) {
726
- case 'rgb':
727
- this.value.set(color.rgbString);
728
- break;
729
- case 'hsl':
730
- this.value.set(color.hslString);
731
- break;
732
- case 'hsv':
733
- this.value.set(color.hsvString);
734
- break;
735
- default:
736
- this.value.set(color.hex);
737
- break;
738
- }
739
- this._oldValue.set(this.value());
740
- }
741
- handleFormatChange() {
742
- this.formatChanged.emit(this.format());
743
- }
744
- async openEyeDropper(e) {
745
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call
746
- const eyeDropper = new this.EyeDropper();
747
- try {
748
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
749
- const result = await eyeDropper.open();
750
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
751
- this.handleChange({ hex: result.sRGBHex, source: 'rgb' });
752
- e.preventDefault();
753
- }
754
- catch (err) {
755
- console.warn(err);
756
- }
757
- }
758
- async copyColor() {
759
- try {
760
- await navigator.clipboard.writeText(this.value());
761
- this.isCopied.set(true);
762
- setTimeout(() => {
763
- this.isCopied.set(false);
764
- }, 1000);
765
- }
766
- catch (err) {
767
- console.warn(err);
768
- }
769
- }
770
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorPickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
771
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.2.0", type: CmatColorPickerComponent, isStandalone: true, selector: "cmat-color-picker", inputs: { format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, hideAlpha: { classPropertyName: "hideAlpha", publicName: "hideAlpha", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { format: "formatChange", value: "valueChange", disabled: "disabledChange", formatChanged: "formatChanged", valueChanged: "valueChanged", colorChanged: "colorChanged" }, host: { classAttribute: "cmat-color-picker" }, providers: [
772
- {
773
- provide: NG_VALUE_ACCESSOR,
774
- useExisting: forwardRef(() => CmatColorPickerComponent),
775
- multi: true,
776
- },
777
- ], ngImport: i0, template: "<cmat-color-saturation-picker [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n\r\n<div class=\"cmat-color-picker-controls\">\r\n @if (supportEyeDropper) {\r\n <cmat-color-icon-button>\r\n <button type=\"button\" (click)=\"openEyeDropper($event)\">\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M19.35,11.72L17.22,13.85L15.81,12.43L8.1,20.14L3.5,22L2,20.5L3.86,15.9L11.57,8.19L10.15,6.78L12.28,4.65L19.35,11.72M16.76,3C17.93,1.83 19.83,1.83 21,3C22.17,4.17 22.17,6.07 21,7.24L19.08,9.16L14.84,4.92L16.76,3M5.56,17.03L4.5,19.5L6.97,18.44L14.4,11L13,9.6L5.56,17.03Z\" />\r\n </svg>\r\n </button>\r\n </cmat-color-icon-button>\r\n }\r\n\r\n <button class=\"cmat-color-preview\" type=\"button\" (click)=\"copyColor()\">\r\n <div class=\"cmat-color-preview-bg\" [ngStyle]=\"{'background-color':value()}\"></div>\r\n <div class=\"cmat-color-preview-backdrop\">\r\n @if (this.isCopied()) {\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\" d=\"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z\" />\r\n </svg>\r\n } @else {\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z\" />\r\n </svg>\r\n }\r\n </div>\r\n </button>\r\n\r\n <div class=\"cmat-color-hue-alpha\">\r\n <cmat-color-hue-slider [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-alpha-slider [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n }\r\n </div>\r\n</div>\r\n\r\n<div class=\"cmat-color-picker-controls\">\r\n <cmat-color-input-fields [color]=\"parsedColor()!\" [hideAlpha]=\"hideAlpha()\" [(format)]=\"format\"\r\n (valueChange)=\"handleChange($event)\" (formatChange)=\"handleFormatChange()\" />\r\n</div>", styles: [".cmat-color-picker{--cp-container-text-color: rgba(0, 0, 0, .9);--cp-container-background-color: #fff;--cp-input-outline-color: #e6e6e6;--cp-input-hover-outline-color: #d6d6d6;--cp-input-focus-outline-color: #0d99ff;--cp-icon-button-hover-background-color: rgba(0, 0, 0, .06);--cp-icon-button-active-background-color: rgba(0, 0, 0, .12);--cp-slider-thumb-background-color: #f2f2f2;--cp-slider-thumb-outline-color: rgba(0, 0, 0, .04)}.cmat-color-picker:is(.dark *){--cp-container-text-color: #fff;--cp-container-background-color: #2c2c2c;--cp-input-outline-color: #444;--cp-input-hover-outline-color: #545454;--cp-input-focus-outline-color: #0c8ce9;--cp-icon-button-hover-background-color: rgba(255, 255, 255, .06);--cp-icon-button-active-background-color: rgba(255, 255, 255, .12);--cp-slider-thumb-background-color: #3c3c3c;--cp-slider-thumb-outline-color: rgba(255, 255, 255, .24)}.cmat-color-picker{box-sizing:border-box;display:block;width:var(--cp-container-width, 240px);padding:var(--cp-container-padding, 12px);margin:var(--cp-container-margin, 0);color:var(--cp-container-text-color);background-color:var(--cp-container-background-color);border-radius:var(--cp-container-shape, 8px);box-shadow:var(--cp-container-elevation-shadow, inset 0 0 1px 0 rgba(255, 255, 255, .64), 0 2px 4px 0 rgba(0, 0, 0, .16), 0 8px 16px 0 rgba(0, 0, 0, .12), 0 0 1px 0 rgba(0, 0, 0, .12))}.cmat-color-picker-controls{display:flex;align-items:center;gap:10px;margin-top:16px}.cmat-color-preview{width:32px;height:32px;border-radius:16px;position:relative;overflow:hidden;border:none;outline:none;background-color:#fff;background-image:conic-gradient(transparent 25%,#ccc 25% 50%,transparent 50% 75%,#ccc 75%);background-size:10px 10px;box-shadow:0 0 0 1px #ffffff1f,0 0 0 1px #0000001f;cursor:pointer}.cmat-color-preview:hover .cmat-color-preview-backdrop,.cmat-color-preview:focus-visible .cmat-color-preview-backdrop{opacity:1}.cmat-color-preview-bg{position:absolute;inset:0}.cmat-color-preview-backdrop{position:absolute;inset:0;padding:6px;background-color:#00000052;color:#fff;opacity:0;pointer-events:none}.cmat-color-hue-alpha{flex:1;display:flex;flex-direction:column;gap:8px}\n"], dependencies: [{ kind: "component", type: CmatColorSaturationPicker, selector: "cmat-color-saturation-picker", inputs: ["color"], outputs: ["change"] }, { kind: "component", type: CmatColorHueSlider, selector: "cmat-color-hue-slider", inputs: ["color", "direction"], outputs: ["change"] }, { kind: "component", type: CmatColorAlphaSlider, selector: "cmat-color-alpha-slider", inputs: ["color", "direction"], outputs: ["change"] }, { kind: "component", type: CmatColorInputFields, selector: "cmat-color-input-fields", inputs: ["color", "format", "hideAlpha"], outputs: ["formatChange", "formatChanged", "valueChange"] }, { kind: "component", type: CmatColorIconButton, selector: "cmat-color-icon-button" }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
778
- }
779
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorPickerComponent, decorators: [{
780
- type: Component,
781
- args: [{ selector: 'cmat-color-picker', imports: [
782
- CmatColorSaturationPicker,
783
- CmatColorHueSlider,
784
- CmatColorAlphaSlider,
785
- CmatColorInputFields,
786
- CmatColorIconButton,
787
- NgStyle
788
- ], host: {
789
- class: 'cmat-color-picker',
790
- }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
791
- {
792
- provide: NG_VALUE_ACCESSOR,
793
- useExisting: forwardRef(() => CmatColorPickerComponent),
794
- multi: true,
795
- },
796
- ], template: "<cmat-color-saturation-picker [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n\r\n<div class=\"cmat-color-picker-controls\">\r\n @if (supportEyeDropper) {\r\n <cmat-color-icon-button>\r\n <button type=\"button\" (click)=\"openEyeDropper($event)\">\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M19.35,11.72L17.22,13.85L15.81,12.43L8.1,20.14L3.5,22L2,20.5L3.86,15.9L11.57,8.19L10.15,6.78L12.28,4.65L19.35,11.72M16.76,3C17.93,1.83 19.83,1.83 21,3C22.17,4.17 22.17,6.07 21,7.24L19.08,9.16L14.84,4.92L16.76,3M5.56,17.03L4.5,19.5L6.97,18.44L14.4,11L13,9.6L5.56,17.03Z\" />\r\n </svg>\r\n </button>\r\n </cmat-color-icon-button>\r\n }\r\n\r\n <button class=\"cmat-color-preview\" type=\"button\" (click)=\"copyColor()\">\r\n <div class=\"cmat-color-preview-bg\" [ngStyle]=\"{'background-color':value()}\"></div>\r\n <div class=\"cmat-color-preview-backdrop\">\r\n @if (this.isCopied()) {\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\" d=\"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z\" />\r\n </svg>\r\n } @else {\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z\" />\r\n </svg>\r\n }\r\n </div>\r\n </button>\r\n\r\n <div class=\"cmat-color-hue-alpha\">\r\n <cmat-color-hue-slider [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-alpha-slider [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n }\r\n </div>\r\n</div>\r\n\r\n<div class=\"cmat-color-picker-controls\">\r\n <cmat-color-input-fields [color]=\"parsedColor()!\" [hideAlpha]=\"hideAlpha()\" [(format)]=\"format\"\r\n (valueChange)=\"handleChange($event)\" (formatChange)=\"handleFormatChange()\" />\r\n</div>", styles: [".cmat-color-picker{--cp-container-text-color: rgba(0, 0, 0, .9);--cp-container-background-color: #fff;--cp-input-outline-color: #e6e6e6;--cp-input-hover-outline-color: #d6d6d6;--cp-input-focus-outline-color: #0d99ff;--cp-icon-button-hover-background-color: rgba(0, 0, 0, .06);--cp-icon-button-active-background-color: rgba(0, 0, 0, .12);--cp-slider-thumb-background-color: #f2f2f2;--cp-slider-thumb-outline-color: rgba(0, 0, 0, .04)}.cmat-color-picker:is(.dark *){--cp-container-text-color: #fff;--cp-container-background-color: #2c2c2c;--cp-input-outline-color: #444;--cp-input-hover-outline-color: #545454;--cp-input-focus-outline-color: #0c8ce9;--cp-icon-button-hover-background-color: rgba(255, 255, 255, .06);--cp-icon-button-active-background-color: rgba(255, 255, 255, .12);--cp-slider-thumb-background-color: #3c3c3c;--cp-slider-thumb-outline-color: rgba(255, 255, 255, .24)}.cmat-color-picker{box-sizing:border-box;display:block;width:var(--cp-container-width, 240px);padding:var(--cp-container-padding, 12px);margin:var(--cp-container-margin, 0);color:var(--cp-container-text-color);background-color:var(--cp-container-background-color);border-radius:var(--cp-container-shape, 8px);box-shadow:var(--cp-container-elevation-shadow, inset 0 0 1px 0 rgba(255, 255, 255, .64), 0 2px 4px 0 rgba(0, 0, 0, .16), 0 8px 16px 0 rgba(0, 0, 0, .12), 0 0 1px 0 rgba(0, 0, 0, .12))}.cmat-color-picker-controls{display:flex;align-items:center;gap:10px;margin-top:16px}.cmat-color-preview{width:32px;height:32px;border-radius:16px;position:relative;overflow:hidden;border:none;outline:none;background-color:#fff;background-image:conic-gradient(transparent 25%,#ccc 25% 50%,transparent 50% 75%,#ccc 75%);background-size:10px 10px;box-shadow:0 0 0 1px #ffffff1f,0 0 0 1px #0000001f;cursor:pointer}.cmat-color-preview:hover .cmat-color-preview-backdrop,.cmat-color-preview:focus-visible .cmat-color-preview-backdrop{opacity:1}.cmat-color-preview-bg{position:absolute;inset:0}.cmat-color-preview-backdrop{position:absolute;inset:0;padding:6px;background-color:#00000052;color:#fff;opacity:0;pointer-events:none}.cmat-color-hue-alpha{flex:1;display:flex;flex-direction:column;gap:8px}\n"] }]
797
- }], ctorParameters: () => [], propDecorators: { format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }, { type: i0.Output, args: ["formatChange"] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], hideAlpha: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideAlpha", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], formatChanged: [{ type: i0.Output, args: ["formatChanged"] }], valueChanged: [{ type: i0.Output, args: ["valueChanged"] }], colorChanged: [{ type: i0.Output, args: ["colorChanged"] }] } });
798
-
799
- class CmatColorPickerButtonComponent {
800
- constructor() {
801
- this.format = model('hex', /* @ts-ignore */
802
- ...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
803
- this.value = model('#000', /* @ts-ignore */
804
- ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
805
- this.hideAlpha = input(false, /* @ts-ignore */
806
- ...(ngDevMode ? [{ debugName: "hideAlpha" }] : /* istanbul ignore next */ []));
807
- this.disabled = model(false, /* @ts-ignore */
808
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
809
- this.placeholder = input('请输入', /* @ts-ignore */
810
- ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
811
- this.label = input('颜色', /* @ts-ignore */
812
- ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
813
- this.formatChanged = output();
814
- this.valueChanged = output();
815
- this.colorChanged = output();
816
- this.isOpen = signal(false, /* @ts-ignore */
817
- ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
818
- }
819
- toggleMenu() {
820
- this.isOpen.update(v => !v);
821
- }
822
- closeMenu() {
823
- this.isOpen.set(false);
824
- }
825
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorPickerButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
826
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "22.2.0", type: CmatColorPickerButtonComponent, isStandalone: true, selector: "cmat-color-picker-button", inputs: { format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, hideAlpha: { classPropertyName: "hideAlpha", publicName: "hideAlpha", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { format: "formatChange", value: "valueChange", disabled: "disabledChange", formatChanged: "formatChanged", valueChanged: "valueChanged", colorChanged: "colorChanged" }, ngImport: i0, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<section>\r\n <mat-form-field class=\"w-full\">\r\n <mat-label>{{ label() }}</mat-label>\r\n <input matInput type=\"text\" [placeholder]=\"placeholder()\" [disabled]=\"disabled()\" [(ngModel)]=\"value\"\r\n (ngModelChange)=\"valueChanged.emit($event);colorChanged.emit($event);\" />\r\n <button #trigger=\"cdkOverlayOrigin\" matPrefix cdkOverlayOrigin class=\"ml-2\"\r\n [ngClass]=\"{'pointer-events-none':disabled()}\"\r\n [style.color]=\"value()\" (click)=\"toggleMenu()\">\r\n <span></span>\r\n </button>\r\n </mat-form-field>\r\n</section>\r\n\r\n<ng-template cdkConnectedOverlay [cdkConnectedOverlayOrigin]=\"trigger\" [cdkConnectedOverlayOpen]=\"isOpen()\"\r\n (overlayOutsideClick)=\"closeMenu()\" (detach)=\"closeMenu()\">\r\n <cmat-color-picker [format]=\"format()\" [hideAlpha]=\"hideAlpha()\" [disabled]=\"disabled()\" [(value)]=\"value\"\r\n (formatChanged)=\"formatChanged.emit($event)\" (valueChanged)=\"valueChanged.emit($event)\"\r\n (colorChanged)=\"colorChanged.emit($event)\" />\r\n</ng-template>", styles: ["cmat-color-picker-button{--cmat-prefix-label-offset: 20px}cmat-color-picker-button section{--outline-color: #b4b4b4;--hover-outline-color: var(--cmat-primary)}cmat-color-picker-button section:is(.dark *){--outline-color: #4d4d4d}cmat-color-picker-button section{display:flex;gap:8px}cmat-color-picker-button .input-group{display:flex;gap:8px}cmat-color-picker-button .input-group input{flex:1}cmat-color-picker-button button{display:inline-flex;width:32px;height:32px;padding:4px;background:none;border-radius:8px;border:1px solid var(--outline-color);cursor:pointer}cmat-color-picker-button button:after{content:\"\";display:inline-block;width:100%;height:100%;background-color:currentColor;border-radius:3px}cmat-color-picker-button button:hover,cmat-color-picker-button button:focus{border-color:var(--hover-outline-color)}cmat-color-picker-button input{padding:4px 8px;border-radius:8px;border:1px solid var(--outline-color);display:flex;flex:1 auto}cmat-color-picker-button input:hover,cmat-color-picker-button input:focus{border-color:var(--hover-outline-color)}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: CmatColorPickerComponent, selector: "cmat-color-picker", inputs: ["format", "value", "hideAlpha", "disabled"], outputs: ["formatChange", "valueChange", "disabledChange", "formatChanged", "valueChanged", "colorChanged"] }, { kind: "directive", type: CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation", "cdkConnectedOverlayUsePopover", "cdkConnectedOverlayMatchWidth", "cdkConnectedOverlay"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "directive", type: CdkOverlayOrigin, selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]", exportAs: ["cdkOverlayOrigin"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: i2.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2.MatLabel, selector: "mat-label" }, { kind: "directive", type: i2.MatPrefix, selector: "[matPrefix], [matIconPrefix], [matTextPrefix]", inputs: ["matTextPrefix"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
827
- }
828
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatColorPickerButtonComponent, decorators: [{
829
- type: Component,
830
- args: [{ selector: 'cmat-color-picker-button', imports: [
831
- FormsModule, CmatColorPickerComponent, CdkConnectedOverlay, CdkOverlayOrigin,
832
- MatInputModule, ReactiveFormsModule, NgClass
833
- ], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<section>\r\n <mat-form-field class=\"w-full\">\r\n <mat-label>{{ label() }}</mat-label>\r\n <input matInput type=\"text\" [placeholder]=\"placeholder()\" [disabled]=\"disabled()\" [(ngModel)]=\"value\"\r\n (ngModelChange)=\"valueChanged.emit($event);colorChanged.emit($event);\" />\r\n <button #trigger=\"cdkOverlayOrigin\" matPrefix cdkOverlayOrigin class=\"ml-2\"\r\n [ngClass]=\"{'pointer-events-none':disabled()}\"\r\n [style.color]=\"value()\" (click)=\"toggleMenu()\">\r\n <span></span>\r\n </button>\r\n </mat-form-field>\r\n</section>\r\n\r\n<ng-template cdkConnectedOverlay [cdkConnectedOverlayOrigin]=\"trigger\" [cdkConnectedOverlayOpen]=\"isOpen()\"\r\n (overlayOutsideClick)=\"closeMenu()\" (detach)=\"closeMenu()\">\r\n <cmat-color-picker [format]=\"format()\" [hideAlpha]=\"hideAlpha()\" [disabled]=\"disabled()\" [(value)]=\"value\"\r\n (formatChanged)=\"formatChanged.emit($event)\" (valueChanged)=\"valueChanged.emit($event)\"\r\n (colorChanged)=\"colorChanged.emit($event)\" />\r\n</ng-template>", styles: ["cmat-color-picker-button{--cmat-prefix-label-offset: 20px}cmat-color-picker-button section{--outline-color: #b4b4b4;--hover-outline-color: var(--cmat-primary)}cmat-color-picker-button section:is(.dark *){--outline-color: #4d4d4d}cmat-color-picker-button section{display:flex;gap:8px}cmat-color-picker-button .input-group{display:flex;gap:8px}cmat-color-picker-button .input-group input{flex:1}cmat-color-picker-button button{display:inline-flex;width:32px;height:32px;padding:4px;background:none;border-radius:8px;border:1px solid var(--outline-color);cursor:pointer}cmat-color-picker-button button:after{content:\"\";display:inline-block;width:100%;height:100%;background-color:currentColor;border-radius:3px}cmat-color-picker-button button:hover,cmat-color-picker-button button:focus{border-color:var(--hover-outline-color)}cmat-color-picker-button input{padding:4px 8px;border-radius:8px;border:1px solid var(--outline-color);display:flex;flex:1 auto}cmat-color-picker-button input:hover,cmat-color-picker-button input:focus{border-color:var(--hover-outline-color)}\n"] }]
834
- }], propDecorators: { format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }, { type: i0.Output, args: ["formatChange"] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], hideAlpha: [{ type: i0.Input, args: [{ isSignal: true, alias: "hideAlpha", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], formatChanged: [{ type: i0.Output, args: ["formatChanged"] }], valueChanged: [{ type: i0.Output, args: ["valueChanged"] }], colorChanged: [{ type: i0.Output, args: ["colorChanged"] }] } });
835
-
836
- /**
837
- * Generated bundle index. Do not edit.
838
- */
839
-
781
+ var CmatColorInputFields = class CmatColorInputFields {
782
+ constructor() {
783
+ this.color = input.required(...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
784
+ this.format = model("hex", ...ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []);
785
+ this.hideAlpha = input(false, ...ngDevMode ? [{ debugName: "hideAlpha" }] : /* istanbul ignore next */ []);
786
+ this.formatChanged = output();
787
+ this.valueChange = output();
788
+ this.hsl = signal(null, ...ngDevMode ? [{ debugName: "hsl" }] : /* istanbul ignore next */ []);
789
+ this.rgb = signal(null, ...ngDevMode ? [{ debugName: "rgb" }] : /* istanbul ignore next */ []);
790
+ this.hex = signal("", ...ngDevMode ? [{ debugName: "hex" }] : /* istanbul ignore next */ []);
791
+ effect(() => {
792
+ const color = this.color();
793
+ this.hsl.set(color.hsl);
794
+ this.rgb.set(color.rgb);
795
+ this.hex.set(color.hex);
796
+ untracked(() => {
797
+ if (!this.format()) this.format.set("hex");
798
+ else if (this.format() === "hsv") this.format.set("hsl");
799
+ });
800
+ });
801
+ }
802
+ round(value) {
803
+ return Math.round(value);
804
+ }
805
+ toggleColorFormat() {
806
+ let format;
807
+ let fieldVal = {};
808
+ if (this.format() === "hex") {
809
+ format = "rgb";
810
+ fieldVal = { ...this.rgb() };
811
+ } else if (this.format() === "rgb") {
812
+ format = "hsl";
813
+ fieldVal = {
814
+ ...this.hsl(),
815
+ s: this.hsl().s * 100,
816
+ l: this.hsl().l * 100
817
+ };
818
+ } else if (this.format() === "hsl") {
819
+ format = "hex";
820
+ fieldVal = { hex: this.hex() };
821
+ }
822
+ this.format.set(format);
823
+ this.formatChanged.emit(format);
824
+ this.handleChange(fieldVal);
825
+ }
826
+ handleChange(e) {
827
+ if (typeof e === "string" || typeof e === "number") return;
828
+ if (e.hex) {
829
+ if (isValidHex(e.hex)) {
830
+ const color = new TinyColor(e.hex);
831
+ this.valueChange.emit({
832
+ hex: this.hideAlpha() ? color.toHex() : color.toHex8(),
833
+ source: "hex"
834
+ });
835
+ }
836
+ } else if (e.r || e.g || e.b) this.valueChange.emit({
837
+ r: e.r ?? this.rgb().r,
838
+ g: e.g ?? this.rgb().g,
839
+ b: e.b ?? this.rgb().b,
840
+ a: Math.round((e.a ?? this.rgb().a) * 100) / 100,
841
+ source: "rgb"
842
+ });
843
+ else if (e.h || e.s || e.l) {
844
+ const s = (typeof e.s === "string" ? Number(e.s.replace("%", "")) : e.s ?? 0) / 100;
845
+ const l = (typeof e.l === "string" ? Number(e.l.replace("%", "")) : e.l ?? 0) / 100;
846
+ this.valueChange.emit({
847
+ h: e.h ?? this.hsl().h,
848
+ s: s ?? this.hsl().s,
849
+ l: l ?? this.hsl().l,
850
+ a: Math.round((e.a ?? this.hsl().a) * 100) / 100,
851
+ source: "hsl"
852
+ });
853
+ } else if (e.a) {
854
+ let a = Math.max(0, Math.min(1, e.a));
855
+ if (this.hideAlpha()) a = 1;
856
+ this.valueChange.emit({
857
+ h: this.hsl().h,
858
+ s: this.hsl().s,
859
+ l: this.hsl().l,
860
+ a: Math.round(a * 100) / 100,
861
+ source: "rgb"
862
+ });
863
+ }
864
+ }
865
+ static {
866
+ this.ɵfac = i0.ɵɵngDeclareFactory({
867
+ minVersion: "12.0.0",
868
+ version: "22.2.3",
869
+ ngImport: i0,
870
+ type: CmatColorInputFields,
871
+ deps: [],
872
+ target: i0.ɵɵFactoryTarget.Component
873
+ });
874
+ }
875
+ static {
876
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
877
+ minVersion: "17.0.0",
878
+ version: "22.2.3",
879
+ type: CmatColorInputFields,
880
+ isStandalone: true,
881
+ selector: "cmat-color-input-fields",
882
+ inputs: {
883
+ color: {
884
+ classPropertyName: "color",
885
+ publicName: "color",
886
+ isSignal: true,
887
+ isRequired: true,
888
+ transformFunction: null
889
+ },
890
+ format: {
891
+ classPropertyName: "format",
892
+ publicName: "format",
893
+ isSignal: true,
894
+ isRequired: false,
895
+ transformFunction: null
896
+ },
897
+ hideAlpha: {
898
+ classPropertyName: "hideAlpha",
899
+ publicName: "hideAlpha",
900
+ isSignal: true,
901
+ isRequired: false,
902
+ transformFunction: null
903
+ }
904
+ },
905
+ outputs: {
906
+ format: "formatChange",
907
+ formatChanged: "formatChanged",
908
+ valueChange: "valueChange"
909
+ },
910
+ host: { classAttribute: "cmat-color-input-fields" },
911
+ ngImport: i0,
912
+ template: "<div class=\"cmat-color-input-field-wrapper\">\r\n @if (format() === 'hex') {\r\n <cmat-color-input-field label=\"hex\" [value]=\"hex()\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n @if (format() === 'rgb') {\r\n <cmat-color-input-field label=\"r\" [value]=\"rgb()!.r\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"g\" [value]=\"rgb()!.g\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"b\" [value]=\"rgb()!.b\" (valueChange)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-input-field label=\"a\" [step]=\"0.01\" [value]=\"rgb()!.a\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n }\r\n @if (format() === 'hsl') {\r\n <cmat-color-input-field label=\"h\" [value]=\"round(hsl()!.h)\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"s\" [value]=\"round(hsl()!.s * 100) + '%'\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"l\" [value]=\"round(hsl()!.l * 100) + '%'\" (valueChange)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-input-field label=\"a\" [step]=\"0.01\" [value]=\"hsl()!.a\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n }\r\n</div>\r\n\r\n<cmat-color-icon-button>\r\n <button type=\"button\" (click)=\"toggleColorFormat()\">\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z\" />\r\n </svg>\r\n </button>\r\n</cmat-color-icon-button>",
913
+ styles: [".cmat-color-input-fields{display:flex;align-items:center;gap:8px;width:100%}.cmat-color-input-field-wrapper{flex:1;display:flex;gap:8px}.cmat-color-input-field-wrapper .cmat-color-input-field{flex:1}\n"],
914
+ dependencies: [{
915
+ kind: "component",
916
+ type: CmatColorInputField,
917
+ selector: "cmat-color-input-field",
918
+ inputs: [
919
+ "label",
920
+ "step",
921
+ "placeholder",
922
+ "value"
923
+ ],
924
+ outputs: ["valueChange"]
925
+ }, {
926
+ kind: "component",
927
+ type: CmatColorIconButton,
928
+ selector: "cmat-color-icon-button"
929
+ }],
930
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
931
+ encapsulation: i0.ViewEncapsulation.None
932
+ });
933
+ }
934
+ };
935
+ i0.ɵɵngDeclareClassMetadata({
936
+ minVersion: "12.0.0",
937
+ version: "22.2.3",
938
+ ngImport: i0,
939
+ type: CmatColorInputFields,
940
+ decorators: [{
941
+ type: Component,
942
+ args: [{
943
+ selector: "cmat-color-input-fields",
944
+ imports: [CmatColorInputField, CmatColorIconButton],
945
+ host: { class: "cmat-color-input-fields" },
946
+ encapsulation: ViewEncapsulation.None,
947
+ changeDetection: ChangeDetectionStrategy.OnPush,
948
+ template: "<div class=\"cmat-color-input-field-wrapper\">\r\n @if (format() === 'hex') {\r\n <cmat-color-input-field label=\"hex\" [value]=\"hex()\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n @if (format() === 'rgb') {\r\n <cmat-color-input-field label=\"r\" [value]=\"rgb()!.r\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"g\" [value]=\"rgb()!.g\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"b\" [value]=\"rgb()!.b\" (valueChange)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-input-field label=\"a\" [step]=\"0.01\" [value]=\"rgb()!.a\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n }\r\n @if (format() === 'hsl') {\r\n <cmat-color-input-field label=\"h\" [value]=\"round(hsl()!.h)\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"s\" [value]=\"round(hsl()!.s * 100) + '%'\" (valueChange)=\"handleChange($event)\" />\r\n <cmat-color-input-field label=\"l\" [value]=\"round(hsl()!.l * 100) + '%'\" (valueChange)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-input-field label=\"a\" [step]=\"0.01\" [value]=\"hsl()!.a\" (valueChange)=\"handleChange($event)\" />\r\n }\r\n }\r\n</div>\r\n\r\n<cmat-color-icon-button>\r\n <button type=\"button\" (click)=\"toggleColorFormat()\">\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M12,18.17L8.83,15L7.42,16.41L12,21L16.59,16.41L15.17,15M12,5.83L15.17,9L16.58,7.59L12,3L7.41,7.59L8.83,9L12,5.83Z\" />\r\n </svg>\r\n </button>\r\n</cmat-color-icon-button>",
949
+ styles: [".cmat-color-input-fields{display:flex;align-items:center;gap:8px;width:100%}.cmat-color-input-field-wrapper{flex:1;display:flex;gap:8px}.cmat-color-input-field-wrapper .cmat-color-input-field{flex:1}\n"]
950
+ }]
951
+ }],
952
+ ctorParameters: () => [],
953
+ propDecorators: {
954
+ color: [{
955
+ type: i0.Input,
956
+ args: [{
957
+ isSignal: true,
958
+ alias: "color",
959
+ required: true
960
+ }]
961
+ }],
962
+ format: [{
963
+ type: i0.Input,
964
+ args: [{
965
+ isSignal: true,
966
+ alias: "format",
967
+ required: false
968
+ }]
969
+ }, {
970
+ type: i0.Output,
971
+ args: ["formatChange"]
972
+ }],
973
+ hideAlpha: [{
974
+ type: i0.Input,
975
+ args: [{
976
+ isSignal: true,
977
+ alias: "hideAlpha",
978
+ required: false
979
+ }]
980
+ }],
981
+ formatChanged: [{
982
+ type: i0.Output,
983
+ args: ["formatChanged"]
984
+ }],
985
+ valueChange: [{
986
+ type: i0.Output,
987
+ args: ["valueChange"]
988
+ }]
989
+ }
990
+ });
991
+ var CmatColorSaturationPicker = class CmatColorSaturationPicker {
992
+ constructor() {
993
+ this.color = input.required(...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
994
+ this.change = output();
995
+ this.hsl = signal(null, ...ngDevMode ? [{ debugName: "hsl" }] : /* istanbul ignore next */ []);
996
+ this.hsv = signal(null, ...ngDevMode ? [{ debugName: "hsv" }] : /* istanbul ignore next */ []);
997
+ this.bgColor = signal("", ...ngDevMode ? [{ debugName: "bgColor" }] : /* istanbul ignore next */ []);
998
+ this.posX = signal(0, ...ngDevMode ? [{ debugName: "posX" }] : /* istanbul ignore next */ []);
999
+ this.posY = signal(0, ...ngDevMode ? [{ debugName: "posY" }] : /* istanbul ignore next */ []);
1000
+ this._el = inject(ElementRef);
1001
+ effect(() => {
1002
+ const color = this.color();
1003
+ this.hsl.set(color.hsl);
1004
+ this.hsv.set(color.hsv);
1005
+ untracked(() => {
1006
+ if (this.hsl()) this.bgColor.set(`hsl(${this.hsl().h}, 100%, 50%)`);
1007
+ if (this.hsv()) {
1008
+ this.posX.set(this.hsv().s * 100);
1009
+ this.posY.set(100 - this.hsv().v * 100);
1010
+ }
1011
+ });
1012
+ });
1013
+ }
1014
+ handleChange(e) {
1015
+ const { top, left, containerHeight, containerWidth } = e;
1016
+ const s = Math.max(0, Math.min(left, containerWidth)) / containerWidth;
1017
+ const v = 1 - Math.max(0, Math.min(top, containerHeight)) / containerHeight;
1018
+ const hsv = this.hsv();
1019
+ if (hsv) this.change.emit({
1020
+ ...hsv,
1021
+ s,
1022
+ v,
1023
+ source: "hsva"
1024
+ });
1025
+ }
1026
+ onScroll() {
1027
+ const el = this._el.nativeElement;
1028
+ if (el.scrollTop !== 0 || el.scrollLeft !== 0) {
1029
+ el.scrollTop = 0;
1030
+ el.scrollLeft = 0;
1031
+ }
1032
+ }
1033
+ static {
1034
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1035
+ minVersion: "12.0.0",
1036
+ version: "22.2.3",
1037
+ ngImport: i0,
1038
+ type: CmatColorSaturationPicker,
1039
+ deps: [],
1040
+ target: i0.ɵɵFactoryTarget.Component
1041
+ });
1042
+ }
1043
+ static {
1044
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1045
+ minVersion: "17.1.0",
1046
+ version: "22.2.3",
1047
+ type: CmatColorSaturationPicker,
1048
+ isStandalone: true,
1049
+ selector: "cmat-color-saturation-picker",
1050
+ inputs: { color: {
1051
+ classPropertyName: "color",
1052
+ publicName: "color",
1053
+ isSignal: true,
1054
+ isRequired: true,
1055
+ transformFunction: null
1056
+ } },
1057
+ outputs: { change: "change" },
1058
+ host: {
1059
+ listeners: { "scroll": "onScroll()" },
1060
+ classAttribute: "cmat-color-saturation-picker"
1061
+ },
1062
+ ngImport: i0,
1063
+ template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-saturation-picker-content\" cmatColorCoordinates [percentX]=\"posX()\" [percentY]=\"posY()\"\r\n [style.background-color]=\"bgColor()\" (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-saturation-picker-pointer\"\r\n [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-saturation-picker-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>",
1064
+ styles: [".cmat-color-saturation-picker{position:relative;display:block;width:100%;padding-bottom:55%;border-radius:var(--cp-saturation-picker-shape, 4px);overflow:hidden;box-shadow:0 0 0 1px #ffffff1f,0 0 0 1px #0000001f}.cmat-color-saturation-picker-content{position:absolute;inset:0;touch-action:none;background-image:linear-gradient(to top,#000,#0000),linear-gradient(to right,#fff,#fff0)}.cmat-color-saturation-picker-pointer{position:absolute}.cmat-color-saturation-picker-thumb{display:block;width:var(--cp-saturation-picker-thumb-size, 12px);height:var(--cp-saturation-picker-thumb-size, 12px);padding:0;border-radius:var(--cp-saturation-picker-thumb-shape, 6px);border:none;background:none;outline:1px solid var(--cp-saturation-picker-thumb-outline-color, #fff);outline-offset:-1px;transform:translate(-50%,-50%);box-shadow:var(--cp-saturation-picker-thumb-shadow, 0 2px 6px 0 rgba(0, 0, 0, .32))}.cmat-color-saturation-picker-thumb:focus-visible{outline-color:var(--cp-saturation-picker-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}\n"],
1065
+ dependencies: [{
1066
+ kind: "directive",
1067
+ type: CmatColorCoordinates,
1068
+ selector: "[cmat-color-coordinates], [cmatColorCoordinates]",
1069
+ inputs: ["percentX", "percentY"],
1070
+ outputs: ["coordinatesChange"]
1071
+ }],
1072
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
1073
+ encapsulation: i0.ViewEncapsulation.None
1074
+ });
1075
+ }
1076
+ };
1077
+ i0.ɵɵngDeclareClassMetadata({
1078
+ minVersion: "12.0.0",
1079
+ version: "22.2.3",
1080
+ ngImport: i0,
1081
+ type: CmatColorSaturationPicker,
1082
+ decorators: [{
1083
+ type: Component,
1084
+ args: [{
1085
+ selector: "cmat-color-saturation-picker",
1086
+ imports: [CmatColorCoordinates],
1087
+ host: {
1088
+ "class": "cmat-color-saturation-picker",
1089
+ "(scroll)": "onScroll()"
1090
+ },
1091
+ encapsulation: ViewEncapsulation.None,
1092
+ changeDetection: ChangeDetectionStrategy.OnPush,
1093
+ template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<div class=\"cmat-color-saturation-picker-content\" cmatColorCoordinates [percentX]=\"posX()\" [percentY]=\"posY()\"\r\n [style.background-color]=\"bgColor()\" (coordinatesChange)=\"handleChange($event)\">\r\n <div class=\"cmat-color-saturation-picker-pointer\"\r\n [style.left.%]=\"posX()\" [style.top.%]=\"posY()\">\r\n <button class=\"cmat-color-saturation-picker-thumb\" type=\"button\">\r\n <!-- -->\r\n </button>\r\n </div>\r\n</div>",
1094
+ styles: [".cmat-color-saturation-picker{position:relative;display:block;width:100%;padding-bottom:55%;border-radius:var(--cp-saturation-picker-shape, 4px);overflow:hidden;box-shadow:0 0 0 1px #ffffff1f,0 0 0 1px #0000001f}.cmat-color-saturation-picker-content{position:absolute;inset:0;touch-action:none;background-image:linear-gradient(to top,#000,#0000),linear-gradient(to right,#fff,#fff0)}.cmat-color-saturation-picker-pointer{position:absolute}.cmat-color-saturation-picker-thumb{display:block;width:var(--cp-saturation-picker-thumb-size, 12px);height:var(--cp-saturation-picker-thumb-size, 12px);padding:0;border-radius:var(--cp-saturation-picker-thumb-shape, 6px);border:none;background:none;outline:1px solid var(--cp-saturation-picker-thumb-outline-color, #fff);outline-offset:-1px;transform:translate(-50%,-50%);box-shadow:var(--cp-saturation-picker-thumb-shadow, 0 2px 6px 0 rgba(0, 0, 0, .32))}.cmat-color-saturation-picker-thumb:focus-visible{outline-color:var(--cp-saturation-picker-thumb-focus-outline-color, var(--cp-input-focus-outline-color, #0d99ff))}\n"]
1095
+ }]
1096
+ }],
1097
+ ctorParameters: () => [],
1098
+ propDecorators: {
1099
+ color: [{
1100
+ type: i0.Input,
1101
+ args: [{
1102
+ isSignal: true,
1103
+ alias: "color",
1104
+ required: true
1105
+ }]
1106
+ }],
1107
+ change: [{
1108
+ type: i0.Output,
1109
+ args: ["change"]
1110
+ }]
1111
+ }
1112
+ });
1113
+ var CmatColorPickerComponent = class CmatColorPickerComponent {
1114
+ constructor() {
1115
+ this.format = model("hex", ...ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []);
1116
+ this.value = model("#000", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
1117
+ this.hideAlpha = input(false, ...ngDevMode ? [{ debugName: "hideAlpha" }] : /* istanbul ignore next */ []);
1118
+ this.disabled = model(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
1119
+ this.formatChanged = output();
1120
+ this.valueChanged = output();
1121
+ this.colorChanged = output();
1122
+ this.parsedColor = signal(null, ...ngDevMode ? [{ debugName: "parsedColor" }] : /* istanbul ignore next */ []);
1123
+ this.isCopied = signal(false, ...ngDevMode ? [{ debugName: "isCopied" }] : /* istanbul ignore next */ []);
1124
+ this.EyeDropper = window.EyeDropper;
1125
+ this.supportEyeDropper = !!this.EyeDropper;
1126
+ this._oldHue = signal(0, ...ngDevMode ? [{ debugName: "_oldHue" }] : /* istanbul ignore next */ []);
1127
+ this._oldValue = signal("", ...ngDevMode ? [{ debugName: "_oldValue" }] : /* istanbul ignore next */ []);
1128
+ this.onChange = () => {};
1129
+ this.onTouched = () => {};
1130
+ effect(() => {
1131
+ this.format();
1132
+ untracked(() => {
1133
+ this.getColorFormat();
1134
+ });
1135
+ });
1136
+ effect(() => {
1137
+ const value = this.value();
1138
+ untracked(() => {
1139
+ if (value !== this._oldValue()) this.getParsedColor(this.value(), this._oldHue());
1140
+ });
1141
+ });
1142
+ }
1143
+ ngOnInit() {
1144
+ this.getParsedColor(this.value());
1145
+ }
1146
+ writeValue(value) {
1147
+ if (value) {
1148
+ this.value.set(value);
1149
+ this.getColorFormat();
1150
+ this.getParsedColor(value, this._oldHue());
1151
+ }
1152
+ }
1153
+ registerOnChange(fn) {
1154
+ this.onChange = fn;
1155
+ }
1156
+ registerOnTouched(fn) {
1157
+ this.onTouched = fn;
1158
+ }
1159
+ setDisabledState(isDisabled) {
1160
+ this.disabled.set(isDisabled);
1161
+ }
1162
+ getParsedColor(data, oldHue = 0) {
1163
+ this.parsedColor.set(parseColor(data, oldHue, this.hideAlpha()));
1164
+ this._oldHue.set(this.parsedColor().oldHue);
1165
+ }
1166
+ handleChange(e) {
1167
+ if (simpleCheckForValidColor(e)) {
1168
+ this.getParsedColor(e, e.h || this._oldHue());
1169
+ this.getColorString(this.parsedColor());
1170
+ this.onChange(this.value());
1171
+ this.valueChanged.emit(this.value());
1172
+ this.colorChanged.emit({
1173
+ value: this.value(),
1174
+ color: this.parsedColor()
1175
+ });
1176
+ }
1177
+ }
1178
+ getColorFormat() {
1179
+ if (!this.format()) {
1180
+ const color = new TinyColor(this.value());
1181
+ if (color.format === "rgb" || color.format === "hsl" || color.format === "hsv") this.format.set(color.format);
1182
+ else this.format.set("hex");
1183
+ }
1184
+ }
1185
+ getColorString(color) {
1186
+ switch (this.format()) {
1187
+ case "rgb":
1188
+ this.value.set(color.rgbString);
1189
+ break;
1190
+ case "hsl":
1191
+ this.value.set(color.hslString);
1192
+ break;
1193
+ case "hsv":
1194
+ this.value.set(color.hsvString);
1195
+ break;
1196
+ default: this.value.set(color.hex);
1197
+ }
1198
+ this._oldValue.set(this.value());
1199
+ }
1200
+ handleFormatChange() {
1201
+ this.formatChanged.emit(this.format());
1202
+ }
1203
+ async openEyeDropper(e) {
1204
+ const eyeDropper = new this.EyeDropper();
1205
+ try {
1206
+ const result = await eyeDropper.open();
1207
+ this.handleChange({
1208
+ hex: result.sRGBHex,
1209
+ source: "rgb"
1210
+ });
1211
+ e.preventDefault();
1212
+ } catch (err) {
1213
+ console.warn(err);
1214
+ }
1215
+ }
1216
+ async copyColor() {
1217
+ try {
1218
+ await navigator.clipboard.writeText(this.value());
1219
+ this.isCopied.set(true);
1220
+ setTimeout(() => {
1221
+ this.isCopied.set(false);
1222
+ }, 1e3);
1223
+ } catch (err) {
1224
+ console.warn(err);
1225
+ }
1226
+ }
1227
+ static {
1228
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1229
+ minVersion: "12.0.0",
1230
+ version: "22.2.3",
1231
+ ngImport: i0,
1232
+ type: CmatColorPickerComponent,
1233
+ deps: [],
1234
+ target: i0.ɵɵFactoryTarget.Component
1235
+ });
1236
+ }
1237
+ static {
1238
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1239
+ minVersion: "17.0.0",
1240
+ version: "22.2.3",
1241
+ type: CmatColorPickerComponent,
1242
+ isStandalone: true,
1243
+ selector: "cmat-color-picker",
1244
+ inputs: {
1245
+ format: {
1246
+ classPropertyName: "format",
1247
+ publicName: "format",
1248
+ isSignal: true,
1249
+ isRequired: false,
1250
+ transformFunction: null
1251
+ },
1252
+ value: {
1253
+ classPropertyName: "value",
1254
+ publicName: "value",
1255
+ isSignal: true,
1256
+ isRequired: false,
1257
+ transformFunction: null
1258
+ },
1259
+ hideAlpha: {
1260
+ classPropertyName: "hideAlpha",
1261
+ publicName: "hideAlpha",
1262
+ isSignal: true,
1263
+ isRequired: false,
1264
+ transformFunction: null
1265
+ },
1266
+ disabled: {
1267
+ classPropertyName: "disabled",
1268
+ publicName: "disabled",
1269
+ isSignal: true,
1270
+ isRequired: false,
1271
+ transformFunction: null
1272
+ }
1273
+ },
1274
+ outputs: {
1275
+ format: "formatChange",
1276
+ value: "valueChange",
1277
+ disabled: "disabledChange",
1278
+ formatChanged: "formatChanged",
1279
+ valueChanged: "valueChanged",
1280
+ colorChanged: "colorChanged"
1281
+ },
1282
+ host: { classAttribute: "cmat-color-picker" },
1283
+ providers: [{
1284
+ provide: NG_VALUE_ACCESSOR,
1285
+ useExisting: forwardRef(() => CmatColorPickerComponent),
1286
+ multi: true
1287
+ }],
1288
+ ngImport: i0,
1289
+ template: "<cmat-color-saturation-picker [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n\r\n<div class=\"cmat-color-picker-controls\">\r\n @if (supportEyeDropper) {\r\n <cmat-color-icon-button>\r\n <button type=\"button\" (click)=\"openEyeDropper($event)\">\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M19.35,11.72L17.22,13.85L15.81,12.43L8.1,20.14L3.5,22L2,20.5L3.86,15.9L11.57,8.19L10.15,6.78L12.28,4.65L19.35,11.72M16.76,3C17.93,1.83 19.83,1.83 21,3C22.17,4.17 22.17,6.07 21,7.24L19.08,9.16L14.84,4.92L16.76,3M5.56,17.03L4.5,19.5L6.97,18.44L14.4,11L13,9.6L5.56,17.03Z\" />\r\n </svg>\r\n </button>\r\n </cmat-color-icon-button>\r\n }\r\n\r\n <button class=\"cmat-color-preview\" type=\"button\" (click)=\"copyColor()\">\r\n <div class=\"cmat-color-preview-bg\" [ngStyle]=\"{'background-color':value()}\"></div>\r\n <div class=\"cmat-color-preview-backdrop\">\r\n @if (this.isCopied()) {\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\" d=\"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z\" />\r\n </svg>\r\n } @else {\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z\" />\r\n </svg>\r\n }\r\n </div>\r\n </button>\r\n\r\n <div class=\"cmat-color-hue-alpha\">\r\n <cmat-color-hue-slider [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-alpha-slider [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n }\r\n </div>\r\n</div>\r\n\r\n<div class=\"cmat-color-picker-controls\">\r\n <cmat-color-input-fields [color]=\"parsedColor()!\" [hideAlpha]=\"hideAlpha()\" [(format)]=\"format\"\r\n (valueChange)=\"handleChange($event)\" (formatChange)=\"handleFormatChange()\" />\r\n</div>",
1290
+ styles: [".cmat-color-picker{--cp-container-text-color: rgba(0, 0, 0, .9);--cp-container-background-color: #fff;--cp-input-outline-color: #e6e6e6;--cp-input-hover-outline-color: #d6d6d6;--cp-input-focus-outline-color: #0d99ff;--cp-icon-button-hover-background-color: rgba(0, 0, 0, .06);--cp-icon-button-active-background-color: rgba(0, 0, 0, .12);--cp-slider-thumb-background-color: #f2f2f2;--cp-slider-thumb-outline-color: rgba(0, 0, 0, .04)}.cmat-color-picker:is(.dark *){--cp-container-text-color: #fff;--cp-container-background-color: #2c2c2c;--cp-input-outline-color: #444;--cp-input-hover-outline-color: #545454;--cp-input-focus-outline-color: #0c8ce9;--cp-icon-button-hover-background-color: rgba(255, 255, 255, .06);--cp-icon-button-active-background-color: rgba(255, 255, 255, .12);--cp-slider-thumb-background-color: #3c3c3c;--cp-slider-thumb-outline-color: rgba(255, 255, 255, .24)}.cmat-color-picker{box-sizing:border-box;display:block;width:var(--cp-container-width, 240px);padding:var(--cp-container-padding, 12px);margin:var(--cp-container-margin, 0);color:var(--cp-container-text-color);background-color:var(--cp-container-background-color);border-radius:var(--cp-container-shape, 8px);box-shadow:var(--cp-container-elevation-shadow, inset 0 0 1px 0 rgba(255, 255, 255, .64), 0 2px 4px 0 rgba(0, 0, 0, .16), 0 8px 16px 0 rgba(0, 0, 0, .12), 0 0 1px 0 rgba(0, 0, 0, .12))}.cmat-color-picker-controls{display:flex;align-items:center;gap:10px;margin-top:16px}.cmat-color-preview{width:32px;height:32px;border-radius:16px;position:relative;overflow:hidden;border:none;outline:none;background-color:#fff;background-image:conic-gradient(transparent 25%,#ccc 25% 50%,transparent 50% 75%,#ccc 75%);background-size:10px 10px;box-shadow:0 0 0 1px #ffffff1f,0 0 0 1px #0000001f;cursor:pointer}.cmat-color-preview:hover .cmat-color-preview-backdrop,.cmat-color-preview:focus-visible .cmat-color-preview-backdrop{opacity:1}.cmat-color-preview-bg{position:absolute;inset:0}.cmat-color-preview-backdrop{position:absolute;inset:0;padding:6px;background-color:#00000052;color:#fff;opacity:0;pointer-events:none}.cmat-color-hue-alpha{flex:1;display:flex;flex-direction:column;gap:8px}\n"],
1291
+ dependencies: [
1292
+ {
1293
+ kind: "component",
1294
+ type: CmatColorSaturationPicker,
1295
+ selector: "cmat-color-saturation-picker",
1296
+ inputs: ["color"],
1297
+ outputs: ["change"]
1298
+ },
1299
+ {
1300
+ kind: "component",
1301
+ type: CmatColorHueSlider,
1302
+ selector: "cmat-color-hue-slider",
1303
+ inputs: ["color", "direction"],
1304
+ outputs: ["change"]
1305
+ },
1306
+ {
1307
+ kind: "component",
1308
+ type: CmatColorAlphaSlider,
1309
+ selector: "cmat-color-alpha-slider",
1310
+ inputs: ["color", "direction"],
1311
+ outputs: ["change"]
1312
+ },
1313
+ {
1314
+ kind: "component",
1315
+ type: CmatColorInputFields,
1316
+ selector: "cmat-color-input-fields",
1317
+ inputs: [
1318
+ "color",
1319
+ "format",
1320
+ "hideAlpha"
1321
+ ],
1322
+ outputs: [
1323
+ "formatChange",
1324
+ "formatChanged",
1325
+ "valueChange"
1326
+ ]
1327
+ },
1328
+ {
1329
+ kind: "component",
1330
+ type: CmatColorIconButton,
1331
+ selector: "cmat-color-icon-button"
1332
+ },
1333
+ {
1334
+ kind: "directive",
1335
+ type: NgStyle,
1336
+ selector: "[ngStyle]",
1337
+ inputs: ["ngStyle"]
1338
+ }
1339
+ ],
1340
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
1341
+ encapsulation: i0.ViewEncapsulation.None
1342
+ });
1343
+ }
1344
+ };
1345
+ i0.ɵɵngDeclareClassMetadata({
1346
+ minVersion: "12.0.0",
1347
+ version: "22.2.3",
1348
+ ngImport: i0,
1349
+ type: CmatColorPickerComponent,
1350
+ decorators: [{
1351
+ type: Component,
1352
+ args: [{
1353
+ selector: "cmat-color-picker",
1354
+ imports: [
1355
+ CmatColorSaturationPicker,
1356
+ CmatColorHueSlider,
1357
+ CmatColorAlphaSlider,
1358
+ CmatColorInputFields,
1359
+ CmatColorIconButton,
1360
+ NgStyle
1361
+ ],
1362
+ host: { class: "cmat-color-picker" },
1363
+ encapsulation: ViewEncapsulation.None,
1364
+ changeDetection: ChangeDetectionStrategy.OnPush,
1365
+ providers: [{
1366
+ provide: NG_VALUE_ACCESSOR,
1367
+ useExisting: forwardRef(() => CmatColorPickerComponent),
1368
+ multi: true
1369
+ }],
1370
+ template: "<cmat-color-saturation-picker [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n\r\n<div class=\"cmat-color-picker-controls\">\r\n @if (supportEyeDropper) {\r\n <cmat-color-icon-button>\r\n <button type=\"button\" (click)=\"openEyeDropper($event)\">\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M19.35,11.72L17.22,13.85L15.81,12.43L8.1,20.14L3.5,22L2,20.5L3.86,15.9L11.57,8.19L10.15,6.78L12.28,4.65L19.35,11.72M16.76,3C17.93,1.83 19.83,1.83 21,3C22.17,4.17 22.17,6.07 21,7.24L19.08,9.16L14.84,4.92L16.76,3M5.56,17.03L4.5,19.5L6.97,18.44L14.4,11L13,9.6L5.56,17.03Z\" />\r\n </svg>\r\n </button>\r\n </cmat-color-icon-button>\r\n }\r\n\r\n <button class=\"cmat-color-preview\" type=\"button\" (click)=\"copyColor()\">\r\n <div class=\"cmat-color-preview-bg\" [ngStyle]=\"{'background-color':value()}\"></div>\r\n <div class=\"cmat-color-preview-backdrop\">\r\n @if (this.isCopied()) {\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\" d=\"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z\" />\r\n </svg>\r\n } @else {\r\n <svg viewBox=\"0 0 24 24\">\r\n <path fill=\"currentColor\"\r\n d=\"M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z\" />\r\n </svg>\r\n }\r\n </div>\r\n </button>\r\n\r\n <div class=\"cmat-color-hue-alpha\">\r\n <cmat-color-hue-slider [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n\r\n @if (!hideAlpha()) {\r\n <cmat-color-alpha-slider [color]=\"parsedColor()!\" (change)=\"handleChange($event)\" />\r\n }\r\n </div>\r\n</div>\r\n\r\n<div class=\"cmat-color-picker-controls\">\r\n <cmat-color-input-fields [color]=\"parsedColor()!\" [hideAlpha]=\"hideAlpha()\" [(format)]=\"format\"\r\n (valueChange)=\"handleChange($event)\" (formatChange)=\"handleFormatChange()\" />\r\n</div>",
1371
+ styles: [".cmat-color-picker{--cp-container-text-color: rgba(0, 0, 0, .9);--cp-container-background-color: #fff;--cp-input-outline-color: #e6e6e6;--cp-input-hover-outline-color: #d6d6d6;--cp-input-focus-outline-color: #0d99ff;--cp-icon-button-hover-background-color: rgba(0, 0, 0, .06);--cp-icon-button-active-background-color: rgba(0, 0, 0, .12);--cp-slider-thumb-background-color: #f2f2f2;--cp-slider-thumb-outline-color: rgba(0, 0, 0, .04)}.cmat-color-picker:is(.dark *){--cp-container-text-color: #fff;--cp-container-background-color: #2c2c2c;--cp-input-outline-color: #444;--cp-input-hover-outline-color: #545454;--cp-input-focus-outline-color: #0c8ce9;--cp-icon-button-hover-background-color: rgba(255, 255, 255, .06);--cp-icon-button-active-background-color: rgba(255, 255, 255, .12);--cp-slider-thumb-background-color: #3c3c3c;--cp-slider-thumb-outline-color: rgba(255, 255, 255, .24)}.cmat-color-picker{box-sizing:border-box;display:block;width:var(--cp-container-width, 240px);padding:var(--cp-container-padding, 12px);margin:var(--cp-container-margin, 0);color:var(--cp-container-text-color);background-color:var(--cp-container-background-color);border-radius:var(--cp-container-shape, 8px);box-shadow:var(--cp-container-elevation-shadow, inset 0 0 1px 0 rgba(255, 255, 255, .64), 0 2px 4px 0 rgba(0, 0, 0, .16), 0 8px 16px 0 rgba(0, 0, 0, .12), 0 0 1px 0 rgba(0, 0, 0, .12))}.cmat-color-picker-controls{display:flex;align-items:center;gap:10px;margin-top:16px}.cmat-color-preview{width:32px;height:32px;border-radius:16px;position:relative;overflow:hidden;border:none;outline:none;background-color:#fff;background-image:conic-gradient(transparent 25%,#ccc 25% 50%,transparent 50% 75%,#ccc 75%);background-size:10px 10px;box-shadow:0 0 0 1px #ffffff1f,0 0 0 1px #0000001f;cursor:pointer}.cmat-color-preview:hover .cmat-color-preview-backdrop,.cmat-color-preview:focus-visible .cmat-color-preview-backdrop{opacity:1}.cmat-color-preview-bg{position:absolute;inset:0}.cmat-color-preview-backdrop{position:absolute;inset:0;padding:6px;background-color:#00000052;color:#fff;opacity:0;pointer-events:none}.cmat-color-hue-alpha{flex:1;display:flex;flex-direction:column;gap:8px}\n"]
1372
+ }]
1373
+ }],
1374
+ ctorParameters: () => [],
1375
+ propDecorators: {
1376
+ format: [{
1377
+ type: i0.Input,
1378
+ args: [{
1379
+ isSignal: true,
1380
+ alias: "format",
1381
+ required: false
1382
+ }]
1383
+ }, {
1384
+ type: i0.Output,
1385
+ args: ["formatChange"]
1386
+ }],
1387
+ value: [{
1388
+ type: i0.Input,
1389
+ args: [{
1390
+ isSignal: true,
1391
+ alias: "value",
1392
+ required: false
1393
+ }]
1394
+ }, {
1395
+ type: i0.Output,
1396
+ args: ["valueChange"]
1397
+ }],
1398
+ hideAlpha: [{
1399
+ type: i0.Input,
1400
+ args: [{
1401
+ isSignal: true,
1402
+ alias: "hideAlpha",
1403
+ required: false
1404
+ }]
1405
+ }],
1406
+ disabled: [{
1407
+ type: i0.Input,
1408
+ args: [{
1409
+ isSignal: true,
1410
+ alias: "disabled",
1411
+ required: false
1412
+ }]
1413
+ }, {
1414
+ type: i0.Output,
1415
+ args: ["disabledChange"]
1416
+ }],
1417
+ formatChanged: [{
1418
+ type: i0.Output,
1419
+ args: ["formatChanged"]
1420
+ }],
1421
+ valueChanged: [{
1422
+ type: i0.Output,
1423
+ args: ["valueChanged"]
1424
+ }],
1425
+ colorChanged: [{
1426
+ type: i0.Output,
1427
+ args: ["colorChanged"]
1428
+ }]
1429
+ }
1430
+ });
1431
+ var CmatColorPickerButtonComponent = class CmatColorPickerButtonComponent {
1432
+ constructor() {
1433
+ this.format = model("hex", ...ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []);
1434
+ this.value = model("#000", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
1435
+ this.hideAlpha = input(false, ...ngDevMode ? [{ debugName: "hideAlpha" }] : /* istanbul ignore next */ []);
1436
+ this.disabled = model(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
1437
+ this.placeholder = input("请输入", ...ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []);
1438
+ this.label = input("颜色", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
1439
+ this.formatChanged = output();
1440
+ this.valueChanged = output();
1441
+ this.colorChanged = output();
1442
+ this.isOpen = signal(false, ...ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []);
1443
+ }
1444
+ toggleMenu() {
1445
+ this.isOpen.update((v) => !v);
1446
+ }
1447
+ closeMenu() {
1448
+ this.isOpen.set(false);
1449
+ }
1450
+ static {
1451
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1452
+ minVersion: "12.0.0",
1453
+ version: "22.2.3",
1454
+ ngImport: i0,
1455
+ type: CmatColorPickerButtonComponent,
1456
+ deps: [],
1457
+ target: i0.ɵɵFactoryTarget.Component
1458
+ });
1459
+ }
1460
+ static {
1461
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1462
+ minVersion: "17.1.0",
1463
+ version: "22.2.3",
1464
+ type: CmatColorPickerButtonComponent,
1465
+ isStandalone: true,
1466
+ selector: "cmat-color-picker-button",
1467
+ inputs: {
1468
+ format: {
1469
+ classPropertyName: "format",
1470
+ publicName: "format",
1471
+ isSignal: true,
1472
+ isRequired: false,
1473
+ transformFunction: null
1474
+ },
1475
+ value: {
1476
+ classPropertyName: "value",
1477
+ publicName: "value",
1478
+ isSignal: true,
1479
+ isRequired: false,
1480
+ transformFunction: null
1481
+ },
1482
+ hideAlpha: {
1483
+ classPropertyName: "hideAlpha",
1484
+ publicName: "hideAlpha",
1485
+ isSignal: true,
1486
+ isRequired: false,
1487
+ transformFunction: null
1488
+ },
1489
+ disabled: {
1490
+ classPropertyName: "disabled",
1491
+ publicName: "disabled",
1492
+ isSignal: true,
1493
+ isRequired: false,
1494
+ transformFunction: null
1495
+ },
1496
+ placeholder: {
1497
+ classPropertyName: "placeholder",
1498
+ publicName: "placeholder",
1499
+ isSignal: true,
1500
+ isRequired: false,
1501
+ transformFunction: null
1502
+ },
1503
+ label: {
1504
+ classPropertyName: "label",
1505
+ publicName: "label",
1506
+ isSignal: true,
1507
+ isRequired: false,
1508
+ transformFunction: null
1509
+ }
1510
+ },
1511
+ outputs: {
1512
+ format: "formatChange",
1513
+ value: "valueChange",
1514
+ disabled: "disabledChange",
1515
+ formatChanged: "formatChanged",
1516
+ valueChanged: "valueChanged",
1517
+ colorChanged: "colorChanged"
1518
+ },
1519
+ ngImport: i0,
1520
+ template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<section>\r\n <mat-form-field class=\"w-full\">\r\n <mat-label>{{ label() }}</mat-label>\r\n <input matInput type=\"text\" [placeholder]=\"placeholder()\" [disabled]=\"disabled()\" [(ngModel)]=\"value\"\r\n (ngModelChange)=\"valueChanged.emit($event);colorChanged.emit($event);\" />\r\n <button #trigger=\"cdkOverlayOrigin\" matPrefix cdkOverlayOrigin class=\"ml-2\"\r\n [ngClass]=\"{'pointer-events-none':disabled()}\"\r\n [style.color]=\"value()\" (click)=\"toggleMenu()\">\r\n <span></span>\r\n </button>\r\n </mat-form-field>\r\n</section>\r\n\r\n<ng-template cdkConnectedOverlay [cdkConnectedOverlayOrigin]=\"trigger\" [cdkConnectedOverlayOpen]=\"isOpen()\"\r\n (overlayOutsideClick)=\"closeMenu()\" (detach)=\"closeMenu()\">\r\n <cmat-color-picker [format]=\"format()\" [hideAlpha]=\"hideAlpha()\" [disabled]=\"disabled()\" [(value)]=\"value\"\r\n (formatChanged)=\"formatChanged.emit($event)\" (valueChanged)=\"valueChanged.emit($event)\"\r\n (colorChanged)=\"colorChanged.emit($event)\" />\r\n</ng-template>",
1521
+ styles: ["cmat-color-picker-button{--cmat-prefix-label-offset: 20px}cmat-color-picker-button section{--outline-color: #b4b4b4;--hover-outline-color: var(--cmat-primary)}cmat-color-picker-button section:is(.dark *){--outline-color: #4d4d4d}cmat-color-picker-button section{display:flex;gap:8px}cmat-color-picker-button .input-group{display:flex;gap:8px}cmat-color-picker-button .input-group input{flex:1}cmat-color-picker-button button{display:inline-flex;width:32px;height:32px;padding:4px;background:none;border-radius:8px;border:1px solid var(--outline-color);cursor:pointer}cmat-color-picker-button button:after{content:\"\";display:inline-block;width:100%;height:100%;background-color:currentColor;border-radius:3px}cmat-color-picker-button button:hover,cmat-color-picker-button button:focus{border-color:var(--hover-outline-color)}cmat-color-picker-button input{padding:4px 8px;border-radius:8px;border:1px solid var(--outline-color);display:flex;flex:1 auto}cmat-color-picker-button input:hover,cmat-color-picker-button input:focus{border-color:var(--hover-outline-color)}\n"],
1522
+ dependencies: [
1523
+ {
1524
+ kind: "ngmodule",
1525
+ type: FormsModule
1526
+ },
1527
+ {
1528
+ kind: "directive",
1529
+ type: i1.DefaultValueAccessor,
1530
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
1531
+ },
1532
+ {
1533
+ kind: "directive",
1534
+ type: i1.NgControlStatus,
1535
+ selector: "[formControlName],[ngModel],[formControl]"
1536
+ },
1537
+ {
1538
+ kind: "directive",
1539
+ type: i1.NgModel,
1540
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
1541
+ inputs: [
1542
+ "name",
1543
+ "disabled",
1544
+ "ngModel",
1545
+ "ngModelOptions"
1546
+ ],
1547
+ outputs: ["ngModelChange"],
1548
+ exportAs: ["ngModel"]
1549
+ },
1550
+ {
1551
+ kind: "component",
1552
+ type: CmatColorPickerComponent,
1553
+ selector: "cmat-color-picker",
1554
+ inputs: [
1555
+ "format",
1556
+ "value",
1557
+ "hideAlpha",
1558
+ "disabled"
1559
+ ],
1560
+ outputs: [
1561
+ "formatChange",
1562
+ "valueChange",
1563
+ "disabledChange",
1564
+ "formatChanged",
1565
+ "valueChanged",
1566
+ "colorChanged"
1567
+ ]
1568
+ },
1569
+ {
1570
+ kind: "directive",
1571
+ type: CdkConnectedOverlay,
1572
+ selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]",
1573
+ inputs: [
1574
+ "cdkConnectedOverlayOrigin",
1575
+ "cdkConnectedOverlayPositions",
1576
+ "cdkConnectedOverlayPositionStrategy",
1577
+ "cdkConnectedOverlayOffsetX",
1578
+ "cdkConnectedOverlayOffsetY",
1579
+ "cdkConnectedOverlayWidth",
1580
+ "cdkConnectedOverlayHeight",
1581
+ "cdkConnectedOverlayMinWidth",
1582
+ "cdkConnectedOverlayMinHeight",
1583
+ "cdkConnectedOverlayBackdropClass",
1584
+ "cdkConnectedOverlayPanelClass",
1585
+ "cdkConnectedOverlayViewportMargin",
1586
+ "cdkConnectedOverlayScrollStrategy",
1587
+ "cdkConnectedOverlayOpen",
1588
+ "cdkConnectedOverlayDisableClose",
1589
+ "cdkConnectedOverlayTransformOriginOn",
1590
+ "cdkConnectedOverlayHasBackdrop",
1591
+ "cdkConnectedOverlayLockPosition",
1592
+ "cdkConnectedOverlayFlexibleDimensions",
1593
+ "cdkConnectedOverlayGrowAfterOpen",
1594
+ "cdkConnectedOverlayPush",
1595
+ "cdkConnectedOverlayDisposeOnNavigation",
1596
+ "cdkConnectedOverlayUsePopover",
1597
+ "cdkConnectedOverlayMatchWidth",
1598
+ "cdkConnectedOverlay"
1599
+ ],
1600
+ outputs: [
1601
+ "backdropClick",
1602
+ "positionChange",
1603
+ "attach",
1604
+ "detach",
1605
+ "overlayKeydown",
1606
+ "overlayOutsideClick"
1607
+ ],
1608
+ exportAs: ["cdkConnectedOverlay"]
1609
+ },
1610
+ {
1611
+ kind: "directive",
1612
+ type: CdkOverlayOrigin,
1613
+ selector: "[cdk-overlay-origin], [overlay-origin], [cdkOverlayOrigin]",
1614
+ exportAs: ["cdkOverlayOrigin"]
1615
+ },
1616
+ {
1617
+ kind: "ngmodule",
1618
+ type: MatInputModule
1619
+ },
1620
+ {
1621
+ kind: "directive",
1622
+ type: i2.MatInput,
1623
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
1624
+ inputs: [
1625
+ "disabled",
1626
+ "id",
1627
+ "placeholder",
1628
+ "name",
1629
+ "required",
1630
+ "type",
1631
+ "errorStateMatcher",
1632
+ "aria-describedby",
1633
+ "value",
1634
+ "readonly",
1635
+ "disabledInteractive"
1636
+ ],
1637
+ exportAs: ["matInput"]
1638
+ },
1639
+ {
1640
+ kind: "component",
1641
+ type: i2.MatFormField,
1642
+ selector: "mat-form-field",
1643
+ inputs: [
1644
+ "hideRequiredMarker",
1645
+ "color",
1646
+ "floatLabel",
1647
+ "appearance",
1648
+ "subscriptSizing",
1649
+ "hintLabel"
1650
+ ],
1651
+ exportAs: ["matFormField"]
1652
+ },
1653
+ {
1654
+ kind: "directive",
1655
+ type: i2.MatLabel,
1656
+ selector: "mat-label"
1657
+ },
1658
+ {
1659
+ kind: "directive",
1660
+ type: i2.MatPrefix,
1661
+ selector: "[matPrefix], [matIconPrefix], [matTextPrefix]",
1662
+ inputs: ["matTextPrefix"]
1663
+ },
1664
+ {
1665
+ kind: "ngmodule",
1666
+ type: ReactiveFormsModule
1667
+ },
1668
+ {
1669
+ kind: "directive",
1670
+ type: NgClass,
1671
+ selector: "[ngClass]",
1672
+ inputs: ["class", "ngClass"]
1673
+ }
1674
+ ],
1675
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
1676
+ encapsulation: i0.ViewEncapsulation.None
1677
+ });
1678
+ }
1679
+ };
1680
+ i0.ɵɵngDeclareClassMetadata({
1681
+ minVersion: "12.0.0",
1682
+ version: "22.2.3",
1683
+ ngImport: i0,
1684
+ type: CmatColorPickerButtonComponent,
1685
+ decorators: [{
1686
+ type: Component,
1687
+ args: [{
1688
+ selector: "cmat-color-picker-button",
1689
+ imports: [
1690
+ FormsModule,
1691
+ CmatColorPickerComponent,
1692
+ CdkConnectedOverlay,
1693
+ CdkOverlayOrigin,
1694
+ MatInputModule,
1695
+ ReactiveFormsModule,
1696
+ NgClass
1697
+ ],
1698
+ encapsulation: ViewEncapsulation.None,
1699
+ changeDetection: ChangeDetectionStrategy.OnPush,
1700
+ template: "<!-- eslint-disable @angular-eslint/template/no-inline-styles -->\r\n<section>\r\n <mat-form-field class=\"w-full\">\r\n <mat-label>{{ label() }}</mat-label>\r\n <input matInput type=\"text\" [placeholder]=\"placeholder()\" [disabled]=\"disabled()\" [(ngModel)]=\"value\"\r\n (ngModelChange)=\"valueChanged.emit($event);colorChanged.emit($event);\" />\r\n <button #trigger=\"cdkOverlayOrigin\" matPrefix cdkOverlayOrigin class=\"ml-2\"\r\n [ngClass]=\"{'pointer-events-none':disabled()}\"\r\n [style.color]=\"value()\" (click)=\"toggleMenu()\">\r\n <span></span>\r\n </button>\r\n </mat-form-field>\r\n</section>\r\n\r\n<ng-template cdkConnectedOverlay [cdkConnectedOverlayOrigin]=\"trigger\" [cdkConnectedOverlayOpen]=\"isOpen()\"\r\n (overlayOutsideClick)=\"closeMenu()\" (detach)=\"closeMenu()\">\r\n <cmat-color-picker [format]=\"format()\" [hideAlpha]=\"hideAlpha()\" [disabled]=\"disabled()\" [(value)]=\"value\"\r\n (formatChanged)=\"formatChanged.emit($event)\" (valueChanged)=\"valueChanged.emit($event)\"\r\n (colorChanged)=\"colorChanged.emit($event)\" />\r\n</ng-template>",
1701
+ styles: ["cmat-color-picker-button{--cmat-prefix-label-offset: 20px}cmat-color-picker-button section{--outline-color: #b4b4b4;--hover-outline-color: var(--cmat-primary)}cmat-color-picker-button section:is(.dark *){--outline-color: #4d4d4d}cmat-color-picker-button section{display:flex;gap:8px}cmat-color-picker-button .input-group{display:flex;gap:8px}cmat-color-picker-button .input-group input{flex:1}cmat-color-picker-button button{display:inline-flex;width:32px;height:32px;padding:4px;background:none;border-radius:8px;border:1px solid var(--outline-color);cursor:pointer}cmat-color-picker-button button:after{content:\"\";display:inline-block;width:100%;height:100%;background-color:currentColor;border-radius:3px}cmat-color-picker-button button:hover,cmat-color-picker-button button:focus{border-color:var(--hover-outline-color)}cmat-color-picker-button input{padding:4px 8px;border-radius:8px;border:1px solid var(--outline-color);display:flex;flex:1 auto}cmat-color-picker-button input:hover,cmat-color-picker-button input:focus{border-color:var(--hover-outline-color)}\n"]
1702
+ }]
1703
+ }],
1704
+ propDecorators: {
1705
+ format: [{
1706
+ type: i0.Input,
1707
+ args: [{
1708
+ isSignal: true,
1709
+ alias: "format",
1710
+ required: false
1711
+ }]
1712
+ }, {
1713
+ type: i0.Output,
1714
+ args: ["formatChange"]
1715
+ }],
1716
+ value: [{
1717
+ type: i0.Input,
1718
+ args: [{
1719
+ isSignal: true,
1720
+ alias: "value",
1721
+ required: false
1722
+ }]
1723
+ }, {
1724
+ type: i0.Output,
1725
+ args: ["valueChange"]
1726
+ }],
1727
+ hideAlpha: [{
1728
+ type: i0.Input,
1729
+ args: [{
1730
+ isSignal: true,
1731
+ alias: "hideAlpha",
1732
+ required: false
1733
+ }]
1734
+ }],
1735
+ disabled: [{
1736
+ type: i0.Input,
1737
+ args: [{
1738
+ isSignal: true,
1739
+ alias: "disabled",
1740
+ required: false
1741
+ }]
1742
+ }, {
1743
+ type: i0.Output,
1744
+ args: ["disabledChange"]
1745
+ }],
1746
+ placeholder: [{
1747
+ type: i0.Input,
1748
+ args: [{
1749
+ isSignal: true,
1750
+ alias: "placeholder",
1751
+ required: false
1752
+ }]
1753
+ }],
1754
+ label: [{
1755
+ type: i0.Input,
1756
+ args: [{
1757
+ isSignal: true,
1758
+ alias: "label",
1759
+ required: false
1760
+ }]
1761
+ }],
1762
+ formatChanged: [{
1763
+ type: i0.Output,
1764
+ args: ["formatChanged"]
1765
+ }],
1766
+ valueChanged: [{
1767
+ type: i0.Output,
1768
+ args: ["valueChanged"]
1769
+ }],
1770
+ colorChanged: [{
1771
+ type: i0.Output,
1772
+ args: ["colorChanged"]
1773
+ }]
1774
+ }
1775
+ });
840
1776
  export { CmatColorAlphaSlider, CmatColorCoordinates, CmatColorHueSlider, CmatColorIconButton, CmatColorInputField, CmatColorInputFields, CmatColorPickerButtonComponent, CmatColorPickerComponent, CmatColorSaturationPicker, hslToHsv, hsvToHsl, isValidHex, parseColor, simpleCheckForValidColor, toHslString, toHsvString };
841
- //# sourceMappingURL=cmat-components-color-picker.mjs.map
1777
+
1778
+ //# sourceMappingURL=cmat-components-color-picker.mjs.map