@nanahoshi/mona-ui 0.27.2 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/docs/api/chart.md +2 -2
  2. package/docs/api/locales.md +8 -0
  3. package/docs/api/popup.md +1 -1
  4. package/docs/api/theme.md +2 -2
  5. package/docs/chart.md +14 -0
  6. package/docs/editor.md +2 -0
  7. package/docs/installation.md +147 -15
  8. package/docs/introduction.md +37 -15
  9. package/docs/theming-built-in-themes.md +67 -0
  10. package/docs/theming-custom-colors.md +274 -0
  11. package/docs/theming-custom-themes.md +168 -0
  12. package/docs/theming.md +164 -248
  13. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  14. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  15. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  16. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  17. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  18. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2071 -1573
  19. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  20. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  21. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  22. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  23. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  24. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
  25. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  26. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  27. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  28. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  29. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  30. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
  31. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  32. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
  33. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  34. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  35. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  36. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  37. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  38. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
  39. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  40. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  41. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  42. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  43. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  44. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  45. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  46. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  47. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  48. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  49. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  50. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  51. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
  52. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  53. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  54. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  55. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  56. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  57. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  58. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  59. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  60. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  61. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  62. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  63. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  64. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  65. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  66. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  67. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  68. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  69. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  70. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +599 -0
  71. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  72. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  73. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  74. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  75. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  76. package/fesm2022/nanahoshi-mona-ui-locales.mjs +61 -77
  77. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  78. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  79. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  80. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  81. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  82. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  83. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  84. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  85. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  86. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  87. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  88. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  89. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  90. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  91. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  92. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  93. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  94. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  95. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  96. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  97. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  98. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  99. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  100. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  101. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  102. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  103. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  104. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  105. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  106. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  107. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  108. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  109. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  110. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  111. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  112. package/llms.txt +7 -3
  113. package/locales/pl-pl/package.json +4 -0
  114. package/locales/pl-pl/pl-pl.messages.json +536 -0
  115. package/package.json +66 -23
  116. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  117. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  118. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  119. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  120. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  121. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  122. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  123. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  124. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  125. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  126. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  127. package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
  128. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  129. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  130. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  131. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  132. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  133. package/types/nanahoshi-mona-ui-common.d.ts +354 -385
  134. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  135. package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
  136. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  137. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  138. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  139. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  140. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  141. package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
  142. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  143. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  144. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  145. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  146. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  147. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  148. package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
  149. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  150. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  151. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  152. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  153. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  154. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  155. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  156. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  157. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  158. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  159. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  160. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  161. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  162. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  163. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  164. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  165. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  166. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  167. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +540 -0
  168. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  169. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  170. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  171. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  172. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  173. package/types/nanahoshi-mona-ui-locales.d.ts +18 -19
  174. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  175. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  176. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  177. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  178. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  179. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  180. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  181. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  182. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  183. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  184. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  185. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  186. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  187. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  188. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  189. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  190. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  191. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  192. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  193. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  194. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  195. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  196. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  197. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  198. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  199. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  200. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  201. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  202. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  203. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  204. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  205. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  206. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  207. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  208. package/types/nanahoshi-mona-ui.d.ts +1 -2
  209. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  210. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  211. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  212. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  213. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
@@ -1,83 +1,115 @@
1
- import { PreventableEvent } from '@nanahoshi/mona-ui/common';
2
- import * as i0 from '@angular/core';
3
- import { Directive, computed, input, inject, DestroyRef, ElementRef, signal, viewChildren, viewChild, model, output, afterRenderEffect, untracked, afterNextRender, Component, contentChild, TemplateRef, booleanAttribute, linkedSignal, contentChildren, effect } from '@angular/core';
4
- import { NgTemplateOutlet } from '@angular/common';
5
- import { firstOrDefault, select } from '@mirei/ts-collections';
6
- import { twMerge } from 'tailwind-merge';
7
- import { cva } from 'class-variance-authority';
8
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
9
- import { LucideChevronDown, LucideChevronLeft, LucideChevronRight, LucideChevronUp, LucideX } from '@lucide/angular';
10
- import { ButtonDirective } from '@nanahoshi/mona-ui/button';
11
- import { injectComponentDirection, MonaI18nService } from '@nanahoshi/mona-ui/i18n';
12
- import { Subject, switchMap, EMPTY, timer, interval, tap, asapScheduler } from 'rxjs';
13
- import { createElementControlId } from '@nanahoshi/mona-ui/internal';
14
-
15
- class TabCloseEvent extends PreventableEvent {
16
- #index;
17
- #selected;
18
- constructor(index, selected, originalEvent) {
19
- super("tabClose", originalEvent);
20
- this.#index = index;
21
- this.#selected = selected;
22
- }
23
- /** Index of the tab a close was requested for. */
24
- get index() {
25
- return this.#index;
26
- }
27
- /** Whether the tab a close was requested for was the selected tab. */
28
- get selected() {
29
- return this.#selected;
30
- }
31
- }
32
-
33
- class TabSelectEvent extends PreventableEvent {
34
- #index;
35
- constructor(index, originalEvent) {
36
- super("tabSelect", originalEvent);
37
- this.#index = index;
38
- }
39
- /** Index of the tab being selected. */
40
- get index() {
41
- return this.#index;
42
- }
43
- }
44
-
45
- class TabContentTemplateDirective {
46
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabContentTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
47
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: TabContentTemplateDirective, isStandalone: true, selector: "ng-template[monaTabContentTemplate]", ngImport: i0 }); }
48
- }
49
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabContentTemplateDirective, decorators: [{
50
- type: Directive,
51
- args: [{
52
- selector: "ng-template[monaTabContentTemplate]"
53
- }]
54
- }] });
55
-
56
- class TabTitleTemplateDirective {
57
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabTitleTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
58
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: TabTitleTemplateDirective, isStandalone: true, selector: "ng-template[monaTabTitleTemplate]", ngImport: i0 }); }
59
- }
60
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabTitleTemplateDirective, decorators: [{
61
- type: Directive,
62
- args: [{
63
- selector: "ng-template[monaTabTitleTemplate]"
64
- }]
65
- }] });
66
-
1
+ import { PreventableEvent } from "@nanahoshi/mona-ui/common";
2
+ import * as i0 from "@angular/core";
3
+ import { Component, DestroyRef, Directive, ElementRef, TemplateRef, afterNextRender, afterRenderEffect, booleanAttribute, computed, contentChild, contentChildren, effect, inject, input, linkedSignal, model, output, signal, untracked, viewChild, viewChildren } from "@angular/core";
4
+ import { NgTemplateOutlet } from "@angular/common";
5
+ import { firstOrDefault, select } from "@mirei/ts-collections";
6
+ import { twMerge } from "tailwind-merge";
7
+ import { cva } from "class-variance-authority";
8
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
9
+ import { LucideChevronDown, LucideChevronLeft, LucideChevronRight, LucideChevronUp, LucideX } from "@lucide/angular";
10
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
11
+ import { MonaI18nService, injectComponentDirection } from "@nanahoshi/mona-ui/i18n";
12
+ import { EMPTY, Subject, asapScheduler, interval, switchMap, tap, timer } from "rxjs";
13
+ import { createElementControlId } from "@nanahoshi/mona-ui/internal";
14
+ var TabCloseEvent = class extends PreventableEvent {
15
+ #index;
16
+ #selected;
17
+ constructor(index, selected, originalEvent) {
18
+ super("tabClose", originalEvent);
19
+ this.#index = index;
20
+ this.#selected = selected;
21
+ }
22
+ get index() {
23
+ return this.#index;
24
+ }
25
+ get selected() {
26
+ return this.#selected;
27
+ }
28
+ };
29
+ var TabSelectEvent = class extends PreventableEvent {
30
+ #index;
31
+ constructor(index, originalEvent) {
32
+ super("tabSelect", originalEvent);
33
+ this.#index = index;
34
+ }
35
+ get index() {
36
+ return this.#index;
37
+ }
38
+ };
39
+ var TabContentTemplateDirective = class TabContentTemplateDirective {
40
+ static {
41
+ this.ɵfac = i0.ɵɵngDeclareFactory({
42
+ minVersion: "12.0.0",
43
+ version: "22.2.6",
44
+ ngImport: i0,
45
+ type: TabContentTemplateDirective,
46
+ deps: [],
47
+ target: i0.ɵɵFactoryTarget.Directive
48
+ });
49
+ }
50
+ static {
51
+ this.ɵdir = i0.ɵɵngDeclareDirective({
52
+ minVersion: "14.0.0",
53
+ version: "22.2.6",
54
+ type: TabContentTemplateDirective,
55
+ isStandalone: true,
56
+ selector: "ng-template[monaTabContentTemplate]",
57
+ ngImport: i0
58
+ });
59
+ }
60
+ };
61
+ i0.ɵɵngDeclareClassMetadata({
62
+ minVersion: "12.0.0",
63
+ version: "22.2.6",
64
+ ngImport: i0,
65
+ type: TabContentTemplateDirective,
66
+ decorators: [{
67
+ type: Directive,
68
+ args: [{ selector: "ng-template[monaTabContentTemplate]" }]
69
+ }]
70
+ });
71
+ var TabTitleTemplateDirective = class TabTitleTemplateDirective {
72
+ static {
73
+ this.ɵfac = i0.ɵɵngDeclareFactory({
74
+ minVersion: "12.0.0",
75
+ version: "22.2.6",
76
+ ngImport: i0,
77
+ type: TabTitleTemplateDirective,
78
+ deps: [],
79
+ target: i0.ɵɵFactoryTarget.Directive
80
+ });
81
+ }
82
+ static {
83
+ this.ɵdir = i0.ɵɵngDeclareDirective({
84
+ minVersion: "14.0.0",
85
+ version: "22.2.6",
86
+ type: TabTitleTemplateDirective,
87
+ isStandalone: true,
88
+ selector: "ng-template[monaTabTitleTemplate]",
89
+ ngImport: i0
90
+ });
91
+ }
92
+ };
93
+ i0.ɵɵngDeclareClassMetadata({
94
+ minVersion: "12.0.0",
95
+ version: "22.2.6",
96
+ ngImport: i0,
97
+ type: TabTitleTemplateDirective,
98
+ decorators: [{
99
+ type: Directive,
100
+ args: [{ selector: "ng-template[monaTabTitleTemplate]" }]
101
+ }]
102
+ });
67
103
  const tabListBaseThemeVariants = cva(`
68
104
  flex max-w-full min-w-0 overflow-hidden
69
105
  `, {
70
- variants: {
71
- position: {
72
- top: "flex-row border-b border-border",
73
- bottom: "flex-row border-t border-border",
74
- left: "flex-col max-h-full min-h-0 border-e border-border",
75
- right: "flex-col max-h-full min-h-0 border-s border-border"
76
- }
77
- },
78
- defaultVariants: {
79
- position: "top"
80
- }
106
+ variants: { position: {
107
+ top: "flex-row border-b border-border",
108
+ bottom: "flex-row border-t border-border",
109
+ left: "flex-col max-h-full min-h-0 border-e border-border",
110
+ right: "flex-col max-h-full min-h-0 border-s border-border"
111
+ } },
112
+ defaultVariants: { position: "top" }
81
113
  });
82
114
  const tabListListWrapperThemeVariants = cva(`flex-1 min-w-0 min-h-0 overflow-hidden`);
83
115
  const tabListListThemeVariants = cva(`
@@ -85,76 +117,70 @@ const tabListListThemeVariants = cva(`
85
117
  cursor-default select-none whitespace-nowrap
86
118
  transition-colors duration-(--mona-motion-standard) ease-out
87
119
  `, {
88
- variants: {
89
- position: {
90
- top: "flex-row max-w-full min-w-0",
91
- bottom: "flex-row max-w-full min-w-0",
92
- left: "flex-col max-h-full min-h-0",
93
- right: "flex-col max-h-full min-h-0"
94
- }
95
- },
96
- defaultVariants: {
97
- position: "top"
98
- }
120
+ variants: { position: {
121
+ top: "flex-row max-w-full min-w-0",
122
+ bottom: "flex-row max-w-full min-w-0",
123
+ left: "flex-col max-h-full min-h-0",
124
+ right: "flex-col max-h-full min-h-0"
125
+ } },
126
+ defaultVariants: { position: "top" }
99
127
  });
100
128
  const tabListListItemThemeVariants = cva(`
101
129
  relative flex shrink-0 cursor-pointer
102
130
  transition-colors duration-(--mona-motion-standard) ease-out
103
131
  `, {
104
- variants: {
105
- active: {
106
- true: `
132
+ variants: {
133
+ active: {
134
+ true: `
107
135
  text-foreground font-semibold
108
136
  after:absolute after:content-[''] after:bg-[var(--mona-indicator-color,var(--color-primary))]
109
137
  after:forced-color-adjust-none forced-colors:after:bg-[Highlight]
110
138
  `,
111
- false: "text-muted-foreground hover:bg-hover hover:text-foreground"
112
- },
113
- disabled: {
114
- true: "pointer-events-none cursor-not-allowed select-none text-disabled-foreground after:hidden",
115
- false: ""
116
- },
117
- position: {
118
- top: "items-center justify-center whitespace-nowrap after:inset-x-0 after:bottom-0 after:h-[2px]",
119
- bottom: "items-center justify-center whitespace-nowrap after:inset-x-0 after:top-0 after:h-[2px]",
120
- left: "w-full items-center justify-start text-start after:inset-y-0 after:end-0 after:w-[2px]",
121
- right: "w-full items-center justify-start text-start after:inset-y-0 after:start-0 after:w-[2px]"
122
- },
123
- size: {
124
- small: "h-8 text-xs",
125
- medium: "h-9 text-sm",
126
- large: "h-10 text-sm"
127
- }
128
- },
129
- defaultVariants: {
130
- position: "top",
131
- size: "medium"
132
- }
139
+ false: "text-muted-foreground hover:bg-hover hover:text-foreground"
140
+ },
141
+ disabled: {
142
+ true: "pointer-events-none cursor-not-allowed select-none text-disabled-foreground after:hidden",
143
+ false: ""
144
+ },
145
+ position: {
146
+ top: "items-center justify-center whitespace-nowrap after:inset-x-0 after:bottom-0 after:h-[2px]",
147
+ bottom: "items-center justify-center whitespace-nowrap after:inset-x-0 after:top-0 after:h-[2px]",
148
+ left: "w-full items-center justify-start text-start after:inset-y-0 after:end-0 after:w-[2px]",
149
+ right: "w-full items-center justify-start text-start after:inset-y-0 after:start-0 after:w-[2px]"
150
+ },
151
+ size: {
152
+ small: "h-8 text-xs",
153
+ medium: "h-9 text-sm",
154
+ large: "h-10 text-sm"
155
+ }
156
+ },
157
+ defaultVariants: {
158
+ position: "top",
159
+ size: "medium"
160
+ }
133
161
  });
134
- /** Inset, because the strip clips anything outside it. */
135
162
  const tabListTabThemeVariants = cva(`
136
163
  flex h-full min-w-0 flex-1 items-center
137
164
  focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus-indicator
138
165
  `, {
139
- variants: {
140
- position: {
141
- top: "justify-center whitespace-nowrap",
142
- bottom: "justify-center whitespace-nowrap",
143
- left: "justify-start text-start",
144
- right: "justify-start text-start"
145
- },
146
- size: {
147
- small: "px-2",
148
- medium: "px-3",
149
- large: "px-4"
150
- }
151
- },
152
- defaultVariants: {
153
- position: "top",
154
- size: "medium"
155
- }
166
+ variants: {
167
+ position: {
168
+ top: "justify-center whitespace-nowrap",
169
+ bottom: "justify-center whitespace-nowrap",
170
+ left: "justify-start text-start",
171
+ right: "justify-start text-start"
172
+ },
173
+ size: {
174
+ small: "px-2",
175
+ medium: "px-3",
176
+ large: "px-4"
177
+ }
178
+ },
179
+ defaultVariants: {
180
+ position: "top",
181
+ size: "medium"
182
+ }
156
183
  });
157
- /** The icon is 16 pixels. The pseudo-element makes the target 24. */
158
184
  const tabListCloseButtonThemeVariants = cva(`
159
185
  relative -ms-1 me-2 h-fit w-min self-center px-0
160
186
  before:absolute before:-inset-1 before:content-['']
@@ -173,722 +199,1248 @@ const tabContentThemeVariants = cva(`
173
199
  const tabsBaseThemeVariants = cva(`
174
200
  flex max-w-full min-w-0 min-h-0
175
201
  `, {
176
- variants: {
177
- position: {
178
- top: "flex-col",
179
- bottom: "flex-col-reverse",
180
- left: "flex-row",
181
- right: "flex-row-reverse"
182
- }
183
- },
184
- defaultVariants: {
185
- position: "top"
186
- }
202
+ variants: { position: {
203
+ top: "flex-col",
204
+ bottom: "flex-col-reverse",
205
+ left: "flex-row",
206
+ right: "flex-row-reverse"
207
+ } },
208
+ defaultVariants: { position: "top" }
209
+ });
210
+ var TabListItemDirective = class TabListItemDirective {
211
+ constructor() {
212
+ this.listItemClass = computed(() => {
213
+ const active = this.active();
214
+ const disabled = this.disabled();
215
+ const position = this.position();
216
+ const size = this.size();
217
+ return tabListListItemThemeVariants({
218
+ active,
219
+ disabled,
220
+ position,
221
+ size
222
+ });
223
+ }, ...ngDevMode ? [{ debugName: "listItemClass" }] : /* istanbul ignore next */ []);
224
+ this.active = input.required(...ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []);
225
+ this.disabled = input.required(...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
226
+ this.position = input.required(...ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []);
227
+ this.size = input.required(...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
228
+ }
229
+ static {
230
+ this.ɵfac = i0.ɵɵngDeclareFactory({
231
+ minVersion: "12.0.0",
232
+ version: "22.2.6",
233
+ ngImport: i0,
234
+ type: TabListItemDirective,
235
+ deps: [],
236
+ target: i0.ɵɵFactoryTarget.Directive
237
+ });
238
+ }
239
+ static {
240
+ this.ɵdir = i0.ɵɵngDeclareDirective({
241
+ minVersion: "17.1.0",
242
+ version: "22.2.6",
243
+ type: TabListItemDirective,
244
+ isStandalone: true,
245
+ selector: "li[monaTabListItem]",
246
+ inputs: {
247
+ active: {
248
+ classPropertyName: "active",
249
+ publicName: "active",
250
+ isSignal: true,
251
+ isRequired: true,
252
+ transformFunction: null
253
+ },
254
+ disabled: {
255
+ classPropertyName: "disabled",
256
+ publicName: "disabled",
257
+ isSignal: true,
258
+ isRequired: true,
259
+ transformFunction: null
260
+ },
261
+ position: {
262
+ classPropertyName: "position",
263
+ publicName: "position",
264
+ isSignal: true,
265
+ isRequired: true,
266
+ transformFunction: null
267
+ },
268
+ size: {
269
+ classPropertyName: "size",
270
+ publicName: "size",
271
+ isSignal: true,
272
+ isRequired: true,
273
+ transformFunction: null
274
+ }
275
+ },
276
+ host: { properties: { "class": "listItemClass()" } },
277
+ ngImport: i0
278
+ });
279
+ }
280
+ };
281
+ i0.ɵɵngDeclareClassMetadata({
282
+ minVersion: "12.0.0",
283
+ version: "22.2.6",
284
+ ngImport: i0,
285
+ type: TabListItemDirective,
286
+ decorators: [{
287
+ type: Directive,
288
+ args: [{
289
+ selector: "li[monaTabListItem]",
290
+ host: { "[class]": "listItemClass()" }
291
+ }]
292
+ }],
293
+ propDecorators: {
294
+ active: [{
295
+ type: i0.Input,
296
+ args: [{
297
+ isSignal: true,
298
+ alias: "active",
299
+ required: true
300
+ }]
301
+ }],
302
+ disabled: [{
303
+ type: i0.Input,
304
+ args: [{
305
+ isSignal: true,
306
+ alias: "disabled",
307
+ required: true
308
+ }]
309
+ }],
310
+ position: [{
311
+ type: i0.Input,
312
+ args: [{
313
+ isSignal: true,
314
+ alias: "position",
315
+ required: true
316
+ }]
317
+ }],
318
+ size: [{
319
+ type: i0.Input,
320
+ args: [{
321
+ isSignal: true,
322
+ alias: "size",
323
+ required: true
324
+ }]
325
+ }]
326
+ }
187
327
  });
188
-
189
- class TabListItemDirective {
190
- constructor() {
191
- this.listItemClass = computed(() => {
192
- const active = this.active();
193
- const disabled = this.disabled();
194
- const position = this.position();
195
- const size = this.size();
196
- return tabListListItemThemeVariants({ active, disabled, position, size });
197
- }, /* @ts-ignore */
198
- ...(ngDevMode ? [{ debugName: "listItemClass" }] : /* istanbul ignore next */ []));
199
- this.active = input.required(/* @ts-ignore */
200
- ...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
201
- this.disabled = input.required(/* @ts-ignore */
202
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
203
- this.position = input.required(/* @ts-ignore */
204
- ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
205
- this.size = input.required(/* @ts-ignore */
206
- ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
207
- }
208
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabListItemDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
209
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: TabListItemDirective, isStandalone: true, selector: "li[monaTabListItem]", inputs: { active: { classPropertyName: "active", publicName: "active", isSignal: true, isRequired: true, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: true, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: true, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "class": "listItemClass()" } }, ngImport: i0 }); }
210
- }
211
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabListItemDirective, decorators: [{
212
- type: Directive,
213
- args: [{
214
- selector: "li[monaTabListItem]",
215
- host: {
216
- "[class]": "listItemClass()"
217
- }
218
- }]
219
- }], propDecorators: { active: [{ type: i0.Input, args: [{ isSignal: true, alias: "active", required: true }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: true }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: true }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: true }] }] } });
220
-
221
- // Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
222
- // Edit the JSON file and run `npm run generate:locale-catalogs`.
223
328
  const TABS_DEFAULT_MESSAGES = {
224
- closeTab: "Close tab",
225
- scrollNext: "Scroll tabs next",
226
- scrollPrevious: "Scroll tabs previous"
329
+ closeTab: "Close tab",
330
+ scrollNext: "Scroll tabs next",
331
+ scrollPrevious: "Scroll tabs previous"
227
332
  };
228
-
229
333
  function getTabOrientation(position) {
230
- return position === "left" || position === "right"
231
- ? "vertical"
232
- : "horizontal";
334
+ return position === "left" || position === "right" ? "vertical" : "horizontal";
233
335
  }
234
-
235
- class TabListComponent {
236
- #destroyRef;
237
- #direction;
238
- #hostElement;
239
- #i18n;
240
- #scrollIntent$;
241
- /** The tab that focus is in, kept when the tab is removed, so focus can go to the selected tab instead of being lost. */
242
- #focusedTabId;
243
- #resizeObserver;
244
- constructor() {
245
- this.#destroyRef = inject(DestroyRef);
246
- this.#direction = injectComponentDirection();
247
- this.#hostElement = inject(ElementRef).nativeElement;
248
- this.#i18n = inject(MonaI18nService);
249
- this.#scrollIntent$ = new Subject();
250
- /** The tab that focus is in, kept when the tab is removed, so focus can go to the selected tab instead of being lost. */
251
- this.#focusedTabId = null;
252
- this.#resizeObserver = null;
253
- this.baseClass = computed(() => {
254
- return tabListBaseThemeVariants({ position: this.position() });
255
- }, /* @ts-ignore */
256
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
257
- this.closeButtonClass = computed(() => {
258
- return tabListCloseButtonThemeVariants();
259
- }, /* @ts-ignore */
260
- ...(ngDevMode ? [{ debugName: "closeButtonClass" }] : /* istanbul ignore next */ []));
261
- this.hasClosableTabs = computed(() => {
262
- return this.closable() || Array.from(this.tabList()).some(tab => tab.closable);
263
- }, /* @ts-ignore */
264
- ...(ngDevMode ? [{ debugName: "hasClosableTabs" }] : /* istanbul ignore next */ []));
265
- this.isRtl = computed(() => this.#direction() === "rtl", /* @ts-ignore */
266
- ...(ngDevMode ? [{ debugName: "isRtl" }] : /* istanbul ignore next */ []));
267
- this.listClass = computed(() => {
268
- return tabListListThemeVariants({ position: this.position() });
269
- }, /* @ts-ignore */
270
- ...(ngDevMode ? [{ debugName: "listClass" }] : /* istanbul ignore next */ []));
271
- this.listWrapperClass = computed(() => {
272
- return tabListListWrapperThemeVariants();
273
- }, /* @ts-ignore */
274
- ...(ngDevMode ? [{ debugName: "listWrapperClass" }] : /* istanbul ignore next */ []));
275
- this.messages = this.#i18n.componentMessages("tabs", TABS_DEFAULT_MESSAGES);
276
- this.orientation = computed(() => {
277
- return getTabOrientation(this.position() ?? "top");
278
- }, /* @ts-ignore */
279
- ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
280
- this.overflowControlsVisible = signal(false, /* @ts-ignore */
281
- ...(ngDevMode ? [{ debugName: "overflowControlsVisible" }] : /* istanbul ignore next */ []));
282
- this.scrollButtonClass = computed(() => {
283
- return tabListScrollButtonThemeVariants();
284
- }, /* @ts-ignore */
285
- ...(ngDevMode ? [{ debugName: "scrollButtonClass" }] : /* istanbul ignore next */ []));
286
- this.tabClass = computed(() => {
287
- return tabListTabThemeVariants({ position: this.position(), size: this.size() });
288
- }, /* @ts-ignore */
289
- ...(ngDevMode ? [{ debugName: "tabClass" }] : /* istanbul ignore next */ []));
290
- this.tabElements = viewChildren("tabElement", /* @ts-ignore */
291
- ...(ngDevMode ? [{ debugName: "tabElements" }] : /* istanbul ignore next */ []));
292
- this.tabListElement = viewChild.required("tabListElement", /* @ts-ignore */
293
- ...(ngDevMode ? [{ debugName: "tabListElement" }] : /* istanbul ignore next */ []));
294
- this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
295
- this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
296
- this.closable = input(false, /* @ts-ignore */
297
- ...(ngDevMode ? [{ debugName: "closable" }] : /* istanbul ignore next */ []));
298
- this.disabled = input(false, /* @ts-ignore */
299
- ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
300
- /**
301
- * @description Placement of the tab list relative to the tab content.
302
- * @default "top"
303
- */
304
- this.position = input.required(/* @ts-ignore */
305
- ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
306
- this.selectedTabId = model(null, /* @ts-ignore */
307
- ...(ngDevMode ? [{ debugName: "selectedTabId" }] : /* istanbul ignore next */ []));
308
- /**
309
- * @description Size preset controlling the tabs' dimensions.
310
- * @default "medium"
311
- */
312
- this.size = input.required(/* @ts-ignore */
313
- ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
314
- this.tabClose = output();
315
- this.tabList = input.required(/* @ts-ignore */
316
- ...(ngDevMode ? [{ debugName: "tabList" }] : /* istanbul ignore next */ []));
317
- this.tabSelect = output();
318
- afterRenderEffect({
319
- read: () => {
320
- const tabs = Array.from(this.tabList());
321
- this.position();
322
- untracked(() => {
323
- this.updateScrollVisibility();
324
- this.restoreFocus(tabs);
325
- });
326
- }
327
- });
328
- afterRenderEffect({
329
- read: () => {
330
- const selectedId = this.selectedTabId();
331
- untracked(() => this.scrollTabIntoStrip(selectedId));
332
- }
333
- });
334
- this.setupScrolling();
335
- afterNextRender({
336
- read: () => this.setupResizeObserver()
337
- });
338
- this.#destroyRef.onDestroy(() => this.#resizeObserver?.disconnect());
339
- }
340
- focusSelectedTab() {
341
- const selectedTab = firstOrDefault(this.tabList(), t => t.id === this.selectedTabId());
342
- if (selectedTab) {
343
- this.focusTab(selectedTab);
344
- }
345
- }
346
- onFocusIn(event) {
347
- this.#focusedTabId = event.target.closest("[data-tab-id]")?.getAttribute("data-tab-id") ?? null;
348
- }
349
- onFocusOut(event) {
350
- const target = event.target;
351
- // Some browsers fire this while removing the focused tab, so only a target that's still there can mean focus left.
352
- // It runs after the focusin of a move within the strip, which has already recorded where focus went.
353
- queueMicrotask(() => {
354
- const root = this.#hostElement.getRootNode();
355
- if (target.isConnected && !this.#hostElement.contains(root.activeElement)) {
356
- this.#focusedTabId = null;
357
- }
358
- });
359
- }
360
- onKeydown(event) {
361
- if (event.altKey || event.ctrlKey || event.metaKey) {
362
- return;
363
- }
364
- const tabs = Array.from(this.tabList());
365
- const currentTab = this.tabFromEvent(tabs, event);
366
- if (!currentTab) {
367
- return;
368
- }
369
- if (event.key === "Tab") {
370
- if (!event.shiftKey) {
371
- this.handleTabKey(tabs, event);
372
- }
373
- return;
374
- }
375
- if (!event.shiftKey) {
376
- this.handleTabStripKey(tabs, currentTab, event);
377
- }
378
- }
379
- onTabClick(tab, event) {
380
- if (tab.disabled || this.disabled() || tab.id === this.selectedTabId()) {
381
- return;
382
- }
383
- if (!this.emitTabSelect(tab, event)) {
384
- this.selectTab(tab);
385
- }
386
- }
387
- onTabClose(tab, event) {
388
- event.stopPropagation();
389
- this.emitTabClose(tab, event);
390
- }
391
- startContinuousScroll(event, element, direction) {
392
- event.currentTarget.setPointerCapture(event.pointerId);
393
- this.startScrolling(element, direction, "continuous");
394
- }
395
- startScrolling(element, direction, type) {
396
- this.#scrollIntent$.next({ element, direction, type });
397
- }
398
- stopScrolling() {
399
- this.#scrollIntent$.next(null);
400
- }
401
- /**
402
- * Selects the tab and moves focus to it. A vetoed selection still moves focus, so the keyboard can get past a tab it
403
- * isn't allowed to select.
404
- */
405
- activateTab(tab, event) {
406
- if (tab.id !== this.selectedTabId() && !this.emitTabSelect(tab, event)) {
407
- this.selectTab(tab);
408
- }
409
- this.focusTab(tab);
410
- }
411
- adjacentEnabledTab(tabs, from, offset) {
412
- const start = tabs.indexOf(from);
413
- for (let step = 1; step <= tabs.length; step++) {
414
- const candidate = tabs[(start + offset * step + tabs.length * step) % tabs.length];
415
- if (this.isTabEnabled(candidate)) {
416
- return candidate;
417
- }
418
- }
419
- return undefined;
420
- }
421
- emitTabClose(tabItem, event) {
422
- this.tabClose.emit(new TabCloseEvent(tabItem.index, tabItem.id === this.selectedTabId(), event));
423
- }
424
- emitTabSelect(tab, event) {
425
- const selectEvent = new TabSelectEvent(tab.index, event);
426
- this.tabSelect.emit(selectEvent);
427
- return selectEvent.isDefaultPrevented();
428
- }
429
- focusTab(tab) {
430
- this.tabElementOf(tab.id)?.focus();
431
- }
432
- getNavigationDirection(event) {
433
- if (this.orientation() === "vertical") {
434
- if (event.key === "ArrowUp") {
435
- return "previous";
436
- }
437
- if (event.key === "ArrowDown") {
438
- return "next";
439
- }
440
- return null;
441
- }
442
- const isRtl = this.isRtl();
443
- if (event.key === "ArrowLeft") {
444
- return isRtl ? "next" : "previous";
445
- }
446
- if (event.key === "ArrowRight") {
447
- return isRtl ? "previous" : "next";
448
- }
449
- return null;
450
- }
451
- handleTabKey(tabs, event) {
452
- const selectedTab = tabs.find(t => t.id === this.selectedTabId());
453
- if (!selectedTab) {
454
- return;
455
- }
456
- // The root node, because a document lookup finds nothing inside a shadow root.
457
- const root = this.#hostElement.getRootNode();
458
- const panel = root.getElementById(selectedTab.id + "-panel");
459
- if (panel) {
460
- event.preventDefault();
461
- panel.focus();
462
- }
463
- }
464
- handleTabStripKey(tabs, currentTab, event) {
465
- const enabledTabs = tabs.filter(t => this.isTabEnabled(t));
466
- if (enabledTabs.length === 0) {
467
- return;
468
- }
469
- const navigationDirection = this.getNavigationDirection(event);
470
- if (navigationDirection) {
471
- event.preventDefault();
472
- const target = this.adjacentEnabledTab(tabs, currentTab, navigationDirection === "next" ? 1 : -1);
473
- if (target) {
474
- this.activateTab(target, event);
475
- }
476
- return;
477
- }
478
- switch (event.key) {
479
- case "Home":
480
- event.preventDefault();
481
- this.activateTab(enabledTabs[0], event);
482
- break;
483
- case "End":
484
- event.preventDefault();
485
- this.activateTab(enabledTabs[enabledTabs.length - 1], event);
486
- break;
487
- case "Delete":
488
- case "Backspace":
489
- if (this.isTabEnabled(currentTab) && (currentTab.closable || this.closable())) {
490
- event.preventDefault();
491
- this.emitTabClose(currentTab, event);
492
- }
493
- break;
494
- }
495
- }
496
- isTabEnabled(tab) {
497
- return !tab.disabled && !this.disabled();
498
- }
499
- performScroll(element, direction) {
500
- let offset = direction === "previous" ? -100 : 100;
501
- const reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
502
- const behavior = reducedMotion ? "auto" : "smooth";
503
- if (this.orientation() === "vertical") {
504
- element.scrollBy({ top: offset, behavior });
505
- return;
506
- }
507
- if (this.isRtl()) {
508
- offset = -offset;
509
- }
510
- element.scrollBy({ left: offset, behavior });
511
- }
512
- restoreFocus(tabs) {
513
- const focusedTabId = this.#focusedTabId;
514
- if (focusedTabId === null || tabs.some(tab => tab.id === focusedTabId)) {
515
- return;
516
- }
517
- this.#focusedTabId = null;
518
- const root = this.#hostElement.getRootNode();
519
- const active = root.activeElement;
520
- if (!active || active === this.#hostElement.ownerDocument.body) {
521
- this.focusSelectedTab();
522
- }
523
- }
524
- /**
525
- * Scrolls only the strip. `scrollIntoView` would also scroll the page, which a selection made by code, or the first
526
- * render, has no business doing.
527
- */
528
- scrollTabIntoStrip(tabId) {
529
- const tabElement = tabId === null ? undefined : this.tabElementOf(tabId);
530
- if (!tabElement) {
531
- return;
532
- }
533
- const list = this.tabListElement().nativeElement;
534
- const listRect = list.getBoundingClientRect();
535
- const tabRect = tabElement.getBoundingClientRect();
536
- if (this.orientation() === "vertical") {
537
- const top = Math.min(tabRect.top - listRect.top, 0) || Math.max(tabRect.bottom - listRect.bottom, 0);
538
- if (top !== 0) {
539
- list.scrollBy({ top });
540
- }
541
- return;
542
- }
543
- const left = Math.min(tabRect.left - listRect.left, 0) || Math.max(tabRect.right - listRect.right, 0);
544
- if (left !== 0) {
545
- list.scrollBy({ left });
546
- }
547
- }
548
- selectTab(tab) {
549
- this.selectedTabId.set(tab.id);
550
- }
551
- setupResizeObserver() {
552
- this.#resizeObserver = new ResizeObserver(entries => {
553
- window.requestAnimationFrame(() => {
554
- if (!Array.isArray(entries) || !entries.length) {
555
- return;
556
- }
557
- this.updateScrollVisibility();
558
- });
559
- });
560
- this.#resizeObserver.observe(this.tabListElement().nativeElement);
561
- }
562
- setupScrolling() {
563
- this.#scrollIntent$
564
- .pipe(takeUntilDestroyed(this.#destroyRef), switchMap(intent => {
565
- if (!intent) {
566
- return EMPTY;
567
- }
568
- const { element, direction, type } = intent;
569
- const timeFunction = type === "single" ? timer : interval;
570
- return timeFunction(60).pipe(tap(() => this.performScroll(element, direction)));
571
- }))
572
- .subscribe();
573
- }
574
- tabElementOf(tabId) {
575
- return this.tabElements().find(tab => tab.nativeElement.id === tabId + "-tab")?.nativeElement;
576
- }
577
- /**
578
- * The tab a key press applies to: the one focus is in, which may not be the selected one after a vetoed selection.
579
- * Keys pressed anywhere else in the strip, such as on a close button, belong to no tab.
580
- */
581
- tabFromEvent(tabs, event) {
582
- const target = event.target;
583
- if (!target) {
584
- return tabs.find(tab => tab.id === this.selectedTabId());
585
- }
586
- const tabElement = target.closest("[role='tab']");
587
- return tabElement ? tabs.find(tab => tab.id + "-tab" === tabElement.id) : undefined;
588
- }
589
- updateScrollVisibility() {
590
- asapScheduler.schedule(() => {
591
- const element = this.tabListElement().nativeElement;
592
- const isVertical = this.orientation() === "vertical";
593
- this.overflowControlsVisible.set(isVertical ? element.scrollHeight > element.clientHeight : element.scrollWidth > element.clientWidth);
594
- });
595
- }
596
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
597
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: TabListComponent, isStandalone: true, selector: "mona-tab-list", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, closable: { classPropertyName: "closable", publicName: "closable", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: true, transformFunction: null }, selectedTabId: { classPropertyName: "selectedTabId", publicName: "selectedTabId", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: true, transformFunction: null }, tabList: { classPropertyName: "tabList", publicName: "tabList", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { selectedTabId: "selectedTabIdChange", tabClose: "tabClose", tabSelect: "tabSelect" }, host: { listeners: { "focusin": "onFocusIn($event)", "focusout": "onFocusOut($event)", "keydown": "onKeydown($event)" }, properties: { "attr.aria-label": "null", "attr.aria-labelledby": "null", "class": "baseClass()" } }, viewQueries: [{ propertyName: "tabElements", predicate: ["tabElement"], descendants: true, isSignal: true }, { propertyName: "tabListElement", first: true, predicate: ["tabListElement"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (overflowControlsVisible()) {\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n size=\"small\"\n [class]=\"scrollButtonClass()\"\n [attr.aria-label]=\"messages().scrollPrevious\"\n (click)=\"startScrolling(tabListElement, 'previous', 'single')\"\n (pointerdown)=\"startContinuousScroll($event, tabListElement, 'previous')\"\n (pointerup)=\"stopScrolling()\"\n (pointercancel)=\"stopScrolling()\"\n [attr.aria-hidden]=\"true\"\n tabindex=\"-1\">\n @if (orientation() === 'vertical') {\n <svg lucideChevronUp [size]=\"16\"></svg>\n } @else {\n <svg lucideChevronLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n </button>\n}\n<div [class]=\"listWrapperClass()\">\n <ul\n [class]=\"listClass()\"\n #tabListElement\n role=\"tablist\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-orientation]=\"orientation()\">\n @for (tab of tabList(); track tab.id) {\n @let selected = tab.id === selectedTabId();\n @let itemDisabled = tab.disabled || disabled();\n @let tabClosable = tab.closable || closable();\n <li\n monaTabListItem\n [active]=\"selected\"\n [disabled]=\"itemDisabled\"\n [position]=\"position()\"\n [size]=\"size()\"\n role=\"presentation\"\n [attr.data-selected]=\"selected\"\n [attr.data-tab-id]=\"tab.id\">\n <div\n #tabElement\n [class]=\"tabClass()\"\n [id]=\"tab.id + '-tab'\"\n role=\"tab\"\n [tabindex]=\"selected ? 0 : -1\"\n [attr.aria-selected]=\"selected\"\n [attr.aria-disabled]=\"itemDisabled\"\n [attr.aria-controls]=\"tab.id + '-panel'\"\n [attr.aria-keyshortcuts]=\"tabClosable && !itemDisabled ? 'Delete Backspace' : null\"\n (click)=\"onTabClick(tab, $event)\">\n <div>\n @if (tab.titleTemplate) {\n <ng-container [ngTemplateOutlet]=\"tab.titleTemplate\"></ng-container>\n } @else {\n <span>{{ tab.title }}</span>\n }\n </div>\n </div>\n @if (tabClosable) {\n <!-- For the pointer. A button assistive technology can see isn't allowed inside a tablist. -->\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n data-tab-close\n [disabled]=\"itemDisabled\"\n [attr.aria-hidden]=\"true\"\n [attr.aria-label]=\"messages().closeTab\"\n (click)=\"onTabClose(tab, $event)\"\n [class]=\"closeButtonClass()\"\n tabindex=\"-1\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n }\n </li>\n }\n </ul>\n</div>\n@if (hasClosableTabs()) {\n <!-- The same action for assistive technology, outside the tablist. The keyboard's route is Delete. -->\n <div class=\"sr-only\">\n @for (tab of tabList(); track tab.id) {\n @if (tab.closable || closable()) {\n <button\n type=\"button\"\n tabindex=\"-1\"\n [id]=\"tab.id + '-close'\"\n [disabled]=\"tab.disabled || disabled()\"\n [attr.aria-label]=\"messages().closeTab\"\n [attr.aria-labelledby]=\"tab.id + '-close ' + tab.id + '-tab'\"\n [attr.data-tab-id]=\"tab.id\"\n (click)=\"onTabClose(tab, $event)\"></button>\n }\n }\n </div>\n}\n@if (overflowControlsVisible()) {\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n size=\"small\"\n [class]=\"scrollButtonClass()\"\n [attr.aria-label]=\"messages().scrollNext\"\n (click)=\"startScrolling(tabListElement, 'next', 'single')\"\n (pointerdown)=\"startContinuousScroll($event, tabListElement, 'next')\"\n (pointerup)=\"stopScrolling()\"\n (pointercancel)=\"stopScrolling()\"\n [attr.aria-hidden]=\"true\"\n tabindex=\"-1\">\n @if (orientation() === 'vertical') {\n <svg lucideChevronDown [size]=\"16\"></svg>\n } @else {\n <svg lucideChevronRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n </button>\n}\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class", "value"], outputs: ["lookChange", "selectedChange"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: TabListItemDirective, selector: "li[monaTabListItem]", inputs: ["active", "disabled", "position", "size"] }, { kind: "component", type: LucideChevronDown, selector: "svg[lucideChevronDown]" }, { kind: "component", type: LucideChevronLeft, selector: "svg[lucideChevronLeft]" }, { kind: "component", type: LucideChevronRight, selector: "svg[lucideChevronRight]" }, { kind: "component", type: LucideChevronUp, selector: "svg[lucideChevronUp]" }, { kind: "component", type: LucideX, selector: "svg[lucideX]" }] }); }
598
- }
599
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabListComponent, decorators: [{
600
- type: Component,
601
- args: [{ selector: "mona-tab-list", imports: [
602
- ButtonDirective,
603
- NgTemplateOutlet,
604
- TabListItemDirective,
605
- LucideChevronDown,
606
- LucideChevronLeft,
607
- LucideChevronRight,
608
- LucideChevronUp,
609
- LucideX
610
- ], host: {
611
- "[attr.aria-label]": "null",
612
- "[attr.aria-labelledby]": "null",
613
- "[class]": "baseClass()",
614
- "(focusin)": "onFocusIn($event)",
615
- "(focusout)": "onFocusOut($event)",
616
- "(keydown)": "onKeydown($event)"
617
- }, template: "@if (overflowControlsVisible()) {\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n size=\"small\"\n [class]=\"scrollButtonClass()\"\n [attr.aria-label]=\"messages().scrollPrevious\"\n (click)=\"startScrolling(tabListElement, 'previous', 'single')\"\n (pointerdown)=\"startContinuousScroll($event, tabListElement, 'previous')\"\n (pointerup)=\"stopScrolling()\"\n (pointercancel)=\"stopScrolling()\"\n [attr.aria-hidden]=\"true\"\n tabindex=\"-1\">\n @if (orientation() === 'vertical') {\n <svg lucideChevronUp [size]=\"16\"></svg>\n } @else {\n <svg lucideChevronLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n </button>\n}\n<div [class]=\"listWrapperClass()\">\n <ul\n [class]=\"listClass()\"\n #tabListElement\n role=\"tablist\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-orientation]=\"orientation()\">\n @for (tab of tabList(); track tab.id) {\n @let selected = tab.id === selectedTabId();\n @let itemDisabled = tab.disabled || disabled();\n @let tabClosable = tab.closable || closable();\n <li\n monaTabListItem\n [active]=\"selected\"\n [disabled]=\"itemDisabled\"\n [position]=\"position()\"\n [size]=\"size()\"\n role=\"presentation\"\n [attr.data-selected]=\"selected\"\n [attr.data-tab-id]=\"tab.id\">\n <div\n #tabElement\n [class]=\"tabClass()\"\n [id]=\"tab.id + '-tab'\"\n role=\"tab\"\n [tabindex]=\"selected ? 0 : -1\"\n [attr.aria-selected]=\"selected\"\n [attr.aria-disabled]=\"itemDisabled\"\n [attr.aria-controls]=\"tab.id + '-panel'\"\n [attr.aria-keyshortcuts]=\"tabClosable && !itemDisabled ? 'Delete Backspace' : null\"\n (click)=\"onTabClick(tab, $event)\">\n <div>\n @if (tab.titleTemplate) {\n <ng-container [ngTemplateOutlet]=\"tab.titleTemplate\"></ng-container>\n } @else {\n <span>{{ tab.title }}</span>\n }\n </div>\n </div>\n @if (tabClosable) {\n <!-- For the pointer. A button assistive technology can see isn't allowed inside a tablist. -->\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n data-tab-close\n [disabled]=\"itemDisabled\"\n [attr.aria-hidden]=\"true\"\n [attr.aria-label]=\"messages().closeTab\"\n (click)=\"onTabClose(tab, $event)\"\n [class]=\"closeButtonClass()\"\n tabindex=\"-1\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n }\n </li>\n }\n </ul>\n</div>\n@if (hasClosableTabs()) {\n <!-- The same action for assistive technology, outside the tablist. The keyboard's route is Delete. -->\n <div class=\"sr-only\">\n @for (tab of tabList(); track tab.id) {\n @if (tab.closable || closable()) {\n <button\n type=\"button\"\n tabindex=\"-1\"\n [id]=\"tab.id + '-close'\"\n [disabled]=\"tab.disabled || disabled()\"\n [attr.aria-label]=\"messages().closeTab\"\n [attr.aria-labelledby]=\"tab.id + '-close ' + tab.id + '-tab'\"\n [attr.data-tab-id]=\"tab.id\"\n (click)=\"onTabClose(tab, $event)\"></button>\n }\n }\n </div>\n}\n@if (overflowControlsVisible()) {\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n size=\"small\"\n [class]=\"scrollButtonClass()\"\n [attr.aria-label]=\"messages().scrollNext\"\n (click)=\"startScrolling(tabListElement, 'next', 'single')\"\n (pointerdown)=\"startContinuousScroll($event, tabListElement, 'next')\"\n (pointerup)=\"stopScrolling()\"\n (pointercancel)=\"stopScrolling()\"\n [attr.aria-hidden]=\"true\"\n tabindex=\"-1\">\n @if (orientation() === 'vertical') {\n <svg lucideChevronDown [size]=\"16\"></svg>\n } @else {\n <svg lucideChevronRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n </button>\n}\n" }]
618
- }], ctorParameters: () => [], propDecorators: { tabElements: [{ type: i0.ViewChildren, args: ["tabElement", { isSignal: true }] }], tabListElement: [{ type: i0.ViewChild, args: ["tabListElement", { isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: true }] }], selectedTabId: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedTabId", required: false }] }, { type: i0.Output, args: ["selectedTabIdChange"] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: true }] }], tabClose: [{ type: i0.Output, args: ["tabClose"] }], tabList: [{ type: i0.Input, args: [{ isSignal: true, alias: "tabList", required: true }] }], tabSelect: [{ type: i0.Output, args: ["tabSelect"] }] } });
619
-
620
- class TabComponent {
621
- constructor() {
622
- this.#id = createElementControlId();
623
- this.#tabItem = computed(() => {
624
- const closable = this.closable();
625
- const contentTemplate = this.contentTemplate();
626
- const disabled = this.disabled();
627
- const selected = this.selected();
628
- const titleTemplate = this.titleTemplate();
629
- const title = this.title();
630
- const id = this.#id;
631
- const tabItem = {
632
- closable,
633
- contentTemplate,
634
- disabled,
635
- id,
636
- index: 0,
637
- selected,
638
- title,
639
- titleTemplate
640
- };
641
- return tabItem;
642
- }, /* @ts-ignore */
643
- ...(ngDevMode ? [{ debugName: "#tabItem" }] : /* istanbul ignore next */ []));
644
- this.contentTemplate = contentChild(TabContentTemplateDirective, { ...(ngDevMode ? { debugName: "contentTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
645
- this.titleTemplate = contentChild(TabTitleTemplateDirective, { ...(ngDevMode ? { debugName: "titleTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
646
- /**
647
- * @description Displays a close button on this tab. Turning it on here shows the button even when the parent
648
- * `mona-tabs` has `closable` off; turning it off here doesn't hide a button the parent asked for.
649
- * @default false
650
- */
651
- this.closable = input(false, { ...(ngDevMode ? { debugName: "closable" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
652
- /**
653
- * @description Renders this tab with reduced visual emphasis and removes pointer and keyboard interaction. A tab is
654
- * disabled when this or the parent `mona-tabs` component's `disabled` input is on.
655
- * @default false
656
- */
657
- this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
658
- /**
659
- * @description Whether the tab is selected. Setting it to `true` selects the tab unless it's disabled, and it
660
- * follows the selection, so `[(selected)]` stays current. Setting it to `false` doesn't clear the selection, because
661
- * a group of tabs always keeps one selected.
662
- * @default false
663
- */
664
- this.selected = model(false, /* @ts-ignore */
665
- ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
666
- /**
667
- * @description Title text displayed on the tab.
668
- * @default ""
669
- */
670
- this.title = input("", /* @ts-ignore */
671
- ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
672
- }
673
- #id;
674
- #tabItem;
675
- /**
676
- * @internal
677
- */
678
- get tabItem() {
679
- return this.#tabItem();
680
- }
681
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
682
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: TabComponent, isStandalone: true, selector: "mona-tab", inputs: { closable: { classPropertyName: "closable", publicName: "closable", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, selected: { classPropertyName: "selected", publicName: "selected", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selected: "selectedChange" }, queries: [{ propertyName: "contentTemplate", first: true, predicate: TabContentTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "titleTemplate", first: true, predicate: TabTitleTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: "", isInline: true }); }
683
- }
684
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabComponent, decorators: [{
685
- type: Component,
686
- args: [{
687
- selector: "mona-tab",
688
- template: ""
689
- }]
690
- }], propDecorators: { contentTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => TabContentTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], titleTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => TabTitleTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], selected: [{ type: i0.Input, args: [{ isSignal: true, alias: "selected", required: false }] }, { type: i0.Output, args: ["selectedChange"] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }] } });
691
-
336
+ var TabListComponent = class TabListComponent {
337
+ #destroyRef;
338
+ #direction;
339
+ #hostElement;
340
+ #i18n;
341
+ #scrollIntent$;
342
+ #focusedTabId;
343
+ #resizeObserver;
344
+ constructor() {
345
+ this.#destroyRef = inject(DestroyRef);
346
+ this.#direction = injectComponentDirection();
347
+ this.#hostElement = inject(ElementRef).nativeElement;
348
+ this.#i18n = inject(MonaI18nService);
349
+ this.#scrollIntent$ = new Subject();
350
+ this.#focusedTabId = null;
351
+ this.#resizeObserver = null;
352
+ this.baseClass = computed(() => {
353
+ return tabListBaseThemeVariants({ position: this.position() });
354
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
355
+ this.closeButtonClass = computed(() => {
356
+ return tabListCloseButtonThemeVariants();
357
+ }, ...ngDevMode ? [{ debugName: "closeButtonClass" }] : /* istanbul ignore next */ []);
358
+ this.hasClosableTabs = computed(() => {
359
+ return this.closable() || Array.from(this.tabList()).some((tab) => tab.closable);
360
+ }, ...ngDevMode ? [{ debugName: "hasClosableTabs" }] : /* istanbul ignore next */ []);
361
+ this.isRtl = computed(() => this.#direction() === "rtl", ...ngDevMode ? [{ debugName: "isRtl" }] : /* istanbul ignore next */ []);
362
+ this.listClass = computed(() => {
363
+ return tabListListThemeVariants({ position: this.position() });
364
+ }, ...ngDevMode ? [{ debugName: "listClass" }] : /* istanbul ignore next */ []);
365
+ this.listWrapperClass = computed(() => {
366
+ return tabListListWrapperThemeVariants();
367
+ }, ...ngDevMode ? [{ debugName: "listWrapperClass" }] : /* istanbul ignore next */ []);
368
+ this.messages = this.#i18n.componentMessages("tabs", TABS_DEFAULT_MESSAGES);
369
+ this.orientation = computed(() => {
370
+ return getTabOrientation(this.position() ?? "top");
371
+ }, ...ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []);
372
+ this.overflowControlsVisible = signal(false, ...ngDevMode ? [{ debugName: "overflowControlsVisible" }] : /* istanbul ignore next */ []);
373
+ this.scrollButtonClass = computed(() => {
374
+ return tabListScrollButtonThemeVariants();
375
+ }, ...ngDevMode ? [{ debugName: "scrollButtonClass" }] : /* istanbul ignore next */ []);
376
+ this.tabClass = computed(() => {
377
+ return tabListTabThemeVariants({
378
+ position: this.position(),
379
+ size: this.size()
380
+ });
381
+ }, ...ngDevMode ? [{ debugName: "tabClass" }] : /* istanbul ignore next */ []);
382
+ this.tabElements = viewChildren("tabElement", ...ngDevMode ? [{ debugName: "tabElements" }] : /* istanbul ignore next */ []);
383
+ this.tabListElement = viewChild.required("tabListElement", ...ngDevMode ? [{ debugName: "tabListElement" }] : /* istanbul ignore next */ []);
384
+ this.ariaLabel = input("", {
385
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
386
+ alias: "aria-label"
387
+ });
388
+ this.ariaLabelledBy = input("", {
389
+ ...ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {},
390
+ alias: "aria-labelledby"
391
+ });
392
+ this.closable = input(false, ...ngDevMode ? [{ debugName: "closable" }] : /* istanbul ignore next */ []);
393
+ this.disabled = input(false, ...ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []);
394
+ this.position = input.required(...ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []);
395
+ this.selectedTabId = model(null, ...ngDevMode ? [{ debugName: "selectedTabId" }] : /* istanbul ignore next */ []);
396
+ this.size = input.required(...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
397
+ this.tabClose = output();
398
+ this.tabList = input.required(...ngDevMode ? [{ debugName: "tabList" }] : /* istanbul ignore next */ []);
399
+ this.tabSelect = output();
400
+ afterRenderEffect({ read: () => {
401
+ const tabs = Array.from(this.tabList());
402
+ this.position();
403
+ untracked(() => {
404
+ this.updateScrollVisibility();
405
+ this.restoreFocus(tabs);
406
+ });
407
+ } });
408
+ afterRenderEffect({ read: () => {
409
+ const selectedId = this.selectedTabId();
410
+ untracked(() => this.scrollTabIntoStrip(selectedId));
411
+ } });
412
+ this.setupScrolling();
413
+ afterNextRender({ read: () => this.setupResizeObserver() });
414
+ this.#destroyRef.onDestroy(() => this.#resizeObserver?.disconnect());
415
+ }
416
+ focusSelectedTab() {
417
+ const selectedTab = firstOrDefault(this.tabList(), (t) => t.id === this.selectedTabId());
418
+ if (selectedTab) this.focusTab(selectedTab);
419
+ }
420
+ onFocusIn(event) {
421
+ this.#focusedTabId = event.target.closest("[data-tab-id]")?.getAttribute("data-tab-id") ?? null;
422
+ }
423
+ onFocusOut(event) {
424
+ const target = event.target;
425
+ queueMicrotask(() => {
426
+ const root = this.#hostElement.getRootNode();
427
+ if (target.isConnected && !this.#hostElement.contains(root.activeElement)) this.#focusedTabId = null;
428
+ });
429
+ }
430
+ onKeydown(event) {
431
+ if (event.altKey || event.ctrlKey || event.metaKey) return;
432
+ const tabs = Array.from(this.tabList());
433
+ const currentTab = this.tabFromEvent(tabs, event);
434
+ if (!currentTab) return;
435
+ if (event.key === "Tab") {
436
+ if (!event.shiftKey) this.handleTabKey(tabs, event);
437
+ return;
438
+ }
439
+ if (!event.shiftKey) this.handleTabStripKey(tabs, currentTab, event);
440
+ }
441
+ onTabClick(tab, event) {
442
+ if (tab.disabled || this.disabled() || tab.id === this.selectedTabId()) return;
443
+ if (!this.emitTabSelect(tab, event)) this.selectTab(tab);
444
+ }
445
+ onTabClose(tab, event) {
446
+ event.stopPropagation();
447
+ this.emitTabClose(tab, event);
448
+ }
449
+ startContinuousScroll(event, element, direction) {
450
+ event.currentTarget.setPointerCapture(event.pointerId);
451
+ this.startScrolling(element, direction, "continuous");
452
+ }
453
+ startScrolling(element, direction, type) {
454
+ this.#scrollIntent$.next({
455
+ element,
456
+ direction,
457
+ type
458
+ });
459
+ }
460
+ stopScrolling() {
461
+ this.#scrollIntent$.next(null);
462
+ }
463
+ activateTab(tab, event) {
464
+ if (tab.id !== this.selectedTabId() && !this.emitTabSelect(tab, event)) this.selectTab(tab);
465
+ this.focusTab(tab);
466
+ }
467
+ adjacentEnabledTab(tabs, from, offset) {
468
+ const start = tabs.indexOf(from);
469
+ for (let step = 1; step <= tabs.length; step++) {
470
+ const candidate = tabs[(start + offset * step + tabs.length * step) % tabs.length];
471
+ if (this.isTabEnabled(candidate)) return candidate;
472
+ }
473
+ }
474
+ emitTabClose(tabItem, event) {
475
+ this.tabClose.emit(new TabCloseEvent(tabItem.index, tabItem.id === this.selectedTabId(), event));
476
+ }
477
+ emitTabSelect(tab, event) {
478
+ const selectEvent = new TabSelectEvent(tab.index, event);
479
+ this.tabSelect.emit(selectEvent);
480
+ return selectEvent.isDefaultPrevented();
481
+ }
482
+ focusTab(tab) {
483
+ this.tabElementOf(tab.id)?.focus();
484
+ }
485
+ getNavigationDirection(event) {
486
+ if (this.orientation() === "vertical") {
487
+ if (event.key === "ArrowUp") return "previous";
488
+ if (event.key === "ArrowDown") return "next";
489
+ return null;
490
+ }
491
+ const isRtl = this.isRtl();
492
+ if (event.key === "ArrowLeft") return isRtl ? "next" : "previous";
493
+ if (event.key === "ArrowRight") return isRtl ? "previous" : "next";
494
+ return null;
495
+ }
496
+ handleTabKey(tabs, event) {
497
+ const selectedTab = tabs.find((t) => t.id === this.selectedTabId());
498
+ if (!selectedTab) return;
499
+ const panel = this.#hostElement.getRootNode().getElementById(selectedTab.id + "-panel");
500
+ if (panel) {
501
+ event.preventDefault();
502
+ panel.focus();
503
+ }
504
+ }
505
+ handleTabStripKey(tabs, currentTab, event) {
506
+ const enabledTabs = tabs.filter((t) => this.isTabEnabled(t));
507
+ if (enabledTabs.length === 0) return;
508
+ const navigationDirection = this.getNavigationDirection(event);
509
+ if (navigationDirection) {
510
+ event.preventDefault();
511
+ const target = this.adjacentEnabledTab(tabs, currentTab, navigationDirection === "next" ? 1 : -1);
512
+ if (target) this.activateTab(target, event);
513
+ return;
514
+ }
515
+ switch (event.key) {
516
+ case "Home":
517
+ event.preventDefault();
518
+ this.activateTab(enabledTabs[0], event);
519
+ break;
520
+ case "End":
521
+ event.preventDefault();
522
+ this.activateTab(enabledTabs[enabledTabs.length - 1], event);
523
+ break;
524
+ case "Delete":
525
+ case "Backspace": if (this.isTabEnabled(currentTab) && (currentTab.closable || this.closable())) {
526
+ event.preventDefault();
527
+ this.emitTabClose(currentTab, event);
528
+ }
529
+ }
530
+ }
531
+ isTabEnabled(tab) {
532
+ return !tab.disabled && !this.disabled();
533
+ }
534
+ performScroll(element, direction) {
535
+ let offset = direction === "previous" ? -100 : 100;
536
+ const behavior = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
537
+ if (this.orientation() === "vertical") {
538
+ element.scrollBy({
539
+ top: offset,
540
+ behavior
541
+ });
542
+ return;
543
+ }
544
+ if (this.isRtl()) offset = -offset;
545
+ element.scrollBy({
546
+ left: offset,
547
+ behavior
548
+ });
549
+ }
550
+ restoreFocus(tabs) {
551
+ const focusedTabId = this.#focusedTabId;
552
+ if (focusedTabId === null || tabs.some((tab) => tab.id === focusedTabId)) return;
553
+ this.#focusedTabId = null;
554
+ const active = this.#hostElement.getRootNode().activeElement;
555
+ if (!active || active === this.#hostElement.ownerDocument.body) this.focusSelectedTab();
556
+ }
557
+ scrollTabIntoStrip(tabId) {
558
+ const tabElement = tabId === null ? void 0 : this.tabElementOf(tabId);
559
+ if (!tabElement) return;
560
+ const list = this.tabListElement().nativeElement;
561
+ const listRect = list.getBoundingClientRect();
562
+ const tabRect = tabElement.getBoundingClientRect();
563
+ if (this.orientation() === "vertical") {
564
+ const top = Math.min(tabRect.top - listRect.top, 0) || Math.max(tabRect.bottom - listRect.bottom, 0);
565
+ if (top !== 0) list.scrollBy({ top });
566
+ return;
567
+ }
568
+ const left = Math.min(tabRect.left - listRect.left, 0) || Math.max(tabRect.right - listRect.right, 0);
569
+ if (left !== 0) list.scrollBy({ left });
570
+ }
571
+ selectTab(tab) {
572
+ this.selectedTabId.set(tab.id);
573
+ }
574
+ setupResizeObserver() {
575
+ this.#resizeObserver = new ResizeObserver((entries) => {
576
+ window.requestAnimationFrame(() => {
577
+ if (!Array.isArray(entries) || !entries.length) return;
578
+ this.updateScrollVisibility();
579
+ });
580
+ });
581
+ this.#resizeObserver.observe(this.tabListElement().nativeElement);
582
+ }
583
+ setupScrolling() {
584
+ this.#scrollIntent$.pipe(takeUntilDestroyed(this.#destroyRef), switchMap((intent) => {
585
+ if (!intent) return EMPTY;
586
+ const { element, direction, type } = intent;
587
+ return (type === "single" ? timer : interval)(60).pipe(tap(() => this.performScroll(element, direction)));
588
+ })).subscribe();
589
+ }
590
+ tabElementOf(tabId) {
591
+ return this.tabElements().find((tab) => tab.nativeElement.id === tabId + "-tab")?.nativeElement;
592
+ }
593
+ tabFromEvent(tabs, event) {
594
+ const target = event.target;
595
+ if (!target) return tabs.find((tab) => tab.id === this.selectedTabId());
596
+ const tabElement = target.closest("[role='tab']");
597
+ return tabElement ? tabs.find((tab) => tab.id + "-tab" === tabElement.id) : void 0;
598
+ }
599
+ updateScrollVisibility() {
600
+ asapScheduler.schedule(() => {
601
+ const element = this.tabListElement().nativeElement;
602
+ const isVertical = this.orientation() === "vertical";
603
+ this.overflowControlsVisible.set(isVertical ? element.scrollHeight > element.clientHeight : element.scrollWidth > element.clientWidth);
604
+ });
605
+ }
606
+ static {
607
+ this.ɵfac = i0.ɵɵngDeclareFactory({
608
+ minVersion: "12.0.0",
609
+ version: "22.2.6",
610
+ ngImport: i0,
611
+ type: TabListComponent,
612
+ deps: [],
613
+ target: i0.ɵɵFactoryTarget.Component
614
+ });
615
+ }
616
+ static {
617
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
618
+ minVersion: "17.0.0",
619
+ version: "22.2.6",
620
+ type: TabListComponent,
621
+ isStandalone: true,
622
+ selector: "mona-tab-list",
623
+ inputs: {
624
+ ariaLabel: {
625
+ classPropertyName: "ariaLabel",
626
+ publicName: "aria-label",
627
+ isSignal: true,
628
+ isRequired: false,
629
+ transformFunction: null
630
+ },
631
+ ariaLabelledBy: {
632
+ classPropertyName: "ariaLabelledBy",
633
+ publicName: "aria-labelledby",
634
+ isSignal: true,
635
+ isRequired: false,
636
+ transformFunction: null
637
+ },
638
+ closable: {
639
+ classPropertyName: "closable",
640
+ publicName: "closable",
641
+ isSignal: true,
642
+ isRequired: false,
643
+ transformFunction: null
644
+ },
645
+ disabled: {
646
+ classPropertyName: "disabled",
647
+ publicName: "disabled",
648
+ isSignal: true,
649
+ isRequired: false,
650
+ transformFunction: null
651
+ },
652
+ position: {
653
+ classPropertyName: "position",
654
+ publicName: "position",
655
+ isSignal: true,
656
+ isRequired: true,
657
+ transformFunction: null
658
+ },
659
+ selectedTabId: {
660
+ classPropertyName: "selectedTabId",
661
+ publicName: "selectedTabId",
662
+ isSignal: true,
663
+ isRequired: false,
664
+ transformFunction: null
665
+ },
666
+ size: {
667
+ classPropertyName: "size",
668
+ publicName: "size",
669
+ isSignal: true,
670
+ isRequired: true,
671
+ transformFunction: null
672
+ },
673
+ tabList: {
674
+ classPropertyName: "tabList",
675
+ publicName: "tabList",
676
+ isSignal: true,
677
+ isRequired: true,
678
+ transformFunction: null
679
+ }
680
+ },
681
+ outputs: {
682
+ selectedTabId: "selectedTabIdChange",
683
+ tabClose: "tabClose",
684
+ tabSelect: "tabSelect"
685
+ },
686
+ host: {
687
+ listeners: {
688
+ "focusin": "onFocusIn($event)",
689
+ "focusout": "onFocusOut($event)",
690
+ "keydown": "onKeydown($event)"
691
+ },
692
+ properties: {
693
+ "attr.aria-label": "null",
694
+ "attr.aria-labelledby": "null",
695
+ "class": "baseClass()"
696
+ }
697
+ },
698
+ viewQueries: [{
699
+ propertyName: "tabElements",
700
+ predicate: ["tabElement"],
701
+ descendants: true,
702
+ isSignal: true
703
+ }, {
704
+ propertyName: "tabListElement",
705
+ first: true,
706
+ predicate: ["tabListElement"],
707
+ descendants: true,
708
+ isSignal: true
709
+ }],
710
+ ngImport: i0,
711
+ template: "@if (overflowControlsVisible()) {\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n size=\"small\"\n [class]=\"scrollButtonClass()\"\n [attr.aria-label]=\"messages().scrollPrevious\"\n (click)=\"startScrolling(tabListElement, 'previous', 'single')\"\n (pointerdown)=\"startContinuousScroll($event, tabListElement, 'previous')\"\n (pointerup)=\"stopScrolling()\"\n (pointercancel)=\"stopScrolling()\"\n [attr.aria-hidden]=\"true\"\n tabindex=\"-1\">\n @if (orientation() === 'vertical') {\n <svg lucideChevronUp [size]=\"16\"></svg>\n } @else {\n <svg lucideChevronLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n </button>\n}\n<div [class]=\"listWrapperClass()\">\n <ul\n [class]=\"listClass()\"\n #tabListElement\n role=\"tablist\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-orientation]=\"orientation()\">\n @for (tab of tabList(); track tab.id) {\n @let selected = tab.id === selectedTabId();\n @let itemDisabled = tab.disabled || disabled();\n @let tabClosable = tab.closable || closable();\n <li\n monaTabListItem\n [active]=\"selected\"\n [disabled]=\"itemDisabled\"\n [position]=\"position()\"\n [size]=\"size()\"\n role=\"presentation\"\n [attr.data-selected]=\"selected\"\n [attr.data-tab-id]=\"tab.id\">\n <div\n #tabElement\n [class]=\"tabClass()\"\n [id]=\"tab.id + '-tab'\"\n role=\"tab\"\n [tabindex]=\"selected ? 0 : -1\"\n [attr.aria-selected]=\"selected\"\n [attr.aria-disabled]=\"itemDisabled\"\n [attr.aria-controls]=\"tab.id + '-panel'\"\n [attr.aria-keyshortcuts]=\"tabClosable && !itemDisabled ? 'Delete Backspace' : null\"\n (click)=\"onTabClick(tab, $event)\">\n <div>\n @if (tab.titleTemplate) {\n <ng-container [ngTemplateOutlet]=\"tab.titleTemplate\"></ng-container>\n } @else {\n <span>{{ tab.title }}</span>\n }\n </div>\n </div>\n @if (tabClosable) {\n <!-- For the pointer. A button assistive technology can see isn't allowed inside a tablist. -->\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n data-tab-close\n [disabled]=\"itemDisabled\"\n [attr.aria-hidden]=\"true\"\n [attr.aria-label]=\"messages().closeTab\"\n (click)=\"onTabClose(tab, $event)\"\n [class]=\"closeButtonClass()\"\n tabindex=\"-1\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n }\n </li>\n }\n </ul>\n</div>\n@if (hasClosableTabs()) {\n <!-- The same action for assistive technology, outside the tablist. The keyboard's route is Delete. -->\n <div class=\"sr-only\">\n @for (tab of tabList(); track tab.id) {\n @if (tab.closable || closable()) {\n <button\n type=\"button\"\n tabindex=\"-1\"\n [id]=\"tab.id + '-close'\"\n [disabled]=\"tab.disabled || disabled()\"\n [attr.aria-label]=\"messages().closeTab\"\n [attr.aria-labelledby]=\"tab.id + '-close ' + tab.id + '-tab'\"\n [attr.data-tab-id]=\"tab.id\"\n (click)=\"onTabClose(tab, $event)\"></button>\n }\n }\n </div>\n}\n@if (overflowControlsVisible()) {\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n size=\"small\"\n [class]=\"scrollButtonClass()\"\n [attr.aria-label]=\"messages().scrollNext\"\n (click)=\"startScrolling(tabListElement, 'next', 'single')\"\n (pointerdown)=\"startContinuousScroll($event, tabListElement, 'next')\"\n (pointerup)=\"stopScrolling()\"\n (pointercancel)=\"stopScrolling()\"\n [attr.aria-hidden]=\"true\"\n tabindex=\"-1\">\n @if (orientation() === 'vertical') {\n <svg lucideChevronDown [size]=\"16\"></svg>\n } @else {\n <svg lucideChevronRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n </button>\n}\n",
712
+ dependencies: [
713
+ {
714
+ kind: "directive",
715
+ type: ButtonDirective,
716
+ selector: "button[monaButton]",
717
+ inputs: [
718
+ "aria-haspopup",
719
+ "disabled",
720
+ "iconOnly",
721
+ "loading",
722
+ "look",
723
+ "rounded",
724
+ "selected",
725
+ "size",
726
+ "tabindex",
727
+ "toggleable",
728
+ "type",
729
+ "class",
730
+ "value"
731
+ ],
732
+ outputs: ["lookChange", "selectedChange"]
733
+ },
734
+ {
735
+ kind: "directive",
736
+ type: NgTemplateOutlet,
737
+ selector: "[ngTemplateOutlet]",
738
+ inputs: [
739
+ "ngTemplateOutletContext",
740
+ "ngTemplateOutlet",
741
+ "ngTemplateOutletInjector"
742
+ ]
743
+ },
744
+ {
745
+ kind: "directive",
746
+ type: TabListItemDirective,
747
+ selector: "li[monaTabListItem]",
748
+ inputs: [
749
+ "active",
750
+ "disabled",
751
+ "position",
752
+ "size"
753
+ ]
754
+ },
755
+ {
756
+ kind: "component",
757
+ type: LucideChevronDown,
758
+ selector: "svg[lucideChevronDown]"
759
+ },
760
+ {
761
+ kind: "component",
762
+ type: LucideChevronLeft,
763
+ selector: "svg[lucideChevronLeft]"
764
+ },
765
+ {
766
+ kind: "component",
767
+ type: LucideChevronRight,
768
+ selector: "svg[lucideChevronRight]"
769
+ },
770
+ {
771
+ kind: "component",
772
+ type: LucideChevronUp,
773
+ selector: "svg[lucideChevronUp]"
774
+ },
775
+ {
776
+ kind: "component",
777
+ type: LucideX,
778
+ selector: "svg[lucideX]"
779
+ }
780
+ ]
781
+ });
782
+ }
783
+ };
784
+ i0.ɵɵngDeclareClassMetadata({
785
+ minVersion: "12.0.0",
786
+ version: "22.2.6",
787
+ ngImport: i0,
788
+ type: TabListComponent,
789
+ decorators: [{
790
+ type: Component,
791
+ args: [{
792
+ selector: "mona-tab-list",
793
+ imports: [
794
+ ButtonDirective,
795
+ NgTemplateOutlet,
796
+ TabListItemDirective,
797
+ LucideChevronDown,
798
+ LucideChevronLeft,
799
+ LucideChevronRight,
800
+ LucideChevronUp,
801
+ LucideX
802
+ ],
803
+ host: {
804
+ "[attr.aria-label]": "null",
805
+ "[attr.aria-labelledby]": "null",
806
+ "[class]": "baseClass()",
807
+ "(focusin)": "onFocusIn($event)",
808
+ "(focusout)": "onFocusOut($event)",
809
+ "(keydown)": "onKeydown($event)"
810
+ },
811
+ template: "@if (overflowControlsVisible()) {\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n size=\"small\"\n [class]=\"scrollButtonClass()\"\n [attr.aria-label]=\"messages().scrollPrevious\"\n (click)=\"startScrolling(tabListElement, 'previous', 'single')\"\n (pointerdown)=\"startContinuousScroll($event, tabListElement, 'previous')\"\n (pointerup)=\"stopScrolling()\"\n (pointercancel)=\"stopScrolling()\"\n [attr.aria-hidden]=\"true\"\n tabindex=\"-1\">\n @if (orientation() === 'vertical') {\n <svg lucideChevronUp [size]=\"16\"></svg>\n } @else {\n <svg lucideChevronLeft [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n </button>\n}\n<div [class]=\"listWrapperClass()\">\n <ul\n [class]=\"listClass()\"\n #tabListElement\n role=\"tablist\"\n [attr.aria-label]=\"ariaLabel() || null\"\n [attr.aria-labelledby]=\"ariaLabelledBy() || null\"\n [attr.aria-orientation]=\"orientation()\">\n @for (tab of tabList(); track tab.id) {\n @let selected = tab.id === selectedTabId();\n @let itemDisabled = tab.disabled || disabled();\n @let tabClosable = tab.closable || closable();\n <li\n monaTabListItem\n [active]=\"selected\"\n [disabled]=\"itemDisabled\"\n [position]=\"position()\"\n [size]=\"size()\"\n role=\"presentation\"\n [attr.data-selected]=\"selected\"\n [attr.data-tab-id]=\"tab.id\">\n <div\n #tabElement\n [class]=\"tabClass()\"\n [id]=\"tab.id + '-tab'\"\n role=\"tab\"\n [tabindex]=\"selected ? 0 : -1\"\n [attr.aria-selected]=\"selected\"\n [attr.aria-disabled]=\"itemDisabled\"\n [attr.aria-controls]=\"tab.id + '-panel'\"\n [attr.aria-keyshortcuts]=\"tabClosable && !itemDisabled ? 'Delete Backspace' : null\"\n (click)=\"onTabClick(tab, $event)\">\n <div>\n @if (tab.titleTemplate) {\n <ng-container [ngTemplateOutlet]=\"tab.titleTemplate\"></ng-container>\n } @else {\n <span>{{ tab.title }}</span>\n }\n </div>\n </div>\n @if (tabClosable) {\n <!-- For the pointer. A button assistive technology can see isn't allowed inside a tablist. -->\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n data-tab-close\n [disabled]=\"itemDisabled\"\n [attr.aria-hidden]=\"true\"\n [attr.aria-label]=\"messages().closeTab\"\n (click)=\"onTabClose(tab, $event)\"\n [class]=\"closeButtonClass()\"\n tabindex=\"-1\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n }\n </li>\n }\n </ul>\n</div>\n@if (hasClosableTabs()) {\n <!-- The same action for assistive technology, outside the tablist. The keyboard's route is Delete. -->\n <div class=\"sr-only\">\n @for (tab of tabList(); track tab.id) {\n @if (tab.closable || closable()) {\n <button\n type=\"button\"\n tabindex=\"-1\"\n [id]=\"tab.id + '-close'\"\n [disabled]=\"tab.disabled || disabled()\"\n [attr.aria-label]=\"messages().closeTab\"\n [attr.aria-labelledby]=\"tab.id + '-close ' + tab.id + '-tab'\"\n [attr.data-tab-id]=\"tab.id\"\n (click)=\"onTabClose(tab, $event)\"></button>\n }\n }\n </div>\n}\n@if (overflowControlsVisible()) {\n <button\n monaButton\n type=\"button\"\n look=\"link\"\n size=\"small\"\n [class]=\"scrollButtonClass()\"\n [attr.aria-label]=\"messages().scrollNext\"\n (click)=\"startScrolling(tabListElement, 'next', 'single')\"\n (pointerdown)=\"startContinuousScroll($event, tabListElement, 'next')\"\n (pointerup)=\"stopScrolling()\"\n (pointercancel)=\"stopScrolling()\"\n [attr.aria-hidden]=\"true\"\n tabindex=\"-1\">\n @if (orientation() === 'vertical') {\n <svg lucideChevronDown [size]=\"16\"></svg>\n } @else {\n <svg lucideChevronRight [size]=\"16\" class=\"rtl:rotate-180\"></svg>\n }\n </button>\n}\n"
812
+ }]
813
+ }],
814
+ ctorParameters: () => [],
815
+ propDecorators: {
816
+ tabElements: [{
817
+ type: i0.ViewChildren,
818
+ args: ["tabElement", { isSignal: true }]
819
+ }],
820
+ tabListElement: [{
821
+ type: i0.ViewChild,
822
+ args: ["tabListElement", { isSignal: true }]
823
+ }],
824
+ ariaLabel: [{
825
+ type: i0.Input,
826
+ args: [{
827
+ isSignal: true,
828
+ alias: "aria-label",
829
+ required: false
830
+ }]
831
+ }],
832
+ ariaLabelledBy: [{
833
+ type: i0.Input,
834
+ args: [{
835
+ isSignal: true,
836
+ alias: "aria-labelledby",
837
+ required: false
838
+ }]
839
+ }],
840
+ closable: [{
841
+ type: i0.Input,
842
+ args: [{
843
+ isSignal: true,
844
+ alias: "closable",
845
+ required: false
846
+ }]
847
+ }],
848
+ disabled: [{
849
+ type: i0.Input,
850
+ args: [{
851
+ isSignal: true,
852
+ alias: "disabled",
853
+ required: false
854
+ }]
855
+ }],
856
+ position: [{
857
+ type: i0.Input,
858
+ args: [{
859
+ isSignal: true,
860
+ alias: "position",
861
+ required: true
862
+ }]
863
+ }],
864
+ selectedTabId: [{
865
+ type: i0.Input,
866
+ args: [{
867
+ isSignal: true,
868
+ alias: "selectedTabId",
869
+ required: false
870
+ }]
871
+ }, {
872
+ type: i0.Output,
873
+ args: ["selectedTabIdChange"]
874
+ }],
875
+ size: [{
876
+ type: i0.Input,
877
+ args: [{
878
+ isSignal: true,
879
+ alias: "size",
880
+ required: true
881
+ }]
882
+ }],
883
+ tabClose: [{
884
+ type: i0.Output,
885
+ args: ["tabClose"]
886
+ }],
887
+ tabList: [{
888
+ type: i0.Input,
889
+ args: [{
890
+ isSignal: true,
891
+ alias: "tabList",
892
+ required: true
893
+ }]
894
+ }],
895
+ tabSelect: [{
896
+ type: i0.Output,
897
+ args: ["tabSelect"]
898
+ }]
899
+ }
900
+ });
901
+ var TabComponent = class TabComponent {
902
+ constructor() {
903
+ this.#id = createElementControlId();
904
+ this.#tabItem = computed(() => {
905
+ const closable = this.closable();
906
+ const contentTemplate = this.contentTemplate();
907
+ const disabled = this.disabled();
908
+ const selected = this.selected();
909
+ const titleTemplate = this.titleTemplate();
910
+ const title = this.title();
911
+ return {
912
+ closable,
913
+ contentTemplate,
914
+ disabled,
915
+ id: this.#id,
916
+ index: 0,
917
+ selected,
918
+ title,
919
+ titleTemplate
920
+ };
921
+ }, ...ngDevMode ? [{ debugName: "#tabItem" }] : /* istanbul ignore next */ []);
922
+ this.contentTemplate = contentChild(TabContentTemplateDirective, {
923
+ ...ngDevMode ? { debugName: "contentTemplate" } : /* istanbul ignore next */ {},
924
+ read: TemplateRef
925
+ });
926
+ this.titleTemplate = contentChild(TabTitleTemplateDirective, {
927
+ ...ngDevMode ? { debugName: "titleTemplate" } : /* istanbul ignore next */ {},
928
+ read: TemplateRef
929
+ });
930
+ this.closable = input(false, {
931
+ ...ngDevMode ? { debugName: "closable" } : /* istanbul ignore next */ {},
932
+ transform: booleanAttribute
933
+ });
934
+ this.disabled = input(false, {
935
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
936
+ transform: booleanAttribute
937
+ });
938
+ this.selected = model(false, ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
939
+ this.title = input("", ...ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []);
940
+ }
941
+ #id;
942
+ #tabItem;
943
+ get tabItem() {
944
+ return this.#tabItem();
945
+ }
946
+ static {
947
+ this.ɵfac = i0.ɵɵngDeclareFactory({
948
+ minVersion: "12.0.0",
949
+ version: "22.2.6",
950
+ ngImport: i0,
951
+ type: TabComponent,
952
+ deps: [],
953
+ target: i0.ɵɵFactoryTarget.Component
954
+ });
955
+ }
956
+ static {
957
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
958
+ minVersion: "17.2.0",
959
+ version: "22.2.6",
960
+ type: TabComponent,
961
+ isStandalone: true,
962
+ selector: "mona-tab",
963
+ inputs: {
964
+ closable: {
965
+ classPropertyName: "closable",
966
+ publicName: "closable",
967
+ isSignal: true,
968
+ isRequired: false,
969
+ transformFunction: null
970
+ },
971
+ disabled: {
972
+ classPropertyName: "disabled",
973
+ publicName: "disabled",
974
+ isSignal: true,
975
+ isRequired: false,
976
+ transformFunction: null
977
+ },
978
+ selected: {
979
+ classPropertyName: "selected",
980
+ publicName: "selected",
981
+ isSignal: true,
982
+ isRequired: false,
983
+ transformFunction: null
984
+ },
985
+ title: {
986
+ classPropertyName: "title",
987
+ publicName: "title",
988
+ isSignal: true,
989
+ isRequired: false,
990
+ transformFunction: null
991
+ }
992
+ },
993
+ outputs: { selected: "selectedChange" },
994
+ queries: [{
995
+ propertyName: "contentTemplate",
996
+ first: true,
997
+ predicate: TabContentTemplateDirective,
998
+ descendants: true,
999
+ read: TemplateRef,
1000
+ isSignal: true
1001
+ }, {
1002
+ propertyName: "titleTemplate",
1003
+ first: true,
1004
+ predicate: TabTitleTemplateDirective,
1005
+ descendants: true,
1006
+ read: TemplateRef,
1007
+ isSignal: true
1008
+ }],
1009
+ ngImport: i0,
1010
+ template: "",
1011
+ isInline: true
1012
+ });
1013
+ }
1014
+ };
1015
+ i0.ɵɵngDeclareClassMetadata({
1016
+ minVersion: "12.0.0",
1017
+ version: "22.2.6",
1018
+ ngImport: i0,
1019
+ type: TabComponent,
1020
+ decorators: [{
1021
+ type: Component,
1022
+ args: [{
1023
+ selector: "mona-tab",
1024
+ template: ""
1025
+ }]
1026
+ }],
1027
+ propDecorators: {
1028
+ contentTemplate: [{
1029
+ type: i0.ContentChild,
1030
+ args: [i0.forwardRef(() => TabContentTemplateDirective), {
1031
+ read: TemplateRef,
1032
+ isSignal: true
1033
+ }]
1034
+ }],
1035
+ titleTemplate: [{
1036
+ type: i0.ContentChild,
1037
+ args: [i0.forwardRef(() => TabTitleTemplateDirective), {
1038
+ read: TemplateRef,
1039
+ isSignal: true
1040
+ }]
1041
+ }],
1042
+ closable: [{
1043
+ type: i0.Input,
1044
+ args: [{
1045
+ isSignal: true,
1046
+ alias: "closable",
1047
+ required: false
1048
+ }]
1049
+ }],
1050
+ disabled: [{
1051
+ type: i0.Input,
1052
+ args: [{
1053
+ isSignal: true,
1054
+ alias: "disabled",
1055
+ required: false
1056
+ }]
1057
+ }],
1058
+ selected: [{
1059
+ type: i0.Input,
1060
+ args: [{
1061
+ isSignal: true,
1062
+ alias: "selected",
1063
+ required: false
1064
+ }]
1065
+ }, {
1066
+ type: i0.Output,
1067
+ args: ["selectedChange"]
1068
+ }],
1069
+ title: [{
1070
+ type: i0.Input,
1071
+ args: [{
1072
+ isSignal: true,
1073
+ alias: "title",
1074
+ required: false
1075
+ }]
1076
+ }]
1077
+ }
1078
+ });
692
1079
  function isEnabled(tab) {
693
- return !tab.disabled;
1080
+ return !tab.disabled;
694
1081
  }
695
- /** The tab to select after the selected one is gone: the one that took its place, else the nearest before it. */
696
1082
  function neighborOf(tabs, removedIndex) {
697
- return tabs.slice(removedIndex).find(isEnabled) ?? tabs.slice(0, removedIndex).reverse().find(isEnabled);
698
- }
699
- class TabsComponent {
700
- #flaggedTabId;
701
- #reportedIndex;
702
- /**
703
- * Whether the tabs have rendered. A tab in an `@for` gets its inputs after this component first reads it, so until then
704
- * a selection is only a first guess, and a tab that turns out to be disabled was never really selected.
705
- */
706
- #tabsSettled;
707
- constructor() {
708
- this.#flaggedTabId = null;
709
- this.#reportedIndex = null;
710
- /**
711
- * Whether the tabs have rendered. A tab in an `@for` gets its inputs after this component first reads it, so until then
712
- * a selection is only a first guess, and a tab that turns out to be disabled was never really selected.
713
- */
714
- this.#tabsSettled = false;
715
- this.baseClass = computed(() => {
716
- const variantClass = tabsBaseThemeVariants({ position: this.position() });
717
- const userClass = this.userClass();
718
- return twMerge(variantClass, userClass);
719
- }, /* @ts-ignore */
720
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
721
- this.contentClass = computed(() => {
722
- return tabContentThemeVariants();
723
- }, /* @ts-ignore */
724
- ...(ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []));
725
- this.selectedTabId = linkedSignal({ ...(ngDevMode ? { debugName: "selectedTabId" } : /* istanbul ignore next */ {}), source: () => this.tabList(),
726
- computation: (tabList, previous) => {
727
- const tabs = tabList.toArray();
728
- const previousId = previous?.value ?? null;
729
- if (previousId === null || !this.#tabsSettled) {
730
- const requested = tabs[untracked(this.selectedIndex)];
731
- return (requested && isEnabled(requested) ? requested : tabs.find(isEnabled))?.id ?? null;
732
- }
733
- if (tabs.some(tab => tab.id === previousId)) {
734
- return previousId;
735
- }
736
- const removedIndex = previous?.source.toArray().findIndex(tab => tab.id === previousId) ?? 0;
737
- return neighborOf(tabs, removedIndex)?.id ?? null;
738
- } });
739
- this.tabList = computed(() => {
740
- const tabs = this.tabs();
741
- return select(tabs, t => t.tabItem)
742
- .tap((t, tx) => (t.index = tx))
743
- .toImmutableSet();
744
- }, /* @ts-ignore */
745
- ...(ngDevMode ? [{ debugName: "tabList" }] : /* istanbul ignore next */ []));
746
- this.tabListComponent = viewChild.required(TabListComponent, /* @ts-ignore */
747
- ...(ngDevMode ? [{ debugName: "tabListComponent" }] : /* istanbul ignore next */ []));
748
- this.tabs = contentChildren(TabComponent, /* @ts-ignore */
749
- ...(ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []));
750
- /**
751
- * @description Accessible name for the tab list.
752
- * @default ""
753
- */
754
- this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
755
- /**
756
- * @description The id of an element that names the tab list. Takes precedence over `aria-label`.
757
- * @default ""
758
- */
759
- this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
760
- /**
761
- * @description Displays a close button on each tab. A tab's own `closable` can add a button, not remove this one.
762
- * @default false
763
- */
764
- this.closable = input(false, { ...(ngDevMode ? { debugName: "closable" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
765
- /**
766
- * @description Renders every tab with reduced visual emphasis and removes pointer and keyboard interaction.
767
- * @default false
768
- */
769
- this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
770
- /**
771
- * @description Keeps a tab's content in the DOM after it is deselected instead of removing it.
772
- * @default true
773
- */
774
- this.keepTabContent = input(true, { ...(ngDevMode ? { debugName: "keepTabContent" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
775
- /**
776
- * @description Placement of the tab list relative to the tab content.
777
- * @default "top"
778
- */
779
- this.position = input("top", /* @ts-ignore */
780
- ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
781
- /**
782
- * @description The zero-based index of the selected tab. Writing it selects that tab, unless it's disabled or out of
783
- * range, in which case the value goes back to the selected tab's index. It also changes when the component moves the
784
- * selection itself, such as when the selected tab is removed.
785
- * @default 0
786
- */
787
- this.selectedIndex = model(0, /* @ts-ignore */
788
- ...(ngDevMode ? [{ debugName: "selectedIndex" }] : /* istanbul ignore next */ []));
789
- /**
790
- * @description Size preset controlling the tabs' dimensions.
791
- * @default "medium"
792
- */
793
- this.size = input("medium", /* @ts-ignore */
794
- ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
795
- /**
796
- * @description Emitted with a {@link TabCloseEvent} when a close is requested. The component doesn't remove the tab:
797
- * remove it from whatever renders the `mona-tab` elements.
798
- */
799
- this.tabClose = output();
800
- /**
801
- * @description Emitted with a {@link TabSelectEvent} before a click or key selects a tab. This event is preventable.
802
- * It doesn't fire for selections made through `selectedIndex` or `selected`, or when the selected tab is removed.
803
- */
804
- this.tabSelect = output();
805
- /**
806
- * @description Additional CSS classes merged onto the host element via `tailwind-merge`.
807
- * @default ""
808
- */
809
- this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
810
- effect(() => {
811
- const requested = this.selectedIndex();
812
- untracked(() => this.applyRequestedIndex(requested));
813
- });
814
- effect(() => {
815
- const items = this.tabList().toArray();
816
- const selectedId = this.selectedTabId();
817
- untracked(() => this.syncSelection(items, selectedId));
818
- });
819
- afterRenderEffect({
820
- read: () => {
821
- this.#tabsSettled = this.tabList().length > 0;
822
- }
823
- });
824
- }
825
- handlePanelKeyDown(event) {
826
- if (event.key === "Tab" && event.shiftKey) {
827
- if (event.target !== event.currentTarget) {
828
- return;
829
- }
830
- event.preventDefault();
831
- this.tabListComponent().focusSelectedTab();
832
- }
833
- }
834
- applyRequestedIndex(requested) {
835
- if (requested === this.#reportedIndex) {
836
- return;
837
- }
838
- const items = this.tabList().toArray();
839
- if (items.length === 0) {
840
- return; // Tabs may still be on their way, and the linked signal reads the index when they arrive.
841
- }
842
- const tab = items[requested];
843
- if (tab && isEnabled(tab)) {
844
- this.selectedTabId.set(tab.id);
845
- }
846
- this.reportIndex(items, this.selectedTabId());
847
- }
848
- reportIndex(items, selectedId) {
849
- const index = items.findIndex(item => item.id === selectedId);
850
- if (index !== -1) {
851
- this.#reportedIndex = index;
852
- this.selectedIndex.set(index);
853
- }
854
- }
855
- /**
856
- * Brings the three views of the selection together. A tab newly flagged `selected` from outside wins, and the first
857
- * one wins when there are several. Every tab's `selected` and the index are then written to match, so a flag that was
858
- * already seen, or one this method wrote, can't take the selection back.
859
- */
860
- syncSelection(items, selectedId) {
861
- const incoming = items.find(item => item.selected && item.id !== this.#flaggedTabId && item.id !== selectedId && isEnabled(item));
862
- const nextId = incoming?.id ?? selectedId;
863
- if (incoming) {
864
- this.selectedTabId.set(incoming.id);
865
- }
866
- this.#flaggedTabId = nextId;
867
- for (const tab of this.tabs()) {
868
- tab.selected.set(tab.tabItem.id === nextId);
869
- }
870
- this.reportIndex(items, nextId);
871
- }
872
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
873
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: TabsComponent, isStandalone: true, selector: "mona-tabs", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, closable: { classPropertyName: "closable", publicName: "closable", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, keepTabContent: { classPropertyName: "keepTabContent", publicName: "keepTabContent", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, selectedIndex: { classPropertyName: "selectedIndex", publicName: "selectedIndex", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selectedIndex: "selectedIndexChange", tabClose: "tabClose", tabSelect: "tabSelect" }, host: { properties: { "class": "baseClass()", "attr.aria-label": "null", "attr.aria-labelledby": "null" } }, queries: [{ propertyName: "tabs", predicate: TabComponent, isSignal: true }], viewQueries: [{ propertyName: "tabListComponent", first: true, predicate: TabListComponent, descendants: true, isSignal: true }], ngImport: i0, template: "<mona-tab-list\n [aria-label]=\"ariaLabel()\"\n [aria-labelledby]=\"ariaLabelledBy()\"\n [closable]=\"closable()\"\n [disabled]=\"disabled()\"\n [position]=\"position()\"\n [size]=\"size()\"\n [tabList]=\"tabList()\"\n [selectedTabId]=\"selectedTabId()\"\n (selectedTabIdChange)=\"selectedTabId.set($event)\"\n (tabClose)=\"tabClose.emit($event)\"\n (tabSelect)=\"tabSelect.emit($event)\"></mona-tab-list>\n<div [class]=\"contentClass()\">\n @for (tab of tabList(); track tab.id) {\n @let selected = tab.id === selectedTabId();\n @let tabLoaded = keepTabContent() || selected;\n @let tabHidden = keepTabContent() && !selected;\n @if (tabLoaded) {\n <div\n class=\"w-full h-full rounded-sm focus-visible:outline-2 focus-visible:outline-focus-indicator focus-visible:-outline-offset-2\"\n [class.hidden]=\"tabHidden\"\n role=\"tabpanel\"\n [id]=\"tab.id + '-panel'\"\n tabindex=\"0\"\n (keydown)=\"handlePanelKeyDown($event)\"\n [attr.aria-hidden]=\"tabHidden\"\n [attr.aria-labelledby]=\"tab.id + '-tab'\">\n <ng-container [ngTemplateOutlet]=\"tab.contentTemplate\"></ng-container>\n </div>\n }\n }\n</div>\n", dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: TabListComponent, selector: "mona-tab-list", inputs: ["aria-label", "aria-labelledby", "closable", "disabled", "position", "selectedTabId", "size", "tabList"], outputs: ["selectedTabIdChange", "tabClose", "tabSelect"] }] }); }
1083
+ return tabs.slice(removedIndex).find(isEnabled) ?? tabs.slice(0, removedIndex).reverse().find(isEnabled);
874
1084
  }
875
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: TabsComponent, decorators: [{
876
- type: Component,
877
- args: [{ selector: "mona-tabs", imports: [NgTemplateOutlet, TabListComponent], host: {
878
- "[class]": "baseClass()",
879
- // The name belongs to the tab list. Left on a host with no role, it would name nothing.
880
- "[attr.aria-label]": "null",
881
- "[attr.aria-labelledby]": "null"
882
- }, template: "<mona-tab-list\n [aria-label]=\"ariaLabel()\"\n [aria-labelledby]=\"ariaLabelledBy()\"\n [closable]=\"closable()\"\n [disabled]=\"disabled()\"\n [position]=\"position()\"\n [size]=\"size()\"\n [tabList]=\"tabList()\"\n [selectedTabId]=\"selectedTabId()\"\n (selectedTabIdChange)=\"selectedTabId.set($event)\"\n (tabClose)=\"tabClose.emit($event)\"\n (tabSelect)=\"tabSelect.emit($event)\"></mona-tab-list>\n<div [class]=\"contentClass()\">\n @for (tab of tabList(); track tab.id) {\n @let selected = tab.id === selectedTabId();\n @let tabLoaded = keepTabContent() || selected;\n @let tabHidden = keepTabContent() && !selected;\n @if (tabLoaded) {\n <div\n class=\"w-full h-full rounded-sm focus-visible:outline-2 focus-visible:outline-focus-indicator focus-visible:-outline-offset-2\"\n [class.hidden]=\"tabHidden\"\n role=\"tabpanel\"\n [id]=\"tab.id + '-panel'\"\n tabindex=\"0\"\n (keydown)=\"handlePanelKeyDown($event)\"\n [attr.aria-hidden]=\"tabHidden\"\n [attr.aria-labelledby]=\"tab.id + '-tab'\">\n <ng-container [ngTemplateOutlet]=\"tab.contentTemplate\"></ng-container>\n </div>\n }\n }\n</div>\n" }]
883
- }], ctorParameters: () => [], propDecorators: { tabListComponent: [{ type: i0.ViewChild, args: [i0.forwardRef(() => TabListComponent), { isSignal: true }] }], tabs: [{ type: i0.ContentChildren, args: [i0.forwardRef(() => TabComponent), { isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], keepTabContent: [{ type: i0.Input, args: [{ isSignal: true, alias: "keepTabContent", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], selectedIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedIndex", required: false }] }, { type: i0.Output, args: ["selectedIndexChange"] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], tabClose: [{ type: i0.Output, args: ["tabClose"] }], tabSelect: [{ type: i0.Output, args: ["tabSelect"] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
884
-
885
- /*
886
- * Public API Surface of @nanahoshi/mona-ui/tabs
887
- */
888
-
889
- /**
890
- * Generated bundle index. Do not edit.
891
- */
892
-
1085
+ var TabsComponent = class TabsComponent {
1086
+ #flaggedTabId;
1087
+ #reportedIndex;
1088
+ #tabsSettled;
1089
+ constructor() {
1090
+ this.#flaggedTabId = null;
1091
+ this.#reportedIndex = null;
1092
+ this.#tabsSettled = false;
1093
+ this.baseClass = computed(() => {
1094
+ const variantClass = tabsBaseThemeVariants({ position: this.position() });
1095
+ const userClass = this.userClass();
1096
+ return twMerge(variantClass, userClass);
1097
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
1098
+ this.contentClass = computed(() => {
1099
+ return tabContentThemeVariants();
1100
+ }, ...ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []);
1101
+ this.selectedTabId = linkedSignal({
1102
+ ...ngDevMode ? { debugName: "selectedTabId" } : /* istanbul ignore next */ {},
1103
+ source: () => this.tabList(),
1104
+ computation: (tabList, previous) => {
1105
+ const tabs = tabList.toArray();
1106
+ const previousId = previous?.value ?? null;
1107
+ if (previousId === null || !this.#tabsSettled) {
1108
+ const requested = tabs[untracked(this.selectedIndex)];
1109
+ return (requested && isEnabled(requested) ? requested : tabs.find(isEnabled))?.id ?? null;
1110
+ }
1111
+ if (tabs.some((tab) => tab.id === previousId)) return previousId;
1112
+ return neighborOf(tabs, previous?.source.toArray().findIndex((tab) => tab.id === previousId) ?? 0)?.id ?? null;
1113
+ }
1114
+ });
1115
+ this.tabList = computed(() => {
1116
+ const tabs = this.tabs();
1117
+ return select(tabs, (t) => t.tabItem).tap((t, tx) => t.index = tx).toImmutableSet();
1118
+ }, ...ngDevMode ? [{ debugName: "tabList" }] : /* istanbul ignore next */ []);
1119
+ this.tabListComponent = viewChild.required(TabListComponent, ...ngDevMode ? [{ debugName: "tabListComponent" }] : /* istanbul ignore next */ []);
1120
+ this.tabs = contentChildren(TabComponent, ...ngDevMode ? [{ debugName: "tabs" }] : /* istanbul ignore next */ []);
1121
+ this.ariaLabel = input("", {
1122
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
1123
+ alias: "aria-label"
1124
+ });
1125
+ this.ariaLabelledBy = input("", {
1126
+ ...ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {},
1127
+ alias: "aria-labelledby"
1128
+ });
1129
+ this.closable = input(false, {
1130
+ ...ngDevMode ? { debugName: "closable" } : /* istanbul ignore next */ {},
1131
+ transform: booleanAttribute
1132
+ });
1133
+ this.disabled = input(false, {
1134
+ ...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
1135
+ transform: booleanAttribute
1136
+ });
1137
+ this.keepTabContent = input(true, {
1138
+ ...ngDevMode ? { debugName: "keepTabContent" } : /* istanbul ignore next */ {},
1139
+ transform: booleanAttribute
1140
+ });
1141
+ this.position = input("top", ...ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []);
1142
+ this.selectedIndex = model(0, ...ngDevMode ? [{ debugName: "selectedIndex" }] : /* istanbul ignore next */ []);
1143
+ this.size = input("medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
1144
+ this.tabClose = output();
1145
+ this.tabSelect = output();
1146
+ this.userClass = input("", {
1147
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
1148
+ alias: "class"
1149
+ });
1150
+ effect(() => {
1151
+ const requested = this.selectedIndex();
1152
+ untracked(() => this.applyRequestedIndex(requested));
1153
+ });
1154
+ effect(() => {
1155
+ const items = this.tabList().toArray();
1156
+ const selectedId = this.selectedTabId();
1157
+ untracked(() => this.syncSelection(items, selectedId));
1158
+ });
1159
+ afterRenderEffect({ read: () => {
1160
+ this.#tabsSettled = this.tabList().length > 0;
1161
+ } });
1162
+ }
1163
+ handlePanelKeyDown(event) {
1164
+ if (event.key === "Tab" && event.shiftKey) {
1165
+ if (event.target !== event.currentTarget) return;
1166
+ event.preventDefault();
1167
+ this.tabListComponent().focusSelectedTab();
1168
+ }
1169
+ }
1170
+ applyRequestedIndex(requested) {
1171
+ if (requested === this.#reportedIndex) return;
1172
+ const items = this.tabList().toArray();
1173
+ if (items.length === 0) return;
1174
+ const tab = items[requested];
1175
+ if (tab && isEnabled(tab)) this.selectedTabId.set(tab.id);
1176
+ this.reportIndex(items, this.selectedTabId());
1177
+ }
1178
+ reportIndex(items, selectedId) {
1179
+ const index = items.findIndex((item) => item.id === selectedId);
1180
+ if (index !== -1) {
1181
+ this.#reportedIndex = index;
1182
+ this.selectedIndex.set(index);
1183
+ }
1184
+ }
1185
+ syncSelection(items, selectedId) {
1186
+ const incoming = items.find((item) => item.selected && item.id !== this.#flaggedTabId && item.id !== selectedId && isEnabled(item));
1187
+ const nextId = incoming?.id ?? selectedId;
1188
+ if (incoming) this.selectedTabId.set(incoming.id);
1189
+ this.#flaggedTabId = nextId;
1190
+ for (const tab of this.tabs()) tab.selected.set(tab.tabItem.id === nextId);
1191
+ this.reportIndex(items, nextId);
1192
+ }
1193
+ static {
1194
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1195
+ minVersion: "12.0.0",
1196
+ version: "22.2.6",
1197
+ ngImport: i0,
1198
+ type: TabsComponent,
1199
+ deps: [],
1200
+ target: i0.ɵɵFactoryTarget.Component
1201
+ });
1202
+ }
1203
+ static {
1204
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1205
+ minVersion: "17.0.0",
1206
+ version: "22.2.6",
1207
+ type: TabsComponent,
1208
+ isStandalone: true,
1209
+ selector: "mona-tabs",
1210
+ inputs: {
1211
+ ariaLabel: {
1212
+ classPropertyName: "ariaLabel",
1213
+ publicName: "aria-label",
1214
+ isSignal: true,
1215
+ isRequired: false,
1216
+ transformFunction: null
1217
+ },
1218
+ ariaLabelledBy: {
1219
+ classPropertyName: "ariaLabelledBy",
1220
+ publicName: "aria-labelledby",
1221
+ isSignal: true,
1222
+ isRequired: false,
1223
+ transformFunction: null
1224
+ },
1225
+ closable: {
1226
+ classPropertyName: "closable",
1227
+ publicName: "closable",
1228
+ isSignal: true,
1229
+ isRequired: false,
1230
+ transformFunction: null
1231
+ },
1232
+ disabled: {
1233
+ classPropertyName: "disabled",
1234
+ publicName: "disabled",
1235
+ isSignal: true,
1236
+ isRequired: false,
1237
+ transformFunction: null
1238
+ },
1239
+ keepTabContent: {
1240
+ classPropertyName: "keepTabContent",
1241
+ publicName: "keepTabContent",
1242
+ isSignal: true,
1243
+ isRequired: false,
1244
+ transformFunction: null
1245
+ },
1246
+ position: {
1247
+ classPropertyName: "position",
1248
+ publicName: "position",
1249
+ isSignal: true,
1250
+ isRequired: false,
1251
+ transformFunction: null
1252
+ },
1253
+ selectedIndex: {
1254
+ classPropertyName: "selectedIndex",
1255
+ publicName: "selectedIndex",
1256
+ isSignal: true,
1257
+ isRequired: false,
1258
+ transformFunction: null
1259
+ },
1260
+ size: {
1261
+ classPropertyName: "size",
1262
+ publicName: "size",
1263
+ isSignal: true,
1264
+ isRequired: false,
1265
+ transformFunction: null
1266
+ },
1267
+ userClass: {
1268
+ classPropertyName: "userClass",
1269
+ publicName: "class",
1270
+ isSignal: true,
1271
+ isRequired: false,
1272
+ transformFunction: null
1273
+ }
1274
+ },
1275
+ outputs: {
1276
+ selectedIndex: "selectedIndexChange",
1277
+ tabClose: "tabClose",
1278
+ tabSelect: "tabSelect"
1279
+ },
1280
+ host: { properties: {
1281
+ "class": "baseClass()",
1282
+ "attr.aria-label": "null",
1283
+ "attr.aria-labelledby": "null"
1284
+ } },
1285
+ queries: [{
1286
+ propertyName: "tabs",
1287
+ predicate: TabComponent,
1288
+ isSignal: true
1289
+ }],
1290
+ viewQueries: [{
1291
+ propertyName: "tabListComponent",
1292
+ first: true,
1293
+ predicate: TabListComponent,
1294
+ descendants: true,
1295
+ isSignal: true
1296
+ }],
1297
+ ngImport: i0,
1298
+ template: "<mona-tab-list\n [aria-label]=\"ariaLabel()\"\n [aria-labelledby]=\"ariaLabelledBy()\"\n [closable]=\"closable()\"\n [disabled]=\"disabled()\"\n [position]=\"position()\"\n [size]=\"size()\"\n [tabList]=\"tabList()\"\n [selectedTabId]=\"selectedTabId()\"\n (selectedTabIdChange)=\"selectedTabId.set($event)\"\n (tabClose)=\"tabClose.emit($event)\"\n (tabSelect)=\"tabSelect.emit($event)\"></mona-tab-list>\n<div [class]=\"contentClass()\">\n @for (tab of tabList(); track tab.id) {\n @let selected = tab.id === selectedTabId();\n @let tabLoaded = keepTabContent() || selected;\n @let tabHidden = keepTabContent() && !selected;\n @if (tabLoaded) {\n <div\n class=\"w-full h-full rounded-sm focus-visible:outline-2 focus-visible:outline-focus-indicator focus-visible:-outline-offset-2\"\n [class.hidden]=\"tabHidden\"\n role=\"tabpanel\"\n [id]=\"tab.id + '-panel'\"\n tabindex=\"0\"\n (keydown)=\"handlePanelKeyDown($event)\"\n [attr.aria-hidden]=\"tabHidden\"\n [attr.aria-labelledby]=\"tab.id + '-tab'\">\n <ng-container [ngTemplateOutlet]=\"tab.contentTemplate\"></ng-container>\n </div>\n }\n }\n</div>\n",
1299
+ dependencies: [{
1300
+ kind: "directive",
1301
+ type: NgTemplateOutlet,
1302
+ selector: "[ngTemplateOutlet]",
1303
+ inputs: [
1304
+ "ngTemplateOutletContext",
1305
+ "ngTemplateOutlet",
1306
+ "ngTemplateOutletInjector"
1307
+ ]
1308
+ }, {
1309
+ kind: "component",
1310
+ type: TabListComponent,
1311
+ selector: "mona-tab-list",
1312
+ inputs: [
1313
+ "aria-label",
1314
+ "aria-labelledby",
1315
+ "closable",
1316
+ "disabled",
1317
+ "position",
1318
+ "selectedTabId",
1319
+ "size",
1320
+ "tabList"
1321
+ ],
1322
+ outputs: [
1323
+ "selectedTabIdChange",
1324
+ "tabClose",
1325
+ "tabSelect"
1326
+ ]
1327
+ }]
1328
+ });
1329
+ }
1330
+ };
1331
+ i0.ɵɵngDeclareClassMetadata({
1332
+ minVersion: "12.0.0",
1333
+ version: "22.2.6",
1334
+ ngImport: i0,
1335
+ type: TabsComponent,
1336
+ decorators: [{
1337
+ type: Component,
1338
+ args: [{
1339
+ selector: "mona-tabs",
1340
+ imports: [NgTemplateOutlet, TabListComponent],
1341
+ host: {
1342
+ "[class]": "baseClass()",
1343
+ "[attr.aria-label]": "null",
1344
+ "[attr.aria-labelledby]": "null"
1345
+ },
1346
+ template: "<mona-tab-list\n [aria-label]=\"ariaLabel()\"\n [aria-labelledby]=\"ariaLabelledBy()\"\n [closable]=\"closable()\"\n [disabled]=\"disabled()\"\n [position]=\"position()\"\n [size]=\"size()\"\n [tabList]=\"tabList()\"\n [selectedTabId]=\"selectedTabId()\"\n (selectedTabIdChange)=\"selectedTabId.set($event)\"\n (tabClose)=\"tabClose.emit($event)\"\n (tabSelect)=\"tabSelect.emit($event)\"></mona-tab-list>\n<div [class]=\"contentClass()\">\n @for (tab of tabList(); track tab.id) {\n @let selected = tab.id === selectedTabId();\n @let tabLoaded = keepTabContent() || selected;\n @let tabHidden = keepTabContent() && !selected;\n @if (tabLoaded) {\n <div\n class=\"w-full h-full rounded-sm focus-visible:outline-2 focus-visible:outline-focus-indicator focus-visible:-outline-offset-2\"\n [class.hidden]=\"tabHidden\"\n role=\"tabpanel\"\n [id]=\"tab.id + '-panel'\"\n tabindex=\"0\"\n (keydown)=\"handlePanelKeyDown($event)\"\n [attr.aria-hidden]=\"tabHidden\"\n [attr.aria-labelledby]=\"tab.id + '-tab'\">\n <ng-container [ngTemplateOutlet]=\"tab.contentTemplate\"></ng-container>\n </div>\n }\n }\n</div>\n"
1347
+ }]
1348
+ }],
1349
+ ctorParameters: () => [],
1350
+ propDecorators: {
1351
+ tabListComponent: [{
1352
+ type: i0.ViewChild,
1353
+ args: [i0.forwardRef(() => TabListComponent), { isSignal: true }]
1354
+ }],
1355
+ tabs: [{
1356
+ type: i0.ContentChildren,
1357
+ args: [i0.forwardRef(() => TabComponent), { isSignal: true }]
1358
+ }],
1359
+ ariaLabel: [{
1360
+ type: i0.Input,
1361
+ args: [{
1362
+ isSignal: true,
1363
+ alias: "aria-label",
1364
+ required: false
1365
+ }]
1366
+ }],
1367
+ ariaLabelledBy: [{
1368
+ type: i0.Input,
1369
+ args: [{
1370
+ isSignal: true,
1371
+ alias: "aria-labelledby",
1372
+ required: false
1373
+ }]
1374
+ }],
1375
+ closable: [{
1376
+ type: i0.Input,
1377
+ args: [{
1378
+ isSignal: true,
1379
+ alias: "closable",
1380
+ required: false
1381
+ }]
1382
+ }],
1383
+ disabled: [{
1384
+ type: i0.Input,
1385
+ args: [{
1386
+ isSignal: true,
1387
+ alias: "disabled",
1388
+ required: false
1389
+ }]
1390
+ }],
1391
+ keepTabContent: [{
1392
+ type: i0.Input,
1393
+ args: [{
1394
+ isSignal: true,
1395
+ alias: "keepTabContent",
1396
+ required: false
1397
+ }]
1398
+ }],
1399
+ position: [{
1400
+ type: i0.Input,
1401
+ args: [{
1402
+ isSignal: true,
1403
+ alias: "position",
1404
+ required: false
1405
+ }]
1406
+ }],
1407
+ selectedIndex: [{
1408
+ type: i0.Input,
1409
+ args: [{
1410
+ isSignal: true,
1411
+ alias: "selectedIndex",
1412
+ required: false
1413
+ }]
1414
+ }, {
1415
+ type: i0.Output,
1416
+ args: ["selectedIndexChange"]
1417
+ }],
1418
+ size: [{
1419
+ type: i0.Input,
1420
+ args: [{
1421
+ isSignal: true,
1422
+ alias: "size",
1423
+ required: false
1424
+ }]
1425
+ }],
1426
+ tabClose: [{
1427
+ type: i0.Output,
1428
+ args: ["tabClose"]
1429
+ }],
1430
+ tabSelect: [{
1431
+ type: i0.Output,
1432
+ args: ["tabSelect"]
1433
+ }],
1434
+ userClass: [{
1435
+ type: i0.Input,
1436
+ args: [{
1437
+ isSignal: true,
1438
+ alias: "class",
1439
+ required: false
1440
+ }]
1441
+ }]
1442
+ }
1443
+ });
893
1444
  export { TABS_DEFAULT_MESSAGES, TabCloseEvent, TabComponent, TabContentTemplateDirective, TabSelectEvent, TabTitleTemplateDirective, TabsComponent };
894
- //# sourceMappingURL=nanahoshi-mona-ui-tabs.mjs.map
1445
+
1446
+ //# sourceMappingURL=nanahoshi-mona-ui-tabs.mjs.map