@nanahoshi/mona-ui 0.27.1 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/docs/api/auto-complete.md +67 -0
  2. package/docs/api/avatar.md +31 -0
  3. package/docs/api/breadcrumb.md +74 -0
  4. package/docs/api/button-group.md +71 -0
  5. package/docs/api/button.md +84 -0
  6. package/docs/api/calendar.md +123 -0
  7. package/docs/api/card.md +97 -0
  8. package/docs/api/chart.md +4380 -0
  9. package/docs/api/check-box.md +70 -0
  10. package/docs/api/chip.md +55 -0
  11. package/docs/api/circular-progress-bar.md +71 -0
  12. package/docs/api/collapsible.md +71 -0
  13. package/docs/api/color-gradient.md +54 -0
  14. package/docs/api/color-palette.md +52 -0
  15. package/docs/api/color-picker.md +89 -0
  16. package/docs/api/combo-box.md +69 -0
  17. package/docs/api/command.md +282 -0
  18. package/docs/api/common.md +599 -0
  19. package/docs/api/contextmenu.md +239 -0
  20. package/docs/api/date-input.md +119 -0
  21. package/docs/api/date-picker.md +67 -0
  22. package/docs/api/datetime-picker.md +72 -0
  23. package/docs/api/dialog.md +291 -0
  24. package/docs/api/dropdown-button.md +248 -0
  25. package/docs/api/dropdown-list.md +72 -0
  26. package/docs/api/dropdowns.md +172 -0
  27. package/docs/api/editor.md +117 -0
  28. package/docs/api/expansion-panel.md +85 -0
  29. package/docs/api/fieldset.md +33 -0
  30. package/docs/api/filter.md +116 -0
  31. package/docs/api/grid.md +1445 -0
  32. package/docs/api/i18n.md +1699 -0
  33. package/docs/api/label.md +58 -0
  34. package/docs/api/list-box.md +301 -0
  35. package/docs/api/list-view.md +294 -0
  36. package/docs/api/list.md +119 -0
  37. package/docs/api/locales.md +134 -0
  38. package/docs/api/menubar.md +275 -0
  39. package/docs/api/multi-select.md +92 -0
  40. package/docs/api/notification.md +164 -0
  41. package/docs/api/numeric-text-box.md +130 -0
  42. package/docs/api/otp-input.md +100 -0
  43. package/docs/api/pager.md +371 -0
  44. package/docs/api/placeholder.md +18 -0
  45. package/docs/api/popover.md +170 -0
  46. package/docs/api/popup-menu.md +328 -0
  47. package/docs/api/popup.md +299 -0
  48. package/docs/api/progress-bar.md +79 -0
  49. package/docs/api/query.md +367 -0
  50. package/docs/api/radio-button.md +113 -0
  51. package/docs/api/rating.md +187 -0
  52. package/docs/api/scroll-view.md +93 -0
  53. package/docs/api/segmented.md +114 -0
  54. package/docs/api/sheet.md +65 -0
  55. package/docs/api/sidebar.md +583 -0
  56. package/docs/api/skeleton.md +26 -0
  57. package/docs/api/slider.md +173 -0
  58. package/docs/api/spinner.md +132 -0
  59. package/docs/api/split-button.md +261 -0
  60. package/docs/api/splitter.md +57 -0
  61. package/docs/api/stepper.md +148 -0
  62. package/docs/api/switch.md +78 -0
  63. package/docs/api/tabs.md +139 -0
  64. package/docs/api/text-area.md +20 -0
  65. package/docs/api/text-box.md +106 -0
  66. package/docs/api/theme.md +627 -0
  67. package/docs/api/time-picker.md +69 -0
  68. package/docs/api/time-selector.md +54 -0
  69. package/docs/api/tooltip.md +112 -0
  70. package/docs/api/tree-view.md +631 -0
  71. package/docs/api/window.md +245 -0
  72. package/docs/auto-complete.md +28 -329
  73. package/docs/avatar.md +4 -24
  74. package/docs/breadcrumb.md +10 -65
  75. package/docs/button-group.md +7 -60
  76. package/docs/button.md +8 -67
  77. package/docs/calendar.md +16 -121
  78. package/docs/card.md +16 -79
  79. package/docs/chart-bar.md +16 -234
  80. package/docs/chart-financial.md +10 -121
  81. package/docs/chart-funnel.md +13 -176
  82. package/docs/chart-heatmap.md +15 -131
  83. package/docs/chart-line-area.md +12 -137
  84. package/docs/chart-pie.md +17 -221
  85. package/docs/chart-radar.md +13 -129
  86. package/docs/chart-radial.md +13 -211
  87. package/docs/chart-scatter.md +6 -74
  88. package/docs/chart-treemap.md +14 -196
  89. package/docs/chart.md +168 -1892
  90. package/docs/checkbox.md +5 -61
  91. package/docs/chip.md +7 -42
  92. package/docs/circular-progress-bar.md +9 -61
  93. package/docs/collapsible.md +5 -87
  94. package/docs/color-gradient.md +8 -81
  95. package/docs/color-palette.md +7 -69
  96. package/docs/color-picker.md +9 -105
  97. package/docs/combo-box.md +28 -331
  98. package/docs/command.md +25 -236
  99. package/docs/contextmenu.md +15 -140
  100. package/docs/date-picker.md +7 -110
  101. package/docs/datetime-picker.md +7 -129
  102. package/docs/decimal-textbox.md +6 -69
  103. package/docs/dialog.md +23 -263
  104. package/docs/dropdown-button.md +15 -146
  105. package/docs/dropdown-list.md +29 -332
  106. package/docs/editor.md +10 -164
  107. package/docs/expansion-panel.md +7 -69
  108. package/docs/fieldset.md +5 -24
  109. package/docs/grid-columns.md +12 -92
  110. package/docs/grid-editing.md +29 -291
  111. package/docs/grid-grouping.md +11 -50
  112. package/docs/grid-rows.md +10 -74
  113. package/docs/grid-selection.md +7 -36
  114. package/docs/grid-server.md +8 -293
  115. package/docs/grid-sorting-filtering.md +10 -333
  116. package/docs/grid-state-export.md +17 -228
  117. package/docs/grid.md +23 -216
  118. package/docs/input.md +7 -19
  119. package/docs/installation.md +147 -15
  120. package/docs/introduction.md +37 -15
  121. package/docs/label.md +8 -39
  122. package/docs/list-box.md +21 -253
  123. package/docs/list-view.md +25 -232
  124. package/docs/menubar.md +21 -167
  125. package/docs/multi-select.md +31 -350
  126. package/docs/notification.md +17 -116
  127. package/docs/numeric-textbox.md +9 -78
  128. package/docs/otp-input.md +9 -95
  129. package/docs/pager.md +19 -239
  130. package/docs/placeholder.md +5 -18
  131. package/docs/popover.md +13 -123
  132. package/docs/popup-menu.md +22 -243
  133. package/docs/popup.md +24 -248
  134. package/docs/progress-bar.md +10 -75
  135. package/docs/radio-button.md +8 -96
  136. package/docs/range-slider.md +9 -82
  137. package/docs/rating.md +15 -163
  138. package/docs/scroll-view.md +9 -86
  139. package/docs/segmented.md +8 -90
  140. package/docs/sheet.md +10 -74
  141. package/docs/sidebar-menus.md +20 -155
  142. package/docs/sidebar-state.md +16 -134
  143. package/docs/sidebar.md +18 -218
  144. package/docs/skeleton.md +5 -26
  145. package/docs/slider.md +9 -97
  146. package/docs/spinner.md +15 -95
  147. package/docs/split-button.md +21 -166
  148. package/docs/splitter.md +9 -56
  149. package/docs/stepper.md +13 -127
  150. package/docs/switch.md +8 -58
  151. package/docs/tabs.md +13 -111
  152. package/docs/textarea.md +4 -13
  153. package/docs/textbox.md +10 -77
  154. package/docs/theming-built-in-themes.md +67 -0
  155. package/docs/theming-custom-colors.md +274 -0
  156. package/docs/theming-custom-themes.md +168 -0
  157. package/docs/theming.md +164 -248
  158. package/docs/time-picker.md +7 -112
  159. package/docs/tooltip-directive.md +12 -96
  160. package/docs/tooltip.md +12 -96
  161. package/docs/tree-view.md +42 -495
  162. package/docs/window.md +19 -230
  163. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  164. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  165. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  166. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  167. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  168. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2070 -1573
  169. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  170. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  171. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  172. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  173. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  174. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -389
  175. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  176. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  177. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  178. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  179. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  180. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -740
  181. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  182. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -254
  183. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  184. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  185. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  186. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  187. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  188. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -729
  189. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  190. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  191. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  192. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  193. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  194. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  195. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  196. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  197. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  198. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  199. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  200. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  201. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5068
  202. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  203. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  204. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  205. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  206. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  207. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  208. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  209. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  210. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  211. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  212. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  213. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  214. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  215. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  216. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  217. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  218. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  219. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  220. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  221. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  222. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  223. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  224. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  225. package/fesm2022/nanahoshi-mona-ui-locales.mjs +59 -77
  226. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  227. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  228. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  229. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  230. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  231. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  232. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  233. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  234. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  235. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  236. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  237. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  238. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  239. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  240. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  241. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  242. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  243. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  244. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  245. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  246. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  247. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  248. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  249. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  250. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  251. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  252. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  253. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  254. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  255. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  256. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  257. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  258. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  259. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  260. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  261. package/llms.txt +80 -2
  262. package/package.json +62 -23
  263. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  264. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  265. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  266. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  267. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  268. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  269. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  270. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  271. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  272. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  273. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  274. package/types/nanahoshi-mona-ui-collapsible.d.ts +105 -87
  275. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  276. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  277. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  278. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  279. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  280. package/types/nanahoshi-mona-ui-common.d.ts +360 -385
  281. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  282. package/types/nanahoshi-mona-ui-date-input.d.ts +97 -97
  283. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  284. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  285. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  286. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  287. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  288. package/types/nanahoshi-mona-ui-dropdowns.d.ts +255 -235
  289. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  290. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  291. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  292. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  293. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  294. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  295. package/types/nanahoshi-mona-ui-i18n.d.ts +999 -1052
  296. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  297. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  298. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  299. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  300. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  301. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  302. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  303. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  304. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  305. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  306. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  307. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  308. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  309. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  310. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  311. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  312. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  313. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  314. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  315. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  316. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  317. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  318. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  319. package/types/nanahoshi-mona-ui-locales.d.ts +17 -19
  320. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  321. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  322. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  323. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  324. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  325. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  326. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  327. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  328. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  329. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  330. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  331. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  332. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  333. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  334. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  335. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  336. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  337. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  338. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  339. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  340. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  341. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  342. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  343. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  344. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  345. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  346. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  347. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  348. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  349. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  350. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  351. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  352. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  353. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  354. package/types/nanahoshi-mona-ui.d.ts +1 -2
  355. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  356. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  357. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  358. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  359. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
@@ -1,1845 +1,2096 @@
1
- import { CdkVirtualScrollViewport, CdkFixedSizeVirtualScroll, CdkVirtualForOf } from '@angular/cdk/scrolling';
2
- import { NgTemplateOutlet } from '@angular/common';
3
- import * as i0 from '@angular/core';
4
- import { Directive, computed, signal, inject, linkedSignal, Injectable, input, ElementRef, Component, DestroyRef, viewChild, contentChild, TemplateRef, booleanAttribute, output, effect, untracked, afterRenderEffect, afterNextRender, InjectionToken } from '@angular/core';
5
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
6
- import { MonaI18nService } from '@nanahoshi/mona-ui/i18n';
7
- import { themeSelectionBarClasses, createElementControlId, isTypeaheadKey, setupTypeahead } from '@nanahoshi/mona-ui/internal';
8
- import { FilterInputComponent } from '@nanahoshi/mona-ui/internal/filter-input';
9
- import { PlaceholderComponent } from '@nanahoshi/mona-ui/placeholder';
10
- import { Subject, ReplaySubject, fromEvent, asyncScheduler, filter, tap } from 'rxjs';
11
- import { twMerge } from 'tailwind-merge';
12
- import { ImmutableList, toImmutableSet, ImmutableSet, from } from '@mirei/ts-collections';
13
- import { v4 } from 'uuid';
14
- import { cva } from 'class-variance-authority';
15
- import { CheckboxDirective } from '@nanahoshi/mona-ui/check-box';
16
-
17
- // Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
18
- // Edit the JSON file and run `npm run generate:locale-catalogs`.
1
+ import { CdkFixedSizeVirtualScroll, CdkVirtualForOf, CdkVirtualScrollViewport } from "@angular/cdk/scrolling";
2
+ import { NgTemplateOutlet } from "@angular/common";
3
+ import * as i0 from "@angular/core";
4
+ import { Component, DestroyRef, Directive, ElementRef, Injectable, InjectionToken, TemplateRef, afterNextRender, afterRenderEffect, booleanAttribute, computed, contentChild, effect, inject, input, linkedSignal, output, signal, untracked, viewChild } from "@angular/core";
5
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
6
+ import { MonaI18nService } from "@nanahoshi/mona-ui/i18n";
7
+ import { createElementControlId, isTypeaheadKey, setupTypeahead, themeSelectionBarClasses } from "@nanahoshi/mona-ui/internal";
8
+ import { FilterInputComponent } from "@nanahoshi/mona-ui/internal/filter-input";
9
+ import { PlaceholderComponent } from "@nanahoshi/mona-ui/placeholder";
10
+ import { ReplaySubject, Subject, asyncScheduler, filter, fromEvent, tap } from "rxjs";
11
+ import { twMerge } from "tailwind-merge";
12
+ import { ImmutableList, ImmutableSet, from, toImmutableSet } from "@mirei/ts-collections";
13
+ import { v4 } from "uuid";
14
+ import { cva } from "class-variance-authority";
15
+ import { CheckboxDirective } from "@nanahoshi/mona-ui/check-box";
19
16
  const LIST_DEFAULT_MESSAGES = {
20
- filterList: "Filter list",
21
- loading: "Loading",
22
- noData: "No data",
23
- pagerLabel: (list) => `${list} pagination`
17
+ filterList: "Filter list",
18
+ loading: "Loading",
19
+ noData: "No data",
20
+ pagerLabel: (list) => `${list} pagination`
24
21
  };
25
-
26
- class ListFooterTemplateDirective {
27
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListFooterTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
28
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ListFooterTemplateDirective, isStandalone: true, selector: "ng-template[monaListFooterTemplate]", ngImport: i0 }); }
29
- }
30
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListFooterTemplateDirective, decorators: [{
31
- type: Directive,
32
- args: [{
33
- selector: "ng-template[monaListFooterTemplate]"
34
- }]
35
- }] });
36
-
37
- class ListGroupHeaderTemplateDirective {
38
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListGroupHeaderTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
39
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ListGroupHeaderTemplateDirective, isStandalone: true, selector: "ng-template[monaListGroupHeaderTemplate]", ngImport: i0 }); }
40
- }
41
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListGroupHeaderTemplateDirective, decorators: [{
42
- type: Directive,
43
- args: [{
44
- selector: "ng-template[monaListGroupHeaderTemplate]"
45
- }]
46
- }] });
47
-
48
- class ListHeaderTemplateDirective {
49
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListHeaderTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
50
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ListHeaderTemplateDirective, isStandalone: true, selector: "ng-template[monaListHeaderTemplate]", ngImport: i0 }); }
51
- }
52
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListHeaderTemplateDirective, decorators: [{
53
- type: Directive,
54
- args: [{
55
- selector: "ng-template[monaListHeaderTemplate]"
56
- }]
57
- }] });
58
-
59
- class ListItemTemplateDirective {
60
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListItemTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
61
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ListItemTemplateDirective, isStandalone: true, selector: "ng-template[monaListItemTemplate]", ngImport: i0 }); }
62
- }
63
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListItemTemplateDirective, decorators: [{
64
- type: Directive,
65
- args: [{
66
- selector: "ng-template[monaListItemTemplate]"
67
- }]
68
- }] });
69
-
70
- /** An item of a list, wrapping its data item. */
71
- class ListItem {
72
- constructor(options) {
73
- this.header = "";
74
- this.data = options.data;
75
- this.uid = options.uid ?? v4();
76
- this.header = options.header ?? this.header;
77
- this.isHeader = options.isHeader ?? this.header !== "";
78
- }
79
- }
80
-
81
- /**
82
- * Finds the item typeahead moves to: the next matching item after the active one, wrapping around. With
83
- * `keepActive` (a buffer longer than one character), an active item that still matches stays active, so typing
84
- * "ap" on Apple doesn't move on to Apricot.
85
- */
86
- const cycleThroughMatchedItems = (items, activeItem, // highlighted or selected item
87
- predicate, keepActive = false) => {
88
- const matchedItems = Array.from(items).filter(predicate);
89
- if (matchedItems.length === 0) {
90
- return null;
91
- }
92
- const currentIndex = activeItem ? matchedItems.indexOf(activeItem) : -1;
93
- if (keepActive && currentIndex !== -1) {
94
- return matchedItems[currentIndex];
95
- }
96
- const nextIndex = (currentIndex + 1) % matchedItems.length;
97
- return matchedItems[nextIndex];
22
+ var ListFooterTemplateDirective = class ListFooterTemplateDirective {
23
+ static {
24
+ this.ɵfac = i0.ɵɵngDeclareFactory({
25
+ minVersion: "12.0.0",
26
+ version: "22.2.6",
27
+ ngImport: i0,
28
+ type: ListFooterTemplateDirective,
29
+ deps: [],
30
+ target: i0.ɵɵFactoryTarget.Directive
31
+ });
32
+ }
33
+ static {
34
+ this.ɵdir = i0.ɵɵngDeclareDirective({
35
+ minVersion: "14.0.0",
36
+ version: "22.2.6",
37
+ type: ListFooterTemplateDirective,
38
+ isStandalone: true,
39
+ selector: "ng-template[monaListFooterTemplate]",
40
+ ngImport: i0
41
+ });
42
+ }
43
+ };
44
+ i0.ɵɵngDeclareClassMetadata({
45
+ minVersion: "12.0.0",
46
+ version: "22.2.6",
47
+ ngImport: i0,
48
+ type: ListFooterTemplateDirective,
49
+ decorators: [{
50
+ type: Directive,
51
+ args: [{ selector: "ng-template[monaListFooterTemplate]" }]
52
+ }]
53
+ });
54
+ var ListGroupHeaderTemplateDirective = class ListGroupHeaderTemplateDirective {
55
+ static {
56
+ this.ɵfac = i0.ɵɵngDeclareFactory({
57
+ minVersion: "12.0.0",
58
+ version: "22.2.6",
59
+ ngImport: i0,
60
+ type: ListGroupHeaderTemplateDirective,
61
+ deps: [],
62
+ target: i0.ɵɵFactoryTarget.Directive
63
+ });
64
+ }
65
+ static {
66
+ this.ɵdir = i0.ɵɵngDeclareDirective({
67
+ minVersion: "14.0.0",
68
+ version: "22.2.6",
69
+ type: ListGroupHeaderTemplateDirective,
70
+ isStandalone: true,
71
+ selector: "ng-template[monaListGroupHeaderTemplate]",
72
+ ngImport: i0
73
+ });
74
+ }
75
+ };
76
+ i0.ɵɵngDeclareClassMetadata({
77
+ minVersion: "12.0.0",
78
+ version: "22.2.6",
79
+ ngImport: i0,
80
+ type: ListGroupHeaderTemplateDirective,
81
+ decorators: [{
82
+ type: Directive,
83
+ args: [{ selector: "ng-template[monaListGroupHeaderTemplate]" }]
84
+ }]
85
+ });
86
+ var ListHeaderTemplateDirective = class ListHeaderTemplateDirective {
87
+ static {
88
+ this.ɵfac = i0.ɵɵngDeclareFactory({
89
+ minVersion: "12.0.0",
90
+ version: "22.2.6",
91
+ ngImport: i0,
92
+ type: ListHeaderTemplateDirective,
93
+ deps: [],
94
+ target: i0.ɵɵFactoryTarget.Directive
95
+ });
96
+ }
97
+ static {
98
+ this.ɵdir = i0.ɵɵngDeclareDirective({
99
+ minVersion: "14.0.0",
100
+ version: "22.2.6",
101
+ type: ListHeaderTemplateDirective,
102
+ isStandalone: true,
103
+ selector: "ng-template[monaListHeaderTemplate]",
104
+ ngImport: i0
105
+ });
106
+ }
107
+ };
108
+ i0.ɵɵngDeclareClassMetadata({
109
+ minVersion: "12.0.0",
110
+ version: "22.2.6",
111
+ ngImport: i0,
112
+ type: ListHeaderTemplateDirective,
113
+ decorators: [{
114
+ type: Directive,
115
+ args: [{ selector: "ng-template[monaListHeaderTemplate]" }]
116
+ }]
117
+ });
118
+ var ListItemTemplateDirective = class ListItemTemplateDirective {
119
+ static {
120
+ this.ɵfac = i0.ɵɵngDeclareFactory({
121
+ minVersion: "12.0.0",
122
+ version: "22.2.6",
123
+ ngImport: i0,
124
+ type: ListItemTemplateDirective,
125
+ deps: [],
126
+ target: i0.ɵɵFactoryTarget.Directive
127
+ });
128
+ }
129
+ static {
130
+ this.ɵdir = i0.ɵɵngDeclareDirective({
131
+ minVersion: "14.0.0",
132
+ version: "22.2.6",
133
+ type: ListItemTemplateDirective,
134
+ isStandalone: true,
135
+ selector: "ng-template[monaListItemTemplate]",
136
+ ngImport: i0
137
+ });
138
+ }
139
+ };
140
+ i0.ɵɵngDeclareClassMetadata({
141
+ minVersion: "12.0.0",
142
+ version: "22.2.6",
143
+ ngImport: i0,
144
+ type: ListItemTemplateDirective,
145
+ decorators: [{
146
+ type: Directive,
147
+ args: [{ selector: "ng-template[monaListItemTemplate]" }]
148
+ }]
149
+ });
150
+ var ListItem = class {
151
+ constructor(options) {
152
+ this.header = "";
153
+ this.data = options.data;
154
+ this.uid = options.uid ?? v4();
155
+ this.header = options.header ?? this.header;
156
+ this.isHeader = options.isHeader ?? this.header !== "";
157
+ }
158
+ };
159
+ const cycleThroughMatchedItems = (items, activeItem, predicate, keepActive = false) => {
160
+ const matchedItems = Array.from(items).filter(predicate);
161
+ if (matchedItems.length === 0) return null;
162
+ const currentIndex = activeItem ? matchedItems.indexOf(activeItem) : -1;
163
+ if (keepActive && currentIndex !== -1) return matchedItems[currentIndex];
164
+ return matchedItems[(currentIndex + 1) % matchedItems.length];
98
165
  };
99
-
100
- /**
101
- * Turns a group value into the key items are grouped by. Dates, and other objects whose `valueOf()` is a primitive,
102
- * group by that primitive, so two `Date` objects for the same moment form one group. `null`, `undefined`, `NaN` and
103
- * invalid dates join the empty group (`""`). Other objects group by identity.
104
- */
105
166
  function toGroupKey(value) {
106
- if (value == null) {
107
- return "";
108
- }
109
- if (typeof value === "number") {
110
- return Number.isNaN(value) ? "" : value;
111
- }
112
- if (typeof value !== "object") {
113
- return value;
114
- }
115
- const primitive = value.valueOf();
116
- if (primitive === value || (typeof primitive === "object" && primitive !== null)) {
117
- return value;
118
- }
119
- return typeof primitive === "number" && Number.isNaN(primitive) ? "" : primitive;
167
+ if (value == null) return "";
168
+ if (typeof value === "number") return Number.isNaN(value) ? "" : value;
169
+ if (typeof value !== "object") return value;
170
+ const primitive = value.valueOf();
171
+ if (primitive === value || typeof primitive === "object" && primitive !== null) return value;
172
+ return typeof primitive === "number" && Number.isNaN(primitive) ? "" : primitive;
120
173
  }
121
- /**
122
- * Formats a group value for its header: dates and numbers with the given locale, everything else with `String`.
123
- */
124
174
  function formatGroupHeader(value, formatters) {
125
- if (value == null) {
126
- return "";
127
- }
128
- if (value instanceof Date) {
129
- return Number.isNaN(value.getTime()) ? "" : formatters.date.format(value);
130
- }
131
- if (typeof value === "number") {
132
- return Number.isNaN(value) ? "" : formatters.number.format(value);
133
- }
134
- return String(value);
135
- }
136
-
137
- class ListService {
138
- constructor() {
139
- this.#arrangedItems = computed(() => {
140
- const listItems = this.#listItems();
141
- const filterText = this.filterText();
142
- const groupableOptions = this.groupableOptions();
143
- let enumerable = listItems;
144
- if (filterText) {
145
- enumerable = enumerable.where(item => this.filterItem(item, filterText));
146
- }
147
- if (!groupableOptions.enabled) {
148
- return enumerable.toImmutableSet();
149
- }
150
- if (groupableOptions.orderBy) {
151
- if (groupableOptions.orderByDirection === "desc") {
152
- enumerable = enumerable.orderByDescending(item => this.getOrderKey(item));
153
- }
154
- else {
155
- enumerable = enumerable.orderBy(item => this.getOrderKey(item));
156
- }
157
- }
158
- // Dates group by their time, so equal dates share a group and header order is chronological.
159
- let groupedEnumerable = enumerable.groupBy(item => toGroupKey(this.getGroupField(item)));
160
- if (groupableOptions.headerOrder) {
161
- if (groupableOptions.headerOrder === "desc") {
162
- groupedEnumerable = groupedEnumerable.orderByDescending(g => g.key);
163
- }
164
- else {
165
- groupedEnumerable = groupedEnumerable.orderBy(g => g.key);
166
- }
167
- }
168
- const localeId = this.#i18n.localeId();
169
- const formatters = {
170
- date: new Intl.DateTimeFormat(localeId, { dateStyle: "medium" }),
171
- number: new Intl.NumberFormat(localeId, { useGrouping: false })
172
- };
173
- const previousHeaders = this.#groupHeaders;
174
- const headers = new Map();
175
- const items = groupedEnumerable
176
- .selectMany(g => {
177
- // The header carries the first item's group value (a Date stays a Date for the header template).
178
- const value = this.getGroupField(g.source.first());
179
- const text = groupableOptions.headerText
180
- ? groupableOptions.headerText(value)
181
- : formatGroupHeader(value, formatters);
182
- const previous = previousHeaders.get(g.key);
183
- const header = previous && previous.header === text && previous.data === value
184
- ? previous
185
- : // A header carries its group's value in place of a data item.
186
- new ListItem({
187
- data: value,
188
- header: text,
189
- isHeader: true,
190
- uid: previous?.uid
191
- });
192
- headers.set(g.key, header);
193
- return g.source.prepend(header);
194
- })
195
- .toImmutableSet();
196
- this.#groupHeaders = headers;
197
- return items;
198
- }, /* @ts-ignore */
199
- ...(ngDevMode ? [{ debugName: "#arrangedItems" }] : /* istanbul ignore next */ []));
200
- this.#data = signal(ImmutableList.create(), /* @ts-ignore */
201
- ...(ngDevMode ? [{ debugName: "#data" }] : /* istanbul ignore next */ []));
202
- this.#i18n = inject(MonaI18nService);
203
- /**
204
- * First list item for each selection key, so key lookups are O(1) instead of a scan per key.
205
- */
206
- this.#itemsByKey = computed(() => {
207
- const itemsByKey = new Map();
208
- for (const item of this.#listItems()) {
209
- const key = this.getSelectionKey(item);
210
- if (!itemsByKey.has(key)) {
211
- itemsByKey.set(key, item);
212
- }
213
- }
214
- return itemsByKey;
215
- }, /* @ts-ignore */
216
- ...(ngDevMode ? [{ debugName: "#itemsByKey" }] : /* istanbul ignore next */ []));
217
- this.#itemsByUid = computed(() => {
218
- const itemsByUid = new Map();
219
- for (const item of this.#listItems()) {
220
- itemsByUid.set(item.uid, item);
221
- }
222
- return itemsByUid;
223
- }, /* @ts-ignore */
224
- ...(ngDevMode ? [{ debugName: "#itemsByUid" }] : /* istanbul ignore next */ []));
225
- /**
226
- * Wraps the data in list items while keeping item identity across data changes:
227
- * an item whose selection key existed before keeps its `uid`, and keeps its instance when the data
228
- * object is also unchanged. Highlight, `aria-activedescendant` ids and rendered rows therefore survive
229
- * a refresh (for example server-side filtering) instead of pointing at items that no longer exist.
230
- */
231
- this.#listItems = linkedSignal({ ...(ngDevMode ? { debugName: "#listItems" } : /* istanbul ignore next */ {}), source: () => ({ data: this.#data(), valueField: this.valueField() }),
232
- computation: ({ data }, previous) => {
233
- const previousByKey = new Map();
234
- for (const item of previous?.value ?? []) {
235
- const key = this.getSelectionKey(item);
236
- if (!previousByKey.has(key)) {
237
- previousByKey.set(key, item);
238
- }
239
- }
240
- const usedUids = new Set();
241
- const items = [];
242
- for (const dataItem of data) {
243
- const previousItem = previousByKey.get(this.getDataItemValue(dataItem));
244
- let item;
245
- if (previousItem && !usedUids.has(previousItem.uid)) {
246
- item =
247
- previousItem.data === dataItem
248
- ? previousItem
249
- : new ListItem({ data: dataItem, uid: previousItem.uid });
250
- }
251
- else {
252
- item = new ListItem({ data: dataItem });
253
- }
254
- usedUids.add(item.uid);
255
- items.push(item);
256
- }
257
- return toImmutableSet(items);
258
- } });
259
- /**
260
- * Group header items from the last grouping pass, reused so header rows keep their uid between recomputations.
261
- */
262
- this.#groupHeaders = new Map();
263
- this.disabledBy = signal("", /* @ts-ignore */
264
- ...(ngDevMode ? [{ debugName: "disabledBy" }] : /* istanbul ignore next */ []));
265
- this.filterChange$ = new Subject();
266
- this.filterInputVisible = signal(true, /* @ts-ignore */
267
- ...(ngDevMode ? [{ debugName: "filterInputVisible" }] : /* istanbul ignore next */ []));
268
- this.filterPlaceholder = signal("", /* @ts-ignore */
269
- ...(ngDevMode ? [{ debugName: "filterPlaceholder" }] : /* istanbul ignore next */ []));
270
- this.filterText = signal("", /* @ts-ignore */
271
- ...(ngDevMode ? [{ debugName: "filterText" }] : /* istanbul ignore next */ []));
272
- this.filterableOptions = signal({
273
- enabled: false,
274
- caseSensitive: false,
275
- debounce: 0,
276
- operator: "contains"
277
- }, /* @ts-ignore */
278
- ...(ngDevMode ? [{ debugName: "filterableOptions" }] : /* istanbul ignore next */ []));
279
- this.focus$ = new Subject();
280
- /**
281
- * The option that holds the list's Tab stop: the highlighted one, else the last selected one, else the first
282
- * enabled one. Only shown items count, so a selection on another page doesn't take the Tab stop away.
283
- */
284
- this.focusableItem = computed(() => {
285
- const viewItems = this.viewItems();
286
- const highlighted = this.highlightedItem();
287
- if (highlighted && viewItems.contains(highlighted)) {
288
- return highlighted;
289
- }
290
- const selected = this.selectedListItems().lastOrDefault(item => viewItems.contains(item));
291
- if (selected) {
292
- return selected;
293
- }
294
- return viewItems.firstOrDefault(i => !i.isHeader && !this.isDisabled(i));
295
- }, /* @ts-ignore */
296
- ...(ngDevMode ? [{ debugName: "focusableItem" }] : /* istanbul ignore next */ []));
297
- this.groupBy = signal(null, /* @ts-ignore */
298
- ...(ngDevMode ? [{ debugName: "groupBy" }] : /* istanbul ignore next */ []));
299
- /**
300
- * Maps each option uid to the uid of the group header it is listed under.
301
- */
302
- this.groupHeaderUids = computed(() => {
303
- const headerUids = new Map();
304
- let headerUid = null;
305
- for (const item of this.#arrangedItems()) {
306
- if (item.isHeader) {
307
- headerUid = item.uid;
308
- }
309
- else if (headerUid != null) {
310
- headerUids.set(item.uid, headerUid);
311
- }
312
- }
313
- return headerUids;
314
- }, /* @ts-ignore */
315
- ...(ngDevMode ? [{ debugName: "groupHeaderUids" }] : /* istanbul ignore next */ []));
316
- this.groupableOptions = signal({
317
- enabled: false,
318
- headerOrder: "asc"
319
- }, /* @ts-ignore */
320
- ...(ngDevMode ? [{ debugName: "groupableOptions" }] : /* istanbul ignore next */ []));
321
- /**
322
- * The highlighted (active) item. When the data changes, it is re-resolved to the item with the same `uid`,
323
- * or cleared when that item is gone.
324
- */
325
- this.highlightedItem = linkedSignal({ ...(ngDevMode ? { debugName: "highlightedItem" } : /* istanbul ignore next */ {}), source: this.#listItems,
326
- computation: (_, previous) => {
327
- const highlighted = previous?.value;
328
- if (!highlighted || highlighted.isHeader) {
329
- return null;
330
- }
331
- return this.#itemsByUid().get(highlighted.uid) ?? null;
332
- } });
333
- this.itemFocusOut$ = new Subject();
334
- /**
335
- * Position of each option among all filtered options (not only the current page), for `aria-posinset`
336
- * and `aria-setsize`.
337
- */
338
- this.itemPositions = computed(() => {
339
- const options = this.#arrangedItems()
340
- .where(i => !i.isHeader)
341
- .toArray();
342
- const positions = new Map();
343
- options.forEach((item, index) => {
344
- positions.set(item.uid, { position: index + 1, total: options.length });
345
- });
346
- return positions;
347
- }, /* @ts-ignore */
348
- ...(ngDevMode ? [{ debugName: "itemPositions" }] : /* istanbul ignore next */ []));
349
- this.navigableOptions = signal({
350
- enabled: false,
351
- mode: "select",
352
- wrap: false
353
- }, /* @ts-ignore */
354
- ...(ngDevMode ? [{ debugName: "navigableOptions" }] : /* istanbul ignore next */ []));
355
- this.navigatedItem$ = new Subject();
356
- this.pageState = signal({ page: 1, skip: 0, take: 10 }, /* @ts-ignore */
357
- ...(ngDevMode ? [{ debugName: "pageState" }] : /* istanbul ignore next */ []));
358
- this.pageableOptions = signal({
359
- enabled: false,
360
- firstLast: false,
361
- showInfo: true,
362
- pageSize: 10,
363
- pageSizeValues: true,
364
- previousNext: false,
365
- type: "numeric",
366
- visiblePages: 5
367
- }, /* @ts-ignore */
368
- ...(ngDevMode ? [{ debugName: "pageableOptions" }] : /* istanbul ignore next */ []));
369
- /**
370
- * `"listbox"` for options to choose from; `"list"` for items that are only shown, as `listitem`s without
371
- * selection state.
372
- */
373
- this.role = signal("listbox", /* @ts-ignore */
374
- ...(ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []));
375
- this.scrollToItem$ = new ReplaySubject(1);
376
- this.selectableOptions = signal({
377
- checkboxes: false,
378
- enabled: false,
379
- mode: "single",
380
- toggleable: false
381
- }, /* @ts-ignore */
382
- ...(ngDevMode ? [{ debugName: "selectableOptions" }] : /* istanbul ignore next */ []));
383
- this.selectedKeys = signal(ImmutableSet.create(), /* @ts-ignore */
384
- ...(ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []));
385
- this.selectedKeysChange$ = new Subject();
386
- this.selectedListItems = computed(() => {
387
- const selectedKeys = this.selectedKeys();
388
- const itemsByKey = this.#itemsByKey();
389
- return selectedKeys
390
- .select(key => itemsByKey.get(key))
391
- .where((i) => i != null)
392
- .toImmutableSet();
393
- }, /* @ts-ignore */
394
- ...(ngDevMode ? [{ debugName: "selectedListItems" }] : /* istanbul ignore next */ []));
395
- this.selectionChange$ = new Subject();
396
- this.textField = signal("", /* @ts-ignore */
397
- ...(ngDevMode ? [{ debugName: "textField" }] : /* istanbul ignore next */ []));
398
- this.valueField = signal("", /* @ts-ignore */
399
- ...(ngDevMode ? [{ debugName: "valueField" }] : /* istanbul ignore next */ []));
400
- /**
401
- * Visible items in display order: filtered, ordered and grouped (with header rows), but not paged.
402
- */
403
- this.viewItems = computed(() => {
404
- const arrangedItems = this.#arrangedItems();
405
- const pageableOptions = this.pageableOptions();
406
- if (this.virtualScrollOptions().enabled || !pageableOptions.enabled) {
407
- return arrangedItems;
408
- }
409
- const pageState = this.pageState();
410
- return toImmutableSet(this.skipTakeWithGroups(arrangedItems.toArray(), pageState.skip, pageState.take));
411
- }, /* @ts-ignore */
412
- ...(ngDevMode ? [{ debugName: "viewItems" }] : /* istanbul ignore next */ []));
413
- this.virtualScrollOptions = signal({
414
- enabled: false,
415
- height: 28
416
- }, /* @ts-ignore */
417
- ...(ngDevMode ? [{ debugName: "virtualScrollOptions" }] : /* istanbul ignore next */ []));
418
- }
419
- #arrangedItems;
420
- #data;
421
- #i18n;
422
- /**
423
- * First list item for each selection key, so key lookups are O(1) instead of a scan per key.
424
- */
425
- #itemsByKey;
426
- #itemsByUid;
427
- /**
428
- * Wraps the data in list items while keeping item identity across data changes:
429
- * an item whose selection key existed before keeps its `uid`, and keeps its instance when the data
430
- * object is also unchanged. Highlight, `aria-activedescendant` ids and rendered rows therefore survive
431
- * a refresh (for example server-side filtering) instead of pointing at items that no longer exist.
432
- */
433
- #listItems;
434
- /**
435
- * Group header items from the last grouping pass, reused so header rows keep their uid between recomputations.
436
- */
437
- #groupHeaders;
438
- clearFilter() {
439
- this.filterText.set("");
440
- }
441
- clearHighlightedItem() {
442
- this.highlightedItem.set(null);
443
- }
444
- clearSelections() {
445
- this.selectedKeys.update(set => set.clear());
446
- this.highlightedItem.set(null);
447
- }
448
- /**
449
- * Finds the next item whose text starts with the typeahead buffer, starting after the active item; once the
450
- * buffer holds more than one character, an active item that still matches stays.
451
- * Group headers and disabled items are never matched.
452
- */
453
- cycleThroughMatchedItems(buffer) {
454
- const activeItem = this.highlightedItem() || this.selectedListItems().lastOrDefault();
455
- const prefix = buffer.toLowerCase();
456
- return cycleThroughMatchedItems(this.viewItems(), activeItem ?? null, item => {
457
- if (item.isHeader || this.isDisabled(item)) {
458
- return false;
459
- }
460
- return this.getItemText(item).toLowerCase().startsWith(prefix);
461
- }, prefix.length > 1);
462
- }
463
- deselectItems(item) {
464
- const keys = from(item)
465
- .select(i => this.getSelectionKey(i))
466
- .toImmutableSet();
467
- this.selectedKeys.update(set => set.removeAll(keys));
468
- }
469
- /**
470
- * Resolves the selection value of a data item through `valueField`.
471
- *
472
- * When no `valueField` is configured, the data item itself is the value.
473
- * When `valueField` is a string, the item property is read with a nullish fallback to the item.
474
- * When `valueField` is a function, its result is used as-is.
475
- *
476
- * Falsy results such as `0`, `false`, and `""` are valid values and do not fall back to the item.
477
- */
478
- getDataItemValue(dataItem) {
479
- const valueField = this.valueField();
480
- if (!valueField) {
481
- return dataItem;
482
- }
483
- if (typeof valueField === "string") {
484
- return dataItem?.[valueField] ?? dataItem;
485
- }
486
- return valueField(dataItem);
487
- }
488
- getFilterDebounceDuration() {
489
- const filterableOptions = this.filterableOptions();
490
- return filterableOptions.enabled ? filterableOptions.debounce : 0;
491
- }
492
- getGroupField(item) {
493
- const groupSelector = this.groupBy();
494
- if (groupSelector == null) {
495
- return "";
496
- }
497
- if (typeof groupSelector === "string") {
498
- return item.data?.[groupSelector] ?? "";
499
- }
500
- return groupSelector(item.data);
501
- }
502
- /**
503
- * Returns the uid of the group header an item is rendered under, or `null` when the list is not grouped.
504
- */
505
- getGroupHeaderUid(item) {
506
- return this.groupHeaderUids().get(item.uid) ?? null;
507
- }
508
- getItemPosition(item) {
509
- return this.itemPositions().get(item.uid) ?? null;
510
- }
511
- /**
512
- * Resolves the display text of an item through `textField`.
513
- * Non-string field values (numbers, dates, …) are converted with `String()`, and nullish values become `""`.
514
- */
515
- getItemText(item) {
516
- const textField = this.textField();
517
- let text;
518
- if (!textField) {
519
- text = item.data;
520
- }
521
- else if (typeof textField === "string") {
522
- text = item.data?.[textField];
523
- }
524
- else {
525
- text = textField(item.data);
526
- }
527
- return text == null ? "" : String(text);
528
- }
529
- /**
530
- * Finds the item that typed text should resolve to: an exact text match first (respecting `caseSensitive`),
531
- * otherwise the first item accepted by the filter operator. Group headers and disabled items are skipped.
532
- */
533
- getMatchingFilteredItem(text) {
534
- const filterableOptions = this.filterableOptions();
535
- const caseSensitive = filterableOptions.enabled ? filterableOptions.caseSensitive : false;
536
- const candidates = this.viewItems().where(i => !i.isHeader && !this.isDisabled(i));
537
- const fullMatchingItem = candidates.firstOrDefault(i => {
538
- const itemText = this.getItemText(i);
539
- return caseSensitive ? itemText === text : itemText.toLowerCase() === text.toLowerCase();
540
- });
541
- if (fullMatchingItem) {
542
- return fullMatchingItem;
543
- }
544
- return candidates.firstOrDefault(i => this.filterItem(i, text));
545
- }
546
- /**
547
- * Whether a data item is disabled by `disabledBy`, whether or not it is in the list.
548
- */
549
- isDataItemDisabled(dataItem) {
550
- const disabledBy = this.disabledBy();
551
- if (typeof disabledBy === "string") {
552
- return disabledBy !== "" && Boolean(dataItem?.[disabledBy]);
553
- }
554
- return disabledBy(dataItem);
555
- }
556
- isDisabled(item) {
557
- return !item.isHeader && this.isDataItemDisabled(item.data);
558
- }
559
- isFilteringEnabled() {
560
- const filterableOptions = this.filterableOptions();
561
- return filterableOptions.enabled;
562
- }
563
- isHighlighted(item) {
564
- const highlightedItem = this.highlightedItem();
565
- return highlightedItem === item;
566
- }
567
- isSelected(item) {
568
- const options = this.selectableOptions();
569
- if (!options.enabled) {
570
- return false;
571
- }
572
- const selectedKeys = this.selectedKeys();
573
- const key = this.getSelectionKey(item);
574
- return selectedKeys.contains(key);
575
- }
576
- navigate(direction, mode, focus) {
577
- const navigableOptions = this.navigableOptions();
578
- if (!navigableOptions.enabled) {
579
- return null;
580
- }
581
- const viewItems = this.viewItems()
582
- .where(i => !i.isHeader && !this.isDisabled(i))
583
- .toImmutableSet();
584
- if (viewItems.isEmpty()) {
585
- return null;
586
- }
587
- const selectableOptions = this.selectableOptions();
588
- if (mode === "select" && (!selectableOptions.enabled || selectableOptions.mode === "multiple")) {
589
- mode = "highlight";
590
- }
591
- let item;
592
- if (selectableOptions.mode === "single") {
593
- item = this.navigateForSingleSelection(viewItems, direction, mode);
594
- }
595
- else {
596
- item = this.navigateForMultipleSelection(viewItems, direction);
597
- }
598
- if (item) {
599
- this.scrollToItem$.next({ item, focus });
600
- this.navigatedItem$.next(item);
601
- }
602
- return item;
603
- }
604
- notifySelectionChange(item) {
605
- this.selectionChange$.next(item);
606
- }
607
- scrollToItem(item, focus) {
608
- this.scrollToItem$.next({ item, focus });
609
- }
610
- /**
611
- * Selects every enabled item currently in view, keeping existing selections. Only applies in multiple mode.
612
- * @returns whether the selection changed.
613
- */
614
- selectAllItems() {
615
- const options = this.selectableOptions();
616
- if (!options.enabled || options.mode !== "multiple") {
617
- return false;
618
- }
619
- const keys = this.viewItems()
620
- .where(i => !i.isHeader && !this.isDisabled(i))
621
- .select(i => this.getSelectionKey(i))
622
- .toArray();
623
- const selectedKeys = this.selectedKeys();
624
- if (keys.every(key => selectedKeys.contains(key))) {
625
- return false;
626
- }
627
- this.selectedKeys.update(set => set.addAll(keys));
628
- return true;
629
- }
630
- selectItem(item, scroll = false, focus = false) {
631
- const key = this.getSelectionKey(item);
632
- const options = this.selectableOptions();
633
- if (options.mode === "single") {
634
- if (options.toggleable) {
635
- this.selectedKeys.update(set => {
636
- if (set.contains(key)) {
637
- if (set.size() > 1) {
638
- return set.where(k => k === key).toImmutableSet();
639
- }
640
- return set.remove(key);
641
- }
642
- return set.clear().add(key);
643
- });
644
- }
645
- else {
646
- this.selectedKeys.update(set => set.clear().add(key));
647
- }
648
- }
649
- else {
650
- this.selectedKeys.update(set => {
651
- if (set.contains(key)) {
652
- return set.remove(key);
653
- }
654
- return set.add(key);
655
- });
656
- }
657
- if (scroll) {
658
- this.scrollToItem(item, focus);
659
- }
660
- this.notifySelectionChange(item);
661
- }
662
- setData(data) {
663
- this.#data.update(list => list.clear().addAll(data));
664
- }
665
- setDisabledBy(disabledBy) {
666
- this.disabledBy.set(disabledBy);
667
- }
668
- setFilter(filter) {
669
- this.filterText.set(filter);
670
- }
671
- setFilterPlaceholder(placeholder) {
672
- this.filterPlaceholder.set(placeholder);
673
- }
674
- setFilterableOptions(options) {
675
- this.filterableOptions.update(o => ({ ...o, ...options }));
676
- }
677
- setGroupBy(groupSelector) {
678
- this.groupBy.set(groupSelector);
679
- }
680
- setGroupableOptions(options) {
681
- this.groupableOptions.update(o => ({ ...o, ...options }));
682
- }
683
- setNavigableOptions(options) {
684
- this.navigableOptions.update(o => ({ ...o, ...options }));
685
- }
686
- setPageableOptions(settings) {
687
- this.pageableOptions.set(settings);
688
- }
689
- setSelectableOptions(options) {
690
- this.selectableOptions.update(o => ({ ...o, ...options }));
691
- }
692
- setSelectedDataItems(dataItems) {
693
- const selectedKeys = from(dataItems)
694
- .select(item => this.getDataItemValue(item))
695
- .toImmutableSet();
696
- this.selectedKeys.update(set => set.clear().addAll(selectedKeys));
697
- }
698
- setSelectedKeys(selectedKeys) {
699
- this.selectedKeys.update(set => set.clear().addAll(selectedKeys));
700
- }
701
- setTextField(textField) {
702
- this.textField.set(textField);
703
- }
704
- setValueField(valueField) {
705
- this.valueField.set(valueField);
706
- }
707
- setVirtualScrollOptions(options) {
708
- this.virtualScrollOptions.update(o => ({ ...o, ...options }));
709
- }
710
- filterItem(item, filterText) {
711
- if (filterText === "") {
712
- return true;
713
- }
714
- const options = this.filterableOptions();
715
- const itemText = this.getItemText(item);
716
- const text = options.caseSensitive ? itemText : itemText.toLowerCase();
717
- const filter = options.caseSensitive ? filterText : filterText.toLowerCase();
718
- const operator = options.enabled ? options.operator : "startsWith";
719
- if (typeof operator === "function") {
720
- return operator(text, filter);
721
- }
722
- switch (operator) {
723
- case "contains":
724
- return text.includes(filter);
725
- case "startsWith":
726
- return text.startsWith(filter);
727
- case "endsWith":
728
- return text.endsWith(filter);
729
- default:
730
- return false;
731
- }
732
- }
733
- /**
734
- * Returns the item when it is one of the navigable items, otherwise `null`.
735
- * An anchor that was filtered out or removed must not be navigated from.
736
- */
737
- getItemInView(viewItems, item) {
738
- return item != null && viewItems.contains(item) ? item : null;
739
- }
740
- getOrderKey(item) {
741
- const orderBy = this.groupableOptions().orderBy;
742
- if (orderBy) {
743
- if (typeof orderBy === "string") {
744
- return item.data[orderBy];
745
- }
746
- else {
747
- return orderBy(item.data);
748
- }
749
- }
750
- return null;
751
- }
752
- getPreviousItemForNavigation(viewItems, navigationItem) {
753
- let prevItem = viewItems.takeWhile(i => i !== navigationItem).lastOrDefault(i => !this.isDisabled(i));
754
- if (prevItem == null) {
755
- const lastItem = viewItems.lastOrDefault(i => !this.isDisabled(i));
756
- if (this.navigableOptions().wrap) {
757
- prevItem = lastItem;
758
- }
759
- else if (!this.navigableOptions().wrap) {
760
- prevItem = navigationItem;
761
- }
762
- }
763
- return prevItem;
764
- }
765
- getSelectionKey(item) {
766
- return this.getDataItemValue(item.data);
767
- }
768
- navigateFirstForSingleSelection(viewItems, mode) {
769
- const firstItem = viewItems.first();
770
- if (mode === "select") {
771
- if (!this.isSelected(firstItem)) {
772
- this.selectItem(firstItem);
773
- }
774
- this.highlightedItem.set(null);
775
- }
776
- else {
777
- this.highlightedItem.set(firstItem);
778
- }
779
- return firstItem;
780
- }
781
- navigateForMultipleSelection(viewItems, direction) {
782
- const selectedKeys = this.selectedKeys();
783
- const firstItem = viewItems.first();
784
- if (direction === "first" || direction === "last") {
785
- const edgeItem = direction === "first" ? firstItem : viewItems.last();
786
- this.highlightedItem.set(edgeItem);
787
- return edgeItem;
788
- }
789
- const lastHighlightedItem = this.getItemInView(viewItems, this.highlightedItem());
790
- if (selectedKeys.isEmpty() && !lastHighlightedItem) {
791
- this.highlightedItem.set(firstItem);
792
- return firstItem;
793
- }
794
- const firstSelectedItem = viewItems.firstOrDefault(i => selectedKeys.contains(this.getSelectionKey(i)));
795
- const lastSelectedItem = viewItems.lastOrDefault(i => selectedKeys.contains(this.getSelectionKey(i)));
796
- if (direction === "next") {
797
- const navigationItem = lastHighlightedItem ?? lastSelectedItem ?? firstItem;
798
- let nextItem = viewItems
799
- .skipWhile(i => i !== navigationItem)
800
- .skip(1)
801
- .firstOrDefault(i => !this.isDisabled(i));
802
- if (nextItem == null) {
803
- const firstItem = viewItems.firstOrDefault(i => !this.isDisabled(i));
804
- if (this.navigableOptions().wrap) {
805
- nextItem = firstItem;
806
- }
807
- else if (!this.navigableOptions().wrap) {
808
- nextItem = navigationItem;
809
- }
810
- }
811
- if (nextItem) {
812
- this.highlightedItem.set(nextItem);
813
- return nextItem;
814
- }
815
- }
816
- else {
817
- const navigationItem = lastHighlightedItem ?? firstSelectedItem ?? firstItem;
818
- const prevItem = this.getPreviousItemForNavigation(viewItems, navigationItem);
819
- if (prevItem) {
820
- this.highlightedItem.set(prevItem);
821
- return prevItem;
822
- }
823
- }
824
- return null;
825
- }
826
- navigateForSingleSelection(viewItems, direction, mode) {
827
- const selectedKeys = this.selectedKeys();
828
- const firstItem = viewItems.first();
829
- const lastHighlightedItem = this.getItemInView(viewItems, this.highlightedItem());
830
- if (selectedKeys.isEmpty() && !lastHighlightedItem) {
831
- if (direction === "last") {
832
- return this.navigateLastForSingleSelection(viewItems, mode);
833
- }
834
- if (mode === "select") {
835
- this.selectItem(firstItem);
836
- }
837
- else {
838
- this.highlightedItem.set(firstItem);
839
- }
840
- return firstItem;
841
- }
842
- else if (selectedKeys.isEmpty() && lastHighlightedItem) {
843
- if (mode === "select") {
844
- this.selectItem(lastHighlightedItem);
845
- return lastHighlightedItem;
846
- }
847
- }
848
- const selectedItem = viewItems.lastOrDefault(i => selectedKeys.contains(this.getSelectionKey(i)));
849
- const navigationItem = lastHighlightedItem ?? selectedItem ?? firstItem;
850
- if (direction === "next") {
851
- return this.navigateNextForSingleSelection(viewItems, navigationItem, mode, firstItem);
852
- }
853
- else if (direction === "previous") {
854
- return this.navigatePreviousForSingleSelection(viewItems, navigationItem, mode);
855
- }
856
- else if (direction === "first") {
857
- return this.navigateFirstForSingleSelection(viewItems, mode);
858
- }
859
- else if (direction === "last") {
860
- return this.navigateLastForSingleSelection(viewItems, mode);
861
- }
862
- return null;
863
- }
864
- navigateLastForSingleSelection(viewItems, mode) {
865
- const lastItem = viewItems.last();
866
- if (mode === "select") {
867
- if (!this.isSelected(lastItem)) {
868
- this.selectItem(lastItem);
869
- }
870
- this.highlightedItem.set(null);
871
- }
872
- else {
873
- this.highlightedItem.set(lastItem);
874
- }
875
- return lastItem;
876
- }
877
- navigateNextForSingleSelection(viewItems, navigationItem, mode, firstItem) {
878
- let nextItem = viewItems
879
- .skipWhile(i => i !== navigationItem)
880
- .skip(1)
881
- .firstOrDefault(i => !this.isDisabled(i));
882
- if (nextItem == null) {
883
- if (this.navigableOptions().wrap) {
884
- nextItem = firstItem;
885
- }
886
- else if (!this.navigableOptions().wrap) {
887
- nextItem = navigationItem;
888
- }
889
- }
890
- if (nextItem) {
891
- if (mode === "select") {
892
- const previouslySelectedItem = this.selectedListItems().firstOrDefault();
893
- if (previouslySelectedItem === nextItem) {
894
- return null;
895
- }
896
- this.selectItem(nextItem);
897
- this.highlightedItem.set(null);
898
- }
899
- else {
900
- this.highlightedItem.set(nextItem);
901
- }
902
- return nextItem;
903
- }
904
- return null;
905
- }
906
- navigatePreviousForSingleSelection(viewItems, navigationItem, mode) {
907
- const prevItem = this.getPreviousItemForNavigation(viewItems, navigationItem);
908
- if (!prevItem) {
909
- return null;
910
- }
911
- if (mode === "select") {
912
- const previouslySelectedItem = this.selectedListItems().firstOrDefault();
913
- if (previouslySelectedItem === prevItem) {
914
- return null;
915
- }
916
- this.selectItem(prevItem);
917
- this.highlightedItem.set(null);
918
- }
919
- else {
920
- this.highlightedItem.set(prevItem);
921
- }
922
- return prevItem;
923
- }
924
- skipTakeWithGroups(items, skip, take) {
925
- let skipped = 0;
926
- let taken = 0;
927
- let capturing = false;
928
- const result = [];
929
- for (const item of items) {
930
- if (item.isHeader) {
931
- // Include group headers when we're capturing
932
- if (capturing) {
933
- result.push(item);
934
- }
935
- }
936
- else {
937
- // Handle regular items
938
- if (!capturing && skipped < skip) {
939
- skipped++;
940
- continue;
941
- }
942
- if (taken < take) {
943
- // Check if we need to include the group header for this item
944
- if (!capturing && result.length === 0) {
945
- // Find the group header for this item
946
- const itemIndex = items.indexOf(item);
947
- for (let i = itemIndex - 1; i >= 0; i--) {
948
- if (items[i].isHeader) {
949
- result.push(items[i]);
950
- break;
951
- }
952
- }
953
- }
954
- capturing = true;
955
- result.push(item);
956
- taken++;
957
- }
958
- else {
959
- break;
960
- }
961
- }
962
- }
963
- // Remove trailing group headers if they are at the end
964
- let lastIndex = result.length - 1;
965
- while (lastIndex >= 0 && result[lastIndex].isHeader) {
966
- result.pop();
967
- lastIndex--;
968
- }
969
- return result;
970
- }
971
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
972
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListService }); }
175
+ if (value == null) return "";
176
+ if (value instanceof Date) return Number.isNaN(value.getTime()) ? "" : formatters.date.format(value);
177
+ if (typeof value === "number") return Number.isNaN(value) ? "" : formatters.number.format(value);
178
+ return String(value);
973
179
  }
974
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListService, decorators: [{
975
- type: Injectable
976
- }] });
977
-
180
+ var ListService = class ListService {
181
+ constructor() {
182
+ this.#arrangedItems = computed(() => {
183
+ const listItems = this.#listItems();
184
+ const filterText = this.filterText();
185
+ const groupableOptions = this.groupableOptions();
186
+ let enumerable = listItems;
187
+ if (filterText) enumerable = enumerable.where((item) => this.filterItem(item, filterText));
188
+ if (!groupableOptions.enabled) return enumerable.toImmutableSet();
189
+ if (groupableOptions.orderBy) {
190
+ if (groupableOptions.orderByDirection === "desc") enumerable = enumerable.orderByDescending((item) => this.getOrderKey(item));
191
+ else enumerable = enumerable.orderBy((item) => this.getOrderKey(item));
192
+ }
193
+ let groupedEnumerable = enumerable.groupBy((item) => toGroupKey(this.getGroupField(item)));
194
+ if (groupableOptions.headerOrder) {
195
+ if (groupableOptions.headerOrder === "desc") groupedEnumerable = groupedEnumerable.orderByDescending((g) => g.key);
196
+ else groupedEnumerable = groupedEnumerable.orderBy((g) => g.key);
197
+ }
198
+ const localeId = this.#i18n.localeId();
199
+ const formatters = {
200
+ date: new Intl.DateTimeFormat(localeId, { dateStyle: "medium" }),
201
+ number: new Intl.NumberFormat(localeId, { useGrouping: false })
202
+ };
203
+ const previousHeaders = this.#groupHeaders;
204
+ const headers = /* @__PURE__ */ new Map();
205
+ const items = groupedEnumerable.selectMany((g) => {
206
+ const value = this.getGroupField(g.source.first());
207
+ const text = groupableOptions.headerText ? groupableOptions.headerText(value) : formatGroupHeader(value, formatters);
208
+ const previous = previousHeaders.get(g.key);
209
+ const header = previous && previous.header === text && previous.data === value ? previous : new ListItem({
210
+ data: value,
211
+ header: text,
212
+ isHeader: true,
213
+ uid: previous?.uid
214
+ });
215
+ headers.set(g.key, header);
216
+ return g.source.prepend(header);
217
+ }).toImmutableSet();
218
+ this.#groupHeaders = headers;
219
+ return items;
220
+ }, ...ngDevMode ? [{ debugName: "#arrangedItems" }] : /* istanbul ignore next */ []);
221
+ this.#data = signal(ImmutableList.create(), ...ngDevMode ? [{ debugName: "#data" }] : /* istanbul ignore next */ []);
222
+ this.#i18n = inject(MonaI18nService);
223
+ this.#itemsByKey = computed(() => {
224
+ const itemsByKey = /* @__PURE__ */ new Map();
225
+ for (const item of this.#listItems()) {
226
+ const key = this.getSelectionKey(item);
227
+ if (!itemsByKey.has(key)) itemsByKey.set(key, item);
228
+ }
229
+ return itemsByKey;
230
+ }, ...ngDevMode ? [{ debugName: "#itemsByKey" }] : /* istanbul ignore next */ []);
231
+ this.#itemsByUid = computed(() => {
232
+ const itemsByUid = /* @__PURE__ */ new Map();
233
+ for (const item of this.#listItems()) itemsByUid.set(item.uid, item);
234
+ return itemsByUid;
235
+ }, ...ngDevMode ? [{ debugName: "#itemsByUid" }] : /* istanbul ignore next */ []);
236
+ this.#listItems = linkedSignal({
237
+ ...ngDevMode ? { debugName: "#listItems" } : /* istanbul ignore next */ {},
238
+ source: () => ({
239
+ data: this.#data(),
240
+ valueField: this.valueField()
241
+ }),
242
+ computation: ({ data }, previous) => {
243
+ const previousByKey = /* @__PURE__ */ new Map();
244
+ for (const item of previous?.value ?? []) {
245
+ const key = this.getSelectionKey(item);
246
+ if (!previousByKey.has(key)) previousByKey.set(key, item);
247
+ }
248
+ const usedUids = /* @__PURE__ */ new Set();
249
+ const items = [];
250
+ for (const dataItem of data) {
251
+ const previousItem = previousByKey.get(this.getDataItemValue(dataItem));
252
+ let item;
253
+ if (previousItem && !usedUids.has(previousItem.uid)) item = previousItem.data === dataItem ? previousItem : new ListItem({
254
+ data: dataItem,
255
+ uid: previousItem.uid
256
+ });
257
+ else item = new ListItem({ data: dataItem });
258
+ usedUids.add(item.uid);
259
+ items.push(item);
260
+ }
261
+ return toImmutableSet(items);
262
+ }
263
+ });
264
+ this.#groupHeaders = /* @__PURE__ */ new Map();
265
+ this.disabledBy = signal("", ...ngDevMode ? [{ debugName: "disabledBy" }] : /* istanbul ignore next */ []);
266
+ this.filterChange$ = new Subject();
267
+ this.filterInputVisible = signal(true, ...ngDevMode ? [{ debugName: "filterInputVisible" }] : /* istanbul ignore next */ []);
268
+ this.filterPlaceholder = signal("", ...ngDevMode ? [{ debugName: "filterPlaceholder" }] : /* istanbul ignore next */ []);
269
+ this.filterText = signal("", ...ngDevMode ? [{ debugName: "filterText" }] : /* istanbul ignore next */ []);
270
+ this.filterableOptions = signal({
271
+ enabled: false,
272
+ caseSensitive: false,
273
+ debounce: 0,
274
+ operator: "contains"
275
+ }, ...ngDevMode ? [{ debugName: "filterableOptions" }] : /* istanbul ignore next */ []);
276
+ this.focus$ = new Subject();
277
+ this.focusableItem = computed(() => {
278
+ const viewItems = this.viewItems();
279
+ const highlighted = this.highlightedItem();
280
+ if (highlighted && viewItems.contains(highlighted)) return highlighted;
281
+ const selected = this.selectedListItems().lastOrDefault((item) => viewItems.contains(item));
282
+ if (selected) return selected;
283
+ return viewItems.firstOrDefault((i) => !i.isHeader && !this.isDisabled(i));
284
+ }, ...ngDevMode ? [{ debugName: "focusableItem" }] : /* istanbul ignore next */ []);
285
+ this.groupBy = signal(null, ...ngDevMode ? [{ debugName: "groupBy" }] : /* istanbul ignore next */ []);
286
+ this.groupHeaderUids = computed(() => {
287
+ const headerUids = /* @__PURE__ */ new Map();
288
+ let headerUid = null;
289
+ for (const item of this.#arrangedItems()) if (item.isHeader) headerUid = item.uid;
290
+ else if (headerUid != null) headerUids.set(item.uid, headerUid);
291
+ return headerUids;
292
+ }, ...ngDevMode ? [{ debugName: "groupHeaderUids" }] : /* istanbul ignore next */ []);
293
+ this.groupableOptions = signal({
294
+ enabled: false,
295
+ headerOrder: "asc"
296
+ }, ...ngDevMode ? [{ debugName: "groupableOptions" }] : /* istanbul ignore next */ []);
297
+ this.highlightedItem = linkedSignal({
298
+ ...ngDevMode ? { debugName: "highlightedItem" } : /* istanbul ignore next */ {},
299
+ source: this.#listItems,
300
+ computation: (_, previous) => {
301
+ const highlighted = previous?.value;
302
+ if (!highlighted || highlighted.isHeader) return null;
303
+ return this.#itemsByUid().get(highlighted.uid) ?? null;
304
+ }
305
+ });
306
+ this.itemFocusOut$ = new Subject();
307
+ this.itemPositions = computed(() => {
308
+ const options = this.#arrangedItems().where((i) => !i.isHeader).toArray();
309
+ const positions = /* @__PURE__ */ new Map();
310
+ options.forEach((item, index) => {
311
+ positions.set(item.uid, {
312
+ position: index + 1,
313
+ total: options.length
314
+ });
315
+ });
316
+ return positions;
317
+ }, ...ngDevMode ? [{ debugName: "itemPositions" }] : /* istanbul ignore next */ []);
318
+ this.navigableOptions = signal({
319
+ enabled: false,
320
+ mode: "select",
321
+ wrap: false
322
+ }, ...ngDevMode ? [{ debugName: "navigableOptions" }] : /* istanbul ignore next */ []);
323
+ this.navigatedItem$ = new Subject();
324
+ this.pageState = signal({
325
+ page: 1,
326
+ skip: 0,
327
+ take: 10
328
+ }, ...ngDevMode ? [{ debugName: "pageState" }] : /* istanbul ignore next */ []);
329
+ this.pageableOptions = signal({
330
+ enabled: false,
331
+ firstLast: false,
332
+ showInfo: true,
333
+ pageSize: 10,
334
+ pageSizeValues: true,
335
+ previousNext: false,
336
+ type: "numeric",
337
+ visiblePages: 5
338
+ }, ...ngDevMode ? [{ debugName: "pageableOptions" }] : /* istanbul ignore next */ []);
339
+ this.role = signal("listbox", ...ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []);
340
+ this.scrollToItem$ = new ReplaySubject(1);
341
+ this.selectableOptions = signal({
342
+ checkboxes: false,
343
+ enabled: false,
344
+ mode: "single",
345
+ toggleable: false
346
+ }, ...ngDevMode ? [{ debugName: "selectableOptions" }] : /* istanbul ignore next */ []);
347
+ this.selectedKeys = signal(ImmutableSet.create(), ...ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []);
348
+ this.selectedKeysChange$ = new Subject();
349
+ this.selectedListItems = computed(() => {
350
+ const selectedKeys = this.selectedKeys();
351
+ const itemsByKey = this.#itemsByKey();
352
+ return selectedKeys.select((key) => itemsByKey.get(key)).where((i) => i != null).toImmutableSet();
353
+ }, ...ngDevMode ? [{ debugName: "selectedListItems" }] : /* istanbul ignore next */ []);
354
+ this.selectionChange$ = new Subject();
355
+ this.textField = signal("", ...ngDevMode ? [{ debugName: "textField" }] : /* istanbul ignore next */ []);
356
+ this.valueField = signal("", ...ngDevMode ? [{ debugName: "valueField" }] : /* istanbul ignore next */ []);
357
+ this.viewItems = computed(() => {
358
+ const arrangedItems = this.#arrangedItems();
359
+ const pageableOptions = this.pageableOptions();
360
+ if (this.virtualScrollOptions().enabled || !pageableOptions.enabled) return arrangedItems;
361
+ const pageState = this.pageState();
362
+ return toImmutableSet(this.skipTakeWithGroups(arrangedItems.toArray(), pageState.skip, pageState.take));
363
+ }, ...ngDevMode ? [{ debugName: "viewItems" }] : /* istanbul ignore next */ []);
364
+ this.virtualScrollOptions = signal({
365
+ enabled: false,
366
+ height: 28
367
+ }, ...ngDevMode ? [{ debugName: "virtualScrollOptions" }] : /* istanbul ignore next */ []);
368
+ }
369
+ #arrangedItems;
370
+ #data;
371
+ #i18n;
372
+ #itemsByKey;
373
+ #itemsByUid;
374
+ #listItems;
375
+ #groupHeaders;
376
+ clearFilter() {
377
+ this.filterText.set("");
378
+ }
379
+ clearHighlightedItem() {
380
+ this.highlightedItem.set(null);
381
+ }
382
+ clearSelections() {
383
+ this.selectedKeys.update((set) => set.clear());
384
+ this.highlightedItem.set(null);
385
+ }
386
+ cycleThroughMatchedItems(buffer) {
387
+ const activeItem = this.highlightedItem() || this.selectedListItems().lastOrDefault();
388
+ const prefix = buffer.toLowerCase();
389
+ return cycleThroughMatchedItems(this.viewItems(), activeItem ?? null, (item) => {
390
+ if (item.isHeader || this.isDisabled(item)) return false;
391
+ return this.getItemText(item).toLowerCase().startsWith(prefix);
392
+ }, prefix.length > 1);
393
+ }
394
+ deselectItems(item) {
395
+ const keys = from(item).select((i) => this.getSelectionKey(i)).toImmutableSet();
396
+ this.selectedKeys.update((set) => set.removeAll(keys));
397
+ }
398
+ getDataItemValue(dataItem) {
399
+ const valueField = this.valueField();
400
+ if (!valueField) return dataItem;
401
+ if (typeof valueField === "string") return dataItem?.[valueField] ?? dataItem;
402
+ return valueField(dataItem);
403
+ }
404
+ getFilterDebounceDuration() {
405
+ const filterableOptions = this.filterableOptions();
406
+ return filterableOptions.enabled ? filterableOptions.debounce : 0;
407
+ }
408
+ getGroupField(item) {
409
+ const groupSelector = this.groupBy();
410
+ if (groupSelector == null) return "";
411
+ if (typeof groupSelector === "string") return item.data?.[groupSelector] ?? "";
412
+ return groupSelector(item.data);
413
+ }
414
+ getGroupHeaderUid(item) {
415
+ return this.groupHeaderUids().get(item.uid) ?? null;
416
+ }
417
+ getItemPosition(item) {
418
+ return this.itemPositions().get(item.uid) ?? null;
419
+ }
420
+ getItemText(item) {
421
+ const textField = this.textField();
422
+ let text;
423
+ if (!textField) text = item.data;
424
+ else if (typeof textField === "string") text = item.data?.[textField];
425
+ else text = textField(item.data);
426
+ return text == null ? "" : String(text);
427
+ }
428
+ getMatchingFilteredItem(text) {
429
+ const filterableOptions = this.filterableOptions();
430
+ const caseSensitive = filterableOptions.enabled ? filterableOptions.caseSensitive : false;
431
+ const candidates = this.viewItems().where((i) => !i.isHeader && !this.isDisabled(i));
432
+ const fullMatchingItem = candidates.firstOrDefault((i) => {
433
+ const itemText = this.getItemText(i);
434
+ return caseSensitive ? itemText === text : itemText.toLowerCase() === text.toLowerCase();
435
+ });
436
+ if (fullMatchingItem) return fullMatchingItem;
437
+ return candidates.firstOrDefault((i) => this.filterItem(i, text));
438
+ }
439
+ isDataItemDisabled(dataItem) {
440
+ const disabledBy = this.disabledBy();
441
+ if (typeof disabledBy === "string") return disabledBy !== "" && Boolean(dataItem?.[disabledBy]);
442
+ return disabledBy(dataItem);
443
+ }
444
+ isDisabled(item) {
445
+ return !item.isHeader && this.isDataItemDisabled(item.data);
446
+ }
447
+ isFilteringEnabled() {
448
+ return this.filterableOptions().enabled;
449
+ }
450
+ isHighlighted(item) {
451
+ return this.highlightedItem() === item;
452
+ }
453
+ isSelected(item) {
454
+ if (!this.selectableOptions().enabled) return false;
455
+ const selectedKeys = this.selectedKeys();
456
+ const key = this.getSelectionKey(item);
457
+ return selectedKeys.contains(key);
458
+ }
459
+ navigate(direction, mode, focus) {
460
+ if (!this.navigableOptions().enabled) return null;
461
+ const viewItems = this.viewItems().where((i) => !i.isHeader && !this.isDisabled(i)).toImmutableSet();
462
+ if (viewItems.isEmpty()) return null;
463
+ const selectableOptions = this.selectableOptions();
464
+ if (mode === "select" && (!selectableOptions.enabled || selectableOptions.mode === "multiple")) mode = "highlight";
465
+ let item;
466
+ if (selectableOptions.mode === "single") item = this.navigateForSingleSelection(viewItems, direction, mode);
467
+ else item = this.navigateForMultipleSelection(viewItems, direction);
468
+ if (item) {
469
+ this.scrollToItem$.next({
470
+ item,
471
+ focus
472
+ });
473
+ this.navigatedItem$.next(item);
474
+ }
475
+ return item;
476
+ }
477
+ notifySelectionChange(item) {
478
+ this.selectionChange$.next(item);
479
+ }
480
+ scrollToItem(item, focus) {
481
+ this.scrollToItem$.next({
482
+ item,
483
+ focus
484
+ });
485
+ }
486
+ selectAllItems() {
487
+ const options = this.selectableOptions();
488
+ if (!options.enabled || options.mode !== "multiple") return false;
489
+ const keys = this.viewItems().where((i) => !i.isHeader && !this.isDisabled(i)).select((i) => this.getSelectionKey(i)).toArray();
490
+ const selectedKeys = this.selectedKeys();
491
+ if (keys.every((key) => selectedKeys.contains(key))) return false;
492
+ this.selectedKeys.update((set) => set.addAll(keys));
493
+ return true;
494
+ }
495
+ selectItem(item, scroll = false, focus = false) {
496
+ const key = this.getSelectionKey(item);
497
+ const options = this.selectableOptions();
498
+ if (options.mode === "single") {
499
+ if (options.toggleable) this.selectedKeys.update((set) => {
500
+ if (set.contains(key)) {
501
+ if (set.size() > 1) return set.where((k) => k === key).toImmutableSet();
502
+ return set.remove(key);
503
+ }
504
+ return set.clear().add(key);
505
+ });
506
+ else this.selectedKeys.update((set) => set.clear().add(key));
507
+ } else this.selectedKeys.update((set) => {
508
+ if (set.contains(key)) return set.remove(key);
509
+ return set.add(key);
510
+ });
511
+ if (scroll) this.scrollToItem(item, focus);
512
+ this.notifySelectionChange(item);
513
+ }
514
+ setData(data) {
515
+ this.#data.update((list) => list.clear().addAll(data));
516
+ }
517
+ setDisabledBy(disabledBy) {
518
+ this.disabledBy.set(disabledBy);
519
+ }
520
+ setFilter(filter) {
521
+ this.filterText.set(filter);
522
+ }
523
+ setFilterPlaceholder(placeholder) {
524
+ this.filterPlaceholder.set(placeholder);
525
+ }
526
+ setFilterableOptions(options) {
527
+ this.filterableOptions.update((o) => ({
528
+ ...o,
529
+ ...options
530
+ }));
531
+ }
532
+ setGroupBy(groupSelector) {
533
+ this.groupBy.set(groupSelector);
534
+ }
535
+ setGroupableOptions(options) {
536
+ this.groupableOptions.update((o) => ({
537
+ ...o,
538
+ ...options
539
+ }));
540
+ }
541
+ setNavigableOptions(options) {
542
+ this.navigableOptions.update((o) => ({
543
+ ...o,
544
+ ...options
545
+ }));
546
+ }
547
+ setPageableOptions(settings) {
548
+ this.pageableOptions.set(settings);
549
+ }
550
+ setSelectableOptions(options) {
551
+ this.selectableOptions.update((o) => ({
552
+ ...o,
553
+ ...options
554
+ }));
555
+ }
556
+ setSelectedDataItems(dataItems) {
557
+ const selectedKeys = from(dataItems).select((item) => this.getDataItemValue(item)).toImmutableSet();
558
+ this.selectedKeys.update((set) => set.clear().addAll(selectedKeys));
559
+ }
560
+ setSelectedKeys(selectedKeys) {
561
+ this.selectedKeys.update((set) => set.clear().addAll(selectedKeys));
562
+ }
563
+ setTextField(textField) {
564
+ this.textField.set(textField);
565
+ }
566
+ setValueField(valueField) {
567
+ this.valueField.set(valueField);
568
+ }
569
+ setVirtualScrollOptions(options) {
570
+ this.virtualScrollOptions.update((o) => ({
571
+ ...o,
572
+ ...options
573
+ }));
574
+ }
575
+ filterItem(item, filterText) {
576
+ if (filterText === "") return true;
577
+ const options = this.filterableOptions();
578
+ const itemText = this.getItemText(item);
579
+ const text = options.caseSensitive ? itemText : itemText.toLowerCase();
580
+ const filter = options.caseSensitive ? filterText : filterText.toLowerCase();
581
+ const operator = options.enabled ? options.operator : "startsWith";
582
+ if (typeof operator === "function") return operator(text, filter);
583
+ switch (operator) {
584
+ case "contains": return text.includes(filter);
585
+ case "startsWith": return text.startsWith(filter);
586
+ case "endsWith": return text.endsWith(filter);
587
+ default: return false;
588
+ }
589
+ }
590
+ getItemInView(viewItems, item) {
591
+ return item != null && viewItems.contains(item) ? item : null;
592
+ }
593
+ getOrderKey(item) {
594
+ const orderBy = this.groupableOptions().orderBy;
595
+ if (orderBy) {
596
+ if (typeof orderBy === "string") return item.data[orderBy];
597
+ else return orderBy(item.data);
598
+ }
599
+ return null;
600
+ }
601
+ getPreviousItemForNavigation(viewItems, navigationItem) {
602
+ let prevItem = viewItems.takeWhile((i) => i !== navigationItem).lastOrDefault((i) => !this.isDisabled(i));
603
+ if (prevItem == null) {
604
+ const lastItem = viewItems.lastOrDefault((i) => !this.isDisabled(i));
605
+ if (this.navigableOptions().wrap) prevItem = lastItem;
606
+ else if (!this.navigableOptions().wrap) prevItem = navigationItem;
607
+ }
608
+ return prevItem;
609
+ }
610
+ getSelectionKey(item) {
611
+ return this.getDataItemValue(item.data);
612
+ }
613
+ navigateFirstForSingleSelection(viewItems, mode) {
614
+ const firstItem = viewItems.first();
615
+ if (mode === "select") {
616
+ if (!this.isSelected(firstItem)) this.selectItem(firstItem);
617
+ this.highlightedItem.set(null);
618
+ } else this.highlightedItem.set(firstItem);
619
+ return firstItem;
620
+ }
621
+ navigateForMultipleSelection(viewItems, direction) {
622
+ const selectedKeys = this.selectedKeys();
623
+ const firstItem = viewItems.first();
624
+ if (direction === "first" || direction === "last") {
625
+ const edgeItem = direction === "first" ? firstItem : viewItems.last();
626
+ this.highlightedItem.set(edgeItem);
627
+ return edgeItem;
628
+ }
629
+ const lastHighlightedItem = this.getItemInView(viewItems, this.highlightedItem());
630
+ if (selectedKeys.isEmpty() && !lastHighlightedItem) {
631
+ this.highlightedItem.set(firstItem);
632
+ return firstItem;
633
+ }
634
+ const firstSelectedItem = viewItems.firstOrDefault((i) => selectedKeys.contains(this.getSelectionKey(i)));
635
+ const lastSelectedItem = viewItems.lastOrDefault((i) => selectedKeys.contains(this.getSelectionKey(i)));
636
+ if (direction === "next") {
637
+ const navigationItem = lastHighlightedItem ?? lastSelectedItem ?? firstItem;
638
+ let nextItem = viewItems.skipWhile((i) => i !== navigationItem).skip(1).firstOrDefault((i) => !this.isDisabled(i));
639
+ if (nextItem == null) {
640
+ const firstItem = viewItems.firstOrDefault((i) => !this.isDisabled(i));
641
+ if (this.navigableOptions().wrap) nextItem = firstItem;
642
+ else if (!this.navigableOptions().wrap) nextItem = navigationItem;
643
+ }
644
+ if (nextItem) {
645
+ this.highlightedItem.set(nextItem);
646
+ return nextItem;
647
+ }
648
+ } else {
649
+ const navigationItem = lastHighlightedItem ?? firstSelectedItem ?? firstItem;
650
+ const prevItem = this.getPreviousItemForNavigation(viewItems, navigationItem);
651
+ if (prevItem) {
652
+ this.highlightedItem.set(prevItem);
653
+ return prevItem;
654
+ }
655
+ }
656
+ return null;
657
+ }
658
+ navigateForSingleSelection(viewItems, direction, mode) {
659
+ const selectedKeys = this.selectedKeys();
660
+ const firstItem = viewItems.first();
661
+ const lastHighlightedItem = this.getItemInView(viewItems, this.highlightedItem());
662
+ if (selectedKeys.isEmpty() && !lastHighlightedItem) {
663
+ if (direction === "last") return this.navigateLastForSingleSelection(viewItems, mode);
664
+ if (mode === "select") this.selectItem(firstItem);
665
+ else this.highlightedItem.set(firstItem);
666
+ return firstItem;
667
+ } else if (selectedKeys.isEmpty() && lastHighlightedItem) {
668
+ if (mode === "select") {
669
+ this.selectItem(lastHighlightedItem);
670
+ return lastHighlightedItem;
671
+ }
672
+ }
673
+ const selectedItem = viewItems.lastOrDefault((i) => selectedKeys.contains(this.getSelectionKey(i)));
674
+ const navigationItem = lastHighlightedItem ?? selectedItem ?? firstItem;
675
+ if (direction === "next") return this.navigateNextForSingleSelection(viewItems, navigationItem, mode, firstItem);
676
+ else if (direction === "previous") return this.navigatePreviousForSingleSelection(viewItems, navigationItem, mode);
677
+ else if (direction === "first") return this.navigateFirstForSingleSelection(viewItems, mode);
678
+ else if (direction === "last") return this.navigateLastForSingleSelection(viewItems, mode);
679
+ return null;
680
+ }
681
+ navigateLastForSingleSelection(viewItems, mode) {
682
+ const lastItem = viewItems.last();
683
+ if (mode === "select") {
684
+ if (!this.isSelected(lastItem)) this.selectItem(lastItem);
685
+ this.highlightedItem.set(null);
686
+ } else this.highlightedItem.set(lastItem);
687
+ return lastItem;
688
+ }
689
+ navigateNextForSingleSelection(viewItems, navigationItem, mode, firstItem) {
690
+ let nextItem = viewItems.skipWhile((i) => i !== navigationItem).skip(1).firstOrDefault((i) => !this.isDisabled(i));
691
+ if (nextItem == null) {
692
+ if (this.navigableOptions().wrap) nextItem = firstItem;
693
+ else if (!this.navigableOptions().wrap) nextItem = navigationItem;
694
+ }
695
+ if (nextItem) {
696
+ if (mode === "select") {
697
+ if (this.selectedListItems().firstOrDefault() === nextItem) return null;
698
+ this.selectItem(nextItem);
699
+ this.highlightedItem.set(null);
700
+ } else this.highlightedItem.set(nextItem);
701
+ return nextItem;
702
+ }
703
+ return null;
704
+ }
705
+ navigatePreviousForSingleSelection(viewItems, navigationItem, mode) {
706
+ const prevItem = this.getPreviousItemForNavigation(viewItems, navigationItem);
707
+ if (!prevItem) return null;
708
+ if (mode === "select") {
709
+ if (this.selectedListItems().firstOrDefault() === prevItem) return null;
710
+ this.selectItem(prevItem);
711
+ this.highlightedItem.set(null);
712
+ } else this.highlightedItem.set(prevItem);
713
+ return prevItem;
714
+ }
715
+ skipTakeWithGroups(items, skip, take) {
716
+ let skipped = 0;
717
+ let taken = 0;
718
+ let capturing = false;
719
+ const result = [];
720
+ for (const item of items) if (item.isHeader) {
721
+ if (capturing) result.push(item);
722
+ } else {
723
+ if (!capturing && skipped < skip) {
724
+ skipped++;
725
+ continue;
726
+ }
727
+ if (taken < take) {
728
+ if (!capturing && result.length === 0) {
729
+ const itemIndex = items.indexOf(item);
730
+ for (let i = itemIndex - 1; i >= 0; i--) if (items[i].isHeader) {
731
+ result.push(items[i]);
732
+ break;
733
+ }
734
+ }
735
+ capturing = true;
736
+ result.push(item);
737
+ taken++;
738
+ } else break;
739
+ }
740
+ let lastIndex = result.length - 1;
741
+ while (lastIndex >= 0 && result[lastIndex].isHeader) {
742
+ result.pop();
743
+ lastIndex--;
744
+ }
745
+ return result;
746
+ }
747
+ static {
748
+ this.ɵfac = i0.ɵɵngDeclareFactory({
749
+ minVersion: "12.0.0",
750
+ version: "22.2.6",
751
+ ngImport: i0,
752
+ type: ListService,
753
+ deps: [],
754
+ target: i0.ɵɵFactoryTarget.Injectable
755
+ });
756
+ }
757
+ static {
758
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
759
+ minVersion: "12.0.0",
760
+ version: "22.2.6",
761
+ ngImport: i0,
762
+ type: ListService
763
+ });
764
+ }
765
+ };
766
+ i0.ɵɵngDeclareClassMetadata({
767
+ minVersion: "12.0.0",
768
+ version: "22.2.6",
769
+ ngImport: i0,
770
+ type: ListService,
771
+ decorators: [{ type: Injectable }]
772
+ });
978
773
  const listThemeVariants = cva(`flex h-full flex-col overflow-hidden outline-none focus-visible:outline-hidden`);
979
774
  const listInnerListThemeVariants = cva(`m-0 h-full list-none overflow-x-hidden overflow-y-auto p-0 outline-none focus-visible:outline-hidden [scrollbar-color:var(--color-scrollbar-thumb)_var(--color-scrollbar-track)] [scrollbar-width:thin]`);
980
- const listGroupHeaderThemeVariants = cva(``, {
981
- variants: {
982
- hasTemplate: {
983
- true: "",
984
- false: "border-y-[length:var(--mona-list-group-border-width)] border-border-subtle bg-(--mona-list-group-background) py-1 font-[var(--mona-list-group-font-weight)]"
985
- }
986
- }
987
- });
988
- const listGroupHeaderTextThemeVariants = cva(`select-none text-muted-foreground`, {
989
- variants: {
990
- hasTemplate: { true: "", false: "w-full px-3 py-1 font-[var(--mona-list-group-font-weight)]" }
991
- }
992
- });
775
+ const listGroupHeaderThemeVariants = cva(``, { variants: { hasTemplate: {
776
+ true: "",
777
+ false: "border-y-[length:var(--mona-list-group-border-width)] border-border-subtle bg-(--mona-list-group-background) py-1 font-[var(--mona-list-group-font-weight)]"
778
+ } } });
779
+ const listGroupHeaderTextThemeVariants = cva(`select-none text-muted-foreground`, { variants: { hasTemplate: {
780
+ true: "",
781
+ false: "w-full px-3 py-1 font-[var(--mona-list-group-font-weight)]"
782
+ } } });
993
783
  const listItemBaseThemeVariants = cva(`flex h-full w-full items-center gap-2`);
994
- // Focus and the active option share the grid's ring: solid 2px, inset, at full strength.
995
784
  const listItemContentThemeVariants = cva(`relative flex cursor-default select-none items-center px-3 py-1 text-foreground outline-none focus-visible:outline-hidden focus-visible:inset-ring-2 focus-visible:inset-ring-focus-indicator`, {
996
- variants: {
997
- checkboxes: { true: "gap-2", false: "" },
998
- selectable: { true: "hover:bg-hover focus:bg-hover", false: "" },
999
- highlighted: {
1000
- true: "bg-hover text-foreground inset-ring-2 inset-ring-focus-indicator",
1001
- false: ""
1002
- },
1003
- selected: { true: "bg-(--color-selected) text-(--color-selected-foreground)", false: "" },
1004
- disabled: {
1005
- true: "pointer-events-none cursor-default bg-(--mona-list-disabled-background) text-disabled-foreground",
1006
- false: ""
1007
- }
1008
- },
1009
- compoundVariants: [
1010
- {
1011
- selectable: true,
1012
- disabled: false,
1013
- class: "cursor-pointer"
1014
- },
1015
- {
1016
- selected: true,
1017
- checkboxes: false,
1018
- class: `bg-(--color-selected) text-(--color-selected-foreground) hover:bg-(--color-selected-hover) hover:text-(--color-selected-hover-foreground) focus:bg-(--color-selected-focus) focus:text-(--color-selected-focus-foreground) ${themeSelectionBarClasses}`
1019
- },
1020
- {
1021
- highlighted: true,
1022
- selected: true,
1023
- checkboxes: false,
1024
- class: "bg-(--color-selected) text-(--color-selected-foreground) inset-ring-2 inset-ring-focus-indicator hover:bg-(--color-selected-hover) hover:text-(--color-selected-hover-foreground) focus:bg-(--color-selected-focus) focus:text-(--color-selected-focus-foreground)"
1025
- },
1026
- { selected: true, checkboxes: true, class: "bg-transparent text-foreground" }
1027
- ]
785
+ variants: {
786
+ checkboxes: {
787
+ true: "gap-2",
788
+ false: ""
789
+ },
790
+ selectable: {
791
+ true: "hover:bg-hover focus:bg-hover",
792
+ false: ""
793
+ },
794
+ highlighted: {
795
+ true: "bg-hover text-foreground inset-ring-2 inset-ring-focus-indicator",
796
+ false: ""
797
+ },
798
+ selected: {
799
+ true: "bg-(--color-selected) text-(--color-selected-foreground)",
800
+ false: ""
801
+ },
802
+ disabled: {
803
+ true: "pointer-events-none cursor-default bg-(--mona-list-disabled-background) text-disabled-foreground",
804
+ false: ""
805
+ }
806
+ },
807
+ compoundVariants: [
808
+ {
809
+ selectable: true,
810
+ disabled: false,
811
+ class: "cursor-pointer"
812
+ },
813
+ {
814
+ selected: true,
815
+ checkboxes: false,
816
+ class: `bg-(--color-selected) text-(--color-selected-foreground) hover:bg-(--color-selected-hover) hover:text-(--color-selected-hover-foreground) focus:bg-(--color-selected-focus) focus:text-(--color-selected-focus-foreground) ${themeSelectionBarClasses}`
817
+ },
818
+ {
819
+ highlighted: true,
820
+ selected: true,
821
+ checkboxes: false,
822
+ class: "bg-(--color-selected) text-(--color-selected-foreground) inset-ring-2 inset-ring-focus-indicator hover:bg-(--color-selected-hover) hover:text-(--color-selected-hover-foreground) focus:bg-(--color-selected-focus) focus:text-(--color-selected-focus-foreground)"
823
+ },
824
+ {
825
+ selected: true,
826
+ checkboxes: true,
827
+ class: "bg-transparent text-foreground"
828
+ }
829
+ ]
830
+ });
831
+ var ListItemDirective = class ListItemDirective {
832
+ #listService;
833
+ constructor() {
834
+ this.#listService = inject(ListService);
835
+ this.disabled = computed(() => this.#listService.isDisabled(this.item()), ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
836
+ this.groupHeaderUid = computed(() => this.#listService.virtualScrollOptions().enabled ? this.#listService.getGroupHeaderUid(this.item()) : null, ...ngDevMode ? [{ debugName: "groupHeaderUid" }] : /* istanbul ignore next */ []);
837
+ this.highlighted = computed(() => this.#listService.isHighlighted(this.item()), ...ngDevMode ? [{ debugName: "highlighted" }] : /* istanbul ignore next */ []);
838
+ this.isOption = computed(() => this.#listService.role() === "listbox", ...ngDevMode ? [{ debugName: "isOption" }] : /* istanbul ignore next */ []);
839
+ this.position = computed(() => {
840
+ return this.#listService.getItemPosition(this.item())?.position ?? null;
841
+ }, ...ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []);
842
+ this.rovingTabIndex = computed(() => this.#listService.focusableItem() === this.item() ? 0 : -1, ...ngDevMode ? [{ debugName: "rovingTabIndex" }] : /* istanbul ignore next */ []);
843
+ this.selected = computed(() => this.#listService.isSelected(this.item()), ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
844
+ this.setSize = computed(() => {
845
+ return this.#listService.getItemPosition(this.item())?.total ?? null;
846
+ }, ...ngDevMode ? [{ debugName: "setSize" }] : /* istanbul ignore next */ []);
847
+ this.textClasses = computed(() => {
848
+ const disabled = this.disabled();
849
+ const highlighted = this.highlighted();
850
+ const selected = this.selected();
851
+ const selectableOptions = this.#listService.selectableOptions();
852
+ const checkboxes = selectableOptions.checkboxes;
853
+ const classes = listItemContentThemeVariants({
854
+ disabled,
855
+ highlighted,
856
+ selected,
857
+ checkboxes,
858
+ selectable: selectableOptions.enabled
859
+ });
860
+ return twMerge(classes);
861
+ }, ...ngDevMode ? [{ debugName: "textClasses" }] : /* istanbul ignore next */ []);
862
+ this.item = input.required(...ngDevMode ? [{ debugName: "item" }] : /* istanbul ignore next */ []);
863
+ fromEvent(inject(ElementRef).nativeElement, "focusout").pipe(takeUntilDestroyed()).subscribe(() => this.#listService.itemFocusOut$.next(this.item()));
864
+ }
865
+ static {
866
+ this.ɵfac = i0.ɵɵngDeclareFactory({
867
+ minVersion: "12.0.0",
868
+ version: "22.2.6",
869
+ ngImport: i0,
870
+ type: ListItemDirective,
871
+ deps: [],
872
+ target: i0.ɵɵFactoryTarget.Directive
873
+ });
874
+ }
875
+ static {
876
+ this.ɵdir = i0.ɵɵngDeclareDirective({
877
+ minVersion: "17.1.0",
878
+ version: "22.2.6",
879
+ type: ListItemDirective,
880
+ isStandalone: true,
881
+ selector: "li[monaListItem]",
882
+ inputs: { item: {
883
+ classPropertyName: "item",
884
+ publicName: "item",
885
+ isSignal: true,
886
+ isRequired: true,
887
+ transformFunction: null
888
+ } },
889
+ host: { properties: {
890
+ "attr.aria-describedby": "groupHeaderUid()",
891
+ "attr.aria-disabled": "isOption() ? disabled() : null",
892
+ "attr.aria-posinset": "position()",
893
+ "attr.aria-selected": "isOption() ? selected() : null",
894
+ "attr.aria-setsize": "setSize()",
895
+ "attr.data-disabled": "disabled()",
896
+ "attr.data-highlighted": "highlighted()",
897
+ "attr.data-selected": "selected()",
898
+ "attr.role": "isOption() ? 'option' : 'listitem'",
899
+ "attr.tabindex": "rovingTabIndex()",
900
+ "class": "textClasses()"
901
+ } },
902
+ ngImport: i0
903
+ });
904
+ }
905
+ };
906
+ i0.ɵɵngDeclareClassMetadata({
907
+ minVersion: "12.0.0",
908
+ version: "22.2.6",
909
+ ngImport: i0,
910
+ type: ListItemDirective,
911
+ decorators: [{
912
+ type: Directive,
913
+ args: [{
914
+ selector: "li[monaListItem]",
915
+ host: {
916
+ "[attr.aria-describedby]": "groupHeaderUid()",
917
+ "[attr.aria-disabled]": "isOption() ? disabled() : null",
918
+ "[attr.aria-posinset]": "position()",
919
+ "[attr.aria-selected]": "isOption() ? selected() : null",
920
+ "[attr.aria-setsize]": "setSize()",
921
+ "[attr.data-disabled]": "disabled()",
922
+ "[attr.data-highlighted]": "highlighted()",
923
+ "[attr.data-selected]": "selected()",
924
+ "[attr.role]": "isOption() ? 'option' : 'listitem'",
925
+ "[attr.tabindex]": "rovingTabIndex()",
926
+ "[class]": "textClasses()"
927
+ }
928
+ }]
929
+ }],
930
+ ctorParameters: () => [],
931
+ propDecorators: { item: [{
932
+ type: i0.Input,
933
+ args: [{
934
+ isSignal: true,
935
+ alias: "item",
936
+ required: true
937
+ }]
938
+ }] }
939
+ });
940
+ var ListNoDataTemplateDirective = class ListNoDataTemplateDirective {
941
+ static {
942
+ this.ɵfac = i0.ɵɵngDeclareFactory({
943
+ minVersion: "12.0.0",
944
+ version: "22.2.6",
945
+ ngImport: i0,
946
+ type: ListNoDataTemplateDirective,
947
+ deps: [],
948
+ target: i0.ɵɵFactoryTarget.Directive
949
+ });
950
+ }
951
+ static {
952
+ this.ɵdir = i0.ɵɵngDeclareDirective({
953
+ minVersion: "14.0.0",
954
+ version: "22.2.6",
955
+ type: ListNoDataTemplateDirective,
956
+ isStandalone: true,
957
+ selector: "ng-template[monaListNoDataTemplate]",
958
+ ngImport: i0
959
+ });
960
+ }
961
+ };
962
+ i0.ɵɵngDeclareClassMetadata({
963
+ minVersion: "12.0.0",
964
+ version: "22.2.6",
965
+ ngImport: i0,
966
+ type: ListNoDataTemplateDirective,
967
+ decorators: [{
968
+ type: Directive,
969
+ args: [{ selector: "ng-template[monaListNoDataTemplate]" }]
970
+ }]
1028
971
  });
1029
-
1030
- class ListItemDirective {
1031
- #listService;
1032
- constructor() {
1033
- this.#listService = inject((ListService));
1034
- this.disabled = computed(() => this.#listService.isDisabled(this.item()), /* @ts-ignore */
1035
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
1036
- /**
1037
- * Without virtual scrolling, items sit inside a group labelled by its header. A virtual list stays flat, so each
1038
- * item points at its header instead.
1039
- */
1040
- this.groupHeaderUid = computed(() => this.#listService.virtualScrollOptions().enabled ? this.#listService.getGroupHeaderUid(this.item()) : null, /* @ts-ignore */
1041
- ...(ngDevMode ? [{ debugName: "groupHeaderUid" }] : /* istanbul ignore next */ []));
1042
- this.highlighted = computed(() => this.#listService.isHighlighted(this.item()), /* @ts-ignore */
1043
- ...(ngDevMode ? [{ debugName: "highlighted" }] : /* istanbul ignore next */ []));
1044
- this.isOption = computed(() => this.#listService.role() === "listbox", /* @ts-ignore */
1045
- ...(ngDevMode ? [{ debugName: "isOption" }] : /* istanbul ignore next */ []));
1046
- this.position = computed(() => {
1047
- const positionInfo = this.#listService.getItemPosition(this.item());
1048
- return positionInfo?.position ?? null;
1049
- }, /* @ts-ignore */
1050
- ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
1051
- this.rovingTabIndex = computed(() => (this.#listService.focusableItem() === this.item() ? 0 : -1), /* @ts-ignore */
1052
- ...(ngDevMode ? [{ debugName: "rovingTabIndex" }] : /* istanbul ignore next */ []));
1053
- this.selected = computed(() => this.#listService.isSelected(this.item()), /* @ts-ignore */
1054
- ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
1055
- this.setSize = computed(() => {
1056
- const positionInfo = this.#listService.getItemPosition(this.item());
1057
- return positionInfo?.total ?? null;
1058
- }, /* @ts-ignore */
1059
- ...(ngDevMode ? [{ debugName: "setSize" }] : /* istanbul ignore next */ []));
1060
- this.textClasses = computed(() => {
1061
- const disabled = this.disabled();
1062
- const highlighted = this.highlighted();
1063
- const selected = this.selected();
1064
- const selectableOptions = this.#listService.selectableOptions();
1065
- const checkboxes = selectableOptions.checkboxes;
1066
- const classes = listItemContentThemeVariants({
1067
- disabled,
1068
- highlighted,
1069
- selected,
1070
- checkboxes,
1071
- selectable: selectableOptions.enabled
1072
- });
1073
- return twMerge(classes);
1074
- }, /* @ts-ignore */
1075
- ...(ngDevMode ? [{ debugName: "textClasses" }] : /* istanbul ignore next */ []));
1076
- this.item = input.required(/* @ts-ignore */
1077
- ...(ngDevMode ? [{ debugName: "item" }] : /* istanbul ignore next */ []));
1078
- fromEvent(inject((ElementRef)).nativeElement, "focusout")
1079
- .pipe(takeUntilDestroyed())
1080
- .subscribe(() => this.#listService.itemFocusOut$.next(this.item()));
1081
- }
1082
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1083
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: ListItemDirective, isStandalone: true, selector: "li[monaListItem]", inputs: { item: { classPropertyName: "item", publicName: "item", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "attr.aria-describedby": "groupHeaderUid()", "attr.aria-disabled": "isOption() ? disabled() : null", "attr.aria-posinset": "position()", "attr.aria-selected": "isOption() ? selected() : null", "attr.aria-setsize": "setSize()", "attr.data-disabled": "disabled()", "attr.data-highlighted": "highlighted()", "attr.data-selected": "selected()", "attr.role": "isOption() ? 'option' : 'listitem'", "attr.tabindex": "rovingTabIndex()", "class": "textClasses()" } }, ngImport: i0 }); }
1084
- }
1085
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListItemDirective, decorators: [{
1086
- type: Directive,
1087
- args: [{
1088
- selector: "li[monaListItem]",
1089
- host: {
1090
- "[attr.aria-describedby]": "groupHeaderUid()",
1091
- "[attr.aria-disabled]": "isOption() ? disabled() : null",
1092
- "[attr.aria-posinset]": "position()",
1093
- "[attr.aria-selected]": "isOption() ? selected() : null",
1094
- "[attr.aria-setsize]": "setSize()",
1095
- "[attr.data-disabled]": "disabled()",
1096
- "[attr.data-highlighted]": "highlighted()",
1097
- "[attr.data-selected]": "selected()",
1098
- "[attr.role]": "isOption() ? 'option' : 'listitem'",
1099
- "[attr.tabindex]": "rovingTabIndex()",
1100
- "[class]": "textClasses()"
1101
- }
1102
- }]
1103
- }], ctorParameters: () => [], propDecorators: { item: [{ type: i0.Input, args: [{ isSignal: true, alias: "item", required: true }] }] } });
1104
-
1105
- class ListNoDataTemplateDirective {
1106
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListNoDataTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
1107
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: ListNoDataTemplateDirective, isStandalone: true, selector: "ng-template[monaListNoDataTemplate]", ngImport: i0 }); }
1108
- }
1109
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListNoDataTemplateDirective, decorators: [{
1110
- type: Directive,
1111
- args: [{
1112
- selector: "ng-template[monaListNoDataTemplate]"
1113
- }]
1114
- }] });
1115
-
1116
972
  const getListNavigationDirection = (key) => {
1117
- switch (key) {
1118
- case "ArrowDown":
1119
- case "Down":
1120
- return "next";
1121
- case "ArrowUp":
1122
- case "Up":
1123
- return "previous";
1124
- case "Home":
1125
- return "first";
1126
- case "End":
1127
- return "last";
1128
- case "PageUp":
1129
- return "pageup";
1130
- case "PageDown":
1131
- return "pagedown";
1132
- default:
1133
- return null;
1134
- }
973
+ switch (key) {
974
+ case "ArrowDown":
975
+ case "Down": return "next";
976
+ case "ArrowUp":
977
+ case "Up": return "previous";
978
+ case "Home": return "first";
979
+ case "End": return "last";
980
+ case "PageUp": return "pageup";
981
+ case "PageDown": return "pagedown";
982
+ default: return null;
983
+ }
1135
984
  };
1136
-
1137
- class ListItemComponent {
1138
- constructor() {
1139
- this.baseClass = computed(() => {
1140
- const isHeader = this.isHeader();
1141
- if (isHeader) {
1142
- return ``;
1143
- }
1144
- return listItemBaseThemeVariants();
1145
- }, /* @ts-ignore */
1146
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
1147
- this.checkboxes = computed(() => {
1148
- return this.listService.selectableOptions().checkboxes && !this.isHeader();
1149
- }, /* @ts-ignore */
1150
- ...(ngDevMode ? [{ debugName: "checkboxes" }] : /* istanbul ignore next */ []));
1151
- this.dataItem = computed(() => this.item()?.data ?? null, /* @ts-ignore */
1152
- ...(ngDevMode ? [{ debugName: "dataItem" }] : /* istanbul ignore next */ []));
1153
- this.isHeader = computed(() => this.item()?.isHeader ?? false, /* @ts-ignore */
1154
- ...(ngDevMode ? [{ debugName: "isHeader" }] : /* istanbul ignore next */ []));
1155
- this.itemChecked = computed(() => this.listService.isSelected(this.item()), /* @ts-ignore */
1156
- ...(ngDevMode ? [{ debugName: "itemChecked" }] : /* istanbul ignore next */ []));
1157
- this.itemText = computed(() => {
1158
- const item = this.item();
1159
- if (item == null) {
1160
- return "";
1161
- }
1162
- if (item.isHeader) {
1163
- return item.header;
1164
- }
1165
- return this.listService.getItemText(item);
1166
- }, /* @ts-ignore */
1167
- ...(ngDevMode ? [{ debugName: "itemText" }] : /* istanbul ignore next */ []));
1168
- this.listService = inject(ListService);
1169
- this.textClasses = computed(() => {
1170
- const isHeader = this.isHeader();
1171
- if (isHeader) {
1172
- const hasTemplate = this.template() != null;
1173
- const classes = listGroupHeaderTextThemeVariants({ hasTemplate });
1174
- return twMerge(classes);
1175
- }
1176
- return ``; // TODO
1177
- }, /* @ts-ignore */
1178
- ...(ngDevMode ? [{ debugName: "textClasses" }] : /* istanbul ignore next */ []));
1179
- this.item = input.required(/* @ts-ignore */
1180
- ...(ngDevMode ? [{ debugName: "item" }] : /* istanbul ignore next */ []));
1181
- this.template = input(/* @ts-ignore */
1182
- ...(ngDevMode ? [undefined, { debugName: "template" }] : /* istanbul ignore next */ []));
1183
- }
1184
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1185
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: ListItemComponent, isStandalone: true, selector: "mona-list-item", inputs: { item: { classPropertyName: "item", publicName: "item", isSignal: true, isRequired: true, transformFunction: null }, template: { classPropertyName: "template", publicName: "template", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "baseClass()" } }, ngImport: i0, template: "@if (checkboxes()) {\n <!-- Visual only: the option row owns selection, so the checkbox is inert (not focusable, clicks reach the row). -->\n <input type=\"checkbox\" [checked]=\"itemChecked()\" monaCheckbox class=\"aspect-square\" inert aria-hidden=\"true\" />\n}\n\n@if (template()) {\n <ng-container [ngTemplateOutlet]=\"template()\" [ngTemplateOutletContext]=\"{ $implicit: dataItem() }\"></ng-container>\n} @else {\n <span [class]=\"textClasses()\">{{ itemText() }}</span>\n}\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CheckboxDirective, selector: "input[type='checkbox'][monaCheckbox]", inputs: ["invalid", "rounded", "touched", "class"] }] }); }
1186
- }
1187
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListItemComponent, decorators: [{
1188
- type: Component,
1189
- args: [{ selector: "mona-list-item", imports: [NgTemplateOutlet, CheckboxDirective], host: {
1190
- "[class]": "baseClass()"
1191
- }, template: "@if (checkboxes()) {\n <!-- Visual only: the option row owns selection, so the checkbox is inert (not focusable, clicks reach the row). -->\n <input type=\"checkbox\" [checked]=\"itemChecked()\" monaCheckbox class=\"aspect-square\" inert aria-hidden=\"true\" />\n}\n\n@if (template()) {\n <ng-container [ngTemplateOutlet]=\"template()\" [ngTemplateOutletContext]=\"{ $implicit: dataItem() }\"></ng-container>\n} @else {\n <span [class]=\"textClasses()\">{{ itemText() }}</span>\n}\n" }]
1192
- }], propDecorators: { item: [{ type: i0.Input, args: [{ isSignal: true, alias: "item", required: true }] }], template: [{ type: i0.Input, args: [{ isSignal: true, alias: "template", required: false }] }] } });
1193
-
1194
- class ListComponent {
1195
- #destroyRef;
1196
- #generatedListId;
1197
- #hostElementRef;
1198
- #i18n;
1199
- /** The rows a virtual list has drawn, so the Tab stop never lands on an option that isn't in the DOM. */
1200
- #renderedRange;
1201
- #typeaheadKey$;
1202
- /** The option that had focus, kept so focus can move to a neighbour when that option is removed. */
1203
- #focusedOption;
1204
- constructor() {
1205
- this.#destroyRef = inject(DestroyRef);
1206
- this.#generatedListId = createElementControlId();
1207
- this.#hostElementRef = inject(ElementRef);
1208
- this.#i18n = inject(MonaI18nService);
1209
- /** The rows a virtual list has drawn, so the Tab stop never lands on an option that isn't in the DOM. */
1210
- this.#renderedRange = signal(null, /* @ts-ignore */
1211
- ...(ngDevMode ? [{ debugName: "#renderedRange" }] : /* istanbul ignore next */ []));
1212
- this.#typeaheadKey$ = new Subject();
1213
- /** The option that had focus, kept so focus can move to a neighbour when that option is removed. */
1214
- this.#focusedOption = null;
1215
- this.filterInput = viewChild(FilterInputComponent, /* @ts-ignore */
1216
- ...(ngDevMode ? [{ debugName: "filterInput" }] : /* istanbul ignore next */ []));
1217
- this.filterInputElement = viewChild(FilterInputComponent, { ...(ngDevMode ? { debugName: "filterInputElement" } : /* istanbul ignore next */ {}), read: ElementRef });
1218
- /**
1219
- * Id of the highlighted option, used as `aria-activedescendant` by the filter input.
1220
- */
1221
- this.activeDescendant = computed(() => {
1222
- const item = this.listService.highlightedItem();
1223
- return item && !item.isHeader ? item.uid : null;
1224
- }, /* @ts-ignore */
1225
- ...(ngDevMode ? [{ debugName: "activeDescendant" }] : /* istanbul ignore next */ []));
1226
- this.classes = computed(() => {
1227
- const classes = listThemeVariants();
1228
- return twMerge(classes);
1229
- }, /* @ts-ignore */
1230
- ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
1231
- /**
1232
- * The `listId` input, or a generated id so the listbox can always be referenced by `aria-controls`.
1233
- */
1234
- this.effectiveListId = computed(() => this.listId() || this.#generatedListId, /* @ts-ignore */
1235
- ...(ngDevMode ? [{ debugName: "effectiveListId" }] : /* istanbul ignore next */ []));
1236
- /** The empty list element covers the "No data" content and shows the focus ring when it has focus. */
1237
- this.emptyListClasses = computed(() => twMerge(this.innerListClasses(), "absolute inset-0 focus-visible:inset-ring-2 focus-visible:inset-ring-focus-indicator"), /* @ts-ignore */
1238
- ...(ngDevMode ? [{ debugName: "emptyListClasses" }] : /* istanbul ignore next */ []));
1239
- this.footerTemplate = contentChild(ListFooterTemplateDirective, { ...(ngDevMode ? { debugName: "footerTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
1240
- this.groupHeaderClasses = computed(() => {
1241
- const listItemClass = this.listItemClass();
1242
- const hasTemplate = this.groupHeaderTemplate() != null;
1243
- const classes = listGroupHeaderThemeVariants({ hasTemplate });
1244
- return twMerge(classes, listItemClass);
1245
- }, /* @ts-ignore */
1246
- ...(ngDevMode ? [{ debugName: "groupHeaderClasses" }] : /* istanbul ignore next */ []));
1247
- this.groupHeaderTemplate = contentChild(ListGroupHeaderTemplateDirective, { ...(ngDevMode ? { debugName: "groupHeaderTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
1248
- this.headerTemplate = contentChild(ListHeaderTemplateDirective, { ...(ngDevMode ? { debugName: "headerTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
1249
- /**
1250
- * The host takes the Tab stop when no option can: every option is disabled, or a virtual list's focusable option
1251
- * is scrolled out of the drawn rows. Focusing the host then moves focus to that option.
1252
- */
1253
- this.hostTabIndex = computed(() => {
1254
- const item = this.listService.focusableItem();
1255
- if (!item) {
1256
- // An empty list element is its own Tab stop.
1257
- return this.listService.viewItems().isEmpty() ? -1 : 0;
1258
- }
1259
- if (!this.listService.virtualScrollOptions().enabled) {
1260
- return -1;
1261
- }
1262
- const range = this.#renderedRange();
1263
- const index = this.listService.viewItems().toArray().indexOf(item);
1264
- return range && index >= range.start && index < range.end ? -1 : 0;
1265
- }, /* @ts-ignore */
1266
- ...(ngDevMode ? [{ debugName: "hostTabIndex" }] : /* istanbul ignore next */ []));
1267
- this.innerListClasses = computed(() => {
1268
- const classes = listInnerListThemeVariants();
1269
- const listClass = this.listClass();
1270
- return twMerge(classes, listClass);
1271
- }, /* @ts-ignore */
1272
- ...(ngDevMode ? [{ debugName: "innerListClasses" }] : /* istanbul ignore next */ []));
1273
- this.itemTemplate = contentChild(ListItemTemplateDirective, { ...(ngDevMode ? { debugName: "itemTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
1274
- this.listHeight = computed(() => {
1275
- const height = this.height();
1276
- if (height == null) {
1277
- return undefined;
1278
- }
1279
- if (typeof height === "number") {
1280
- return `${height}px`;
1281
- }
1282
- return height;
1283
- }, /* @ts-ignore */
1284
- ...(ngDevMode ? [{ debugName: "listHeight" }] : /* istanbul ignore next */ []));
1285
- this.listMaxHeight = computed(() => {
1286
- const maxHeight = this.maxHeight();
1287
- if (maxHeight == null) {
1288
- return undefined;
1289
- }
1290
- if (typeof maxHeight === "number") {
1291
- return `${maxHeight}px`;
1292
- }
1293
- return maxHeight;
1294
- }, /* @ts-ignore */
1295
- ...(ngDevMode ? [{ debugName: "listMaxHeight" }] : /* istanbul ignore next */ []));
1296
- this.listMaxWidth = computed(() => {
1297
- const maxWidth = this.maxWidth();
1298
- if (maxWidth == null) {
1299
- return undefined;
1300
- }
1301
- if (typeof maxWidth === "number") {
1302
- return `${maxWidth}px`;
1303
- }
1304
- return maxWidth;
1305
- }, /* @ts-ignore */
1306
- ...(ngDevMode ? [{ debugName: "listMaxWidth" }] : /* istanbul ignore next */ []));
1307
- this.listService = inject(ListService);
1308
- this.listWidth = computed(() => {
1309
- const width = this.width();
1310
- if (width == null) {
1311
- return undefined;
1312
- }
1313
- if (typeof width === "number") {
1314
- return `${width}px`;
1315
- }
1316
- return width;
1317
- }, /* @ts-ignore */
1318
- ...(ngDevMode ? [{ debugName: "listWidth" }] : /* istanbul ignore next */ []));
1319
- this.messages = this.#i18n.componentMessages("list", LIST_DEFAULT_MESSAGES);
1320
- /** Id of the "No data" content, which describes an empty list. */
1321
- this.noDataId = `${this.#generatedListId}-no-data`;
1322
- this.noDataTemplate = contentChild(ListNoDataTemplateDirective, { ...(ngDevMode ? { debugName: "noDataTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
1323
- /**
1324
- * The shown items split at group headers: a section without a header holds ungrouped items.
1325
- */
1326
- this.viewSections = computed(() => {
1327
- const sections = [];
1328
- for (const item of this.listService.viewItems()) {
1329
- if (item.isHeader) {
1330
- sections.push({ header: item, items: [], key: item.uid });
1331
- continue;
1332
- }
1333
- if (sections.length === 0) {
1334
- sections.push({ header: null, items: [], key: "" });
1335
- }
1336
- sections[sections.length - 1].items.push(item);
1337
- }
1338
- return sections;
1339
- }, /* @ts-ignore */
1340
- ...(ngDevMode ? [{ debugName: "viewSections" }] : /* istanbul ignore next */ []));
1341
- this.viewportHeight = computed(() => {
1342
- const listHeight = this.listHeight();
1343
- if (listHeight) {
1344
- return listHeight;
1345
- }
1346
- const items = this.listService.viewItems().size();
1347
- const headerItems = this.listService
1348
- .viewItems()
1349
- .where(i => i.isHeader)
1350
- .count();
1351
- const itemHeight = this.listService.virtualScrollOptions().height ?? 28;
1352
- const height = items * itemHeight + headerItems * 2;
1353
- return `${height}px`;
1354
- }, /* @ts-ignore */
1355
- ...(ngDevMode ? [{ debugName: "viewportHeight" }] : /* istanbul ignore next */ []));
1356
- this.virtualScrollViewport = viewChild(CdkVirtualScrollViewport, /* @ts-ignore */
1357
- ...(ngDevMode ? [{ debugName: "virtualScrollViewport" }] : /* istanbul ignore next */ []));
1358
- /**
1359
- * @description Accessible name for the list's `listbox` element. Describe what the list represents.
1360
- * @default ""
1361
- */
1362
- this.ariaLabel = input("", /* @ts-ignore */
1363
- ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
1364
- /**
1365
- * @description Id of the element that names the list, as an alternative to `ariaLabel`.
1366
- * @default ""
1367
- */
1368
- this.ariaLabelledBy = input("", /* @ts-ignore */
1369
- ...(ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
1370
- /**
1371
- * @description Marks the list as loading (`aria-busy`).
1372
- * @default false
1373
- */
1374
- this.busy = input(false, { ...(ngDevMode ? { debugName: "busy" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1375
- this.data = input(null, /* @ts-ignore */
1376
- ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
1377
- this.focusOnMount = input(true, /* @ts-ignore */
1378
- ...(ngDevMode ? [{ debugName: "focusOnMount" }] : /* istanbul ignore next */ []));
1379
- this.height = input(undefined, /* @ts-ignore */
1380
- ...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
1381
- /**
1382
- * @description Emitted when the user activates an enabled item by clicking it or pressing Enter on it, whether or
1383
- * not the list is selectable.
1384
- */
1385
- this.itemActivate = output();
1386
- this.itemSelect = output();
1387
- this.listClass = input("", /* @ts-ignore */
1388
- ...(ngDevMode ? [{ debugName: "listClass" }] : /* istanbul ignore next */ []));
1389
- this.listId = input("", /* @ts-ignore */
1390
- ...(ngDevMode ? [{ debugName: "listId" }] : /* istanbul ignore next */ []));
1391
- this.listItemClass = input("", /* @ts-ignore */
1392
- ...(ngDevMode ? [{ debugName: "listItemClass" }] : /* istanbul ignore next */ []));
1393
- this.listItemStyle = input({}, /* @ts-ignore */
1394
- ...(ngDevMode ? [{ debugName: "listItemStyle" }] : /* istanbul ignore next */ []));
1395
- /**
1396
- * @description `"listbox"` for options to choose from, `"list"` for items that are only shown.
1397
- * @default "listbox"
1398
- */
1399
- this.listRole = input("listbox", /* @ts-ignore */
1400
- ...(ngDevMode ? [{ debugName: "listRole" }] : /* istanbul ignore next */ []));
1401
- this.listStyle = input({}, /* @ts-ignore */
1402
- ...(ngDevMode ? [{ debugName: "listStyle" }] : /* istanbul ignore next */ []));
1403
- this.maxHeight = input(/* @ts-ignore */
1404
- ...(ngDevMode ? [undefined, { debugName: "maxHeight" }] : /* istanbul ignore next */ []));
1405
- this.maxWidth = input(/* @ts-ignore */
1406
- ...(ngDevMode ? [undefined, { debugName: "maxWidth" }] : /* istanbul ignore next */ []));
1407
- this.size = input("medium", /* @ts-ignore */
1408
- ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ [])); // TODO: Update this to a cva variable when list styles are added
1409
- this.textField = input(null, /* @ts-ignore */
1410
- ...(ngDevMode ? [{ debugName: "textField" }] : /* istanbul ignore next */ []));
1411
- this.width = input(/* @ts-ignore */
1412
- ...(ngDevMode ? [undefined, { debugName: "width" }] : /* istanbul ignore next */ []));
1413
- effect(() => {
1414
- const textField = this.textField();
1415
- untracked(() => {
1416
- if (textField != null) {
1417
- this.listService.setTextField(textField);
1418
- }
1419
- });
1420
- });
1421
- effect(() => {
1422
- const data = this.data();
1423
- untracked(() => {
1424
- if (data != null) {
1425
- this.listService.setData(data);
1426
- }
1427
- });
1428
- });
1429
- effect(() => {
1430
- const listRole = this.listRole();
1431
- untracked(() => this.listService.role.set(listRole));
1432
- });
1433
- effect(onCleanup => {
1434
- const viewport = this.virtualScrollViewport();
1435
- if (!viewport) {
1436
- this.#renderedRange.set(null);
1437
- return;
1438
- }
1439
- const subscription = viewport.renderedRangeStream.subscribe(range => this.#renderedRange.set(range));
1440
- onCleanup(() => subscription.unsubscribe());
1441
- });
1442
- afterRenderEffect({
1443
- write: () => {
1444
- this.listService.viewItems();
1445
- untracked(() => this.restoreFocusAfterRemoval());
1446
- }
1447
- });
1448
- afterNextRender({
1449
- read: () => this.setInitialSelectionOrFocus()
1450
- });
1451
- }
1452
- ngOnInit() {
1453
- this.setSubscriptions();
1454
- }
1455
- onFilterChange(event) {
1456
- this.listService.filterChange$.next(event);
1457
- if (!event.isDefaultPrevented()) {
1458
- this.listService.setFilter(event.filter);
1459
- }
1460
- }
1461
- onListItemClick(item) {
1462
- this.toggleItem(item);
1463
- if (!item.isHeader && !this.listService.isDisabled(item)) {
1464
- this.itemActivate.emit(item);
1465
- }
1466
- }
1467
- trackByUid(_, item) {
1468
- return item.uid;
1469
- }
1470
- cycleThroughMatchedItems(buffer) {
1471
- const nextItem = this.listService.cycleThroughMatchedItems(buffer);
1472
- if (nextItem) {
1473
- const navigationMode = this.listService.navigableOptions().mode;
1474
- const selectableOptions = this.listService.selectableOptions();
1475
- this.listService.highlightedItem.set(nextItem);
1476
- // In multiple mode typeahead only moves focus, as the arrow keys do: selecting would toggle the match.
1477
- if (navigationMode === "select" && selectableOptions.enabled && selectableOptions.mode !== "multiple") {
1478
- this.selectItem(nextItem);
1479
- this.itemSelect.emit({ item: nextItem, source: { via: "keyboard", key: buffer } });
1480
- }
1481
- this.scrollToItem(nextItem, true, "instant");
1482
- }
1483
- }
1484
- /** Focuses the list element of an empty list, which names the list and is described by "No data". */
1485
- focusEmptyList() {
1486
- const id = this.effectiveListId();
1487
- const list = Array.from(this.#hostElementRef.nativeElement.querySelectorAll("ul")).find(element => element.id === id);
1488
- list?.focus({ preventScroll: true });
1489
- }
1490
- focusToItem(item) {
1491
- if (this.listService.navigableOptions().enabled) {
1492
- this.listService.highlightedItem.set(item);
1493
- }
1494
- this.scrollToItem(item, this.filterInput() == null);
1495
- }
1496
- /**
1497
- * Handles multiple-selection shortcuts from the WAI-ARIA listbox pattern:
1498
- * Space toggles the highlighted option and Ctrl/Cmd+A selects every enabled option.
1499
- * @returns whether the event was handled.
1500
- */
1501
- handleMultipleSelectionKeys(event) {
1502
- const selectableOptions = this.listService.selectableOptions();
1503
- if (!selectableOptions.enabled || selectableOptions.mode !== "multiple") {
1504
- return false;
1505
- }
1506
- if (event.key === " " && !event.ctrlKey && !event.metaKey && !event.altKey) {
1507
- const highlightedItem = this.listService.highlightedItem();
1508
- if (highlightedItem && !this.listService.isDisabled(highlightedItem)) {
1509
- this.selectItem(highlightedItem);
1510
- this.itemSelect.emit({ item: highlightedItem, source: { via: "keyboard", key: event.key } });
1511
- }
1512
- return true;
1513
- }
1514
- if ((event.ctrlKey || event.metaKey) && !event.altKey && event.key.toLowerCase() === "a") {
1515
- if (this.listService.selectAllItems()) {
1516
- this.listService.selectedKeysChange$.next(this.listService.selectedKeys().toArray());
1517
- }
1518
- return true;
1519
- }
1520
- return false;
1521
- }
1522
- handleNavigation(key) {
1523
- const direction = getListNavigationDirection(key);
1524
- if (!direction) {
1525
- return;
1526
- }
1527
- if (direction === "pageup" || direction === "pagedown") {
1528
- this.handlePageScroll(direction);
1529
- return;
1530
- }
1531
- const navigableOptions = this.listService.navigableOptions();
1532
- const selectableOptions = this.listService.selectableOptions();
1533
- const previousSelectedItems = this.listService.selectedListItems();
1534
- const filterInput = this.filterInput();
1535
- // With a filter input, focus stays in the input and the active option is conveyed by aria-activedescendant.
1536
- const item = this.listService.navigate(direction, navigableOptions.mode, filterInput == null);
1537
- if (item && navigableOptions.mode === "select" && selectableOptions.enabled) {
1538
- this.itemSelect.emit({ item, source: { via: "keyboard", key } });
1539
- if (previousSelectedItems.contains(item)) {
1540
- return;
1541
- }
1542
- this.listService.selectedKeysChange$.next(this.listService.selectedKeys().toArray());
1543
- }
1544
- if (filterInput) {
1545
- filterInput.focus();
1546
- }
1547
- }
1548
- handlePageScroll(direction) {
1549
- const listElement = this.#hostElementRef.nativeElement.firstElementChild;
1550
- switch (direction) {
1551
- case "pagedown": {
1552
- const virtualScrollViewport = this.virtualScrollViewport();
1553
- if (virtualScrollViewport) {
1554
- const scrollOffset = virtualScrollViewport.measureScrollOffset();
1555
- virtualScrollViewport.scrollToOffset(scrollOffset + virtualScrollViewport.getViewportSize(), "smooth");
1556
- }
1557
- else {
1558
- const top = listElement.scrollTop + listElement.clientHeight * 0.8;
1559
- listElement.scrollTo({ top, behavior: "smooth" });
1560
- }
1561
- break;
1562
- }
1563
- case "pageup": {
1564
- const virtualScrollViewport = this.virtualScrollViewport();
1565
- if (virtualScrollViewport) {
1566
- const scrollOffset = virtualScrollViewport.measureScrollOffset();
1567
- virtualScrollViewport.scrollToOffset(scrollOffset - virtualScrollViewport.getViewportSize(), "smooth");
1568
- }
1569
- else {
1570
- const top = listElement.scrollTop - listElement.clientHeight * 0.8;
1571
- listElement.scrollTo({ top, behavior: "smooth" });
1572
- }
1573
- break;
1574
- }
1575
- }
1576
- }
1577
- /**
1578
- * Whether a key event is meant for the list: from the host, the list element, one of this list's own options or
1579
- * its filter input. Keys typed into controls in header, footer or item templates (or in a nested list) are left
1580
- * to those controls.
1581
- */
1582
- isListKeyTarget(event) {
1583
- const host = this.#hostElementRef.nativeElement;
1584
- const target = event.target;
1585
- if (!(target instanceof HTMLElement) || target === host) {
1586
- return true;
1587
- }
1588
- if (this.filterInputElement()?.nativeElement.contains(target)) {
1589
- return true;
1590
- }
1591
- const ownElement = target.closest("mona-list") === host;
1592
- return ownElement && (target.hasAttribute("data-uid") || target.id === this.effectiveListId());
1593
- }
1594
- rememberFocusedOption(target) {
1595
- if (!(target instanceof HTMLElement) || target.closest("mona-list") !== this.#hostElementRef.nativeElement) {
1596
- return;
1597
- }
1598
- const uid = target.getAttribute("data-uid");
1599
- if (uid == null) {
1600
- return;
1601
- }
1602
- const options = this.listService
1603
- .viewItems()
1604
- .where(i => !i.isHeader)
1605
- .toArray();
1606
- const index = options.findIndex(i => i.uid === uid);
1607
- this.#focusedOption = index < 0 ? null : { index, uid };
1608
- // The focused option is where arrow keys continue from, whether it got focus by Tab, click or script.
1609
- if (index >= 0 &&
1610
- this.listService.navigableOptions().enabled &&
1611
- this.listService.highlightedItem() !== options[index]) {
1612
- this.listService.highlightedItem.set(options[index]);
1613
- }
1614
- }
1615
- /**
1616
- * When the option that had focus is removed from the data, focus would fall to the page. Move it to the option
1617
- * now at the same position, or the last one.
1618
- */
1619
- restoreFocusAfterRemoval() {
1620
- const focused = this.#focusedOption;
1621
- if (!focused) {
1622
- return;
1623
- }
1624
- const options = this.listService
1625
- .viewItems()
1626
- .where(i => !i.isHeader)
1627
- .toArray();
1628
- if (options.some(i => i.uid === focused.uid)) {
1629
- return;
1630
- }
1631
- const activeElement = document.activeElement;
1632
- if (activeElement &&
1633
- activeElement !== document.body &&
1634
- this.#hostElementRef.nativeElement.contains(activeElement)) {
1635
- return;
1636
- }
1637
- if (activeElement && activeElement !== document.body) {
1638
- this.#focusedOption = null;
1639
- return;
1640
- }
1641
- const enabled = options.filter(i => !this.listService.isDisabled(i));
1642
- const next = enabled[Math.min(focused.index, enabled.length - 1)];
1643
- if (!next) {
1644
- this.#focusedOption = null;
1645
- this.#hostElementRef.nativeElement.focus();
1646
- return;
1647
- }
1648
- this.focusToItem(next);
1649
- }
1650
- scrollToItem(item, focus, behavior = "auto") {
1651
- const element = this.#hostElementRef.nativeElement.querySelector(`[data-uid="${item.uid}"]`);
1652
- if (element) {
1653
- // "nearest" avoids scrolling the page when the option is already visible.
1654
- element.scrollIntoView({ block: "nearest", behavior });
1655
- if (focus) {
1656
- element.focus({ preventScroll: true });
1657
- }
1658
- }
1659
- else if (this.listService.virtualScrollOptions().enabled) {
1660
- const index = this.listService.viewItems().toList().indexOf(item);
1661
- const itemHeight = this.listService.virtualScrollOptions().height ?? 28;
1662
- const rect = this.#hostElementRef.nativeElement.getBoundingClientRect();
1663
- const offset = itemHeight * index - rect.height / 2;
1664
- asyncScheduler.schedule(() => {
1665
- this.virtualScrollViewport()?.scrollToOffset(offset, behavior);
1666
- const scrolledElement = this.#hostElementRef.nativeElement.querySelector(`[data-uid="${item.uid}"]`);
1667
- if (scrolledElement && focus) {
1668
- scrolledElement.focus({ preventScroll: true });
1669
- }
1670
- });
1671
- }
1672
- }
1673
- selectItem(item) {
1674
- const selectedItems = this.listService.selectedListItems();
1675
- const options = this.listService.selectableOptions();
1676
- // A disabled item can't be selected, whether it is clicked, typed to or activated with Enter.
1677
- if (!options.enabled || this.listService.isDisabled(item)) {
1678
- return;
1679
- }
1680
- if ((options.mode === "single" && !selectedItems.contains(item)) ||
1681
- (options.mode === "single" && options.toggleable) ||
1682
- options.mode === "multiple" ||
1683
- (options.mode === "single" && selectedItems.size() > 1)) {
1684
- this.listService.selectItem(item);
1685
- this.listService.highlightedItem.set(item);
1686
- this.listService.selectedKeysChange$.next(this.listService.selectedKeys().toArray());
1687
- }
1688
- }
1689
- setInitialSelectionOrFocus() {
1690
- if (!this.focusOnMount()) {
1691
- return;
1692
- }
1693
- const selectedItem = this.listService.selectedListItems().lastOrDefault();
1694
- if (selectedItem) {
1695
- this.focusToItem(selectedItem);
1696
- return;
1697
- }
1698
- const firstItem = this.listService
1699
- .viewItems()
1700
- .where(i => !i.isHeader && !this.listService.isDisabled(i))
1701
- .firstOrDefault();
1702
- if (firstItem) {
1703
- this.focusToItem(firstItem);
1704
- }
1705
- }
1706
- setKeyboardEvents() {
1707
- fromEvent(this.#hostElementRef.nativeElement, "keydown")
1708
- .pipe(takeUntilDestroyed(this.#destroyRef), filter(event => event.key === "Enter" && !event.isComposing && this.isListKeyTarget(event)), tap(event => event.preventDefault()))
1709
- .subscribe((event) => {
1710
- const highlightedItem = this.listService.highlightedItem();
1711
- const selectedItem = this.listService.selectedListItems().firstOrDefault();
1712
- const source = { via: "keyboard", key: event.key };
1713
- const item = highlightedItem ?? selectedItem;
1714
- if (item) {
1715
- this.selectItem(item);
1716
- this.itemSelect.emit({ item, source });
1717
- if (!item.isHeader && !this.listService.isDisabled(item)) {
1718
- this.itemActivate.emit(item);
1719
- }
1720
- }
1721
- });
1722
- }
1723
- setNavigationEvents() {
1724
- fromEvent(this.#hostElementRef.nativeElement, "keydown")
1725
- .pipe(takeUntilDestroyed(this.#destroyRef), filter(event => this.listService.navigableOptions().enabled && this.isListKeyTarget(event)))
1726
- .subscribe(event => {
1727
- if (this.handleMultipleSelectionKeys(event)) {
1728
- event.preventDefault();
1729
- return;
1730
- }
1731
- if (isTypeaheadKey(event.key, event)) {
1732
- event.preventDefault();
1733
- this.#typeaheadKey$.next(event.key);
1734
- return;
1735
- }
1736
- // Alt+Arrow is left to the page and to components built on the list (the list box moves items with it).
1737
- if (getListNavigationDirection(event.key) == null || event.altKey) {
1738
- return;
1739
- }
1740
- event.preventDefault();
1741
- this.#typeaheadKey$.next("");
1742
- this.handleNavigation(event.key);
1743
- });
1744
- }
1745
- setSubscriptions() {
1746
- this.setNavigationEvents();
1747
- this.setKeyboardEvents();
1748
- this.setTypeaheadSubscription();
1749
- this.listService.scrollToItem$
1750
- .pipe(takeUntilDestroyed(this.#destroyRef))
1751
- .subscribe(event => this.scrollToItem(event.item, event.focus));
1752
- this.listService.focus$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
1753
- this.#hostElementRef.nativeElement.focus();
1754
- this.setInitialSelectionOrFocus();
1755
- });
1756
- fromEvent(this.#hostElementRef.nativeElement, "focus")
1757
- .pipe(takeUntilDestroyed(this.#destroyRef))
1758
- .subscribe(event => {
1759
- const previous = event.relatedTarget;
1760
- if (previous && this.#hostElementRef.nativeElement.contains(previous)) {
1761
- return;
1762
- }
1763
- if (this.listService.viewItems().isEmpty()) {
1764
- this.focusEmptyList();
1765
- return;
1766
- }
1767
- if (this.focusOnMount()) {
1768
- this.setInitialSelectionOrFocus();
1769
- return;
1770
- }
1771
- // The host only holds the Tab stop while its option isn't drawn; hand focus on to that option.
1772
- const item = this.listService.focusableItem();
1773
- if (item) {
1774
- this.focusToItem(item);
1775
- }
1776
- });
1777
- fromEvent(this.#hostElementRef.nativeElement, "focusin")
1778
- .pipe(takeUntilDestroyed(this.#destroyRef))
1779
- .subscribe(event => this.rememberFocusedOption(event.target));
1780
- fromEvent(this.#hostElementRef.nativeElement, "focusout")
1781
- .pipe(takeUntilDestroyed(this.#destroyRef))
1782
- .subscribe(event => {
1783
- const next = event.relatedTarget;
1784
- if (next && this.#hostElementRef.nativeElement.contains(next)) {
1785
- return;
1786
- }
1787
- this.#focusedOption = null;
1788
- this.listService.highlightedItem.set(null);
1789
- });
1790
- }
1791
- setTypeaheadSubscription() {
1792
- setupTypeahead(this.#typeaheadKey$)
1793
- .pipe(takeUntilDestroyed(this.#destroyRef))
1794
- .subscribe(buffer => this.cycleThroughMatchedItems(buffer));
1795
- }
1796
- toggleItem(item) {
1797
- this.listService.highlightedItem.set(item);
1798
- if (!this.listService.selectableOptions().enabled) {
1799
- return;
1800
- }
1801
- this.selectItem(item);
1802
- this.itemSelect.emit({ item, source: { via: "mouse" } });
1803
- }
1804
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1805
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: ListComponent, isStandalone: true, selector: "mona-list", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "ariaLabelledBy", isSignal: true, isRequired: false, transformFunction: null }, busy: { classPropertyName: "busy", publicName: "busy", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, focusOnMount: { classPropertyName: "focusOnMount", publicName: "focusOnMount", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, listClass: { classPropertyName: "listClass", publicName: "listClass", isSignal: true, isRequired: false, transformFunction: null }, listId: { classPropertyName: "listId", publicName: "listId", isSignal: true, isRequired: false, transformFunction: null }, listItemClass: { classPropertyName: "listItemClass", publicName: "listItemClass", isSignal: true, isRequired: false, transformFunction: null }, listItemStyle: { classPropertyName: "listItemStyle", publicName: "listItemStyle", isSignal: true, isRequired: false, transformFunction: null }, listRole: { classPropertyName: "listRole", publicName: "listRole", isSignal: true, isRequired: false, transformFunction: null }, listStyle: { classPropertyName: "listStyle", publicName: "listStyle", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", 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 }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemActivate: "itemActivate", itemSelect: "itemSelect" }, host: { properties: { "attr.tabindex": "hostTabIndex()", "class": "classes()", "style.height": "listHeight()", "style.max-height": "listMaxHeight()", "style.max-width": "listMaxWidth()", "style.width": "listWidth()" } }, queries: [{ propertyName: "footerTemplate", first: true, predicate: ListFooterTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ListGroupHeaderTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "headerTemplate", first: true, predicate: ListHeaderTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "itemTemplate", first: true, predicate: ListItemTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "noDataTemplate", first: true, predicate: ListNoDataTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], viewQueries: [{ propertyName: "filterInput", first: true, predicate: FilterInputComponent, descendants: true, isSignal: true }, { propertyName: "filterInputElement", first: true, predicate: FilterInputComponent, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "virtualScrollViewport", first: true, predicate: CdkVirtualScrollViewport, descendants: true, isSignal: true }], ngImport: i0, template: "@if (headerTemplate()) {\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n}\n@if (listService.filterableOptions().enabled && listService.filterInputVisible()) {\n <div class=\"p-2\">\n <mona-filter-input\n [filter]=\"listService.filterText()\"\n [debounce]=\"listService.filterableOptions().debounce\"\n [placeholder]=\"listService.filterPlaceholder()\"\n [ariaLabel]=\"messages().filterList\"\n [controls]=\"effectiveListId()\"\n [activeDescendant]=\"activeDescendant()\"\n [size]=\"size()\"\n (filterChange)=\"onFilterChange($event)\"></mona-filter-input>\n </div>\n}\n@let listRole = listService.role();\n@let isListbox = listRole === \"listbox\";\n@if (listService.virtualScrollOptions().enabled) {\n @if (listService.viewItems().length !== 0) {\n <cdk-virtual-scroll-viewport\n [itemSize]=\"listService.virtualScrollOptions().height\"\n [style.height]=\"viewportHeight()\">\n <ul\n [class]=\"innerListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"-1\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listRole\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-multiselectable]=\"\n (isListbox && listService.selectableOptions().mode === 'multiple') || null\n \">\n <ng-container *cdkVirtualFor=\"let item of listService.viewItems(); trackBy: trackByUid\">\n @if (item.isHeader) {\n <li\n [class]=\"groupHeaderClasses()\"\n [style]=\"listItemStyle()\"\n [id]=\"item.uid\"\n role=\"presentation\">\n <mona-list-item [item]=\"item\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </li>\n } @else {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ng-container>\n </ul>\n </cdk-virtual-scroll-viewport>\n } @else {\n <ng-container [ngTemplateOutlet]=\"emptyListTemplate\"></ng-container>\n }\n} @else {\n @if (listService.viewItems().length !== 0) {\n <ul\n [class]=\"innerListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"-1\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listRole\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-multiselectable]=\"(isListbox && listService.selectableOptions().mode === 'multiple') || null\">\n @for (section of viewSections(); track section.key) {\n @if (section.header; as header) {\n @if (isListbox) {\n <!-- A group of options, named by its header. -->\n <li role=\"none\" class=\"m-0 list-none p-0\">\n <ul role=\"group\" [attr.aria-labelledby]=\"header.uid\" class=\"m-0 list-none p-0\">\n <li\n [class]=\"groupHeaderClasses()\"\n [style]=\"listItemStyle()\"\n [id]=\"header.uid\"\n role=\"presentation\">\n <mona-list-item [item]=\"header\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </li>\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ul>\n </li>\n } @else {\n <!-- A nested list, named by its header. -->\n <li class=\"m-0 list-none p-0\">\n <div [class]=\"groupHeaderClasses()\" [style]=\"listItemStyle()\" [id]=\"header.uid\">\n <mona-list-item [item]=\"header\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </div>\n <ul role=\"list\" [attr.aria-labelledby]=\"header.uid\" class=\"m-0 list-none p-0\">\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ul>\n </li>\n }\n } @else {\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n }\n }\n </ul>\n } @else {\n <ng-container [ngTemplateOutlet]=\"emptyListTemplate\"></ng-container>\n }\n}\n@if (footerTemplate()) {\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n}\n\n<!-- An empty list keeps its named list element, so it stays in the accessibility tree, described by \"No data\". -->\n<ng-template #emptyListTemplate>\n <!-- The empty list element lies over the \"No data\" content, so that content keeps its place and the ring frames it. -->\n <div class=\"relative w-full h-full\">\n @if (noDataTemplate()) {\n <div [id]=\"noDataId\" class=\"contents\">\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </div>\n } @else {\n <mona-placeholder\n [id]=\"noDataId\"\n [text]=\"messages().noData\"\n class=\"w-full h-full flex items-center justify-center\"></mona-placeholder>\n }\n <ul\n [class]=\"emptyListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"0\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listService.role()\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-describedby]=\"noDataId\"></ul>\n </div>\n</ng-template>\n\n<ng-template #listItemTemplate let-item>\n <li\n [class]=\"listItemClass()\"\n [class.px-0.5]=\"true\"\n [style]=\"listItemStyle()\"\n [id]=\"item.uid\"\n [attr.data-uid]=\"item.uid\"\n (click)=\"onListItemClick(item)\"\n monaListItem\n [item]=\"item\">\n <mona-list-item [item]=\"item\" [template]=\"itemTemplate()\"></mona-list-item>\n </li>\n</ng-template>\n", dependencies: [{ kind: "component", type: FilterInputComponent, selector: "mona-filter-input", inputs: ["activeDescendant", "ariaControls", "ariaLabel", "autoFocus", "controls", "debounce", "filter", "placeholder", "size"], outputs: ["filterChange", "inputBlur", "inputFocus"] }, { kind: "component", type: ListItemComponent, selector: "mona-list-item", inputs: ["item", "template"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: ListItemDirective, selector: "li[monaListItem]", inputs: ["item"] }, { kind: "component", type: PlaceholderComponent, selector: "mona-placeholder", inputs: ["text", "class"] }, { kind: "component", type: CdkVirtualScrollViewport, selector: "cdk-virtual-scroll-viewport", inputs: ["orientation", "appendOnly"], outputs: ["scrolledIndexChange"] }, { kind: "directive", type: CdkFixedSizeVirtualScroll, selector: "cdk-virtual-scroll-viewport[itemSize]", inputs: ["itemSize", "minBufferPx", "maxBufferPx"] }, { kind: "directive", type: CdkVirtualForOf, selector: "[cdkVirtualFor][cdkVirtualForOf]", inputs: ["cdkVirtualForOf", "cdkVirtualForTrackBy", "cdkVirtualForTemplate", "cdkVirtualForTemplateCacheSize"] }] }); }
1806
- }
1807
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ListComponent, decorators: [{
1808
- type: Component,
1809
- args: [{ selector: "mona-list", imports: [
1810
- FilterInputComponent,
1811
- ListItemComponent,
1812
- NgTemplateOutlet,
1813
- ListItemDirective,
1814
- PlaceholderComponent,
1815
- CdkVirtualScrollViewport,
1816
- CdkFixedSizeVirtualScroll,
1817
- CdkVirtualForOf
1818
- ], host: {
1819
- "[attr.tabindex]": "hostTabIndex()",
1820
- "[class]": "classes()",
1821
- "[style.height]": "listHeight()",
1822
- "[style.max-height]": "listMaxHeight()",
1823
- "[style.max-width]": "listMaxWidth()",
1824
- "[style.width]": "listWidth()"
1825
- }, template: "@if (headerTemplate()) {\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n}\n@if (listService.filterableOptions().enabled && listService.filterInputVisible()) {\n <div class=\"p-2\">\n <mona-filter-input\n [filter]=\"listService.filterText()\"\n [debounce]=\"listService.filterableOptions().debounce\"\n [placeholder]=\"listService.filterPlaceholder()\"\n [ariaLabel]=\"messages().filterList\"\n [controls]=\"effectiveListId()\"\n [activeDescendant]=\"activeDescendant()\"\n [size]=\"size()\"\n (filterChange)=\"onFilterChange($event)\"></mona-filter-input>\n </div>\n}\n@let listRole = listService.role();\n@let isListbox = listRole === \"listbox\";\n@if (listService.virtualScrollOptions().enabled) {\n @if (listService.viewItems().length !== 0) {\n <cdk-virtual-scroll-viewport\n [itemSize]=\"listService.virtualScrollOptions().height\"\n [style.height]=\"viewportHeight()\">\n <ul\n [class]=\"innerListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"-1\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listRole\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-multiselectable]=\"\n (isListbox && listService.selectableOptions().mode === 'multiple') || null\n \">\n <ng-container *cdkVirtualFor=\"let item of listService.viewItems(); trackBy: trackByUid\">\n @if (item.isHeader) {\n <li\n [class]=\"groupHeaderClasses()\"\n [style]=\"listItemStyle()\"\n [id]=\"item.uid\"\n role=\"presentation\">\n <mona-list-item [item]=\"item\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </li>\n } @else {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ng-container>\n </ul>\n </cdk-virtual-scroll-viewport>\n } @else {\n <ng-container [ngTemplateOutlet]=\"emptyListTemplate\"></ng-container>\n }\n} @else {\n @if (listService.viewItems().length !== 0) {\n <ul\n [class]=\"innerListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"-1\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listRole\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-multiselectable]=\"(isListbox && listService.selectableOptions().mode === 'multiple') || null\">\n @for (section of viewSections(); track section.key) {\n @if (section.header; as header) {\n @if (isListbox) {\n <!-- A group of options, named by its header. -->\n <li role=\"none\" class=\"m-0 list-none p-0\">\n <ul role=\"group\" [attr.aria-labelledby]=\"header.uid\" class=\"m-0 list-none p-0\">\n <li\n [class]=\"groupHeaderClasses()\"\n [style]=\"listItemStyle()\"\n [id]=\"header.uid\"\n role=\"presentation\">\n <mona-list-item [item]=\"header\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </li>\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ul>\n </li>\n } @else {\n <!-- A nested list, named by its header. -->\n <li class=\"m-0 list-none p-0\">\n <div [class]=\"groupHeaderClasses()\" [style]=\"listItemStyle()\" [id]=\"header.uid\">\n <mona-list-item [item]=\"header\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </div>\n <ul role=\"list\" [attr.aria-labelledby]=\"header.uid\" class=\"m-0 list-none p-0\">\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ul>\n </li>\n }\n } @else {\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n }\n }\n </ul>\n } @else {\n <ng-container [ngTemplateOutlet]=\"emptyListTemplate\"></ng-container>\n }\n}\n@if (footerTemplate()) {\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n}\n\n<!-- An empty list keeps its named list element, so it stays in the accessibility tree, described by \"No data\". -->\n<ng-template #emptyListTemplate>\n <!-- The empty list element lies over the \"No data\" content, so that content keeps its place and the ring frames it. -->\n <div class=\"relative w-full h-full\">\n @if (noDataTemplate()) {\n <div [id]=\"noDataId\" class=\"contents\">\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </div>\n } @else {\n <mona-placeholder\n [id]=\"noDataId\"\n [text]=\"messages().noData\"\n class=\"w-full h-full flex items-center justify-center\"></mona-placeholder>\n }\n <ul\n [class]=\"emptyListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"0\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listService.role()\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-describedby]=\"noDataId\"></ul>\n </div>\n</ng-template>\n\n<ng-template #listItemTemplate let-item>\n <li\n [class]=\"listItemClass()\"\n [class.px-0.5]=\"true\"\n [style]=\"listItemStyle()\"\n [id]=\"item.uid\"\n [attr.data-uid]=\"item.uid\"\n (click)=\"onListItemClick(item)\"\n monaListItem\n [item]=\"item\">\n <mona-list-item [item]=\"item\" [template]=\"itemTemplate()\"></mona-list-item>\n </li>\n</ng-template>\n" }]
1826
- }], ctorParameters: () => [], propDecorators: { filterInput: [{ type: i0.ViewChild, args: [i0.forwardRef(() => FilterInputComponent), { isSignal: true }] }], filterInputElement: [{ type: i0.ViewChild, args: [i0.forwardRef(() => FilterInputComponent), { ...{ read: ElementRef }, isSignal: true }] }], footerTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListFooterTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], groupHeaderTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListGroupHeaderTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], headerTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListHeaderTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], itemTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListItemTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], noDataTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ListNoDataTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], virtualScrollViewport: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CdkVirtualScrollViewport), { isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabelledBy", required: false }] }], busy: [{ type: i0.Input, args: [{ isSignal: true, alias: "busy", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], focusOnMount: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusOnMount", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], itemActivate: [{ type: i0.Output, args: ["itemActivate"] }], itemSelect: [{ type: i0.Output, args: ["itemSelect"] }], listClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "listClass", required: false }] }], listId: [{ type: i0.Input, args: [{ isSignal: true, alias: "listId", required: false }] }], listItemClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "listItemClass", required: false }] }], listItemStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "listItemStyle", required: false }] }], listRole: [{ type: i0.Input, args: [{ isSignal: true, alias: "listRole", required: false }] }], listStyle: [{ type: i0.Input, args: [{ isSignal: true, alias: "listStyle", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], textField: [{ type: i0.Input, args: [{ isSignal: true, alias: "textField", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }] } });
1827
-
1828
- /**
1829
- * Lets a component that wraps a `mona-list-view` in its own template share its `ListService` with that list view.
1830
- * Provide it in `viewProviders` (`{ provide: LIST_VIEW_HOST_LIST_SERVICE, useExisting: ListService }`), so only the
1831
- * component's own list view sees it, never a list view placed in content the component projects or renders from a
1832
- * consumer's template. Without it, every list view has its own service.
1833
- */
985
+ var ListItemComponent = class ListItemComponent {
986
+ constructor() {
987
+ this.baseClass = computed(() => {
988
+ if (this.isHeader()) return ``;
989
+ return listItemBaseThemeVariants();
990
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
991
+ this.checkboxes = computed(() => {
992
+ return this.listService.selectableOptions().checkboxes && !this.isHeader();
993
+ }, ...ngDevMode ? [{ debugName: "checkboxes" }] : /* istanbul ignore next */ []);
994
+ this.dataItem = computed(() => this.item()?.data ?? null, ...ngDevMode ? [{ debugName: "dataItem" }] : /* istanbul ignore next */ []);
995
+ this.isHeader = computed(() => this.item()?.isHeader ?? false, ...ngDevMode ? [{ debugName: "isHeader" }] : /* istanbul ignore next */ []);
996
+ this.itemChecked = computed(() => this.listService.isSelected(this.item()), ...ngDevMode ? [{ debugName: "itemChecked" }] : /* istanbul ignore next */ []);
997
+ this.itemText = computed(() => {
998
+ const item = this.item();
999
+ if (item == null) return "";
1000
+ if (item.isHeader) return item.header;
1001
+ return this.listService.getItemText(item);
1002
+ }, ...ngDevMode ? [{ debugName: "itemText" }] : /* istanbul ignore next */ []);
1003
+ this.listService = inject(ListService);
1004
+ this.textClasses = computed(() => {
1005
+ if (this.isHeader()) {
1006
+ const hasTemplate = this.template() != null;
1007
+ const classes = listGroupHeaderTextThemeVariants({ hasTemplate });
1008
+ return twMerge(classes);
1009
+ }
1010
+ return ``;
1011
+ }, ...ngDevMode ? [{ debugName: "textClasses" }] : /* istanbul ignore next */ []);
1012
+ this.item = input.required(...ngDevMode ? [{ debugName: "item" }] : /* istanbul ignore next */ []);
1013
+ this.template = input(...ngDevMode ? [void 0, { debugName: "template" }] : /* istanbul ignore next */ []);
1014
+ }
1015
+ static {
1016
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1017
+ minVersion: "12.0.0",
1018
+ version: "22.2.6",
1019
+ ngImport: i0,
1020
+ type: ListItemComponent,
1021
+ deps: [],
1022
+ target: i0.ɵɵFactoryTarget.Component
1023
+ });
1024
+ }
1025
+ static {
1026
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1027
+ minVersion: "17.0.0",
1028
+ version: "22.2.6",
1029
+ type: ListItemComponent,
1030
+ isStandalone: true,
1031
+ selector: "mona-list-item",
1032
+ inputs: {
1033
+ item: {
1034
+ classPropertyName: "item",
1035
+ publicName: "item",
1036
+ isSignal: true,
1037
+ isRequired: true,
1038
+ transformFunction: null
1039
+ },
1040
+ template: {
1041
+ classPropertyName: "template",
1042
+ publicName: "template",
1043
+ isSignal: true,
1044
+ isRequired: false,
1045
+ transformFunction: null
1046
+ }
1047
+ },
1048
+ host: { properties: { "class": "baseClass()" } },
1049
+ ngImport: i0,
1050
+ template: "@if (checkboxes()) {\n <!-- Visual only: the option row owns selection, so the checkbox is inert (not focusable, clicks reach the row). -->\n <input type=\"checkbox\" [checked]=\"itemChecked()\" monaCheckbox class=\"aspect-square\" inert aria-hidden=\"true\" />\n}\n\n@if (template()) {\n <ng-container [ngTemplateOutlet]=\"template()\" [ngTemplateOutletContext]=\"{ $implicit: dataItem() }\"></ng-container>\n} @else {\n <span [class]=\"textClasses()\">{{ itemText() }}</span>\n}\n",
1051
+ dependencies: [{
1052
+ kind: "directive",
1053
+ type: NgTemplateOutlet,
1054
+ selector: "[ngTemplateOutlet]",
1055
+ inputs: [
1056
+ "ngTemplateOutletContext",
1057
+ "ngTemplateOutlet",
1058
+ "ngTemplateOutletInjector"
1059
+ ]
1060
+ }, {
1061
+ kind: "directive",
1062
+ type: CheckboxDirective,
1063
+ selector: "input[type='checkbox'][monaCheckbox]",
1064
+ inputs: [
1065
+ "invalid",
1066
+ "rounded",
1067
+ "touched",
1068
+ "class"
1069
+ ]
1070
+ }]
1071
+ });
1072
+ }
1073
+ };
1074
+ i0.ɵɵngDeclareClassMetadata({
1075
+ minVersion: "12.0.0",
1076
+ version: "22.2.6",
1077
+ ngImport: i0,
1078
+ type: ListItemComponent,
1079
+ decorators: [{
1080
+ type: Component,
1081
+ args: [{
1082
+ selector: "mona-list-item",
1083
+ imports: [NgTemplateOutlet, CheckboxDirective],
1084
+ host: { "[class]": "baseClass()" },
1085
+ template: "@if (checkboxes()) {\n <!-- Visual only: the option row owns selection, so the checkbox is inert (not focusable, clicks reach the row). -->\n <input type=\"checkbox\" [checked]=\"itemChecked()\" monaCheckbox class=\"aspect-square\" inert aria-hidden=\"true\" />\n}\n\n@if (template()) {\n <ng-container [ngTemplateOutlet]=\"template()\" [ngTemplateOutletContext]=\"{ $implicit: dataItem() }\"></ng-container>\n} @else {\n <span [class]=\"textClasses()\">{{ itemText() }}</span>\n}\n"
1086
+ }]
1087
+ }],
1088
+ propDecorators: {
1089
+ item: [{
1090
+ type: i0.Input,
1091
+ args: [{
1092
+ isSignal: true,
1093
+ alias: "item",
1094
+ required: true
1095
+ }]
1096
+ }],
1097
+ template: [{
1098
+ type: i0.Input,
1099
+ args: [{
1100
+ isSignal: true,
1101
+ alias: "template",
1102
+ required: false
1103
+ }]
1104
+ }]
1105
+ }
1106
+ });
1107
+ var ListComponent = class ListComponent {
1108
+ #destroyRef;
1109
+ #generatedListId;
1110
+ #hostElementRef;
1111
+ #i18n;
1112
+ #renderedRange;
1113
+ #typeaheadKey$;
1114
+ #focusedOption;
1115
+ constructor() {
1116
+ this.#destroyRef = inject(DestroyRef);
1117
+ this.#generatedListId = createElementControlId();
1118
+ this.#hostElementRef = inject(ElementRef);
1119
+ this.#i18n = inject(MonaI18nService);
1120
+ this.#renderedRange = signal(null, ...ngDevMode ? [{ debugName: "#renderedRange" }] : /* istanbul ignore next */ []);
1121
+ this.#typeaheadKey$ = new Subject();
1122
+ this.#focusedOption = null;
1123
+ this.filterInput = viewChild(FilterInputComponent, ...ngDevMode ? [{ debugName: "filterInput" }] : /* istanbul ignore next */ []);
1124
+ this.filterInputElement = viewChild(FilterInputComponent, {
1125
+ ...ngDevMode ? { debugName: "filterInputElement" } : /* istanbul ignore next */ {},
1126
+ read: ElementRef
1127
+ });
1128
+ this.activeDescendant = computed(() => {
1129
+ const item = this.listService.highlightedItem();
1130
+ return item && !item.isHeader ? item.uid : null;
1131
+ }, ...ngDevMode ? [{ debugName: "activeDescendant" }] : /* istanbul ignore next */ []);
1132
+ this.classes = computed(() => {
1133
+ const classes = listThemeVariants();
1134
+ return twMerge(classes);
1135
+ }, ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
1136
+ this.effectiveListId = computed(() => this.listId() || this.#generatedListId, ...ngDevMode ? [{ debugName: "effectiveListId" }] : /* istanbul ignore next */ []);
1137
+ this.emptyListClasses = computed(() => twMerge(this.innerListClasses(), "absolute inset-0 focus-visible:inset-ring-2 focus-visible:inset-ring-focus-indicator"), ...ngDevMode ? [{ debugName: "emptyListClasses" }] : /* istanbul ignore next */ []);
1138
+ this.footerTemplate = contentChild(ListFooterTemplateDirective, {
1139
+ ...ngDevMode ? { debugName: "footerTemplate" } : /* istanbul ignore next */ {},
1140
+ read: TemplateRef
1141
+ });
1142
+ this.groupHeaderClasses = computed(() => {
1143
+ const listItemClass = this.listItemClass();
1144
+ const hasTemplate = this.groupHeaderTemplate() != null;
1145
+ const classes = listGroupHeaderThemeVariants({ hasTemplate });
1146
+ return twMerge(classes, listItemClass);
1147
+ }, ...ngDevMode ? [{ debugName: "groupHeaderClasses" }] : /* istanbul ignore next */ []);
1148
+ this.groupHeaderTemplate = contentChild(ListGroupHeaderTemplateDirective, {
1149
+ ...ngDevMode ? { debugName: "groupHeaderTemplate" } : /* istanbul ignore next */ {},
1150
+ read: TemplateRef
1151
+ });
1152
+ this.headerTemplate = contentChild(ListHeaderTemplateDirective, {
1153
+ ...ngDevMode ? { debugName: "headerTemplate" } : /* istanbul ignore next */ {},
1154
+ read: TemplateRef
1155
+ });
1156
+ this.hostTabIndex = computed(() => {
1157
+ const item = this.listService.focusableItem();
1158
+ if (!item) return this.listService.viewItems().isEmpty() ? -1 : 0;
1159
+ if (!this.listService.virtualScrollOptions().enabled) return -1;
1160
+ const range = this.#renderedRange();
1161
+ const index = this.listService.viewItems().toArray().indexOf(item);
1162
+ return range && index >= range.start && index < range.end ? -1 : 0;
1163
+ }, ...ngDevMode ? [{ debugName: "hostTabIndex" }] : /* istanbul ignore next */ []);
1164
+ this.innerListClasses = computed(() => {
1165
+ const classes = listInnerListThemeVariants();
1166
+ const listClass = this.listClass();
1167
+ return twMerge(classes, listClass);
1168
+ }, ...ngDevMode ? [{ debugName: "innerListClasses" }] : /* istanbul ignore next */ []);
1169
+ this.itemTemplate = contentChild(ListItemTemplateDirective, {
1170
+ ...ngDevMode ? { debugName: "itemTemplate" } : /* istanbul ignore next */ {},
1171
+ read: TemplateRef
1172
+ });
1173
+ this.listHeight = computed(() => {
1174
+ const height = this.height();
1175
+ if (height == null) return;
1176
+ if (typeof height === "number") return `${height}px`;
1177
+ return height;
1178
+ }, ...ngDevMode ? [{ debugName: "listHeight" }] : /* istanbul ignore next */ []);
1179
+ this.listMaxHeight = computed(() => {
1180
+ const maxHeight = this.maxHeight();
1181
+ if (maxHeight == null) return;
1182
+ if (typeof maxHeight === "number") return `${maxHeight}px`;
1183
+ return maxHeight;
1184
+ }, ...ngDevMode ? [{ debugName: "listMaxHeight" }] : /* istanbul ignore next */ []);
1185
+ this.listMaxWidth = computed(() => {
1186
+ const maxWidth = this.maxWidth();
1187
+ if (maxWidth == null) return;
1188
+ if (typeof maxWidth === "number") return `${maxWidth}px`;
1189
+ return maxWidth;
1190
+ }, ...ngDevMode ? [{ debugName: "listMaxWidth" }] : /* istanbul ignore next */ []);
1191
+ this.listService = inject(ListService);
1192
+ this.listWidth = computed(() => {
1193
+ const width = this.width();
1194
+ if (width == null) return;
1195
+ if (typeof width === "number") return `${width}px`;
1196
+ return width;
1197
+ }, ...ngDevMode ? [{ debugName: "listWidth" }] : /* istanbul ignore next */ []);
1198
+ this.messages = this.#i18n.componentMessages("list", LIST_DEFAULT_MESSAGES);
1199
+ this.noDataId = `${this.#generatedListId}-no-data`;
1200
+ this.noDataTemplate = contentChild(ListNoDataTemplateDirective, {
1201
+ ...ngDevMode ? { debugName: "noDataTemplate" } : /* istanbul ignore next */ {},
1202
+ read: TemplateRef
1203
+ });
1204
+ this.viewSections = computed(() => {
1205
+ const sections = [];
1206
+ for (const item of this.listService.viewItems()) {
1207
+ if (item.isHeader) {
1208
+ sections.push({
1209
+ header: item,
1210
+ items: [],
1211
+ key: item.uid
1212
+ });
1213
+ continue;
1214
+ }
1215
+ if (sections.length === 0) sections.push({
1216
+ header: null,
1217
+ items: [],
1218
+ key: ""
1219
+ });
1220
+ sections[sections.length - 1].items.push(item);
1221
+ }
1222
+ return sections;
1223
+ }, ...ngDevMode ? [{ debugName: "viewSections" }] : /* istanbul ignore next */ []);
1224
+ this.viewportHeight = computed(() => {
1225
+ const listHeight = this.listHeight();
1226
+ if (listHeight) return listHeight;
1227
+ const items = this.listService.viewItems().size();
1228
+ const headerItems = this.listService.viewItems().where((i) => i.isHeader).count();
1229
+ return `${items * (this.listService.virtualScrollOptions().height ?? 28) + headerItems * 2}px`;
1230
+ }, ...ngDevMode ? [{ debugName: "viewportHeight" }] : /* istanbul ignore next */ []);
1231
+ this.virtualScrollViewport = viewChild(CdkVirtualScrollViewport, ...ngDevMode ? [{ debugName: "virtualScrollViewport" }] : /* istanbul ignore next */ []);
1232
+ this.ariaLabel = input("", ...ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []);
1233
+ this.ariaLabelledBy = input("", ...ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []);
1234
+ this.busy = input(false, {
1235
+ ...ngDevMode ? { debugName: "busy" } : /* istanbul ignore next */ {},
1236
+ transform: booleanAttribute
1237
+ });
1238
+ this.data = input(null, ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
1239
+ this.focusOnMount = input(true, ...ngDevMode ? [{ debugName: "focusOnMount" }] : /* istanbul ignore next */ []);
1240
+ this.height = input(void 0, ...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
1241
+ this.itemActivate = output();
1242
+ this.itemSelect = output();
1243
+ this.listClass = input("", ...ngDevMode ? [{ debugName: "listClass" }] : /* istanbul ignore next */ []);
1244
+ this.listId = input("", ...ngDevMode ? [{ debugName: "listId" }] : /* istanbul ignore next */ []);
1245
+ this.listItemClass = input("", ...ngDevMode ? [{ debugName: "listItemClass" }] : /* istanbul ignore next */ []);
1246
+ this.listItemStyle = input({}, ...ngDevMode ? [{ debugName: "listItemStyle" }] : /* istanbul ignore next */ []);
1247
+ this.listRole = input("listbox", ...ngDevMode ? [{ debugName: "listRole" }] : /* istanbul ignore next */ []);
1248
+ this.listStyle = input({}, ...ngDevMode ? [{ debugName: "listStyle" }] : /* istanbul ignore next */ []);
1249
+ this.maxHeight = input(...ngDevMode ? [void 0, { debugName: "maxHeight" }] : /* istanbul ignore next */ []);
1250
+ this.maxWidth = input(...ngDevMode ? [void 0, { debugName: "maxWidth" }] : /* istanbul ignore next */ []);
1251
+ this.size = input("medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
1252
+ this.textField = input(null, ...ngDevMode ? [{ debugName: "textField" }] : /* istanbul ignore next */ []);
1253
+ this.width = input(...ngDevMode ? [void 0, { debugName: "width" }] : /* istanbul ignore next */ []);
1254
+ effect(() => {
1255
+ const textField = this.textField();
1256
+ untracked(() => {
1257
+ if (textField != null) this.listService.setTextField(textField);
1258
+ });
1259
+ });
1260
+ effect(() => {
1261
+ const data = this.data();
1262
+ untracked(() => {
1263
+ if (data != null) this.listService.setData(data);
1264
+ });
1265
+ });
1266
+ effect(() => {
1267
+ const listRole = this.listRole();
1268
+ untracked(() => this.listService.role.set(listRole));
1269
+ });
1270
+ effect((onCleanup) => {
1271
+ const viewport = this.virtualScrollViewport();
1272
+ if (!viewport) {
1273
+ this.#renderedRange.set(null);
1274
+ return;
1275
+ }
1276
+ const subscription = viewport.renderedRangeStream.subscribe((range) => this.#renderedRange.set(range));
1277
+ onCleanup(() => subscription.unsubscribe());
1278
+ });
1279
+ afterRenderEffect({ write: () => {
1280
+ this.listService.viewItems();
1281
+ untracked(() => this.restoreFocusAfterRemoval());
1282
+ } });
1283
+ afterNextRender({ read: () => this.setInitialSelectionOrFocus() });
1284
+ }
1285
+ ngOnInit() {
1286
+ this.setSubscriptions();
1287
+ }
1288
+ onFilterChange(event) {
1289
+ this.listService.filterChange$.next(event);
1290
+ if (!event.isDefaultPrevented()) this.listService.setFilter(event.filter);
1291
+ }
1292
+ onListItemClick(item) {
1293
+ this.toggleItem(item);
1294
+ if (!item.isHeader && !this.listService.isDisabled(item)) this.itemActivate.emit(item);
1295
+ }
1296
+ trackByUid(_, item) {
1297
+ return item.uid;
1298
+ }
1299
+ cycleThroughMatchedItems(buffer) {
1300
+ const nextItem = this.listService.cycleThroughMatchedItems(buffer);
1301
+ if (nextItem) {
1302
+ const navigationMode = this.listService.navigableOptions().mode;
1303
+ const selectableOptions = this.listService.selectableOptions();
1304
+ this.listService.highlightedItem.set(nextItem);
1305
+ if (navigationMode === "select" && selectableOptions.enabled && selectableOptions.mode !== "multiple") {
1306
+ this.selectItem(nextItem);
1307
+ this.itemSelect.emit({
1308
+ item: nextItem,
1309
+ source: {
1310
+ via: "keyboard",
1311
+ key: buffer
1312
+ }
1313
+ });
1314
+ }
1315
+ this.scrollToItem(nextItem, true, "instant");
1316
+ }
1317
+ }
1318
+ focusEmptyList() {
1319
+ const id = this.effectiveListId();
1320
+ Array.from(this.#hostElementRef.nativeElement.querySelectorAll("ul")).find((element) => element.id === id)?.focus({ preventScroll: true });
1321
+ }
1322
+ focusToItem(item) {
1323
+ if (this.listService.navigableOptions().enabled) this.listService.highlightedItem.set(item);
1324
+ this.scrollToItem(item, this.filterInput() == null);
1325
+ }
1326
+ handleMultipleSelectionKeys(event) {
1327
+ const selectableOptions = this.listService.selectableOptions();
1328
+ if (!selectableOptions.enabled || selectableOptions.mode !== "multiple") return false;
1329
+ if (event.key === " " && !event.ctrlKey && !event.metaKey && !event.altKey) {
1330
+ const highlightedItem = this.listService.highlightedItem();
1331
+ if (highlightedItem && !this.listService.isDisabled(highlightedItem)) {
1332
+ this.selectItem(highlightedItem);
1333
+ this.itemSelect.emit({
1334
+ item: highlightedItem,
1335
+ source: {
1336
+ via: "keyboard",
1337
+ key: event.key
1338
+ }
1339
+ });
1340
+ }
1341
+ return true;
1342
+ }
1343
+ if ((event.ctrlKey || event.metaKey) && !event.altKey && event.key.toLowerCase() === "a") {
1344
+ if (this.listService.selectAllItems()) this.listService.selectedKeysChange$.next(this.listService.selectedKeys().toArray());
1345
+ return true;
1346
+ }
1347
+ return false;
1348
+ }
1349
+ handleNavigation(key) {
1350
+ const direction = getListNavigationDirection(key);
1351
+ if (!direction) return;
1352
+ if (direction === "pageup" || direction === "pagedown") {
1353
+ this.handlePageScroll(direction);
1354
+ return;
1355
+ }
1356
+ const navigableOptions = this.listService.navigableOptions();
1357
+ const selectableOptions = this.listService.selectableOptions();
1358
+ const previousSelectedItems = this.listService.selectedListItems();
1359
+ const filterInput = this.filterInput();
1360
+ const item = this.listService.navigate(direction, navigableOptions.mode, filterInput == null);
1361
+ if (item && navigableOptions.mode === "select" && selectableOptions.enabled) {
1362
+ this.itemSelect.emit({
1363
+ item,
1364
+ source: {
1365
+ via: "keyboard",
1366
+ key
1367
+ }
1368
+ });
1369
+ if (previousSelectedItems.contains(item)) return;
1370
+ this.listService.selectedKeysChange$.next(this.listService.selectedKeys().toArray());
1371
+ }
1372
+ if (filterInput) filterInput.focus();
1373
+ }
1374
+ handlePageScroll(direction) {
1375
+ const listElement = this.#hostElementRef.nativeElement.firstElementChild;
1376
+ switch (direction) {
1377
+ case "pagedown": {
1378
+ const virtualScrollViewport = this.virtualScrollViewport();
1379
+ if (virtualScrollViewport) {
1380
+ const scrollOffset = virtualScrollViewport.measureScrollOffset();
1381
+ virtualScrollViewport.scrollToOffset(scrollOffset + virtualScrollViewport.getViewportSize(), "smooth");
1382
+ } else {
1383
+ const top = listElement.scrollTop + listElement.clientHeight * .8;
1384
+ listElement.scrollTo({
1385
+ top,
1386
+ behavior: "smooth"
1387
+ });
1388
+ }
1389
+ break;
1390
+ }
1391
+ case "pageup": {
1392
+ const virtualScrollViewport = this.virtualScrollViewport();
1393
+ if (virtualScrollViewport) {
1394
+ const scrollOffset = virtualScrollViewport.measureScrollOffset();
1395
+ virtualScrollViewport.scrollToOffset(scrollOffset - virtualScrollViewport.getViewportSize(), "smooth");
1396
+ } else {
1397
+ const top = listElement.scrollTop - listElement.clientHeight * .8;
1398
+ listElement.scrollTo({
1399
+ top,
1400
+ behavior: "smooth"
1401
+ });
1402
+ }
1403
+ break;
1404
+ }
1405
+ }
1406
+ }
1407
+ isListKeyTarget(event) {
1408
+ const host = this.#hostElementRef.nativeElement;
1409
+ const target = event.target;
1410
+ if (!(target instanceof HTMLElement) || target === host) return true;
1411
+ if (this.filterInputElement()?.nativeElement.contains(target)) return true;
1412
+ return target.closest("mona-list") === host && (target.hasAttribute("data-uid") || target.id === this.effectiveListId());
1413
+ }
1414
+ rememberFocusedOption(target) {
1415
+ if (!(target instanceof HTMLElement) || target.closest("mona-list") !== this.#hostElementRef.nativeElement) return;
1416
+ const uid = target.getAttribute("data-uid");
1417
+ if (uid == null) return;
1418
+ const options = this.listService.viewItems().where((i) => !i.isHeader).toArray();
1419
+ const index = options.findIndex((i) => i.uid === uid);
1420
+ this.#focusedOption = index < 0 ? null : {
1421
+ index,
1422
+ uid
1423
+ };
1424
+ if (index >= 0 && this.listService.navigableOptions().enabled && this.listService.highlightedItem() !== options[index]) this.listService.highlightedItem.set(options[index]);
1425
+ }
1426
+ restoreFocusAfterRemoval() {
1427
+ const focused = this.#focusedOption;
1428
+ if (!focused) return;
1429
+ const options = this.listService.viewItems().where((i) => !i.isHeader).toArray();
1430
+ if (options.some((i) => i.uid === focused.uid)) return;
1431
+ const activeElement = document.activeElement;
1432
+ if (activeElement && activeElement !== document.body && this.#hostElementRef.nativeElement.contains(activeElement)) return;
1433
+ if (activeElement && activeElement !== document.body) {
1434
+ this.#focusedOption = null;
1435
+ return;
1436
+ }
1437
+ const enabled = options.filter((i) => !this.listService.isDisabled(i));
1438
+ const next = enabled[Math.min(focused.index, enabled.length - 1)];
1439
+ if (!next) {
1440
+ this.#focusedOption = null;
1441
+ this.#hostElementRef.nativeElement.focus();
1442
+ return;
1443
+ }
1444
+ this.focusToItem(next);
1445
+ }
1446
+ scrollToItem(item, focus, behavior = "auto") {
1447
+ const element = this.#hostElementRef.nativeElement.querySelector(`[data-uid="${item.uid}"]`);
1448
+ if (element) {
1449
+ element.scrollIntoView({
1450
+ block: "nearest",
1451
+ behavior
1452
+ });
1453
+ if (focus) element.focus({ preventScroll: true });
1454
+ } else if (this.listService.virtualScrollOptions().enabled) {
1455
+ const index = this.listService.viewItems().toList().indexOf(item);
1456
+ const itemHeight = this.listService.virtualScrollOptions().height ?? 28;
1457
+ const rect = this.#hostElementRef.nativeElement.getBoundingClientRect();
1458
+ const offset = itemHeight * index - rect.height / 2;
1459
+ asyncScheduler.schedule(() => {
1460
+ this.virtualScrollViewport()?.scrollToOffset(offset, behavior);
1461
+ const scrolledElement = this.#hostElementRef.nativeElement.querySelector(`[data-uid="${item.uid}"]`);
1462
+ if (scrolledElement && focus) scrolledElement.focus({ preventScroll: true });
1463
+ });
1464
+ }
1465
+ }
1466
+ selectItem(item) {
1467
+ const selectedItems = this.listService.selectedListItems();
1468
+ const options = this.listService.selectableOptions();
1469
+ if (!options.enabled || this.listService.isDisabled(item)) return;
1470
+ if (options.mode === "single" && !selectedItems.contains(item) || options.mode === "single" && options.toggleable || options.mode === "multiple" || options.mode === "single" && selectedItems.size() > 1) {
1471
+ this.listService.selectItem(item);
1472
+ this.listService.highlightedItem.set(item);
1473
+ this.listService.selectedKeysChange$.next(this.listService.selectedKeys().toArray());
1474
+ }
1475
+ }
1476
+ setInitialSelectionOrFocus() {
1477
+ if (!this.focusOnMount()) return;
1478
+ const selectedItem = this.listService.selectedListItems().lastOrDefault();
1479
+ if (selectedItem) {
1480
+ this.focusToItem(selectedItem);
1481
+ return;
1482
+ }
1483
+ const firstItem = this.listService.viewItems().where((i) => !i.isHeader && !this.listService.isDisabled(i)).firstOrDefault();
1484
+ if (firstItem) this.focusToItem(firstItem);
1485
+ }
1486
+ setKeyboardEvents() {
1487
+ fromEvent(this.#hostElementRef.nativeElement, "keydown").pipe(takeUntilDestroyed(this.#destroyRef), filter((event) => event.key === "Enter" && !event.isComposing && this.isListKeyTarget(event)), tap((event) => event.preventDefault())).subscribe((event) => {
1488
+ const highlightedItem = this.listService.highlightedItem();
1489
+ const selectedItem = this.listService.selectedListItems().firstOrDefault();
1490
+ const source = {
1491
+ via: "keyboard",
1492
+ key: event.key
1493
+ };
1494
+ const item = highlightedItem ?? selectedItem;
1495
+ if (item) {
1496
+ this.selectItem(item);
1497
+ this.itemSelect.emit({
1498
+ item,
1499
+ source
1500
+ });
1501
+ if (!item.isHeader && !this.listService.isDisabled(item)) this.itemActivate.emit(item);
1502
+ }
1503
+ });
1504
+ }
1505
+ setNavigationEvents() {
1506
+ fromEvent(this.#hostElementRef.nativeElement, "keydown").pipe(takeUntilDestroyed(this.#destroyRef), filter((event) => this.listService.navigableOptions().enabled && this.isListKeyTarget(event))).subscribe((event) => {
1507
+ if (this.handleMultipleSelectionKeys(event)) {
1508
+ event.preventDefault();
1509
+ return;
1510
+ }
1511
+ if (isTypeaheadKey(event.key, event)) {
1512
+ event.preventDefault();
1513
+ this.#typeaheadKey$.next(event.key);
1514
+ return;
1515
+ }
1516
+ if (getListNavigationDirection(event.key) == null || event.altKey) return;
1517
+ event.preventDefault();
1518
+ this.#typeaheadKey$.next("");
1519
+ this.handleNavigation(event.key);
1520
+ });
1521
+ }
1522
+ setSubscriptions() {
1523
+ this.setNavigationEvents();
1524
+ this.setKeyboardEvents();
1525
+ this.setTypeaheadSubscription();
1526
+ this.listService.scrollToItem$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => this.scrollToItem(event.item, event.focus));
1527
+ this.listService.focus$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
1528
+ this.#hostElementRef.nativeElement.focus();
1529
+ this.setInitialSelectionOrFocus();
1530
+ });
1531
+ fromEvent(this.#hostElementRef.nativeElement, "focus").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
1532
+ const previous = event.relatedTarget;
1533
+ if (previous && this.#hostElementRef.nativeElement.contains(previous)) return;
1534
+ if (this.listService.viewItems().isEmpty()) {
1535
+ this.focusEmptyList();
1536
+ return;
1537
+ }
1538
+ if (this.focusOnMount()) {
1539
+ this.setInitialSelectionOrFocus();
1540
+ return;
1541
+ }
1542
+ const item = this.listService.focusableItem();
1543
+ if (item) this.focusToItem(item);
1544
+ });
1545
+ fromEvent(this.#hostElementRef.nativeElement, "focusin").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => this.rememberFocusedOption(event.target));
1546
+ fromEvent(this.#hostElementRef.nativeElement, "focusout").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
1547
+ const next = event.relatedTarget;
1548
+ if (next && this.#hostElementRef.nativeElement.contains(next)) return;
1549
+ this.#focusedOption = null;
1550
+ this.listService.highlightedItem.set(null);
1551
+ });
1552
+ }
1553
+ setTypeaheadSubscription() {
1554
+ setupTypeahead(this.#typeaheadKey$).pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((buffer) => this.cycleThroughMatchedItems(buffer));
1555
+ }
1556
+ toggleItem(item) {
1557
+ this.listService.highlightedItem.set(item);
1558
+ if (!this.listService.selectableOptions().enabled) return;
1559
+ this.selectItem(item);
1560
+ this.itemSelect.emit({
1561
+ item,
1562
+ source: { via: "mouse" }
1563
+ });
1564
+ }
1565
+ static {
1566
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1567
+ minVersion: "12.0.0",
1568
+ version: "22.2.6",
1569
+ ngImport: i0,
1570
+ type: ListComponent,
1571
+ deps: [],
1572
+ target: i0.ɵɵFactoryTarget.Component
1573
+ });
1574
+ }
1575
+ static {
1576
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1577
+ minVersion: "17.0.0",
1578
+ version: "22.2.6",
1579
+ type: ListComponent,
1580
+ isStandalone: true,
1581
+ selector: "mona-list",
1582
+ inputs: {
1583
+ ariaLabel: {
1584
+ classPropertyName: "ariaLabel",
1585
+ publicName: "ariaLabel",
1586
+ isSignal: true,
1587
+ isRequired: false,
1588
+ transformFunction: null
1589
+ },
1590
+ ariaLabelledBy: {
1591
+ classPropertyName: "ariaLabelledBy",
1592
+ publicName: "ariaLabelledBy",
1593
+ isSignal: true,
1594
+ isRequired: false,
1595
+ transformFunction: null
1596
+ },
1597
+ busy: {
1598
+ classPropertyName: "busy",
1599
+ publicName: "busy",
1600
+ isSignal: true,
1601
+ isRequired: false,
1602
+ transformFunction: null
1603
+ },
1604
+ data: {
1605
+ classPropertyName: "data",
1606
+ publicName: "data",
1607
+ isSignal: true,
1608
+ isRequired: false,
1609
+ transformFunction: null
1610
+ },
1611
+ focusOnMount: {
1612
+ classPropertyName: "focusOnMount",
1613
+ publicName: "focusOnMount",
1614
+ isSignal: true,
1615
+ isRequired: false,
1616
+ transformFunction: null
1617
+ },
1618
+ height: {
1619
+ classPropertyName: "height",
1620
+ publicName: "height",
1621
+ isSignal: true,
1622
+ isRequired: false,
1623
+ transformFunction: null
1624
+ },
1625
+ listClass: {
1626
+ classPropertyName: "listClass",
1627
+ publicName: "listClass",
1628
+ isSignal: true,
1629
+ isRequired: false,
1630
+ transformFunction: null
1631
+ },
1632
+ listId: {
1633
+ classPropertyName: "listId",
1634
+ publicName: "listId",
1635
+ isSignal: true,
1636
+ isRequired: false,
1637
+ transformFunction: null
1638
+ },
1639
+ listItemClass: {
1640
+ classPropertyName: "listItemClass",
1641
+ publicName: "listItemClass",
1642
+ isSignal: true,
1643
+ isRequired: false,
1644
+ transformFunction: null
1645
+ },
1646
+ listItemStyle: {
1647
+ classPropertyName: "listItemStyle",
1648
+ publicName: "listItemStyle",
1649
+ isSignal: true,
1650
+ isRequired: false,
1651
+ transformFunction: null
1652
+ },
1653
+ listRole: {
1654
+ classPropertyName: "listRole",
1655
+ publicName: "listRole",
1656
+ isSignal: true,
1657
+ isRequired: false,
1658
+ transformFunction: null
1659
+ },
1660
+ listStyle: {
1661
+ classPropertyName: "listStyle",
1662
+ publicName: "listStyle",
1663
+ isSignal: true,
1664
+ isRequired: false,
1665
+ transformFunction: null
1666
+ },
1667
+ maxHeight: {
1668
+ classPropertyName: "maxHeight",
1669
+ publicName: "maxHeight",
1670
+ isSignal: true,
1671
+ isRequired: false,
1672
+ transformFunction: null
1673
+ },
1674
+ maxWidth: {
1675
+ classPropertyName: "maxWidth",
1676
+ publicName: "maxWidth",
1677
+ isSignal: true,
1678
+ isRequired: false,
1679
+ transformFunction: null
1680
+ },
1681
+ size: {
1682
+ classPropertyName: "size",
1683
+ publicName: "size",
1684
+ isSignal: true,
1685
+ isRequired: false,
1686
+ transformFunction: null
1687
+ },
1688
+ textField: {
1689
+ classPropertyName: "textField",
1690
+ publicName: "textField",
1691
+ isSignal: true,
1692
+ isRequired: false,
1693
+ transformFunction: null
1694
+ },
1695
+ width: {
1696
+ classPropertyName: "width",
1697
+ publicName: "width",
1698
+ isSignal: true,
1699
+ isRequired: false,
1700
+ transformFunction: null
1701
+ }
1702
+ },
1703
+ outputs: {
1704
+ itemActivate: "itemActivate",
1705
+ itemSelect: "itemSelect"
1706
+ },
1707
+ host: { properties: {
1708
+ "attr.tabindex": "hostTabIndex()",
1709
+ "class": "classes()",
1710
+ "style.height": "listHeight()",
1711
+ "style.max-height": "listMaxHeight()",
1712
+ "style.max-width": "listMaxWidth()",
1713
+ "style.width": "listWidth()"
1714
+ } },
1715
+ queries: [
1716
+ {
1717
+ propertyName: "footerTemplate",
1718
+ first: true,
1719
+ predicate: ListFooterTemplateDirective,
1720
+ descendants: true,
1721
+ read: TemplateRef,
1722
+ isSignal: true
1723
+ },
1724
+ {
1725
+ propertyName: "groupHeaderTemplate",
1726
+ first: true,
1727
+ predicate: ListGroupHeaderTemplateDirective,
1728
+ descendants: true,
1729
+ read: TemplateRef,
1730
+ isSignal: true
1731
+ },
1732
+ {
1733
+ propertyName: "headerTemplate",
1734
+ first: true,
1735
+ predicate: ListHeaderTemplateDirective,
1736
+ descendants: true,
1737
+ read: TemplateRef,
1738
+ isSignal: true
1739
+ },
1740
+ {
1741
+ propertyName: "itemTemplate",
1742
+ first: true,
1743
+ predicate: ListItemTemplateDirective,
1744
+ descendants: true,
1745
+ read: TemplateRef,
1746
+ isSignal: true
1747
+ },
1748
+ {
1749
+ propertyName: "noDataTemplate",
1750
+ first: true,
1751
+ predicate: ListNoDataTemplateDirective,
1752
+ descendants: true,
1753
+ read: TemplateRef,
1754
+ isSignal: true
1755
+ }
1756
+ ],
1757
+ viewQueries: [
1758
+ {
1759
+ propertyName: "filterInput",
1760
+ first: true,
1761
+ predicate: FilterInputComponent,
1762
+ descendants: true,
1763
+ isSignal: true
1764
+ },
1765
+ {
1766
+ propertyName: "filterInputElement",
1767
+ first: true,
1768
+ predicate: FilterInputComponent,
1769
+ descendants: true,
1770
+ read: ElementRef,
1771
+ isSignal: true
1772
+ },
1773
+ {
1774
+ propertyName: "virtualScrollViewport",
1775
+ first: true,
1776
+ predicate: CdkVirtualScrollViewport,
1777
+ descendants: true,
1778
+ isSignal: true
1779
+ }
1780
+ ],
1781
+ ngImport: i0,
1782
+ template: "@if (headerTemplate()) {\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n}\n@if (listService.filterableOptions().enabled && listService.filterInputVisible()) {\n <div class=\"p-2\">\n <mona-filter-input\n [filter]=\"listService.filterText()\"\n [debounce]=\"listService.filterableOptions().debounce\"\n [placeholder]=\"listService.filterPlaceholder()\"\n [ariaLabel]=\"messages().filterList\"\n [controls]=\"effectiveListId()\"\n [activeDescendant]=\"activeDescendant()\"\n [size]=\"size()\"\n (filterChange)=\"onFilterChange($event)\"></mona-filter-input>\n </div>\n}\n@let listRole = listService.role();\n@let isListbox = listRole === \"listbox\";\n@if (listService.virtualScrollOptions().enabled) {\n @if (listService.viewItems().length !== 0) {\n <cdk-virtual-scroll-viewport\n [itemSize]=\"listService.virtualScrollOptions().height\"\n [style.height]=\"viewportHeight()\">\n <ul\n [class]=\"innerListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"-1\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listRole\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-multiselectable]=\"\n (isListbox && listService.selectableOptions().mode === 'multiple') || null\n \">\n <ng-container *cdkVirtualFor=\"let item of listService.viewItems(); trackBy: trackByUid\">\n @if (item.isHeader) {\n <li\n [class]=\"groupHeaderClasses()\"\n [style]=\"listItemStyle()\"\n [id]=\"item.uid\"\n role=\"presentation\">\n <mona-list-item [item]=\"item\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </li>\n } @else {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ng-container>\n </ul>\n </cdk-virtual-scroll-viewport>\n } @else {\n <ng-container [ngTemplateOutlet]=\"emptyListTemplate\"></ng-container>\n }\n} @else {\n @if (listService.viewItems().length !== 0) {\n <ul\n [class]=\"innerListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"-1\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listRole\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-multiselectable]=\"(isListbox && listService.selectableOptions().mode === 'multiple') || null\">\n @for (section of viewSections(); track section.key) {\n @if (section.header; as header) {\n @if (isListbox) {\n <!-- A group of options, named by its header. -->\n <li role=\"none\" class=\"m-0 list-none p-0\">\n <ul role=\"group\" [attr.aria-labelledby]=\"header.uid\" class=\"m-0 list-none p-0\">\n <li\n [class]=\"groupHeaderClasses()\"\n [style]=\"listItemStyle()\"\n [id]=\"header.uid\"\n role=\"presentation\">\n <mona-list-item [item]=\"header\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </li>\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ul>\n </li>\n } @else {\n <!-- A nested list, named by its header. -->\n <li class=\"m-0 list-none p-0\">\n <div [class]=\"groupHeaderClasses()\" [style]=\"listItemStyle()\" [id]=\"header.uid\">\n <mona-list-item [item]=\"header\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </div>\n <ul role=\"list\" [attr.aria-labelledby]=\"header.uid\" class=\"m-0 list-none p-0\">\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ul>\n </li>\n }\n } @else {\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n }\n }\n </ul>\n } @else {\n <ng-container [ngTemplateOutlet]=\"emptyListTemplate\"></ng-container>\n }\n}\n@if (footerTemplate()) {\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n}\n\n<!-- An empty list keeps its named list element, so it stays in the accessibility tree, described by \"No data\". -->\n<ng-template #emptyListTemplate>\n <!-- The empty list element lies over the \"No data\" content, so that content keeps its place and the ring frames it. -->\n <div class=\"relative w-full h-full\">\n @if (noDataTemplate()) {\n <div [id]=\"noDataId\" class=\"contents\">\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </div>\n } @else {\n <mona-placeholder\n [id]=\"noDataId\"\n [text]=\"messages().noData\"\n class=\"w-full h-full flex items-center justify-center\"></mona-placeholder>\n }\n <ul\n [class]=\"emptyListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"0\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listService.role()\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-describedby]=\"noDataId\"></ul>\n </div>\n</ng-template>\n\n<ng-template #listItemTemplate let-item>\n <li\n [class]=\"listItemClass()\"\n [class.px-0.5]=\"true\"\n [style]=\"listItemStyle()\"\n [id]=\"item.uid\"\n [attr.data-uid]=\"item.uid\"\n (click)=\"onListItemClick(item)\"\n monaListItem\n [item]=\"item\">\n <mona-list-item [item]=\"item\" [template]=\"itemTemplate()\"></mona-list-item>\n </li>\n</ng-template>\n",
1783
+ dependencies: [
1784
+ {
1785
+ kind: "component",
1786
+ type: FilterInputComponent,
1787
+ selector: "mona-filter-input",
1788
+ inputs: [
1789
+ "activeDescendant",
1790
+ "ariaControls",
1791
+ "ariaLabel",
1792
+ "autoFocus",
1793
+ "controls",
1794
+ "debounce",
1795
+ "filter",
1796
+ "placeholder",
1797
+ "size"
1798
+ ],
1799
+ outputs: [
1800
+ "filterChange",
1801
+ "inputBlur",
1802
+ "inputFocus"
1803
+ ]
1804
+ },
1805
+ {
1806
+ kind: "component",
1807
+ type: ListItemComponent,
1808
+ selector: "mona-list-item",
1809
+ inputs: ["item", "template"]
1810
+ },
1811
+ {
1812
+ kind: "directive",
1813
+ type: NgTemplateOutlet,
1814
+ selector: "[ngTemplateOutlet]",
1815
+ inputs: [
1816
+ "ngTemplateOutletContext",
1817
+ "ngTemplateOutlet",
1818
+ "ngTemplateOutletInjector"
1819
+ ]
1820
+ },
1821
+ {
1822
+ kind: "directive",
1823
+ type: ListItemDirective,
1824
+ selector: "li[monaListItem]",
1825
+ inputs: ["item"]
1826
+ },
1827
+ {
1828
+ kind: "component",
1829
+ type: PlaceholderComponent,
1830
+ selector: "mona-placeholder",
1831
+ inputs: ["text", "class"]
1832
+ },
1833
+ {
1834
+ kind: "component",
1835
+ type: CdkVirtualScrollViewport,
1836
+ selector: "cdk-virtual-scroll-viewport",
1837
+ inputs: ["orientation", "appendOnly"],
1838
+ outputs: ["scrolledIndexChange"]
1839
+ },
1840
+ {
1841
+ kind: "directive",
1842
+ type: CdkFixedSizeVirtualScroll,
1843
+ selector: "cdk-virtual-scroll-viewport[itemSize]",
1844
+ inputs: [
1845
+ "itemSize",
1846
+ "minBufferPx",
1847
+ "maxBufferPx"
1848
+ ]
1849
+ },
1850
+ {
1851
+ kind: "directive",
1852
+ type: CdkVirtualForOf,
1853
+ selector: "[cdkVirtualFor][cdkVirtualForOf]",
1854
+ inputs: [
1855
+ "cdkVirtualForOf",
1856
+ "cdkVirtualForTrackBy",
1857
+ "cdkVirtualForTemplate",
1858
+ "cdkVirtualForTemplateCacheSize"
1859
+ ]
1860
+ }
1861
+ ]
1862
+ });
1863
+ }
1864
+ };
1865
+ i0.ɵɵngDeclareClassMetadata({
1866
+ minVersion: "12.0.0",
1867
+ version: "22.2.6",
1868
+ ngImport: i0,
1869
+ type: ListComponent,
1870
+ decorators: [{
1871
+ type: Component,
1872
+ args: [{
1873
+ selector: "mona-list",
1874
+ imports: [
1875
+ FilterInputComponent,
1876
+ ListItemComponent,
1877
+ NgTemplateOutlet,
1878
+ ListItemDirective,
1879
+ PlaceholderComponent,
1880
+ CdkVirtualScrollViewport,
1881
+ CdkFixedSizeVirtualScroll,
1882
+ CdkVirtualForOf
1883
+ ],
1884
+ host: {
1885
+ "[attr.tabindex]": "hostTabIndex()",
1886
+ "[class]": "classes()",
1887
+ "[style.height]": "listHeight()",
1888
+ "[style.max-height]": "listMaxHeight()",
1889
+ "[style.max-width]": "listMaxWidth()",
1890
+ "[style.width]": "listWidth()"
1891
+ },
1892
+ template: "@if (headerTemplate()) {\n <ng-container [ngTemplateOutlet]=\"headerTemplate()\"></ng-container>\n}\n@if (listService.filterableOptions().enabled && listService.filterInputVisible()) {\n <div class=\"p-2\">\n <mona-filter-input\n [filter]=\"listService.filterText()\"\n [debounce]=\"listService.filterableOptions().debounce\"\n [placeholder]=\"listService.filterPlaceholder()\"\n [ariaLabel]=\"messages().filterList\"\n [controls]=\"effectiveListId()\"\n [activeDescendant]=\"activeDescendant()\"\n [size]=\"size()\"\n (filterChange)=\"onFilterChange($event)\"></mona-filter-input>\n </div>\n}\n@let listRole = listService.role();\n@let isListbox = listRole === \"listbox\";\n@if (listService.virtualScrollOptions().enabled) {\n @if (listService.viewItems().length !== 0) {\n <cdk-virtual-scroll-viewport\n [itemSize]=\"listService.virtualScrollOptions().height\"\n [style.height]=\"viewportHeight()\">\n <ul\n [class]=\"innerListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"-1\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listRole\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-multiselectable]=\"\n (isListbox && listService.selectableOptions().mode === 'multiple') || null\n \">\n <ng-container *cdkVirtualFor=\"let item of listService.viewItems(); trackBy: trackByUid\">\n @if (item.isHeader) {\n <li\n [class]=\"groupHeaderClasses()\"\n [style]=\"listItemStyle()\"\n [id]=\"item.uid\"\n role=\"presentation\">\n <mona-list-item [item]=\"item\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </li>\n } @else {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ng-container>\n </ul>\n </cdk-virtual-scroll-viewport>\n } @else {\n <ng-container [ngTemplateOutlet]=\"emptyListTemplate\"></ng-container>\n }\n} @else {\n @if (listService.viewItems().length !== 0) {\n <ul\n [class]=\"innerListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"-1\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listRole\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-multiselectable]=\"(isListbox && listService.selectableOptions().mode === 'multiple') || null\">\n @for (section of viewSections(); track section.key) {\n @if (section.header; as header) {\n @if (isListbox) {\n <!-- A group of options, named by its header. -->\n <li role=\"none\" class=\"m-0 list-none p-0\">\n <ul role=\"group\" [attr.aria-labelledby]=\"header.uid\" class=\"m-0 list-none p-0\">\n <li\n [class]=\"groupHeaderClasses()\"\n [style]=\"listItemStyle()\"\n [id]=\"header.uid\"\n role=\"presentation\">\n <mona-list-item [item]=\"header\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </li>\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ul>\n </li>\n } @else {\n <!-- A nested list, named by its header. -->\n <li class=\"m-0 list-none p-0\">\n <div [class]=\"groupHeaderClasses()\" [style]=\"listItemStyle()\" [id]=\"header.uid\">\n <mona-list-item [item]=\"header\" [template]=\"groupHeaderTemplate()\"></mona-list-item>\n </div>\n <ul role=\"list\" [attr.aria-labelledby]=\"header.uid\" class=\"m-0 list-none p-0\">\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n </ul>\n </li>\n }\n } @else {\n @for (item of section.items; track item.uid) {\n <ng-container\n [ngTemplateOutlet]=\"listItemTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: item }\"></ng-container>\n }\n }\n }\n </ul>\n } @else {\n <ng-container [ngTemplateOutlet]=\"emptyListTemplate\"></ng-container>\n }\n}\n@if (footerTemplate()) {\n <ng-container [ngTemplateOutlet]=\"footerTemplate()\"></ng-container>\n}\n\n<!-- An empty list keeps its named list element, so it stays in the accessibility tree, described by \"No data\". -->\n<ng-template #emptyListTemplate>\n <!-- The empty list element lies over the \"No data\" content, so that content keeps its place and the ring frames it. -->\n <div class=\"relative w-full h-full\">\n @if (noDataTemplate()) {\n <div [id]=\"noDataId\" class=\"contents\">\n <ng-container [ngTemplateOutlet]=\"noDataTemplate()\"></ng-container>\n </div>\n } @else {\n <mona-placeholder\n [id]=\"noDataId\"\n [text]=\"messages().noData\"\n class=\"w-full h-full flex items-center justify-center\"></mona-placeholder>\n }\n <ul\n [class]=\"emptyListClasses()\"\n [style]=\"listStyle()\"\n [tabIndex]=\"0\"\n [id]=\"effectiveListId()\"\n [attr.role]=\"listService.role()\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-busy]=\"busy() || null\"\n [attr.aria-describedby]=\"noDataId\"></ul>\n </div>\n</ng-template>\n\n<ng-template #listItemTemplate let-item>\n <li\n [class]=\"listItemClass()\"\n [class.px-0.5]=\"true\"\n [style]=\"listItemStyle()\"\n [id]=\"item.uid\"\n [attr.data-uid]=\"item.uid\"\n (click)=\"onListItemClick(item)\"\n monaListItem\n [item]=\"item\">\n <mona-list-item [item]=\"item\" [template]=\"itemTemplate()\"></mona-list-item>\n </li>\n</ng-template>\n"
1893
+ }]
1894
+ }],
1895
+ ctorParameters: () => [],
1896
+ propDecorators: {
1897
+ filterInput: [{
1898
+ type: i0.ViewChild,
1899
+ args: [i0.forwardRef(() => FilterInputComponent), { isSignal: true }]
1900
+ }],
1901
+ filterInputElement: [{
1902
+ type: i0.ViewChild,
1903
+ args: [i0.forwardRef(() => FilterInputComponent), {
1904
+ read: ElementRef,
1905
+ isSignal: true
1906
+ }]
1907
+ }],
1908
+ footerTemplate: [{
1909
+ type: i0.ContentChild,
1910
+ args: [i0.forwardRef(() => ListFooterTemplateDirective), {
1911
+ read: TemplateRef,
1912
+ isSignal: true
1913
+ }]
1914
+ }],
1915
+ groupHeaderTemplate: [{
1916
+ type: i0.ContentChild,
1917
+ args: [i0.forwardRef(() => ListGroupHeaderTemplateDirective), {
1918
+ read: TemplateRef,
1919
+ isSignal: true
1920
+ }]
1921
+ }],
1922
+ headerTemplate: [{
1923
+ type: i0.ContentChild,
1924
+ args: [i0.forwardRef(() => ListHeaderTemplateDirective), {
1925
+ read: TemplateRef,
1926
+ isSignal: true
1927
+ }]
1928
+ }],
1929
+ itemTemplate: [{
1930
+ type: i0.ContentChild,
1931
+ args: [i0.forwardRef(() => ListItemTemplateDirective), {
1932
+ read: TemplateRef,
1933
+ isSignal: true
1934
+ }]
1935
+ }],
1936
+ noDataTemplate: [{
1937
+ type: i0.ContentChild,
1938
+ args: [i0.forwardRef(() => ListNoDataTemplateDirective), {
1939
+ read: TemplateRef,
1940
+ isSignal: true
1941
+ }]
1942
+ }],
1943
+ virtualScrollViewport: [{
1944
+ type: i0.ViewChild,
1945
+ args: [i0.forwardRef(() => CdkVirtualScrollViewport), { isSignal: true }]
1946
+ }],
1947
+ ariaLabel: [{
1948
+ type: i0.Input,
1949
+ args: [{
1950
+ isSignal: true,
1951
+ alias: "ariaLabel",
1952
+ required: false
1953
+ }]
1954
+ }],
1955
+ ariaLabelledBy: [{
1956
+ type: i0.Input,
1957
+ args: [{
1958
+ isSignal: true,
1959
+ alias: "ariaLabelledBy",
1960
+ required: false
1961
+ }]
1962
+ }],
1963
+ busy: [{
1964
+ type: i0.Input,
1965
+ args: [{
1966
+ isSignal: true,
1967
+ alias: "busy",
1968
+ required: false
1969
+ }]
1970
+ }],
1971
+ data: [{
1972
+ type: i0.Input,
1973
+ args: [{
1974
+ isSignal: true,
1975
+ alias: "data",
1976
+ required: false
1977
+ }]
1978
+ }],
1979
+ focusOnMount: [{
1980
+ type: i0.Input,
1981
+ args: [{
1982
+ isSignal: true,
1983
+ alias: "focusOnMount",
1984
+ required: false
1985
+ }]
1986
+ }],
1987
+ height: [{
1988
+ type: i0.Input,
1989
+ args: [{
1990
+ isSignal: true,
1991
+ alias: "height",
1992
+ required: false
1993
+ }]
1994
+ }],
1995
+ itemActivate: [{
1996
+ type: i0.Output,
1997
+ args: ["itemActivate"]
1998
+ }],
1999
+ itemSelect: [{
2000
+ type: i0.Output,
2001
+ args: ["itemSelect"]
2002
+ }],
2003
+ listClass: [{
2004
+ type: i0.Input,
2005
+ args: [{
2006
+ isSignal: true,
2007
+ alias: "listClass",
2008
+ required: false
2009
+ }]
2010
+ }],
2011
+ listId: [{
2012
+ type: i0.Input,
2013
+ args: [{
2014
+ isSignal: true,
2015
+ alias: "listId",
2016
+ required: false
2017
+ }]
2018
+ }],
2019
+ listItemClass: [{
2020
+ type: i0.Input,
2021
+ args: [{
2022
+ isSignal: true,
2023
+ alias: "listItemClass",
2024
+ required: false
2025
+ }]
2026
+ }],
2027
+ listItemStyle: [{
2028
+ type: i0.Input,
2029
+ args: [{
2030
+ isSignal: true,
2031
+ alias: "listItemStyle",
2032
+ required: false
2033
+ }]
2034
+ }],
2035
+ listRole: [{
2036
+ type: i0.Input,
2037
+ args: [{
2038
+ isSignal: true,
2039
+ alias: "listRole",
2040
+ required: false
2041
+ }]
2042
+ }],
2043
+ listStyle: [{
2044
+ type: i0.Input,
2045
+ args: [{
2046
+ isSignal: true,
2047
+ alias: "listStyle",
2048
+ required: false
2049
+ }]
2050
+ }],
2051
+ maxHeight: [{
2052
+ type: i0.Input,
2053
+ args: [{
2054
+ isSignal: true,
2055
+ alias: "maxHeight",
2056
+ required: false
2057
+ }]
2058
+ }],
2059
+ maxWidth: [{
2060
+ type: i0.Input,
2061
+ args: [{
2062
+ isSignal: true,
2063
+ alias: "maxWidth",
2064
+ required: false
2065
+ }]
2066
+ }],
2067
+ size: [{
2068
+ type: i0.Input,
2069
+ args: [{
2070
+ isSignal: true,
2071
+ alias: "size",
2072
+ required: false
2073
+ }]
2074
+ }],
2075
+ textField: [{
2076
+ type: i0.Input,
2077
+ args: [{
2078
+ isSignal: true,
2079
+ alias: "textField",
2080
+ required: false
2081
+ }]
2082
+ }],
2083
+ width: [{
2084
+ type: i0.Input,
2085
+ args: [{
2086
+ isSignal: true,
2087
+ alias: "width",
2088
+ required: false
2089
+ }]
2090
+ }]
2091
+ }
2092
+ });
1834
2093
  const LIST_VIEW_HOST_LIST_SERVICE = new InjectionToken("LIST_VIEW_HOST_LIST_SERVICE");
1835
-
1836
- /*
1837
- * Public API Surface of @nanahoshi/mona-ui/list
1838
- */
1839
-
1840
- /**
1841
- * Generated bundle index. Do not edit.
1842
- */
1843
-
1844
2094
  export { LIST_DEFAULT_MESSAGES, LIST_VIEW_HOST_LIST_SERVICE, ListComponent, ListFooterTemplateDirective, ListGroupHeaderTemplateDirective, ListHeaderTemplateDirective, ListItem, ListItemTemplateDirective, ListNoDataTemplateDirective, ListService };
1845
- //# sourceMappingURL=nanahoshi-mona-ui-internal-list.mjs.map
2095
+
2096
+ //# sourceMappingURL=nanahoshi-mona-ui-internal-list.mjs.map