@nanahoshi/mona-ui 0.27.2 → 0.28.0

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 (208) hide show
  1. package/docs/api/chart.md +2 -2
  2. package/docs/api/popup.md +1 -1
  3. package/docs/api/theme.md +2 -2
  4. package/docs/chart.md +14 -0
  5. package/docs/editor.md +2 -0
  6. package/docs/installation.md +147 -15
  7. package/docs/introduction.md +37 -15
  8. package/docs/theming-built-in-themes.md +67 -0
  9. package/docs/theming-custom-colors.md +274 -0
  10. package/docs/theming-custom-themes.md +168 -0
  11. package/docs/theming.md +164 -248
  12. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  13. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  14. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  15. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  16. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  17. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2070 -1573
  18. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  19. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  20. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  21. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  22. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  23. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
  24. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  25. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  26. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  27. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  28. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  29. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
  30. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  31. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
  32. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  33. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  34. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  35. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  36. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  37. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
  38. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  39. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  40. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  41. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  42. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  43. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  44. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  45. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  46. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  47. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  48. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  49. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  50. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
  51. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  52. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  53. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  54. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  55. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  56. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  57. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  58. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  59. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  60. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  61. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  62. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  63. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  64. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  65. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  66. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  67. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  68. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  69. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  70. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  71. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  72. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  73. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  74. package/fesm2022/nanahoshi-mona-ui-locales.mjs +59 -77
  75. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  76. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  77. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  78. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  79. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  80. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  81. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  82. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  83. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  84. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  85. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  86. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  87. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  88. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  89. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  90. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  91. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  92. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  93. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  94. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  95. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  96. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  97. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  98. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  99. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  100. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  101. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  102. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  103. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  104. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  105. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  106. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  107. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  108. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  109. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  110. package/llms.txt +6 -2
  111. package/package.json +62 -23
  112. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  113. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  114. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  115. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  116. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  117. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  118. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  119. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  120. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  121. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  122. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  123. package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
  124. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  125. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  126. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  127. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  128. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  129. package/types/nanahoshi-mona-ui-common.d.ts +354 -385
  130. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  131. package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
  132. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  133. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  134. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  135. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  136. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  137. package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
  138. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  139. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  140. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  141. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  142. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  143. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  144. package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
  145. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  146. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  147. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  148. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  149. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  150. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  151. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  152. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  153. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  154. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  155. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  156. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  157. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  158. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  159. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  160. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  161. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  162. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  163. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  164. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  165. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  166. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  167. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  168. package/types/nanahoshi-mona-ui-locales.d.ts +17 -19
  169. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  170. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  171. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  172. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  173. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  174. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  175. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  176. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  177. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  178. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  179. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  180. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  181. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  182. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  183. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  184. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  185. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  186. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  187. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  188. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  189. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  190. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  191. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  192. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  193. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  194. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  195. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  196. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  197. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  198. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  199. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  200. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  201. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  202. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  203. package/types/nanahoshi-mona-ui.d.ts +1 -2
  204. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  205. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  206. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  207. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  208. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
@@ -1,51 +1,47 @@
1
- import { LiveAnnouncer } from '@angular/cdk/a11y';
2
- import { Clipboard } from '@angular/cdk/clipboard';
3
- import { NgTemplateOutlet } from '@angular/common';
4
- import * as i0 from '@angular/core';
5
- import { inject, DestroyRef, DOCUMENT, ElementRef, signal, computed, viewChild, output, input, booleanAttribute, model, afterNextRender, effect, untracked, isDevMode, Component } from '@angular/core';
6
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
7
- import { LucideDropletOff, LucideChevronsUpDown, LucideCopy } from '@lucide/angular';
8
- import { ButtonDirective } from '@nanahoshi/mona-ui/button';
9
- import { injectLabelAssociation, rgba2hex, injectEffectiveDisabled, hsva2rgba, formatAlpha, isValidHex, hex2rgba, rgba2hsva, rgba2hsla, parseColor } from '@nanahoshi/mona-ui/internal';
10
- import { DropdownButtonComponent, DropdownButtonItemComponent, DropdownButtonTextTemplateDirective } from '@nanahoshi/mona-ui/dropdown-button';
11
- import { NumericTextBoxComponent, NumericTextBoxPrefixTemplateDirective } from '@nanahoshi/mona-ui/numeric-text-box';
12
- import { SliderComponent } from '@nanahoshi/mona-ui/slider';
13
- import { TextBoxComponent, TextBoxPrefixTemplateDirective, TextBoxSuffixTemplateDirective } from '@nanahoshi/mona-ui/text-box';
14
- import { formatNumber, MonaI18nService } from '@nanahoshi/mona-ui/i18n';
15
- import { fromEvent, filter, tap, switchMap, merge, takeUntil } from 'rxjs';
16
- import { cva } from 'class-variance-authority';
17
-
18
- // Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
19
- // Edit the JSON file and run `npm run generate:locale-catalogs`.
1
+ import { LiveAnnouncer } from "@angular/cdk/a11y";
2
+ import { Clipboard } from "@angular/cdk/clipboard";
3
+ import { NgTemplateOutlet } from "@angular/common";
4
+ import * as i0 from "@angular/core";
5
+ import { Component, DOCUMENT, DestroyRef, ElementRef, afterNextRender, booleanAttribute, computed, effect, inject, input, isDevMode, model, output, signal, untracked, viewChild } from "@angular/core";
6
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
7
+ import { LucideChevronsUpDown, LucideCopy, LucideDropletOff } from "@lucide/angular";
8
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
9
+ import { formatAlpha, hex2rgba, hsva2rgba, injectEffectiveDisabled, injectLabelAssociation, isValidHex, parseColor, rgba2hex, rgba2hsla, rgba2hsva } from "@nanahoshi/mona-ui/internal";
10
+ import { DropdownButtonComponent, DropdownButtonItemComponent, DropdownButtonTextTemplateDirective } from "@nanahoshi/mona-ui/dropdown-button";
11
+ import { NumericTextBoxComponent, NumericTextBoxPrefixTemplateDirective } from "@nanahoshi/mona-ui/numeric-text-box";
12
+ import { SliderComponent } from "@nanahoshi/mona-ui/slider";
13
+ import { TextBoxComponent, TextBoxPrefixTemplateDirective, TextBoxSuffixTemplateDirective } from "@nanahoshi/mona-ui/text-box";
14
+ import { MonaI18nService, formatNumber } from "@nanahoshi/mona-ui/i18n";
15
+ import { filter, fromEvent, merge, switchMap, takeUntil, tap } from "rxjs";
16
+ import { cva } from "class-variance-authority";
20
17
  function localizeNumber(value, options) {
21
- return formatNumber(value, "en-US", options);
18
+ return formatNumber(value, "en-US", options);
22
19
  }
23
20
  const COLOR_GRADIENT_DEFAULT_MESSAGES = {
24
- alpha: "Alpha",
25
- alphaText: (opacity) => `Opacity ${localizeNumber(opacity)}%`,
26
- apply: "Apply",
27
- blue: "Blue",
28
- cancel: "Cancel",
29
- clearColor: "Clear color",
30
- colorCopied: "Color copied",
31
- colorGradient: "Color gradient",
32
- copyAsHex: "Copy as HEX",
33
- copyAsRgb: "Copy as RGB",
34
- copyColor: "Copy color",
35
- copyFailed: "Couldn't copy the color",
36
- currentColor: "Current color",
37
- green: "Green",
38
- hexColor: "Hex color",
39
- hue: "Hue",
40
- previousColor: "Previous color",
41
- red: "Red",
42
- saturation: "Saturation",
43
- saturationAndValue: "Color saturation and value",
44
- saturationAndValueText: (saturation, value) => `Saturation ${localizeNumber(saturation)}%, Value ${localizeNumber(value)}%`,
45
- switchColorMode: "Switch color mode",
46
- value: "Value"
21
+ alpha: "Alpha",
22
+ alphaText: (opacity) => `Opacity ${localizeNumber(opacity)}%`,
23
+ apply: "Apply",
24
+ blue: "Blue",
25
+ cancel: "Cancel",
26
+ clearColor: "Clear color",
27
+ colorCopied: "Color copied",
28
+ colorGradient: "Color gradient",
29
+ copyAsHex: "Copy as HEX",
30
+ copyAsRgb: "Copy as RGB",
31
+ copyColor: "Copy color",
32
+ copyFailed: "Couldn't copy the color",
33
+ currentColor: "Current color",
34
+ green: "Green",
35
+ hexColor: "Hex color",
36
+ hue: "Hue",
37
+ previousColor: "Previous color",
38
+ red: "Red",
39
+ saturation: "Saturation",
40
+ saturationAndValue: "Color saturation and value",
41
+ saturationAndValueText: (saturation, value) => `Saturation ${localizeNumber(saturation)}%, Value ${localizeNumber(value)}%`,
42
+ switchColorMode: "Switch color mode",
43
+ value: "Value"
47
44
  };
48
-
49
45
  const colorGradientBaseThemeVariants = cva(`
50
46
  flex flex-col min-w-64
51
47
  gap-2 p-2
@@ -65,17 +61,13 @@ const colorGradientHsvRectangleThemeVariants = cva(`
65
61
  cursor-crosshair touch-none forced-color-adjust-none
66
62
  bg-[linear-gradient(to_bottom,rgba(0,0,0,0),black),linear-gradient(to_right,white,rgba(255,255,255,0))]
67
63
  border border-border-subtle
68
- `, {
69
- variants: {
70
- rounded: {
71
- none: "rounded-none",
72
- small: "rounded-sm",
73
- medium: "rounded-md",
74
- large: "rounded-lg",
75
- full: "rounded-lg" // Full is not suitable for color gradient rectangle.
76
- }
77
- }
78
- });
64
+ `, { variants: { rounded: {
65
+ none: "rounded-none",
66
+ small: "rounded-sm",
67
+ medium: "rounded-md",
68
+ large: "rounded-lg",
69
+ full: "rounded-lg"
70
+ } } });
79
71
  const colorGradientHsvRectangleHandleThemeVariants = cva(`
80
72
  absolute
81
73
  h-3 w-3
@@ -86,774 +78,1106 @@ const colorGradientHsvRectangleHandleThemeVariants = cva(`
86
78
 
87
79
  focus-visible:outline-2 focus-visible:outline-white/90!
88
80
  focus-visible:shadow-[0_0_0_4px_rgb(0_0_0/0.9)]
89
- `, {
90
- variants: {
91
- rounded: {
92
- none: "rounded-none",
93
- small: "rounded-sm",
94
- medium: "rounded-md",
95
- large: "rounded-lg",
96
- full: "rounded-full"
97
- }
98
- }
99
- });
81
+ `, { variants: { rounded: {
82
+ none: "rounded-none",
83
+ small: "rounded-sm",
84
+ medium: "rounded-md",
85
+ large: "rounded-lg",
86
+ full: "rounded-full"
87
+ } } });
100
88
  const colorGradientPreviewThemeVariants = cva(`
101
89
  flex h-10 w-10
102
90
  border border-border-subtle
103
91
  forced-color-adjust-none
104
92
  focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator
105
- `, {
106
- variants: {
107
- rounded: {
108
- none: "rounded-none",
109
- small: "rounded-sm",
110
- medium: "rounded-md",
111
- large: "rounded-lg",
112
- full: "rounded-full"
113
- }
114
- }
115
- });
93
+ `, { variants: { rounded: {
94
+ none: "rounded-none",
95
+ small: "rounded-sm",
96
+ medium: "rounded-md",
97
+ large: "rounded-lg",
98
+ full: "rounded-full"
99
+ } } });
116
100
  const colorGradientSliderHandleThemeVariants = cva(`
117
101
  h-3 w-3
118
102
  bg-transparent
119
103
  border-3 border-white/90
120
104
  outline outline-solid outline-black/90
121
105
  `);
122
-
123
- const DEFAULT_HSV = { h: 0, s: 0, v: 100 };
124
- const DEFAULT_RGB = { r: 255, g: 255, b: 255 };
125
- class ColorGradientComponent {
126
- #announcer;
127
- #clipboard;
128
- #destroyRef;
129
- #document;
130
- #hostElementRef;
131
- #i18n;
132
- #label;
133
- #viewReady;
134
- /** Whether the color on screen differs from the value because of something the user did. */
135
- #edited;
136
- #internalValueUpdatePending;
137
- #lastInternalValue;
138
- constructor() {
139
- this.#announcer = inject(LiveAnnouncer);
140
- this.#clipboard = inject(Clipboard);
141
- this.#destroyRef = inject(DestroyRef);
142
- this.#document = inject(DOCUMENT);
143
- this.#hostElementRef = inject(ElementRef);
144
- this.#i18n = inject(MonaI18nService);
145
- this.#label = injectLabelAssociation({
146
- activate: () => this.focus(),
147
- ariaLabel: () => this.ariaLabel(),
148
- ariaLabelledBy: () => this.ariaLabelledBy()
149
- });
150
- this.#viewReady = signal(false, /* @ts-ignore */
151
- ...(ngDevMode ? [{ debugName: "#viewReady" }] : /* istanbul ignore next */ []));
152
- /** Whether the color on screen differs from the value because of something the user did. */
153
- this.#edited = false;
154
- this.#internalValueUpdatePending = false;
155
- this.#lastInternalValue = undefined;
156
- this.alpha = signal(255, /* @ts-ignore */
157
- ...(ngDevMode ? [{ debugName: "alpha" }] : /* istanbul ignore next */ []));
158
- this.alphaInputColor = computed(() => {
159
- // With no color there is still a track to show.
160
- const rgb = this.rgb();
161
- return rgba2hex(rgb.r ?? 0, rgb.g ?? 0, rgb.b ?? 0, 255);
162
- }, /* @ts-ignore */
163
- ...(ngDevMode ? [{ debugName: "alphaInputColor" }] : /* istanbul ignore next */ []));
164
- this.alphaSliderBackground = computed(() => {
165
- const color = this.alphaInputColor();
166
- return `linear-gradient(to right, transparent, ${color})`;
167
- }, /* @ts-ignore */
168
- ...(ngDevMode ? [{ debugName: "alphaSliderBackground" }] : /* istanbul ignore next */ []));
169
- this.alphaValueText = computed(() => {
170
- const { alphaText } = this.messages();
171
- return (alpha) => alphaText(Math.round((alpha / 255) * 100));
172
- }, /* @ts-ignore */
173
- ...(ngDevMode ? [{ debugName: "alphaValueText" }] : /* istanbul ignore next */ []));
174
- this.baseClasses = computed(() => {
175
- return colorGradientBaseThemeVariants();
176
- }, /* @ts-ignore */
177
- ...(ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []));
178
- this.colorInputs = computed(() => {
179
- const mode = this.colorMode();
180
- const baseInputs = mode === "rgb" ? this.createRgbInputList() : this.createHsvInputList();
181
- if (this.opacity()) {
182
- baseInputs.push({
183
- ariaLabel: this.messages().alpha,
184
- key: "a",
185
- label: "A",
186
- value: this.alpha(),
187
- min: 0,
188
- max: 255,
189
- change: (value) => this.onAlphaChange(value)
190
- });
191
- }
192
- return baseInputs;
193
- }, /* @ts-ignore */
194
- ...(ngDevMode ? [{ debugName: "colorInputs" }] : /* istanbul ignore next */ []));
195
- this.colorMode = signal("rgb", /* @ts-ignore */
196
- ...(ngDevMode ? [{ debugName: "colorMode" }] : /* istanbul ignore next */ []));
197
- this.colorPreviewClasses = computed(() => {
198
- const rounded = this.rounded();
199
- return colorGradientPreviewThemeVariants({ rounded });
200
- }, /* @ts-ignore */
201
- ...(ngDevMode ? [{ debugName: "colorPreviewClasses" }] : /* istanbul ignore next */ []));
202
- this.colorPreviews = computed(() => [
203
- {
204
- type: "current",
205
- color: this.selectedColor(),
206
- title: this.messages().currentColor
207
- },
208
- {
209
- type: "last",
210
- color: this.lastSelectedColor(),
211
- title: this.messages().previousColor,
212
- onClick: () => this.onResetColorClick()
213
- }
214
- ], /* @ts-ignore */
215
- ...(ngDevMode ? [{ debugName: "colorPreviews" }] : /* istanbul ignore next */ []));
216
- this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
217
- this.hex = computed(() => {
218
- const rgb = this.rgb();
219
- const alpha = this.alpha();
220
- const focused = this.hexFocused();
221
- if (!focused) {
222
- return rgba2hex(rgb.r, rgb.g, rgb.b, alpha);
223
- }
224
- return this.hexInputValue();
225
- }, /* @ts-ignore */
226
- ...(ngDevMode ? [{ debugName: "hex" }] : /* istanbul ignore next */ []));
227
- this.hexFocused = signal(false, /* @ts-ignore */
228
- ...(ngDevMode ? [{ debugName: "hexFocused" }] : /* istanbul ignore next */ []));
229
- this.hexInputValue = signal("", /* @ts-ignore */
230
- ...(ngDevMode ? [{ debugName: "hexInputValue" }] : /* istanbul ignore next */ []));
231
- this.hsv = signal({ ...DEFAULT_HSV }, /* @ts-ignore */
232
- ...(ngDevMode ? [{ debugName: "hsv" }] : /* istanbul ignore next */ []));
233
- this.hsvHandle = viewChild.required("hsvPointer", /* @ts-ignore */
234
- ...(ngDevMode ? [{ debugName: "hsvHandle" }] : /* istanbul ignore next */ []));
235
- this.hsvRectangle = viewChild.required("hsvRectangle", /* @ts-ignore */
236
- ...(ngDevMode ? [{ debugName: "hsvRectangle" }] : /* istanbul ignore next */ []));
237
- this.hsvRectangleBackground = computed(() => {
238
- const rgb = hsva2rgba(this.hsv().h ?? 0, 100, 100, 255);
239
- return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
240
- }, /* @ts-ignore */
241
- ...(ngDevMode ? [{ debugName: "hsvRectangleBackground" }] : /* istanbul ignore next */ []));
242
- this.hsvRectangleClasses = computed(() => {
243
- const rounded = this.rounded() === "full" ? "large" : this.rounded();
244
- return colorGradientHsvRectangleThemeVariants({ rounded });
245
- }, /* @ts-ignore */
246
- ...(ngDevMode ? [{ debugName: "hsvRectangleClasses" }] : /* istanbul ignore next */ []));
247
- this.hsvRectangleHandleClasses = computed(() => {
248
- const rounded = this.rounded();
249
- return colorGradientHsvRectangleHandleThemeVariants({ rounded });
250
- }, /* @ts-ignore */
251
- ...(ngDevMode ? [{ debugName: "hsvRectangleHandleClasses" }] : /* istanbul ignore next */ []));
252
- this.interactionDisabled = computed(() => this.effectiveDisabled() || this.readonly(), /* @ts-ignore */
253
- ...(ngDevMode ? [{ debugName: "interactionDisabled" }] : /* istanbul ignore next */ []));
254
- this.invalidState = computed(() => this.touched() && (this.invalid() || (this.required() && !this.value())), /* @ts-ignore */
255
- ...(ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []));
256
- this.labelledBy = this.#label.labelledBy;
257
- this.lastSelectedColor = signal("", /* @ts-ignore */
258
- ...(ngDevMode ? [{ debugName: "lastSelectedColor" }] : /* istanbul ignore next */ []));
259
- this.messages = this.#i18n.componentMessages("colorGradient", COLOR_GRADIENT_DEFAULT_MESSAGES);
260
- this.rgb = signal({ ...DEFAULT_RGB }, /* @ts-ignore */
261
- ...(ngDevMode ? [{ debugName: "rgb" }] : /* istanbul ignore next */ []));
262
- this.roundedHue = computed(() => Math.round(this.hsv().h ?? 0), /* @ts-ignore */
263
- ...(ngDevMode ? [{ debugName: "roundedHue" }] : /* istanbul ignore next */ []));
264
- this.roundedSaturation = computed(() => Math.round(this.hsv().s ?? 0), /* @ts-ignore */
265
- ...(ngDevMode ? [{ debugName: "roundedSaturation" }] : /* istanbul ignore next */ []));
266
- this.roundedValue = computed(() => Math.round(this.hsv().v ?? 0), /* @ts-ignore */
267
- ...(ngDevMode ? [{ debugName: "roundedValue" }] : /* istanbul ignore next */ []));
268
- this.selectedColor = computed(() => {
269
- const rgb = this.rgb();
270
- if (rgb.r == null || rgb.g == null || rgb.b == null) {
271
- return "";
272
- }
273
- return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${this.alpha() / 255})`;
274
- }, /* @ts-ignore */
275
- ...(ngDevMode ? [{ debugName: "selectedColor" }] : /* istanbul ignore next */ []));
276
- this.sliderHandleClasses = computed(() => {
277
- return colorGradientSliderHandleThemeVariants();
278
- }, /* @ts-ignore */
279
- ...(ngDevMode ? [{ debugName: "sliderHandleClasses" }] : /* istanbul ignore next */ []));
280
- this.sliderHeight = 10;
281
- /**
282
- * @description Emits when the Apply button is clicked.
283
- * The `Apply` button is only displayed when `showButtons` is set to true.
284
- */
285
- this.apply = output();
286
- /**
287
- * @description Accessible name of the group of controls.
288
- * @default ""
289
- */
290
- this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
291
- /**
292
- * @description Id of the element that names the group of controls.
293
- * @default ""
294
- */
295
- this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
296
- /**
297
- * @description Emits when the Cancel button is clicked, after the controls go back to the current value.
298
- * The `Cancel` button is only displayed when `showButtons` is set to true.
299
- */
300
- // eslint-disable-next-line @angular-eslint/no-output-native -- renaming the output would break existing (cancel) bindings
301
- this.cancel = output();
302
- /**
303
- * @description Sets the disabled state of the color gradient.
304
- * @default false
305
- */
306
- this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
307
- /**
308
- * @description Specifies the format of the color output.
309
- * @default "hex"
310
- */
311
- this.format = input("hex", /* @ts-ignore */
312
- ...(ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []));
313
- /**
314
- * @description Marks the color gradient as invalid. When bound to a signal form field via `[formField]`,
315
- * this is written by the `FormField` directive.
316
- * @default false
317
- */
318
- this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
319
- /**
320
- * @description Specifies whether the color picker should display the alpha slider.
321
- * @default true
322
- */
323
- this.opacity = input(true, { ...(ngDevMode ? { debugName: "opacity" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
324
- /**
325
- * @description Prevents value changes while the control stays focusable and readable. When bound to a signal form
326
- * field via `[formField]`, this is written by the `FormField` directive.
327
- * @default false
328
- */
329
- this.readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
330
- /**
331
- * @description Marks the color gradient as required for form validation.
332
- * @default false
333
- */
334
- this.required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
335
- /**
336
- * @description Specifies the rounded variant of the color picker.
337
- * @default "medium"
338
- */
339
- this.rounded = input("medium", /* @ts-ignore */
340
- ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
341
- /**
342
- * @description Specifies whether the color picker should display the buttons.
343
- * When set to true, the color picker will display the "Apply" and "Cancel" buttons.
344
- * When set to false, the color picker will not display the buttons and will emit the color value on change.
345
- * @default true
346
- */
347
- this.showButtons = input(true, { ...(ngDevMode ? { debugName: "showButtons" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
348
- /**
349
- * @description Specifies whether the color picker should display the channel inputs (RGB or HSV).
350
- * @default true
351
- */
352
- this.showColorInputs = input(true, { ...(ngDevMode ? { debugName: "showColorInputs" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
353
- /**
354
- * @description Specifies whether the color picker should display the hex input.
355
- * @default true
356
- */
357
- this.showHexInput = input(true, { ...(ngDevMode ? { debugName: "showHexInput" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
358
- /**
359
- * @description Emitted when focus leaves the color gradient. Moving between its own parts doesn't count.
360
- * The `FormField` directive listens to this to mark the field as touched.
361
- */
362
- this.touch = output();
363
- /**
364
- * @description Marks the color gradient as touched. When bound to a signal form field via `[formField]`,
365
- * this is written by the `FormField` directive.
366
- * @default false
367
- */
368
- this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
369
- /**
370
- * @description Two-way bindable current color value.
371
- * When undefined, the component keeps its default internal color state (white, #ffffffff).
372
- * @default undefined
373
- */
374
- this.value = model(undefined, /* @ts-ignore */
375
- ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
376
- afterNextRender({
377
- read: () => {
378
- this.lastSelectedColor.set(this.hex());
379
- this.setHsvRectPointerEvents();
380
- this.#viewReady.set(true);
381
- }
382
- });
383
- effect(() => {
384
- if (!this.#viewReady()) {
385
- return;
386
- }
387
- const value = this.value();
388
- untracked(() => this.syncValue(value));
389
- });
390
- }
391
- /**
392
- * @description Moves focus to the saturation and value handle.
393
- * @param options Options passed to the native `focus()` call, such as `preventScroll`.
394
- */
395
- focus(options) {
396
- this.hsvHandle().nativeElement.focus(options);
397
- }
398
- /**
399
- * @internal
400
- */
401
- setLabelledBy(id) {
402
- this.#label.setLabelledBy(id);
403
- }
404
- onAlphaChange(value) {
405
- if (value == null) {
406
- return;
407
- }
408
- this.#edited = true;
409
- const alpha = this.getValidChannelValue(value, "a");
410
- this.alpha.set(alpha);
411
- this.updateHexInputValue();
412
- if (!this.showButtons()) {
413
- this.emitValue();
414
- }
415
- }
416
- onApply() {
417
- if (this.interactionDisabled()) {
418
- return;
419
- }
420
- // Applying what was never edited keeps the value as written, whatever its format, even one this can't read.
421
- if (this.#edited || this.value() === undefined) {
422
- this.lastSelectedColor.set(this.hex());
423
- this.emitValue();
424
- }
425
- this.#edited = false;
426
- this.apply.emit();
427
- }
428
- onCancel() {
429
- this.loadValue(this.value());
430
- this.cancel.emit();
431
- }
432
- onClearClick() {
433
- if (this.interactionDisabled()) {
434
- return;
435
- }
436
- this.#edited = true;
437
- this.clear();
438
- if (!this.showButtons()) {
439
- this.commitValue(null);
440
- }
441
- }
442
- onCopyColorSelect(mode) {
443
- const rgb = this.rgb();
444
- const text = mode === "hex"
445
- ? rgba2hex(rgb.r, rgb.g, rgb.b, this.alpha())
446
- : `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${formatAlpha(this.alpha())})`;
447
- const copied = this.#clipboard.copy(text);
448
- void this.#announcer.announce(copied ? this.messages().colorCopied : this.messages().copyFailed);
449
- }
450
- onFocusOut(event) {
451
- const nextTarget = event.relatedTarget;
452
- if (nextTarget instanceof Node && this.#hostElementRef.nativeElement.contains(nextTarget)) {
453
- return;
454
- }
455
- this.touch.emit();
456
- }
457
- onHexChange(value) {
458
- this.hexInputValue.set(value);
459
- if (!isValidHex(value)) {
460
- return;
461
- }
462
- this.#edited = true;
463
- const rgb = hex2rgba(value);
464
- const hsv = rgba2hsva(rgb.r, rgb.g, rgb.b, rgb.a);
465
- this.hsv.update(c => ({ ...c, h: hsv.h, s: hsv.s, v: hsv.v }));
466
- this.rgb.update(c => ({ ...c, r: rgb.r, g: rgb.g, b: rgb.b }));
467
- this.alpha.set(rgb.a ?? 255);
468
- if (!this.showButtons()) {
469
- this.emitValue();
470
- }
471
- }
472
- onHexInputBlur() {
473
- this.hexFocused.set(false);
474
- this.updateHexInputValue();
475
- }
476
- onHexInputFocus() {
477
- this.updateHexInputValue();
478
- this.hexFocused.set(true);
479
- }
480
- onHsvChange(value, channel) {
481
- if (value == null) {
482
- return;
483
- }
484
- this.#edited = true;
485
- value = this.getValidChannelValue(value, channel);
486
- this.hsv.update(c => ({ ...c, [channel]: value }));
487
- this.updateOtherNullChannels(channel);
488
- const hsv = this.hsv();
489
- const rgb = hsva2rgba(hsv.h, hsv.s, hsv.v, this.alpha());
490
- this.rgb.update(c => ({ ...c, r: rgb.r, g: rgb.g, b: rgb.b }));
491
- this.updateHexInputValue();
492
- if (!this.showButtons()) {
493
- this.emitValue();
494
- }
495
- }
496
- onHsvHandleKeyDown(event) {
497
- if (this.interactionDisabled()) {
498
- return;
499
- }
500
- const step = event.shiftKey ? 10 : 1;
501
- const largeStep = 25;
502
- let handled = false;
503
- const currentHsv = this.hsv();
504
- const currentSaturation = currentHsv.s ?? 0;
505
- const currentValue = currentHsv.v ?? 0;
506
- let newSaturation = currentSaturation;
507
- let newValue = currentValue;
508
- switch (event.key) {
509
- case "ArrowLeft":
510
- newSaturation = this.getValidChannelValue(currentSaturation - step, "s");
511
- handled = true;
512
- break;
513
- case "ArrowRight":
514
- newSaturation = this.getValidChannelValue(currentSaturation + step, "s");
515
- handled = true;
516
- break;
517
- case "ArrowUp":
518
- newValue = this.getValidChannelValue(currentValue + step, "v");
519
- handled = true;
520
- break;
521
- case "ArrowDown":
522
- newValue = this.getValidChannelValue(currentValue - step, "v");
523
- handled = true;
524
- break;
525
- case "Home":
526
- newSaturation = 0;
527
- newValue = 100;
528
- handled = true;
529
- break;
530
- case "End":
531
- newSaturation = 100;
532
- newValue = 0;
533
- handled = true;
534
- break;
535
- case "PageUp":
536
- newValue = this.getValidChannelValue(currentValue + largeStep, "v");
537
- handled = true;
538
- break;
539
- case "PageDown":
540
- newValue = this.getValidChannelValue(currentValue - largeStep, "v");
541
- handled = true;
542
- break;
543
- }
544
- if (handled) {
545
- event.preventDefault();
546
- event.stopPropagation();
547
- this.updateHsvValues(newSaturation, newValue);
548
- this.updateHexInputValue();
549
- }
550
- }
551
- onHueChange(value) {
552
- this.#edited = true;
553
- this.hsv.update(c => ({ ...c, h: Math.round(value) }));
554
- this.updateOtherNullChannels("h");
555
- this.updateRgbFromHsv();
556
- this.updateHexInputValue();
557
- }
558
- onPreviousColorKeyDown(event, handler) {
559
- if (event.key === "Enter" || event.key === " ") {
560
- event.preventDefault();
561
- handler?.();
562
- }
563
- }
564
- onResetColorClick() {
565
- if (this.interactionDisabled()) {
566
- return;
567
- }
568
- this.onHexChange(this.lastSelectedColor());
569
- }
570
- onRgbChange(value, channel) {
571
- if (value == null) {
572
- return;
573
- }
574
- this.#edited = true;
575
- value = this.getValidChannelValue(value, channel);
576
- this.rgb.update(c => ({ ...c, [channel]: value }));
577
- this.updateOtherNullChannels(channel);
578
- const rgb = this.rgb();
579
- const hsv = rgba2hsva(rgb.r, rgb.g, rgb.b, this.alpha());
580
- this.hsv.update(c => ({ ...c, h: hsv.h, s: hsv.s, v: hsv.v }));
581
- this.updateHexInputValue();
582
- if (!this.showButtons()) {
583
- this.emitValue();
584
- }
585
- }
586
- onSwitchColorModeClick() {
587
- this.colorMode.set(this.colorMode() === "rgb" ? "hsv" : "rgb");
588
- }
589
- clear() {
590
- this.hexInputValue.set("");
591
- this.rgb.update(c => ({ ...c, r: null, g: null, b: null }));
592
- this.alpha.set(255);
593
- this.hsv.update(c => ({ ...c, h: null, s: null, v: null }));
594
- }
595
- commitValue(value) {
596
- if (value === this.value()) {
597
- return;
598
- }
599
- this.#internalValueUpdatePending = true;
600
- this.#lastInternalValue = value;
601
- this.value.set(value);
602
- }
603
- createHsvInputList() {
604
- const messages = this.messages();
605
- const hue = {
606
- ariaLabel: messages.hue,
607
- key: "h",
608
- label: "H",
609
- value: this.roundedHue(),
610
- min: 0,
611
- max: 360,
612
- change: (value) => this.onHsvChange(value, "h")
613
- };
614
- const saturation = {
615
- ariaLabel: messages.saturation,
616
- key: "s",
617
- label: "S",
618
- value: this.roundedSaturation(),
619
- min: 0,
620
- max: 100,
621
- change: (value) => this.onHsvChange(value, "s")
622
- };
623
- const value = {
624
- ariaLabel: messages.value,
625
- key: "v",
626
- label: "V",
627
- value: this.roundedValue(),
628
- min: 0,
629
- max: 100,
630
- change: (value) => this.onHsvChange(value, "v")
631
- };
632
- return [hue, saturation, value];
633
- }
634
- createRgbInputList() {
635
- const messages = this.messages();
636
- const red = {
637
- ariaLabel: messages.red,
638
- key: "r",
639
- label: "R",
640
- value: this.rgb().r,
641
- min: 0,
642
- max: 255,
643
- change: (value) => this.onRgbChange(value, "r")
644
- };
645
- const green = {
646
- ariaLabel: messages.green,
647
- key: "g",
648
- label: "G",
649
- value: this.rgb().g,
650
- min: 0,
651
- max: 255,
652
- change: (value) => this.onRgbChange(value, "g")
653
- };
654
- const blue = {
655
- ariaLabel: messages.blue,
656
- key: "b",
657
- label: "B",
658
- value: this.rgb().b,
659
- min: 0,
660
- max: 255,
661
- change: (value) => this.onRgbChange(value, "b")
662
- };
663
- return [red, green, blue];
664
- }
665
- emitValue() {
666
- const rgb = this.rgb();
667
- const alpha = this.alpha();
668
- if (rgb.r == null || rgb.g == null || rgb.b == null || alpha == null) {
669
- this.commitValue(null);
670
- return;
671
- }
672
- const format = this.format();
673
- if (format === "hex") {
674
- this.commitValue(rgba2hex(rgb.r, rgb.g, rgb.b, alpha));
675
- }
676
- else if (format === "rgb") {
677
- this.commitValue(`rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${formatAlpha(alpha)})`);
678
- }
679
- else if (format === "hsl") {
680
- const hsl = rgba2hsla(rgb.r, rgb.g, rgb.b, alpha);
681
- this.commitValue(`hsla(${hsl.h}, ${hsl.s}%, ${hsl.l}%, ${formatAlpha(alpha)})`);
682
- }
683
- }
684
- getValidChannelValue(value, channel) {
685
- if (channel === "r" || channel === "g" || channel === "b" || channel === "a") {
686
- return Math.min(255, Math.max(0, value));
687
- }
688
- if (channel === "h") {
689
- return Math.min(360, Math.max(0, value));
690
- }
691
- if (channel === "s" || channel === "v") {
692
- return Math.min(100, Math.max(0, value));
693
- }
694
- return value;
695
- }
696
- loadColorFromString(color) {
697
- const rgba = parseColor(color, this.#document);
698
- if (!rgba && color.trim() && isDevMode()) {
699
- console.warn(`[Mona Color Gradient] Can't read the color "${color}", so the controls show no color. The value stays ` +
700
- "as it is until a user changes it.", this.#hostElementRef.nativeElement);
701
- }
702
- if (!rgba) {
703
- this.clear();
704
- return;
705
- }
706
- const hsv = rgba2hsva(rgba.r, rgba.g, rgba.b, rgba.a);
707
- this.hsv.set({ h: hsv.h, s: hsv.s, v: hsv.v });
708
- this.updateRgb(rgba);
709
- this.alpha.set(rgba.a ?? 255);
710
- this.updateHexInputValue();
711
- }
712
- /**
713
- * Shows a value in the controls, dropping any edit that wasn't applied.
714
- */
715
- loadValue(value) {
716
- this.#edited = false;
717
- if (value === undefined) {
718
- this.hsv.set({ ...DEFAULT_HSV });
719
- this.rgb.set({ ...DEFAULT_RGB });
720
- this.alpha.set(255);
721
- this.updateHexInputValue();
722
- }
723
- else if (value === null) {
724
- this.clear();
725
- }
726
- else {
727
- this.loadColorFromString(value);
728
- }
729
- this.lastSelectedColor.set(this.hex());
730
- }
731
- moveHandleToPointer(event) {
732
- const { height, left, top, width } = this.hsvRectangle().nativeElement.getBoundingClientRect();
733
- if (width <= 0 || height <= 0) {
734
- return;
735
- }
736
- this.updateHsvValues(((event.clientX - left) / width) * 100, 100 - ((event.clientY - top) / height) * 100);
737
- this.updateHexInputValue();
738
- }
739
- /**
740
- * Pressing anywhere in the area starts a drag. Capturing the pointer keeps the moves coming when it leaves the area,
741
- * and the press itself mustn't take focus away from the handle.
742
- */
743
- setHsvRectPointerEvents() {
744
- const area = this.hsvRectangle().nativeElement;
745
- const isPrimaryPress = (event) => event.button === 0 && !event.ctrlKey && !this.interactionDisabled();
746
- fromEvent(area, "mousedown")
747
- .pipe(filter(isPrimaryPress), takeUntilDestroyed(this.#destroyRef))
748
- .subscribe(event => event.preventDefault());
749
- fromEvent(area, "pointerdown")
750
- .pipe(filter(event => isPrimaryPress(event) && event.isPrimary), tap(event => {
751
- area.setPointerCapture?.(event.pointerId);
752
- this.hsvHandle().nativeElement.focus({ preventScroll: true });
753
- this.moveHandleToPointer(event);
754
- }), switchMap(({ pointerId }) => {
755
- const isSamePointer = (event) => event.pointerId === pointerId;
756
- const end$ = merge(fromEvent(area, "pointerup"), fromEvent(area, "pointercancel"), fromEvent(area, "lostpointercapture")).pipe(filter(isSamePointer));
757
- return fromEvent(area, "pointermove").pipe(filter(isSamePointer), takeUntil(end$));
758
- }), takeUntilDestroyed(this.#destroyRef))
759
- .subscribe(event => this.moveHandleToPointer(event));
760
- }
761
- syncValue(value) {
762
- if (value === undefined) {
763
- return;
764
- }
765
- if (this.#internalValueUpdatePending && value === this.#lastInternalValue) {
766
- this.#internalValueUpdatePending = false;
767
- this.#lastInternalValue = undefined;
768
- return;
769
- }
770
- this.#internalValueUpdatePending = false;
771
- this.#lastInternalValue = undefined;
772
- this.loadValue(value);
773
- }
774
- updateHexInputValue() {
775
- const rgb = this.rgb();
776
- const hex = rgba2hex(rgb.r, rgb.g, rgb.b, this.alpha());
777
- this.hexInputValue.set(hex);
778
- }
779
- updateHsvValues(saturation, value) {
780
- this.#edited = true;
781
- this.hsv.update(c => ({
782
- ...c,
783
- h: c.h ?? 0,
784
- s: this.getValidChannelValue(saturation, "s"),
785
- v: this.getValidChannelValue(value, "v")
786
- }));
787
- this.updateRgbFromHsv();
788
- }
789
- updateOtherNullChannels(channel) {
790
- if (channel === "r" || channel === "g" || channel === "b") {
791
- this.rgb.update(c => ({ ...c, r: c.r ?? 0, g: c.g ?? 0, b: c.b ?? 0 }));
792
- }
793
- else if (channel === "h" || channel === "s" || channel === "v") {
794
- this.hsv.update(c => ({ ...c, h: c.h ?? 0, s: c.s ?? 0, v: c.v ?? 0 }));
795
- }
796
- else if (channel === "a") {
797
- this.alpha.set(this.alpha() ?? 255);
798
- }
799
- }
800
- updateRgb(rgba) {
801
- this.rgb.update(c => ({ ...c, r: rgba.r, g: rgba.g, b: rgba.b }));
802
- }
803
- updateRgbFromHsv() {
804
- const hsv = this.hsv();
805
- const hue = hsv.h ?? 0;
806
- const saturation = hsv.s ?? 0;
807
- const value = hsv.v ?? 0;
808
- const rgb = hsva2rgba(hue, saturation, value, this.alpha());
809
- if (this.rgb().r === rgb.r && this.rgb().g === rgb.g && this.rgb().b === rgb.b) {
810
- return;
811
- }
812
- this.rgb.update(c => ({ ...c, r: rgb.r, g: rgb.g, b: rgb.b }));
813
- if (!this.showButtons()) {
814
- this.emitValue();
815
- }
816
- }
817
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ColorGradientComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
818
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: ColorGradientComponent, isStandalone: true, selector: "mona-color-gradient", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, opacity: { classPropertyName: "opacity", publicName: "opacity", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, showButtons: { classPropertyName: "showButtons", publicName: "showButtons", isSignal: true, isRequired: false, transformFunction: null }, showColorInputs: { classPropertyName: "showColorInputs", publicName: "showColorInputs", isSignal: true, isRequired: false, transformFunction: null }, showHexInput: { classPropertyName: "showHexInput", publicName: "showHexInput", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { apply: "apply", cancel: "cancel", touch: "touch", value: "valueChange" }, host: { listeners: { "focusout": "onFocusOut($event)" }, properties: { "class": "baseClasses()", "attr.data-disabled": "effectiveDisabled()", "attr.data-readonly": "readonly() || null", "attr.data-invalid": "invalidState() || null", "attr.role": "'group'", "attr.aria-label": "labelledBy() ? null : ariaLabel() || messages().colorGradient", "attr.aria-labelledby": "labelledBy()", "attr.aria-invalid": "invalidState() ? 'true' : null" } }, viewQueries: [{ propertyName: "hsvHandle", first: true, predicate: ["hsvPointer"], descendants: true, isSignal: true }, { propertyName: "hsvRectangle", first: true, predicate: ["hsvRectangle"], descendants: true, isSignal: true }], ngImport: i0, template: "<div [class]=\"hsvRectangleClasses()\" [style.background-color]=\"hsvRectangleBackground()\" #hsvRectangle>\n <div\n [class]=\"hsvRectangleHandleClasses()\"\n [style.left.%]=\"hsv().s ?? 0\"\n [style.top.%]=\"100 - (hsv().v ?? 100)\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\n [attr.role]=\"'slider'\"\n [attr.aria-label]=\"messages().saturationAndValue\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"100\"\n [attr.aria-valuenow]=\"roundedSaturation()\"\n [attr.aria-valuetext]=\"messages().saturationAndValueText(roundedSaturation(), roundedValue())\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (keydown)=\"onHsvHandleKeyDown($event)\"\n #hsvPointer></div>\n</div>\n<div class=\"flex items-center gap-2\">\n <div class=\"flex flex-1 flex-col gap-1 me-2 forced-color-adjust-none\">\n <mona-slider\n dir=\"ltr\"\n [aria-label]=\"messages().hue\"\n [minValue]=\"0\"\n [maxValue]=\"360\"\n [trackBackground]=\"'linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)'\"\n [selectionBackground]=\"'transparent'\"\n [handleClasses]=\"sliderHandleClasses()\"\n [trackSize]=\"sliderHeight\"\n [rounded]=\"rounded()\"\n [value]=\"roundedHue()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onHueChange($event)\"></mona-slider>\n @if (opacity()) {\n <mona-slider\n dir=\"ltr\"\n [aria-label]=\"messages().alpha\"\n [ariaValueText]=\"alphaValueText()\"\n [minValue]=\"0\"\n [maxValue]=\"255\"\n [trackBackground]=\"alphaSliderBackground()\"\n [selectionBackground]=\"'transparent'\"\n [handleClasses]=\"sliderHandleClasses()\"\n [trackSize]=\"sliderHeight\"\n [rounded]=\"rounded()\"\n [value]=\"alpha()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onAlphaChange($event)\"></mona-slider>\n }\n </div>\n @for (preview of colorPreviews(); track preview.type) {\n <div\n [class]=\"colorPreviewClasses()\"\n [class.cursor-pointer]=\"$index === 1\"\n [style.background-color]=\"preview.color\"\n [attr.title]=\"$index === 1 ? preview.title : null\"\n [attr.aria-label]=\"$index === 1 ? preview.title : null\"\n [attr.aria-hidden]=\"$index === 0 ? 'true' : null\"\n [attr.aria-disabled]=\"$index === 1 && interactionDisabled() ? 'true' : null\"\n [attr.role]=\"$index === 1 ? 'button' : null\"\n [attr.tabindex]=\"$index === 1 && !interactionDisabled() ? 0 : null\"\n (click)=\"preview.onClick?.()\"\n (keydown)=\"onPreviousColorKeyDown($event, preview.onClick)\"></div>\n }\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [disabled]=\"interactionDisabled()\"\n [attr.aria-label]=\"messages().clearColor\"\n (click)=\"onClearClick()\">\n <svg lucideDropletOff [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n</div>\n<div class=\"flex flex-col gap-2\">\n @if (showColorInputs()) {\n <div class=\"flex gap-2\">\n <div class=\"flex gap-1\">\n @for (input of colorInputs(); track input.key) {\n <mona-numeric-text-box\n [aria-label]=\"input.ariaLabel\"\n [value]=\"input.value\"\n [minValue]=\"input.min\"\n [maxValue]=\"input.max\"\n [decimals]=\"0\"\n [spinners]=\"false\"\n [nullable]=\"false\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n class=\"w-18\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"input.change($event)\">\n <ng-template monaNumericTextBoxPrefixTemplate>\n <ng-container\n [ngTemplateOutlet]=\"numericInputPrefixTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: input.label }\"></ng-container>\n </ng-template>\n </mona-numeric-text-box>\n }\n </div>\n <div class=\"flex flex-1 items-center justify-end\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n size=\"small\"\n [disabled]=\"effectiveDisabled()\"\n [attr.aria-label]=\"messages().switchColorMode\"\n (click)=\"onSwitchColorModeClick()\">\n <svg lucideChevronsUpDown [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n </div>\n </div>\n }\n @if (showHexInput()) {\n <mona-text-box\n [aria-label]=\"messages().hexColor\"\n [rounded]=\"rounded()\"\n [value]=\"hex()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onHexChange($event)\"\n (inputBlur)=\"onHexInputBlur()\"\n (inputFocus)=\"onHexInputFocus()\"\n class=\"w-full\">\n <ng-template monaTextBoxPrefixTemplate>\n <ng-container\n [ngTemplateOutlet]=\"numericInputPrefixTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: 'HEX', classes: 'w-auto px-2' }\"></ng-container>\n </ng-template>\n <ng-template monaTextBoxSuffixTemplate>\n <mona-dropdown-button\n look=\"ghost\"\n [disabled]=\"effectiveDisabled() || !selectedColor()\"\n [iconOnly]=\"true\"\n [aria-label]=\"messages().copyColor\"\n class=\"h-full\">\n <ng-template monaDropdownButtonTextTemplate>\n <svg lucideCopy [size]=\"12\" aria-hidden=\"true\"></svg>\n </ng-template>\n <mona-dropdown-button-item\n [label]=\"messages().copyAsHex\"\n (menuClick)=\"onCopyColorSelect('hex')\"></mona-dropdown-button-item>\n <mona-dropdown-button-item\n [label]=\"messages().copyAsRgb\"\n (menuClick)=\"onCopyColorSelect('rgb')\"></mona-dropdown-button-item>\n </mona-dropdown-button>\n </ng-template>\n </mona-text-box>\n }\n @if (showButtons()) {\n <div class=\"flex items-center justify-end gap-2\">\n <button\n monaButton\n [rounded]=\"rounded()\"\n look=\"primary\"\n [disabled]=\"interactionDisabled()\"\n (click)=\"onApply()\">\n {{ messages().apply }}\n </button>\n <button monaButton [rounded]=\"rounded()\" [disabled]=\"effectiveDisabled()\" (click)=\"onCancel()\">\n {{ messages().cancel }}\n </button>\n </div>\n }\n</div>\n\n<ng-template #numericInputPrefixTemplate let-text let-classes=\"classes\">\n <span\n [class]=\"classes\"\n class=\"inline-flex items-center justify-center select-none w-7.5 [background-color:var(--mona-input-addon-background,var(--color-secondary))] h-full text-foreground text-xs font-semibold border-e border-e-input-border\"\n aria-hidden=\"true\"\n >{{ text }}</span\n >\n</ng-template>\n", dependencies: [{ kind: "component", type: LucideDropletOff, selector: "svg[lucideDropletOff]" }, { kind: "component", type: LucideChevronsUpDown, selector: "svg[lucideChevronsUpDown]" }, { kind: "component", type: NumericTextBoxComponent, selector: "mona-numeric-text-box", inputs: ["formatter", "maxValue", "minValue", "step", "value"], outputs: ["valueChange"] }, { kind: "directive", type: NumericTextBoxPrefixTemplateDirective, selector: "ng-template[monaNumericTextBoxPrefixTemplate]" }, { kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class", "value"], outputs: ["lookChange", "selectedChange"] }, { kind: "component", type: TextBoxComponent, selector: "mona-text-box", inputs: ["aria-describedby", "aria-label", "aria-labelledby", "clearButton", "disabled", "inputAttributes", "inputClass", "inputId", "inputStyle", "invalid", "maxLength", "minLength", "name", "placeholder", "readonly", "required", "rounded", "size", "touched", "type", "class", "value"], outputs: ["inputBlur", "inputFocus", "touch", "valueChange"] }, { kind: "directive", type: TextBoxPrefixTemplateDirective, selector: "ng-template[monaTextBoxPrefixTemplate]" }, { kind: "directive", type: TextBoxSuffixTemplateDirective, selector: "ng-template[monaTextBoxSuffixTemplate]" }, { kind: "component", type: SliderComponent, selector: "mona-slider", inputs: ["max", "min", "value"], outputs: ["valueChange"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: DropdownButtonComponent, selector: "mona-dropdown-button", inputs: ["aria-label", "aria-labelledby", "disabled", "iconOnly", "loading", "look", "popupWidth", "rounded", "showArrow", "size", "text", "class"], outputs: ["menuItemClick"] }, { kind: "component", type: DropdownButtonItemComponent, selector: "mona-dropdown-button-item" }, { kind: "directive", type: DropdownButtonTextTemplateDirective, selector: "ng-template[monaDropdownButtonTextTemplate]" }, { kind: "component", type: LucideCopy, selector: "svg[lucideCopy]" }] }); }
819
- }
820
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ColorGradientComponent, decorators: [{
821
- type: Component,
822
- args: [{ selector: "mona-color-gradient", imports: [
823
- LucideDropletOff,
824
- LucideChevronsUpDown,
825
- NumericTextBoxComponent,
826
- NumericTextBoxPrefixTemplateDirective,
827
- ButtonDirective,
828
- TextBoxComponent,
829
- TextBoxPrefixTemplateDirective,
830
- TextBoxSuffixTemplateDirective,
831
- SliderComponent,
832
- NgTemplateOutlet,
833
- DropdownButtonComponent,
834
- DropdownButtonItemComponent,
835
- DropdownButtonTextTemplateDirective,
836
- LucideCopy
837
- ], host: {
838
- "[class]": "baseClasses()",
839
- "[attr.data-disabled]": "effectiveDisabled()",
840
- "[attr.data-readonly]": "readonly() || null",
841
- "(focusout)": "onFocusOut($event)",
842
- "[attr.data-invalid]": "invalidState() || null",
843
- "[attr.role]": "'group'",
844
- "[attr.aria-label]": "labelledBy() ? null : ariaLabel() || messages().colorGradient",
845
- "[attr.aria-labelledby]": "labelledBy()",
846
- "[attr.aria-invalid]": "invalidState() ? 'true' : null"
847
- }, template: "<div [class]=\"hsvRectangleClasses()\" [style.background-color]=\"hsvRectangleBackground()\" #hsvRectangle>\n <div\n [class]=\"hsvRectangleHandleClasses()\"\n [style.left.%]=\"hsv().s ?? 0\"\n [style.top.%]=\"100 - (hsv().v ?? 100)\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\n [attr.role]=\"'slider'\"\n [attr.aria-label]=\"messages().saturationAndValue\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"100\"\n [attr.aria-valuenow]=\"roundedSaturation()\"\n [attr.aria-valuetext]=\"messages().saturationAndValueText(roundedSaturation(), roundedValue())\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (keydown)=\"onHsvHandleKeyDown($event)\"\n #hsvPointer></div>\n</div>\n<div class=\"flex items-center gap-2\">\n <div class=\"flex flex-1 flex-col gap-1 me-2 forced-color-adjust-none\">\n <mona-slider\n dir=\"ltr\"\n [aria-label]=\"messages().hue\"\n [minValue]=\"0\"\n [maxValue]=\"360\"\n [trackBackground]=\"'linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)'\"\n [selectionBackground]=\"'transparent'\"\n [handleClasses]=\"sliderHandleClasses()\"\n [trackSize]=\"sliderHeight\"\n [rounded]=\"rounded()\"\n [value]=\"roundedHue()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onHueChange($event)\"></mona-slider>\n @if (opacity()) {\n <mona-slider\n dir=\"ltr\"\n [aria-label]=\"messages().alpha\"\n [ariaValueText]=\"alphaValueText()\"\n [minValue]=\"0\"\n [maxValue]=\"255\"\n [trackBackground]=\"alphaSliderBackground()\"\n [selectionBackground]=\"'transparent'\"\n [handleClasses]=\"sliderHandleClasses()\"\n [trackSize]=\"sliderHeight\"\n [rounded]=\"rounded()\"\n [value]=\"alpha()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onAlphaChange($event)\"></mona-slider>\n }\n </div>\n @for (preview of colorPreviews(); track preview.type) {\n <div\n [class]=\"colorPreviewClasses()\"\n [class.cursor-pointer]=\"$index === 1\"\n [style.background-color]=\"preview.color\"\n [attr.title]=\"$index === 1 ? preview.title : null\"\n [attr.aria-label]=\"$index === 1 ? preview.title : null\"\n [attr.aria-hidden]=\"$index === 0 ? 'true' : null\"\n [attr.aria-disabled]=\"$index === 1 && interactionDisabled() ? 'true' : null\"\n [attr.role]=\"$index === 1 ? 'button' : null\"\n [attr.tabindex]=\"$index === 1 && !interactionDisabled() ? 0 : null\"\n (click)=\"preview.onClick?.()\"\n (keydown)=\"onPreviousColorKeyDown($event, preview.onClick)\"></div>\n }\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [disabled]=\"interactionDisabled()\"\n [attr.aria-label]=\"messages().clearColor\"\n (click)=\"onClearClick()\">\n <svg lucideDropletOff [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n</div>\n<div class=\"flex flex-col gap-2\">\n @if (showColorInputs()) {\n <div class=\"flex gap-2\">\n <div class=\"flex gap-1\">\n @for (input of colorInputs(); track input.key) {\n <mona-numeric-text-box\n [aria-label]=\"input.ariaLabel\"\n [value]=\"input.value\"\n [minValue]=\"input.min\"\n [maxValue]=\"input.max\"\n [decimals]=\"0\"\n [spinners]=\"false\"\n [nullable]=\"false\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n class=\"w-18\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"input.change($event)\">\n <ng-template monaNumericTextBoxPrefixTemplate>\n <ng-container\n [ngTemplateOutlet]=\"numericInputPrefixTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: input.label }\"></ng-container>\n </ng-template>\n </mona-numeric-text-box>\n }\n </div>\n <div class=\"flex flex-1 items-center justify-end\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n size=\"small\"\n [disabled]=\"effectiveDisabled()\"\n [attr.aria-label]=\"messages().switchColorMode\"\n (click)=\"onSwitchColorModeClick()\">\n <svg lucideChevronsUpDown [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n </div>\n </div>\n }\n @if (showHexInput()) {\n <mona-text-box\n [aria-label]=\"messages().hexColor\"\n [rounded]=\"rounded()\"\n [value]=\"hex()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onHexChange($event)\"\n (inputBlur)=\"onHexInputBlur()\"\n (inputFocus)=\"onHexInputFocus()\"\n class=\"w-full\">\n <ng-template monaTextBoxPrefixTemplate>\n <ng-container\n [ngTemplateOutlet]=\"numericInputPrefixTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: 'HEX', classes: 'w-auto px-2' }\"></ng-container>\n </ng-template>\n <ng-template monaTextBoxSuffixTemplate>\n <mona-dropdown-button\n look=\"ghost\"\n [disabled]=\"effectiveDisabled() || !selectedColor()\"\n [iconOnly]=\"true\"\n [aria-label]=\"messages().copyColor\"\n class=\"h-full\">\n <ng-template monaDropdownButtonTextTemplate>\n <svg lucideCopy [size]=\"12\" aria-hidden=\"true\"></svg>\n </ng-template>\n <mona-dropdown-button-item\n [label]=\"messages().copyAsHex\"\n (menuClick)=\"onCopyColorSelect('hex')\"></mona-dropdown-button-item>\n <mona-dropdown-button-item\n [label]=\"messages().copyAsRgb\"\n (menuClick)=\"onCopyColorSelect('rgb')\"></mona-dropdown-button-item>\n </mona-dropdown-button>\n </ng-template>\n </mona-text-box>\n }\n @if (showButtons()) {\n <div class=\"flex items-center justify-end gap-2\">\n <button\n monaButton\n [rounded]=\"rounded()\"\n look=\"primary\"\n [disabled]=\"interactionDisabled()\"\n (click)=\"onApply()\">\n {{ messages().apply }}\n </button>\n <button monaButton [rounded]=\"rounded()\" [disabled]=\"effectiveDisabled()\" (click)=\"onCancel()\">\n {{ messages().cancel }}\n </button>\n </div>\n }\n</div>\n\n<ng-template #numericInputPrefixTemplate let-text let-classes=\"classes\">\n <span\n [class]=\"classes\"\n class=\"inline-flex items-center justify-center select-none w-7.5 [background-color:var(--mona-input-addon-background,var(--color-secondary))] h-full text-foreground text-xs font-semibold border-e border-e-input-border\"\n aria-hidden=\"true\"\n >{{ text }}</span\n >\n</ng-template>\n" }]
848
- }], ctorParameters: () => [], propDecorators: { hsvHandle: [{ type: i0.ViewChild, args: ["hsvPointer", { isSignal: true }] }], hsvRectangle: [{ type: i0.ViewChild, args: ["hsvRectangle", { isSignal: true }] }], apply: [{ type: i0.Output, args: ["apply"] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], cancel: [{ type: i0.Output, args: ["cancel"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], opacity: [{ type: i0.Input, args: [{ isSignal: true, alias: "opacity", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], showButtons: [{ type: i0.Input, args: [{ isSignal: true, alias: "showButtons", required: false }] }], showColorInputs: [{ type: i0.Input, args: [{ isSignal: true, alias: "showColorInputs", required: false }] }], showHexInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "showHexInput", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
849
-
850
- /*
851
- * Public API Surface of @nanahoshi/mona-ui/color-gradient
852
- */
853
-
854
- /**
855
- * Generated bundle index. Do not edit.
856
- */
857
-
106
+ const DEFAULT_HSV = {
107
+ h: 0,
108
+ s: 0,
109
+ v: 100
110
+ };
111
+ const DEFAULT_RGB = {
112
+ r: 255,
113
+ g: 255,
114
+ b: 255
115
+ };
116
+ var ColorGradientComponent = class ColorGradientComponent {
117
+ #announcer;
118
+ #clipboard;
119
+ #destroyRef;
120
+ #document;
121
+ #hostElementRef;
122
+ #i18n;
123
+ #label;
124
+ #viewReady;
125
+ #edited;
126
+ #internalValueUpdatePending;
127
+ #lastInternalValue;
128
+ constructor() {
129
+ this.#announcer = inject(LiveAnnouncer);
130
+ this.#clipboard = inject(Clipboard);
131
+ this.#destroyRef = inject(DestroyRef);
132
+ this.#document = inject(DOCUMENT);
133
+ this.#hostElementRef = inject(ElementRef);
134
+ this.#i18n = inject(MonaI18nService);
135
+ this.#label = injectLabelAssociation({
136
+ activate: () => this.focus(),
137
+ ariaLabel: () => this.ariaLabel(),
138
+ ariaLabelledBy: () => this.ariaLabelledBy()
139
+ });
140
+ this.#viewReady = signal(false, ...ngDevMode ? [{ debugName: "#viewReady" }] : /* istanbul ignore next */ []);
141
+ this.#edited = false;
142
+ this.#internalValueUpdatePending = false;
143
+ this.#lastInternalValue = void 0;
144
+ this.alpha = signal(255, ...ngDevMode ? [{ debugName: "alpha" }] : /* istanbul ignore next */ []);
145
+ this.alphaInputColor = computed(() => {
146
+ const rgb = this.rgb();
147
+ return rgba2hex(rgb.r ?? 0, rgb.g ?? 0, rgb.b ?? 0, 255);
148
+ }, ...ngDevMode ? [{ debugName: "alphaInputColor" }] : /* istanbul ignore next */ []);
149
+ this.alphaSliderBackground = computed(() => {
150
+ return `linear-gradient(to right, transparent, ${this.alphaInputColor()})`;
151
+ }, ...ngDevMode ? [{ debugName: "alphaSliderBackground" }] : /* istanbul ignore next */ []);
152
+ this.alphaValueText = computed(() => {
153
+ const { alphaText } = this.messages();
154
+ return (alpha) => alphaText(Math.round(alpha / 255 * 100));
155
+ }, ...ngDevMode ? [{ debugName: "alphaValueText" }] : /* istanbul ignore next */ []);
156
+ this.baseClasses = computed(() => {
157
+ return colorGradientBaseThemeVariants();
158
+ }, ...ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []);
159
+ this.colorInputs = computed(() => {
160
+ const baseInputs = this.colorMode() === "rgb" ? this.createRgbInputList() : this.createHsvInputList();
161
+ if (this.opacity()) baseInputs.push({
162
+ ariaLabel: this.messages().alpha,
163
+ key: "a",
164
+ label: "A",
165
+ value: this.alpha(),
166
+ min: 0,
167
+ max: 255,
168
+ change: (value) => this.onAlphaChange(value)
169
+ });
170
+ return baseInputs;
171
+ }, ...ngDevMode ? [{ debugName: "colorInputs" }] : /* istanbul ignore next */ []);
172
+ this.colorMode = signal("rgb", ...ngDevMode ? [{ debugName: "colorMode" }] : /* istanbul ignore next */ []);
173
+ this.colorPreviewClasses = computed(() => {
174
+ const rounded = this.rounded();
175
+ return colorGradientPreviewThemeVariants({ rounded });
176
+ }, ...ngDevMode ? [{ debugName: "colorPreviewClasses" }] : /* istanbul ignore next */ []);
177
+ this.colorPreviews = computed(() => [{
178
+ type: "current",
179
+ color: this.selectedColor(),
180
+ title: this.messages().currentColor
181
+ }, {
182
+ type: "last",
183
+ color: this.lastSelectedColor(),
184
+ title: this.messages().previousColor,
185
+ onClick: () => this.onResetColorClick()
186
+ }], ...ngDevMode ? [{ debugName: "colorPreviews" }] : /* istanbul ignore next */ []);
187
+ this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
188
+ this.hex = computed(() => {
189
+ const rgb = this.rgb();
190
+ const alpha = this.alpha();
191
+ if (!this.hexFocused()) return rgba2hex(rgb.r, rgb.g, rgb.b, alpha);
192
+ return this.hexInputValue();
193
+ }, ...ngDevMode ? [{ debugName: "hex" }] : /* istanbul ignore next */ []);
194
+ this.hexFocused = signal(false, ...ngDevMode ? [{ debugName: "hexFocused" }] : /* istanbul ignore next */ []);
195
+ this.hexInputValue = signal("", ...ngDevMode ? [{ debugName: "hexInputValue" }] : /* istanbul ignore next */ []);
196
+ this.hsv = signal({ ...DEFAULT_HSV }, ...ngDevMode ? [{ debugName: "hsv" }] : /* istanbul ignore next */ []);
197
+ this.hsvHandle = viewChild.required("hsvPointer", ...ngDevMode ? [{ debugName: "hsvHandle" }] : /* istanbul ignore next */ []);
198
+ this.hsvRectangle = viewChild.required("hsvRectangle", ...ngDevMode ? [{ debugName: "hsvRectangle" }] : /* istanbul ignore next */ []);
199
+ this.hsvRectangleBackground = computed(() => {
200
+ const rgb = hsva2rgba(this.hsv().h ?? 0, 100, 100, 255);
201
+ return `rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`;
202
+ }, ...ngDevMode ? [{ debugName: "hsvRectangleBackground" }] : /* istanbul ignore next */ []);
203
+ this.hsvRectangleClasses = computed(() => {
204
+ const rounded = this.rounded() === "full" ? "large" : this.rounded();
205
+ return colorGradientHsvRectangleThemeVariants({ rounded });
206
+ }, ...ngDevMode ? [{ debugName: "hsvRectangleClasses" }] : /* istanbul ignore next */ []);
207
+ this.hsvRectangleHandleClasses = computed(() => {
208
+ const rounded = this.rounded();
209
+ return colorGradientHsvRectangleHandleThemeVariants({ rounded });
210
+ }, ...ngDevMode ? [{ debugName: "hsvRectangleHandleClasses" }] : /* istanbul ignore next */ []);
211
+ this.interactionDisabled = computed(() => this.effectiveDisabled() || this.readonly(), ...ngDevMode ? [{ debugName: "interactionDisabled" }] : /* istanbul ignore next */ []);
212
+ this.invalidState = computed(() => this.touched() && (this.invalid() || this.required() && !this.value()), ...ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []);
213
+ this.labelledBy = this.#label.labelledBy;
214
+ this.lastSelectedColor = signal("", ...ngDevMode ? [{ debugName: "lastSelectedColor" }] : /* istanbul ignore next */ []);
215
+ this.messages = this.#i18n.componentMessages("colorGradient", COLOR_GRADIENT_DEFAULT_MESSAGES);
216
+ this.rgb = signal({ ...DEFAULT_RGB }, ...ngDevMode ? [{ debugName: "rgb" }] : /* istanbul ignore next */ []);
217
+ this.roundedHue = computed(() => Math.round(this.hsv().h ?? 0), ...ngDevMode ? [{ debugName: "roundedHue" }] : /* istanbul ignore next */ []);
218
+ this.roundedSaturation = computed(() => Math.round(this.hsv().s ?? 0), ...ngDevMode ? [{ debugName: "roundedSaturation" }] : /* istanbul ignore next */ []);
219
+ this.roundedValue = computed(() => Math.round(this.hsv().v ?? 0), ...ngDevMode ? [{ debugName: "roundedValue" }] : /* istanbul ignore next */ []);
220
+ this.selectedColor = computed(() => {
221
+ const rgb = this.rgb();
222
+ if (rgb.r == null || rgb.g == null || rgb.b == null) return "";
223
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${this.alpha() / 255})`;
224
+ }, ...ngDevMode ? [{ debugName: "selectedColor" }] : /* istanbul ignore next */ []);
225
+ this.sliderHandleClasses = computed(() => {
226
+ return colorGradientSliderHandleThemeVariants();
227
+ }, ...ngDevMode ? [{ debugName: "sliderHandleClasses" }] : /* istanbul ignore next */ []);
228
+ this.sliderHeight = 10;
229
+ this.apply = output();
230
+ this.ariaLabel = input("", {
231
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
232
+ alias: "aria-label"
233
+ });
234
+ this.ariaLabelledBy = input("", {
235
+ ...ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {},
236
+ alias: "aria-labelledby"
237
+ });
238
+ this.cancel = output();
239
+ this.disabled = input(false, {
240
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
241
+ transform: booleanAttribute
242
+ });
243
+ this.format = input("hex", ...ngDevMode ? [{ debugName: "format" }] : /* istanbul ignore next */ []);
244
+ this.invalid = input(false, {
245
+ ...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
246
+ transform: booleanAttribute
247
+ });
248
+ this.opacity = input(true, {
249
+ ...ngDevMode ? { debugName: "opacity" } : /* istanbul ignore next */ {},
250
+ transform: booleanAttribute
251
+ });
252
+ this.readonly = input(false, {
253
+ ...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
254
+ transform: booleanAttribute
255
+ });
256
+ this.required = input(false, {
257
+ ...ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {},
258
+ transform: booleanAttribute
259
+ });
260
+ this.rounded = input("medium", ...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
261
+ this.showButtons = input(true, {
262
+ ...ngDevMode ? { debugName: "showButtons" } : /* istanbul ignore next */ {},
263
+ transform: booleanAttribute
264
+ });
265
+ this.showColorInputs = input(true, {
266
+ ...ngDevMode ? { debugName: "showColorInputs" } : /* istanbul ignore next */ {},
267
+ transform: booleanAttribute
268
+ });
269
+ this.showHexInput = input(true, {
270
+ ...ngDevMode ? { debugName: "showHexInput" } : /* istanbul ignore next */ {},
271
+ transform: booleanAttribute
272
+ });
273
+ this.touch = output();
274
+ this.touched = input(false, {
275
+ ...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
276
+ transform: booleanAttribute
277
+ });
278
+ this.value = model(void 0, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
279
+ afterNextRender({ read: () => {
280
+ this.lastSelectedColor.set(this.hex());
281
+ this.setHsvRectPointerEvents();
282
+ this.#viewReady.set(true);
283
+ } });
284
+ effect(() => {
285
+ if (!this.#viewReady()) return;
286
+ const value = this.value();
287
+ untracked(() => this.syncValue(value));
288
+ });
289
+ }
290
+ focus(options) {
291
+ this.hsvHandle().nativeElement.focus(options);
292
+ }
293
+ setLabelledBy(id) {
294
+ this.#label.setLabelledBy(id);
295
+ }
296
+ onAlphaChange(value) {
297
+ if (value == null) return;
298
+ this.#edited = true;
299
+ const alpha = this.getValidChannelValue(value, "a");
300
+ this.alpha.set(alpha);
301
+ this.updateHexInputValue();
302
+ if (!this.showButtons()) this.emitValue();
303
+ }
304
+ onApply() {
305
+ if (this.interactionDisabled()) return;
306
+ if (this.#edited || this.value() === void 0) {
307
+ this.lastSelectedColor.set(this.hex());
308
+ this.emitValue();
309
+ }
310
+ this.#edited = false;
311
+ this.apply.emit();
312
+ }
313
+ onCancel() {
314
+ this.loadValue(this.value());
315
+ this.cancel.emit();
316
+ }
317
+ onClearClick() {
318
+ if (this.interactionDisabled()) return;
319
+ this.#edited = true;
320
+ this.clear();
321
+ if (!this.showButtons()) this.commitValue(null);
322
+ }
323
+ onCopyColorSelect(mode) {
324
+ const rgb = this.rgb();
325
+ const text = mode === "hex" ? rgba2hex(rgb.r, rgb.g, rgb.b, this.alpha()) : `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${formatAlpha(this.alpha())})`;
326
+ const copied = this.#clipboard.copy(text);
327
+ this.#announcer.announce(copied ? this.messages().colorCopied : this.messages().copyFailed);
328
+ }
329
+ onFocusOut(event) {
330
+ const nextTarget = event.relatedTarget;
331
+ if (nextTarget instanceof Node && this.#hostElementRef.nativeElement.contains(nextTarget)) return;
332
+ this.touch.emit();
333
+ }
334
+ onHexChange(value) {
335
+ this.hexInputValue.set(value);
336
+ if (!isValidHex(value)) return;
337
+ this.#edited = true;
338
+ const rgb = hex2rgba(value);
339
+ const hsv = rgba2hsva(rgb.r, rgb.g, rgb.b, rgb.a);
340
+ this.hsv.update((c) => ({
341
+ ...c,
342
+ h: hsv.h,
343
+ s: hsv.s,
344
+ v: hsv.v
345
+ }));
346
+ this.rgb.update((c) => ({
347
+ ...c,
348
+ r: rgb.r,
349
+ g: rgb.g,
350
+ b: rgb.b
351
+ }));
352
+ this.alpha.set(rgb.a ?? 255);
353
+ if (!this.showButtons()) this.emitValue();
354
+ }
355
+ onHexInputBlur() {
356
+ this.hexFocused.set(false);
357
+ this.updateHexInputValue();
358
+ }
359
+ onHexInputFocus() {
360
+ this.updateHexInputValue();
361
+ this.hexFocused.set(true);
362
+ }
363
+ onHsvChange(value, channel) {
364
+ if (value == null) return;
365
+ this.#edited = true;
366
+ value = this.getValidChannelValue(value, channel);
367
+ this.hsv.update((c) => ({
368
+ ...c,
369
+ [channel]: value
370
+ }));
371
+ this.updateOtherNullChannels(channel);
372
+ const hsv = this.hsv();
373
+ const rgb = hsva2rgba(hsv.h, hsv.s, hsv.v, this.alpha());
374
+ this.rgb.update((c) => ({
375
+ ...c,
376
+ r: rgb.r,
377
+ g: rgb.g,
378
+ b: rgb.b
379
+ }));
380
+ this.updateHexInputValue();
381
+ if (!this.showButtons()) this.emitValue();
382
+ }
383
+ onHsvHandleKeyDown(event) {
384
+ if (this.interactionDisabled()) return;
385
+ const step = event.shiftKey ? 10 : 1;
386
+ const largeStep = 25;
387
+ let handled = false;
388
+ const currentHsv = this.hsv();
389
+ const currentSaturation = currentHsv.s ?? 0;
390
+ const currentValue = currentHsv.v ?? 0;
391
+ let newSaturation = currentSaturation;
392
+ let newValue = currentValue;
393
+ switch (event.key) {
394
+ case "ArrowLeft":
395
+ newSaturation = this.getValidChannelValue(currentSaturation - step, "s");
396
+ handled = true;
397
+ break;
398
+ case "ArrowRight":
399
+ newSaturation = this.getValidChannelValue(currentSaturation + step, "s");
400
+ handled = true;
401
+ break;
402
+ case "ArrowUp":
403
+ newValue = this.getValidChannelValue(currentValue + step, "v");
404
+ handled = true;
405
+ break;
406
+ case "ArrowDown":
407
+ newValue = this.getValidChannelValue(currentValue - step, "v");
408
+ handled = true;
409
+ break;
410
+ case "Home":
411
+ newSaturation = 0;
412
+ newValue = 100;
413
+ handled = true;
414
+ break;
415
+ case "End":
416
+ newSaturation = 100;
417
+ newValue = 0;
418
+ handled = true;
419
+ break;
420
+ case "PageUp":
421
+ newValue = this.getValidChannelValue(currentValue + largeStep, "v");
422
+ handled = true;
423
+ break;
424
+ case "PageDown":
425
+ newValue = this.getValidChannelValue(currentValue - largeStep, "v");
426
+ handled = true;
427
+ }
428
+ if (handled) {
429
+ event.preventDefault();
430
+ event.stopPropagation();
431
+ this.updateHsvValues(newSaturation, newValue);
432
+ this.updateHexInputValue();
433
+ }
434
+ }
435
+ onHueChange(value) {
436
+ this.#edited = true;
437
+ this.hsv.update((c) => ({
438
+ ...c,
439
+ h: Math.round(value)
440
+ }));
441
+ this.updateOtherNullChannels("h");
442
+ this.updateRgbFromHsv();
443
+ this.updateHexInputValue();
444
+ }
445
+ onPreviousColorKeyDown(event, handler) {
446
+ if (event.key === "Enter" || event.key === " ") {
447
+ event.preventDefault();
448
+ handler?.();
449
+ }
450
+ }
451
+ onResetColorClick() {
452
+ if (this.interactionDisabled()) return;
453
+ this.onHexChange(this.lastSelectedColor());
454
+ }
455
+ onRgbChange(value, channel) {
456
+ if (value == null) return;
457
+ this.#edited = true;
458
+ value = this.getValidChannelValue(value, channel);
459
+ this.rgb.update((c) => ({
460
+ ...c,
461
+ [channel]: value
462
+ }));
463
+ this.updateOtherNullChannels(channel);
464
+ const rgb = this.rgb();
465
+ const hsv = rgba2hsva(rgb.r, rgb.g, rgb.b, this.alpha());
466
+ this.hsv.update((c) => ({
467
+ ...c,
468
+ h: hsv.h,
469
+ s: hsv.s,
470
+ v: hsv.v
471
+ }));
472
+ this.updateHexInputValue();
473
+ if (!this.showButtons()) this.emitValue();
474
+ }
475
+ onSwitchColorModeClick() {
476
+ this.colorMode.set(this.colorMode() === "rgb" ? "hsv" : "rgb");
477
+ }
478
+ clear() {
479
+ this.hexInputValue.set("");
480
+ this.rgb.update((c) => ({
481
+ ...c,
482
+ r: null,
483
+ g: null,
484
+ b: null
485
+ }));
486
+ this.alpha.set(255);
487
+ this.hsv.update((c) => ({
488
+ ...c,
489
+ h: null,
490
+ s: null,
491
+ v: null
492
+ }));
493
+ }
494
+ commitValue(value) {
495
+ if (value === this.value()) return;
496
+ this.#internalValueUpdatePending = true;
497
+ this.#lastInternalValue = value;
498
+ this.value.set(value);
499
+ }
500
+ createHsvInputList() {
501
+ const messages = this.messages();
502
+ return [
503
+ {
504
+ ariaLabel: messages.hue,
505
+ key: "h",
506
+ label: "H",
507
+ value: this.roundedHue(),
508
+ min: 0,
509
+ max: 360,
510
+ change: (value) => this.onHsvChange(value, "h")
511
+ },
512
+ {
513
+ ariaLabel: messages.saturation,
514
+ key: "s",
515
+ label: "S",
516
+ value: this.roundedSaturation(),
517
+ min: 0,
518
+ max: 100,
519
+ change: (value) => this.onHsvChange(value, "s")
520
+ },
521
+ {
522
+ ariaLabel: messages.value,
523
+ key: "v",
524
+ label: "V",
525
+ value: this.roundedValue(),
526
+ min: 0,
527
+ max: 100,
528
+ change: (value) => this.onHsvChange(value, "v")
529
+ }
530
+ ];
531
+ }
532
+ createRgbInputList() {
533
+ const messages = this.messages();
534
+ return [
535
+ {
536
+ ariaLabel: messages.red,
537
+ key: "r",
538
+ label: "R",
539
+ value: this.rgb().r,
540
+ min: 0,
541
+ max: 255,
542
+ change: (value) => this.onRgbChange(value, "r")
543
+ },
544
+ {
545
+ ariaLabel: messages.green,
546
+ key: "g",
547
+ label: "G",
548
+ value: this.rgb().g,
549
+ min: 0,
550
+ max: 255,
551
+ change: (value) => this.onRgbChange(value, "g")
552
+ },
553
+ {
554
+ ariaLabel: messages.blue,
555
+ key: "b",
556
+ label: "B",
557
+ value: this.rgb().b,
558
+ min: 0,
559
+ max: 255,
560
+ change: (value) => this.onRgbChange(value, "b")
561
+ }
562
+ ];
563
+ }
564
+ emitValue() {
565
+ const rgb = this.rgb();
566
+ const alpha = this.alpha();
567
+ if (rgb.r == null || rgb.g == null || rgb.b == null || alpha == null) {
568
+ this.commitValue(null);
569
+ return;
570
+ }
571
+ const format = this.format();
572
+ if (format === "hex") this.commitValue(rgba2hex(rgb.r, rgb.g, rgb.b, alpha));
573
+ else if (format === "rgb") this.commitValue(`rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${formatAlpha(alpha)})`);
574
+ else if (format === "hsl") {
575
+ const hsl = rgba2hsla(rgb.r, rgb.g, rgb.b, alpha);
576
+ this.commitValue(`hsla(${hsl.h}, ${hsl.s}%, ${hsl.l}%, ${formatAlpha(alpha)})`);
577
+ }
578
+ }
579
+ getValidChannelValue(value, channel) {
580
+ if (channel === "r" || channel === "g" || channel === "b" || channel === "a") return Math.min(255, Math.max(0, value));
581
+ if (channel === "h") return Math.min(360, Math.max(0, value));
582
+ if (channel === "s" || channel === "v") return Math.min(100, Math.max(0, value));
583
+ return value;
584
+ }
585
+ loadColorFromString(color) {
586
+ const rgba = parseColor(color, this.#document);
587
+ if (!rgba && color.trim() && isDevMode()) console.warn(`[Mona Color Gradient] Can't read the color "${color}", so the controls show no color. The value stays as it is until a user changes it.`, this.#hostElementRef.nativeElement);
588
+ if (!rgba) {
589
+ this.clear();
590
+ return;
591
+ }
592
+ const hsv = rgba2hsva(rgba.r, rgba.g, rgba.b, rgba.a);
593
+ this.hsv.set({
594
+ h: hsv.h,
595
+ s: hsv.s,
596
+ v: hsv.v
597
+ });
598
+ this.updateRgb(rgba);
599
+ this.alpha.set(rgba.a ?? 255);
600
+ this.updateHexInputValue();
601
+ }
602
+ loadValue(value) {
603
+ this.#edited = false;
604
+ if (value === void 0) {
605
+ this.hsv.set({ ...DEFAULT_HSV });
606
+ this.rgb.set({ ...DEFAULT_RGB });
607
+ this.alpha.set(255);
608
+ this.updateHexInputValue();
609
+ } else if (value === null) this.clear();
610
+ else this.loadColorFromString(value);
611
+ this.lastSelectedColor.set(this.hex());
612
+ }
613
+ moveHandleToPointer(event) {
614
+ const { height, left, top, width } = this.hsvRectangle().nativeElement.getBoundingClientRect();
615
+ if (width <= 0 || height <= 0) return;
616
+ this.updateHsvValues((event.clientX - left) / width * 100, 100 - (event.clientY - top) / height * 100);
617
+ this.updateHexInputValue();
618
+ }
619
+ setHsvRectPointerEvents() {
620
+ const area = this.hsvRectangle().nativeElement;
621
+ const isPrimaryPress = (event) => event.button === 0 && !event.ctrlKey && !this.interactionDisabled();
622
+ fromEvent(area, "mousedown").pipe(filter(isPrimaryPress), takeUntilDestroyed(this.#destroyRef)).subscribe((event) => event.preventDefault());
623
+ fromEvent(area, "pointerdown").pipe(filter((event) => isPrimaryPress(event) && event.isPrimary), tap((event) => {
624
+ area.setPointerCapture?.(event.pointerId);
625
+ this.hsvHandle().nativeElement.focus({ preventScroll: true });
626
+ this.moveHandleToPointer(event);
627
+ }), switchMap(({ pointerId }) => {
628
+ const isSamePointer = (event) => event.pointerId === pointerId;
629
+ const end$ = merge(fromEvent(area, "pointerup"), fromEvent(area, "pointercancel"), fromEvent(area, "lostpointercapture")).pipe(filter(isSamePointer));
630
+ return fromEvent(area, "pointermove").pipe(filter(isSamePointer), takeUntil(end$));
631
+ }), takeUntilDestroyed(this.#destroyRef)).subscribe((event) => this.moveHandleToPointer(event));
632
+ }
633
+ syncValue(value) {
634
+ if (value === void 0) return;
635
+ if (this.#internalValueUpdatePending && value === this.#lastInternalValue) {
636
+ this.#internalValueUpdatePending = false;
637
+ this.#lastInternalValue = void 0;
638
+ return;
639
+ }
640
+ this.#internalValueUpdatePending = false;
641
+ this.#lastInternalValue = void 0;
642
+ this.loadValue(value);
643
+ }
644
+ updateHexInputValue() {
645
+ const rgb = this.rgb();
646
+ const hex = rgba2hex(rgb.r, rgb.g, rgb.b, this.alpha());
647
+ this.hexInputValue.set(hex);
648
+ }
649
+ updateHsvValues(saturation, value) {
650
+ this.#edited = true;
651
+ this.hsv.update((c) => ({
652
+ ...c,
653
+ h: c.h ?? 0,
654
+ s: this.getValidChannelValue(saturation, "s"),
655
+ v: this.getValidChannelValue(value, "v")
656
+ }));
657
+ this.updateRgbFromHsv();
658
+ }
659
+ updateOtherNullChannels(channel) {
660
+ if (channel === "r" || channel === "g" || channel === "b") this.rgb.update((c) => ({
661
+ ...c,
662
+ r: c.r ?? 0,
663
+ g: c.g ?? 0,
664
+ b: c.b ?? 0
665
+ }));
666
+ else if (channel === "h" || channel === "s" || channel === "v") this.hsv.update((c) => ({
667
+ ...c,
668
+ h: c.h ?? 0,
669
+ s: c.s ?? 0,
670
+ v: c.v ?? 0
671
+ }));
672
+ else if (channel === "a") this.alpha.set(this.alpha() ?? 255);
673
+ }
674
+ updateRgb(rgba) {
675
+ this.rgb.update((c) => ({
676
+ ...c,
677
+ r: rgba.r,
678
+ g: rgba.g,
679
+ b: rgba.b
680
+ }));
681
+ }
682
+ updateRgbFromHsv() {
683
+ const hsv = this.hsv();
684
+ const hue = hsv.h ?? 0;
685
+ const saturation = hsv.s ?? 0;
686
+ const value = hsv.v ?? 0;
687
+ const rgb = hsva2rgba(hue, saturation, value, this.alpha());
688
+ if (this.rgb().r === rgb.r && this.rgb().g === rgb.g && this.rgb().b === rgb.b) return;
689
+ this.rgb.update((c) => ({
690
+ ...c,
691
+ r: rgb.r,
692
+ g: rgb.g,
693
+ b: rgb.b
694
+ }));
695
+ if (!this.showButtons()) this.emitValue();
696
+ }
697
+ static {
698
+ this.ɵfac = i0.ɵɵngDeclareFactory({
699
+ minVersion: "12.0.0",
700
+ version: "22.2.6",
701
+ ngImport: i0,
702
+ type: ColorGradientComponent,
703
+ deps: [],
704
+ target: i0.ɵɵFactoryTarget.Component
705
+ });
706
+ }
707
+ static {
708
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
709
+ minVersion: "17.0.0",
710
+ version: "22.2.6",
711
+ type: ColorGradientComponent,
712
+ isStandalone: true,
713
+ selector: "mona-color-gradient",
714
+ inputs: {
715
+ ariaLabel: {
716
+ classPropertyName: "ariaLabel",
717
+ publicName: "aria-label",
718
+ isSignal: true,
719
+ isRequired: false,
720
+ transformFunction: null
721
+ },
722
+ ariaLabelledBy: {
723
+ classPropertyName: "ariaLabelledBy",
724
+ publicName: "aria-labelledby",
725
+ isSignal: true,
726
+ isRequired: false,
727
+ transformFunction: null
728
+ },
729
+ disabled: {
730
+ classPropertyName: "disabled",
731
+ publicName: "disabled",
732
+ isSignal: true,
733
+ isRequired: false,
734
+ transformFunction: null
735
+ },
736
+ format: {
737
+ classPropertyName: "format",
738
+ publicName: "format",
739
+ isSignal: true,
740
+ isRequired: false,
741
+ transformFunction: null
742
+ },
743
+ invalid: {
744
+ classPropertyName: "invalid",
745
+ publicName: "invalid",
746
+ isSignal: true,
747
+ isRequired: false,
748
+ transformFunction: null
749
+ },
750
+ opacity: {
751
+ classPropertyName: "opacity",
752
+ publicName: "opacity",
753
+ isSignal: true,
754
+ isRequired: false,
755
+ transformFunction: null
756
+ },
757
+ readonly: {
758
+ classPropertyName: "readonly",
759
+ publicName: "readonly",
760
+ isSignal: true,
761
+ isRequired: false,
762
+ transformFunction: null
763
+ },
764
+ required: {
765
+ classPropertyName: "required",
766
+ publicName: "required",
767
+ isSignal: true,
768
+ isRequired: false,
769
+ transformFunction: null
770
+ },
771
+ rounded: {
772
+ classPropertyName: "rounded",
773
+ publicName: "rounded",
774
+ isSignal: true,
775
+ isRequired: false,
776
+ transformFunction: null
777
+ },
778
+ showButtons: {
779
+ classPropertyName: "showButtons",
780
+ publicName: "showButtons",
781
+ isSignal: true,
782
+ isRequired: false,
783
+ transformFunction: null
784
+ },
785
+ showColorInputs: {
786
+ classPropertyName: "showColorInputs",
787
+ publicName: "showColorInputs",
788
+ isSignal: true,
789
+ isRequired: false,
790
+ transformFunction: null
791
+ },
792
+ showHexInput: {
793
+ classPropertyName: "showHexInput",
794
+ publicName: "showHexInput",
795
+ isSignal: true,
796
+ isRequired: false,
797
+ transformFunction: null
798
+ },
799
+ touched: {
800
+ classPropertyName: "touched",
801
+ publicName: "touched",
802
+ isSignal: true,
803
+ isRequired: false,
804
+ transformFunction: null
805
+ },
806
+ value: {
807
+ classPropertyName: "value",
808
+ publicName: "value",
809
+ isSignal: true,
810
+ isRequired: false,
811
+ transformFunction: null
812
+ }
813
+ },
814
+ outputs: {
815
+ apply: "apply",
816
+ cancel: "cancel",
817
+ touch: "touch",
818
+ value: "valueChange"
819
+ },
820
+ host: {
821
+ listeners: { "focusout": "onFocusOut($event)" },
822
+ properties: {
823
+ "class": "baseClasses()",
824
+ "attr.data-disabled": "effectiveDisabled()",
825
+ "attr.data-readonly": "readonly() || null",
826
+ "attr.data-invalid": "invalidState() || null",
827
+ "attr.role": "'group'",
828
+ "attr.aria-label": "labelledBy() ? null : ariaLabel() || messages().colorGradient",
829
+ "attr.aria-labelledby": "labelledBy()",
830
+ "attr.aria-invalid": "invalidState() ? 'true' : null"
831
+ }
832
+ },
833
+ viewQueries: [{
834
+ propertyName: "hsvHandle",
835
+ first: true,
836
+ predicate: ["hsvPointer"],
837
+ descendants: true,
838
+ isSignal: true
839
+ }, {
840
+ propertyName: "hsvRectangle",
841
+ first: true,
842
+ predicate: ["hsvRectangle"],
843
+ descendants: true,
844
+ isSignal: true
845
+ }],
846
+ ngImport: i0,
847
+ template: "<div [class]=\"hsvRectangleClasses()\" [style.background-color]=\"hsvRectangleBackground()\" #hsvRectangle>\n <div\n [class]=\"hsvRectangleHandleClasses()\"\n [style.left.%]=\"hsv().s ?? 0\"\n [style.top.%]=\"100 - (hsv().v ?? 100)\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\n [attr.role]=\"'slider'\"\n [attr.aria-label]=\"messages().saturationAndValue\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"100\"\n [attr.aria-valuenow]=\"roundedSaturation()\"\n [attr.aria-valuetext]=\"messages().saturationAndValueText(roundedSaturation(), roundedValue())\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (keydown)=\"onHsvHandleKeyDown($event)\"\n #hsvPointer></div>\n</div>\n<div class=\"flex items-center gap-2\">\n <div class=\"flex flex-1 flex-col gap-1 me-2 forced-color-adjust-none\">\n <mona-slider\n dir=\"ltr\"\n [aria-label]=\"messages().hue\"\n [minValue]=\"0\"\n [maxValue]=\"360\"\n [trackBackground]=\"'linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)'\"\n [selectionBackground]=\"'transparent'\"\n [handleClasses]=\"sliderHandleClasses()\"\n [trackSize]=\"sliderHeight\"\n [rounded]=\"rounded()\"\n [value]=\"roundedHue()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onHueChange($event)\"></mona-slider>\n @if (opacity()) {\n <mona-slider\n dir=\"ltr\"\n [aria-label]=\"messages().alpha\"\n [ariaValueText]=\"alphaValueText()\"\n [minValue]=\"0\"\n [maxValue]=\"255\"\n [trackBackground]=\"alphaSliderBackground()\"\n [selectionBackground]=\"'transparent'\"\n [handleClasses]=\"sliderHandleClasses()\"\n [trackSize]=\"sliderHeight\"\n [rounded]=\"rounded()\"\n [value]=\"alpha()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onAlphaChange($event)\"></mona-slider>\n }\n </div>\n @for (preview of colorPreviews(); track preview.type) {\n <div\n [class]=\"colorPreviewClasses()\"\n [class.cursor-pointer]=\"$index === 1\"\n [style.background-color]=\"preview.color\"\n [attr.title]=\"$index === 1 ? preview.title : null\"\n [attr.aria-label]=\"$index === 1 ? preview.title : null\"\n [attr.aria-hidden]=\"$index === 0 ? 'true' : null\"\n [attr.aria-disabled]=\"$index === 1 && interactionDisabled() ? 'true' : null\"\n [attr.role]=\"$index === 1 ? 'button' : null\"\n [attr.tabindex]=\"$index === 1 && !interactionDisabled() ? 0 : null\"\n (click)=\"preview.onClick?.()\"\n (keydown)=\"onPreviousColorKeyDown($event, preview.onClick)\"></div>\n }\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [disabled]=\"interactionDisabled()\"\n [attr.aria-label]=\"messages().clearColor\"\n (click)=\"onClearClick()\">\n <svg lucideDropletOff [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n</div>\n<div class=\"flex flex-col gap-2\">\n @if (showColorInputs()) {\n <div class=\"flex gap-2\">\n <div class=\"flex gap-1\">\n @for (input of colorInputs(); track input.key) {\n <mona-numeric-text-box\n [aria-label]=\"input.ariaLabel\"\n [value]=\"input.value\"\n [minValue]=\"input.min\"\n [maxValue]=\"input.max\"\n [decimals]=\"0\"\n [spinners]=\"false\"\n [nullable]=\"false\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n class=\"w-18\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"input.change($event)\">\n <ng-template monaNumericTextBoxPrefixTemplate>\n <ng-container\n [ngTemplateOutlet]=\"numericInputPrefixTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: input.label }\"></ng-container>\n </ng-template>\n </mona-numeric-text-box>\n }\n </div>\n <div class=\"flex flex-1 items-center justify-end\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n size=\"small\"\n [disabled]=\"effectiveDisabled()\"\n [attr.aria-label]=\"messages().switchColorMode\"\n (click)=\"onSwitchColorModeClick()\">\n <svg lucideChevronsUpDown [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n </div>\n </div>\n }\n @if (showHexInput()) {\n <mona-text-box\n [aria-label]=\"messages().hexColor\"\n [rounded]=\"rounded()\"\n [value]=\"hex()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onHexChange($event)\"\n (inputBlur)=\"onHexInputBlur()\"\n (inputFocus)=\"onHexInputFocus()\"\n class=\"w-full\">\n <ng-template monaTextBoxPrefixTemplate>\n <ng-container\n [ngTemplateOutlet]=\"numericInputPrefixTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: 'HEX', classes: 'w-auto px-2' }\"></ng-container>\n </ng-template>\n <ng-template monaTextBoxSuffixTemplate>\n <mona-dropdown-button\n look=\"ghost\"\n [disabled]=\"effectiveDisabled() || !selectedColor()\"\n [iconOnly]=\"true\"\n [aria-label]=\"messages().copyColor\"\n class=\"h-full\">\n <ng-template monaDropdownButtonTextTemplate>\n <svg lucideCopy [size]=\"12\" aria-hidden=\"true\"></svg>\n </ng-template>\n <mona-dropdown-button-item\n [label]=\"messages().copyAsHex\"\n (menuClick)=\"onCopyColorSelect('hex')\"></mona-dropdown-button-item>\n <mona-dropdown-button-item\n [label]=\"messages().copyAsRgb\"\n (menuClick)=\"onCopyColorSelect('rgb')\"></mona-dropdown-button-item>\n </mona-dropdown-button>\n </ng-template>\n </mona-text-box>\n }\n @if (showButtons()) {\n <div class=\"flex items-center justify-end gap-2\">\n <button\n monaButton\n [rounded]=\"rounded()\"\n look=\"primary\"\n [disabled]=\"interactionDisabled()\"\n (click)=\"onApply()\">\n {{ messages().apply }}\n </button>\n <button monaButton [rounded]=\"rounded()\" [disabled]=\"effectiveDisabled()\" (click)=\"onCancel()\">\n {{ messages().cancel }}\n </button>\n </div>\n }\n</div>\n\n<ng-template #numericInputPrefixTemplate let-text let-classes=\"classes\">\n <span\n [class]=\"classes\"\n class=\"inline-flex items-center justify-center select-none w-7.5 [background-color:var(--mona-input-addon-background,var(--color-secondary))] h-full text-foreground text-xs font-semibold border-e border-e-input-border\"\n aria-hidden=\"true\"\n >{{ text }}</span\n >\n</ng-template>\n",
848
+ dependencies: [
849
+ {
850
+ kind: "component",
851
+ type: LucideDropletOff,
852
+ selector: "svg[lucideDropletOff]"
853
+ },
854
+ {
855
+ kind: "component",
856
+ type: LucideChevronsUpDown,
857
+ selector: "svg[lucideChevronsUpDown]"
858
+ },
859
+ {
860
+ kind: "component",
861
+ type: NumericTextBoxComponent,
862
+ selector: "mona-numeric-text-box",
863
+ inputs: [
864
+ "formatter",
865
+ "maxValue",
866
+ "minValue",
867
+ "step",
868
+ "value"
869
+ ],
870
+ outputs: ["valueChange"]
871
+ },
872
+ {
873
+ kind: "directive",
874
+ type: NumericTextBoxPrefixTemplateDirective,
875
+ selector: "ng-template[monaNumericTextBoxPrefixTemplate]"
876
+ },
877
+ {
878
+ kind: "directive",
879
+ type: ButtonDirective,
880
+ selector: "button[monaButton]",
881
+ inputs: [
882
+ "aria-haspopup",
883
+ "disabled",
884
+ "iconOnly",
885
+ "loading",
886
+ "look",
887
+ "rounded",
888
+ "selected",
889
+ "size",
890
+ "tabindex",
891
+ "toggleable",
892
+ "type",
893
+ "class",
894
+ "value"
895
+ ],
896
+ outputs: ["lookChange", "selectedChange"]
897
+ },
898
+ {
899
+ kind: "component",
900
+ type: TextBoxComponent,
901
+ selector: "mona-text-box",
902
+ inputs: [
903
+ "aria-describedby",
904
+ "aria-label",
905
+ "aria-labelledby",
906
+ "clearButton",
907
+ "disabled",
908
+ "inputAttributes",
909
+ "inputClass",
910
+ "inputId",
911
+ "inputStyle",
912
+ "invalid",
913
+ "maxLength",
914
+ "minLength",
915
+ "name",
916
+ "placeholder",
917
+ "readonly",
918
+ "required",
919
+ "rounded",
920
+ "size",
921
+ "touched",
922
+ "type",
923
+ "class",
924
+ "value"
925
+ ],
926
+ outputs: [
927
+ "inputBlur",
928
+ "inputFocus",
929
+ "touch",
930
+ "valueChange"
931
+ ]
932
+ },
933
+ {
934
+ kind: "directive",
935
+ type: TextBoxPrefixTemplateDirective,
936
+ selector: "ng-template[monaTextBoxPrefixTemplate]"
937
+ },
938
+ {
939
+ kind: "directive",
940
+ type: TextBoxSuffixTemplateDirective,
941
+ selector: "ng-template[monaTextBoxSuffixTemplate]"
942
+ },
943
+ {
944
+ kind: "component",
945
+ type: SliderComponent,
946
+ selector: "mona-slider",
947
+ inputs: [
948
+ "max",
949
+ "min",
950
+ "value"
951
+ ],
952
+ outputs: ["valueChange"]
953
+ },
954
+ {
955
+ kind: "directive",
956
+ type: NgTemplateOutlet,
957
+ selector: "[ngTemplateOutlet]",
958
+ inputs: [
959
+ "ngTemplateOutletContext",
960
+ "ngTemplateOutlet",
961
+ "ngTemplateOutletInjector"
962
+ ]
963
+ },
964
+ {
965
+ kind: "component",
966
+ type: DropdownButtonComponent,
967
+ selector: "mona-dropdown-button",
968
+ inputs: [
969
+ "aria-label",
970
+ "aria-labelledby",
971
+ "disabled",
972
+ "iconOnly",
973
+ "loading",
974
+ "look",
975
+ "popupWidth",
976
+ "rounded",
977
+ "showArrow",
978
+ "size",
979
+ "text",
980
+ "class"
981
+ ],
982
+ outputs: ["menuItemClick"]
983
+ },
984
+ {
985
+ kind: "component",
986
+ type: DropdownButtonItemComponent,
987
+ selector: "mona-dropdown-button-item"
988
+ },
989
+ {
990
+ kind: "directive",
991
+ type: DropdownButtonTextTemplateDirective,
992
+ selector: "ng-template[monaDropdownButtonTextTemplate]"
993
+ },
994
+ {
995
+ kind: "component",
996
+ type: LucideCopy,
997
+ selector: "svg[lucideCopy]"
998
+ }
999
+ ]
1000
+ });
1001
+ }
1002
+ };
1003
+ i0.ɵɵngDeclareClassMetadata({
1004
+ minVersion: "12.0.0",
1005
+ version: "22.2.6",
1006
+ ngImport: i0,
1007
+ type: ColorGradientComponent,
1008
+ decorators: [{
1009
+ type: Component,
1010
+ args: [{
1011
+ selector: "mona-color-gradient",
1012
+ imports: [
1013
+ LucideDropletOff,
1014
+ LucideChevronsUpDown,
1015
+ NumericTextBoxComponent,
1016
+ NumericTextBoxPrefixTemplateDirective,
1017
+ ButtonDirective,
1018
+ TextBoxComponent,
1019
+ TextBoxPrefixTemplateDirective,
1020
+ TextBoxSuffixTemplateDirective,
1021
+ SliderComponent,
1022
+ NgTemplateOutlet,
1023
+ DropdownButtonComponent,
1024
+ DropdownButtonItemComponent,
1025
+ DropdownButtonTextTemplateDirective,
1026
+ LucideCopy
1027
+ ],
1028
+ host: {
1029
+ "[class]": "baseClasses()",
1030
+ "[attr.data-disabled]": "effectiveDisabled()",
1031
+ "[attr.data-readonly]": "readonly() || null",
1032
+ "(focusout)": "onFocusOut($event)",
1033
+ "[attr.data-invalid]": "invalidState() || null",
1034
+ "[attr.role]": "'group'",
1035
+ "[attr.aria-label]": "labelledBy() ? null : ariaLabel() || messages().colorGradient",
1036
+ "[attr.aria-labelledby]": "labelledBy()",
1037
+ "[attr.aria-invalid]": "invalidState() ? 'true' : null"
1038
+ },
1039
+ template: "<div [class]=\"hsvRectangleClasses()\" [style.background-color]=\"hsvRectangleBackground()\" #hsvRectangle>\n <div\n [class]=\"hsvRectangleHandleClasses()\"\n [style.left.%]=\"hsv().s ?? 0\"\n [style.top.%]=\"100 - (hsv().v ?? 100)\"\n [attr.tabindex]=\"effectiveDisabled() ? -1 : 0\"\n [attr.role]=\"'slider'\"\n [attr.aria-label]=\"messages().saturationAndValue\"\n [attr.aria-valuemin]=\"0\"\n [attr.aria-valuemax]=\"100\"\n [attr.aria-valuenow]=\"roundedSaturation()\"\n [attr.aria-valuetext]=\"messages().saturationAndValueText(roundedSaturation(), roundedValue())\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (keydown)=\"onHsvHandleKeyDown($event)\"\n #hsvPointer></div>\n</div>\n<div class=\"flex items-center gap-2\">\n <div class=\"flex flex-1 flex-col gap-1 me-2 forced-color-adjust-none\">\n <mona-slider\n dir=\"ltr\"\n [aria-label]=\"messages().hue\"\n [minValue]=\"0\"\n [maxValue]=\"360\"\n [trackBackground]=\"'linear-gradient(to right, #ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000)'\"\n [selectionBackground]=\"'transparent'\"\n [handleClasses]=\"sliderHandleClasses()\"\n [trackSize]=\"sliderHeight\"\n [rounded]=\"rounded()\"\n [value]=\"roundedHue()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onHueChange($event)\"></mona-slider>\n @if (opacity()) {\n <mona-slider\n dir=\"ltr\"\n [aria-label]=\"messages().alpha\"\n [ariaValueText]=\"alphaValueText()\"\n [minValue]=\"0\"\n [maxValue]=\"255\"\n [trackBackground]=\"alphaSliderBackground()\"\n [selectionBackground]=\"'transparent'\"\n [handleClasses]=\"sliderHandleClasses()\"\n [trackSize]=\"sliderHeight\"\n [rounded]=\"rounded()\"\n [value]=\"alpha()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onAlphaChange($event)\"></mona-slider>\n }\n </div>\n @for (preview of colorPreviews(); track preview.type) {\n <div\n [class]=\"colorPreviewClasses()\"\n [class.cursor-pointer]=\"$index === 1\"\n [style.background-color]=\"preview.color\"\n [attr.title]=\"$index === 1 ? preview.title : null\"\n [attr.aria-label]=\"$index === 1 ? preview.title : null\"\n [attr.aria-hidden]=\"$index === 0 ? 'true' : null\"\n [attr.aria-disabled]=\"$index === 1 && interactionDisabled() ? 'true' : null\"\n [attr.role]=\"$index === 1 ? 'button' : null\"\n [attr.tabindex]=\"$index === 1 && !interactionDisabled() ? 0 : null\"\n (click)=\"preview.onClick?.()\"\n (keydown)=\"onPreviousColorKeyDown($event, preview.onClick)\"></div>\n }\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [disabled]=\"interactionDisabled()\"\n [attr.aria-label]=\"messages().clearColor\"\n (click)=\"onClearClick()\">\n <svg lucideDropletOff [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n</div>\n<div class=\"flex flex-col gap-2\">\n @if (showColorInputs()) {\n <div class=\"flex gap-2\">\n <div class=\"flex gap-1\">\n @for (input of colorInputs(); track input.key) {\n <mona-numeric-text-box\n [aria-label]=\"input.ariaLabel\"\n [value]=\"input.value\"\n [minValue]=\"input.min\"\n [maxValue]=\"input.max\"\n [decimals]=\"0\"\n [spinners]=\"false\"\n [nullable]=\"false\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n class=\"w-18\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"input.change($event)\">\n <ng-template monaNumericTextBoxPrefixTemplate>\n <ng-container\n [ngTemplateOutlet]=\"numericInputPrefixTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: input.label }\"></ng-container>\n </ng-template>\n </mona-numeric-text-box>\n }\n </div>\n <div class=\"flex flex-1 items-center justify-end\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n size=\"small\"\n [disabled]=\"effectiveDisabled()\"\n [attr.aria-label]=\"messages().switchColorMode\"\n (click)=\"onSwitchColorModeClick()\">\n <svg lucideChevronsUpDown [size]=\"16\" aria-hidden=\"true\"></svg>\n </button>\n </div>\n </div>\n }\n @if (showHexInput()) {\n <mona-text-box\n [aria-label]=\"messages().hexColor\"\n [rounded]=\"rounded()\"\n [value]=\"hex()\"\n [disabled]=\"effectiveDisabled()\"\n [readonly]=\"readonly()\"\n (valueChange)=\"onHexChange($event)\"\n (inputBlur)=\"onHexInputBlur()\"\n (inputFocus)=\"onHexInputFocus()\"\n class=\"w-full\">\n <ng-template monaTextBoxPrefixTemplate>\n <ng-container\n [ngTemplateOutlet]=\"numericInputPrefixTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: 'HEX', classes: 'w-auto px-2' }\"></ng-container>\n </ng-template>\n <ng-template monaTextBoxSuffixTemplate>\n <mona-dropdown-button\n look=\"ghost\"\n [disabled]=\"effectiveDisabled() || !selectedColor()\"\n [iconOnly]=\"true\"\n [aria-label]=\"messages().copyColor\"\n class=\"h-full\">\n <ng-template monaDropdownButtonTextTemplate>\n <svg lucideCopy [size]=\"12\" aria-hidden=\"true\"></svg>\n </ng-template>\n <mona-dropdown-button-item\n [label]=\"messages().copyAsHex\"\n (menuClick)=\"onCopyColorSelect('hex')\"></mona-dropdown-button-item>\n <mona-dropdown-button-item\n [label]=\"messages().copyAsRgb\"\n (menuClick)=\"onCopyColorSelect('rgb')\"></mona-dropdown-button-item>\n </mona-dropdown-button>\n </ng-template>\n </mona-text-box>\n }\n @if (showButtons()) {\n <div class=\"flex items-center justify-end gap-2\">\n <button\n monaButton\n [rounded]=\"rounded()\"\n look=\"primary\"\n [disabled]=\"interactionDisabled()\"\n (click)=\"onApply()\">\n {{ messages().apply }}\n </button>\n <button monaButton [rounded]=\"rounded()\" [disabled]=\"effectiveDisabled()\" (click)=\"onCancel()\">\n {{ messages().cancel }}\n </button>\n </div>\n }\n</div>\n\n<ng-template #numericInputPrefixTemplate let-text let-classes=\"classes\">\n <span\n [class]=\"classes\"\n class=\"inline-flex items-center justify-center select-none w-7.5 [background-color:var(--mona-input-addon-background,var(--color-secondary))] h-full text-foreground text-xs font-semibold border-e border-e-input-border\"\n aria-hidden=\"true\"\n >{{ text }}</span\n >\n</ng-template>\n"
1040
+ }]
1041
+ }],
1042
+ ctorParameters: () => [],
1043
+ propDecorators: {
1044
+ hsvHandle: [{
1045
+ type: i0.ViewChild,
1046
+ args: ["hsvPointer", { isSignal: true }]
1047
+ }],
1048
+ hsvRectangle: [{
1049
+ type: i0.ViewChild,
1050
+ args: ["hsvRectangle", { isSignal: true }]
1051
+ }],
1052
+ apply: [{
1053
+ type: i0.Output,
1054
+ args: ["apply"]
1055
+ }],
1056
+ ariaLabel: [{
1057
+ type: i0.Input,
1058
+ args: [{
1059
+ isSignal: true,
1060
+ alias: "aria-label",
1061
+ required: false
1062
+ }]
1063
+ }],
1064
+ ariaLabelledBy: [{
1065
+ type: i0.Input,
1066
+ args: [{
1067
+ isSignal: true,
1068
+ alias: "aria-labelledby",
1069
+ required: false
1070
+ }]
1071
+ }],
1072
+ cancel: [{
1073
+ type: i0.Output,
1074
+ args: ["cancel"]
1075
+ }],
1076
+ disabled: [{
1077
+ type: i0.Input,
1078
+ args: [{
1079
+ isSignal: true,
1080
+ alias: "disabled",
1081
+ required: false
1082
+ }]
1083
+ }],
1084
+ format: [{
1085
+ type: i0.Input,
1086
+ args: [{
1087
+ isSignal: true,
1088
+ alias: "format",
1089
+ required: false
1090
+ }]
1091
+ }],
1092
+ invalid: [{
1093
+ type: i0.Input,
1094
+ args: [{
1095
+ isSignal: true,
1096
+ alias: "invalid",
1097
+ required: false
1098
+ }]
1099
+ }],
1100
+ opacity: [{
1101
+ type: i0.Input,
1102
+ args: [{
1103
+ isSignal: true,
1104
+ alias: "opacity",
1105
+ required: false
1106
+ }]
1107
+ }],
1108
+ readonly: [{
1109
+ type: i0.Input,
1110
+ args: [{
1111
+ isSignal: true,
1112
+ alias: "readonly",
1113
+ required: false
1114
+ }]
1115
+ }],
1116
+ required: [{
1117
+ type: i0.Input,
1118
+ args: [{
1119
+ isSignal: true,
1120
+ alias: "required",
1121
+ required: false
1122
+ }]
1123
+ }],
1124
+ rounded: [{
1125
+ type: i0.Input,
1126
+ args: [{
1127
+ isSignal: true,
1128
+ alias: "rounded",
1129
+ required: false
1130
+ }]
1131
+ }],
1132
+ showButtons: [{
1133
+ type: i0.Input,
1134
+ args: [{
1135
+ isSignal: true,
1136
+ alias: "showButtons",
1137
+ required: false
1138
+ }]
1139
+ }],
1140
+ showColorInputs: [{
1141
+ type: i0.Input,
1142
+ args: [{
1143
+ isSignal: true,
1144
+ alias: "showColorInputs",
1145
+ required: false
1146
+ }]
1147
+ }],
1148
+ showHexInput: [{
1149
+ type: i0.Input,
1150
+ args: [{
1151
+ isSignal: true,
1152
+ alias: "showHexInput",
1153
+ required: false
1154
+ }]
1155
+ }],
1156
+ touch: [{
1157
+ type: i0.Output,
1158
+ args: ["touch"]
1159
+ }],
1160
+ touched: [{
1161
+ type: i0.Input,
1162
+ args: [{
1163
+ isSignal: true,
1164
+ alias: "touched",
1165
+ required: false
1166
+ }]
1167
+ }],
1168
+ value: [{
1169
+ type: i0.Input,
1170
+ args: [{
1171
+ isSignal: true,
1172
+ alias: "value",
1173
+ required: false
1174
+ }]
1175
+ }, {
1176
+ type: i0.Output,
1177
+ args: ["valueChange"]
1178
+ }]
1179
+ }
1180
+ });
858
1181
  export { COLOR_GRADIENT_DEFAULT_MESSAGES, ColorGradientComponent };
859
- //# sourceMappingURL=nanahoshi-mona-ui-color-gradient.mjs.map
1182
+
1183
+ //# sourceMappingURL=nanahoshi-mona-ui-color-gradient.mjs.map