@nanahoshi/mona-ui 0.27.2 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/api/chart.md +2 -2
- package/docs/api/popup.md +1 -1
- package/docs/api/theme.md +2 -2
- package/docs/chart.md +14 -0
- package/docs/editor.md +2 -0
- package/docs/installation.md +147 -15
- package/docs/introduction.md +37 -15
- package/docs/theming-built-in-themes.md +67 -0
- package/docs/theming-custom-colors.md +274 -0
- package/docs/theming-custom-themes.md +168 -0
- package/docs/theming.md +164 -248
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
- package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2070 -1573
- package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
- package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
- package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
- package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
- package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
- package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
- package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales.mjs +59 -77
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
- package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
- package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
- package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
- package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
- package/llms.txt +6 -2
- package/package.json +62 -23
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
- package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
- package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
- package/types/nanahoshi-mona-ui-button.d.ts +227 -166
- package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
- package/types/nanahoshi-mona-ui-card.d.ts +125 -111
- package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
- package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
- package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
- package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
- package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
- package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
- package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
- package/types/nanahoshi-mona-ui-command.d.ts +279 -191
- package/types/nanahoshi-mona-ui-common.d.ts +354 -385
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
- package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
- package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
- package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
- package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
- package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
- package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
- package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
- package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
- package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
- package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
- package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
- package/types/nanahoshi-mona-ui-label.d.ts +108 -78
- package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
- package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
- package/types/nanahoshi-mona-ui-list.d.ts +2 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales.d.ts +17 -19
- package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
- package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
- package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
- package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
- package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
- package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
- package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
- package/types/nanahoshi-mona-ui-query.d.ts +82 -88
- package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
- package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
- package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
- package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
- package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
- package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
- package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
- package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
- package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
- package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
- package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
- package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
- package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
- package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
- package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
- package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
- package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
- package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
- package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
- package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
- package/types/nanahoshi-mona-ui-window.d.ts +494 -399
- package/types/nanahoshi-mona-ui.d.ts +1 -2
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { toCssValue } from
|
|
6
|
-
import { select } from
|
|
7
|
-
import { Subject,
|
|
8
|
-
import { twMerge } from
|
|
9
|
-
import { formatNumber, injectComponentDirection
|
|
10
|
-
import { cva } from
|
|
11
|
-
|
|
1
|
+
import { NgTemplateOutlet, isPlatformBrowser } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { Component, DOCUMENT, DestroyRef, Directive, ElementRef, PLATFORM_ID, TemplateRef, afterNextRender, afterRenderEffect, computed, contentChild, effect, inject, input, isDevMode, model, signal, untracked, viewChild } from "@angular/core";
|
|
4
|
+
import { takeUntilDestroyed, toObservable, toSignal } from "@angular/core/rxjs-interop";
|
|
5
|
+
import { toCssValue } from "@nanahoshi/mona-ui/internal";
|
|
6
|
+
import { select } from "@mirei/ts-collections";
|
|
7
|
+
import { Subject, interval, map, pairwise, startWith, takeUntil } from "rxjs";
|
|
8
|
+
import { twMerge } from "tailwind-merge";
|
|
9
|
+
import { MonaI18nService, formatNumber, injectComponentDirection } from "@nanahoshi/mona-ui/i18n";
|
|
10
|
+
import { cva } from "class-variance-authority";
|
|
12
11
|
const scrollViewBaseThemeVariants = cva(`
|
|
13
12
|
relative block h-full w-full overflow-hidden
|
|
14
13
|
bg-surface
|
|
15
14
|
border border-border-subtle
|
|
16
15
|
focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus-indicator
|
|
17
|
-
`, {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
none: "rounded-none"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
});
|
|
16
|
+
`, { variants: { rounded: {
|
|
17
|
+
small: "rounded-sm",
|
|
18
|
+
medium: "rounded-md",
|
|
19
|
+
large: "rounded-lg",
|
|
20
|
+
none: "rounded-none"
|
|
21
|
+
} } });
|
|
27
22
|
const scrollViewContentThemeVariants = cva(`
|
|
28
23
|
absolute inset-0 overflow-hidden
|
|
29
24
|
touch-pan-y touch-pinch-zoom
|
|
@@ -44,29 +39,23 @@ const scrollViewArrowThemeVariants = cva(`
|
|
|
44
39
|
[&_svg]:transition-opacity [&_svg]:duration-(--mona-motion-standard) [&_svg]:ease-out
|
|
45
40
|
hover:[&_svg]:opacity-100 active:[&_svg]:opacity-100 focus-visible:[&_svg]:opacity-100
|
|
46
41
|
contrast-more:[&_svg]:opacity-100 forced-colors:[&_svg]:opacity-100
|
|
47
|
-
`, {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
});
|
|
42
|
+
`, { variants: {
|
|
43
|
+
hidden: {
|
|
44
|
+
true: "hidden",
|
|
45
|
+
false: ""
|
|
46
|
+
},
|
|
47
|
+
side: {
|
|
48
|
+
left: "left-0",
|
|
49
|
+
right: "right-0"
|
|
50
|
+
}
|
|
51
|
+
} });
|
|
59
52
|
const scrollViewPagerThemeVariants = cva(`
|
|
60
53
|
absolute inset-x-0 bottom-0 flex items-center justify-center
|
|
61
|
-
`, {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
none: ""
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
54
|
+
`, { variants: { pagerOverlay: {
|
|
55
|
+
dark: "bg-canvas/85 border-0 border-t border-border-subtle",
|
|
56
|
+
light: "bg-surface-overlay/85 border-0 border-t border-border-subtle",
|
|
57
|
+
none: ""
|
|
58
|
+
} } });
|
|
70
59
|
const scrollViewPagerListContainerThemeVariants = cva(`
|
|
71
60
|
flex flex-1 items-center justify-center overflow-hidden
|
|
72
61
|
`);
|
|
@@ -83,21 +72,19 @@ const scrollViewPagerListItemThemeVariants = cva(`
|
|
|
83
72
|
not-last:me-3
|
|
84
73
|
hover:bg-muted-foreground/60 active:bg-foreground
|
|
85
74
|
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator
|
|
86
|
-
`, {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
});
|
|
75
|
+
`, { variants: {
|
|
76
|
+
active: {
|
|
77
|
+
true: "!bg-foreground hover:!bg-foreground !border-foreground forced-color-adjust-none forced-colors:!bg-[CanvasText] forced-colors:!border-[CanvasText]",
|
|
78
|
+
false: ""
|
|
79
|
+
},
|
|
80
|
+
pagerRounded: {
|
|
81
|
+
small: "rounded-sm",
|
|
82
|
+
medium: "rounded-md",
|
|
83
|
+
large: "rounded-lg",
|
|
84
|
+
full: "rounded-full",
|
|
85
|
+
none: "rounded-none"
|
|
86
|
+
}
|
|
87
|
+
} });
|
|
101
88
|
const scrollViewPagerArrowThemeVariants = cva(`
|
|
102
89
|
flex items-center justify-center
|
|
103
90
|
p-2
|
|
@@ -108,872 +95,1098 @@ const scrollViewPagerArrowThemeVariants = cva(`
|
|
|
108
95
|
focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus-indicator
|
|
109
96
|
[&_svg]:stroke-current
|
|
110
97
|
`);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
98
|
+
var ScrollViewActivePageDirective = class ScrollViewActivePageDirective {
|
|
99
|
+
constructor() {
|
|
100
|
+
this.pageItemClass = computed(() => {
|
|
101
|
+
const active = this.active();
|
|
102
|
+
const pagerRounded = this.rounded();
|
|
103
|
+
return scrollViewPagerListItemThemeVariants({
|
|
104
|
+
active,
|
|
105
|
+
pagerRounded
|
|
106
|
+
});
|
|
107
|
+
}, ...ngDevMode ? [{ debugName: "pageItemClass" }] : /* istanbul ignore next */ []);
|
|
108
|
+
this.active = input.required(...ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []);
|
|
109
|
+
this.rounded = input.required(...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
|
|
110
|
+
}
|
|
111
|
+
static {
|
|
112
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
113
|
+
minVersion: "12.0.0",
|
|
114
|
+
version: "22.2.6",
|
|
115
|
+
ngImport: i0,
|
|
116
|
+
type: ScrollViewActivePageDirective,
|
|
117
|
+
deps: [],
|
|
118
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
static {
|
|
122
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
123
|
+
minVersion: "17.1.0",
|
|
124
|
+
version: "22.2.6",
|
|
125
|
+
type: ScrollViewActivePageDirective,
|
|
126
|
+
isStandalone: true,
|
|
127
|
+
selector: "button[monaScrollViewActivePage]",
|
|
128
|
+
inputs: {
|
|
129
|
+
active: {
|
|
130
|
+
classPropertyName: "active",
|
|
131
|
+
publicName: "active",
|
|
132
|
+
isSignal: true,
|
|
133
|
+
isRequired: true,
|
|
134
|
+
transformFunction: null
|
|
135
|
+
},
|
|
136
|
+
rounded: {
|
|
137
|
+
classPropertyName: "rounded",
|
|
138
|
+
publicName: "rounded",
|
|
139
|
+
isSignal: true,
|
|
140
|
+
isRequired: true,
|
|
141
|
+
transformFunction: null
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
host: { properties: { "class": "pageItemClass()" } },
|
|
145
|
+
ngImport: i0
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
150
|
+
minVersion: "12.0.0",
|
|
151
|
+
version: "22.2.6",
|
|
152
|
+
ngImport: i0,
|
|
153
|
+
type: ScrollViewActivePageDirective,
|
|
154
|
+
decorators: [{
|
|
155
|
+
type: Directive,
|
|
156
|
+
args: [{
|
|
157
|
+
selector: "button[monaScrollViewActivePage]",
|
|
158
|
+
host: { "[class]": "pageItemClass()" }
|
|
159
|
+
}]
|
|
160
|
+
}],
|
|
161
|
+
propDecorators: {
|
|
162
|
+
active: [{
|
|
163
|
+
type: i0.Input,
|
|
164
|
+
args: [{
|
|
165
|
+
isSignal: true,
|
|
166
|
+
alias: "active",
|
|
167
|
+
required: true
|
|
168
|
+
}]
|
|
169
|
+
}],
|
|
170
|
+
rounded: [{
|
|
171
|
+
type: i0.Input,
|
|
172
|
+
args: [{
|
|
173
|
+
isSignal: true,
|
|
174
|
+
alias: "rounded",
|
|
175
|
+
required: true
|
|
176
|
+
}]
|
|
177
|
+
}]
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
var ScrollViewSlideDirective = class ScrollViewSlideDirective {
|
|
181
|
+
constructor() {
|
|
182
|
+
this.monaScrollViewSlide = input("", ...ngDevMode ? [{ debugName: "monaScrollViewSlide" }] : /* istanbul ignore next */ []);
|
|
183
|
+
this.templateRef = inject(TemplateRef);
|
|
184
|
+
}
|
|
185
|
+
static ngTemplateContextGuard(_dir, _ctx) {
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
static {
|
|
189
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
190
|
+
minVersion: "12.0.0",
|
|
191
|
+
version: "22.2.6",
|
|
192
|
+
ngImport: i0,
|
|
193
|
+
type: ScrollViewSlideDirective,
|
|
194
|
+
deps: [],
|
|
195
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
static {
|
|
199
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
200
|
+
minVersion: "17.1.0",
|
|
201
|
+
version: "22.2.6",
|
|
202
|
+
type: ScrollViewSlideDirective,
|
|
203
|
+
isStandalone: true,
|
|
204
|
+
selector: "ng-template[monaScrollViewSlide]",
|
|
205
|
+
inputs: { monaScrollViewSlide: {
|
|
206
|
+
classPropertyName: "monaScrollViewSlide",
|
|
207
|
+
publicName: "monaScrollViewSlide",
|
|
208
|
+
isSignal: true,
|
|
209
|
+
isRequired: false,
|
|
210
|
+
transformFunction: null
|
|
211
|
+
} },
|
|
212
|
+
ngImport: i0
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
217
|
+
minVersion: "12.0.0",
|
|
218
|
+
version: "22.2.6",
|
|
219
|
+
ngImport: i0,
|
|
220
|
+
type: ScrollViewSlideDirective,
|
|
221
|
+
decorators: [{
|
|
222
|
+
type: Directive,
|
|
223
|
+
args: [{ selector: "ng-template[monaScrollViewSlide]" }]
|
|
224
|
+
}],
|
|
225
|
+
propDecorators: { monaScrollViewSlide: [{
|
|
226
|
+
type: i0.Input,
|
|
227
|
+
args: [{
|
|
228
|
+
isSignal: true,
|
|
229
|
+
alias: "monaScrollViewSlide",
|
|
230
|
+
required: false
|
|
231
|
+
}]
|
|
232
|
+
}] }
|
|
233
|
+
});
|
|
168
234
|
function localizeNumber(value, options) {
|
|
169
|
-
|
|
235
|
+
return formatNumber(value, "en-US", options);
|
|
170
236
|
}
|
|
171
237
|
const SCROLL_VIEW_DEFAULT_MESSAGES = {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
238
|
+
carousel: "carousel",
|
|
239
|
+
nextPage: "Next page",
|
|
240
|
+
page: (current) => `Page ${localizeNumber(current)}`,
|
|
241
|
+
pageOf: (current, total) => `Page ${localizeNumber(current)} of ${localizeNumber(total)}`,
|
|
242
|
+
pages: "Pages",
|
|
243
|
+
previousPage: "Previous page",
|
|
244
|
+
scrollPagerNext: "Scroll pager next",
|
|
245
|
+
scrollPagerPrevious: "Scroll pager previous",
|
|
246
|
+
slide: "slide"
|
|
181
247
|
};
|
|
182
|
-
|
|
183
|
-
/** How far a touch has to travel, in pixels, to count as a swipe. */
|
|
184
248
|
const SWIPE_DISTANCE = 40;
|
|
185
|
-
/** Where a horizontal drag belongs to the control under it and not to the carousel. */
|
|
186
249
|
const SWIPE_EXEMPT_SELECTOR = "input, select, textarea, [contenteditable], [role='slider'], [role='scrollbar']";
|
|
187
250
|
function normalizeScrollViewIndex(rawIndex, itemCount, infinite) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (infinite) {
|
|
193
|
-
return ((finiteIndex % itemCount) + itemCount) % itemCount;
|
|
194
|
-
}
|
|
195
|
-
return Math.max(0, Math.min(itemCount - 1, finiteIndex));
|
|
196
|
-
}
|
|
197
|
-
class ScrollViewComponent {
|
|
198
|
-
#destroyRef;
|
|
199
|
-
#direction;
|
|
200
|
-
#directionFromIndex;
|
|
201
|
-
#document;
|
|
202
|
-
#hostElementRef;
|
|
203
|
-
#i18n;
|
|
204
|
-
#platformId;
|
|
205
|
-
#pointerCancelHandler;
|
|
206
|
-
#pointerUpHandler;
|
|
207
|
-
#prefersReducedMotion;
|
|
208
|
-
#rejectedPagerPointers;
|
|
209
|
-
#scroll$;
|
|
210
|
-
#swipeCancelHandler;
|
|
211
|
-
#swipeEndHandler;
|
|
212
|
-
#suppressedPagerClickPointerIds;
|
|
213
|
-
#viewIndex;
|
|
214
|
-
#activePagerPointerControl;
|
|
215
|
-
#activePagerPointerId;
|
|
216
|
-
#activeSwipe;
|
|
217
|
-
#continuousTicked;
|
|
218
|
-
#navigationIntent;
|
|
219
|
-
#pagerCentered;
|
|
220
|
-
#pagerScrollCompletionCleanup;
|
|
221
|
-
#pagerScrollContext;
|
|
222
|
-
#resizeObserver;
|
|
223
|
-
constructor() {
|
|
224
|
-
this.#destroyRef = inject(DestroyRef);
|
|
225
|
-
this.#direction = injectComponentDirection();
|
|
226
|
-
this.#document = inject(DOCUMENT);
|
|
227
|
-
this.#hostElementRef = inject(ElementRef);
|
|
228
|
-
this.#i18n = inject(MonaI18nService);
|
|
229
|
-
this.#platformId = inject(PLATFORM_ID);
|
|
230
|
-
this.#pointerCancelHandler = (event) => this.#handlePointerEnd(event, false);
|
|
231
|
-
this.#pointerUpHandler = (event) => this.#handlePointerEnd(event, true);
|
|
232
|
-
this.#prefersReducedMotion = signal(false, /* @ts-ignore */
|
|
233
|
-
...(ngDevMode ? [{ debugName: "#prefersReducedMotion" }] : /* istanbul ignore next */ []));
|
|
234
|
-
this.#rejectedPagerPointers = new Map();
|
|
235
|
-
this.#scroll$ = new Subject();
|
|
236
|
-
this.#swipeCancelHandler = (event) => this.#endSwipe(event, false);
|
|
237
|
-
this.#swipeEndHandler = (event) => this.#endSwipe(event, true);
|
|
238
|
-
this.#suppressedPagerClickPointerIds = new Set();
|
|
239
|
-
this.#viewIndex = computed(() => {
|
|
240
|
-
return normalizeScrollViewIndex(this.index(), this.itemCount(), this.infinite());
|
|
241
|
-
}, /* @ts-ignore */
|
|
242
|
-
...(ngDevMode ? [{ debugName: "#viewIndex" }] : /* istanbul ignore next */ []));
|
|
243
|
-
this.#activePagerPointerControl = null;
|
|
244
|
-
this.#activePagerPointerId = null;
|
|
245
|
-
this.#activeSwipe = null;
|
|
246
|
-
this.#continuousTicked = false;
|
|
247
|
-
this.#navigationIntent = null;
|
|
248
|
-
this.#pagerCentered = false;
|
|
249
|
-
this.#pagerScrollCompletionCleanup = null;
|
|
250
|
-
this.#pagerScrollContext = null;
|
|
251
|
-
this.#resizeObserver = null;
|
|
252
|
-
this.animationDuration = computed(() => {
|
|
253
|
-
const animate = this.animate();
|
|
254
|
-
return typeof animate === "boolean" ? (animate ? 500 : 0) : animate;
|
|
255
|
-
}, /* @ts-ignore */
|
|
256
|
-
...(ngDevMode ? [{ debugName: "animationDuration" }] : /* istanbul ignore next */ []));
|
|
257
|
-
this.bareTemplate = contentChild(TemplateRef, /* @ts-ignore */
|
|
258
|
-
...(ngDevMode ? [{ debugName: "bareTemplate" }] : /* istanbul ignore next */ []));
|
|
259
|
-
this.baseClass = computed(() => {
|
|
260
|
-
const rounded = this.rounded();
|
|
261
|
-
const variantClass = scrollViewBaseThemeVariants({ rounded });
|
|
262
|
-
const userClass = this.userClass();
|
|
263
|
-
return twMerge(variantClass, userClass);
|
|
264
|
-
}, /* @ts-ignore */
|
|
265
|
-
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
266
|
-
this.contentClass = computed(() => {
|
|
267
|
-
return scrollViewContentThemeVariants();
|
|
268
|
-
}, /* @ts-ignore */
|
|
269
|
-
...(ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []));
|
|
270
|
-
this.contentElementRef = viewChild("contentElement", /* @ts-ignore */
|
|
271
|
-
...(ngDevMode ? [{ debugName: "contentElementRef" }] : /* istanbul ignore next */ []));
|
|
272
|
-
this.contentTemplate = computed(() => this.slideDirective()?.templateRef ?? this.bareTemplate(), /* @ts-ignore */
|
|
273
|
-
...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
|
|
274
|
-
this.enterAnimation = computed(() => {
|
|
275
|
-
const isRtl = this.isRtl();
|
|
276
|
-
const dir = this.#directionFromIndex();
|
|
277
|
-
const effectiveDir = isRtl ? (dir === "right" ? "left" : "right") : dir;
|
|
278
|
-
return effectiveDir === "right" ? "slide-in-from-right" : "slide-in-from-left";
|
|
279
|
-
}, /* @ts-ignore */
|
|
280
|
-
...(ngDevMode ? [{ debugName: "enterAnimation" }] : /* istanbul ignore next */ []));
|
|
281
|
-
this.hostRole = computed(() => (this.ariaLabel() || this.ariaLabelledBy() ? "region" : "group"), /* @ts-ignore */
|
|
282
|
-
...(ngDevMode ? [{ debugName: "hostRole" }] : /* istanbul ignore next */ []));
|
|
283
|
-
this.isRtl = computed(() => this.#direction() === "rtl", /* @ts-ignore */
|
|
284
|
-
...(ngDevMode ? [{ debugName: "isRtl" }] : /* istanbul ignore next */ []));
|
|
285
|
-
this.itemCount = computed(() => this.viewData().length, /* @ts-ignore */
|
|
286
|
-
...(ngDevMode ? [{ debugName: "itemCount" }] : /* istanbul ignore next */ []));
|
|
287
|
-
this.leaveAnimation = computed(() => {
|
|
288
|
-
const isRtl = this.isRtl();
|
|
289
|
-
const dir = this.#directionFromIndex();
|
|
290
|
-
const effectiveDir = isRtl ? (dir === "right" ? "left" : "right") : dir;
|
|
291
|
-
return effectiveDir === "right" ? "slide-out-to-left" : "slide-out-to-right";
|
|
292
|
-
}, /* @ts-ignore */
|
|
293
|
-
...(ngDevMode ? [{ debugName: "leaveAnimation" }] : /* istanbul ignore next */ []));
|
|
294
|
-
this.leftArrowClass = computed(() => {
|
|
295
|
-
const side = this.isRtl() ? "right" : "left";
|
|
296
|
-
return scrollViewArrowThemeVariants({ hidden: this.previousArrowHidden(), side });
|
|
297
|
-
}, /* @ts-ignore */
|
|
298
|
-
...(ngDevMode ? [{ debugName: "leftArrowClass" }] : /* istanbul ignore next */ []));
|
|
299
|
-
this.messages = this.#i18n.componentMessages("scrollView", SCROLL_VIEW_DEFAULT_MESSAGES);
|
|
300
|
-
this.nextArrowHidden = computed(() => {
|
|
301
|
-
const count = this.itemCount();
|
|
302
|
-
return !this.arrows() || count <= 1 || !(this.infinite() || this.viewIndex() !== count - 1);
|
|
303
|
-
}, /* @ts-ignore */
|
|
304
|
-
...(ngDevMode ? [{ debugName: "nextArrowHidden" }] : /* istanbul ignore next */ []));
|
|
305
|
-
this.nextArrowRef = viewChild("nextArrow", /* @ts-ignore */
|
|
306
|
-
...(ngDevMode ? [{ debugName: "nextArrowRef" }] : /* istanbul ignore next */ []));
|
|
307
|
-
this.pagerArrowClass = computed(() => {
|
|
308
|
-
return scrollViewPagerArrowThemeVariants();
|
|
309
|
-
}, /* @ts-ignore */
|
|
310
|
-
...(ngDevMode ? [{ debugName: "pagerArrowClass" }] : /* istanbul ignore next */ []));
|
|
311
|
-
this.pagerArrowVisible = signal(false, /* @ts-ignore */
|
|
312
|
-
...(ngDevMode ? [{ debugName: "pagerArrowVisible" }] : /* istanbul ignore next */ []));
|
|
313
|
-
this.pagerClass = computed(() => {
|
|
314
|
-
const pagerOverlay = this.pagerOverlay();
|
|
315
|
-
return scrollViewPagerThemeVariants({ pagerOverlay });
|
|
316
|
-
}, /* @ts-ignore */
|
|
317
|
-
...(ngDevMode ? [{ debugName: "pagerClass" }] : /* istanbul ignore next */ []));
|
|
318
|
-
this.pagerElementRef = viewChild("pagerElement", /* @ts-ignore */
|
|
319
|
-
...(ngDevMode ? [{ debugName: "pagerElementRef" }] : /* istanbul ignore next */ []));
|
|
320
|
-
this.pagerListClass = computed(() => {
|
|
321
|
-
return scrollViewPagerListThemeVariants();
|
|
322
|
-
}, /* @ts-ignore */
|
|
323
|
-
...(ngDevMode ? [{ debugName: "pagerListClass" }] : /* istanbul ignore next */ []));
|
|
324
|
-
this.pagerListContainerClass = computed(() => {
|
|
325
|
-
return scrollViewPagerListContainerThemeVariants();
|
|
326
|
-
}, /* @ts-ignore */
|
|
327
|
-
...(ngDevMode ? [{ debugName: "pagerListContainerClass" }] : /* istanbul ignore next */ []));
|
|
328
|
-
this.pagerListElementRef = viewChild("pagerListElement", /* @ts-ignore */
|
|
329
|
-
...(ngDevMode ? [{ debugName: "pagerListElementRef" }] : /* istanbul ignore next */ []));
|
|
330
|
-
this.previousArrowHidden = computed(() => {
|
|
331
|
-
return !this.arrows() || this.itemCount() <= 1 || !(this.infinite() || this.viewIndex() !== 0);
|
|
332
|
-
}, /* @ts-ignore */
|
|
333
|
-
...(ngDevMode ? [{ debugName: "previousArrowHidden" }] : /* istanbul ignore next */ []));
|
|
334
|
-
this.previousArrowRef = viewChild("previousArrow", /* @ts-ignore */
|
|
335
|
-
...(ngDevMode ? [{ debugName: "previousArrowRef" }] : /* istanbul ignore next */ []));
|
|
336
|
-
this.rightArrowClass = computed(() => {
|
|
337
|
-
const side = this.isRtl() ? "left" : "right";
|
|
338
|
-
return scrollViewArrowThemeVariants({ hidden: this.nextArrowHidden(), side });
|
|
339
|
-
}, /* @ts-ignore */
|
|
340
|
-
...(ngDevMode ? [{ debugName: "rightArrowClass" }] : /* istanbul ignore next */ []));
|
|
341
|
-
this.scrollBehavior = computed(() => this.#prefersReducedMotion() ? "instant" : "smooth", /* @ts-ignore */
|
|
342
|
-
...(ngDevMode ? [{ debugName: "scrollBehavior" }] : /* istanbul ignore next */ []));
|
|
343
|
-
this.scrollViewHeight = computed(() => {
|
|
344
|
-
const height = this.height();
|
|
345
|
-
return toCssValue(height);
|
|
346
|
-
}, /* @ts-ignore */
|
|
347
|
-
...(ngDevMode ? [{ debugName: "scrollViewHeight" }] : /* istanbul ignore next */ []));
|
|
348
|
-
this.scrollViewWidth = computed(() => {
|
|
349
|
-
const width = this.width();
|
|
350
|
-
return toCssValue(width);
|
|
351
|
-
}, /* @ts-ignore */
|
|
352
|
-
...(ngDevMode ? [{ debugName: "scrollViewWidth" }] : /* istanbul ignore next */ []));
|
|
353
|
-
this.slideClass = computed(() => {
|
|
354
|
-
return scrollViewSlideThemeVariants();
|
|
355
|
-
}, /* @ts-ignore */
|
|
356
|
-
...(ngDevMode ? [{ debugName: "slideClass" }] : /* istanbul ignore next */ []));
|
|
357
|
-
this.slideDirective = contentChild(ScrollViewSlideDirective, /* @ts-ignore */
|
|
358
|
-
...(ngDevMode ? [{ debugName: "slideDirective" }] : /* istanbul ignore next */ []));
|
|
359
|
-
this.slideSize = signal({ height: 0, width: 0 }, /* @ts-ignore */
|
|
360
|
-
...(ngDevMode ? [{ debugName: "slideSize" }] : /* istanbul ignore next */ []));
|
|
361
|
-
this.viewData = computed(() => {
|
|
362
|
-
const data = this.data();
|
|
363
|
-
return select(data, d => ({ data: d })).toImmutableSet();
|
|
364
|
-
}, /* @ts-ignore */
|
|
365
|
-
...(ngDevMode ? [{ debugName: "viewData" }] : /* istanbul ignore next */ []));
|
|
366
|
-
this.viewIndex = this.#viewIndex;
|
|
367
|
-
/**
|
|
368
|
-
* @description Sets whether page transitions are animated.
|
|
369
|
-
* Pass a boolean for default duration (500ms) or a number for custom duration in milliseconds.
|
|
370
|
-
* @default true
|
|
371
|
-
*/
|
|
372
|
-
this.animate = input(true, /* @ts-ignore */
|
|
373
|
-
...(ngDevMode ? [{ debugName: "animate" }] : /* istanbul ignore next */ []));
|
|
374
|
-
/**
|
|
375
|
-
* @description Accessible name of the carousel, saying what it shows. Use this or `aria-labelledby`; with neither,
|
|
376
|
-
* the host is a plain group and a warning is logged in development.
|
|
377
|
-
* @default ""
|
|
378
|
-
*/
|
|
379
|
-
this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
380
|
-
/**
|
|
381
|
-
* @description The id of the element that names the carousel.
|
|
382
|
-
* @default ""
|
|
383
|
-
*/
|
|
384
|
-
this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
|
|
385
|
-
/**
|
|
386
|
-
* @description Shows the previous and next arrows. A swipe is a gesture, so give pointer users arrows or a pager too.
|
|
387
|
-
* @default false
|
|
388
|
-
*/
|
|
389
|
-
this.arrows = input(false, /* @ts-ignore */
|
|
390
|
-
...(ngDevMode ? [{ debugName: "arrows" }] : /* istanbul ignore next */ []));
|
|
391
|
-
/**
|
|
392
|
-
* @description Sets the data of the scroll view.
|
|
393
|
-
*/
|
|
394
|
-
this.data = input([], /* @ts-ignore */
|
|
395
|
-
...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
|
|
396
|
-
/**
|
|
397
|
-
* @description Sets the height of the scroll view.
|
|
398
|
-
* This property is required.
|
|
399
|
-
*/
|
|
400
|
-
this.height = input.required(/* @ts-ignore */
|
|
401
|
-
...(ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []));
|
|
402
|
-
/**
|
|
403
|
-
* @description Sets the active page of the scroll view.
|
|
404
|
-
* @default 0
|
|
405
|
-
*/
|
|
406
|
-
this.index = model(0, /* @ts-ignore */
|
|
407
|
-
...(ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []));
|
|
408
|
-
/**
|
|
409
|
-
* @description Sets whether the scroll view is infinite.
|
|
410
|
-
* @default false
|
|
411
|
-
*/
|
|
412
|
-
this.infinite = input(false, /* @ts-ignore */
|
|
413
|
-
...(ngDevMode ? [{ debugName: "infinite" }] : /* istanbul ignore next */ []));
|
|
414
|
-
/**
|
|
415
|
-
* @description Shows the pager. A swipe is a gesture, so give pointer users arrows or a pager too.
|
|
416
|
-
* @default false
|
|
417
|
-
*/
|
|
418
|
-
this.pageable = input(false, /* @ts-ignore */
|
|
419
|
-
...(ngDevMode ? [{ debugName: "pageable" }] : /* istanbul ignore next */ []));
|
|
420
|
-
/**
|
|
421
|
-
* @description Sets the background blur of the pager in pixels. It doesn't apply with `pagerOverlay` set to `"none"`.
|
|
422
|
-
* @default 3
|
|
423
|
-
*/
|
|
424
|
-
this.pagerBlur = input(3, /* @ts-ignore */
|
|
425
|
-
...(ngDevMode ? [{ debugName: "pagerBlur" }] : /* istanbul ignore next */ []));
|
|
426
|
-
/**
|
|
427
|
-
* @description Sets the color of the pager.
|
|
428
|
-
* @default "dark"
|
|
429
|
-
*/
|
|
430
|
-
this.pagerOverlay = input("dark", /* @ts-ignore */
|
|
431
|
-
...(ngDevMode ? [{ debugName: "pagerOverlay" }] : /* istanbul ignore next */ []));
|
|
432
|
-
/**
|
|
433
|
-
* @description Sets the border radius of the pager items.
|
|
434
|
-
* @default "medium"
|
|
435
|
-
*/
|
|
436
|
-
this.pagerRounded = input("medium", /* @ts-ignore */
|
|
437
|
-
...(ngDevMode ? [{ debugName: "pagerRounded" }] : /* istanbul ignore next */ []));
|
|
438
|
-
/**
|
|
439
|
-
* @description Sets the border radius of the scroll view.
|
|
440
|
-
* @default "medium"
|
|
441
|
-
*/
|
|
442
|
-
this.rounded = input("medium", /* @ts-ignore */
|
|
443
|
-
...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
|
|
444
|
-
/**
|
|
445
|
-
* @description Sets custom CSS classes on the component host element. Merged with base classes via tailwind-merge.
|
|
446
|
-
*/
|
|
447
|
-
this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class" });
|
|
448
|
-
/**
|
|
449
|
-
* @description Sets the width of the scroll view.
|
|
450
|
-
*/
|
|
451
|
-
this.width = input.required(/* @ts-ignore */
|
|
452
|
-
...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
|
|
453
|
-
effect(() => {
|
|
454
|
-
const rawIndex = this.index();
|
|
455
|
-
const count = this.itemCount();
|
|
456
|
-
if (count === 0) {
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
const normalizedIndex = this.#viewIndex();
|
|
460
|
-
if (rawIndex !== normalizedIndex) {
|
|
461
|
-
this.index.set(normalizedIndex);
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
this.#directionFromIndex = toSignal(toObservable(this.#viewIndex).pipe(startWith(0), pairwise(), map(([prevIndex, index]) => {
|
|
465
|
-
const intent = this.#navigationIntent;
|
|
466
|
-
this.#navigationIntent = null;
|
|
467
|
-
if (intent) {
|
|
468
|
-
return intent;
|
|
469
|
-
}
|
|
470
|
-
const infinite = this.infinite();
|
|
471
|
-
const totalItems = this.itemCount();
|
|
472
|
-
// With two slides a wrap and a plain step are the same move, so only an intent can tell them apart.
|
|
473
|
-
if (infinite && totalItems > 2) {
|
|
474
|
-
const lastIndex = totalItems - 1;
|
|
475
|
-
if (prevIndex === lastIndex && index === 0) {
|
|
476
|
-
return "right";
|
|
477
|
-
}
|
|
478
|
-
if (prevIndex === 0 && index === lastIndex) {
|
|
479
|
-
return "left";
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
return index < prevIndex ? "left" : "right";
|
|
483
|
-
})), {
|
|
484
|
-
initialValue: "right"
|
|
485
|
-
});
|
|
486
|
-
if (isPlatformBrowser(this.#platformId) &&
|
|
487
|
-
typeof window !== "undefined" &&
|
|
488
|
-
typeof window.matchMedia === "function") {
|
|
489
|
-
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
490
|
-
const onPreferenceChange = (event) => this.#prefersReducedMotion.set(event.matches);
|
|
491
|
-
this.#prefersReducedMotion.set(mediaQuery.matches);
|
|
492
|
-
mediaQuery.addEventListener("change", onPreferenceChange);
|
|
493
|
-
this.#destroyRef.onDestroy(() => mediaQuery.removeEventListener("change", onPreferenceChange));
|
|
494
|
-
}
|
|
495
|
-
// A slide is rendered one at a time, so focus inside the one that's leaving would otherwise fall to the body.
|
|
496
|
-
effect(() => {
|
|
497
|
-
this.#viewIndex();
|
|
498
|
-
untracked(() => {
|
|
499
|
-
const content = this.contentElementRef()?.nativeElement;
|
|
500
|
-
if (content?.contains(this.#document.activeElement)) {
|
|
501
|
-
this.#hostElementRef.nativeElement.focus({ preventScroll: true });
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
});
|
|
505
|
-
this.#destroyRef.onDestroy(() => {
|
|
506
|
-
this.#removeSwipeListeners();
|
|
507
|
-
this.#stopContinuousScroll();
|
|
508
|
-
this.#resetPagerScrollState();
|
|
509
|
-
this.#scroll$.complete();
|
|
510
|
-
this.#resizeObserver?.disconnect();
|
|
511
|
-
});
|
|
512
|
-
afterRenderEffect({
|
|
513
|
-
read: onCleanup => {
|
|
514
|
-
const pagerListElementRef = this.pagerListElementRef();
|
|
515
|
-
const pagerElementRef = this.pagerElementRef();
|
|
516
|
-
this.itemCount();
|
|
517
|
-
this.#resizeObserver?.disconnect();
|
|
518
|
-
this.#resizeObserver = null;
|
|
519
|
-
onCleanup(() => {
|
|
520
|
-
this.#resizeObserver?.disconnect();
|
|
521
|
-
this.#resizeObserver = null;
|
|
522
|
-
});
|
|
523
|
-
if (!pagerListElementRef || !pagerElementRef) {
|
|
524
|
-
this.pagerArrowVisible.set(false);
|
|
525
|
-
this.#resetPagerScrollState();
|
|
526
|
-
return;
|
|
527
|
-
}
|
|
528
|
-
const element = pagerListElementRef.nativeElement;
|
|
529
|
-
const pagerElement = pagerElementRef.nativeElement;
|
|
530
|
-
if (this.#pagerScrollContext && this.#pagerScrollContext.element !== element) {
|
|
531
|
-
this.#resetPagerScrollState();
|
|
532
|
-
}
|
|
533
|
-
this.#updatePagerArrowVisibility(element, pagerElement);
|
|
534
|
-
if (typeof ResizeObserver !== "undefined") {
|
|
535
|
-
this.#resizeObserver = new ResizeObserver(() => {
|
|
536
|
-
this.#updatePagerArrowVisibility(element, pagerElement);
|
|
537
|
-
if (this.#pagerScrollContext && this.#pagerScrollContext.element === element) {
|
|
538
|
-
const currentMaxScroll = Math.max(0, element.scrollWidth - element.clientWidth);
|
|
539
|
-
if (this.#pagerScrollContext.maxScroll !== currentMaxScroll) {
|
|
540
|
-
this.#resetPagerScrollState();
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
});
|
|
544
|
-
this.#resizeObserver.observe(element);
|
|
545
|
-
this.#resizeObserver.observe(pagerElement);
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
});
|
|
549
|
-
afterRenderEffect(() => {
|
|
550
|
-
const index = this.#viewIndex();
|
|
551
|
-
const list = this.pagerListElementRef()?.nativeElement;
|
|
552
|
-
this.itemCount();
|
|
553
|
-
untracked(() => {
|
|
554
|
-
if (!list) {
|
|
555
|
-
this.#pagerCentered = false;
|
|
556
|
-
return;
|
|
557
|
-
}
|
|
558
|
-
const firstRun = !this.#pagerCentered;
|
|
559
|
-
this.#pagerCentered = true;
|
|
560
|
-
if (!firstRun || index !== 0) {
|
|
561
|
-
this.#centerActivePage(list, firstRun ? "instant" : this.scrollBehavior());
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
afterRenderEffect(() => {
|
|
566
|
-
const previousHidden = this.previousArrowHidden();
|
|
567
|
-
const nextHidden = this.nextArrowHidden();
|
|
568
|
-
untracked(() => {
|
|
569
|
-
const previous = this.previousArrowRef()?.nativeElement;
|
|
570
|
-
const next = this.nextArrowRef()?.nativeElement;
|
|
571
|
-
const active = this.#document.activeElement;
|
|
572
|
-
if (active === previous && previousHidden) {
|
|
573
|
-
(nextHidden ? this.#hostElementRef.nativeElement : next)?.focus({ preventScroll: true });
|
|
574
|
-
}
|
|
575
|
-
else if (active === next && nextHidden) {
|
|
576
|
-
(previousHidden ? this.#hostElementRef.nativeElement : previous)?.focus({ preventScroll: true });
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
});
|
|
580
|
-
afterNextRender(() => {
|
|
581
|
-
const content = this.contentElementRef()?.nativeElement;
|
|
582
|
-
if (!content) {
|
|
583
|
-
return;
|
|
584
|
-
}
|
|
585
|
-
const measure = () => {
|
|
586
|
-
const { clientHeight: height, clientWidth: width } = content;
|
|
587
|
-
const current = this.slideSize();
|
|
588
|
-
if (current.height !== height || current.width !== width) {
|
|
589
|
-
this.slideSize.set({ height, width });
|
|
590
|
-
}
|
|
591
|
-
};
|
|
592
|
-
measure();
|
|
593
|
-
if (typeof ResizeObserver !== "undefined") {
|
|
594
|
-
const observer = new ResizeObserver(measure);
|
|
595
|
-
observer.observe(content);
|
|
596
|
-
this.#destroyRef.onDestroy(() => observer.disconnect());
|
|
597
|
-
}
|
|
598
|
-
if (isDevMode() &&
|
|
599
|
-
this.itemCount() > 0 &&
|
|
600
|
-
!this.#hostElementRef.nativeElement.hasAttribute("aria-label") &&
|
|
601
|
-
!this.#hostElementRef.nativeElement.hasAttribute("aria-labelledby")) {
|
|
602
|
-
console.warn("mona-scroll-view: a carousel needs a name. Set aria-label or aria-labelledby.");
|
|
603
|
-
}
|
|
604
|
-
});
|
|
605
|
-
}
|
|
606
|
-
onArrowClick(direction) {
|
|
607
|
-
this.#navigate(direction);
|
|
608
|
-
}
|
|
609
|
-
onKeydown(event) {
|
|
610
|
-
const count = this.itemCount();
|
|
611
|
-
if (count === 0 ||
|
|
612
|
-
event.defaultPrevented ||
|
|
613
|
-
event.altKey ||
|
|
614
|
-
event.ctrlKey ||
|
|
615
|
-
event.metaKey ||
|
|
616
|
-
event.shiftKey ||
|
|
617
|
-
this.contentElementRef()?.nativeElement.contains(event.target)) {
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
const isRtl = this.isRtl();
|
|
621
|
-
switch (event.key) {
|
|
622
|
-
case "ArrowLeft":
|
|
623
|
-
this.#navigate(isRtl ? "right" : "left");
|
|
624
|
-
break;
|
|
625
|
-
case "ArrowRight":
|
|
626
|
-
this.#navigate(isRtl ? "left" : "right");
|
|
627
|
-
break;
|
|
628
|
-
case "Home":
|
|
629
|
-
this.index.set(0);
|
|
630
|
-
break;
|
|
631
|
-
case "End":
|
|
632
|
-
this.index.set(count - 1);
|
|
633
|
-
break;
|
|
634
|
-
default:
|
|
635
|
-
return;
|
|
636
|
-
}
|
|
637
|
-
event.preventDefault();
|
|
638
|
-
}
|
|
639
|
-
onPageClick(index) {
|
|
640
|
-
this.index.set(index);
|
|
641
|
-
}
|
|
642
|
-
onPagerClick(event, element, direction) {
|
|
643
|
-
if (event.button !== 0) {
|
|
644
|
-
return;
|
|
645
|
-
}
|
|
646
|
-
const isKeyboardActivation = event.detail === 0;
|
|
647
|
-
if (!isKeyboardActivation) {
|
|
648
|
-
const pointerId = "pointerId" in event && typeof event.pointerId === "number"
|
|
649
|
-
? event.pointerId
|
|
650
|
-
: null;
|
|
651
|
-
if (pointerId !== null && pointerId !== -1) {
|
|
652
|
-
if (this.#rejectedPagerPointers.has(pointerId)) {
|
|
653
|
-
this.#rejectedPagerPointers.delete(pointerId);
|
|
654
|
-
this.#cleanupDocumentPointerListenersIfNeeded();
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
if (this.#suppressedPagerClickPointerIds.delete(pointerId)) {
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
else {
|
|
662
|
-
if (this.#rejectedPagerPointers.size === 1) {
|
|
663
|
-
const firstKey = this.#rejectedPagerPointers.keys().next().value;
|
|
664
|
-
if (firstKey !== undefined) {
|
|
665
|
-
this.#rejectedPagerPointers.delete(firstKey);
|
|
666
|
-
this.#cleanupDocumentPointerListenersIfNeeded();
|
|
667
|
-
return;
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
if (this.#suppressedPagerClickPointerIds.size === 1) {
|
|
671
|
-
const firstId = this.#suppressedPagerClickPointerIds.values().next().value;
|
|
672
|
-
if (firstId !== undefined) {
|
|
673
|
-
this.#suppressedPagerClickPointerIds.delete(firstId);
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
this.#scrollPagerBy(element, direction);
|
|
680
|
-
}
|
|
681
|
-
onPagerPointerDown(event, element, direction) {
|
|
682
|
-
if (!event.isPrimary || event.button !== 0) {
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
const currentTarget = event.currentTarget;
|
|
686
|
-
const target = event.target;
|
|
687
|
-
this.#releasePagerPointerCapture(currentTarget, event.pointerId);
|
|
688
|
-
if (target !== currentTarget) {
|
|
689
|
-
this.#releasePagerPointerCapture(target, event.pointerId);
|
|
690
|
-
}
|
|
691
|
-
const control = (currentTarget ?? target);
|
|
692
|
-
if (this.#activePagerPointerId !== null) {
|
|
693
|
-
this.#rejectedPagerPointers.set(event.pointerId, {
|
|
694
|
-
control,
|
|
695
|
-
phase: "down"
|
|
696
|
-
});
|
|
697
|
-
this.#ensureDocumentPointerListeners();
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
this.#rejectedPagerPointers.delete(event.pointerId);
|
|
701
|
-
this.#suppressedPagerClickPointerIds.delete(event.pointerId);
|
|
702
|
-
this.#activePagerPointerId = event.pointerId;
|
|
703
|
-
this.#activePagerPointerControl = control;
|
|
704
|
-
this.#continuousTicked = false;
|
|
705
|
-
this.#ensureDocumentPointerListeners();
|
|
706
|
-
interval(60)
|
|
707
|
-
.pipe(takeUntil(this.#scroll$), takeUntilDestroyed(this.#destroyRef))
|
|
708
|
-
.subscribe(() => {
|
|
709
|
-
this.#continuousTicked = true;
|
|
710
|
-
this.#scrollPagerBy(element, direction);
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
onSwipeStart(event) {
|
|
714
|
-
this.#removeSwipeListeners();
|
|
715
|
-
if (!event.isPrimary ||
|
|
716
|
-
event.pointerType === "mouse" ||
|
|
717
|
-
event.button !== 0 ||
|
|
718
|
-
this.itemCount() <= 1 ||
|
|
719
|
-
event.target.closest(SWIPE_EXEMPT_SELECTOR)) {
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
this.#activeSwipe = { pointerId: event.pointerId, startX: event.clientX, startY: event.clientY };
|
|
723
|
-
this.#document.addEventListener("pointerup", this.#swipeEndHandler);
|
|
724
|
-
this.#document.addEventListener("pointercancel", this.#swipeCancelHandler);
|
|
725
|
-
}
|
|
726
|
-
#armPagerScrollCompletion(element) {
|
|
727
|
-
if (this.#pagerScrollCompletionCleanup) {
|
|
728
|
-
this.#pagerScrollCompletionCleanup();
|
|
729
|
-
this.#pagerScrollCompletionCleanup = null;
|
|
730
|
-
}
|
|
731
|
-
const onScrollEnd = () => {
|
|
732
|
-
this.#resetPagerScrollState();
|
|
733
|
-
};
|
|
734
|
-
const supportsScrollEnd = isPlatformBrowser(this.#platformId) &&
|
|
735
|
-
typeof window !== "undefined" &&
|
|
736
|
-
"onscrollend" in element &&
|
|
737
|
-
typeof element.addEventListener === "function";
|
|
738
|
-
if (supportsScrollEnd) {
|
|
739
|
-
element.addEventListener("scrollend", onScrollEnd, { once: true });
|
|
740
|
-
this.#pagerScrollCompletionCleanup = () => {
|
|
741
|
-
element.removeEventListener?.("scrollend", onScrollEnd);
|
|
742
|
-
};
|
|
743
|
-
}
|
|
744
|
-
else {
|
|
745
|
-
let inactivityTimeoutId = null;
|
|
746
|
-
const scheduleInactivityTimeout = () => {
|
|
747
|
-
if (inactivityTimeoutId !== null && typeof window !== "undefined") {
|
|
748
|
-
window.clearTimeout(inactivityTimeoutId);
|
|
749
|
-
}
|
|
750
|
-
if (isPlatformBrowser(this.#platformId) && typeof window !== "undefined") {
|
|
751
|
-
inactivityTimeoutId = window.setTimeout(onScrollEnd, 150);
|
|
752
|
-
}
|
|
753
|
-
};
|
|
754
|
-
const onScroll = () => {
|
|
755
|
-
scheduleInactivityTimeout();
|
|
756
|
-
};
|
|
757
|
-
if (typeof element.addEventListener === "function") {
|
|
758
|
-
element.addEventListener("scroll", onScroll, { passive: true });
|
|
759
|
-
}
|
|
760
|
-
scheduleInactivityTimeout();
|
|
761
|
-
this.#pagerScrollCompletionCleanup = () => {
|
|
762
|
-
if (typeof element.removeEventListener === "function") {
|
|
763
|
-
element.removeEventListener("scroll", onScroll);
|
|
764
|
-
}
|
|
765
|
-
if (inactivityTimeoutId !== null && typeof window !== "undefined") {
|
|
766
|
-
window.clearTimeout(inactivityTimeoutId);
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
#centerActivePage(list, behavior) {
|
|
772
|
-
this.#resetPagerScrollState();
|
|
773
|
-
const active = list.querySelector("button[data-active-page='true']");
|
|
774
|
-
if (!active || typeof list.scrollTo !== "function") {
|
|
775
|
-
return;
|
|
776
|
-
}
|
|
777
|
-
const listRect = list.getBoundingClientRect();
|
|
778
|
-
const activeRect = active.getBoundingClientRect();
|
|
779
|
-
const offset = activeRect.left + activeRect.width / 2 - (listRect.left + listRect.width / 2);
|
|
780
|
-
// Only the pager list moves, unlike scrollIntoView, which would also scroll the page to the carousel.
|
|
781
|
-
list.scrollTo({ behavior, left: list.scrollLeft + offset });
|
|
782
|
-
}
|
|
783
|
-
#cleanupDocumentPointerListenersIfNeeded() {
|
|
784
|
-
let hasDownRejected = false;
|
|
785
|
-
for (const p of this.#rejectedPagerPointers.values()) {
|
|
786
|
-
if (p.phase === "down") {
|
|
787
|
-
hasDownRejected = true;
|
|
788
|
-
break;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
if (this.#activePagerPointerId === null && !hasDownRejected) {
|
|
792
|
-
this.#document.removeEventListener("pointerup", this.#pointerUpHandler);
|
|
793
|
-
this.#document.removeEventListener("pointercancel", this.#pointerCancelHandler);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
#endSwipe(event, completed) {
|
|
797
|
-
const swipe = this.#activeSwipe;
|
|
798
|
-
if (swipe?.pointerId !== event.pointerId) {
|
|
799
|
-
return;
|
|
800
|
-
}
|
|
801
|
-
this.#removeSwipeListeners();
|
|
802
|
-
if (!completed) {
|
|
803
|
-
return;
|
|
804
|
-
}
|
|
805
|
-
const deltaX = event.clientX - swipe.startX;
|
|
806
|
-
const deltaY = event.clientY - swipe.startY;
|
|
807
|
-
if (Math.abs(deltaX) < SWIPE_DISTANCE || Math.abs(deltaX) <= Math.abs(deltaY)) {
|
|
808
|
-
return;
|
|
809
|
-
}
|
|
810
|
-
const towardsNext = this.isRtl() ? deltaX > 0 : deltaX < 0;
|
|
811
|
-
this.#navigate(towardsNext ? "right" : "left");
|
|
812
|
-
}
|
|
813
|
-
#ensureDocumentPointerListeners() {
|
|
814
|
-
this.#document.addEventListener("pointerup", this.#pointerUpHandler);
|
|
815
|
-
this.#document.addEventListener("pointercancel", this.#pointerCancelHandler);
|
|
816
|
-
}
|
|
817
|
-
#handlePointerEnd(event, isUp) {
|
|
818
|
-
if (event.pointerId !== this.#activePagerPointerId) {
|
|
819
|
-
const rejected = this.#rejectedPagerPointers.get(event.pointerId);
|
|
820
|
-
if (rejected) {
|
|
821
|
-
if (!isUp) {
|
|
822
|
-
this.#rejectedPagerPointers.delete(event.pointerId);
|
|
823
|
-
}
|
|
824
|
-
else {
|
|
825
|
-
const isWithinControl = this.#isPointerReleaseWithinControl(event, rejected.control ?? null);
|
|
826
|
-
if (isWithinControl) {
|
|
827
|
-
rejected.phase = "awaiting-click";
|
|
828
|
-
}
|
|
829
|
-
else {
|
|
830
|
-
this.#rejectedPagerPointers.delete(event.pointerId);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
this.#cleanupDocumentPointerListenersIfNeeded();
|
|
835
|
-
return;
|
|
836
|
-
}
|
|
837
|
-
this.#scroll$.next();
|
|
838
|
-
const shouldSuppressTrailingClick = isUp &&
|
|
839
|
-
this.#continuousTicked &&
|
|
840
|
-
this.#isPointerReleaseWithinControl(event, this.#activePagerPointerControl);
|
|
841
|
-
if (shouldSuppressTrailingClick) {
|
|
842
|
-
this.#suppressedPagerClickPointerIds.add(event.pointerId);
|
|
843
|
-
}
|
|
844
|
-
else {
|
|
845
|
-
this.#suppressedPagerClickPointerIds.delete(event.pointerId);
|
|
846
|
-
}
|
|
847
|
-
this.#continuousTicked = false;
|
|
848
|
-
this.#activePagerPointerId = null;
|
|
849
|
-
this.#activePagerPointerControl = null;
|
|
850
|
-
this.#cleanupDocumentPointerListenersIfNeeded();
|
|
851
|
-
}
|
|
852
|
-
#isPointerReleaseWithinControl(event, control) {
|
|
853
|
-
if (control == null) {
|
|
854
|
-
return true;
|
|
855
|
-
}
|
|
856
|
-
const targetNode = event.target;
|
|
857
|
-
return ((targetNode != null && control.contains(targetNode)) ||
|
|
858
|
-
(typeof event.composedPath === "function" && event.composedPath().includes(control)));
|
|
859
|
-
}
|
|
860
|
-
#navigate(direction) {
|
|
861
|
-
const count = this.itemCount();
|
|
862
|
-
if (count === 0) {
|
|
863
|
-
return;
|
|
864
|
-
}
|
|
865
|
-
const current = this.#viewIndex();
|
|
866
|
-
const step = direction === "left" ? -1 : 1;
|
|
867
|
-
const next = this.infinite() ? (current + step + count) % count : Math.max(0, Math.min(count - 1, current + step));
|
|
868
|
-
if (next !== current) {
|
|
869
|
-
this.#navigationIntent = direction;
|
|
870
|
-
this.index.set(next);
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
#releasePagerPointerCapture(control, pointerId) {
|
|
874
|
-
if (control == null ||
|
|
875
|
-
typeof control.hasPointerCapture !== "function" ||
|
|
876
|
-
typeof control.releasePointerCapture !== "function") {
|
|
877
|
-
return;
|
|
878
|
-
}
|
|
879
|
-
try {
|
|
880
|
-
if (control.hasPointerCapture(pointerId)) {
|
|
881
|
-
control.releasePointerCapture(pointerId);
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
catch {
|
|
885
|
-
// Do not let an implementation-specific capture race break pager interaction.
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
#removeSwipeListeners() {
|
|
889
|
-
this.#activeSwipe = null;
|
|
890
|
-
this.#document.removeEventListener("pointerup", this.#swipeEndHandler);
|
|
891
|
-
this.#document.removeEventListener("pointercancel", this.#swipeCancelHandler);
|
|
892
|
-
}
|
|
893
|
-
#resetPagerScrollState() {
|
|
894
|
-
if (this.#pagerScrollCompletionCleanup) {
|
|
895
|
-
this.#pagerScrollCompletionCleanup();
|
|
896
|
-
this.#pagerScrollCompletionCleanup = null;
|
|
897
|
-
}
|
|
898
|
-
this.#pagerScrollContext = null;
|
|
899
|
-
}
|
|
900
|
-
#scrollPagerBy(element, direction) {
|
|
901
|
-
const currentDirection = this.isRtl() ? "rtl" : "ltr";
|
|
902
|
-
const maxScroll = Math.max(0, (element.scrollWidth ?? 0) - (element.clientWidth ?? 0));
|
|
903
|
-
const sameContext = this.#pagerScrollContext?.element === element &&
|
|
904
|
-
this.#pagerScrollContext.direction === currentDirection &&
|
|
905
|
-
this.#pagerScrollContext.maxScroll === maxScroll;
|
|
906
|
-
const currentScrollLeft = element.scrollLeft ?? 0;
|
|
907
|
-
const base = sameContext ? this.#pagerScrollContext.target : currentScrollLeft;
|
|
908
|
-
let offset = direction === "left" ? -100 : 100;
|
|
909
|
-
if (currentDirection === "rtl") {
|
|
910
|
-
offset = -offset;
|
|
911
|
-
}
|
|
912
|
-
const target = base + offset;
|
|
913
|
-
const clampedTarget = currentDirection === "ltr"
|
|
914
|
-
? Math.max(0, Math.min(maxScroll, target))
|
|
915
|
-
: Math.max(-maxScroll, Math.min(0, target));
|
|
916
|
-
if (!sameContext && clampedTarget === currentScrollLeft) {
|
|
917
|
-
this.#resetPagerScrollState();
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
|
-
if (sameContext && clampedTarget === this.#pagerScrollContext.target) {
|
|
921
|
-
return;
|
|
922
|
-
}
|
|
923
|
-
this.#pagerScrollContext = {
|
|
924
|
-
direction: currentDirection,
|
|
925
|
-
element,
|
|
926
|
-
maxScroll,
|
|
927
|
-
target: clampedTarget
|
|
928
|
-
};
|
|
929
|
-
if (typeof element.scrollTo === "function") {
|
|
930
|
-
element.scrollTo({ behavior: this.scrollBehavior(), left: clampedTarget });
|
|
931
|
-
}
|
|
932
|
-
else if (typeof element.scrollBy === "function") {
|
|
933
|
-
element.scrollBy({ behavior: this.scrollBehavior(), left: offset });
|
|
934
|
-
}
|
|
935
|
-
this.#armPagerScrollCompletion(element);
|
|
936
|
-
}
|
|
937
|
-
#stopContinuousScroll() {
|
|
938
|
-
this.#document.removeEventListener("pointerup", this.#pointerUpHandler);
|
|
939
|
-
this.#document.removeEventListener("pointercancel", this.#pointerCancelHandler);
|
|
940
|
-
this.#scroll$.next();
|
|
941
|
-
this.#continuousTicked = false;
|
|
942
|
-
this.#activePagerPointerId = null;
|
|
943
|
-
this.#activePagerPointerControl = null;
|
|
944
|
-
this.#suppressedPagerClickPointerIds.clear();
|
|
945
|
-
this.#rejectedPagerPointers.clear();
|
|
946
|
-
}
|
|
947
|
-
#updatePagerArrowVisibility(list, pager) {
|
|
948
|
-
const requiredWidth = list.scrollWidth;
|
|
949
|
-
const arrowFreeAvailableWidth = pager.clientWidth;
|
|
950
|
-
this.pagerArrowVisible.set(requiredWidth > arrowFreeAvailableWidth);
|
|
951
|
-
}
|
|
952
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
953
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: ScrollViewComponent, isStandalone: true, selector: "mona-scroll-view", inputs: { animate: { classPropertyName: "animate", publicName: "animate", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, ariaLabelledBy: { classPropertyName: "ariaLabelledBy", publicName: "aria-labelledby", isSignal: true, isRequired: false, transformFunction: null }, arrows: { classPropertyName: "arrows", publicName: "arrows", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: true, transformFunction: null }, index: { classPropertyName: "index", publicName: "index", isSignal: true, isRequired: false, transformFunction: null }, infinite: { classPropertyName: "infinite", publicName: "infinite", isSignal: true, isRequired: false, transformFunction: null }, pageable: { classPropertyName: "pageable", publicName: "pageable", isSignal: true, isRequired: false, transformFunction: null }, pagerBlur: { classPropertyName: "pagerBlur", publicName: "pagerBlur", isSignal: true, isRequired: false, transformFunction: null }, pagerOverlay: { classPropertyName: "pagerOverlay", publicName: "pagerOverlay", isSignal: true, isRequired: false, transformFunction: null }, pagerRounded: { classPropertyName: "pagerRounded", publicName: "pagerRounded", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { index: "indexChange" }, host: { listeners: { "keydown": "onKeydown($event)" }, properties: { "class": "baseClass()", "attr.tabindex": "itemCount() > 0 ? 0 : null", "style.height": "scrollViewHeight()", "style.width": "scrollViewWidth()", "attr.role": "hostRole()", "attr.aria-roledescription": "itemCount() > 0 ? messages().carousel : null", "attr.aria-label": "ariaLabel() || null", "attr.aria-labelledby": "ariaLabelledBy() || null" } }, queries: [{ propertyName: "bareTemplate", first: true, predicate: TemplateRef, descendants: true, isSignal: true }, { propertyName: "slideDirective", first: true, predicate: ScrollViewSlideDirective, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "contentElementRef", first: true, predicate: ["contentElement"], descendants: true, isSignal: true }, { propertyName: "nextArrowRef", first: true, predicate: ["nextArrow"], descendants: true, isSignal: true }, { propertyName: "pagerElementRef", first: true, predicate: ["pagerElement"], descendants: true, isSignal: true }, { propertyName: "pagerListElementRef", first: true, predicate: ["pagerListElement"], descendants: true, isSignal: true }, { propertyName: "previousArrowRef", first: true, predicate: ["previousArrow"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n [class]=\"contentClass()\"\n aria-live=\"polite\"\n aria-atomic=\"false\"\n data-scroll-view-content=\"true\"\n (pointerdown)=\"onSwipeStart($event)\"\n #contentElement>\n @for (item of viewData(); track $index) {\n @if ($index === viewIndex()) {\n <div\n role=\"group\"\n data-scroll-view-slide=\"true\"\n [class]=\"slideClass()\"\n [attr.aria-roledescription]=\"messages().slide\"\n [attr.aria-label]=\"messages().pageOf($index + 1, itemCount())\"\n [animate.enter]=\"enterAnimation()\"\n [animate.leave]=\"leaveAnimation()\"\n [style.--mona-scroll-view-animation-duration]=\"animationDuration() + 'ms'\">\n <ng-container\n [ngTemplateOutlet]=\"contentTemplate()\"\n [ngTemplateOutletContext]=\"{\n $implicit: item.data,\n width: slideSize().width,\n height: slideSize().height\n }\"></ng-container>\n </div>\n }\n }\n</div>\n<button\n #previousArrow\n type=\"button\"\n [class]=\"leftArrowClass()\"\n (click)=\"onArrowClick('left')\"\n [attr.data-navigate-prev]=\"true\"\n [attr.aria-label]=\"messages().previousPage\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"48\"\n height=\"48\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-left-icon lucide-chevron-left rtl:rotate-180\">\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n</button>\n<button\n #nextArrow\n type=\"button\"\n [class]=\"rightArrowClass()\"\n (click)=\"onArrowClick('right')\"\n [attr.data-navigate-next]=\"true\"\n [attr.aria-label]=\"messages().nextPage\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"48\"\n height=\"48\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-right-icon lucide-chevron-right rtl:rotate-180\">\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n</button>\n\n@if (pageable()) {\n <div\n #pagerElement\n data-pager-root=\"true\"\n [class]=\"pagerClass()\"\n [style.direction]=\"isRtl() ? 'rtl' : 'ltr'\"\n [style.backdrop-filter]=\"pagerOverlay() === 'none' ? null : 'blur(' + pagerBlur() + 'px)'\">\n @if (pagerArrowVisible()) {\n <button\n type=\"button\"\n [class]=\"pagerArrowClass()\"\n [attr.aria-label]=\"messages().scrollPagerPrevious\"\n (pointerdown)=\"onPagerPointerDown($event, pagerListElement, 'left')\"\n (click)=\"onPagerClick($event, pagerListElement, 'left')\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-left-icon lucide-chevron-left rtl:rotate-180\">\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n }\n <div [class]=\"pagerListContainerClass()\">\n <ul [class]=\"pagerListClass()\" [attr.aria-label]=\"messages().pages\" #pagerListElement>\n @for (_ of viewData(); track $index) {\n <li [attr.data-page-index]=\"$index\" [attr.data-page-item]=\"true\">\n <button\n type=\"button\"\n monaScrollViewActivePage\n [active]=\"$index === viewIndex()\"\n [rounded]=\"pagerRounded()\"\n [attr.data-active-page]=\"$index === viewIndex()\"\n [attr.aria-current]=\"$index === viewIndex() ? true : null\"\n [attr.aria-label]=\"messages().page($index + 1)\"\n (click)=\"onPageClick($index)\"></button>\n </li>\n }\n </ul>\n </div>\n @if (pagerArrowVisible()) {\n <button\n type=\"button\"\n [class]=\"pagerArrowClass()\"\n [attr.aria-label]=\"messages().scrollPagerNext\"\n (pointerdown)=\"onPagerPointerDown($event, pagerListElement, 'right')\"\n (click)=\"onPagerClick($event, pagerListElement, 'right')\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-right-icon lucide-chevron-right rtl:rotate-180\">\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n }\n </div>\n}\n", styles: ["@keyframes slideInFromRight{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes slideOutToLeft{0%{transform:translate(0)}to{transform:translate(-100%)}}@keyframes slideInFromLeft{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes slideOutToRight{0%{transform:translate(0)}to{transform:translate(100%)}}.slide-in-from-right,.slide-out-to-left,.slide-in-from-left,.slide-out-to-right{animation-duration:var(--mona-scroll-view-animation-duration, .5s);animation-timing-function:ease-out;animation-fill-mode:both}.slide-in-from-right{animation-name:slideInFromRight}.slide-out-to-left{animation-name:slideOutToLeft}.slide-in-from-left{animation-name:slideInFromLeft}.slide-out-to-right{animation-name:slideOutToRight}@media(prefers-reduced-motion:reduce){.slide-in-from-right,.slide-out-to-left,.slide-in-from-left,.slide-out-to-right{animation-duration:min(var(--mona-scroll-view-animation-duration, .5s),1ms)}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: ScrollViewActivePageDirective, selector: "button[monaScrollViewActivePage]", inputs: ["active", "rounded"] }] }); }
|
|
251
|
+
if (itemCount <= 0) return 0;
|
|
252
|
+
const finiteIndex = Number.isFinite(rawIndex) ? Math.trunc(rawIndex) : 0;
|
|
253
|
+
if (infinite) return (finiteIndex % itemCount + itemCount) % itemCount;
|
|
254
|
+
return Math.max(0, Math.min(itemCount - 1, finiteIndex));
|
|
954
255
|
}
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
256
|
+
var ScrollViewComponent = class ScrollViewComponent {
|
|
257
|
+
#destroyRef;
|
|
258
|
+
#direction;
|
|
259
|
+
#directionFromIndex;
|
|
260
|
+
#document;
|
|
261
|
+
#hostElementRef;
|
|
262
|
+
#i18n;
|
|
263
|
+
#platformId;
|
|
264
|
+
#pointerCancelHandler;
|
|
265
|
+
#pointerUpHandler;
|
|
266
|
+
#prefersReducedMotion;
|
|
267
|
+
#rejectedPagerPointers;
|
|
268
|
+
#scroll$;
|
|
269
|
+
#swipeCancelHandler;
|
|
270
|
+
#swipeEndHandler;
|
|
271
|
+
#suppressedPagerClickPointerIds;
|
|
272
|
+
#viewIndex;
|
|
273
|
+
#activePagerPointerControl;
|
|
274
|
+
#activePagerPointerId;
|
|
275
|
+
#activeSwipe;
|
|
276
|
+
#continuousTicked;
|
|
277
|
+
#navigationIntent;
|
|
278
|
+
#pagerCentered;
|
|
279
|
+
#pagerScrollCompletionCleanup;
|
|
280
|
+
#pagerScrollContext;
|
|
281
|
+
#resizeObserver;
|
|
282
|
+
constructor() {
|
|
283
|
+
this.#destroyRef = inject(DestroyRef);
|
|
284
|
+
this.#direction = injectComponentDirection();
|
|
285
|
+
this.#document = inject(DOCUMENT);
|
|
286
|
+
this.#hostElementRef = inject(ElementRef);
|
|
287
|
+
this.#i18n = inject(MonaI18nService);
|
|
288
|
+
this.#platformId = inject(PLATFORM_ID);
|
|
289
|
+
this.#pointerCancelHandler = (event) => this.#handlePointerEnd(event, false);
|
|
290
|
+
this.#pointerUpHandler = (event) => this.#handlePointerEnd(event, true);
|
|
291
|
+
this.#prefersReducedMotion = signal(false, ...ngDevMode ? [{ debugName: "#prefersReducedMotion" }] : /* istanbul ignore next */ []);
|
|
292
|
+
this.#rejectedPagerPointers = /* @__PURE__ */ new Map();
|
|
293
|
+
this.#scroll$ = new Subject();
|
|
294
|
+
this.#swipeCancelHandler = (event) => this.#endSwipe(event, false);
|
|
295
|
+
this.#swipeEndHandler = (event) => this.#endSwipe(event, true);
|
|
296
|
+
this.#suppressedPagerClickPointerIds = /* @__PURE__ */ new Set();
|
|
297
|
+
this.#viewIndex = computed(() => {
|
|
298
|
+
return normalizeScrollViewIndex(this.index(), this.itemCount(), this.infinite());
|
|
299
|
+
}, ...ngDevMode ? [{ debugName: "#viewIndex" }] : /* istanbul ignore next */ []);
|
|
300
|
+
this.#activePagerPointerControl = null;
|
|
301
|
+
this.#activePagerPointerId = null;
|
|
302
|
+
this.#activeSwipe = null;
|
|
303
|
+
this.#continuousTicked = false;
|
|
304
|
+
this.#navigationIntent = null;
|
|
305
|
+
this.#pagerCentered = false;
|
|
306
|
+
this.#pagerScrollCompletionCleanup = null;
|
|
307
|
+
this.#pagerScrollContext = null;
|
|
308
|
+
this.#resizeObserver = null;
|
|
309
|
+
this.animationDuration = computed(() => {
|
|
310
|
+
const animate = this.animate();
|
|
311
|
+
return typeof animate === "boolean" ? animate ? 500 : 0 : animate;
|
|
312
|
+
}, ...ngDevMode ? [{ debugName: "animationDuration" }] : /* istanbul ignore next */ []);
|
|
313
|
+
this.bareTemplate = contentChild(TemplateRef, ...ngDevMode ? [{ debugName: "bareTemplate" }] : /* istanbul ignore next */ []);
|
|
314
|
+
this.baseClass = computed(() => {
|
|
315
|
+
const rounded = this.rounded();
|
|
316
|
+
const variantClass = scrollViewBaseThemeVariants({ rounded });
|
|
317
|
+
const userClass = this.userClass();
|
|
318
|
+
return twMerge(variantClass, userClass);
|
|
319
|
+
}, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
|
|
320
|
+
this.contentClass = computed(() => {
|
|
321
|
+
return scrollViewContentThemeVariants();
|
|
322
|
+
}, ...ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []);
|
|
323
|
+
this.contentElementRef = viewChild("contentElement", ...ngDevMode ? [{ debugName: "contentElementRef" }] : /* istanbul ignore next */ []);
|
|
324
|
+
this.contentTemplate = computed(() => this.slideDirective()?.templateRef ?? this.bareTemplate(), ...ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []);
|
|
325
|
+
this.enterAnimation = computed(() => {
|
|
326
|
+
const isRtl = this.isRtl();
|
|
327
|
+
const dir = this.#directionFromIndex();
|
|
328
|
+
return (isRtl ? dir === "right" ? "left" : "right" : dir) === "right" ? "slide-in-from-right" : "slide-in-from-left";
|
|
329
|
+
}, ...ngDevMode ? [{ debugName: "enterAnimation" }] : /* istanbul ignore next */ []);
|
|
330
|
+
this.hostRole = computed(() => this.ariaLabel() || this.ariaLabelledBy() ? "region" : "group", ...ngDevMode ? [{ debugName: "hostRole" }] : /* istanbul ignore next */ []);
|
|
331
|
+
this.isRtl = computed(() => this.#direction() === "rtl", ...ngDevMode ? [{ debugName: "isRtl" }] : /* istanbul ignore next */ []);
|
|
332
|
+
this.itemCount = computed(() => this.viewData().length, ...ngDevMode ? [{ debugName: "itemCount" }] : /* istanbul ignore next */ []);
|
|
333
|
+
this.leaveAnimation = computed(() => {
|
|
334
|
+
const isRtl = this.isRtl();
|
|
335
|
+
const dir = this.#directionFromIndex();
|
|
336
|
+
return (isRtl ? dir === "right" ? "left" : "right" : dir) === "right" ? "slide-out-to-left" : "slide-out-to-right";
|
|
337
|
+
}, ...ngDevMode ? [{ debugName: "leaveAnimation" }] : /* istanbul ignore next */ []);
|
|
338
|
+
this.leftArrowClass = computed(() => {
|
|
339
|
+
const side = this.isRtl() ? "right" : "left";
|
|
340
|
+
return scrollViewArrowThemeVariants({
|
|
341
|
+
hidden: this.previousArrowHidden(),
|
|
342
|
+
side
|
|
343
|
+
});
|
|
344
|
+
}, ...ngDevMode ? [{ debugName: "leftArrowClass" }] : /* istanbul ignore next */ []);
|
|
345
|
+
this.messages = this.#i18n.componentMessages("scrollView", SCROLL_VIEW_DEFAULT_MESSAGES);
|
|
346
|
+
this.nextArrowHidden = computed(() => {
|
|
347
|
+
const count = this.itemCount();
|
|
348
|
+
return !this.arrows() || count <= 1 || !(this.infinite() || this.viewIndex() !== count - 1);
|
|
349
|
+
}, ...ngDevMode ? [{ debugName: "nextArrowHidden" }] : /* istanbul ignore next */ []);
|
|
350
|
+
this.nextArrowRef = viewChild("nextArrow", ...ngDevMode ? [{ debugName: "nextArrowRef" }] : /* istanbul ignore next */ []);
|
|
351
|
+
this.pagerArrowClass = computed(() => {
|
|
352
|
+
return scrollViewPagerArrowThemeVariants();
|
|
353
|
+
}, ...ngDevMode ? [{ debugName: "pagerArrowClass" }] : /* istanbul ignore next */ []);
|
|
354
|
+
this.pagerArrowVisible = signal(false, ...ngDevMode ? [{ debugName: "pagerArrowVisible" }] : /* istanbul ignore next */ []);
|
|
355
|
+
this.pagerClass = computed(() => {
|
|
356
|
+
const pagerOverlay = this.pagerOverlay();
|
|
357
|
+
return scrollViewPagerThemeVariants({ pagerOverlay });
|
|
358
|
+
}, ...ngDevMode ? [{ debugName: "pagerClass" }] : /* istanbul ignore next */ []);
|
|
359
|
+
this.pagerElementRef = viewChild("pagerElement", ...ngDevMode ? [{ debugName: "pagerElementRef" }] : /* istanbul ignore next */ []);
|
|
360
|
+
this.pagerListClass = computed(() => {
|
|
361
|
+
return scrollViewPagerListThemeVariants();
|
|
362
|
+
}, ...ngDevMode ? [{ debugName: "pagerListClass" }] : /* istanbul ignore next */ []);
|
|
363
|
+
this.pagerListContainerClass = computed(() => {
|
|
364
|
+
return scrollViewPagerListContainerThemeVariants();
|
|
365
|
+
}, ...ngDevMode ? [{ debugName: "pagerListContainerClass" }] : /* istanbul ignore next */ []);
|
|
366
|
+
this.pagerListElementRef = viewChild("pagerListElement", ...ngDevMode ? [{ debugName: "pagerListElementRef" }] : /* istanbul ignore next */ []);
|
|
367
|
+
this.previousArrowHidden = computed(() => {
|
|
368
|
+
return !this.arrows() || this.itemCount() <= 1 || !(this.infinite() || this.viewIndex() !== 0);
|
|
369
|
+
}, ...ngDevMode ? [{ debugName: "previousArrowHidden" }] : /* istanbul ignore next */ []);
|
|
370
|
+
this.previousArrowRef = viewChild("previousArrow", ...ngDevMode ? [{ debugName: "previousArrowRef" }] : /* istanbul ignore next */ []);
|
|
371
|
+
this.rightArrowClass = computed(() => {
|
|
372
|
+
const side = this.isRtl() ? "left" : "right";
|
|
373
|
+
return scrollViewArrowThemeVariants({
|
|
374
|
+
hidden: this.nextArrowHidden(),
|
|
375
|
+
side
|
|
376
|
+
});
|
|
377
|
+
}, ...ngDevMode ? [{ debugName: "rightArrowClass" }] : /* istanbul ignore next */ []);
|
|
378
|
+
this.scrollBehavior = computed(() => this.#prefersReducedMotion() ? "instant" : "smooth", ...ngDevMode ? [{ debugName: "scrollBehavior" }] : /* istanbul ignore next */ []);
|
|
379
|
+
this.scrollViewHeight = computed(() => {
|
|
380
|
+
const height = this.height();
|
|
381
|
+
return toCssValue(height);
|
|
382
|
+
}, ...ngDevMode ? [{ debugName: "scrollViewHeight" }] : /* istanbul ignore next */ []);
|
|
383
|
+
this.scrollViewWidth = computed(() => {
|
|
384
|
+
const width = this.width();
|
|
385
|
+
return toCssValue(width);
|
|
386
|
+
}, ...ngDevMode ? [{ debugName: "scrollViewWidth" }] : /* istanbul ignore next */ []);
|
|
387
|
+
this.slideClass = computed(() => {
|
|
388
|
+
return scrollViewSlideThemeVariants();
|
|
389
|
+
}, ...ngDevMode ? [{ debugName: "slideClass" }] : /* istanbul ignore next */ []);
|
|
390
|
+
this.slideDirective = contentChild(ScrollViewSlideDirective, ...ngDevMode ? [{ debugName: "slideDirective" }] : /* istanbul ignore next */ []);
|
|
391
|
+
this.slideSize = signal({
|
|
392
|
+
height: 0,
|
|
393
|
+
width: 0
|
|
394
|
+
}, ...ngDevMode ? [{ debugName: "slideSize" }] : /* istanbul ignore next */ []);
|
|
395
|
+
this.viewData = computed(() => {
|
|
396
|
+
const data = this.data();
|
|
397
|
+
return select(data, (d) => ({ data: d })).toImmutableSet();
|
|
398
|
+
}, ...ngDevMode ? [{ debugName: "viewData" }] : /* istanbul ignore next */ []);
|
|
399
|
+
this.viewIndex = this.#viewIndex;
|
|
400
|
+
this.animate = input(true, ...ngDevMode ? [{ debugName: "animate" }] : /* istanbul ignore next */ []);
|
|
401
|
+
this.ariaLabel = input("", {
|
|
402
|
+
...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
|
|
403
|
+
alias: "aria-label"
|
|
404
|
+
});
|
|
405
|
+
this.ariaLabelledBy = input("", {
|
|
406
|
+
...ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {},
|
|
407
|
+
alias: "aria-labelledby"
|
|
408
|
+
});
|
|
409
|
+
this.arrows = input(false, ...ngDevMode ? [{ debugName: "arrows" }] : /* istanbul ignore next */ []);
|
|
410
|
+
this.data = input([], ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
411
|
+
this.height = input.required(...ngDevMode ? [{ debugName: "height" }] : /* istanbul ignore next */ []);
|
|
412
|
+
this.index = model(0, ...ngDevMode ? [{ debugName: "index" }] : /* istanbul ignore next */ []);
|
|
413
|
+
this.infinite = input(false, ...ngDevMode ? [{ debugName: "infinite" }] : /* istanbul ignore next */ []);
|
|
414
|
+
this.pageable = input(false, ...ngDevMode ? [{ debugName: "pageable" }] : /* istanbul ignore next */ []);
|
|
415
|
+
this.pagerBlur = input(3, ...ngDevMode ? [{ debugName: "pagerBlur" }] : /* istanbul ignore next */ []);
|
|
416
|
+
this.pagerOverlay = input("dark", ...ngDevMode ? [{ debugName: "pagerOverlay" }] : /* istanbul ignore next */ []);
|
|
417
|
+
this.pagerRounded = input("medium", ...ngDevMode ? [{ debugName: "pagerRounded" }] : /* istanbul ignore next */ []);
|
|
418
|
+
this.rounded = input("medium", ...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
|
|
419
|
+
this.userClass = input("", {
|
|
420
|
+
...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
|
|
421
|
+
alias: "class"
|
|
422
|
+
});
|
|
423
|
+
this.width = input.required(...ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []);
|
|
424
|
+
effect(() => {
|
|
425
|
+
const rawIndex = this.index();
|
|
426
|
+
if (this.itemCount() === 0) return;
|
|
427
|
+
const normalizedIndex = this.#viewIndex();
|
|
428
|
+
if (rawIndex !== normalizedIndex) this.index.set(normalizedIndex);
|
|
429
|
+
});
|
|
430
|
+
this.#directionFromIndex = toSignal(toObservable(this.#viewIndex).pipe(startWith(0), pairwise(), map(([prevIndex, index]) => {
|
|
431
|
+
const intent = this.#navigationIntent;
|
|
432
|
+
this.#navigationIntent = null;
|
|
433
|
+
if (intent) return intent;
|
|
434
|
+
const infinite = this.infinite();
|
|
435
|
+
const totalItems = this.itemCount();
|
|
436
|
+
if (infinite && totalItems > 2) {
|
|
437
|
+
const lastIndex = totalItems - 1;
|
|
438
|
+
if (prevIndex === lastIndex && index === 0) return "right";
|
|
439
|
+
if (prevIndex === 0 && index === lastIndex) return "left";
|
|
440
|
+
}
|
|
441
|
+
return index < prevIndex ? "left" : "right";
|
|
442
|
+
})), { initialValue: "right" });
|
|
443
|
+
if (isPlatformBrowser(this.#platformId) && typeof window !== "undefined" && typeof window.matchMedia === "function") {
|
|
444
|
+
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
445
|
+
const onPreferenceChange = (event) => this.#prefersReducedMotion.set(event.matches);
|
|
446
|
+
this.#prefersReducedMotion.set(mediaQuery.matches);
|
|
447
|
+
mediaQuery.addEventListener("change", onPreferenceChange);
|
|
448
|
+
this.#destroyRef.onDestroy(() => mediaQuery.removeEventListener("change", onPreferenceChange));
|
|
449
|
+
}
|
|
450
|
+
effect(() => {
|
|
451
|
+
this.#viewIndex();
|
|
452
|
+
untracked(() => {
|
|
453
|
+
if ((this.contentElementRef()?.nativeElement)?.contains(this.#document.activeElement)) this.#hostElementRef.nativeElement.focus({ preventScroll: true });
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
this.#destroyRef.onDestroy(() => {
|
|
457
|
+
this.#removeSwipeListeners();
|
|
458
|
+
this.#stopContinuousScroll();
|
|
459
|
+
this.#resetPagerScrollState();
|
|
460
|
+
this.#scroll$.complete();
|
|
461
|
+
this.#resizeObserver?.disconnect();
|
|
462
|
+
});
|
|
463
|
+
afterRenderEffect({ read: (onCleanup) => {
|
|
464
|
+
const pagerListElementRef = this.pagerListElementRef();
|
|
465
|
+
const pagerElementRef = this.pagerElementRef();
|
|
466
|
+
this.itemCount();
|
|
467
|
+
this.#resizeObserver?.disconnect();
|
|
468
|
+
this.#resizeObserver = null;
|
|
469
|
+
onCleanup(() => {
|
|
470
|
+
this.#resizeObserver?.disconnect();
|
|
471
|
+
this.#resizeObserver = null;
|
|
472
|
+
});
|
|
473
|
+
if (!pagerListElementRef || !pagerElementRef) {
|
|
474
|
+
this.pagerArrowVisible.set(false);
|
|
475
|
+
this.#resetPagerScrollState();
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const element = pagerListElementRef.nativeElement;
|
|
479
|
+
const pagerElement = pagerElementRef.nativeElement;
|
|
480
|
+
if (this.#pagerScrollContext && this.#pagerScrollContext.element !== element) this.#resetPagerScrollState();
|
|
481
|
+
this.#updatePagerArrowVisibility(element, pagerElement);
|
|
482
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
483
|
+
this.#resizeObserver = new ResizeObserver(() => {
|
|
484
|
+
this.#updatePagerArrowVisibility(element, pagerElement);
|
|
485
|
+
if (this.#pagerScrollContext && this.#pagerScrollContext.element === element) {
|
|
486
|
+
const currentMaxScroll = Math.max(0, element.scrollWidth - element.clientWidth);
|
|
487
|
+
if (this.#pagerScrollContext.maxScroll !== currentMaxScroll) this.#resetPagerScrollState();
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
this.#resizeObserver.observe(element);
|
|
491
|
+
this.#resizeObserver.observe(pagerElement);
|
|
492
|
+
}
|
|
493
|
+
} });
|
|
494
|
+
afterRenderEffect(() => {
|
|
495
|
+
const index = this.#viewIndex();
|
|
496
|
+
const list = this.pagerListElementRef()?.nativeElement;
|
|
497
|
+
this.itemCount();
|
|
498
|
+
untracked(() => {
|
|
499
|
+
if (!list) {
|
|
500
|
+
this.#pagerCentered = false;
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const firstRun = !this.#pagerCentered;
|
|
504
|
+
this.#pagerCentered = true;
|
|
505
|
+
if (!firstRun || index !== 0) this.#centerActivePage(list, firstRun ? "instant" : this.scrollBehavior());
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
afterRenderEffect(() => {
|
|
509
|
+
const previousHidden = this.previousArrowHidden();
|
|
510
|
+
const nextHidden = this.nextArrowHidden();
|
|
511
|
+
untracked(() => {
|
|
512
|
+
const previous = this.previousArrowRef()?.nativeElement;
|
|
513
|
+
const next = this.nextArrowRef()?.nativeElement;
|
|
514
|
+
const active = this.#document.activeElement;
|
|
515
|
+
if (active === previous && previousHidden) (nextHidden ? this.#hostElementRef.nativeElement : next)?.focus({ preventScroll: true });
|
|
516
|
+
else if (active === next && nextHidden) (previousHidden ? this.#hostElementRef.nativeElement : previous)?.focus({ preventScroll: true });
|
|
517
|
+
});
|
|
518
|
+
});
|
|
519
|
+
afterNextRender(() => {
|
|
520
|
+
const content = this.contentElementRef()?.nativeElement;
|
|
521
|
+
if (!content) return;
|
|
522
|
+
const measure = () => {
|
|
523
|
+
const { clientHeight: height, clientWidth: width } = content;
|
|
524
|
+
const current = this.slideSize();
|
|
525
|
+
if (current.height !== height || current.width !== width) this.slideSize.set({
|
|
526
|
+
height,
|
|
527
|
+
width
|
|
528
|
+
});
|
|
529
|
+
};
|
|
530
|
+
measure();
|
|
531
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
532
|
+
const observer = new ResizeObserver(measure);
|
|
533
|
+
observer.observe(content);
|
|
534
|
+
this.#destroyRef.onDestroy(() => observer.disconnect());
|
|
535
|
+
}
|
|
536
|
+
if (isDevMode() && this.itemCount() > 0 && !this.#hostElementRef.nativeElement.hasAttribute("aria-label") && !this.#hostElementRef.nativeElement.hasAttribute("aria-labelledby")) console.warn("mona-scroll-view: a carousel needs a name. Set aria-label or aria-labelledby.");
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
onArrowClick(direction) {
|
|
540
|
+
this.#navigate(direction);
|
|
541
|
+
}
|
|
542
|
+
onKeydown(event) {
|
|
543
|
+
const count = this.itemCount();
|
|
544
|
+
if (count === 0 || event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || this.contentElementRef()?.nativeElement.contains(event.target)) return;
|
|
545
|
+
const isRtl = this.isRtl();
|
|
546
|
+
switch (event.key) {
|
|
547
|
+
case "ArrowLeft":
|
|
548
|
+
this.#navigate(isRtl ? "right" : "left");
|
|
549
|
+
break;
|
|
550
|
+
case "ArrowRight":
|
|
551
|
+
this.#navigate(isRtl ? "left" : "right");
|
|
552
|
+
break;
|
|
553
|
+
case "Home":
|
|
554
|
+
this.index.set(0);
|
|
555
|
+
break;
|
|
556
|
+
case "End":
|
|
557
|
+
this.index.set(count - 1);
|
|
558
|
+
break;
|
|
559
|
+
default: return;
|
|
560
|
+
}
|
|
561
|
+
event.preventDefault();
|
|
562
|
+
}
|
|
563
|
+
onPageClick(index) {
|
|
564
|
+
this.index.set(index);
|
|
565
|
+
}
|
|
566
|
+
onPagerClick(event, element, direction) {
|
|
567
|
+
if (event.button !== 0) return;
|
|
568
|
+
if (!(event.detail === 0)) {
|
|
569
|
+
const pointerId = "pointerId" in event && typeof event.pointerId === "number" ? event.pointerId : null;
|
|
570
|
+
if (pointerId !== null && pointerId !== -1) {
|
|
571
|
+
if (this.#rejectedPagerPointers.has(pointerId)) {
|
|
572
|
+
this.#rejectedPagerPointers.delete(pointerId);
|
|
573
|
+
this.#cleanupDocumentPointerListenersIfNeeded();
|
|
574
|
+
return;
|
|
575
|
+
}
|
|
576
|
+
if (this.#suppressedPagerClickPointerIds.delete(pointerId)) return;
|
|
577
|
+
} else {
|
|
578
|
+
if (this.#rejectedPagerPointers.size === 1) {
|
|
579
|
+
const firstKey = this.#rejectedPagerPointers.keys().next().value;
|
|
580
|
+
if (firstKey !== void 0) {
|
|
581
|
+
this.#rejectedPagerPointers.delete(firstKey);
|
|
582
|
+
this.#cleanupDocumentPointerListenersIfNeeded();
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
if (this.#suppressedPagerClickPointerIds.size === 1) {
|
|
587
|
+
const firstId = this.#suppressedPagerClickPointerIds.values().next().value;
|
|
588
|
+
if (firstId !== void 0) {
|
|
589
|
+
this.#suppressedPagerClickPointerIds.delete(firstId);
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
this.#scrollPagerBy(element, direction);
|
|
596
|
+
}
|
|
597
|
+
onPagerPointerDown(event, element, direction) {
|
|
598
|
+
if (!event.isPrimary || event.button !== 0) return;
|
|
599
|
+
const currentTarget = event.currentTarget;
|
|
600
|
+
const target = event.target;
|
|
601
|
+
this.#releasePagerPointerCapture(currentTarget, event.pointerId);
|
|
602
|
+
if (target !== currentTarget) this.#releasePagerPointerCapture(target, event.pointerId);
|
|
603
|
+
const control = currentTarget ?? target;
|
|
604
|
+
if (this.#activePagerPointerId !== null) {
|
|
605
|
+
this.#rejectedPagerPointers.set(event.pointerId, {
|
|
606
|
+
control,
|
|
607
|
+
phase: "down"
|
|
608
|
+
});
|
|
609
|
+
this.#ensureDocumentPointerListeners();
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
this.#rejectedPagerPointers.delete(event.pointerId);
|
|
613
|
+
this.#suppressedPagerClickPointerIds.delete(event.pointerId);
|
|
614
|
+
this.#activePagerPointerId = event.pointerId;
|
|
615
|
+
this.#activePagerPointerControl = control;
|
|
616
|
+
this.#continuousTicked = false;
|
|
617
|
+
this.#ensureDocumentPointerListeners();
|
|
618
|
+
interval(60).pipe(takeUntil(this.#scroll$), takeUntilDestroyed(this.#destroyRef)).subscribe(() => {
|
|
619
|
+
this.#continuousTicked = true;
|
|
620
|
+
this.#scrollPagerBy(element, direction);
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
onSwipeStart(event) {
|
|
624
|
+
this.#removeSwipeListeners();
|
|
625
|
+
if (!event.isPrimary || event.pointerType === "mouse" || event.button !== 0 || this.itemCount() <= 1 || event.target.closest(SWIPE_EXEMPT_SELECTOR)) return;
|
|
626
|
+
this.#activeSwipe = {
|
|
627
|
+
pointerId: event.pointerId,
|
|
628
|
+
startX: event.clientX,
|
|
629
|
+
startY: event.clientY
|
|
630
|
+
};
|
|
631
|
+
this.#document.addEventListener("pointerup", this.#swipeEndHandler);
|
|
632
|
+
this.#document.addEventListener("pointercancel", this.#swipeCancelHandler);
|
|
633
|
+
}
|
|
634
|
+
#armPagerScrollCompletion(element) {
|
|
635
|
+
if (this.#pagerScrollCompletionCleanup) {
|
|
636
|
+
this.#pagerScrollCompletionCleanup();
|
|
637
|
+
this.#pagerScrollCompletionCleanup = null;
|
|
638
|
+
}
|
|
639
|
+
const onScrollEnd = () => {
|
|
640
|
+
this.#resetPagerScrollState();
|
|
641
|
+
};
|
|
642
|
+
if (isPlatformBrowser(this.#platformId) && typeof window !== "undefined" && "onscrollend" in element && typeof element.addEventListener === "function") {
|
|
643
|
+
element.addEventListener("scrollend", onScrollEnd, { once: true });
|
|
644
|
+
this.#pagerScrollCompletionCleanup = () => {
|
|
645
|
+
element.removeEventListener?.("scrollend", onScrollEnd);
|
|
646
|
+
};
|
|
647
|
+
} else {
|
|
648
|
+
let inactivityTimeoutId = null;
|
|
649
|
+
const scheduleInactivityTimeout = () => {
|
|
650
|
+
if (inactivityTimeoutId !== null && typeof window !== "undefined") window.clearTimeout(inactivityTimeoutId);
|
|
651
|
+
if (isPlatformBrowser(this.#platformId) && typeof window !== "undefined") inactivityTimeoutId = window.setTimeout(onScrollEnd, 150);
|
|
652
|
+
};
|
|
653
|
+
const onScroll = () => {
|
|
654
|
+
scheduleInactivityTimeout();
|
|
655
|
+
};
|
|
656
|
+
if (typeof element.addEventListener === "function") element.addEventListener("scroll", onScroll, { passive: true });
|
|
657
|
+
scheduleInactivityTimeout();
|
|
658
|
+
this.#pagerScrollCompletionCleanup = () => {
|
|
659
|
+
if (typeof element.removeEventListener === "function") element.removeEventListener("scroll", onScroll);
|
|
660
|
+
if (inactivityTimeoutId !== null && typeof window !== "undefined") window.clearTimeout(inactivityTimeoutId);
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
#centerActivePage(list, behavior) {
|
|
665
|
+
this.#resetPagerScrollState();
|
|
666
|
+
const active = list.querySelector("button[data-active-page='true']");
|
|
667
|
+
if (!active || typeof list.scrollTo !== "function") return;
|
|
668
|
+
const listRect = list.getBoundingClientRect();
|
|
669
|
+
const activeRect = active.getBoundingClientRect();
|
|
670
|
+
const offset = activeRect.left + activeRect.width / 2 - (listRect.left + listRect.width / 2);
|
|
671
|
+
list.scrollTo({
|
|
672
|
+
behavior,
|
|
673
|
+
left: list.scrollLeft + offset
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
#cleanupDocumentPointerListenersIfNeeded() {
|
|
677
|
+
let hasDownRejected = false;
|
|
678
|
+
for (const p of this.#rejectedPagerPointers.values()) if (p.phase === "down") {
|
|
679
|
+
hasDownRejected = true;
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
if (this.#activePagerPointerId === null && !hasDownRejected) {
|
|
683
|
+
this.#document.removeEventListener("pointerup", this.#pointerUpHandler);
|
|
684
|
+
this.#document.removeEventListener("pointercancel", this.#pointerCancelHandler);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
#endSwipe(event, completed) {
|
|
688
|
+
const swipe = this.#activeSwipe;
|
|
689
|
+
if (swipe?.pointerId !== event.pointerId) return;
|
|
690
|
+
this.#removeSwipeListeners();
|
|
691
|
+
if (!completed) return;
|
|
692
|
+
const deltaX = event.clientX - swipe.startX;
|
|
693
|
+
const deltaY = event.clientY - swipe.startY;
|
|
694
|
+
if (Math.abs(deltaX) < SWIPE_DISTANCE || Math.abs(deltaX) <= Math.abs(deltaY)) return;
|
|
695
|
+
const towardsNext = this.isRtl() ? deltaX > 0 : deltaX < 0;
|
|
696
|
+
this.#navigate(towardsNext ? "right" : "left");
|
|
697
|
+
}
|
|
698
|
+
#ensureDocumentPointerListeners() {
|
|
699
|
+
this.#document.addEventListener("pointerup", this.#pointerUpHandler);
|
|
700
|
+
this.#document.addEventListener("pointercancel", this.#pointerCancelHandler);
|
|
701
|
+
}
|
|
702
|
+
#handlePointerEnd(event, isUp) {
|
|
703
|
+
if (event.pointerId !== this.#activePagerPointerId) {
|
|
704
|
+
const rejected = this.#rejectedPagerPointers.get(event.pointerId);
|
|
705
|
+
if (rejected) {
|
|
706
|
+
if (!isUp) this.#rejectedPagerPointers.delete(event.pointerId);
|
|
707
|
+
else if (this.#isPointerReleaseWithinControl(event, rejected.control ?? null)) rejected.phase = "awaiting-click";
|
|
708
|
+
else this.#rejectedPagerPointers.delete(event.pointerId);
|
|
709
|
+
}
|
|
710
|
+
this.#cleanupDocumentPointerListenersIfNeeded();
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
this.#scroll$.next();
|
|
714
|
+
if (isUp && this.#continuousTicked && this.#isPointerReleaseWithinControl(event, this.#activePagerPointerControl)) this.#suppressedPagerClickPointerIds.add(event.pointerId);
|
|
715
|
+
else this.#suppressedPagerClickPointerIds.delete(event.pointerId);
|
|
716
|
+
this.#continuousTicked = false;
|
|
717
|
+
this.#activePagerPointerId = null;
|
|
718
|
+
this.#activePagerPointerControl = null;
|
|
719
|
+
this.#cleanupDocumentPointerListenersIfNeeded();
|
|
720
|
+
}
|
|
721
|
+
#isPointerReleaseWithinControl(event, control) {
|
|
722
|
+
if (control == null) return true;
|
|
723
|
+
const targetNode = event.target;
|
|
724
|
+
return targetNode != null && control.contains(targetNode) || typeof event.composedPath === "function" && event.composedPath().includes(control);
|
|
725
|
+
}
|
|
726
|
+
#navigate(direction) {
|
|
727
|
+
const count = this.itemCount();
|
|
728
|
+
if (count === 0) return;
|
|
729
|
+
const current = this.#viewIndex();
|
|
730
|
+
const step = direction === "left" ? -1 : 1;
|
|
731
|
+
const next = this.infinite() ? (current + step + count) % count : Math.max(0, Math.min(count - 1, current + step));
|
|
732
|
+
if (next !== current) {
|
|
733
|
+
this.#navigationIntent = direction;
|
|
734
|
+
this.index.set(next);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
#releasePagerPointerCapture(control, pointerId) {
|
|
738
|
+
if (control == null || typeof control.hasPointerCapture !== "function" || typeof control.releasePointerCapture !== "function") return;
|
|
739
|
+
try {
|
|
740
|
+
if (control.hasPointerCapture(pointerId)) control.releasePointerCapture(pointerId);
|
|
741
|
+
} catch {}
|
|
742
|
+
}
|
|
743
|
+
#removeSwipeListeners() {
|
|
744
|
+
this.#activeSwipe = null;
|
|
745
|
+
this.#document.removeEventListener("pointerup", this.#swipeEndHandler);
|
|
746
|
+
this.#document.removeEventListener("pointercancel", this.#swipeCancelHandler);
|
|
747
|
+
}
|
|
748
|
+
#resetPagerScrollState() {
|
|
749
|
+
if (this.#pagerScrollCompletionCleanup) {
|
|
750
|
+
this.#pagerScrollCompletionCleanup();
|
|
751
|
+
this.#pagerScrollCompletionCleanup = null;
|
|
752
|
+
}
|
|
753
|
+
this.#pagerScrollContext = null;
|
|
754
|
+
}
|
|
755
|
+
#scrollPagerBy(element, direction) {
|
|
756
|
+
const currentDirection = this.isRtl() ? "rtl" : "ltr";
|
|
757
|
+
const maxScroll = Math.max(0, (element.scrollWidth ?? 0) - (element.clientWidth ?? 0));
|
|
758
|
+
const sameContext = this.#pagerScrollContext?.element === element && this.#pagerScrollContext.direction === currentDirection && this.#pagerScrollContext.maxScroll === maxScroll;
|
|
759
|
+
const currentScrollLeft = element.scrollLeft ?? 0;
|
|
760
|
+
const base = sameContext ? this.#pagerScrollContext.target : currentScrollLeft;
|
|
761
|
+
let offset = direction === "left" ? -100 : 100;
|
|
762
|
+
if (currentDirection === "rtl") offset = -offset;
|
|
763
|
+
const target = base + offset;
|
|
764
|
+
const clampedTarget = currentDirection === "ltr" ? Math.max(0, Math.min(maxScroll, target)) : Math.max(-maxScroll, Math.min(0, target));
|
|
765
|
+
if (!sameContext && clampedTarget === currentScrollLeft) {
|
|
766
|
+
this.#resetPagerScrollState();
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
if (sameContext && clampedTarget === this.#pagerScrollContext.target) return;
|
|
770
|
+
this.#pagerScrollContext = {
|
|
771
|
+
direction: currentDirection,
|
|
772
|
+
element,
|
|
773
|
+
maxScroll,
|
|
774
|
+
target: clampedTarget
|
|
775
|
+
};
|
|
776
|
+
if (typeof element.scrollTo === "function") element.scrollTo({
|
|
777
|
+
behavior: this.scrollBehavior(),
|
|
778
|
+
left: clampedTarget
|
|
779
|
+
});
|
|
780
|
+
else if (typeof element.scrollBy === "function") element.scrollBy({
|
|
781
|
+
behavior: this.scrollBehavior(),
|
|
782
|
+
left: offset
|
|
783
|
+
});
|
|
784
|
+
this.#armPagerScrollCompletion(element);
|
|
785
|
+
}
|
|
786
|
+
#stopContinuousScroll() {
|
|
787
|
+
this.#document.removeEventListener("pointerup", this.#pointerUpHandler);
|
|
788
|
+
this.#document.removeEventListener("pointercancel", this.#pointerCancelHandler);
|
|
789
|
+
this.#scroll$.next();
|
|
790
|
+
this.#continuousTicked = false;
|
|
791
|
+
this.#activePagerPointerId = null;
|
|
792
|
+
this.#activePagerPointerControl = null;
|
|
793
|
+
this.#suppressedPagerClickPointerIds.clear();
|
|
794
|
+
this.#rejectedPagerPointers.clear();
|
|
795
|
+
}
|
|
796
|
+
#updatePagerArrowVisibility(list, pager) {
|
|
797
|
+
const requiredWidth = list.scrollWidth;
|
|
798
|
+
const arrowFreeAvailableWidth = pager.clientWidth;
|
|
799
|
+
this.pagerArrowVisible.set(requiredWidth > arrowFreeAvailableWidth);
|
|
800
|
+
}
|
|
801
|
+
static {
|
|
802
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
803
|
+
minVersion: "12.0.0",
|
|
804
|
+
version: "22.2.6",
|
|
805
|
+
ngImport: i0,
|
|
806
|
+
type: ScrollViewComponent,
|
|
807
|
+
deps: [],
|
|
808
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
static {
|
|
812
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
813
|
+
minVersion: "17.0.0",
|
|
814
|
+
version: "22.2.6",
|
|
815
|
+
type: ScrollViewComponent,
|
|
816
|
+
isStandalone: true,
|
|
817
|
+
selector: "mona-scroll-view",
|
|
818
|
+
inputs: {
|
|
819
|
+
animate: {
|
|
820
|
+
classPropertyName: "animate",
|
|
821
|
+
publicName: "animate",
|
|
822
|
+
isSignal: true,
|
|
823
|
+
isRequired: false,
|
|
824
|
+
transformFunction: null
|
|
825
|
+
},
|
|
826
|
+
ariaLabel: {
|
|
827
|
+
classPropertyName: "ariaLabel",
|
|
828
|
+
publicName: "aria-label",
|
|
829
|
+
isSignal: true,
|
|
830
|
+
isRequired: false,
|
|
831
|
+
transformFunction: null
|
|
832
|
+
},
|
|
833
|
+
ariaLabelledBy: {
|
|
834
|
+
classPropertyName: "ariaLabelledBy",
|
|
835
|
+
publicName: "aria-labelledby",
|
|
836
|
+
isSignal: true,
|
|
837
|
+
isRequired: false,
|
|
838
|
+
transformFunction: null
|
|
839
|
+
},
|
|
840
|
+
arrows: {
|
|
841
|
+
classPropertyName: "arrows",
|
|
842
|
+
publicName: "arrows",
|
|
843
|
+
isSignal: true,
|
|
844
|
+
isRequired: false,
|
|
845
|
+
transformFunction: null
|
|
846
|
+
},
|
|
847
|
+
data: {
|
|
848
|
+
classPropertyName: "data",
|
|
849
|
+
publicName: "data",
|
|
850
|
+
isSignal: true,
|
|
851
|
+
isRequired: false,
|
|
852
|
+
transformFunction: null
|
|
853
|
+
},
|
|
854
|
+
height: {
|
|
855
|
+
classPropertyName: "height",
|
|
856
|
+
publicName: "height",
|
|
857
|
+
isSignal: true,
|
|
858
|
+
isRequired: true,
|
|
859
|
+
transformFunction: null
|
|
860
|
+
},
|
|
861
|
+
index: {
|
|
862
|
+
classPropertyName: "index",
|
|
863
|
+
publicName: "index",
|
|
864
|
+
isSignal: true,
|
|
865
|
+
isRequired: false,
|
|
866
|
+
transformFunction: null
|
|
867
|
+
},
|
|
868
|
+
infinite: {
|
|
869
|
+
classPropertyName: "infinite",
|
|
870
|
+
publicName: "infinite",
|
|
871
|
+
isSignal: true,
|
|
872
|
+
isRequired: false,
|
|
873
|
+
transformFunction: null
|
|
874
|
+
},
|
|
875
|
+
pageable: {
|
|
876
|
+
classPropertyName: "pageable",
|
|
877
|
+
publicName: "pageable",
|
|
878
|
+
isSignal: true,
|
|
879
|
+
isRequired: false,
|
|
880
|
+
transformFunction: null
|
|
881
|
+
},
|
|
882
|
+
pagerBlur: {
|
|
883
|
+
classPropertyName: "pagerBlur",
|
|
884
|
+
publicName: "pagerBlur",
|
|
885
|
+
isSignal: true,
|
|
886
|
+
isRequired: false,
|
|
887
|
+
transformFunction: null
|
|
888
|
+
},
|
|
889
|
+
pagerOverlay: {
|
|
890
|
+
classPropertyName: "pagerOverlay",
|
|
891
|
+
publicName: "pagerOverlay",
|
|
892
|
+
isSignal: true,
|
|
893
|
+
isRequired: false,
|
|
894
|
+
transformFunction: null
|
|
895
|
+
},
|
|
896
|
+
pagerRounded: {
|
|
897
|
+
classPropertyName: "pagerRounded",
|
|
898
|
+
publicName: "pagerRounded",
|
|
899
|
+
isSignal: true,
|
|
900
|
+
isRequired: false,
|
|
901
|
+
transformFunction: null
|
|
902
|
+
},
|
|
903
|
+
rounded: {
|
|
904
|
+
classPropertyName: "rounded",
|
|
905
|
+
publicName: "rounded",
|
|
906
|
+
isSignal: true,
|
|
907
|
+
isRequired: false,
|
|
908
|
+
transformFunction: null
|
|
909
|
+
},
|
|
910
|
+
userClass: {
|
|
911
|
+
classPropertyName: "userClass",
|
|
912
|
+
publicName: "class",
|
|
913
|
+
isSignal: true,
|
|
914
|
+
isRequired: false,
|
|
915
|
+
transformFunction: null
|
|
916
|
+
},
|
|
917
|
+
width: {
|
|
918
|
+
classPropertyName: "width",
|
|
919
|
+
publicName: "width",
|
|
920
|
+
isSignal: true,
|
|
921
|
+
isRequired: true,
|
|
922
|
+
transformFunction: null
|
|
923
|
+
}
|
|
924
|
+
},
|
|
925
|
+
outputs: { index: "indexChange" },
|
|
926
|
+
host: {
|
|
927
|
+
listeners: { "keydown": "onKeydown($event)" },
|
|
928
|
+
properties: {
|
|
929
|
+
"class": "baseClass()",
|
|
930
|
+
"attr.tabindex": "itemCount() > 0 ? 0 : null",
|
|
931
|
+
"style.height": "scrollViewHeight()",
|
|
932
|
+
"style.width": "scrollViewWidth()",
|
|
933
|
+
"attr.role": "hostRole()",
|
|
934
|
+
"attr.aria-roledescription": "itemCount() > 0 ? messages().carousel : null",
|
|
935
|
+
"attr.aria-label": "ariaLabel() || null",
|
|
936
|
+
"attr.aria-labelledby": "ariaLabelledBy() || null"
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
queries: [{
|
|
940
|
+
propertyName: "bareTemplate",
|
|
941
|
+
first: true,
|
|
942
|
+
predicate: TemplateRef,
|
|
943
|
+
descendants: true,
|
|
944
|
+
isSignal: true
|
|
945
|
+
}, {
|
|
946
|
+
propertyName: "slideDirective",
|
|
947
|
+
first: true,
|
|
948
|
+
predicate: ScrollViewSlideDirective,
|
|
949
|
+
descendants: true,
|
|
950
|
+
isSignal: true
|
|
951
|
+
}],
|
|
952
|
+
viewQueries: [
|
|
953
|
+
{
|
|
954
|
+
propertyName: "contentElementRef",
|
|
955
|
+
first: true,
|
|
956
|
+
predicate: ["contentElement"],
|
|
957
|
+
descendants: true,
|
|
958
|
+
isSignal: true
|
|
959
|
+
},
|
|
960
|
+
{
|
|
961
|
+
propertyName: "nextArrowRef",
|
|
962
|
+
first: true,
|
|
963
|
+
predicate: ["nextArrow"],
|
|
964
|
+
descendants: true,
|
|
965
|
+
isSignal: true
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
propertyName: "pagerElementRef",
|
|
969
|
+
first: true,
|
|
970
|
+
predicate: ["pagerElement"],
|
|
971
|
+
descendants: true,
|
|
972
|
+
isSignal: true
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
propertyName: "pagerListElementRef",
|
|
976
|
+
first: true,
|
|
977
|
+
predicate: ["pagerListElement"],
|
|
978
|
+
descendants: true,
|
|
979
|
+
isSignal: true
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
propertyName: "previousArrowRef",
|
|
983
|
+
first: true,
|
|
984
|
+
predicate: ["previousArrow"],
|
|
985
|
+
descendants: true,
|
|
986
|
+
isSignal: true
|
|
987
|
+
}
|
|
988
|
+
],
|
|
989
|
+
ngImport: i0,
|
|
990
|
+
template: "<div\n [class]=\"contentClass()\"\n aria-live=\"polite\"\n aria-atomic=\"false\"\n data-scroll-view-content=\"true\"\n (pointerdown)=\"onSwipeStart($event)\"\n #contentElement>\n @for (item of viewData(); track $index) {\n @if ($index === viewIndex()) {\n <div\n role=\"group\"\n data-scroll-view-slide=\"true\"\n [class]=\"slideClass()\"\n [attr.aria-roledescription]=\"messages().slide\"\n [attr.aria-label]=\"messages().pageOf($index + 1, itemCount())\"\n [animate.enter]=\"enterAnimation()\"\n [animate.leave]=\"leaveAnimation()\"\n [style.--mona-scroll-view-animation-duration]=\"animationDuration() + 'ms'\">\n <ng-container\n [ngTemplateOutlet]=\"contentTemplate()\"\n [ngTemplateOutletContext]=\"{\n $implicit: item.data,\n width: slideSize().width,\n height: slideSize().height\n }\"></ng-container>\n </div>\n }\n }\n</div>\n<button\n #previousArrow\n type=\"button\"\n [class]=\"leftArrowClass()\"\n (click)=\"onArrowClick('left')\"\n [attr.data-navigate-prev]=\"true\"\n [attr.aria-label]=\"messages().previousPage\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"48\"\n height=\"48\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-left-icon lucide-chevron-left rtl:rotate-180\">\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n</button>\n<button\n #nextArrow\n type=\"button\"\n [class]=\"rightArrowClass()\"\n (click)=\"onArrowClick('right')\"\n [attr.data-navigate-next]=\"true\"\n [attr.aria-label]=\"messages().nextPage\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"48\"\n height=\"48\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-right-icon lucide-chevron-right rtl:rotate-180\">\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n</button>\n\n@if (pageable()) {\n <div\n #pagerElement\n data-pager-root=\"true\"\n [class]=\"pagerClass()\"\n [style.direction]=\"isRtl() ? 'rtl' : 'ltr'\"\n [style.backdrop-filter]=\"pagerOverlay() === 'none' ? null : 'blur(' + pagerBlur() + 'px)'\">\n @if (pagerArrowVisible()) {\n <button\n type=\"button\"\n [class]=\"pagerArrowClass()\"\n [attr.aria-label]=\"messages().scrollPagerPrevious\"\n (pointerdown)=\"onPagerPointerDown($event, pagerListElement, 'left')\"\n (click)=\"onPagerClick($event, pagerListElement, 'left')\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-left-icon lucide-chevron-left rtl:rotate-180\">\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n }\n <div [class]=\"pagerListContainerClass()\">\n <ul [class]=\"pagerListClass()\" [attr.aria-label]=\"messages().pages\" #pagerListElement>\n @for (_ of viewData(); track $index) {\n <li [attr.data-page-index]=\"$index\" [attr.data-page-item]=\"true\">\n <button\n type=\"button\"\n monaScrollViewActivePage\n [active]=\"$index === viewIndex()\"\n [rounded]=\"pagerRounded()\"\n [attr.data-active-page]=\"$index === viewIndex()\"\n [attr.aria-current]=\"$index === viewIndex() ? true : null\"\n [attr.aria-label]=\"messages().page($index + 1)\"\n (click)=\"onPageClick($index)\"></button>\n </li>\n }\n </ul>\n </div>\n @if (pagerArrowVisible()) {\n <button\n type=\"button\"\n [class]=\"pagerArrowClass()\"\n [attr.aria-label]=\"messages().scrollPagerNext\"\n (pointerdown)=\"onPagerPointerDown($event, pagerListElement, 'right')\"\n (click)=\"onPagerClick($event, pagerListElement, 'right')\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-right-icon lucide-chevron-right rtl:rotate-180\">\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n }\n </div>\n}\n",
|
|
991
|
+
styles: ["@keyframes slideInFromRight{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes slideOutToLeft{0%{transform:translate(0)}to{transform:translate(-100%)}}@keyframes slideInFromLeft{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes slideOutToRight{0%{transform:translate(0)}to{transform:translate(100%)}}.slide-in-from-right,.slide-out-to-left,.slide-in-from-left,.slide-out-to-right{animation-duration:var(--mona-scroll-view-animation-duration, .5s);animation-timing-function:ease-out;animation-fill-mode:both}.slide-in-from-right{animation-name:slideInFromRight}.slide-out-to-left{animation-name:slideOutToLeft}.slide-in-from-left{animation-name:slideInFromLeft}.slide-out-to-right{animation-name:slideOutToRight}@media(prefers-reduced-motion:reduce){.slide-in-from-right,.slide-out-to-left,.slide-in-from-left,.slide-out-to-right{animation-duration:min(var(--mona-scroll-view-animation-duration, .5s),1ms)}}\n"],
|
|
992
|
+
dependencies: [{
|
|
993
|
+
kind: "directive",
|
|
994
|
+
type: NgTemplateOutlet,
|
|
995
|
+
selector: "[ngTemplateOutlet]",
|
|
996
|
+
inputs: [
|
|
997
|
+
"ngTemplateOutletContext",
|
|
998
|
+
"ngTemplateOutlet",
|
|
999
|
+
"ngTemplateOutletInjector"
|
|
1000
|
+
]
|
|
1001
|
+
}, {
|
|
1002
|
+
kind: "directive",
|
|
1003
|
+
type: ScrollViewActivePageDirective,
|
|
1004
|
+
selector: "button[monaScrollViewActivePage]",
|
|
1005
|
+
inputs: ["active", "rounded"]
|
|
1006
|
+
}]
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1011
|
+
minVersion: "12.0.0",
|
|
1012
|
+
version: "22.2.6",
|
|
1013
|
+
ngImport: i0,
|
|
1014
|
+
type: ScrollViewComponent,
|
|
1015
|
+
decorators: [{
|
|
1016
|
+
type: Component,
|
|
1017
|
+
args: [{
|
|
1018
|
+
selector: "mona-scroll-view",
|
|
1019
|
+
imports: [NgTemplateOutlet, ScrollViewActivePageDirective],
|
|
1020
|
+
host: {
|
|
1021
|
+
"[class]": "baseClass()",
|
|
1022
|
+
"[attr.tabindex]": "itemCount() > 0 ? 0 : null",
|
|
1023
|
+
"[style.height]": "scrollViewHeight()",
|
|
1024
|
+
"[style.width]": "scrollViewWidth()",
|
|
1025
|
+
"[attr.role]": "hostRole()",
|
|
1026
|
+
"[attr.aria-roledescription]": "itemCount() > 0 ? messages().carousel : null",
|
|
1027
|
+
"[attr.aria-label]": "ariaLabel() || null",
|
|
1028
|
+
"[attr.aria-labelledby]": "ariaLabelledBy() || null",
|
|
1029
|
+
"(keydown)": "onKeydown($event)"
|
|
1030
|
+
},
|
|
1031
|
+
template: "<div\n [class]=\"contentClass()\"\n aria-live=\"polite\"\n aria-atomic=\"false\"\n data-scroll-view-content=\"true\"\n (pointerdown)=\"onSwipeStart($event)\"\n #contentElement>\n @for (item of viewData(); track $index) {\n @if ($index === viewIndex()) {\n <div\n role=\"group\"\n data-scroll-view-slide=\"true\"\n [class]=\"slideClass()\"\n [attr.aria-roledescription]=\"messages().slide\"\n [attr.aria-label]=\"messages().pageOf($index + 1, itemCount())\"\n [animate.enter]=\"enterAnimation()\"\n [animate.leave]=\"leaveAnimation()\"\n [style.--mona-scroll-view-animation-duration]=\"animationDuration() + 'ms'\">\n <ng-container\n [ngTemplateOutlet]=\"contentTemplate()\"\n [ngTemplateOutletContext]=\"{\n $implicit: item.data,\n width: slideSize().width,\n height: slideSize().height\n }\"></ng-container>\n </div>\n }\n }\n</div>\n<button\n #previousArrow\n type=\"button\"\n [class]=\"leftArrowClass()\"\n (click)=\"onArrowClick('left')\"\n [attr.data-navigate-prev]=\"true\"\n [attr.aria-label]=\"messages().previousPage\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"48\"\n height=\"48\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-left-icon lucide-chevron-left rtl:rotate-180\">\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n</button>\n<button\n #nextArrow\n type=\"button\"\n [class]=\"rightArrowClass()\"\n (click)=\"onArrowClick('right')\"\n [attr.data-navigate-next]=\"true\"\n [attr.aria-label]=\"messages().nextPage\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"48\"\n height=\"48\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-right-icon lucide-chevron-right rtl:rotate-180\">\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n</button>\n\n@if (pageable()) {\n <div\n #pagerElement\n data-pager-root=\"true\"\n [class]=\"pagerClass()\"\n [style.direction]=\"isRtl() ? 'rtl' : 'ltr'\"\n [style.backdrop-filter]=\"pagerOverlay() === 'none' ? null : 'blur(' + pagerBlur() + 'px)'\">\n @if (pagerArrowVisible()) {\n <button\n type=\"button\"\n [class]=\"pagerArrowClass()\"\n [attr.aria-label]=\"messages().scrollPagerPrevious\"\n (pointerdown)=\"onPagerPointerDown($event, pagerListElement, 'left')\"\n (click)=\"onPagerClick($event, pagerListElement, 'left')\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-left-icon lucide-chevron-left rtl:rotate-180\">\n <path d=\"m15 18-6-6 6-6\" />\n </svg>\n </button>\n }\n <div [class]=\"pagerListContainerClass()\">\n <ul [class]=\"pagerListClass()\" [attr.aria-label]=\"messages().pages\" #pagerListElement>\n @for (_ of viewData(); track $index) {\n <li [attr.data-page-index]=\"$index\" [attr.data-page-item]=\"true\">\n <button\n type=\"button\"\n monaScrollViewActivePage\n [active]=\"$index === viewIndex()\"\n [rounded]=\"pagerRounded()\"\n [attr.data-active-page]=\"$index === viewIndex()\"\n [attr.aria-current]=\"$index === viewIndex() ? true : null\"\n [attr.aria-label]=\"messages().page($index + 1)\"\n (click)=\"onPageClick($index)\"></button>\n </li>\n }\n </ul>\n </div>\n @if (pagerArrowVisible()) {\n <button\n type=\"button\"\n [class]=\"pagerArrowClass()\"\n [attr.aria-label]=\"messages().scrollPagerNext\"\n (pointerdown)=\"onPagerPointerDown($event, pagerListElement, 'right')\"\n (click)=\"onPagerClick($event, pagerListElement, 'right')\">\n <svg\n aria-hidden=\"true\"\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-chevron-right-icon lucide-chevron-right rtl:rotate-180\">\n <path d=\"m9 18 6-6-6-6\" />\n </svg>\n </button>\n }\n </div>\n}\n",
|
|
1032
|
+
styles: ["@keyframes slideInFromRight{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes slideOutToLeft{0%{transform:translate(0)}to{transform:translate(-100%)}}@keyframes slideInFromLeft{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes slideOutToRight{0%{transform:translate(0)}to{transform:translate(100%)}}.slide-in-from-right,.slide-out-to-left,.slide-in-from-left,.slide-out-to-right{animation-duration:var(--mona-scroll-view-animation-duration, .5s);animation-timing-function:ease-out;animation-fill-mode:both}.slide-in-from-right{animation-name:slideInFromRight}.slide-out-to-left{animation-name:slideOutToLeft}.slide-in-from-left{animation-name:slideInFromLeft}.slide-out-to-right{animation-name:slideOutToRight}@media(prefers-reduced-motion:reduce){.slide-in-from-right,.slide-out-to-left,.slide-in-from-left,.slide-out-to-right{animation-duration:min(var(--mona-scroll-view-animation-duration, .5s),1ms)}}\n"]
|
|
1033
|
+
}]
|
|
1034
|
+
}],
|
|
1035
|
+
ctorParameters: () => [],
|
|
1036
|
+
propDecorators: {
|
|
1037
|
+
bareTemplate: [{
|
|
1038
|
+
type: i0.ContentChild,
|
|
1039
|
+
args: [i0.forwardRef(() => TemplateRef), { isSignal: true }]
|
|
1040
|
+
}],
|
|
1041
|
+
contentElementRef: [{
|
|
1042
|
+
type: i0.ViewChild,
|
|
1043
|
+
args: ["contentElement", { isSignal: true }]
|
|
1044
|
+
}],
|
|
1045
|
+
nextArrowRef: [{
|
|
1046
|
+
type: i0.ViewChild,
|
|
1047
|
+
args: ["nextArrow", { isSignal: true }]
|
|
1048
|
+
}],
|
|
1049
|
+
pagerElementRef: [{
|
|
1050
|
+
type: i0.ViewChild,
|
|
1051
|
+
args: ["pagerElement", { isSignal: true }]
|
|
1052
|
+
}],
|
|
1053
|
+
pagerListElementRef: [{
|
|
1054
|
+
type: i0.ViewChild,
|
|
1055
|
+
args: ["pagerListElement", { isSignal: true }]
|
|
1056
|
+
}],
|
|
1057
|
+
previousArrowRef: [{
|
|
1058
|
+
type: i0.ViewChild,
|
|
1059
|
+
args: ["previousArrow", { isSignal: true }]
|
|
1060
|
+
}],
|
|
1061
|
+
slideDirective: [{
|
|
1062
|
+
type: i0.ContentChild,
|
|
1063
|
+
args: [i0.forwardRef(() => ScrollViewSlideDirective), { isSignal: true }]
|
|
1064
|
+
}],
|
|
1065
|
+
animate: [{
|
|
1066
|
+
type: i0.Input,
|
|
1067
|
+
args: [{
|
|
1068
|
+
isSignal: true,
|
|
1069
|
+
alias: "animate",
|
|
1070
|
+
required: false
|
|
1071
|
+
}]
|
|
1072
|
+
}],
|
|
1073
|
+
ariaLabel: [{
|
|
1074
|
+
type: i0.Input,
|
|
1075
|
+
args: [{
|
|
1076
|
+
isSignal: true,
|
|
1077
|
+
alias: "aria-label",
|
|
1078
|
+
required: false
|
|
1079
|
+
}]
|
|
1080
|
+
}],
|
|
1081
|
+
ariaLabelledBy: [{
|
|
1082
|
+
type: i0.Input,
|
|
1083
|
+
args: [{
|
|
1084
|
+
isSignal: true,
|
|
1085
|
+
alias: "aria-labelledby",
|
|
1086
|
+
required: false
|
|
1087
|
+
}]
|
|
1088
|
+
}],
|
|
1089
|
+
arrows: [{
|
|
1090
|
+
type: i0.Input,
|
|
1091
|
+
args: [{
|
|
1092
|
+
isSignal: true,
|
|
1093
|
+
alias: "arrows",
|
|
1094
|
+
required: false
|
|
1095
|
+
}]
|
|
1096
|
+
}],
|
|
1097
|
+
data: [{
|
|
1098
|
+
type: i0.Input,
|
|
1099
|
+
args: [{
|
|
1100
|
+
isSignal: true,
|
|
1101
|
+
alias: "data",
|
|
1102
|
+
required: false
|
|
1103
|
+
}]
|
|
1104
|
+
}],
|
|
1105
|
+
height: [{
|
|
1106
|
+
type: i0.Input,
|
|
1107
|
+
args: [{
|
|
1108
|
+
isSignal: true,
|
|
1109
|
+
alias: "height",
|
|
1110
|
+
required: true
|
|
1111
|
+
}]
|
|
1112
|
+
}],
|
|
1113
|
+
index: [{
|
|
1114
|
+
type: i0.Input,
|
|
1115
|
+
args: [{
|
|
1116
|
+
isSignal: true,
|
|
1117
|
+
alias: "index",
|
|
1118
|
+
required: false
|
|
1119
|
+
}]
|
|
1120
|
+
}, {
|
|
1121
|
+
type: i0.Output,
|
|
1122
|
+
args: ["indexChange"]
|
|
1123
|
+
}],
|
|
1124
|
+
infinite: [{
|
|
1125
|
+
type: i0.Input,
|
|
1126
|
+
args: [{
|
|
1127
|
+
isSignal: true,
|
|
1128
|
+
alias: "infinite",
|
|
1129
|
+
required: false
|
|
1130
|
+
}]
|
|
1131
|
+
}],
|
|
1132
|
+
pageable: [{
|
|
1133
|
+
type: i0.Input,
|
|
1134
|
+
args: [{
|
|
1135
|
+
isSignal: true,
|
|
1136
|
+
alias: "pageable",
|
|
1137
|
+
required: false
|
|
1138
|
+
}]
|
|
1139
|
+
}],
|
|
1140
|
+
pagerBlur: [{
|
|
1141
|
+
type: i0.Input,
|
|
1142
|
+
args: [{
|
|
1143
|
+
isSignal: true,
|
|
1144
|
+
alias: "pagerBlur",
|
|
1145
|
+
required: false
|
|
1146
|
+
}]
|
|
1147
|
+
}],
|
|
1148
|
+
pagerOverlay: [{
|
|
1149
|
+
type: i0.Input,
|
|
1150
|
+
args: [{
|
|
1151
|
+
isSignal: true,
|
|
1152
|
+
alias: "pagerOverlay",
|
|
1153
|
+
required: false
|
|
1154
|
+
}]
|
|
1155
|
+
}],
|
|
1156
|
+
pagerRounded: [{
|
|
1157
|
+
type: i0.Input,
|
|
1158
|
+
args: [{
|
|
1159
|
+
isSignal: true,
|
|
1160
|
+
alias: "pagerRounded",
|
|
1161
|
+
required: false
|
|
1162
|
+
}]
|
|
1163
|
+
}],
|
|
1164
|
+
rounded: [{
|
|
1165
|
+
type: i0.Input,
|
|
1166
|
+
args: [{
|
|
1167
|
+
isSignal: true,
|
|
1168
|
+
alias: "rounded",
|
|
1169
|
+
required: false
|
|
1170
|
+
}]
|
|
1171
|
+
}],
|
|
1172
|
+
userClass: [{
|
|
1173
|
+
type: i0.Input,
|
|
1174
|
+
args: [{
|
|
1175
|
+
isSignal: true,
|
|
1176
|
+
alias: "class",
|
|
1177
|
+
required: false
|
|
1178
|
+
}]
|
|
1179
|
+
}],
|
|
1180
|
+
width: [{
|
|
1181
|
+
type: i0.Input,
|
|
1182
|
+
args: [{
|
|
1183
|
+
isSignal: true,
|
|
1184
|
+
alias: "width",
|
|
1185
|
+
required: true
|
|
1186
|
+
}]
|
|
1187
|
+
}]
|
|
1188
|
+
}
|
|
1189
|
+
});
|
|
978
1190
|
export { SCROLL_VIEW_DEFAULT_MESSAGES, ScrollViewComponent, ScrollViewSlideDirective };
|
|
979
|
-
|
|
1191
|
+
|
|
1192
|
+
//# sourceMappingURL=nanahoshi-mona-ui-scroll-view.mjs.map
|