@nanahoshi/mona-ui 0.27.2 → 0.29.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 (213) hide show
  1. package/docs/api/chart.md +2 -2
  2. package/docs/api/locales.md +8 -0
  3. package/docs/api/popup.md +1 -1
  4. package/docs/api/theme.md +2 -2
  5. package/docs/chart.md +14 -0
  6. package/docs/editor.md +2 -0
  7. package/docs/installation.md +147 -15
  8. package/docs/introduction.md +37 -15
  9. package/docs/theming-built-in-themes.md +67 -0
  10. package/docs/theming-custom-colors.md +274 -0
  11. package/docs/theming-custom-themes.md +168 -0
  12. package/docs/theming.md +164 -248
  13. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  14. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  15. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  16. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  17. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  18. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2071 -1573
  19. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  20. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  21. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  22. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  23. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  24. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
  25. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  26. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  27. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  28. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  29. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  30. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
  31. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  32. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
  33. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  34. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  35. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  36. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  37. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  38. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
  39. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  40. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  41. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  42. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  43. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  44. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  45. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  46. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  47. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  48. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  49. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  50. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  51. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
  52. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  53. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  54. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  55. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  56. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  57. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  58. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  59. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  60. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  61. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  62. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  63. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  64. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  65. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  66. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  67. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  68. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  69. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  70. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +599 -0
  71. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  72. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  73. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  74. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  75. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  76. package/fesm2022/nanahoshi-mona-ui-locales.mjs +61 -77
  77. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  78. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  79. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  80. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  81. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  82. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  83. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  84. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  85. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  86. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  87. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  88. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  89. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  90. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  91. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  92. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  93. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  94. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  95. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  96. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  97. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  98. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  99. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  100. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  101. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  102. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  103. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  104. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  105. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  106. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  107. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  108. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  109. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  110. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  111. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  112. package/llms.txt +7 -3
  113. package/locales/pl-pl/package.json +4 -0
  114. package/locales/pl-pl/pl-pl.messages.json +536 -0
  115. package/package.json +66 -23
  116. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  117. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  118. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  119. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  120. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  121. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  122. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  123. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  124. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  125. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  126. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  127. package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
  128. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  129. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  130. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  131. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  132. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  133. package/types/nanahoshi-mona-ui-common.d.ts +354 -385
  134. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  135. package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
  136. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  137. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  138. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  139. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  140. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  141. package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
  142. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  143. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  144. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  145. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  146. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  147. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  148. package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
  149. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  150. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  151. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  152. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  153. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  154. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  155. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  156. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  157. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  158. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  159. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  160. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  161. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  162. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  163. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  164. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  165. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  166. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  167. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +540 -0
  168. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  169. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  170. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  171. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  172. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  173. package/types/nanahoshi-mona-ui-locales.d.ts +18 -19
  174. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  175. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  176. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  177. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  178. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  179. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  180. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  181. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  182. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  183. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  184. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  185. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  186. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  187. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  188. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  189. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  190. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  191. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  192. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  193. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  194. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  195. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  196. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  197. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  198. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  199. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  200. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  201. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  202. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  203. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  204. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  205. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  206. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  207. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  208. package/types/nanahoshi-mona-ui.d.ts +1 -2
  209. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  210. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  211. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  212. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  213. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
@@ -1,1029 +1,1328 @@
1
- import { LiveAnnouncer } from '@angular/cdk/a11y';
2
- import { NgTemplateOutlet } from '@angular/common';
3
- import * as i0 from '@angular/core';
4
- import { Directive, input, booleanAttribute, inject, ElementRef, Injector, computed, signal, contentChild, TemplateRef, output, effect, untracked, afterNextRender, Component } from '@angular/core';
5
- import { toObservable } from '@angular/core/rxjs-interop';
6
- import { LucideChevronUp, LucideChevronDown, LucideChevronLeft, LucideChevronRight, LucideChevronsLeft, LucideChevronsRight, LucideX, LucideTrash2 } from '@lucide/angular';
7
- import { ImmutableList } from '@mirei/ts-collections';
8
- import { ButtonDirective } from '@nanahoshi/mona-ui/button';
9
- import { formatNumber, injectComponentDirection, MonaI18nService } from '@nanahoshi/mona-ui/i18n';
10
- import { injectLabelledByText } from '@nanahoshi/mona-ui/internal';
11
- import { ListService, LIST_VIEW_HOST_LIST_SERVICE } from '@nanahoshi/mona-ui/internal/list';
12
- import { ListViewComponent, ListViewSelectableDirective, ListViewItemTemplateDirective, ListViewNavigableDirective, ListViewNoDataTemplateDirective, ListViewFooterTemplateDirective, ListViewHeaderTemplateDirective } from '@nanahoshi/mona-ui/list-view';
13
- import { PreventableEvent } from '@nanahoshi/mona-ui/common';
14
- import { cva } from 'class-variance-authority';
15
-
16
- class ListBoxFooterTemplateDirective {
17
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListBoxFooterTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
18
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ListBoxFooterTemplateDirective, isStandalone: true, selector: "ng-template[monaListBoxFooterTemplate]", ngImport: i0 }); }
19
- }
20
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListBoxFooterTemplateDirective, decorators: [{
21
- type: Directive,
22
- args: [{
23
- selector: "ng-template[monaListBoxFooterTemplate]"
24
- }]
25
- }] });
26
-
27
- class ListBoxHeaderTemplateDirective {
28
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListBoxHeaderTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
29
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ListBoxHeaderTemplateDirective, isStandalone: true, selector: "ng-template[monaListBoxHeaderTemplate]", ngImport: i0 }); }
30
- }
31
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListBoxHeaderTemplateDirective, decorators: [{
32
- type: Directive,
33
- args: [{
34
- selector: "ng-template[monaListBoxHeaderTemplate]"
35
- }]
36
- }] });
37
-
38
- /**
39
- * Template for each item of a list box. The data item is the template's implicit value (`let-item`). Bind the list
40
- * box's items to `monaListBoxItemTemplateOf` to type it; without it, the item is `any` in templates.
41
- */
42
- // `any` by default: a template without `monaListBoxItemTemplateOf` keeps an untyped item, as before the guard existed.
43
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
- class ListBoxItemTemplateDirective {
45
- constructor() {
46
- /**
47
- * @description The list box's items, used only to type the template's item. Optional.
48
- * @default null
49
- */
50
- this.monaListBoxItemTemplateOf = input(null, /* @ts-ignore */
51
- ...(ngDevMode ? [{ debugName: "monaListBoxItemTemplateOf" }] : /* istanbul ignore next */ []));
52
- }
53
- static ngTemplateContextGuard(_directive, _context) {
54
- return true;
55
- }
56
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListBoxItemTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
57
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: ListBoxItemTemplateDirective, isStandalone: true, selector: "ng-template[monaListBoxItemTemplate]", inputs: { monaListBoxItemTemplateOf: { classPropertyName: "monaListBoxItemTemplateOf", publicName: "monaListBoxItemTemplateOf", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
58
- }
59
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListBoxItemTemplateDirective, decorators: [{
60
- type: Directive,
61
- args: [{
62
- selector: "ng-template[monaListBoxItemTemplate]"
63
- }]
64
- }], propDecorators: { monaListBoxItemTemplateOf: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaListBoxItemTemplateOf", required: false }] }] } });
65
-
66
- class ListBoxNoDataTemplateDirective {
67
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListBoxNoDataTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
68
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ListBoxNoDataTemplateDirective, isStandalone: true, selector: "ng-template[monaListBoxNoDataTemplate]", ngImport: i0 }); }
69
- }
70
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListBoxNoDataTemplateDirective, decorators: [{
71
- type: Directive,
72
- args: [{
73
- selector: "ng-template[monaListBoxNoDataTemplate]"
74
- }]
75
- }] });
76
-
77
- // Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
78
- // Edit the JSON file and run `npm run generate:locale-catalogs`.
1
+ import { LiveAnnouncer } from "@angular/cdk/a11y";
2
+ import { NgTemplateOutlet } from "@angular/common";
3
+ import * as i0 from "@angular/core";
4
+ import { Component, Directive, ElementRef, Injector, TemplateRef, afterNextRender, booleanAttribute, computed, contentChild, effect, inject, input, output, signal, untracked } from "@angular/core";
5
+ import { toObservable } from "@angular/core/rxjs-interop";
6
+ import { LucideChevronDown, LucideChevronLeft, LucideChevronRight, LucideChevronUp, LucideChevronsLeft, LucideChevronsRight, LucideTrash2, LucideX } from "@lucide/angular";
7
+ import { ImmutableList } from "@mirei/ts-collections";
8
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
9
+ import { MonaI18nService, formatNumber, injectComponentDirection } from "@nanahoshi/mona-ui/i18n";
10
+ import { injectLabelledByText } from "@nanahoshi/mona-ui/internal";
11
+ import { LIST_VIEW_HOST_LIST_SERVICE, ListService } from "@nanahoshi/mona-ui/internal/list";
12
+ import { ListViewComponent, ListViewFooterTemplateDirective, ListViewHeaderTemplateDirective, ListViewItemTemplateDirective, ListViewNavigableDirective, ListViewNoDataTemplateDirective, ListViewSelectableDirective } from "@nanahoshi/mona-ui/list-view";
13
+ import { PreventableEvent } from "@nanahoshi/mona-ui/common";
14
+ import { cva } from "class-variance-authority";
15
+ var ListBoxFooterTemplateDirective = class ListBoxFooterTemplateDirective {
16
+ static {
17
+ this.ɵfac = i0.ɵɵngDeclareFactory({
18
+ minVersion: "12.0.0",
19
+ version: "22.2.6",
20
+ ngImport: i0,
21
+ type: ListBoxFooterTemplateDirective,
22
+ deps: [],
23
+ target: i0.ɵɵFactoryTarget.Directive
24
+ });
25
+ }
26
+ static {
27
+ this.ɵdir = i0.ɵɵngDeclareDirective({
28
+ minVersion: "14.0.0",
29
+ version: "22.2.6",
30
+ type: ListBoxFooterTemplateDirective,
31
+ isStandalone: true,
32
+ selector: "ng-template[monaListBoxFooterTemplate]",
33
+ ngImport: i0
34
+ });
35
+ }
36
+ };
37
+ i0.ɵɵngDeclareClassMetadata({
38
+ minVersion: "12.0.0",
39
+ version: "22.2.6",
40
+ ngImport: i0,
41
+ type: ListBoxFooterTemplateDirective,
42
+ decorators: [{
43
+ type: Directive,
44
+ args: [{ selector: "ng-template[monaListBoxFooterTemplate]" }]
45
+ }]
46
+ });
47
+ var ListBoxHeaderTemplateDirective = class ListBoxHeaderTemplateDirective {
48
+ static {
49
+ this.ɵfac = i0.ɵɵngDeclareFactory({
50
+ minVersion: "12.0.0",
51
+ version: "22.2.6",
52
+ ngImport: i0,
53
+ type: ListBoxHeaderTemplateDirective,
54
+ deps: [],
55
+ target: i0.ɵɵFactoryTarget.Directive
56
+ });
57
+ }
58
+ static {
59
+ this.ɵdir = i0.ɵɵngDeclareDirective({
60
+ minVersion: "14.0.0",
61
+ version: "22.2.6",
62
+ type: ListBoxHeaderTemplateDirective,
63
+ isStandalone: true,
64
+ selector: "ng-template[monaListBoxHeaderTemplate]",
65
+ ngImport: i0
66
+ });
67
+ }
68
+ };
69
+ i0.ɵɵngDeclareClassMetadata({
70
+ minVersion: "12.0.0",
71
+ version: "22.2.6",
72
+ ngImport: i0,
73
+ type: ListBoxHeaderTemplateDirective,
74
+ decorators: [{
75
+ type: Directive,
76
+ args: [{ selector: "ng-template[monaListBoxHeaderTemplate]" }]
77
+ }]
78
+ });
79
+ var ListBoxItemTemplateDirective = class ListBoxItemTemplateDirective {
80
+ constructor() {
81
+ this.monaListBoxItemTemplateOf = input(null, ...ngDevMode ? [{ debugName: "monaListBoxItemTemplateOf" }] : /* istanbul ignore next */ []);
82
+ }
83
+ static ngTemplateContextGuard(_directive, _context) {
84
+ return true;
85
+ }
86
+ static {
87
+ this.ɵfac = i0.ɵɵngDeclareFactory({
88
+ minVersion: "12.0.0",
89
+ version: "22.2.6",
90
+ ngImport: i0,
91
+ type: ListBoxItemTemplateDirective,
92
+ deps: [],
93
+ target: i0.ɵɵFactoryTarget.Directive
94
+ });
95
+ }
96
+ static {
97
+ this.ɵdir = i0.ɵɵngDeclareDirective({
98
+ minVersion: "17.1.0",
99
+ version: "22.2.6",
100
+ type: ListBoxItemTemplateDirective,
101
+ isStandalone: true,
102
+ selector: "ng-template[monaListBoxItemTemplate]",
103
+ inputs: { monaListBoxItemTemplateOf: {
104
+ classPropertyName: "monaListBoxItemTemplateOf",
105
+ publicName: "monaListBoxItemTemplateOf",
106
+ isSignal: true,
107
+ isRequired: false,
108
+ transformFunction: null
109
+ } },
110
+ ngImport: i0
111
+ });
112
+ }
113
+ };
114
+ i0.ɵɵngDeclareClassMetadata({
115
+ minVersion: "12.0.0",
116
+ version: "22.2.6",
117
+ ngImport: i0,
118
+ type: ListBoxItemTemplateDirective,
119
+ decorators: [{
120
+ type: Directive,
121
+ args: [{ selector: "ng-template[monaListBoxItemTemplate]" }]
122
+ }],
123
+ propDecorators: { monaListBoxItemTemplateOf: [{
124
+ type: i0.Input,
125
+ args: [{
126
+ isSignal: true,
127
+ alias: "monaListBoxItemTemplateOf",
128
+ required: false
129
+ }]
130
+ }] }
131
+ });
132
+ var ListBoxNoDataTemplateDirective = class ListBoxNoDataTemplateDirective {
133
+ static {
134
+ this.ɵfac = i0.ɵɵngDeclareFactory({
135
+ minVersion: "12.0.0",
136
+ version: "22.2.6",
137
+ ngImport: i0,
138
+ type: ListBoxNoDataTemplateDirective,
139
+ deps: [],
140
+ target: i0.ɵɵFactoryTarget.Directive
141
+ });
142
+ }
143
+ static {
144
+ this.ɵdir = i0.ɵɵngDeclareDirective({
145
+ minVersion: "14.0.0",
146
+ version: "22.2.6",
147
+ type: ListBoxNoDataTemplateDirective,
148
+ isStandalone: true,
149
+ selector: "ng-template[monaListBoxNoDataTemplate]",
150
+ ngImport: i0
151
+ });
152
+ }
153
+ };
154
+ i0.ɵɵngDeclareClassMetadata({
155
+ minVersion: "12.0.0",
156
+ version: "22.2.6",
157
+ ngImport: i0,
158
+ type: ListBoxNoDataTemplateDirective,
159
+ decorators: [{
160
+ type: Directive,
161
+ args: [{ selector: "ng-template[monaListBoxNoDataTemplate]" }]
162
+ }]
163
+ });
79
164
  function localizeNumber(value, options) {
80
- return formatNumber(value, "en-US", options);
165
+ return formatNumber(value, "en-US", options);
81
166
  }
82
167
  const LIST_BOX_DEFAULT_MESSAGES = {
83
- clearSelection: "Clear Selection",
84
- itemsMoved: (position, total) => `Moved to position ${localizeNumber(position)} of ${localizeNumber(total)}`,
85
- itemsRemoved: (count) => count === 1 ? `${localizeNumber(count)} item removed` : `${localizeNumber(count)} items removed`,
86
- itemsTransferred: (count, list) => count === 1
87
- ? `${localizeNumber(count)} item moved to ${list}`
88
- : `${localizeNumber(count)} items moved to ${list}`,
89
- itemsTransferredToOtherList: (count) => count === 1
90
- ? `${localizeNumber(count)} item moved to the other list`
91
- : `${localizeNumber(count)} items moved to the other list`,
92
- moveDown: "Move Down",
93
- moveUp: "Move Up",
94
- remove: "Remove",
95
- selectionCleared: "Selection cleared",
96
- toolbarLabel: (list) => `${list} actions`,
97
- transferAllFrom: "Transfer all from the other list",
98
- transferAllFromList: (list) => `Transfer all from ${list}`,
99
- transferAllTo: "Transfer all to the other list",
100
- transferAllToList: (list) => `Transfer all to ${list}`,
101
- transferFrom: "Transfer from the other list",
102
- transferFromList: (list) => `Transfer from ${list}`,
103
- transferTo: "Transfer to the other list",
104
- transferToList: (list) => `Transfer to ${list}`
168
+ clearSelection: "Clear Selection",
169
+ itemsMoved: (position, total) => `Moved to position ${localizeNumber(position)} of ${localizeNumber(total)}`,
170
+ itemsRemoved: (count) => count === 1 ? `${localizeNumber(count)} item removed` : `${localizeNumber(count)} items removed`,
171
+ itemsTransferred: (count, list) => count === 1 ? `${localizeNumber(count)} item moved to ${list}` : `${localizeNumber(count)} items moved to ${list}`,
172
+ itemsTransferredToOtherList: (count) => count === 1 ? `${localizeNumber(count)} item moved to the other list` : `${localizeNumber(count)} items moved to the other list`,
173
+ moveDown: "Move Down",
174
+ moveUp: "Move Up",
175
+ remove: "Remove",
176
+ selectionCleared: "Selection cleared",
177
+ toolbarLabel: (list) => `${list} actions`,
178
+ transferAllFrom: "Transfer all from the other list",
179
+ transferAllFromList: (list) => `Transfer all from ${list}`,
180
+ transferAllTo: "Transfer all to the other list",
181
+ transferAllToList: (list) => `Transfer all to ${list}`,
182
+ transferFrom: "Transfer from the other list",
183
+ transferFromList: (list) => `Transfer from ${list}`,
184
+ transferTo: "Transfer to the other list",
185
+ transferToList: (list) => `Transfer to ${list}`
186
+ };
187
+ var ListBoxClearEvent = class extends PreventableEvent {
188
+ #action = "clear";
189
+ #selectedItems;
190
+ constructor(selectedItems, originalEvent) {
191
+ super("listBoxClear", originalEvent);
192
+ this.#selectedItems = [...selectedItems];
193
+ }
194
+ get action() {
195
+ return this.#action;
196
+ }
197
+ get selectedItems() {
198
+ return this.#selectedItems;
199
+ }
200
+ };
201
+ var ListBoxMoveEvent = class extends PreventableEvent {
202
+ #action;
203
+ #newIndex;
204
+ #oldIndex;
205
+ #selectedIndices;
206
+ #selectedItems;
207
+ constructor(action, selectedItems, selectedIndices, oldIndex, newIndex, originalEvent) {
208
+ super("listBoxMove", originalEvent);
209
+ this.#action = action;
210
+ this.#newIndex = newIndex;
211
+ this.#oldIndex = oldIndex;
212
+ this.#selectedIndices = Array.from(selectedIndices);
213
+ this.#selectedItems = Array.from(selectedItems);
214
+ }
215
+ get action() {
216
+ return this.#action;
217
+ }
218
+ get newIndex() {
219
+ return this.#newIndex;
220
+ }
221
+ get oldIndex() {
222
+ return this.#oldIndex;
223
+ }
224
+ get selectedIndices() {
225
+ return this.#selectedIndices;
226
+ }
227
+ get selectedItems() {
228
+ return this.#selectedItems;
229
+ }
230
+ };
231
+ var ListBoxRemoveEvent = class extends PreventableEvent {
232
+ #action = "remove";
233
+ #selectedItems;
234
+ constructor(selectedItems, originalEvent) {
235
+ super("listBoxRemove", originalEvent);
236
+ this.#selectedItems = [...selectedItems];
237
+ }
238
+ get action() {
239
+ return this.#action;
240
+ }
241
+ get selectedItems() {
242
+ return this.#selectedItems;
243
+ }
244
+ };
245
+ var ListBoxTransferEvent = class extends PreventableEvent {
246
+ #action;
247
+ #selectedItems;
248
+ constructor(action, selectedItems, originalEvent) {
249
+ super("listBoxTransfer", originalEvent);
250
+ this.#action = action;
251
+ this.#selectedItems = Array.from(selectedItems);
252
+ }
253
+ get action() {
254
+ return this.#action;
255
+ }
256
+ get selectedItems() {
257
+ return this.#selectedItems;
258
+ }
105
259
  };
106
-
107
- // `any` by default, so an event annotated without a type argument keeps untyped items.
108
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
109
- class ListBoxClearEvent extends PreventableEvent {
110
- #action = "clear";
111
- #selectedItems;
112
- constructor(selectedItems, originalEvent) {
113
- super("listBoxClear", originalEvent);
114
- this.#selectedItems = [...selectedItems];
115
- }
116
- /** Discriminant matching the `ListBoxActionEvent` union. */
117
- get action() {
118
- return this.#action;
119
- }
120
- /** The items that were selected when Clear Selection was clicked. */
121
- get selectedItems() {
122
- return this.#selectedItems;
123
- }
124
- }
125
-
126
- // `any` by default, so an event annotated without a type argument keeps untyped items.
127
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
128
- class ListBoxMoveEvent extends PreventableEvent {
129
- #action;
130
- #newIndex;
131
- #oldIndex;
132
- #selectedIndices;
133
- #selectedItems;
134
- constructor(action, selectedItems, selectedIndices, oldIndex, newIndex, originalEvent) {
135
- super("listBoxMove", originalEvent);
136
- this.#action = action;
137
- this.#newIndex = newIndex;
138
- this.#oldIndex = oldIndex;
139
- this.#selectedIndices = Array.from(selectedIndices);
140
- this.#selectedItems = Array.from(selectedItems);
141
- }
142
- /** Discriminant matching the `ListBoxActionEvent` union. */
143
- get action() {
144
- return this.#action;
145
- }
146
- /** For Move Up, the index above the first selected item; for Move Down, the index below the last one. */
147
- get newIndex() {
148
- return this.#newIndex;
149
- }
150
- /** The index of the first selected item (in list order) before the move. */
151
- get oldIndex() {
152
- return this.#oldIndex;
153
- }
154
- /** Indices of all selected items before the move, ascending. */
155
- get selectedIndices() {
156
- return this.#selectedIndices;
157
- }
158
- /** The items that were selected when the move was requested. */
159
- get selectedItems() {
160
- return this.#selectedItems;
161
- }
162
- }
163
-
164
- // `any` by default, so an event annotated without a type argument keeps untyped items.
165
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
166
- class ListBoxRemoveEvent extends PreventableEvent {
167
- #action = "remove";
168
- #selectedItems;
169
- constructor(selectedItems, originalEvent) {
170
- super("listBoxRemove", originalEvent);
171
- this.#selectedItems = [...selectedItems];
172
- }
173
- /** Discriminant matching the `ListBoxActionEvent` union. */
174
- get action() {
175
- return this.#action;
176
- }
177
- /** The items that were selected when Remove was clicked. */
178
- get selectedItems() {
179
- return this.#selectedItems;
180
- }
181
- }
182
-
183
- // `any` by default, so an event annotated without a type argument keeps untyped items.
184
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
- class ListBoxTransferEvent extends PreventableEvent {
186
- #action;
187
- #selectedItems;
188
- constructor(action, selectedItems, originalEvent) {
189
- super("listBoxTransfer", originalEvent);
190
- this.#action = action;
191
- this.#selectedItems = Array.from(selectedItems);
192
- }
193
- /** Discriminant matching the `ListBoxActionEvent` union. */
194
- get action() {
195
- return this.#action;
196
- }
197
- /**
198
- * The items to transfer, in list order: the source's selection, or all of the source's items for the "All"
199
- * variants. See Which list box's `actionClick` fires.
200
- */
201
- get selectedItems() {
202
- return this.#selectedItems;
203
- }
204
- }
205
-
206
260
  const listBoxBaseThemeVariants = cva(`
207
261
  flex gap-1
208
262
  [&_mona-list-view]:w-full
209
263
  `, {
210
- variants: {
211
- direction: {
212
- horizontal: "flex-row",
213
- vertical: "flex-col"
214
- },
215
- reversed: {
216
- true: "",
217
- false: ""
218
- },
219
- rounded: {
220
- small: "rounded-sm",
221
- medium: "rounded-md",
222
- large: "rounded-lg",
223
- none: "rounded-none"
224
- },
225
- size: {
226
- small: "text-sm",
227
- medium: "text-base",
228
- large: "text-lg"
229
- }
230
- },
231
- compoundVariants: [
232
- {
233
- direction: "horizontal",
234
- reversed: true,
235
- class: "flex-row-reverse"
236
- },
237
- {
238
- direction: "vertical",
239
- reversed: true,
240
- class: "flex-col-reverse"
241
- }
242
- ]
264
+ variants: {
265
+ direction: {
266
+ horizontal: "flex-row",
267
+ vertical: "flex-col"
268
+ },
269
+ reversed: {
270
+ true: "",
271
+ false: ""
272
+ },
273
+ rounded: {
274
+ small: "rounded-sm",
275
+ medium: "rounded-md",
276
+ large: "rounded-lg",
277
+ none: "rounded-none"
278
+ },
279
+ size: {
280
+ small: "text-sm",
281
+ medium: "text-base",
282
+ large: "text-lg"
283
+ }
284
+ },
285
+ compoundVariants: [{
286
+ direction: "horizontal",
287
+ reversed: true,
288
+ class: "flex-row-reverse"
289
+ }, {
290
+ direction: "vertical",
291
+ reversed: true,
292
+ class: "flex-col-reverse"
293
+ }]
243
294
  });
244
295
  const listBoxToolbarThemeVariants = cva(`
245
296
  flex gap-1
246
297
  items-center justify-center
247
- `, {
248
- variants: {
249
- direction: {
250
- horizontal: "flex-row",
251
- vertical: "flex-col"
252
- }
253
- }
254
- });
255
-
298
+ `, { variants: { direction: {
299
+ horizontal: "flex-row",
300
+ vertical: "flex-col"
301
+ } } });
256
302
  const DEFAULT_ACTIONS = [
257
- "clear",
258
- "moveDown",
259
- "moveUp",
260
- "remove",
261
- "transferAllFrom",
262
- "transferAllTo",
263
- "transferFrom",
264
- "transferTo"
303
+ "clear",
304
+ "moveDown",
305
+ "moveUp",
306
+ "remove",
307
+ "transferAllFrom",
308
+ "transferAllTo",
309
+ "transferFrom",
310
+ "transferTo"
265
311
  ];
266
- /** The order the toolbar shows its buttons in, whatever order `actions` lists them in. */
267
312
  const TOOLBAR_ORDER = [
268
- "moveUp",
269
- "moveDown",
270
- "transferFrom",
271
- "transferTo",
272
- "transferAllFrom",
273
- "transferAllTo",
274
- "clear",
275
- "remove"
313
+ "moveUp",
314
+ "moveDown",
315
+ "transferFrom",
316
+ "transferTo",
317
+ "transferAllFrom",
318
+ "transferAllTo",
319
+ "clear",
320
+ "remove"
276
321
  ];
277
- const TRANSFER_ACTIONS = new Set([
278
- "transferAllFrom",
279
- "transferAllTo",
280
- "transferFrom",
281
- "transferTo"
322
+ const TRANSFER_ACTIONS = /* @__PURE__ */ new Set([
323
+ "transferAllFrom",
324
+ "transferAllTo",
325
+ "transferFrom",
326
+ "transferTo"
282
327
  ]);
283
- /** Accepts the bare `toolbar` attribute and `"true"`/`"false"`, as well as a boolean or an options object. */
284
328
  function toToolbarSetting(value) {
285
- if (value == null) {
286
- return true;
287
- }
288
- if (typeof value === "boolean" || typeof value === "object") {
289
- return value;
290
- }
291
- return booleanAttribute(value);
329
+ if (value == null) return true;
330
+ if (typeof value === "boolean" || typeof value === "object") return value;
331
+ return booleanAttribute(value);
292
332
  }
293
- class ListBoxComponent {
294
- #direction;
295
- #hostElementRef;
296
- #i18n;
297
- #injector;
298
- /** The first index of each item, so positions are looked up once per action instead of with `indexOf`. */
299
- #itemIndexes;
300
- #labelledByText;
301
- #listService;
302
- #liveAnnouncer;
303
- /** The list box's name as text: its `aria-label`, else the text of its `aria-labelledby` elements. */
304
- #name;
305
- /** The list box whose `connectedList` is this one, if any: its toolbar transfers items to and from this one. */
306
- #owner;
307
- /** The toolbar button that last had focus, which keeps the toolbar's Tab stop. */
308
- #toolbarFocus;
309
- /** The selection keys last reported through `selectionChange`, with their items. */
310
- #reported;
311
- constructor() {
312
- this.#direction = injectComponentDirection();
313
- this.#hostElementRef = inject(ElementRef);
314
- this.#i18n = inject(MonaI18nService);
315
- this.#injector = inject(Injector);
316
- /** The first index of each item, so positions are looked up once per action instead of with `indexOf`. */
317
- this.#itemIndexes = computed(() => {
318
- const indexes = new Map();
319
- this.listBoxItems().forEach((item, index) => {
320
- if (!indexes.has(item)) {
321
- indexes.set(item, index);
322
- }
323
- });
324
- return indexes;
325
- }, /* @ts-ignore */
326
- ...(ngDevMode ? [{ debugName: "#itemIndexes" }] : /* istanbul ignore next */ []));
327
- this.#labelledByText = injectLabelledByText(() => this.ariaLabelledBy());
328
- this.#listService = inject(ListService);
329
- this.#liveAnnouncer = inject(LiveAnnouncer);
330
- /** The list box's name as text: its `aria-label`, else the text of its `aria-labelledby` elements. */
331
- this.#name = computed(() => this.ariaLabel().trim() || this.#labelledByText(), /* @ts-ignore */
332
- ...(ngDevMode ? [{ debugName: "#name" }] : /* istanbul ignore next */ []));
333
- /** The list box whose `connectedList` is this one, if any: its toolbar transfers items to and from this one. */
334
- this.#owner = signal(null, /* @ts-ignore */
335
- ...(ngDevMode ? [{ debugName: "#owner" }] : /* istanbul ignore next */ []));
336
- /** The toolbar button that last had focus, which keeps the toolbar's Tab stop. */
337
- this.#toolbarFocus = signal(null, /* @ts-ignore */
338
- ...(ngDevMode ? [{ debugName: "#toolbarFocus" }] : /* istanbul ignore next */ []));
339
- /** The selection keys last reported through `selectionChange`, with their items. */
340
- this.#reported = new Map();
341
- this.baseClasses = computed(() => {
342
- const rounded = this.rounded();
343
- const size = this.size();
344
- const toolbarOptions = this.toolbarOptions();
345
- const position = toolbarOptions?.position ?? "right";
346
- const direction = position === "left" || position === "right" ? "horizontal" : "vertical";
347
- const reversed = position === "left" || position === "top";
348
- return listBoxBaseThemeVariants({ direction, reversed, rounded, size });
349
- }, /* @ts-ignore */
350
- ...(ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []));
351
- /** Whether the selection (in this list box or the connected one) can move down: it doesn't touch the end. */
352
- this.canMoveDown = computed(() => {
353
- const source = this.selectionHolder();
354
- const indices = source?.selectedIndices() ?? [];
355
- return source != null && indices.length > 0 && indices[indices.length - 1] < source.listBoxItems().length - 1;
356
- }, /* @ts-ignore */
357
- ...(ngDevMode ? [{ debugName: "canMoveDown" }] : /* istanbul ignore next */ []));
358
- /** Whether the selection (in this list box or the connected one) can move up: it doesn't touch the start. */
359
- this.canMoveUp = computed(() => {
360
- const indices = this.selectionHolder()?.selectedIndices() ?? [];
361
- return indices.length > 0 && indices[0] > 0;
362
- }, /* @ts-ignore */
363
- ...(ngDevMode ? [{ debugName: "canMoveUp" }] : /* istanbul ignore next */ []));
364
- /** The items that aren't disabled by `disabledBy`, which are the ones the "All" transfers carry. */
365
- this.enabledItems = computed(() => this.listBoxItems()
366
- .where(item => !this.#listService.isDataItemDisabled(item))
367
- .toArray(), /* @ts-ignore */
368
- ...(ngDevMode ? [{ debugName: "enabledItems" }] : /* istanbul ignore next */ []));
369
- this.footerTemplate = contentChild(ListBoxFooterTemplateDirective, { ...(ngDevMode ? { debugName: "footerTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
370
- this.headerTemplate = contentChild(ListBoxHeaderTemplateDirective, { ...(ngDevMode ? { debugName: "headerTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
371
- this.itemTemplate = contentChild(ListBoxItemTemplateDirective, { ...(ngDevMode ? { debugName: "itemTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
372
- this.listHeight = computed(() => {
373
- const height = this.height();
374
- return typeof height === "number" ? `${height}px` : height;
375
- }, /* @ts-ignore */
376
- ...(ngDevMode ? [{ debugName: "listHeight" }] : /* istanbul ignore next */ []));
377
- this.listWidth = computed(() => {
378
- const width = this.width();
379
- return typeof width === "number" ? `${width}px` : width;
380
- }, /* @ts-ignore */
381
- ...(ngDevMode ? [{ debugName: "listWidth" }] : /* istanbul ignore next */ []));
382
- this.messages = this.#i18n.componentMessages("listBox", LIST_BOX_DEFAULT_MESSAGES);
383
- this.noDataTemplate = contentChild(ListBoxNoDataTemplateDirective, { ...(ngDevMode ? { debugName: "noDataTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
384
- /**
385
- * The selected items in list order (not the order they were selected in), with their indices. Disabled items
386
- * are left out, so no action carries them.
387
- */
388
- this.orderedSelection = computed(() => {
389
- const indexes = this.#itemIndexes();
390
- return this.selectedItems()
391
- .toArray()
392
- .filter(item => !this.#listService.isDataItemDisabled(item))
393
- .map(item => ({ index: indexes.get(item) ?? -1, item }))
394
- .filter(entry => entry.index >= 0)
395
- .sort((a, b) => a.index - b.index);
396
- }, /* @ts-ignore */
397
- ...(ngDevMode ? [{ debugName: "orderedSelection" }] : /* istanbul ignore next */ []));
398
- this.selectableOptions = computed(() => {
399
- const enabled = true;
400
- const mode = this.selectionMode();
401
- if (mode === "multiple") {
402
- return { enabled, mode };
403
- }
404
- return { enabled, mode, toggleable: this.singleSelectionToggleable() };
405
- }, /* @ts-ignore */
406
- ...(ngDevMode ? [{ debugName: "selectableOptions" }] : /* istanbul ignore next */ []));
407
- /** Indices of the selected items, in list order. */
408
- this.selectedIndices = computed(() => this.orderedSelection().map(entry => entry.index), /* @ts-ignore */
409
- ...(ngDevMode ? [{ debugName: "selectedIndices" }] : /* istanbul ignore next */ []));
410
- /** The list box that holds the selection: this one, else the connected one, else none. */
411
- this.selectionHolder = computed(() => {
412
- if (this.orderedSelection().length > 0) {
413
- return this;
414
- }
415
- const connectedList = this.connectedList();
416
- return connectedList && connectedList.orderedSelection().length > 0 ? connectedList : null;
417
- }, /* @ts-ignore */
418
- ...(ngDevMode ? [{ debugName: "selectionHolder" }] : /* istanbul ignore next */ []));
419
- /**
420
- * The toolbar's buttons, in toolbar order. The transfer actions need a connected list box; the others work on a
421
- * list box of its own.
422
- */
423
- this.toolbarButtons = computed(() => {
424
- const options = this.toolbarOptions();
425
- if (!options) {
426
- return [];
427
- }
428
- const connectedList = this.connectedList();
429
- const messages = this.messages();
430
- const holder = this.selectionHolder();
431
- const target = connectedList ? connectedList.#name() : "";
432
- const enabled = {
433
- clear: holder != null,
434
- moveDown: this.canMoveDown(),
435
- moveUp: this.canMoveUp(),
436
- remove: holder != null,
437
- transferAllFrom: (connectedList?.enabledItems().length ?? 0) > 0,
438
- transferAllTo: this.enabledItems().length > 0,
439
- transferFrom: (connectedList?.orderedSelection().length ?? 0) > 0,
440
- transferTo: this.orderedSelection().length > 0
441
- };
442
- const labels = {
443
- clear: messages.clearSelection,
444
- moveDown: messages.moveDown,
445
- moveUp: messages.moveUp,
446
- remove: messages.remove,
447
- transferAllFrom: target ? messages.transferAllFromList(target) : messages.transferAllFrom,
448
- transferAllTo: target ? messages.transferAllToList(target) : messages.transferAllTo,
449
- transferFrom: target ? messages.transferFromList(target) : messages.transferFrom,
450
- transferTo: target ? messages.transferToList(target) : messages.transferTo
451
- };
452
- return TOOLBAR_ORDER.filter(action => options.actions.includes(action) && (connectedList != null || !TRANSFER_ACTIONS.has(action))).map(action => ({ action, enabled: enabled[action], label: labels[action] }));
453
- }, /* @ts-ignore */
454
- ...(ngDevMode ? [{ debugName: "toolbarButtons" }] : /* istanbul ignore next */ []));
455
- this.toolbarClasses = computed(() => {
456
- const direction = this.toolbarOrientation();
457
- return listBoxToolbarThemeVariants({ direction });
458
- }, /* @ts-ignore */
459
- ...(ngDevMode ? [{ debugName: "toolbarClasses" }] : /* istanbul ignore next */ []));
460
- /** The toolbar's name: `toolbarAriaLabel`, else one built from the list box's name. */
461
- this.toolbarLabel = computed(() => {
462
- const label = this.toolbarAriaLabel().trim();
463
- if (label) {
464
- return label;
465
- }
466
- const list = this.#name();
467
- return list ? this.messages().toolbarLabel(list) : null;
468
- }, /* @ts-ignore */
469
- ...(ngDevMode ? [{ debugName: "toolbarLabel" }] : /* istanbul ignore next */ []));
470
- this.toolbarOptions = computed(() => {
471
- const toolbar = this.toolbar();
472
- if (typeof toolbar === "boolean") {
473
- return toolbar ? { actions: [...DEFAULT_ACTIONS], position: "right" } : null;
474
- }
475
- return {
476
- actions: toolbar.actions ? [...toolbar.actions] : [...DEFAULT_ACTIONS],
477
- position: toolbar.position ?? "right"
478
- };
479
- }, /* @ts-ignore */
480
- ...(ngDevMode ? [{ debugName: "toolbarOptions" }] : /* istanbul ignore next */ []));
481
- /** A toolbar beside the list stacks its buttons; one above or below lines them up. */
482
- this.toolbarOrientation = computed(() => {
483
- const position = this.toolbarOptions()?.position ?? "right";
484
- return position === "left" || position === "right" ? "vertical" : "horizontal";
485
- }, /* @ts-ignore */
486
- ...(ngDevMode ? [{ debugName: "toolbarOrientation" }] : /* istanbul ignore next */ []));
487
- /** The one enabled toolbar button in the Tab order; the arrow keys move between the others. */
488
- this.toolbarTabStop = computed(() => {
489
- const enabled = this.toolbarButtons().filter(button => button.enabled);
490
- const focused = this.#toolbarFocus();
491
- return (enabled.find(button => button.action === focused) ?? enabled[0])?.action ?? null;
492
- }, /* @ts-ignore */
493
- ...(ngDevMode ? [{ debugName: "toolbarTabStop" }] : /* istanbul ignore next */ []));
494
- /**
495
- * @description Emitted when a toolbar action button is clicked, carrying the action's details.
496
- */
497
- this.actionClick = output();
498
- /**
499
- * @description Accessible name for the list box's `listbox` element. Describe what the list represents,
500
- * which matters in particular when connecting two list boxes: the toolbar's name and the transfer buttons'
501
- * labels are built from it.
502
- * @default ""
503
- */
504
- this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
505
- /**
506
- * @description Id of the element that names the list box, as an alternative to `aria-label`. Without an
507
- * `aria-label`, the toolbar's name and the transfer buttons' labels are built from that element's text.
508
- * @default ""
509
- */
510
- this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
511
- /**
512
- * @description The other list box to transfer items to and from using the toolbar actions.
513
- * @default null
514
- */
515
- this.connectedList = input(null, /* @ts-ignore */
516
- ...(ngDevMode ? [{ debugName: "connectedList" }] : /* istanbul ignore next */ []));
517
- /**
518
- * @description Property name or predicate that marks items as disabled. Disabled items can't be selected, and no
519
- * action (including the "All" transfers) carries them.
520
- * @default ""
521
- */
522
- this.disabledBy = input("", /* @ts-ignore */
523
- ...(ngDevMode ? [{ debugName: "disabledBy" }] : /* istanbul ignore next */ []));
524
- /**
525
- * @description Sets the height of the component.
526
- * @default 100%
527
- */
528
- this.height = input("100%", /* @ts-ignore */
529
- ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
530
- /**
531
- * @description Collection of items to render.
532
- * @default []
533
- */
534
- this.items = input([], /* @ts-ignore */
535
- ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
536
- /** The items, as rendered. Read-only: change `items` to change them. */
537
- this.listBoxItems = computed(() => ImmutableList.create(this.items()), /* @ts-ignore */
538
- ...(ngDevMode ? [{ debugName: "listBoxItems" }] : /* istanbul ignore next */ []));
539
- /**
540
- * @description Border-radius preset applied to the component.
541
- * @default medium
542
- */
543
- this.rounded = input("medium", /* @ts-ignore */
544
- ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
545
- /**
546
- * @description Property name or accessor used to derive the key from a data item, used to identify selected items.
547
- * @default ""
548
- */
549
- this.selectBy = input("", /* @ts-ignore */
550
- ...(ngDevMode ? [{ debugName: "selectBy" }] : /* istanbul ignore next */ []));
551
- /** The selected items, read-only. */
552
- this.selectedItems = computed(() => {
553
- const listItems = this.#listService.selectedListItems();
554
- return listItems.select(item => item.data).toImmutableSet();
555
- }, /* @ts-ignore */
556
- ...(ngDevMode ? [{ debugName: "selectedItems" }] : /* istanbul ignore next */ []));
557
- /** @deprecated Use the `selectedItems` signal or the `selectionChange` output. */
558
- this.selectedItems$ = toObservable(this.selectedItems);
559
- /**
560
- * @description Keys of the currently selected items.
561
- * @default []
562
- */
563
- this.selectedKeys = input([], /* @ts-ignore */
564
- ...(ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []));
565
- /**
566
- * @description Emitted with the updated keys whenever the user changes the selection, including when an
567
- * action (transfer, clear, remove) or a selection in the connected list box changes it.
568
- */
569
- this.selectedKeysChange = output();
570
- /**
571
- * @description Emitted with the selected and deselected items whenever the user changes the selection, including
572
- * when an action (transfer, clear, remove) or a selection in the connected list box changes it.
573
- */
574
- this.selectionChange = output();
575
- /**
576
- * @description Allows multiple items to be selected simultaneously when set to `"multiple"`.
577
- * @default single
578
- */
579
- this.selectionMode = input("single", /* @ts-ignore */
580
- ...(ngDevMode ? [{ debugName: "selectionMode" }] : /* istanbul ignore next */ []));
581
- /**
582
- * @description Allows an already-selected item to be deselected by clicking it again while `selectionMode`
583
- * is `"single"`. Has no effect when `selectionMode` is `"multiple"`. Accepts the bare attribute form.
584
- * @default true
585
- */
586
- this.singleSelectionToggleable = input(true, { ...(ngDevMode ? { debugName: "singleSelectionToggleable" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
587
- /**
588
- * @description Size preset controlling the component's dimensions.
589
- * @default medium
590
- */
591
- this.size = input("medium", /* @ts-ignore */
592
- ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
593
- /**
594
- * @description Property name or accessor used to derive the display text from a data item.
595
- * @default ""
596
- */
597
- this.textField = input("", /* @ts-ignore */
598
- ...(ngDevMode ? [{ debugName: "textField" }] : /* istanbul ignore next */ []));
599
- /**
600
- * @description Shows the action toolbar. Pass `false` to hide it entirely, or an options object to customize
601
- * which actions are shown and where the toolbar is positioned. The transfer actions appear only with a
602
- * `connectedList`; the move, clear and remove actions work on a list box of its own. Accepts the bare attribute
603
- * form.
604
- * @default true
605
- */
606
- this.toolbar = input(true, { ...(ngDevMode ? { debugName: "toolbar" } : /* istanbul ignore next */ {}), transform: toToolbarSetting });
607
- /**
608
- * @description Accessible name for the toolbar. By default it is built from the list box's name
609
- * ("Available foods actions").
610
- * @default ""
611
- */
612
- this.toolbarAriaLabel = input("", /* @ts-ignore */
613
- ...(ngDevMode ? [{ debugName: "toolbarAriaLabel" }] : /* istanbul ignore next */ []));
614
- /**
615
- * @description Sets the width of the component.
616
- * @default 100%
617
- */
618
- this.width = input("100%", /* @ts-ignore */
619
- ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
620
- effect(() => {
621
- const selectBy = this.selectBy();
622
- const keys = this.selectedKeys();
623
- untracked(() => {
624
- // Keys set from code are the new baseline; they aren't reported back as a user change.
625
- this.#listService.setValueField(selectBy ?? "");
626
- this.#listService.setSelectedKeys(keys ?? []);
627
- this.#reported = new Map(Array.from(keys ?? [], key => [key, undefined]));
628
- });
629
- });
630
- effect(onCleanup => {
631
- const connectedList = this.connectedList();
632
- if (!connectedList) {
633
- return;
634
- }
635
- // The connected list box learns which list box transfers to it, for the shortcuts used in it.
636
- untracked(() => connectedList.#owner.set(this));
637
- onCleanup(() => {
638
- if (untracked(connectedList.#owner) === this) {
639
- connectedList.#owner.set(null);
640
- }
641
- });
642
- });
643
- }
644
- /**
645
- * @description Clears the selection and reports the change through `selectionChange` and `selectedKeysChange`.
646
- */
647
- clearSelections() {
648
- this.#listService.clearSelections();
649
- this.reportSelection();
650
- }
651
- /**
652
- * @deprecated `clearSelections()` and the actions report selection changes themselves.
653
- */
654
- notifySelectionChange() {
655
- this.reportSelection();
656
- }
657
- onActionClick(action, event) {
658
- const button = event.currentTarget instanceof HTMLButtonElement ? event.currentTarget : null;
659
- this.runAction(action, event, button);
660
- }
661
- /**
662
- * Keyboard shortcuts on an option: Alt+ArrowUp and Alt+ArrowDown move the selection, Delete removes it, and
663
- * Alt+ArrowRight and Alt+ArrowLeft (mirrored in RTL) transfer it to and from the connected list box. Each runs
664
- * only when the toolbar offers that action and the selection is in this list box.
665
- */
666
- onHostKeydown(event) {
667
- if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.shiftKey || !this.isOwnOption(event)) {
668
- return;
669
- }
670
- const shortcut = this.resolveShortcut(event);
671
- if (!shortcut) {
672
- return;
673
- }
674
- const { action, controller } = shortcut;
675
- const button = controller.toolbarButtons().find(candidate => candidate.action === action);
676
- if (!button?.enabled || controller.selectionHolder() !== this) {
677
- return;
678
- }
679
- event.preventDefault();
680
- controller.runAction(action, event, null);
681
- }
682
- onSelectedKeysChange() {
683
- this.reportSelection();
684
- }
685
- onToolbarFocusIn(event) {
686
- const action = this.toolbarActionOf(event.target);
687
- if (action) {
688
- this.#toolbarFocus.set(action);
689
- }
690
- }
691
- /** Arrow keys move between the toolbar's enabled buttons (wrapping), Home and End go to the first and last. */
692
- onToolbarKeydown(event) {
693
- if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) {
694
- return;
695
- }
696
- const buttons = this.toolbarButtons().filter(button => button.enabled);
697
- if (buttons.length === 0) {
698
- return;
699
- }
700
- const vertical = this.toolbarOrientation() === "vertical";
701
- const rtl = this.#direction() === "rtl";
702
- const nextKey = vertical ? "ArrowDown" : rtl ? "ArrowLeft" : "ArrowRight";
703
- const previousKey = vertical ? "ArrowUp" : rtl ? "ArrowRight" : "ArrowLeft";
704
- const current = Math.max(0, buttons.findIndex(button => button.action === this.toolbarTabStop()));
705
- let index;
706
- if (event.key === nextKey) {
707
- index = (current + 1) % buttons.length;
708
- }
709
- else if (event.key === previousKey) {
710
- index = (current - 1 + buttons.length) % buttons.length;
711
- }
712
- else if (event.key === "Home") {
713
- index = 0;
714
- }
715
- else if (event.key === "End") {
716
- index = buttons.length - 1;
717
- }
718
- else {
719
- return;
720
- }
721
- event.preventDefault();
722
- this.focusToolbarButton(buttons[index].action);
723
- }
724
- /**
725
- * Runs once the consumer's data change has rendered: announces the result and moves focus to what the action
726
- * acted on when a shortcut ran it, or when its button is now disabled (focus would otherwise drop to the page).
727
- */
728
- afterActionRender(button, outcome) {
729
- afterNextRender({
730
- write: () => {
731
- const { announcement, focus } = outcome();
732
- if (announcement) {
733
- void this.#liveAnnouncer.announce(announcement, "polite");
734
- }
735
- const active = this.#hostElementRef.nativeElement.ownerDocument.activeElement;
736
- const focusLost = active == null || active === active.ownerDocument.body;
737
- if (button == null || button.disabled || focusLost) {
738
- focus();
739
- }
740
- }
741
- }, { injector: this.#injector });
742
- }
743
- clear(event, button) {
744
- const holder = this.selectionHolder();
745
- if (!holder) {
746
- return;
747
- }
748
- const selection = holder.orderedSelection();
749
- const clearEvent = new ListBoxClearEvent(selection.map(entry => entry.item), event);
750
- holder.actionClick.emit(clearEvent);
751
- if (clearEvent.isDefaultPrevented()) {
752
- return;
753
- }
754
- this.clearSelections();
755
- this.connectedList()?.clearSelections();
756
- this.afterActionRender(button, () => ({
757
- announcement: this.messages().selectionCleared,
758
- focus: () => holder.revealItem(selection[0]?.item, true)
759
- }));
760
- }
761
- findItemByKey(key) {
762
- return (this.listBoxItems().firstOrDefault(item => this.#listService.getDataItemValue(item) === key) ?? undefined);
763
- }
764
- focusToolbarButton(action) {
765
- this.#toolbarFocus.set(action);
766
- const button = this.#hostElementRef.nativeElement.querySelector(`[role='toolbar'] button[data-action='${action}']`);
767
- button?.focus();
768
- }
769
- /** Whether a key event comes from one of this list box's own options (not a control in a template). */
770
- isOwnOption(event) {
771
- const target = event.target;
772
- return (target instanceof HTMLElement &&
773
- target.hasAttribute("data-uid") &&
774
- target.closest("mona-list-box") === this.#hostElementRef.nativeElement);
775
- }
776
- move(direction, event, button) {
777
- const holder = this.selectionHolder();
778
- if (!holder || (direction === "moveUp" ? !this.canMoveUp() : !this.canMoveDown())) {
779
- return;
780
- }
781
- const selection = holder.orderedSelection();
782
- const indices = selection.map(entry => entry.index);
783
- const startIndex = indices[0];
784
- const newIndex = direction === "moveDown" ? indices[indices.length - 1] + 1 : startIndex - 1;
785
- const items = selection.map(entry => entry.item);
786
- // A shortcut keeps focus on the option it was pressed on; a button moves it to the first moved item.
787
- const highlighted = holder.#listService.highlightedItem()?.data;
788
- const focusItem = highlighted !== undefined && items.includes(highlighted) ? highlighted : items[0];
789
- const moveEvent = new ListBoxMoveEvent(direction, items, indices, startIndex, newIndex, event);
790
- holder.actionClick.emit(moveEvent);
791
- if (moveEvent.isDefaultPrevented()) {
792
- return;
793
- }
794
- this.afterActionRender(button, () => {
795
- const first = holder.selectedIndices()[0];
796
- holder.revealItem(holder.orderedSelection()[0]?.item, false);
797
- return {
798
- announcement: first !== undefined && first !== startIndex
799
- ? this.messages().itemsMoved(first + 1, holder.listBoxItems().size())
800
- : null,
801
- focus: () => holder.revealItem(focusItem, true)
802
- };
803
- });
804
- }
805
- remove(event, button) {
806
- const holder = this.selectionHolder();
807
- if (!holder) {
808
- return;
809
- }
810
- const selection = holder.orderedSelection();
811
- const removeEvent = new ListBoxRemoveEvent(selection.map(entry => entry.item), event);
812
- holder.actionClick.emit(removeEvent);
813
- if (removeEvent.isDefaultPrevented()) {
814
- return;
815
- }
816
- const keys = selection.map(entry => holder.#listService.getDataItemValue(entry.item));
817
- const firstIndex = selection[0].index;
818
- holder.clearSelections();
819
- this.afterActionRender(button, () => {
820
- const remaining = new Set(holder.listBoxItems().select(item => holder.#listService.getDataItemValue(item)));
821
- const removed = keys.filter(key => !remaining.has(key)).length;
822
- const enabledItems = holder.enabledItems();
823
- // The item now at the first removed one's position, or the last one.
824
- const neighbour = enabledItems.find(item => (holder.#itemIndexes().get(item) ?? -1) >= firstIndex);
825
- return {
826
- announcement: removed > 0 ? this.messages().itemsRemoved(removed) : null,
827
- focus: () => holder.revealItem(neighbour ?? enabledItems[enabledItems.length - 1], true)
828
- };
829
- });
830
- }
831
- /**
832
- * Emits `selectionChange` and `selectedKeysChange` when the selected keys differ from the ones last reported. A
833
- * new selection clears the connected list box's, as only one side holds a selection.
834
- */
835
- reportSelection() {
836
- const keys = this.#listService.selectedKeys().toArray();
837
- const current = new Map();
838
- for (const listItem of this.#listService.selectedListItems()) {
839
- current.set(this.#listService.getDataItemValue(listItem.data), listItem.data);
840
- }
841
- for (const key of keys) {
842
- if (!current.has(key)) {
843
- current.set(key, undefined);
844
- }
845
- }
846
- const previous = this.#reported;
847
- const selectedItems = [...current]
848
- .filter(([key]) => !previous.has(key))
849
- .map(([, item]) => item)
850
- .filter((item) => item !== undefined);
851
- const deselectedItems = [...previous]
852
- .filter(([key]) => !current.has(key))
853
- .map(([key, item]) => item ?? this.findItemByKey(key))
854
- .filter((item) => item !== undefined);
855
- const changed = keys.length !== previous.size || keys.some(key => !previous.has(key));
856
- this.#reported = current;
857
- if (!changed) {
858
- return;
859
- }
860
- this.selectionChange.emit({ deselectedItems, selectedItems });
861
- this.selectedKeysChange.emit(keys);
862
- if (selectedItems.length > 0) {
863
- this.connectedList()?.clearSelections();
864
- this.#owner()?.clearSelections();
865
- }
866
- }
867
- /**
868
- * The action a shortcut runs and the list box whose toolbar runs it. Transfers go towards the connected list
869
- * box, which follows this one in reading order: Alt+ArrowRight (Alt+ArrowLeft in RTL) from this list box,
870
- * Alt+ArrowLeft (Alt+ArrowRight in RTL) back from the connected one.
871
- */
872
- resolveShortcut(event) {
873
- const toolbarHolder = this.toolbarOptions() ? this : this.#owner();
874
- if (event.key === "Delete" && !event.altKey) {
875
- return toolbarHolder ? { action: "remove", controller: toolbarHolder } : null;
876
- }
877
- if (!event.altKey) {
878
- return null;
879
- }
880
- if (event.key === "ArrowUp" || event.key === "ArrowDown") {
881
- const action = event.key === "ArrowUp" ? "moveUp" : "moveDown";
882
- return toolbarHolder ? { action, controller: toolbarHolder } : null;
883
- }
884
- if (event.key !== "ArrowRight" && event.key !== "ArrowLeft") {
885
- return null;
886
- }
887
- const forward = (event.key === "ArrowRight") !== (this.#direction() === "rtl");
888
- if (forward) {
889
- return this.connectedList() ? { action: "transferTo", controller: this } : null;
890
- }
891
- const owner = this.#owner();
892
- return owner ? { action: "transferFrom", controller: owner } : null;
893
- }
894
- /** Scrolls an item into view, and focuses it, or the list when the item isn't there. */
895
- revealItem(dataItem, focus) {
896
- const key = dataItem === undefined ? undefined : this.#listService.getDataItemValue(dataItem);
897
- const listItem = dataItem === undefined
898
- ? null
899
- : this.#listService
900
- .viewItems()
901
- .firstOrDefault(item => !item.isHeader && this.#listService.getDataItemValue(item.data) === key);
902
- if (listItem) {
903
- if (focus) {
904
- this.#listService.highlightedItem.set(listItem);
905
- }
906
- this.#listService.scrollToItem(listItem, focus);
907
- }
908
- else if (focus) {
909
- this.#listService.focus$.next();
910
- }
911
- }
912
- runAction(action, event, button) {
913
- switch (action) {
914
- case "clear":
915
- this.clear(event, button);
916
- break;
917
- case "moveDown":
918
- case "moveUp":
919
- this.move(action, event, button);
920
- break;
921
- case "remove":
922
- this.remove(event, button);
923
- break;
924
- default:
925
- this.transfer(action, event, button);
926
- }
927
- }
928
- /** Selects the items a transfer brought into this list box: all of them, or the first in single mode. */
929
- selectTransferredItems(items) {
930
- const selected = this.selectionMode() === "multiple" ? items : items.slice(0, 1);
931
- this.#listService.setSelectedKeys(selected.map(item => this.#listService.getDataItemValue(item)));
932
- this.reportSelection();
933
- }
934
- toolbarActionOf(target) {
935
- if (!(target instanceof HTMLElement)) {
936
- return null;
937
- }
938
- const action = target.closest("button[data-action]")?.getAttribute("data-action");
939
- return TOOLBAR_ORDER.find(candidate => candidate === action) ?? null;
940
- }
941
- /**
942
- * "To" actions move items from this list box to the connected one, "From" actions from the connected one to
943
- * this one. The event fires on the source list box and carries the items to move: the selection, or every enabled
944
- * item for the "All" actions. Once the consumer has moved them, they are selected in the target.
945
- */
946
- transfer(action, event, button) {
947
- const connectedList = this.connectedList();
948
- if (!connectedList) {
949
- return;
950
- }
951
- const toConnected = action === "transferTo" || action === "transferAllTo";
952
- const source = toConnected ? this : connectedList;
953
- const target = toConnected ? connectedList : this;
954
- const all = action === "transferAllTo" || action === "transferAllFrom";
955
- const items = all ? source.enabledItems() : source.orderedSelection().map(entry => entry.item);
956
- if (items.length === 0) {
957
- return;
958
- }
959
- const transferEvent = new ListBoxTransferEvent(action, items, event);
960
- source.actionClick.emit(transferEvent);
961
- if (transferEvent.isDefaultPrevented()) {
962
- return;
963
- }
964
- source.clearSelections();
965
- target.clearSelections();
966
- const keys = new Set(items.map(item => target.#listService.getDataItemValue(item)));
967
- this.afterActionRender(button, () => {
968
- const arrived = target
969
- .listBoxItems()
970
- .where(item => keys.has(target.#listService.getDataItemValue(item)))
971
- .toArray();
972
- if (arrived.length > 0) {
973
- target.selectTransferredItems(arrived);
974
- target.revealItem(arrived[0], false);
975
- }
976
- const name = target.#name();
977
- const messages = this.messages();
978
- let announcement = null;
979
- if (arrived.length > 0) {
980
- announcement = name
981
- ? messages.itemsTransferred(arrived.length, name)
982
- : messages.itemsTransferredToOtherList(arrived.length);
983
- }
984
- return { announcement, focus: () => target.revealItem(arrived[0], true) };
985
- });
986
- }
987
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListBoxComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
988
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: ListBoxComponent, isStandalone: true, selector: "mona-list-box", 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 }, connectedList: { classPropertyName: "connectedList", publicName: "connectedList", isSignal: true, isRequired: false, transformFunction: null }, disabledBy: { classPropertyName: "disabledBy", publicName: "disabledBy", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, selectBy: { classPropertyName: "selectBy", publicName: "selectBy", isSignal: true, isRequired: false, transformFunction: null }, selectedKeys: { classPropertyName: "selectedKeys", publicName: "selectedKeys", isSignal: true, isRequired: false, transformFunction: null }, selectionMode: { classPropertyName: "selectionMode", publicName: "selectionMode", isSignal: true, isRequired: false, transformFunction: null }, singleSelectionToggleable: { classPropertyName: "singleSelectionToggleable", publicName: "singleSelectionToggleable", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, textField: { classPropertyName: "textField", publicName: "textField", isSignal: true, isRequired: false, transformFunction: null }, toolbar: { classPropertyName: "toolbar", publicName: "toolbar", isSignal: true, isRequired: false, transformFunction: null }, toolbarAriaLabel: { classPropertyName: "toolbarAriaLabel", publicName: "toolbarAriaLabel", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { actionClick: "actionClick", selectedKeysChange: "selectedKeysChange", selectionChange: "selectionChange" }, host: { listeners: { "keydown": "onHostKeydown($event)" }, properties: { "attr.aria-label": "null", "class": "baseClasses()", "style.height": "listHeight()", "style.width": "listWidth()" } }, providers: [ListService], queries: [{ propertyName: "footerTemplate", first: true, predicate: ListBoxFooterTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "headerTemplate", first: true, predicate: ListBoxHeaderTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "itemTemplate", first: true, predicate: ListBoxItemTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "noDataTemplate", first: true, predicate: ListBoxNoDataTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "<mona-list-view\n [aria-label]=\"ariaLabel()\"\n [aria-labelledby]=\"ariaLabelledBy()\"\n [items]=\"listBoxItems()\"\n [height]=\"'100%'\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [textField]=\"textField()\"\n [width]=\"'100%'\"\n [disabledBy]=\"disabledBy()\"\n [monaListViewNavigable]=\"{ enabled: true, mode: 'select' }\"\n [monaListViewSelectable]=\"selectableOptions()\"\n [selectBy]=\"selectBy()\"\n [selectedKeys]=\"selectedKeys()\"\n (selectedKeysChange)=\"onSelectedKeysChange()\">\n @if (footerTemplate()) {\n <ng-template monaListViewFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListViewHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListViewItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListViewNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </ng-template>\n }\n</mona-list-view>\n\n@let buttons = toolbarButtons();\n@if (buttons.length > 0) {\n @let tabStop = toolbarTabStop();\n <div\n role=\"toolbar\"\n [attr.aria-label]=\"toolbarLabel()\"\n [attr.aria-orientation]=\"toolbarOrientation()\"\n [class]=\"toolbarClasses()\"\n (focusin)=\"onToolbarFocusIn($event)\"\n (keydown)=\"onToolbarKeydown($event)\">\n @for (button of buttons; track button.action) {\n <button\n monaButton\n type=\"button\"\n [attr.data-action]=\"button.action\"\n (click)=\"onActionClick(button.action, $event)\"\n [iconOnly]=\"true\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [title]=\"button.label\"\n [attr.aria-label]=\"button.label\"\n [disabled]=\"!button.enabled\"\n [tabindex]=\"tabStop === button.action ? 0 : -1\">\n @switch (button.action) {\n @case (\"moveUp\") {\n <svg lucideChevronUp [size]=\"16\"></svg>\n }\n @case (\"moveDown\") {\n <svg lucideChevronDown [size]=\"16\"></svg>\n }\n @case (\"transferFrom\") {\n <svg lucideChevronLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferTo\") {\n <svg lucideChevronRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferAllFrom\") {\n <svg lucideChevronsLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferAllTo\") {\n <svg lucideChevronsRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"clear\") {\n <svg lucideX [size]=\"16\"></svg>\n }\n @case (\"remove\") {\n <svg lucideTrash2 [size]=\"14\"></svg>\n }\n }\n </button>\n }\n </div>\n}\n", dependencies: [{ kind: "component", type: ListViewComponent, selector: "mona-list-view", inputs: ["aria-label", "aria-labelledby", "disabledBy", "height", "items", "listClass", "listItemClass", "listItemStyle", "listStyle", "loading", "maxHeight", "maxWidth", "pagerAriaLabel", "rounded", "size", "textField", "class", "width"], outputs: ["itemActivate", "scrollBottom"] }, { kind: "directive", type: ListViewSelectableDirective, selector: "mona-list-view[monaListViewSelectable]", inputs: ["monaListViewSelectable", "selectBy", "selectedKeys"], outputs: ["selectedKeysChange"] }, { kind: "directive", type: ListViewItemTemplateDirective, selector: "ng-template[monaListViewItemTemplate]", inputs: ["monaListViewItemTemplateOf"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { 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: "directive", type: ListViewNavigableDirective, selector: "mona-list-view[monaListViewNavigable]", inputs: ["monaListViewNavigable"] }, { kind: "directive", type: ListViewNoDataTemplateDirective, selector: "ng-template[monaListViewNoDataTemplate]" }, { kind: "directive", type: ListViewFooterTemplateDirective, selector: "ng-template[monaListViewFooterTemplate]" }, { kind: "directive", type: ListViewHeaderTemplateDirective, selector: "ng-template[monaListViewHeaderTemplate]" }, { kind: "component", type: LucideChevronUp, selector: "svg[lucideChevronUp]" }, { kind: "component", type: LucideChevronDown, selector: "svg[lucideChevronDown]" }, { kind: "component", type: LucideChevronLeft, selector: "svg[lucideChevronLeft]" }, { kind: "component", type: LucideChevronRight, selector: "svg[lucideChevronRight]" }, { kind: "component", type: LucideChevronsLeft, selector: "svg[lucideChevronsLeft]" }, { kind: "component", type: LucideChevronsRight, selector: "svg[lucideChevronsRight]" }, { kind: "component", type: LucideX, selector: "svg[lucideX]" }, { kind: "component", type: LucideTrash2, selector: "svg[lucideTrash2]" }], viewProviders: [{ provide: LIST_VIEW_HOST_LIST_SERVICE, useExisting: ListService }] }); }
989
- }
990
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListBoxComponent, decorators: [{
991
- type: Component,
992
- args: [{ selector: "mona-list-box", providers: [ListService], viewProviders: [{ provide: LIST_VIEW_HOST_LIST_SERVICE, useExisting: ListService }], imports: [
993
- ListViewComponent,
994
- ListViewSelectableDirective,
995
- ListViewItemTemplateDirective,
996
- NgTemplateOutlet,
997
- ButtonDirective,
998
- ListViewNavigableDirective,
999
- ListViewNoDataTemplateDirective,
1000
- ListViewFooterTemplateDirective,
1001
- ListViewHeaderTemplateDirective,
1002
- LucideChevronUp,
1003
- LucideChevronDown,
1004
- LucideChevronLeft,
1005
- LucideChevronRight,
1006
- LucideChevronsLeft,
1007
- LucideChevronsRight,
1008
- LucideX,
1009
- LucideTrash2
1010
- ], host: {
1011
- // The name belongs to the listbox inside; on the host it would be a name on a generic element.
1012
- "[attr.aria-label]": "null",
1013
- "[class]": "baseClasses()",
1014
- "[style.height]": "listHeight()",
1015
- "[style.width]": "listWidth()",
1016
- "(keydown)": "onHostKeydown($event)"
1017
- }, template: "<mona-list-view\n [aria-label]=\"ariaLabel()\"\n [aria-labelledby]=\"ariaLabelledBy()\"\n [items]=\"listBoxItems()\"\n [height]=\"'100%'\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [textField]=\"textField()\"\n [width]=\"'100%'\"\n [disabledBy]=\"disabledBy()\"\n [monaListViewNavigable]=\"{ enabled: true, mode: 'select' }\"\n [monaListViewSelectable]=\"selectableOptions()\"\n [selectBy]=\"selectBy()\"\n [selectedKeys]=\"selectedKeys()\"\n (selectedKeysChange)=\"onSelectedKeysChange()\">\n @if (footerTemplate()) {\n <ng-template monaListViewFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListViewHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListViewItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListViewNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </ng-template>\n }\n</mona-list-view>\n\n@let buttons = toolbarButtons();\n@if (buttons.length > 0) {\n @let tabStop = toolbarTabStop();\n <div\n role=\"toolbar\"\n [attr.aria-label]=\"toolbarLabel()\"\n [attr.aria-orientation]=\"toolbarOrientation()\"\n [class]=\"toolbarClasses()\"\n (focusin)=\"onToolbarFocusIn($event)\"\n (keydown)=\"onToolbarKeydown($event)\">\n @for (button of buttons; track button.action) {\n <button\n monaButton\n type=\"button\"\n [attr.data-action]=\"button.action\"\n (click)=\"onActionClick(button.action, $event)\"\n [iconOnly]=\"true\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [title]=\"button.label\"\n [attr.aria-label]=\"button.label\"\n [disabled]=\"!button.enabled\"\n [tabindex]=\"tabStop === button.action ? 0 : -1\">\n @switch (button.action) {\n @case (\"moveUp\") {\n <svg lucideChevronUp [size]=\"16\"></svg>\n }\n @case (\"moveDown\") {\n <svg lucideChevronDown [size]=\"16\"></svg>\n }\n @case (\"transferFrom\") {\n <svg lucideChevronLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferTo\") {\n <svg lucideChevronRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferAllFrom\") {\n <svg lucideChevronsLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferAllTo\") {\n <svg lucideChevronsRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"clear\") {\n <svg lucideX [size]=\"16\"></svg>\n }\n @case (\"remove\") {\n <svg lucideTrash2 [size]=\"14\"></svg>\n }\n }\n </button>\n }\n </div>\n}\n" }]
1018
- }], ctorParameters: () => [], propDecorators: { footerTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListBoxFooterTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], headerTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListBoxHeaderTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], itemTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListBoxItemTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], noDataTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListBoxNoDataTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], actionClick: [{ type: i0.Output, args: ["actionClick"] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], connectedList: [{ type: i0.Input, args: [{ isSignal: true, alias: "connectedList", required: false }] }], disabledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabledBy", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], selectBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectBy", required: false }] }], selectedKeys: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedKeys", required: false }] }], selectedKeysChange: [{ type: i0.Output, args: ["selectedKeysChange"] }], selectionChange: [{ type: i0.Output, args: ["selectionChange"] }], selectionMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionMode", required: false }] }], singleSelectionToggleable: [{ type: i0.Input, args: [{ isSignal: true, alias: "singleSelectionToggleable", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], textField: [{ type: i0.Input, args: [{ isSignal: true, alias: "textField", required: false }] }], toolbar: [{ type: i0.Input, args: [{ isSignal: true, alias: "toolbar", required: false }] }], toolbarAriaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "toolbarAriaLabel", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }] } });
1019
-
1020
- /*
1021
- * Public API Surface of @nanahoshi/mona-ui/list-box
1022
- */
1023
-
1024
- /**
1025
- * Generated bundle index. Do not edit.
1026
- */
1027
-
333
+ var ListBoxComponent = class ListBoxComponent {
334
+ #direction;
335
+ #hostElementRef;
336
+ #i18n;
337
+ #injector;
338
+ #itemIndexes;
339
+ #labelledByText;
340
+ #listService;
341
+ #liveAnnouncer;
342
+ #name;
343
+ #owner;
344
+ #toolbarFocus;
345
+ #reported;
346
+ constructor() {
347
+ this.#direction = injectComponentDirection();
348
+ this.#hostElementRef = inject(ElementRef);
349
+ this.#i18n = inject(MonaI18nService);
350
+ this.#injector = inject(Injector);
351
+ this.#itemIndexes = computed(() => {
352
+ const indexes = /* @__PURE__ */ new Map();
353
+ this.listBoxItems().forEach((item, index) => {
354
+ if (!indexes.has(item)) indexes.set(item, index);
355
+ });
356
+ return indexes;
357
+ }, ...ngDevMode ? [{ debugName: "#itemIndexes" }] : /* istanbul ignore next */ []);
358
+ this.#labelledByText = injectLabelledByText(() => this.ariaLabelledBy());
359
+ this.#listService = inject(ListService);
360
+ this.#liveAnnouncer = inject(LiveAnnouncer);
361
+ this.#name = computed(() => this.ariaLabel().trim() || this.#labelledByText(), ...ngDevMode ? [{ debugName: "#name" }] : /* istanbul ignore next */ []);
362
+ this.#owner = signal(null, ...ngDevMode ? [{ debugName: "#owner" }] : /* istanbul ignore next */ []);
363
+ this.#toolbarFocus = signal(null, ...ngDevMode ? [{ debugName: "#toolbarFocus" }] : /* istanbul ignore next */ []);
364
+ this.#reported = /* @__PURE__ */ new Map();
365
+ this.baseClasses = computed(() => {
366
+ const rounded = this.rounded();
367
+ const size = this.size();
368
+ const position = this.toolbarOptions()?.position ?? "right";
369
+ return listBoxBaseThemeVariants({
370
+ direction: position === "left" || position === "right" ? "horizontal" : "vertical",
371
+ reversed: position === "left" || position === "top",
372
+ rounded,
373
+ size
374
+ });
375
+ }, ...ngDevMode ? [{ debugName: "baseClasses" }] : /* istanbul ignore next */ []);
376
+ this.canMoveDown = computed(() => {
377
+ const source = this.selectionHolder();
378
+ const indices = source?.selectedIndices() ?? [];
379
+ return source != null && indices.length > 0 && indices[indices.length - 1] < source.listBoxItems().length - 1;
380
+ }, ...ngDevMode ? [{ debugName: "canMoveDown" }] : /* istanbul ignore next */ []);
381
+ this.canMoveUp = computed(() => {
382
+ const indices = this.selectionHolder()?.selectedIndices() ?? [];
383
+ return indices.length > 0 && indices[0] > 0;
384
+ }, ...ngDevMode ? [{ debugName: "canMoveUp" }] : /* istanbul ignore next */ []);
385
+ this.enabledItems = computed(() => this.listBoxItems().where((item) => !this.#listService.isDataItemDisabled(item)).toArray(), ...ngDevMode ? [{ debugName: "enabledItems" }] : /* istanbul ignore next */ []);
386
+ this.footerTemplate = contentChild(ListBoxFooterTemplateDirective, {
387
+ ...ngDevMode ? { debugName: "footerTemplate" } : /* istanbul ignore next */ {},
388
+ read: TemplateRef
389
+ });
390
+ this.headerTemplate = contentChild(ListBoxHeaderTemplateDirective, {
391
+ ...ngDevMode ? { debugName: "headerTemplate" } : /* istanbul ignore next */ {},
392
+ read: TemplateRef
393
+ });
394
+ this.itemTemplate = contentChild(ListBoxItemTemplateDirective, {
395
+ ...ngDevMode ? { debugName: "itemTemplate" } : /* istanbul ignore next */ {},
396
+ read: TemplateRef
397
+ });
398
+ this.listHeight = computed(() => {
399
+ const height = this.height();
400
+ return typeof height === "number" ? `${height}px` : height;
401
+ }, ...ngDevMode ? [{ debugName: "listHeight" }] : /* istanbul ignore next */ []);
402
+ this.listWidth = computed(() => {
403
+ const width = this.width();
404
+ return typeof width === "number" ? `${width}px` : width;
405
+ }, ...ngDevMode ? [{ debugName: "listWidth" }] : /* istanbul ignore next */ []);
406
+ this.messages = this.#i18n.componentMessages("listBox", LIST_BOX_DEFAULT_MESSAGES);
407
+ this.noDataTemplate = contentChild(ListBoxNoDataTemplateDirective, {
408
+ ...ngDevMode ? { debugName: "noDataTemplate" } : /* istanbul ignore next */ {},
409
+ read: TemplateRef
410
+ });
411
+ this.orderedSelection = computed(() => {
412
+ const indexes = this.#itemIndexes();
413
+ return this.selectedItems().toArray().filter((item) => !this.#listService.isDataItemDisabled(item)).map((item) => ({
414
+ index: indexes.get(item) ?? -1,
415
+ item
416
+ })).filter((entry) => entry.index >= 0).sort((a, b) => a.index - b.index);
417
+ }, ...ngDevMode ? [{ debugName: "orderedSelection" }] : /* istanbul ignore next */ []);
418
+ this.selectableOptions = computed(() => {
419
+ const enabled = true;
420
+ const mode = this.selectionMode();
421
+ if (mode === "multiple") return {
422
+ enabled,
423
+ mode
424
+ };
425
+ return {
426
+ enabled,
427
+ mode,
428
+ toggleable: this.singleSelectionToggleable()
429
+ };
430
+ }, ...ngDevMode ? [{ debugName: "selectableOptions" }] : /* istanbul ignore next */ []);
431
+ this.selectedIndices = computed(() => this.orderedSelection().map((entry) => entry.index), ...ngDevMode ? [{ debugName: "selectedIndices" }] : /* istanbul ignore next */ []);
432
+ this.selectionHolder = computed(() => {
433
+ if (this.orderedSelection().length > 0) return this;
434
+ const connectedList = this.connectedList();
435
+ return connectedList && connectedList.orderedSelection().length > 0 ? connectedList : null;
436
+ }, ...ngDevMode ? [{ debugName: "selectionHolder" }] : /* istanbul ignore next */ []);
437
+ this.toolbarButtons = computed(() => {
438
+ const options = this.toolbarOptions();
439
+ if (!options) return [];
440
+ const connectedList = this.connectedList();
441
+ const messages = this.messages();
442
+ const holder = this.selectionHolder();
443
+ const target = connectedList ? connectedList.#name() : "";
444
+ const enabled = {
445
+ clear: holder != null,
446
+ moveDown: this.canMoveDown(),
447
+ moveUp: this.canMoveUp(),
448
+ remove: holder != null,
449
+ transferAllFrom: (connectedList?.enabledItems().length ?? 0) > 0,
450
+ transferAllTo: this.enabledItems().length > 0,
451
+ transferFrom: (connectedList?.orderedSelection().length ?? 0) > 0,
452
+ transferTo: this.orderedSelection().length > 0
453
+ };
454
+ const labels = {
455
+ clear: messages.clearSelection,
456
+ moveDown: messages.moveDown,
457
+ moveUp: messages.moveUp,
458
+ remove: messages.remove,
459
+ transferAllFrom: target ? messages.transferAllFromList(target) : messages.transferAllFrom,
460
+ transferAllTo: target ? messages.transferAllToList(target) : messages.transferAllTo,
461
+ transferFrom: target ? messages.transferFromList(target) : messages.transferFrom,
462
+ transferTo: target ? messages.transferToList(target) : messages.transferTo
463
+ };
464
+ return TOOLBAR_ORDER.filter((action) => options.actions.includes(action) && (connectedList != null || !TRANSFER_ACTIONS.has(action))).map((action) => ({
465
+ action,
466
+ enabled: enabled[action],
467
+ label: labels[action]
468
+ }));
469
+ }, ...ngDevMode ? [{ debugName: "toolbarButtons" }] : /* istanbul ignore next */ []);
470
+ this.toolbarClasses = computed(() => {
471
+ const direction = this.toolbarOrientation();
472
+ return listBoxToolbarThemeVariants({ direction });
473
+ }, ...ngDevMode ? [{ debugName: "toolbarClasses" }] : /* istanbul ignore next */ []);
474
+ this.toolbarLabel = computed(() => {
475
+ const label = this.toolbarAriaLabel().trim();
476
+ if (label) return label;
477
+ const list = this.#name();
478
+ return list ? this.messages().toolbarLabel(list) : null;
479
+ }, ...ngDevMode ? [{ debugName: "toolbarLabel" }] : /* istanbul ignore next */ []);
480
+ this.toolbarOptions = computed(() => {
481
+ const toolbar = this.toolbar();
482
+ if (typeof toolbar === "boolean") return toolbar ? {
483
+ actions: [...DEFAULT_ACTIONS],
484
+ position: "right"
485
+ } : null;
486
+ return {
487
+ actions: toolbar.actions ? [...toolbar.actions] : [...DEFAULT_ACTIONS],
488
+ position: toolbar.position ?? "right"
489
+ };
490
+ }, ...ngDevMode ? [{ debugName: "toolbarOptions" }] : /* istanbul ignore next */ []);
491
+ this.toolbarOrientation = computed(() => {
492
+ const position = this.toolbarOptions()?.position ?? "right";
493
+ return position === "left" || position === "right" ? "vertical" : "horizontal";
494
+ }, ...ngDevMode ? [{ debugName: "toolbarOrientation" }] : /* istanbul ignore next */ []);
495
+ this.toolbarTabStop = computed(() => {
496
+ const enabled = this.toolbarButtons().filter((button) => button.enabled);
497
+ const focused = this.#toolbarFocus();
498
+ return (enabled.find((button) => button.action === focused) ?? enabled[0])?.action ?? null;
499
+ }, ...ngDevMode ? [{ debugName: "toolbarTabStop" }] : /* istanbul ignore next */ []);
500
+ this.actionClick = output();
501
+ this.ariaLabel = input("", {
502
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
503
+ alias: "aria-label"
504
+ });
505
+ this.ariaLabelledBy = input("", {
506
+ ...ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {},
507
+ alias: "aria-labelledby"
508
+ });
509
+ this.connectedList = input(null, ...ngDevMode ? [{ debugName: "connectedList" }] : /* istanbul ignore next */ []);
510
+ this.disabledBy = input("", ...ngDevMode ? [{ debugName: "disabledBy" }] : /* istanbul ignore next */ []);
511
+ this.height = input("100%", ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
512
+ this.items = input([], ...ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []);
513
+ this.listBoxItems = computed(() => ImmutableList.create(this.items()), ...ngDevMode ? [{ debugName: "listBoxItems" }] : /* istanbul ignore next */ []);
514
+ this.rounded = input("medium", ...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
515
+ this.selectBy = input("", ...ngDevMode ? [{ debugName: "selectBy" }] : /* istanbul ignore next */ []);
516
+ this.selectedItems = computed(() => {
517
+ return this.#listService.selectedListItems().select((item) => item.data).toImmutableSet();
518
+ }, ...ngDevMode ? [{ debugName: "selectedItems" }] : /* istanbul ignore next */ []);
519
+ this.selectedItems$ = toObservable(this.selectedItems);
520
+ this.selectedKeys = input([], ...ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []);
521
+ this.selectedKeysChange = output();
522
+ this.selectionChange = output();
523
+ this.selectionMode = input("single", ...ngDevMode ? [{ debugName: "selectionMode" }] : /* istanbul ignore next */ []);
524
+ this.singleSelectionToggleable = input(true, {
525
+ ...ngDevMode ? { debugName: "singleSelectionToggleable" } : /* istanbul ignore next */ {},
526
+ transform: booleanAttribute
527
+ });
528
+ this.size = input("medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
529
+ this.textField = input("", ...ngDevMode ? [{ debugName: "textField" }] : /* istanbul ignore next */ []);
530
+ this.toolbar = input(true, {
531
+ ...ngDevMode ? { debugName: "toolbar" } : /* istanbul ignore next */ {},
532
+ transform: toToolbarSetting
533
+ });
534
+ this.toolbarAriaLabel = input("", ...ngDevMode ? [{ debugName: "toolbarAriaLabel" }] : /* istanbul ignore next */ []);
535
+ this.width = input("100%", ...ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []);
536
+ effect(() => {
537
+ const selectBy = this.selectBy();
538
+ const keys = this.selectedKeys();
539
+ untracked(() => {
540
+ this.#listService.setValueField(selectBy ?? "");
541
+ this.#listService.setSelectedKeys(keys ?? []);
542
+ this.#reported = new Map(Array.from(keys ?? [], (key) => [key, void 0]));
543
+ });
544
+ });
545
+ effect((onCleanup) => {
546
+ const connectedList = this.connectedList();
547
+ if (!connectedList) return;
548
+ untracked(() => connectedList.#owner.set(this));
549
+ onCleanup(() => {
550
+ if (untracked(connectedList.#owner) === this) connectedList.#owner.set(null);
551
+ });
552
+ });
553
+ }
554
+ clearSelections() {
555
+ this.#listService.clearSelections();
556
+ this.reportSelection();
557
+ }
558
+ notifySelectionChange() {
559
+ this.reportSelection();
560
+ }
561
+ onActionClick(action, event) {
562
+ const button = event.currentTarget instanceof HTMLButtonElement ? event.currentTarget : null;
563
+ this.runAction(action, event, button);
564
+ }
565
+ onHostKeydown(event) {
566
+ if (event.defaultPrevented || event.ctrlKey || event.metaKey || event.shiftKey || !this.isOwnOption(event)) return;
567
+ const shortcut = this.resolveShortcut(event);
568
+ if (!shortcut) return;
569
+ const { action, controller } = shortcut;
570
+ if (!controller.toolbarButtons().find((candidate) => candidate.action === action)?.enabled || controller.selectionHolder() !== this) return;
571
+ event.preventDefault();
572
+ controller.runAction(action, event, null);
573
+ }
574
+ onSelectedKeysChange() {
575
+ this.reportSelection();
576
+ }
577
+ onToolbarFocusIn(event) {
578
+ const action = this.toolbarActionOf(event.target);
579
+ if (action) this.#toolbarFocus.set(action);
580
+ }
581
+ onToolbarKeydown(event) {
582
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;
583
+ const buttons = this.toolbarButtons().filter((button) => button.enabled);
584
+ if (buttons.length === 0) return;
585
+ const vertical = this.toolbarOrientation() === "vertical";
586
+ const rtl = this.#direction() === "rtl";
587
+ const nextKey = vertical ? "ArrowDown" : rtl ? "ArrowLeft" : "ArrowRight";
588
+ const previousKey = vertical ? "ArrowUp" : rtl ? "ArrowRight" : "ArrowLeft";
589
+ const current = Math.max(0, buttons.findIndex((button) => button.action === this.toolbarTabStop()));
590
+ let index;
591
+ if (event.key === nextKey) index = (current + 1) % buttons.length;
592
+ else if (event.key === previousKey) index = (current - 1 + buttons.length) % buttons.length;
593
+ else if (event.key === "Home") index = 0;
594
+ else if (event.key === "End") index = buttons.length - 1;
595
+ else return;
596
+ event.preventDefault();
597
+ this.focusToolbarButton(buttons[index].action);
598
+ }
599
+ afterActionRender(button, outcome) {
600
+ afterNextRender({ write: () => {
601
+ const { announcement, focus } = outcome();
602
+ if (announcement) this.#liveAnnouncer.announce(announcement, "polite");
603
+ const active = this.#hostElementRef.nativeElement.ownerDocument.activeElement;
604
+ const focusLost = active == null || active === active.ownerDocument.body;
605
+ if (button == null || button.disabled || focusLost) focus();
606
+ } }, { injector: this.#injector });
607
+ }
608
+ clear(event, button) {
609
+ const holder = this.selectionHolder();
610
+ if (!holder) return;
611
+ const selection = holder.orderedSelection();
612
+ const clearEvent = new ListBoxClearEvent(selection.map((entry) => entry.item), event);
613
+ holder.actionClick.emit(clearEvent);
614
+ if (clearEvent.isDefaultPrevented()) return;
615
+ this.clearSelections();
616
+ this.connectedList()?.clearSelections();
617
+ this.afterActionRender(button, () => ({
618
+ announcement: this.messages().selectionCleared,
619
+ focus: () => holder.revealItem(selection[0]?.item, true)
620
+ }));
621
+ }
622
+ findItemByKey(key) {
623
+ return this.listBoxItems().firstOrDefault((item) => this.#listService.getDataItemValue(item) === key) ?? void 0;
624
+ }
625
+ focusToolbarButton(action) {
626
+ this.#toolbarFocus.set(action);
627
+ this.#hostElementRef.nativeElement.querySelector(`[role='toolbar'] button[data-action='${action}']`)?.focus();
628
+ }
629
+ isOwnOption(event) {
630
+ const target = event.target;
631
+ return target instanceof HTMLElement && target.hasAttribute("data-uid") && target.closest("mona-list-box") === this.#hostElementRef.nativeElement;
632
+ }
633
+ move(direction, event, button) {
634
+ const holder = this.selectionHolder();
635
+ if (!holder || (direction === "moveUp" ? !this.canMoveUp() : !this.canMoveDown())) return;
636
+ const selection = holder.orderedSelection();
637
+ const indices = selection.map((entry) => entry.index);
638
+ const startIndex = indices[0];
639
+ const newIndex = direction === "moveDown" ? indices[indices.length - 1] + 1 : startIndex - 1;
640
+ const items = selection.map((entry) => entry.item);
641
+ const highlighted = holder.#listService.highlightedItem()?.data;
642
+ const focusItem = highlighted !== void 0 && items.includes(highlighted) ? highlighted : items[0];
643
+ const moveEvent = new ListBoxMoveEvent(direction, items, indices, startIndex, newIndex, event);
644
+ holder.actionClick.emit(moveEvent);
645
+ if (moveEvent.isDefaultPrevented()) return;
646
+ this.afterActionRender(button, () => {
647
+ const first = holder.selectedIndices()[0];
648
+ holder.revealItem(holder.orderedSelection()[0]?.item, false);
649
+ return {
650
+ announcement: first !== void 0 && first !== startIndex ? this.messages().itemsMoved(first + 1, holder.listBoxItems().size()) : null,
651
+ focus: () => holder.revealItem(focusItem, true)
652
+ };
653
+ });
654
+ }
655
+ remove(event, button) {
656
+ const holder = this.selectionHolder();
657
+ if (!holder) return;
658
+ const selection = holder.orderedSelection();
659
+ const removeEvent = new ListBoxRemoveEvent(selection.map((entry) => entry.item), event);
660
+ holder.actionClick.emit(removeEvent);
661
+ if (removeEvent.isDefaultPrevented()) return;
662
+ const keys = selection.map((entry) => holder.#listService.getDataItemValue(entry.item));
663
+ const firstIndex = selection[0].index;
664
+ holder.clearSelections();
665
+ this.afterActionRender(button, () => {
666
+ const remaining = new Set(holder.listBoxItems().select((item) => holder.#listService.getDataItemValue(item)));
667
+ const removed = keys.filter((key) => !remaining.has(key)).length;
668
+ const enabledItems = holder.enabledItems();
669
+ const neighbour = enabledItems.find((item) => (holder.#itemIndexes().get(item) ?? -1) >= firstIndex);
670
+ return {
671
+ announcement: removed > 0 ? this.messages().itemsRemoved(removed) : null,
672
+ focus: () => holder.revealItem(neighbour ?? enabledItems[enabledItems.length - 1], true)
673
+ };
674
+ });
675
+ }
676
+ reportSelection() {
677
+ const keys = this.#listService.selectedKeys().toArray();
678
+ const current = /* @__PURE__ */ new Map();
679
+ for (const listItem of this.#listService.selectedListItems()) current.set(this.#listService.getDataItemValue(listItem.data), listItem.data);
680
+ for (const key of keys) if (!current.has(key)) current.set(key, void 0);
681
+ const previous = this.#reported;
682
+ const selectedItems = [...current].filter(([key]) => !previous.has(key)).map(([, item]) => item).filter((item) => item !== void 0);
683
+ const deselectedItems = [...previous].filter(([key]) => !current.has(key)).map(([key, item]) => item ?? this.findItemByKey(key)).filter((item) => item !== void 0);
684
+ const changed = keys.length !== previous.size || keys.some((key) => !previous.has(key));
685
+ this.#reported = current;
686
+ if (!changed) return;
687
+ this.selectionChange.emit({
688
+ deselectedItems,
689
+ selectedItems
690
+ });
691
+ this.selectedKeysChange.emit(keys);
692
+ if (selectedItems.length > 0) {
693
+ this.connectedList()?.clearSelections();
694
+ this.#owner()?.clearSelections();
695
+ }
696
+ }
697
+ resolveShortcut(event) {
698
+ const toolbarHolder = this.toolbarOptions() ? this : this.#owner();
699
+ if (event.key === "Delete" && !event.altKey) return toolbarHolder ? {
700
+ action: "remove",
701
+ controller: toolbarHolder
702
+ } : null;
703
+ if (!event.altKey) return null;
704
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {
705
+ const action = event.key === "ArrowUp" ? "moveUp" : "moveDown";
706
+ return toolbarHolder ? {
707
+ action,
708
+ controller: toolbarHolder
709
+ } : null;
710
+ }
711
+ if (event.key !== "ArrowRight" && event.key !== "ArrowLeft") return null;
712
+ if (event.key === "ArrowRight" !== (this.#direction() === "rtl")) return this.connectedList() ? {
713
+ action: "transferTo",
714
+ controller: this
715
+ } : null;
716
+ const owner = this.#owner();
717
+ return owner ? {
718
+ action: "transferFrom",
719
+ controller: owner
720
+ } : null;
721
+ }
722
+ revealItem(dataItem, focus) {
723
+ const key = dataItem === void 0 ? void 0 : this.#listService.getDataItemValue(dataItem);
724
+ const listItem = dataItem === void 0 ? null : this.#listService.viewItems().firstOrDefault((item) => !item.isHeader && this.#listService.getDataItemValue(item.data) === key);
725
+ if (listItem) {
726
+ if (focus) this.#listService.highlightedItem.set(listItem);
727
+ this.#listService.scrollToItem(listItem, focus);
728
+ } else if (focus) this.#listService.focus$.next();
729
+ }
730
+ runAction(action, event, button) {
731
+ switch (action) {
732
+ case "clear":
733
+ this.clear(event, button);
734
+ break;
735
+ case "moveDown":
736
+ case "moveUp":
737
+ this.move(action, event, button);
738
+ break;
739
+ case "remove":
740
+ this.remove(event, button);
741
+ break;
742
+ default: this.transfer(action, event, button);
743
+ }
744
+ }
745
+ selectTransferredItems(items) {
746
+ const selected = this.selectionMode() === "multiple" ? items : items.slice(0, 1);
747
+ this.#listService.setSelectedKeys(selected.map((item) => this.#listService.getDataItemValue(item)));
748
+ this.reportSelection();
749
+ }
750
+ toolbarActionOf(target) {
751
+ if (!(target instanceof HTMLElement)) return null;
752
+ const action = target.closest("button[data-action]")?.getAttribute("data-action");
753
+ return TOOLBAR_ORDER.find((candidate) => candidate === action) ?? null;
754
+ }
755
+ transfer(action, event, button) {
756
+ const connectedList = this.connectedList();
757
+ if (!connectedList) return;
758
+ const toConnected = action === "transferTo" || action === "transferAllTo";
759
+ const source = toConnected ? this : connectedList;
760
+ const target = toConnected ? connectedList : this;
761
+ const items = action === "transferAllTo" || action === "transferAllFrom" ? source.enabledItems() : source.orderedSelection().map((entry) => entry.item);
762
+ if (items.length === 0) return;
763
+ const transferEvent = new ListBoxTransferEvent(action, items, event);
764
+ source.actionClick.emit(transferEvent);
765
+ if (transferEvent.isDefaultPrevented()) return;
766
+ source.clearSelections();
767
+ target.clearSelections();
768
+ const keys = new Set(items.map((item) => target.#listService.getDataItemValue(item)));
769
+ this.afterActionRender(button, () => {
770
+ const arrived = target.listBoxItems().where((item) => keys.has(target.#listService.getDataItemValue(item))).toArray();
771
+ if (arrived.length > 0) {
772
+ target.selectTransferredItems(arrived);
773
+ target.revealItem(arrived[0], false);
774
+ }
775
+ const name = target.#name();
776
+ const messages = this.messages();
777
+ let announcement = null;
778
+ if (arrived.length > 0) announcement = name ? messages.itemsTransferred(arrived.length, name) : messages.itemsTransferredToOtherList(arrived.length);
779
+ return {
780
+ announcement,
781
+ focus: () => target.revealItem(arrived[0], true)
782
+ };
783
+ });
784
+ }
785
+ static {
786
+ this.ɵfac = i0.ɵɵngDeclareFactory({
787
+ minVersion: "12.0.0",
788
+ version: "22.2.6",
789
+ ngImport: i0,
790
+ type: ListBoxComponent,
791
+ deps: [],
792
+ target: i0.ɵɵFactoryTarget.Component
793
+ });
794
+ }
795
+ static {
796
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
797
+ minVersion: "17.0.0",
798
+ version: "22.2.6",
799
+ type: ListBoxComponent,
800
+ isStandalone: true,
801
+ selector: "mona-list-box",
802
+ inputs: {
803
+ ariaLabel: {
804
+ classPropertyName: "ariaLabel",
805
+ publicName: "aria-label",
806
+ isSignal: true,
807
+ isRequired: false,
808
+ transformFunction: null
809
+ },
810
+ ariaLabelledBy: {
811
+ classPropertyName: "ariaLabelledBy",
812
+ publicName: "aria-labelledby",
813
+ isSignal: true,
814
+ isRequired: false,
815
+ transformFunction: null
816
+ },
817
+ connectedList: {
818
+ classPropertyName: "connectedList",
819
+ publicName: "connectedList",
820
+ isSignal: true,
821
+ isRequired: false,
822
+ transformFunction: null
823
+ },
824
+ disabledBy: {
825
+ classPropertyName: "disabledBy",
826
+ publicName: "disabledBy",
827
+ isSignal: true,
828
+ isRequired: false,
829
+ transformFunction: null
830
+ },
831
+ height: {
832
+ classPropertyName: "height",
833
+ publicName: "height",
834
+ isSignal: true,
835
+ isRequired: false,
836
+ transformFunction: null
837
+ },
838
+ items: {
839
+ classPropertyName: "items",
840
+ publicName: "items",
841
+ isSignal: true,
842
+ isRequired: false,
843
+ transformFunction: null
844
+ },
845
+ rounded: {
846
+ classPropertyName: "rounded",
847
+ publicName: "rounded",
848
+ isSignal: true,
849
+ isRequired: false,
850
+ transformFunction: null
851
+ },
852
+ selectBy: {
853
+ classPropertyName: "selectBy",
854
+ publicName: "selectBy",
855
+ isSignal: true,
856
+ isRequired: false,
857
+ transformFunction: null
858
+ },
859
+ selectedKeys: {
860
+ classPropertyName: "selectedKeys",
861
+ publicName: "selectedKeys",
862
+ isSignal: true,
863
+ isRequired: false,
864
+ transformFunction: null
865
+ },
866
+ selectionMode: {
867
+ classPropertyName: "selectionMode",
868
+ publicName: "selectionMode",
869
+ isSignal: true,
870
+ isRequired: false,
871
+ transformFunction: null
872
+ },
873
+ singleSelectionToggleable: {
874
+ classPropertyName: "singleSelectionToggleable",
875
+ publicName: "singleSelectionToggleable",
876
+ isSignal: true,
877
+ isRequired: false,
878
+ transformFunction: null
879
+ },
880
+ size: {
881
+ classPropertyName: "size",
882
+ publicName: "size",
883
+ isSignal: true,
884
+ isRequired: false,
885
+ transformFunction: null
886
+ },
887
+ textField: {
888
+ classPropertyName: "textField",
889
+ publicName: "textField",
890
+ isSignal: true,
891
+ isRequired: false,
892
+ transformFunction: null
893
+ },
894
+ toolbar: {
895
+ classPropertyName: "toolbar",
896
+ publicName: "toolbar",
897
+ isSignal: true,
898
+ isRequired: false,
899
+ transformFunction: null
900
+ },
901
+ toolbarAriaLabel: {
902
+ classPropertyName: "toolbarAriaLabel",
903
+ publicName: "toolbarAriaLabel",
904
+ isSignal: true,
905
+ isRequired: false,
906
+ transformFunction: null
907
+ },
908
+ width: {
909
+ classPropertyName: "width",
910
+ publicName: "width",
911
+ isSignal: true,
912
+ isRequired: false,
913
+ transformFunction: null
914
+ }
915
+ },
916
+ outputs: {
917
+ actionClick: "actionClick",
918
+ selectedKeysChange: "selectedKeysChange",
919
+ selectionChange: "selectionChange"
920
+ },
921
+ host: {
922
+ listeners: { "keydown": "onHostKeydown($event)" },
923
+ properties: {
924
+ "attr.aria-label": "null",
925
+ "class": "baseClasses()",
926
+ "style.height": "listHeight()",
927
+ "style.width": "listWidth()"
928
+ }
929
+ },
930
+ providers: [ListService],
931
+ queries: [
932
+ {
933
+ propertyName: "footerTemplate",
934
+ first: true,
935
+ predicate: ListBoxFooterTemplateDirective,
936
+ descendants: true,
937
+ read: TemplateRef,
938
+ isSignal: true
939
+ },
940
+ {
941
+ propertyName: "headerTemplate",
942
+ first: true,
943
+ predicate: ListBoxHeaderTemplateDirective,
944
+ descendants: true,
945
+ read: TemplateRef,
946
+ isSignal: true
947
+ },
948
+ {
949
+ propertyName: "itemTemplate",
950
+ first: true,
951
+ predicate: ListBoxItemTemplateDirective,
952
+ descendants: true,
953
+ read: TemplateRef,
954
+ isSignal: true
955
+ },
956
+ {
957
+ propertyName: "noDataTemplate",
958
+ first: true,
959
+ predicate: ListBoxNoDataTemplateDirective,
960
+ descendants: true,
961
+ read: TemplateRef,
962
+ isSignal: true
963
+ }
964
+ ],
965
+ ngImport: i0,
966
+ template: "<mona-list-view\n [aria-label]=\"ariaLabel()\"\n [aria-labelledby]=\"ariaLabelledBy()\"\n [items]=\"listBoxItems()\"\n [height]=\"'100%'\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [textField]=\"textField()\"\n [width]=\"'100%'\"\n [disabledBy]=\"disabledBy()\"\n [monaListViewNavigable]=\"{ enabled: true, mode: 'select' }\"\n [monaListViewSelectable]=\"selectableOptions()\"\n [selectBy]=\"selectBy()\"\n [selectedKeys]=\"selectedKeys()\"\n (selectedKeysChange)=\"onSelectedKeysChange()\">\n @if (footerTemplate()) {\n <ng-template monaListViewFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListViewHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListViewItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListViewNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </ng-template>\n }\n</mona-list-view>\n\n@let buttons = toolbarButtons();\n@if (buttons.length > 0) {\n @let tabStop = toolbarTabStop();\n <div\n role=\"toolbar\"\n [attr.aria-label]=\"toolbarLabel()\"\n [attr.aria-orientation]=\"toolbarOrientation()\"\n [class]=\"toolbarClasses()\"\n (focusin)=\"onToolbarFocusIn($event)\"\n (keydown)=\"onToolbarKeydown($event)\">\n @for (button of buttons; track button.action) {\n <button\n monaButton\n type=\"button\"\n [attr.data-action]=\"button.action\"\n (click)=\"onActionClick(button.action, $event)\"\n [iconOnly]=\"true\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [title]=\"button.label\"\n [attr.aria-label]=\"button.label\"\n [disabled]=\"!button.enabled\"\n [tabindex]=\"tabStop === button.action ? 0 : -1\">\n @switch (button.action) {\n @case (\"moveUp\") {\n <svg lucideChevronUp [size]=\"16\"></svg>\n }\n @case (\"moveDown\") {\n <svg lucideChevronDown [size]=\"16\"></svg>\n }\n @case (\"transferFrom\") {\n <svg lucideChevronLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferTo\") {\n <svg lucideChevronRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferAllFrom\") {\n <svg lucideChevronsLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferAllTo\") {\n <svg lucideChevronsRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"clear\") {\n <svg lucideX [size]=\"16\"></svg>\n }\n @case (\"remove\") {\n <svg lucideTrash2 [size]=\"14\"></svg>\n }\n }\n </button>\n }\n </div>\n}\n",
967
+ dependencies: [
968
+ {
969
+ kind: "component",
970
+ type: ListViewComponent,
971
+ selector: "mona-list-view",
972
+ inputs: [
973
+ "aria-label",
974
+ "aria-labelledby",
975
+ "disabledBy",
976
+ "height",
977
+ "items",
978
+ "listClass",
979
+ "listItemClass",
980
+ "listItemStyle",
981
+ "listStyle",
982
+ "loading",
983
+ "maxHeight",
984
+ "maxWidth",
985
+ "pagerAriaLabel",
986
+ "rounded",
987
+ "size",
988
+ "textField",
989
+ "class",
990
+ "width"
991
+ ],
992
+ outputs: ["itemActivate", "scrollBottom"]
993
+ },
994
+ {
995
+ kind: "directive",
996
+ type: ListViewSelectableDirective,
997
+ selector: "mona-list-view[monaListViewSelectable]",
998
+ inputs: [
999
+ "monaListViewSelectable",
1000
+ "selectBy",
1001
+ "selectedKeys"
1002
+ ],
1003
+ outputs: ["selectedKeysChange"]
1004
+ },
1005
+ {
1006
+ kind: "directive",
1007
+ type: ListViewItemTemplateDirective,
1008
+ selector: "ng-template[monaListViewItemTemplate]",
1009
+ inputs: ["monaListViewItemTemplateOf"]
1010
+ },
1011
+ {
1012
+ kind: "directive",
1013
+ type: NgTemplateOutlet,
1014
+ selector: "[ngTemplateOutlet]",
1015
+ inputs: [
1016
+ "ngTemplateOutletContext",
1017
+ "ngTemplateOutlet",
1018
+ "ngTemplateOutletInjector"
1019
+ ]
1020
+ },
1021
+ {
1022
+ kind: "directive",
1023
+ type: ButtonDirective,
1024
+ selector: "button[monaButton]",
1025
+ inputs: [
1026
+ "aria-haspopup",
1027
+ "disabled",
1028
+ "iconOnly",
1029
+ "loading",
1030
+ "look",
1031
+ "rounded",
1032
+ "selected",
1033
+ "size",
1034
+ "tabindex",
1035
+ "toggleable",
1036
+ "type",
1037
+ "class",
1038
+ "value"
1039
+ ],
1040
+ outputs: ["lookChange", "selectedChange"]
1041
+ },
1042
+ {
1043
+ kind: "directive",
1044
+ type: ListViewNavigableDirective,
1045
+ selector: "mona-list-view[monaListViewNavigable]",
1046
+ inputs: ["monaListViewNavigable"]
1047
+ },
1048
+ {
1049
+ kind: "directive",
1050
+ type: ListViewNoDataTemplateDirective,
1051
+ selector: "ng-template[monaListViewNoDataTemplate]"
1052
+ },
1053
+ {
1054
+ kind: "directive",
1055
+ type: ListViewFooterTemplateDirective,
1056
+ selector: "ng-template[monaListViewFooterTemplate]"
1057
+ },
1058
+ {
1059
+ kind: "directive",
1060
+ type: ListViewHeaderTemplateDirective,
1061
+ selector: "ng-template[monaListViewHeaderTemplate]"
1062
+ },
1063
+ {
1064
+ kind: "component",
1065
+ type: LucideChevronUp,
1066
+ selector: "svg[lucideChevronUp]"
1067
+ },
1068
+ {
1069
+ kind: "component",
1070
+ type: LucideChevronDown,
1071
+ selector: "svg[lucideChevronDown]"
1072
+ },
1073
+ {
1074
+ kind: "component",
1075
+ type: LucideChevronLeft,
1076
+ selector: "svg[lucideChevronLeft]"
1077
+ },
1078
+ {
1079
+ kind: "component",
1080
+ type: LucideChevronRight,
1081
+ selector: "svg[lucideChevronRight]"
1082
+ },
1083
+ {
1084
+ kind: "component",
1085
+ type: LucideChevronsLeft,
1086
+ selector: "svg[lucideChevronsLeft]"
1087
+ },
1088
+ {
1089
+ kind: "component",
1090
+ type: LucideChevronsRight,
1091
+ selector: "svg[lucideChevronsRight]"
1092
+ },
1093
+ {
1094
+ kind: "component",
1095
+ type: LucideX,
1096
+ selector: "svg[lucideX]"
1097
+ },
1098
+ {
1099
+ kind: "component",
1100
+ type: LucideTrash2,
1101
+ selector: "svg[lucideTrash], svg[lucideTrash2]"
1102
+ }
1103
+ ],
1104
+ viewProviders: [{
1105
+ provide: LIST_VIEW_HOST_LIST_SERVICE,
1106
+ useExisting: ListService
1107
+ }]
1108
+ });
1109
+ }
1110
+ };
1111
+ i0.ɵɵngDeclareClassMetadata({
1112
+ minVersion: "12.0.0",
1113
+ version: "22.2.6",
1114
+ ngImport: i0,
1115
+ type: ListBoxComponent,
1116
+ decorators: [{
1117
+ type: Component,
1118
+ args: [{
1119
+ selector: "mona-list-box",
1120
+ providers: [ListService],
1121
+ viewProviders: [{
1122
+ provide: LIST_VIEW_HOST_LIST_SERVICE,
1123
+ useExisting: ListService
1124
+ }],
1125
+ imports: [
1126
+ ListViewComponent,
1127
+ ListViewSelectableDirective,
1128
+ ListViewItemTemplateDirective,
1129
+ NgTemplateOutlet,
1130
+ ButtonDirective,
1131
+ ListViewNavigableDirective,
1132
+ ListViewNoDataTemplateDirective,
1133
+ ListViewFooterTemplateDirective,
1134
+ ListViewHeaderTemplateDirective,
1135
+ LucideChevronUp,
1136
+ LucideChevronDown,
1137
+ LucideChevronLeft,
1138
+ LucideChevronRight,
1139
+ LucideChevronsLeft,
1140
+ LucideChevronsRight,
1141
+ LucideX,
1142
+ LucideTrash2
1143
+ ],
1144
+ host: {
1145
+ "[attr.aria-label]": "null",
1146
+ "[class]": "baseClasses()",
1147
+ "[style.height]": "listHeight()",
1148
+ "[style.width]": "listWidth()",
1149
+ "(keydown)": "onHostKeydown($event)"
1150
+ },
1151
+ template: "<mona-list-view\n [aria-label]=\"ariaLabel()\"\n [aria-labelledby]=\"ariaLabelledBy()\"\n [items]=\"listBoxItems()\"\n [height]=\"'100%'\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [textField]=\"textField()\"\n [width]=\"'100%'\"\n [disabledBy]=\"disabledBy()\"\n [monaListViewNavigable]=\"{ enabled: true, mode: 'select' }\"\n [monaListViewSelectable]=\"selectableOptions()\"\n [selectBy]=\"selectBy()\"\n [selectedKeys]=\"selectedKeys()\"\n (selectedKeysChange)=\"onSelectedKeysChange()\">\n @if (footerTemplate()) {\n <ng-template monaListViewFooterTemplate>\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (headerTemplate()) {\n <ng-template monaListViewHeaderTemplate>\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n </ng-template>\n }\n @if (itemTemplate()) {\n <ng-template monaListViewItemTemplate let-dataItem>\n <ng-container\n [ngTemplateOutlet]=\"itemTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: dataItem }\"></ng-container>\n </ng-template>\n }\n @if (noDataTemplate()) {\n <ng-template monaListViewNoDataTemplate>\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </ng-template>\n }\n</mona-list-view>\n\n@let buttons = toolbarButtons();\n@if (buttons.length > 0) {\n @let tabStop = toolbarTabStop();\n <div\n role=\"toolbar\"\n [attr.aria-label]=\"toolbarLabel()\"\n [attr.aria-orientation]=\"toolbarOrientation()\"\n [class]=\"toolbarClasses()\"\n (focusin)=\"onToolbarFocusIn($event)\"\n (keydown)=\"onToolbarKeydown($event)\">\n @for (button of buttons; track button.action) {\n <button\n monaButton\n type=\"button\"\n [attr.data-action]=\"button.action\"\n (click)=\"onActionClick(button.action, $event)\"\n [iconOnly]=\"true\"\n [rounded]=\"rounded()\"\n [size]=\"size()\"\n [title]=\"button.label\"\n [attr.aria-label]=\"button.label\"\n [disabled]=\"!button.enabled\"\n [tabindex]=\"tabStop === button.action ? 0 : -1\">\n @switch (button.action) {\n @case (\"moveUp\") {\n <svg lucideChevronUp [size]=\"16\"></svg>\n }\n @case (\"moveDown\") {\n <svg lucideChevronDown [size]=\"16\"></svg>\n }\n @case (\"transferFrom\") {\n <svg lucideChevronLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferTo\") {\n <svg lucideChevronRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferAllFrom\") {\n <svg lucideChevronsLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"transferAllTo\") {\n <svg lucideChevronsRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n @case (\"clear\") {\n <svg lucideX [size]=\"16\"></svg>\n }\n @case (\"remove\") {\n <svg lucideTrash2 [size]=\"14\"></svg>\n }\n }\n </button>\n }\n </div>\n}\n"
1152
+ }]
1153
+ }],
1154
+ ctorParameters: () => [],
1155
+ propDecorators: {
1156
+ footerTemplate: [{
1157
+ type: i0.ContentChild,
1158
+ args: [i0.forwardRef(() => ListBoxFooterTemplateDirective), {
1159
+ read: TemplateRef,
1160
+ isSignal: true
1161
+ }]
1162
+ }],
1163
+ headerTemplate: [{
1164
+ type: i0.ContentChild,
1165
+ args: [i0.forwardRef(() => ListBoxHeaderTemplateDirective), {
1166
+ read: TemplateRef,
1167
+ isSignal: true
1168
+ }]
1169
+ }],
1170
+ itemTemplate: [{
1171
+ type: i0.ContentChild,
1172
+ args: [i0.forwardRef(() => ListBoxItemTemplateDirective), {
1173
+ read: TemplateRef,
1174
+ isSignal: true
1175
+ }]
1176
+ }],
1177
+ noDataTemplate: [{
1178
+ type: i0.ContentChild,
1179
+ args: [i0.forwardRef(() => ListBoxNoDataTemplateDirective), {
1180
+ read: TemplateRef,
1181
+ isSignal: true
1182
+ }]
1183
+ }],
1184
+ actionClick: [{
1185
+ type: i0.Output,
1186
+ args: ["actionClick"]
1187
+ }],
1188
+ ariaLabel: [{
1189
+ type: i0.Input,
1190
+ args: [{
1191
+ isSignal: true,
1192
+ alias: "aria-label",
1193
+ required: false
1194
+ }]
1195
+ }],
1196
+ ariaLabelledBy: [{
1197
+ type: i0.Input,
1198
+ args: [{
1199
+ isSignal: true,
1200
+ alias: "aria-labelledby",
1201
+ required: false
1202
+ }]
1203
+ }],
1204
+ connectedList: [{
1205
+ type: i0.Input,
1206
+ args: [{
1207
+ isSignal: true,
1208
+ alias: "connectedList",
1209
+ required: false
1210
+ }]
1211
+ }],
1212
+ disabledBy: [{
1213
+ type: i0.Input,
1214
+ args: [{
1215
+ isSignal: true,
1216
+ alias: "disabledBy",
1217
+ required: false
1218
+ }]
1219
+ }],
1220
+ height: [{
1221
+ type: i0.Input,
1222
+ args: [{
1223
+ isSignal: true,
1224
+ alias: "height",
1225
+ required: false
1226
+ }]
1227
+ }],
1228
+ items: [{
1229
+ type: i0.Input,
1230
+ args: [{
1231
+ isSignal: true,
1232
+ alias: "items",
1233
+ required: false
1234
+ }]
1235
+ }],
1236
+ rounded: [{
1237
+ type: i0.Input,
1238
+ args: [{
1239
+ isSignal: true,
1240
+ alias: "rounded",
1241
+ required: false
1242
+ }]
1243
+ }],
1244
+ selectBy: [{
1245
+ type: i0.Input,
1246
+ args: [{
1247
+ isSignal: true,
1248
+ alias: "selectBy",
1249
+ required: false
1250
+ }]
1251
+ }],
1252
+ selectedKeys: [{
1253
+ type: i0.Input,
1254
+ args: [{
1255
+ isSignal: true,
1256
+ alias: "selectedKeys",
1257
+ required: false
1258
+ }]
1259
+ }],
1260
+ selectedKeysChange: [{
1261
+ type: i0.Output,
1262
+ args: ["selectedKeysChange"]
1263
+ }],
1264
+ selectionChange: [{
1265
+ type: i0.Output,
1266
+ args: ["selectionChange"]
1267
+ }],
1268
+ selectionMode: [{
1269
+ type: i0.Input,
1270
+ args: [{
1271
+ isSignal: true,
1272
+ alias: "selectionMode",
1273
+ required: false
1274
+ }]
1275
+ }],
1276
+ singleSelectionToggleable: [{
1277
+ type: i0.Input,
1278
+ args: [{
1279
+ isSignal: true,
1280
+ alias: "singleSelectionToggleable",
1281
+ required: false
1282
+ }]
1283
+ }],
1284
+ size: [{
1285
+ type: i0.Input,
1286
+ args: [{
1287
+ isSignal: true,
1288
+ alias: "size",
1289
+ required: false
1290
+ }]
1291
+ }],
1292
+ textField: [{
1293
+ type: i0.Input,
1294
+ args: [{
1295
+ isSignal: true,
1296
+ alias: "textField",
1297
+ required: false
1298
+ }]
1299
+ }],
1300
+ toolbar: [{
1301
+ type: i0.Input,
1302
+ args: [{
1303
+ isSignal: true,
1304
+ alias: "toolbar",
1305
+ required: false
1306
+ }]
1307
+ }],
1308
+ toolbarAriaLabel: [{
1309
+ type: i0.Input,
1310
+ args: [{
1311
+ isSignal: true,
1312
+ alias: "toolbarAriaLabel",
1313
+ required: false
1314
+ }]
1315
+ }],
1316
+ width: [{
1317
+ type: i0.Input,
1318
+ args: [{
1319
+ isSignal: true,
1320
+ alias: "width",
1321
+ required: false
1322
+ }]
1323
+ }]
1324
+ }
1325
+ });
1028
1326
  export { LIST_BOX_DEFAULT_MESSAGES, ListBoxClearEvent, ListBoxComponent, ListBoxFooterTemplateDirective, ListBoxHeaderTemplateDirective, ListBoxItemTemplateDirective, ListBoxMoveEvent, ListBoxNoDataTemplateDirective, ListBoxRemoveEvent, ListBoxTransferEvent };
1029
- //# sourceMappingURL=nanahoshi-mona-ui-list-box.mjs.map
1327
+
1328
+ //# sourceMappingURL=nanahoshi-mona-ui-list-box.mjs.map