@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,19 +1,13 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, DestroyRef, ElementRef, computed, contentChildren, input, booleanAttribute, output, model, effect, untracked, afterNextRender, Component } from '@angular/core';
3
- import { outputFromObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
- import { ButtonService, ButtonDirective, BUTTON_GROUP_MEMBER } from '@nanahoshi/mona-ui/button';
5
- import { MonaI18nService } from '@nanahoshi/mona-ui/i18n';
6
- import { injectLabelAssociation, injectEffectiveDisabled } from '@nanahoshi/mona-ui/internal';
7
- import { filter, map } from 'rxjs';
8
- import { twMerge } from 'tailwind-merge';
9
- import { cva } from 'class-variance-authority';
10
-
11
- // Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
12
- // Edit the JSON file and run `npm run generate:locale-catalogs`.
13
- const BUTTON_GROUP_DEFAULT_MESSAGES = {
14
- buttonGroup: "Button group"
15
- };
16
-
1
+ import * as i0 from "@angular/core";
2
+ import { Component, DestroyRef, ElementRef, afterNextRender, booleanAttribute, computed, contentChildren, effect, inject, input, model, output, untracked } from "@angular/core";
3
+ import { outputFromObservable, takeUntilDestroyed } from "@angular/core/rxjs-interop";
4
+ import { BUTTON_GROUP_MEMBER, ButtonDirective, ButtonService } from "@nanahoshi/mona-ui/button";
5
+ import { MonaI18nService } from "@nanahoshi/mona-ui/i18n";
6
+ import { injectEffectiveDisabled, injectLabelAssociation } from "@nanahoshi/mona-ui/internal";
7
+ import { filter, map } from "rxjs";
8
+ import { twMerge } from "tailwind-merge";
9
+ import { cva } from "class-variance-authority";
10
+ const BUTTON_GROUP_DEFAULT_MESSAGES = { buttonGroup: "Button group" };
17
11
  const buttonGroupThemeVariants = cva(`
18
12
  inline-flex items-center justify-center
19
13
  border border-input-border
@@ -33,374 +27,534 @@ const buttonGroupThemeVariants = cva(`
33
27
  [&>*>button:not(:last-of-type)]:border-e
34
28
  [&>*>button:not(:last-of-type)]:border-border-subtle
35
29
  `, {
36
- variants: {
37
- look: {
38
- default: "",
39
- error: "border-transparent",
40
- ghost: "border-transparent [&>*:not(:last-child)]:border-e-0 [&>*>button:not(:last-of-type)]:border-e-0",
41
- info: "border-transparent",
42
- outline: "",
43
- primary: "border-transparent",
44
- secondary: "border-transparent",
45
- success: "border-transparent",
46
- warning: "border-transparent"
47
- },
48
- rounded: {
49
- full: `
30
+ variants: {
31
+ look: {
32
+ default: "",
33
+ error: "border-transparent",
34
+ ghost: "border-transparent [&>*:not(:last-child)]:border-e-0 [&>*>button:not(:last-of-type)]:border-e-0",
35
+ info: "border-transparent",
36
+ outline: "",
37
+ primary: "border-transparent",
38
+ secondary: "border-transparent",
39
+ success: "border-transparent",
40
+ warning: "border-transparent"
41
+ },
42
+ rounded: {
43
+ full: `
50
44
  rounded-full
51
45
  [&>button]:first:rounded-ss-full [&>button]:first:rounded-es-full
52
46
  [&>button]:last:rounded-se-full [&>button]:last:rounded-ee-full
53
47
  [&>*:first-child>button:first-of-type]:rounded-ss-full! [&>*:first-child>button:first-of-type]:rounded-es-full!
54
48
  [&>*:last-child>button:last-of-type]:rounded-se-full! [&>*:last-child>button:last-of-type]:rounded-ee-full!
55
49
  `,
56
- large: `
50
+ large: `
57
51
  rounded-lg
58
52
  [&>button]:first:rounded-ss-lg [&>button]:first:rounded-es-lg
59
53
  [&>button]:last:rounded-se-lg [&>button]:last:rounded-ee-lg
60
54
  [&>*:first-child>button:first-of-type]:rounded-ss-lg! [&>*:first-child>button:first-of-type]:rounded-es-lg!
61
55
  [&>*:last-child>button:last-of-type]:rounded-se-lg! [&>*:last-child>button:last-of-type]:rounded-ee-lg!
62
56
  `,
63
- medium: `
57
+ medium: `
64
58
  rounded-md
65
59
  [&>button]:first:rounded-ss-md [&>button]:first:rounded-es-md
66
60
  [&>button]:last:rounded-se-md [&>button]:last:rounded-ee-md
67
61
  [&>*:first-child>button:first-of-type]:rounded-ss-md! [&>*:first-child>button:first-of-type]:rounded-es-md!
68
62
  [&>*:last-child>button:last-of-type]:rounded-se-md! [&>*:last-child>button:last-of-type]:rounded-ee-md!
69
63
  `,
70
- none: `
64
+ none: `
71
65
  rounded-none
72
66
  `,
73
- small: `
67
+ small: `
74
68
  rounded-sm
75
69
  [&>button]:first:rounded-ss-sm [&>button]:first:rounded-es-sm
76
70
  [&>button]:last:rounded-se-sm [&>button]:last:rounded-ee-sm
77
71
  [&>*:first-child>button:first-of-type]:rounded-ss-sm! [&>*:first-child>button:first-of-type]:rounded-es-sm!
78
72
  [&>*:last-child>button:last-of-type]:rounded-se-sm! [&>*:last-child>button:last-of-type]:rounded-ee-sm!
79
73
  `
80
- },
81
- size: {
82
- large: ``,
83
- medium: "",
84
- small: ``
85
- }
86
- },
87
- defaultVariants: {
88
- look: "default",
89
- size: "medium"
90
- }
74
+ },
75
+ size: {
76
+ large: ``,
77
+ medium: "",
78
+ small: ``
79
+ }
80
+ },
81
+ defaultVariants: {
82
+ look: "default",
83
+ size: "medium"
84
+ }
85
+ });
86
+ var ButtonGroupComponent = class ButtonGroupComponent {
87
+ #buttonService;
88
+ #destroyRef;
89
+ #hostElementRef;
90
+ #i18n;
91
+ #label;
92
+ #lastSelected;
93
+ constructor() {
94
+ this.#buttonService = inject(ButtonService, { self: true });
95
+ this.#destroyRef = inject(DestroyRef);
96
+ this.#hostElementRef = inject(ElementRef);
97
+ this.#i18n = inject(MonaI18nService);
98
+ this.#label = injectLabelAssociation({
99
+ activate: () => this.focus(),
100
+ ariaLabel: () => this.ariaLabel(),
101
+ ariaLabelledBy: () => this.ariaLabelledBy()
102
+ });
103
+ this.#lastSelected = [];
104
+ this.baseClass = computed(() => {
105
+ const look = this.look();
106
+ const rounded = this.rounded();
107
+ const size = this.size();
108
+ const variantClasses = buttonGroupThemeVariants({
109
+ look,
110
+ rounded,
111
+ size
112
+ });
113
+ const userClass = this.userClass();
114
+ return twMerge(variantClasses, userClass);
115
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
116
+ this.buttons = contentChildren(ButtonDirective, ...ngDevMode ? [{ debugName: "buttons" }] : /* istanbul ignore next */ []);
117
+ this.components = contentChildren(BUTTON_GROUP_MEMBER, ...ngDevMode ? [{ debugName: "components" }] : /* istanbul ignore next */ []);
118
+ this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
119
+ this.invalidState = computed(() => this.touched() && this.invalid(), ...ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []);
120
+ this.labelledBy = this.#label.labelledBy;
121
+ this.members = computed(() => [...this.buttons(), ...this.components().flatMap((component) => component.groupButtons())], ...ngDevMode ? [{ debugName: "members" }] : /* istanbul ignore next */ []);
122
+ this.messages = this.#i18n.componentMessages("buttonGroup", BUTTON_GROUP_DEFAULT_MESSAGES);
123
+ this.allowEmpty = input(true, {
124
+ ...ngDevMode ? { debugName: "allowEmpty" } : /* istanbul ignore next */ {},
125
+ transform: booleanAttribute
126
+ });
127
+ this.ariaLabel = input(void 0, {
128
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
129
+ alias: "aria-label"
130
+ });
131
+ this.ariaLabelledBy = input("", {
132
+ ...ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {},
133
+ alias: "aria-labelledby"
134
+ });
135
+ this.buttonClick = outputFromObservable(this.#buttonService.memberClick$.pipe(filter(([button]) => this.buttons().includes(button) && !(this.readonly() && button.effectiveToggleable())), map(([button, element]) => ({
136
+ button: element,
137
+ selected: button.selected(),
138
+ value: button.value()
139
+ })), takeUntilDestroyed(this.#destroyRef)));
140
+ this.disabled = input(false, {
141
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
142
+ transform: booleanAttribute
143
+ });
144
+ this.invalid = input(false, {
145
+ ...ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {},
146
+ transform: booleanAttribute
147
+ });
148
+ this.look = input("outline", ...ngDevMode ? [{ debugName: "look" }] : /* istanbul ignore next */ []);
149
+ this.readonly = input(false, {
150
+ ...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
151
+ transform: booleanAttribute
152
+ });
153
+ this.rounded = input("medium", ...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
154
+ this.selection = input("multiple", ...ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []);
155
+ this.size = input("medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
156
+ this.touch = output();
157
+ this.touched = input(false, {
158
+ ...ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {},
159
+ transform: booleanAttribute
160
+ });
161
+ this.userClass = input("", {
162
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
163
+ alias: "class"
164
+ });
165
+ this.value = model(void 0, ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
166
+ this.#buttonService.setMembers(this.members);
167
+ effect(() => {
168
+ const disabled = this.effectiveDisabled();
169
+ untracked(() => this.#buttonService.groupDisabled.set(disabled));
170
+ });
171
+ effect(() => {
172
+ const readonly = this.readonly();
173
+ untracked(() => this.#buttonService.groupReadonly.set(readonly));
174
+ });
175
+ effect(() => {
176
+ const look = this.look();
177
+ untracked(() => this.#buttonService.groupLook.set(look));
178
+ });
179
+ effect(() => {
180
+ const rounded = this.rounded();
181
+ untracked(() => this.#buttonService.groupRounded.set(rounded));
182
+ });
183
+ effect(() => {
184
+ const size = this.size();
185
+ untracked(() => this.#buttonService.groupSize.set(size));
186
+ });
187
+ effect(() => {
188
+ const value = this.value();
189
+ if (value === void 0) return;
190
+ const values = this.valuesOf(value);
191
+ for (const button of this.valueButtons()) {
192
+ const selected = values.includes(button.value());
193
+ untracked(() => button.selected.set(selected));
194
+ }
195
+ });
196
+ effect(() => {
197
+ const buttons = this.buttons();
198
+ const selected = buttons.filter((button) => button.selected());
199
+ const single = this.selection() === "single";
200
+ const allowEmpty = this.allowEmpty();
201
+ untracked(() => this.enforceSelectionPolicy(buttons, selected, single, allowEmpty));
202
+ });
203
+ afterNextRender({ read: () => this.setSubscriptions() });
204
+ }
205
+ focus(options) {
206
+ const host = this.#hostElementRef.nativeElement;
207
+ (host.querySelector("button[aria-pressed='true']:not(:disabled)") ?? host.querySelector("button:not(:disabled)"))?.focus(options);
208
+ }
209
+ setLabelledBy(id) {
210
+ this.#label.setLabelledBy(id);
211
+ }
212
+ onFocusOut(event) {
213
+ const nextTarget = event.relatedTarget;
214
+ if (nextTarget instanceof Node && this.#hostElementRef.nativeElement.contains(nextTarget)) return;
215
+ this.touch.emit();
216
+ }
217
+ commitValue() {
218
+ const buttons = this.valueButtons();
219
+ if (buttons.length === 0) return;
220
+ const selected = buttons.filter((button) => button.selected()).map((button) => button.value());
221
+ if (this.selection() === "single") {
222
+ this.value.set(selected[0] ?? null);
223
+ return;
224
+ }
225
+ const known = buttons.map((button) => button.value());
226
+ const waiting = this.valuesOf(this.value()).filter((value) => !known.includes(value));
227
+ this.value.set([...waiting, ...selected]);
228
+ }
229
+ enforceSelectionPolicy(buttons, selected, single, allowEmpty) {
230
+ if (single && selected.length > 1) {
231
+ const fresh = selected.filter((button) => !this.#lastSelected.includes(button));
232
+ const keep = fresh.length < selected.length ? fresh[fresh.length - 1] ?? selected[0] : selected[0];
233
+ selected.filter((button) => button !== keep).forEach((button) => button.selected.set(false));
234
+ this.#lastSelected = [keep];
235
+ this.commitValue();
236
+ return;
237
+ }
238
+ if (single && !allowEmpty && selected.length === 0 && this.value() === void 0) {
239
+ const previous = this.#lastSelected.find((button) => buttons.includes(button));
240
+ previous?.selected.set(true);
241
+ if (previous) return;
242
+ }
243
+ this.#lastSelected = selected;
244
+ }
245
+ setSubscriptions() {
246
+ this.#buttonService.buttonClick$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(([button, wasSelected]) => {
247
+ if (this.readonly()) return;
248
+ if (this.selection() === "single") {
249
+ if (wasSelected && !this.allowEmpty()) return;
250
+ this.buttons().forEach((b) => {
251
+ if (b.selected()) this.#buttonService.buttonSelect$.next([b, false]);
252
+ });
253
+ if (!wasSelected) this.#buttonService.buttonSelect$.next([button, true]);
254
+ } else this.#buttonService.buttonSelect$.next([button, !wasSelected]);
255
+ this.commitValue();
256
+ this.touch.emit();
257
+ });
258
+ }
259
+ valueButtons() {
260
+ return this.buttons().filter((button) => button.effectiveToggleable() && button.value() !== void 0);
261
+ }
262
+ valuesOf(value) {
263
+ if (value == null) return [];
264
+ return Array.isArray(value) ? value : [value];
265
+ }
266
+ static {
267
+ this.ɵfac = i0.ɵɵngDeclareFactory({
268
+ minVersion: "12.0.0",
269
+ version: "22.2.6",
270
+ ngImport: i0,
271
+ type: ButtonGroupComponent,
272
+ deps: [],
273
+ target: i0.ɵɵFactoryTarget.Component
274
+ });
275
+ }
276
+ static {
277
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
278
+ minVersion: "17.2.0",
279
+ version: "22.2.6",
280
+ type: ButtonGroupComponent,
281
+ isStandalone: true,
282
+ selector: "mona-button-group",
283
+ inputs: {
284
+ allowEmpty: {
285
+ classPropertyName: "allowEmpty",
286
+ publicName: "allowEmpty",
287
+ isSignal: true,
288
+ isRequired: false,
289
+ transformFunction: null
290
+ },
291
+ ariaLabel: {
292
+ classPropertyName: "ariaLabel",
293
+ publicName: "aria-label",
294
+ isSignal: true,
295
+ isRequired: false,
296
+ transformFunction: null
297
+ },
298
+ ariaLabelledBy: {
299
+ classPropertyName: "ariaLabelledBy",
300
+ publicName: "aria-labelledby",
301
+ isSignal: true,
302
+ isRequired: false,
303
+ transformFunction: null
304
+ },
305
+ disabled: {
306
+ classPropertyName: "disabled",
307
+ publicName: "disabled",
308
+ isSignal: true,
309
+ isRequired: false,
310
+ transformFunction: null
311
+ },
312
+ invalid: {
313
+ classPropertyName: "invalid",
314
+ publicName: "invalid",
315
+ isSignal: true,
316
+ isRequired: false,
317
+ transformFunction: null
318
+ },
319
+ look: {
320
+ classPropertyName: "look",
321
+ publicName: "look",
322
+ isSignal: true,
323
+ isRequired: false,
324
+ transformFunction: null
325
+ },
326
+ readonly: {
327
+ classPropertyName: "readonly",
328
+ publicName: "readonly",
329
+ isSignal: true,
330
+ isRequired: false,
331
+ transformFunction: null
332
+ },
333
+ rounded: {
334
+ classPropertyName: "rounded",
335
+ publicName: "rounded",
336
+ isSignal: true,
337
+ isRequired: false,
338
+ transformFunction: null
339
+ },
340
+ selection: {
341
+ classPropertyName: "selection",
342
+ publicName: "selection",
343
+ isSignal: true,
344
+ isRequired: false,
345
+ transformFunction: null
346
+ },
347
+ size: {
348
+ classPropertyName: "size",
349
+ publicName: "size",
350
+ isSignal: true,
351
+ isRequired: false,
352
+ transformFunction: null
353
+ },
354
+ touched: {
355
+ classPropertyName: "touched",
356
+ publicName: "touched",
357
+ isSignal: true,
358
+ isRequired: false,
359
+ transformFunction: null
360
+ },
361
+ userClass: {
362
+ classPropertyName: "userClass",
363
+ publicName: "class",
364
+ isSignal: true,
365
+ isRequired: false,
366
+ transformFunction: null
367
+ },
368
+ value: {
369
+ classPropertyName: "value",
370
+ publicName: "value",
371
+ isSignal: true,
372
+ isRequired: false,
373
+ transformFunction: null
374
+ }
375
+ },
376
+ outputs: {
377
+ buttonClick: "buttonClick",
378
+ touch: "touch",
379
+ value: "valueChange"
380
+ },
381
+ host: {
382
+ attributes: { "role": "group" },
383
+ listeners: { "focusout": "onFocusOut($event)" },
384
+ properties: {
385
+ "attr.aria-invalid": "invalidState() ? 'true' : null",
386
+ "attr.aria-label": "labelledBy() ? null : ariaLabel() || messages().buttonGroup",
387
+ "attr.aria-labelledby": "labelledBy()",
388
+ "attr.data-invalid": "invalidState() || null",
389
+ "attr.data-readonly": "readonly() || null",
390
+ "class": "baseClass()"
391
+ }
392
+ },
393
+ providers: [ButtonService],
394
+ queries: [{
395
+ propertyName: "buttons",
396
+ predicate: ButtonDirective,
397
+ isSignal: true
398
+ }, {
399
+ propertyName: "components",
400
+ predicate: BUTTON_GROUP_MEMBER,
401
+ isSignal: true
402
+ }],
403
+ ngImport: i0,
404
+ template: "<ng-content select=\"[monaButton], mona-dropdown-button, mona-split-button\"></ng-content>\n"
405
+ });
406
+ }
407
+ };
408
+ i0.ɵɵngDeclareClassMetadata({
409
+ minVersion: "12.0.0",
410
+ version: "22.2.6",
411
+ ngImport: i0,
412
+ type: ButtonGroupComponent,
413
+ decorators: [{
414
+ type: Component,
415
+ args: [{
416
+ selector: "mona-button-group",
417
+ providers: [ButtonService],
418
+ host: {
419
+ "[attr.aria-invalid]": "invalidState() ? 'true' : null",
420
+ "[attr.aria-label]": "labelledBy() ? null : ariaLabel() || messages().buttonGroup",
421
+ "[attr.aria-labelledby]": "labelledBy()",
422
+ "[attr.data-invalid]": "invalidState() || null",
423
+ "[attr.data-readonly]": "readonly() || null",
424
+ "(focusout)": "onFocusOut($event)",
425
+ "[class]": "baseClass()",
426
+ role: "group"
427
+ },
428
+ template: "<ng-content select=\"[monaButton], mona-dropdown-button, mona-split-button\"></ng-content>\n"
429
+ }]
430
+ }],
431
+ ctorParameters: () => [],
432
+ propDecorators: {
433
+ buttons: [{
434
+ type: i0.ContentChildren,
435
+ args: [i0.forwardRef(() => ButtonDirective), { isSignal: true }]
436
+ }],
437
+ components: [{
438
+ type: i0.ContentChildren,
439
+ args: [i0.forwardRef(() => BUTTON_GROUP_MEMBER), { isSignal: true }]
440
+ }],
441
+ allowEmpty: [{
442
+ type: i0.Input,
443
+ args: [{
444
+ isSignal: true,
445
+ alias: "allowEmpty",
446
+ required: false
447
+ }]
448
+ }],
449
+ ariaLabel: [{
450
+ type: i0.Input,
451
+ args: [{
452
+ isSignal: true,
453
+ alias: "aria-label",
454
+ required: false
455
+ }]
456
+ }],
457
+ ariaLabelledBy: [{
458
+ type: i0.Input,
459
+ args: [{
460
+ isSignal: true,
461
+ alias: "aria-labelledby",
462
+ required: false
463
+ }]
464
+ }],
465
+ buttonClick: [{
466
+ type: i0.Output,
467
+ args: ["buttonClick"]
468
+ }],
469
+ disabled: [{
470
+ type: i0.Input,
471
+ args: [{
472
+ isSignal: true,
473
+ alias: "disabled",
474
+ required: false
475
+ }]
476
+ }],
477
+ invalid: [{
478
+ type: i0.Input,
479
+ args: [{
480
+ isSignal: true,
481
+ alias: "invalid",
482
+ required: false
483
+ }]
484
+ }],
485
+ look: [{
486
+ type: i0.Input,
487
+ args: [{
488
+ isSignal: true,
489
+ alias: "look",
490
+ required: false
491
+ }]
492
+ }],
493
+ readonly: [{
494
+ type: i0.Input,
495
+ args: [{
496
+ isSignal: true,
497
+ alias: "readonly",
498
+ required: false
499
+ }]
500
+ }],
501
+ rounded: [{
502
+ type: i0.Input,
503
+ args: [{
504
+ isSignal: true,
505
+ alias: "rounded",
506
+ required: false
507
+ }]
508
+ }],
509
+ selection: [{
510
+ type: i0.Input,
511
+ args: [{
512
+ isSignal: true,
513
+ alias: "selection",
514
+ required: false
515
+ }]
516
+ }],
517
+ size: [{
518
+ type: i0.Input,
519
+ args: [{
520
+ isSignal: true,
521
+ alias: "size",
522
+ required: false
523
+ }]
524
+ }],
525
+ touch: [{
526
+ type: i0.Output,
527
+ args: ["touch"]
528
+ }],
529
+ touched: [{
530
+ type: i0.Input,
531
+ args: [{
532
+ isSignal: true,
533
+ alias: "touched",
534
+ required: false
535
+ }]
536
+ }],
537
+ userClass: [{
538
+ type: i0.Input,
539
+ args: [{
540
+ isSignal: true,
541
+ alias: "class",
542
+ required: false
543
+ }]
544
+ }],
545
+ value: [{
546
+ type: i0.Input,
547
+ args: [{
548
+ isSignal: true,
549
+ alias: "value",
550
+ required: false
551
+ }]
552
+ }, {
553
+ type: i0.Output,
554
+ args: ["valueChange"]
555
+ }]
556
+ }
91
557
  });
92
-
93
- class ButtonGroupComponent {
94
- #buttonService;
95
- #destroyRef;
96
- #hostElementRef;
97
- #i18n;
98
- #label;
99
- /** The buttons seen selected last time, to tell which one is new and which one to bring back. */
100
- #lastSelected;
101
- constructor() {
102
- this.#buttonService = inject(ButtonService, { self: true });
103
- this.#destroyRef = inject(DestroyRef);
104
- this.#hostElementRef = inject(ElementRef);
105
- this.#i18n = inject(MonaI18nService);
106
- this.#label = injectLabelAssociation({
107
- activate: () => this.focus(),
108
- ariaLabel: () => this.ariaLabel(),
109
- ariaLabelledBy: () => this.ariaLabelledBy()
110
- });
111
- /** The buttons seen selected last time, to tell which one is new and which one to bring back. */
112
- this.#lastSelected = [];
113
- this.baseClass = computed(() => {
114
- const look = this.look();
115
- const rounded = this.rounded();
116
- const size = this.size();
117
- const variantClasses = buttonGroupThemeVariants({ look, rounded, size });
118
- const userClass = this.userClass();
119
- return twMerge(variantClasses, userClass);
120
- }, /* @ts-ignore */
121
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
122
- /**
123
- * The group's own buttons: they follow its look, size, rounding and disabled state, and its selection.
124
- */
125
- this.buttons = contentChildren(ButtonDirective, /* @ts-ignore */
126
- ...(ngDevMode ? [{ debugName: "buttons" }] : /* istanbul ignore next */ []));
127
- /**
128
- * Dropdown and split buttons placed in the group. Their buttons follow the group's look, size, rounding and
129
- * disabled state, but not its selection.
130
- */
131
- this.components = contentChildren(BUTTON_GROUP_MEMBER, /* @ts-ignore */
132
- ...(ngDevMode ? [{ debugName: "components" }] : /* istanbul ignore next */ []));
133
- this.effectiveDisabled = injectEffectiveDisabled(() => this.disabled());
134
- this.invalidState = computed(() => this.touched() && this.invalid(), /* @ts-ignore */
135
- ...(ngDevMode ? [{ debugName: "invalidState" }] : /* istanbul ignore next */ []));
136
- this.labelledBy = this.#label.labelledBy;
137
- this.members = computed(() => [
138
- ...this.buttons(),
139
- ...this.components().flatMap(component => component.groupButtons())
140
- ], /* @ts-ignore */
141
- ...(ngDevMode ? [{ debugName: "members" }] : /* istanbul ignore next */ []));
142
- this.messages = this.#i18n.componentMessages("buttonGroup", BUTTON_GROUP_DEFAULT_MESSAGES);
143
- /**
144
- * @description When `false` and `selection` is `"single"`, a selected button stays selected until another one takes
145
- * over: the active button can't be deselected, and clearing every `selected` brings it back. It doesn't choose a
146
- * first button, and a `value` of `null` still clears the group, so a form can reset it. Has no effect in `"multiple"`
147
- * mode.
148
- * @default true
149
- */
150
- this.allowEmpty = input(true, { ...(ngDevMode ? { debugName: "allowEmpty" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
151
- /**
152
- * @description Accessible name for the host element. Override when multiple button groups appear on the same page
153
- * so screen reader users can distinguish them.
154
- */
155
- this.ariaLabel = input(undefined, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
156
- /**
157
- * @description Id of the element that names the group.
158
- * @default ""
159
- */
160
- this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
161
- /**
162
- * @description Emitted when a button placed directly in the group is clicked, toggleable or not, after the group has
163
- * applied its selection. Not emitted for a dropdown or split button's own buttons, for a disabled button, or for a
164
- * toggle button while the group is read-only, since nothing was selected.
165
- */
166
- this.buttonClick = outputFromObservable(this.#buttonService.memberClick$.pipe(filter(([button]) => this.buttons().includes(button) && !(this.readonly() && button.effectiveToggleable())), map(([button, element]) => ({
167
- button: element,
168
- selected: button.selected(),
169
- value: button.value()
170
- })), takeUntilDestroyed(this.#destroyRef)));
171
- /**
172
- * @description Renders all child buttons with reduced visual emphasis and removes pointer interaction. When bound to
173
- * a signal form field via `[formField]`, this is written by the `FormField` directive.
174
- * @default false
175
- */
176
- this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
177
- /**
178
- * @description Marks the group as invalid. Error styling requires both `invalid` and `touched` to be `true`. When
179
- * bound to a signal form field via `[formField]`, this is written by the `FormField` directive.
180
- * @default false
181
- */
182
- this.invalid = input(false, { ...(ngDevMode ? { debugName: "invalid" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
183
- /**
184
- * @description Visual style variant propagated to all child buttons.
185
- * Also controls container-level divider and border behavior.
186
- * @default "outline"
187
- */
188
- this.look = input("outline", /* @ts-ignore */
189
- ...(ngDevMode ? [{ debugName: "look" }] : /* istanbul ignore next */ []));
190
- /**
191
- * @description Prevents selection changes while the buttons stay focusable. Buttons that aren't toggleable keep
192
- * working. When bound to a signal form field via `[formField]`, this is written by the `FormField` directive.
193
- * @default false
194
- */
195
- this.readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
196
- /**
197
- * @description Border-radius preset applied to the container and the outer corners of the first and last child button.
198
- * @default "medium"
199
- */
200
- this.rounded = input("medium", /* @ts-ignore */
201
- ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
202
- /**
203
- * @description Whether one button can be selected at a time (`"single"`) or each toggles on its own (`"multiple"`).
204
- * The buttons stay toggle buttons with `aria-pressed` in both. For a choice that must always hold one value, use
205
- * `mona-segmented`, which is a radio group.
206
- * @default "multiple"
207
- */
208
- this.selection = input("multiple", /* @ts-ignore */
209
- ...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
210
- /**
211
- * @description Size preset propagated to all child buttons, overriding their individual `size` inputs.
212
- * @default "medium"
213
- */
214
- this.size = input("medium", /* @ts-ignore */
215
- ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
216
- /**
217
- * @description Emitted when a user changes the selection or focus leaves the group.
218
- * The `FormField` directive listens to this to mark the field as touched.
219
- */
220
- this.touch = output();
221
- /**
222
- * @description Marks the group as touched. When bound to a signal form field via `[formField]`, this is written by
223
- * the `FormField` directive.
224
- * @default false
225
- */
226
- this.touched = input(false, { ...(ngDevMode ? { debugName: "touched" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
227
- /**
228
- * @description Additional CSS classes merged onto the host element via `tailwind-merge`.
229
- * @default ""
230
- */
231
- this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
232
- /**
233
- * @description The value of the selected button in `"single"` mode, or `null`, and an array of the selected buttons'
234
- * values in `"multiple"` mode. Buttons take part by having a `value`. While `undefined`, it leaves each button's
235
- * `selected` alone. A value with no button yet stays, so one that loads before its button isn't lost. Use either this
236
- * or `[(selected)]` on the buttons, not both.
237
- * @default undefined
238
- */
239
- this.value = model(undefined, /* @ts-ignore */
240
- ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
241
- this.#buttonService.setMembers(this.members);
242
- effect(() => {
243
- const disabled = this.effectiveDisabled();
244
- untracked(() => this.#buttonService.groupDisabled.set(disabled));
245
- });
246
- effect(() => {
247
- const readonly = this.readonly();
248
- untracked(() => this.#buttonService.groupReadonly.set(readonly));
249
- });
250
- effect(() => {
251
- const look = this.look();
252
- untracked(() => this.#buttonService.groupLook.set(look));
253
- });
254
- effect(() => {
255
- const rounded = this.rounded();
256
- untracked(() => this.#buttonService.groupRounded.set(rounded));
257
- });
258
- effect(() => {
259
- const size = this.size();
260
- untracked(() => this.#buttonService.groupSize.set(size));
261
- });
262
- effect(() => {
263
- const value = this.value();
264
- if (value === undefined) {
265
- return;
266
- }
267
- const values = this.valuesOf(value);
268
- for (const button of this.valueButtons()) {
269
- const selected = values.includes(button.value());
270
- untracked(() => button.selected.set(selected));
271
- }
272
- });
273
- effect(() => {
274
- const buttons = this.buttons();
275
- const selected = buttons.filter(button => button.selected());
276
- const single = this.selection() === "single";
277
- const allowEmpty = this.allowEmpty();
278
- untracked(() => this.enforceSelectionPolicy(buttons, selected, single, allowEmpty));
279
- });
280
- afterNextRender({
281
- read: () => this.setSubscriptions()
282
- });
283
- }
284
- /**
285
- * @description Moves focus to the selected button, or the first enabled one.
286
- * @param options Options passed to the native `focus()` call, such as `preventScroll`.
287
- */
288
- focus(options) {
289
- const host = this.#hostElementRef.nativeElement;
290
- const target = host.querySelector("button[aria-pressed='true']:not(:disabled)") ??
291
- host.querySelector("button:not(:disabled)");
292
- target?.focus(options);
293
- }
294
- /**
295
- * @internal
296
- */
297
- setLabelledBy(id) {
298
- this.#label.setLabelledBy(id);
299
- }
300
- onFocusOut(event) {
301
- const nextTarget = event.relatedTarget;
302
- if (nextTarget instanceof Node && this.#hostElementRef.nativeElement.contains(nextTarget)) {
303
- return;
304
- }
305
- this.touch.emit();
306
- }
307
- commitValue() {
308
- const buttons = this.valueButtons();
309
- if (buttons.length === 0) {
310
- return;
311
- }
312
- const selected = buttons.filter(button => button.selected()).map(button => button.value());
313
- if (this.selection() === "single") {
314
- this.value.set(selected[0] ?? null);
315
- return;
316
- }
317
- const known = buttons.map(button => button.value());
318
- const waiting = this.valuesOf(this.value()).filter(value => !known.includes(value));
319
- this.value.set([...waiting, ...selected]);
320
- }
321
- /**
322
- * Holds the group to `selection` and `allowEmpty` however a button's `selected` changed, since a binding can change
323
- * it as well as a click. A form's `value` of `null` is left alone, so the form can reset the group.
324
- */
325
- enforceSelectionPolicy(buttons, selected, single, allowEmpty) {
326
- if (single && selected.length > 1) {
327
- // Both new, as on the first render, keeps the first. A new one next to an old one keeps the new one.
328
- const fresh = selected.filter(button => !this.#lastSelected.includes(button));
329
- const keep = fresh.length < selected.length ? (fresh[fresh.length - 1] ?? selected[0]) : selected[0];
330
- selected.filter(button => button !== keep).forEach(button => button.selected.set(false));
331
- this.#lastSelected = [keep];
332
- this.commitValue();
333
- return;
334
- }
335
- if (single && !allowEmpty && selected.length === 0 && this.value() === undefined) {
336
- const previous = this.#lastSelected.find(button => buttons.includes(button));
337
- previous?.selected.set(true);
338
- if (previous) {
339
- return;
340
- }
341
- }
342
- this.#lastSelected = selected;
343
- }
344
- setSubscriptions() {
345
- this.#buttonService.buttonClick$
346
- .pipe(takeUntilDestroyed(this.#destroyRef))
347
- .subscribe(([button, wasSelected]) => {
348
- if (this.readonly()) {
349
- return;
350
- }
351
- if (this.selection() === "single") {
352
- if (wasSelected && !this.allowEmpty()) {
353
- return;
354
- }
355
- this.buttons().forEach(b => {
356
- if (b.selected()) {
357
- this.#buttonService.buttonSelect$.next([b, false]);
358
- }
359
- });
360
- if (!wasSelected) {
361
- this.#buttonService.buttonSelect$.next([button, true]);
362
- }
363
- }
364
- else {
365
- this.#buttonService.buttonSelect$.next([button, !wasSelected]);
366
- }
367
- this.commitValue();
368
- this.touch.emit();
369
- });
370
- }
371
- valueButtons() {
372
- return this.buttons().filter(button => button.effectiveToggleable() && button.value() !== undefined);
373
- }
374
- valuesOf(value) {
375
- if (value == null) {
376
- return [];
377
- }
378
- return Array.isArray(value) ? value : [value];
379
- }
380
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonGroupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
381
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: ButtonGroupComponent, isStandalone: true, selector: "mona-button-group", inputs: { allowEmpty: { classPropertyName: "allowEmpty", publicName: "allowEmpty", isSignal: true, isRequired: false, transformFunction: null }, 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 }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, look: { classPropertyName: "look", publicName: "look", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, touched: { classPropertyName: "touched", publicName: "touched", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { buttonClick: "buttonClick", touch: "touch", value: "valueChange" }, host: { attributes: { "role": "group" }, listeners: { "focusout": "onFocusOut($event)" }, properties: { "attr.aria-invalid": "invalidState() ? 'true' : null", "attr.aria-label": "labelledBy() ? null : ariaLabel() || messages().buttonGroup", "attr.aria-labelledby": "labelledBy()", "attr.data-invalid": "invalidState() || null", "attr.data-readonly": "readonly() || null", "class": "baseClass()" } }, providers: [ButtonService], queries: [{ propertyName: "buttons", predicate: ButtonDirective, isSignal: true }, { propertyName: "components", predicate: BUTTON_GROUP_MEMBER, isSignal: true }], ngImport: i0, template: "<ng-content select=\"[monaButton], mona-dropdown-button, mona-split-button\"></ng-content>\n" }); }
382
- }
383
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ButtonGroupComponent, decorators: [{
384
- type: Component,
385
- args: [{ selector: "mona-button-group", providers: [ButtonService], host: {
386
- "[attr.aria-invalid]": "invalidState() ? 'true' : null",
387
- "[attr.aria-label]": "labelledBy() ? null : ariaLabel() || messages().buttonGroup",
388
- "[attr.aria-labelledby]": "labelledBy()",
389
- "[attr.data-invalid]": "invalidState() || null",
390
- "[attr.data-readonly]": "readonly() || null",
391
- "(focusout)": "onFocusOut($event)",
392
- "[class]": "baseClass()",
393
- role: "group"
394
- }, template: "<ng-content select=\"[monaButton], mona-dropdown-button, mona-split-button\"></ng-content>\n" }]
395
- }], ctorParameters: () => [], propDecorators: { buttons: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => ButtonDirective), { isSignal: true }] }], components: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => BUTTON_GROUP_MEMBER), { isSignal: true }] }], allowEmpty: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowEmpty", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], buttonClick: [{ type: i0.Output, args: ["buttonClick"] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], look: [{ type: i0.Input, args: [{ isSignal: true, alias: "look", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], touch: [{ type: i0.Output, args: ["touch"] }], touched: [{ type: i0.Input, args: [{ isSignal: true, alias: "touched", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
396
-
397
- /*
398
- * Public API Surface of @nanahoshi/mona-ui/button-group
399
- */
400
-
401
- /**
402
- * Generated bundle index. Do not edit.
403
- */
404
-
405
558
  export { BUTTON_GROUP_DEFAULT_MESSAGES, ButtonGroupComponent };
406
- //# sourceMappingURL=nanahoshi-mona-ui-button-group.mjs.map
559
+
560
+ //# sourceMappingURL=nanahoshi-mona-ui-button-group.mjs.map