@nanahoshi/mona-ui 0.24.10 → 0.25.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/README.md +9 -0
- package/chart/README.md +223 -77
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +11 -10
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +37 -20
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +239 -47
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +184 -31
- package/fesm2022/nanahoshi-mona-ui-button.mjs +47 -11
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +17 -13
- package/fesm2022/nanahoshi-mona-ui-card.mjs +54 -30
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +1909 -666
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +112 -31
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +131 -89
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +59 -19
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +118 -41
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +243 -212
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +155 -86
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +161 -131
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +12 -11
- package/fesm2022/nanahoshi-mona-ui-common.mjs +18 -1
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +25 -24
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +202 -33
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +31 -10
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1 -1
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-DhKLnW06.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-voGbKOiB.mjs → nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-HQ1Kv6R9.mjs → nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs} +7 -7
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-PNLJFcuH.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BO19AVwC.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs} +27 -29
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +146 -5
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +7 -7
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +183 -47
- package/fesm2022/nanahoshi-mona-ui-label.mjs +111 -15
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +111 -5
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +100 -6
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +105 -5
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +103 -5
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +90 -5
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +14 -13
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +13 -12
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +192 -56
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +3 -1
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +60 -29
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +334 -37
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +84 -30
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +274 -108
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +127 -37
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +595 -170
- package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +323 -166
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +167 -82
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +3 -3
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +273 -165
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +219 -132
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +84 -32
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +337 -116
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +10 -12
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +21 -8
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +444 -88
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +15 -14
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +17 -3
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1 -1
- package/i18n/catalogs/en-US.messages.json +90 -5
- package/locales/ar-sa/ar-sa.messages.json +90 -5
- package/locales/de-de/de-de.messages.json +90 -5
- package/locales/es-es/es-es.messages.json +90 -5
- package/locales/fr-fr/fr-fr.messages.json +91 -6
- package/locales/id-id/id-id.messages.json +90 -5
- package/locales/it-it/it-it.messages.json +90 -5
- package/locales/ja-jp/ja-jp.messages.json +90 -5
- package/locales/ko-kr/ko-kr.messages.json +90 -5
- package/locales/pt-br/pt-br.messages.json +90 -5
- package/locales/ru-ru/ru-ru.messages.json +90 -5
- package/locales/tr-tr/tr-tr.messages.json +90 -5
- package/locales/zh-cn/zh-cn.messages.json +90 -5
- package/locales/zh-tw/zh-tw.messages.json +90 -5
- package/package.json +2 -1
- package/styles.css +156 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +18 -11
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +62 -14
- package/types/nanahoshi-mona-ui-button-group.d.ts +86 -16
- package/types/nanahoshi-mona-ui-button.d.ts +26 -3
- package/types/nanahoshi-mona-ui-calendar.d.ts +1 -0
- package/types/nanahoshi-mona-ui-card.d.ts +22 -6
- package/types/nanahoshi-mona-ui-chart.d.ts +519 -527
- package/types/nanahoshi-mona-ui-check-box.d.ts +54 -13
- package/types/nanahoshi-mona-ui-chip.d.ts +31 -18
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +21 -5
- package/types/nanahoshi-mona-ui-collapsible.d.ts +20 -11
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +62 -36
- package/types/nanahoshi-mona-ui-color-palette.d.ts +65 -27
- package/types/nanahoshi-mona-ui-color-picker.d.ts +64 -23
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-common.d.ts +28 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +1 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +51 -7
- package/types/nanahoshi-mona-ui-fieldset.d.ts +18 -4
- package/types/nanahoshi-mona-ui-grid.d.ts +0 -1
- package/types/nanahoshi-mona-ui-i18n.d.ts +130 -3
- package/types/nanahoshi-mona-ui-internal.d.ts +95 -14
- package/types/nanahoshi-mona-ui-label.d.ts +17 -2
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +85 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +85 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +1 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-otp-input.d.ts +49 -12
- package/types/nanahoshi-mona-ui-placeholder.d.ts +2 -1
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +21 -9
- package/types/nanahoshi-mona-ui-radio-button.d.ts +165 -20
- package/types/nanahoshi-mona-ui-rating.d.ts +21 -6
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +59 -27
- package/types/nanahoshi-mona-ui-segmented.d.ts +52 -24
- package/types/nanahoshi-mona-ui-sidebar.d.ts +104 -41
- package/types/nanahoshi-mona-ui-skeleton.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +99 -35
- package/types/nanahoshi-mona-ui-spinner.d.ts +9 -5
- package/types/nanahoshi-mona-ui-splitter.d.ts +31 -10
- package/types/nanahoshi-mona-ui-stepper.d.ts +58 -12
- package/types/nanahoshi-mona-ui-switch.d.ts +32 -10
- package/types/nanahoshi-mona-ui-tabs.d.ts +75 -20
- package/types/nanahoshi-mona-ui-text-area.d.ts +7 -7
- package/types/nanahoshi-mona-ui-text-box.d.ts +2 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +392 -15
- package/types/nanahoshi-mona-ui-time-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +1 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +7 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { isPlatformBrowser, NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { computed, input, Directive, inject, DestroyRef, DOCUMENT, ElementRef, PLATFORM_ID, signal, contentChild,
|
|
3
|
+
import { computed, input, Directive, inject, TemplateRef, DestroyRef, DOCUMENT, ElementRef, PLATFORM_ID, signal, contentChild, viewChild, model, effect, untracked, afterRenderEffect, afterNextRender, isDevMode, Component } from '@angular/core';
|
|
4
4
|
import { toSignal, toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { toCssValue } from '@nanahoshi/mona-ui/internal';
|
|
6
6
|
import { select } from '@mirei/ts-collections';
|
|
7
|
-
import { Subject, startWith, pairwise, map, interval, takeUntil
|
|
7
|
+
import { Subject, startWith, pairwise, map, interval, takeUntil } from 'rxjs';
|
|
8
8
|
import { twMerge } from 'tailwind-merge';
|
|
9
9
|
import { formatNumber, injectComponentDirection, MonaI18nService } from '@nanahoshi/mona-ui/i18n';
|
|
10
10
|
import { cva } from 'class-variance-authority';
|
|
11
11
|
|
|
12
12
|
const scrollViewBaseThemeVariants = cva(`
|
|
13
13
|
relative block h-full w-full overflow-hidden
|
|
14
|
-
bg-surface
|
|
14
|
+
bg-surface
|
|
15
15
|
border border-border-subtle
|
|
16
|
-
focus-visible:
|
|
16
|
+
focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus-indicator
|
|
17
17
|
`, {
|
|
18
18
|
variants: {
|
|
19
19
|
rounded: {
|
|
@@ -26,12 +26,10 @@ const scrollViewBaseThemeVariants = cva(`
|
|
|
26
26
|
});
|
|
27
27
|
const scrollViewContentThemeVariants = cva(`
|
|
28
28
|
absolute inset-0 overflow-hidden
|
|
29
|
+
touch-pan-y touch-pinch-zoom
|
|
29
30
|
`);
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
[&_li]:absolute
|
|
33
|
-
[&_li]:inset-0
|
|
34
|
-
[&_li]:outline-none
|
|
31
|
+
const scrollViewSlideThemeVariants = cva(`
|
|
32
|
+
absolute inset-0
|
|
35
33
|
`);
|
|
36
34
|
const scrollViewArrowThemeVariants = cva(`
|
|
37
35
|
absolute top-0 bottom-0 flex items-center justify-center
|
|
@@ -40,7 +38,7 @@ const scrollViewArrowThemeVariants = cva(`
|
|
|
40
38
|
bg-surface-overlay/65 text-foreground
|
|
41
39
|
transition-colors duration-(--mona-motion-standard) ease-out
|
|
42
40
|
hover:bg-hover/90 active:bg-active/90
|
|
43
|
-
focus-visible:outline-
|
|
41
|
+
focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus-indicator
|
|
44
42
|
[&_svg]:stroke-current
|
|
45
43
|
`, {
|
|
46
44
|
variants: {
|
|
@@ -76,15 +74,15 @@ const scrollViewPagerListThemeVariants = cva(`
|
|
|
76
74
|
const scrollViewPagerListItemThemeVariants = cva(`
|
|
77
75
|
h-3 w-3 flex-none basis-3
|
|
78
76
|
cursor-pointer
|
|
79
|
-
bg-
|
|
77
|
+
bg-transparent border border-muted-foreground
|
|
80
78
|
transition-colors
|
|
81
79
|
not-last:me-3
|
|
82
80
|
hover:bg-muted-foreground/60 active:bg-foreground
|
|
83
|
-
focus-visible:outline-
|
|
81
|
+
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator
|
|
84
82
|
`, {
|
|
85
83
|
variants: {
|
|
86
84
|
active: {
|
|
87
|
-
true: "!bg-foreground hover:!bg-foreground",
|
|
85
|
+
true: "!bg-foreground hover:!bg-foreground !border-foreground forced-color-adjust-none forced-colors:!bg-[CanvasText] forced-colors:!border-[CanvasText]",
|
|
88
86
|
false: ""
|
|
89
87
|
},
|
|
90
88
|
pagerRounded: {
|
|
@@ -103,7 +101,7 @@ const scrollViewPagerArrowThemeVariants = cva(`
|
|
|
103
101
|
font-medium text-muted-foreground
|
|
104
102
|
transition-colors duration-(--mona-motion-standard) ease-out
|
|
105
103
|
hover:bg-hover hover:text-foreground active:bg-active
|
|
106
|
-
focus-visible:outline-
|
|
104
|
+
focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus-indicator
|
|
107
105
|
[&_svg]:stroke-current
|
|
108
106
|
`);
|
|
109
107
|
|
|
@@ -133,6 +131,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
133
131
|
}]
|
|
134
132
|
}], propDecorators: { active: [{ type: i0.Input, args: [{ isSignal: true, alias: "active", required: true }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: true }] }] } });
|
|
135
133
|
|
|
134
|
+
/**
|
|
135
|
+
* @description Marks the template that renders each slide. Bind `[monaScrollViewSlide]` to the same data as the scroll
|
|
136
|
+
* view, and `let-item` takes its type from it.
|
|
137
|
+
*/
|
|
138
|
+
class ScrollViewSlideDirective {
|
|
139
|
+
constructor() {
|
|
140
|
+
/**
|
|
141
|
+
* @description The scroll view's data, bound only so that `let-item` takes its type from it. Leave it empty for
|
|
142
|
+
* `unknown`.
|
|
143
|
+
* @default ""
|
|
144
|
+
*/
|
|
145
|
+
this.monaScrollViewSlide = input("", /* @ts-ignore */
|
|
146
|
+
...(ngDevMode ? [{ debugName: "monaScrollViewSlide" }] : /* istanbul ignore next */ []));
|
|
147
|
+
this.templateRef = inject(TemplateRef);
|
|
148
|
+
}
|
|
149
|
+
static ngTemplateContextGuard(_dir, _ctx) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollViewSlideDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
153
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.6", type: ScrollViewSlideDirective, isStandalone: true, selector: "ng-template[monaScrollViewSlide]", inputs: { monaScrollViewSlide: { classPropertyName: "monaScrollViewSlide", publicName: "monaScrollViewSlide", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 }); }
|
|
154
|
+
}
|
|
155
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollViewSlideDirective, decorators: [{
|
|
156
|
+
type: Directive,
|
|
157
|
+
args: [{
|
|
158
|
+
selector: "ng-template[monaScrollViewSlide]"
|
|
159
|
+
}]
|
|
160
|
+
}], propDecorators: { monaScrollViewSlide: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaScrollViewSlide", required: false }] }] } });
|
|
161
|
+
|
|
136
162
|
// Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
|
|
137
163
|
// Edit the JSON file and run `npm run generate:locale-catalogs`.
|
|
138
164
|
function localizeNumber(value, options) {
|
|
@@ -143,12 +169,17 @@ const SCROLL_VIEW_DEFAULT_MESSAGES = {
|
|
|
143
169
|
nextPage: "Next page",
|
|
144
170
|
page: (current) => `Page ${localizeNumber(current)}`,
|
|
145
171
|
pageOf: (current, total) => `Page ${localizeNumber(current)} of ${localizeNumber(total)}`,
|
|
172
|
+
pages: "Pages",
|
|
146
173
|
previousPage: "Previous page",
|
|
147
174
|
scrollPagerNext: "Scroll pager next",
|
|
148
175
|
scrollPagerPrevious: "Scroll pager previous",
|
|
149
176
|
slide: "slide"
|
|
150
177
|
};
|
|
151
178
|
|
|
179
|
+
/** How far a touch has to travel, in pixels, to count as a swipe. */
|
|
180
|
+
const SWIPE_DISTANCE = 40;
|
|
181
|
+
/** Where a horizontal drag belongs to the control under it and not to the carousel. */
|
|
182
|
+
const SWIPE_EXEMPT_SELECTOR = "input, select, textarea, [contenteditable], [role='slider'], [role='scrollbar']";
|
|
152
183
|
function normalizeScrollViewIndex(rawIndex, itemCount, infinite) {
|
|
153
184
|
if (itemCount <= 0) {
|
|
154
185
|
return 0;
|
|
@@ -172,11 +203,16 @@ class ScrollViewComponent {
|
|
|
172
203
|
#prefersReducedMotion;
|
|
173
204
|
#rejectedPagerPointers;
|
|
174
205
|
#scroll$;
|
|
206
|
+
#swipeCancelHandler;
|
|
207
|
+
#swipeEndHandler;
|
|
175
208
|
#suppressedPagerClickPointerIds;
|
|
176
209
|
#viewIndex;
|
|
177
210
|
#activePagerPointerControl;
|
|
178
211
|
#activePagerPointerId;
|
|
212
|
+
#activeSwipe;
|
|
179
213
|
#continuousTicked;
|
|
214
|
+
#navigationIntent;
|
|
215
|
+
#pagerCentered;
|
|
180
216
|
#pagerScrollCompletionCleanup;
|
|
181
217
|
#pagerScrollContext;
|
|
182
218
|
#resizeObserver;
|
|
@@ -193,6 +229,8 @@ class ScrollViewComponent {
|
|
|
193
229
|
...(ngDevMode ? [{ debugName: "#prefersReducedMotion" }] : /* istanbul ignore next */ []));
|
|
194
230
|
this.#rejectedPagerPointers = new Map();
|
|
195
231
|
this.#scroll$ = new Subject();
|
|
232
|
+
this.#swipeCancelHandler = (event) => this.#endSwipe(event, false);
|
|
233
|
+
this.#swipeEndHandler = (event) => this.#endSwipe(event, true);
|
|
196
234
|
this.#suppressedPagerClickPointerIds = new Set();
|
|
197
235
|
this.#viewIndex = computed(() => {
|
|
198
236
|
return normalizeScrollViewIndex(this.index(), this.itemCount(), this.infinite());
|
|
@@ -200,7 +238,10 @@ class ScrollViewComponent {
|
|
|
200
238
|
...(ngDevMode ? [{ debugName: "#viewIndex" }] : /* istanbul ignore next */ []));
|
|
201
239
|
this.#activePagerPointerControl = null;
|
|
202
240
|
this.#activePagerPointerId = null;
|
|
241
|
+
this.#activeSwipe = null;
|
|
203
242
|
this.#continuousTicked = false;
|
|
243
|
+
this.#navigationIntent = null;
|
|
244
|
+
this.#pagerCentered = false;
|
|
204
245
|
this.#pagerScrollCompletionCleanup = null;
|
|
205
246
|
this.#pagerScrollContext = null;
|
|
206
247
|
this.#resizeObserver = null;
|
|
@@ -209,12 +250,8 @@ class ScrollViewComponent {
|
|
|
209
250
|
return typeof animate === "boolean" ? (animate ? 500 : 0) : animate;
|
|
210
251
|
}, /* @ts-ignore */
|
|
211
252
|
...(ngDevMode ? [{ debugName: "animationDuration" }] : /* istanbul ignore next */ []));
|
|
212
|
-
this.
|
|
213
|
-
|
|
214
|
-
const count = this.itemCount();
|
|
215
|
-
return count > 0 ? this.messages().pageOf(index + 1, count) : undefined;
|
|
216
|
-
}, /* @ts-ignore */
|
|
217
|
-
...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
253
|
+
this.bareTemplate = contentChild(TemplateRef, /* @ts-ignore */
|
|
254
|
+
...(ngDevMode ? [{ debugName: "bareTemplate" }] : /* istanbul ignore next */ []));
|
|
218
255
|
this.baseClass = computed(() => {
|
|
219
256
|
const rounded = this.rounded();
|
|
220
257
|
const variantClass = scrollViewBaseThemeVariants({ rounded });
|
|
@@ -226,7 +263,9 @@ class ScrollViewComponent {
|
|
|
226
263
|
return scrollViewContentThemeVariants();
|
|
227
264
|
}, /* @ts-ignore */
|
|
228
265
|
...(ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []));
|
|
229
|
-
this.
|
|
266
|
+
this.contentElementRef = viewChild("contentElement", /* @ts-ignore */
|
|
267
|
+
...(ngDevMode ? [{ debugName: "contentElementRef" }] : /* istanbul ignore next */ []));
|
|
268
|
+
this.contentTemplate = computed(() => this.slideDirective()?.templateRef ?? this.bareTemplate(), /* @ts-ignore */
|
|
230
269
|
...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
|
|
231
270
|
this.enterAnimation = computed(() => {
|
|
232
271
|
const isRtl = this.isRtl();
|
|
@@ -235,6 +274,8 @@ class ScrollViewComponent {
|
|
|
235
274
|
return effectiveDir === "right" ? "slide-in-from-right" : "slide-in-from-left";
|
|
236
275
|
}, /* @ts-ignore */
|
|
237
276
|
...(ngDevMode ? [{ debugName: "enterAnimation" }] : /* istanbul ignore next */ []));
|
|
277
|
+
this.hostRole = computed(() => (this.ariaLabel() || this.ariaLabelledBy() ? "region" : "group"), /* @ts-ignore */
|
|
278
|
+
...(ngDevMode ? [{ debugName: "hostRole" }] : /* istanbul ignore next */ []));
|
|
238
279
|
this.isRtl = computed(() => this.#direction() === "rtl", /* @ts-ignore */
|
|
239
280
|
...(ngDevMode ? [{ debugName: "isRtl" }] : /* istanbul ignore next */ []));
|
|
240
281
|
this.itemCount = computed(() => this.viewData().length, /* @ts-ignore */
|
|
@@ -247,17 +288,18 @@ class ScrollViewComponent {
|
|
|
247
288
|
}, /* @ts-ignore */
|
|
248
289
|
...(ngDevMode ? [{ debugName: "leaveAnimation" }] : /* istanbul ignore next */ []));
|
|
249
290
|
this.leftArrowClass = computed(() => {
|
|
250
|
-
const count = this.itemCount();
|
|
251
|
-
const hidden = !this.arrows() || count <= 1 || !(this.infinite() || this.viewIndex() !== 0);
|
|
252
291
|
const side = this.isRtl() ? "right" : "left";
|
|
253
|
-
return scrollViewArrowThemeVariants({ hidden, side });
|
|
292
|
+
return scrollViewArrowThemeVariants({ hidden: this.previousArrowHidden(), side });
|
|
254
293
|
}, /* @ts-ignore */
|
|
255
294
|
...(ngDevMode ? [{ debugName: "leftArrowClass" }] : /* istanbul ignore next */ []));
|
|
256
|
-
this.listClass = computed(() => {
|
|
257
|
-
return scrollViewListThemeVariants();
|
|
258
|
-
}, /* @ts-ignore */
|
|
259
|
-
...(ngDevMode ? [{ debugName: "listClass" }] : /* istanbul ignore next */ []));
|
|
260
295
|
this.messages = this.#i18n.componentMessages("scrollView", SCROLL_VIEW_DEFAULT_MESSAGES);
|
|
296
|
+
this.nextArrowHidden = computed(() => {
|
|
297
|
+
const count = this.itemCount();
|
|
298
|
+
return !this.arrows() || count <= 1 || !(this.infinite() || this.viewIndex() !== count - 1);
|
|
299
|
+
}, /* @ts-ignore */
|
|
300
|
+
...(ngDevMode ? [{ debugName: "nextArrowHidden" }] : /* istanbul ignore next */ []));
|
|
301
|
+
this.nextArrowRef = viewChild("nextArrow", /* @ts-ignore */
|
|
302
|
+
...(ngDevMode ? [{ debugName: "nextArrowRef" }] : /* istanbul ignore next */ []));
|
|
261
303
|
this.pagerArrowClass = computed(() => {
|
|
262
304
|
return scrollViewPagerArrowThemeVariants();
|
|
263
305
|
}, /* @ts-ignore */
|
|
@@ -281,11 +323,15 @@ class ScrollViewComponent {
|
|
|
281
323
|
...(ngDevMode ? [{ debugName: "pagerListContainerClass" }] : /* istanbul ignore next */ []));
|
|
282
324
|
this.pagerListElementRef = viewChild("pagerListElement", /* @ts-ignore */
|
|
283
325
|
...(ngDevMode ? [{ debugName: "pagerListElementRef" }] : /* istanbul ignore next */ []));
|
|
326
|
+
this.previousArrowHidden = computed(() => {
|
|
327
|
+
return !this.arrows() || this.itemCount() <= 1 || !(this.infinite() || this.viewIndex() !== 0);
|
|
328
|
+
}, /* @ts-ignore */
|
|
329
|
+
...(ngDevMode ? [{ debugName: "previousArrowHidden" }] : /* istanbul ignore next */ []));
|
|
330
|
+
this.previousArrowRef = viewChild("previousArrow", /* @ts-ignore */
|
|
331
|
+
...(ngDevMode ? [{ debugName: "previousArrowRef" }] : /* istanbul ignore next */ []));
|
|
284
332
|
this.rightArrowClass = computed(() => {
|
|
285
|
-
const count = this.itemCount();
|
|
286
|
-
const hidden = !this.arrows() || count <= 1 || !(this.infinite() || this.viewIndex() !== count - 1);
|
|
287
333
|
const side = this.isRtl() ? "left" : "right";
|
|
288
|
-
return scrollViewArrowThemeVariants({ hidden, side });
|
|
334
|
+
return scrollViewArrowThemeVariants({ hidden: this.nextArrowHidden(), side });
|
|
289
335
|
}, /* @ts-ignore */
|
|
290
336
|
...(ngDevMode ? [{ debugName: "rightArrowClass" }] : /* istanbul ignore next */ []));
|
|
291
337
|
this.scrollBehavior = computed(() => this.#prefersReducedMotion() ? "instant" : "smooth", /* @ts-ignore */
|
|
@@ -300,6 +346,14 @@ class ScrollViewComponent {
|
|
|
300
346
|
return toCssValue(width);
|
|
301
347
|
}, /* @ts-ignore */
|
|
302
348
|
...(ngDevMode ? [{ debugName: "scrollViewWidth" }] : /* istanbul ignore next */ []));
|
|
349
|
+
this.slideClass = computed(() => {
|
|
350
|
+
return scrollViewSlideThemeVariants();
|
|
351
|
+
}, /* @ts-ignore */
|
|
352
|
+
...(ngDevMode ? [{ debugName: "slideClass" }] : /* istanbul ignore next */ []));
|
|
353
|
+
this.slideDirective = contentChild(ScrollViewSlideDirective, /* @ts-ignore */
|
|
354
|
+
...(ngDevMode ? [{ debugName: "slideDirective" }] : /* istanbul ignore next */ []));
|
|
355
|
+
this.slideSize = signal({ height: 0, width: 0 }, /* @ts-ignore */
|
|
356
|
+
...(ngDevMode ? [{ debugName: "slideSize" }] : /* istanbul ignore next */ []));
|
|
303
357
|
this.viewData = computed(() => {
|
|
304
358
|
const data = this.data();
|
|
305
359
|
return select(data, d => ({ data: d })).toImmutableSet();
|
|
@@ -314,7 +368,18 @@ class ScrollViewComponent {
|
|
|
314
368
|
this.animate = input(true, /* @ts-ignore */
|
|
315
369
|
...(ngDevMode ? [{ debugName: "animate" }] : /* istanbul ignore next */ []));
|
|
316
370
|
/**
|
|
317
|
-
* @description
|
|
371
|
+
* @description Accessible name of the carousel, saying what it shows. Use this or `aria-labelledby`; with neither,
|
|
372
|
+
* the host is a plain group and a warning is logged in development.
|
|
373
|
+
* @default ""
|
|
374
|
+
*/
|
|
375
|
+
this.ariaLabel = input("", { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
376
|
+
/**
|
|
377
|
+
* @description The id of the element that names the carousel.
|
|
378
|
+
* @default ""
|
|
379
|
+
*/
|
|
380
|
+
this.ariaLabelledBy = input("", { ...(ngDevMode ? { debugName: "ariaLabelledBy" } : /* istanbul ignore next */ {}), alias: "aria-labelledby" });
|
|
381
|
+
/**
|
|
382
|
+
* @description Shows the previous and next arrows. A swipe is a gesture, so give pointer users arrows or a pager too.
|
|
318
383
|
* @default false
|
|
319
384
|
*/
|
|
320
385
|
this.arrows = input(false, /* @ts-ignore */
|
|
@@ -343,12 +408,13 @@ class ScrollViewComponent {
|
|
|
343
408
|
this.infinite = input(false, /* @ts-ignore */
|
|
344
409
|
...(ngDevMode ? [{ debugName: "infinite" }] : /* istanbul ignore next */ []));
|
|
345
410
|
/**
|
|
346
|
-
* @description
|
|
411
|
+
* @description Shows the pager. A swipe is a gesture, so give pointer users arrows or a pager too.
|
|
412
|
+
* @default false
|
|
347
413
|
*/
|
|
348
414
|
this.pageable = input(false, /* @ts-ignore */
|
|
349
415
|
...(ngDevMode ? [{ debugName: "pageable" }] : /* istanbul ignore next */ []));
|
|
350
416
|
/**
|
|
351
|
-
* @description Sets the background blur of the pager in pixels.
|
|
417
|
+
* @description Sets the background blur of the pager in pixels. It doesn't apply with `pagerOverlay` set to `"none"`.
|
|
352
418
|
* @default 3
|
|
353
419
|
*/
|
|
354
420
|
this.pagerBlur = input(3, /* @ts-ignore */
|
|
@@ -392,9 +458,15 @@ class ScrollViewComponent {
|
|
|
392
458
|
}
|
|
393
459
|
});
|
|
394
460
|
this.#directionFromIndex = toSignal(toObservable(this.#viewIndex).pipe(startWith(0), pairwise(), map(([prevIndex, index]) => {
|
|
461
|
+
const intent = this.#navigationIntent;
|
|
462
|
+
this.#navigationIntent = null;
|
|
463
|
+
if (intent) {
|
|
464
|
+
return intent;
|
|
465
|
+
}
|
|
395
466
|
const infinite = this.infinite();
|
|
396
467
|
const totalItems = this.itemCount();
|
|
397
|
-
|
|
468
|
+
// With two slides a wrap and a plain step are the same move, so only an intent can tell them apart.
|
|
469
|
+
if (infinite && totalItems > 2) {
|
|
398
470
|
const lastIndex = totalItems - 1;
|
|
399
471
|
if (prevIndex === lastIndex && index === 0) {
|
|
400
472
|
return "right";
|
|
@@ -416,7 +488,18 @@ class ScrollViewComponent {
|
|
|
416
488
|
mediaQuery.addEventListener("change", onPreferenceChange);
|
|
417
489
|
this.#destroyRef.onDestroy(() => mediaQuery.removeEventListener("change", onPreferenceChange));
|
|
418
490
|
}
|
|
491
|
+
// A slide is rendered one at a time, so focus inside the one that's leaving would otherwise fall to the body.
|
|
492
|
+
effect(() => {
|
|
493
|
+
this.#viewIndex();
|
|
494
|
+
untracked(() => {
|
|
495
|
+
const content = this.contentElementRef()?.nativeElement;
|
|
496
|
+
if (content?.contains(this.#document.activeElement)) {
|
|
497
|
+
this.#hostElementRef.nativeElement.focus({ preventScroll: true });
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
});
|
|
419
501
|
this.#destroyRef.onDestroy(() => {
|
|
502
|
+
this.#removeSwipeListeners();
|
|
420
503
|
this.#stopContinuousScroll();
|
|
421
504
|
this.#resetPagerScrollState();
|
|
422
505
|
this.#scroll$.complete();
|
|
@@ -459,18 +542,98 @@ class ScrollViewComponent {
|
|
|
459
542
|
}
|
|
460
543
|
}
|
|
461
544
|
});
|
|
545
|
+
afterRenderEffect(() => {
|
|
546
|
+
const index = this.#viewIndex();
|
|
547
|
+
const list = this.pagerListElementRef()?.nativeElement;
|
|
548
|
+
this.itemCount();
|
|
549
|
+
untracked(() => {
|
|
550
|
+
if (!list) {
|
|
551
|
+
this.#pagerCentered = false;
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
const firstRun = !this.#pagerCentered;
|
|
555
|
+
this.#pagerCentered = true;
|
|
556
|
+
if (!firstRun || index !== 0) {
|
|
557
|
+
this.#centerActivePage(list, firstRun ? "instant" : this.scrollBehavior());
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
});
|
|
561
|
+
afterRenderEffect(() => {
|
|
562
|
+
const previousHidden = this.previousArrowHidden();
|
|
563
|
+
const nextHidden = this.nextArrowHidden();
|
|
564
|
+
untracked(() => {
|
|
565
|
+
const previous = this.previousArrowRef()?.nativeElement;
|
|
566
|
+
const next = this.nextArrowRef()?.nativeElement;
|
|
567
|
+
const active = this.#document.activeElement;
|
|
568
|
+
if (active === previous && previousHidden) {
|
|
569
|
+
(nextHidden ? this.#hostElementRef.nativeElement : next)?.focus({ preventScroll: true });
|
|
570
|
+
}
|
|
571
|
+
else if (active === next && nextHidden) {
|
|
572
|
+
(previousHidden ? this.#hostElementRef.nativeElement : previous)?.focus({ preventScroll: true });
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
});
|
|
462
576
|
afterNextRender(() => {
|
|
463
|
-
this.
|
|
464
|
-
|
|
577
|
+
const content = this.contentElementRef()?.nativeElement;
|
|
578
|
+
if (!content) {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
const measure = () => {
|
|
582
|
+
const { clientHeight: height, clientWidth: width } = content;
|
|
583
|
+
const current = this.slideSize();
|
|
584
|
+
if (current.height !== height || current.width !== width) {
|
|
585
|
+
this.slideSize.set({ height, width });
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
measure();
|
|
589
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
590
|
+
const observer = new ResizeObserver(measure);
|
|
591
|
+
observer.observe(content);
|
|
592
|
+
this.#destroyRef.onDestroy(() => observer.disconnect());
|
|
593
|
+
}
|
|
594
|
+
if (isDevMode() &&
|
|
595
|
+
this.itemCount() > 0 &&
|
|
596
|
+
!this.#hostElementRef.nativeElement.hasAttribute("aria-label") &&
|
|
597
|
+
!this.#hostElementRef.nativeElement.hasAttribute("aria-labelledby")) {
|
|
598
|
+
console.warn("mona-scroll-view: a carousel needs a name. Set aria-label or aria-labelledby.");
|
|
599
|
+
}
|
|
465
600
|
});
|
|
466
601
|
}
|
|
467
602
|
onArrowClick(direction) {
|
|
468
|
-
this
|
|
603
|
+
this.#navigate(direction);
|
|
469
604
|
}
|
|
470
|
-
|
|
471
|
-
this
|
|
605
|
+
onKeydown(event) {
|
|
606
|
+
const count = this.itemCount();
|
|
607
|
+
if (count === 0 ||
|
|
608
|
+
event.defaultPrevented ||
|
|
609
|
+
event.altKey ||
|
|
610
|
+
event.ctrlKey ||
|
|
611
|
+
event.metaKey ||
|
|
612
|
+
event.shiftKey ||
|
|
613
|
+
this.contentElementRef()?.nativeElement.contains(event.target)) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
const isRtl = this.isRtl();
|
|
617
|
+
switch (event.key) {
|
|
618
|
+
case "ArrowLeft":
|
|
619
|
+
this.#navigate(isRtl ? "right" : "left");
|
|
620
|
+
break;
|
|
621
|
+
case "ArrowRight":
|
|
622
|
+
this.#navigate(isRtl ? "left" : "right");
|
|
623
|
+
break;
|
|
624
|
+
case "Home":
|
|
625
|
+
this.index.set(0);
|
|
626
|
+
break;
|
|
627
|
+
case "End":
|
|
628
|
+
this.index.set(count - 1);
|
|
629
|
+
break;
|
|
630
|
+
default:
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
event.preventDefault();
|
|
634
|
+
}
|
|
635
|
+
onPageClick(index) {
|
|
472
636
|
this.index.set(index);
|
|
473
|
-
element.scrollIntoView({ behavior: this.scrollBehavior(), block: "nearest", inline: "center" });
|
|
474
637
|
}
|
|
475
638
|
onPagerClick(event, element, direction) {
|
|
476
639
|
if (event.button !== 0) {
|
|
@@ -543,6 +706,19 @@ class ScrollViewComponent {
|
|
|
543
706
|
this.#scrollPagerBy(element, direction);
|
|
544
707
|
});
|
|
545
708
|
}
|
|
709
|
+
onSwipeStart(event) {
|
|
710
|
+
this.#removeSwipeListeners();
|
|
711
|
+
if (!event.isPrimary ||
|
|
712
|
+
event.pointerType === "mouse" ||
|
|
713
|
+
event.button !== 0 ||
|
|
714
|
+
this.itemCount() <= 1 ||
|
|
715
|
+
event.target.closest(SWIPE_EXEMPT_SELECTOR)) {
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
this.#activeSwipe = { pointerId: event.pointerId, startX: event.clientX, startY: event.clientY };
|
|
719
|
+
this.#document.addEventListener("pointerup", this.#swipeEndHandler);
|
|
720
|
+
this.#document.addEventListener("pointercancel", this.#swipeCancelHandler);
|
|
721
|
+
}
|
|
546
722
|
#armPagerScrollCompletion(element) {
|
|
547
723
|
if (this.#pagerScrollCompletionCleanup) {
|
|
548
724
|
this.#pagerScrollCompletionCleanup();
|
|
@@ -588,6 +764,18 @@ class ScrollViewComponent {
|
|
|
588
764
|
};
|
|
589
765
|
}
|
|
590
766
|
}
|
|
767
|
+
#centerActivePage(list, behavior) {
|
|
768
|
+
this.#resetPagerScrollState();
|
|
769
|
+
const active = list.querySelector("button[data-active-page='true']");
|
|
770
|
+
if (!active || typeof list.scrollTo !== "function") {
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
const listRect = list.getBoundingClientRect();
|
|
774
|
+
const activeRect = active.getBoundingClientRect();
|
|
775
|
+
const offset = activeRect.left + activeRect.width / 2 - (listRect.left + listRect.width / 2);
|
|
776
|
+
// Only the pager list moves, unlike scrollIntoView, which would also scroll the page to the carousel.
|
|
777
|
+
list.scrollTo({ behavior, left: list.scrollLeft + offset });
|
|
778
|
+
}
|
|
591
779
|
#cleanupDocumentPointerListenersIfNeeded() {
|
|
592
780
|
let hasDownRejected = false;
|
|
593
781
|
for (const p of this.#rejectedPagerPointers.values()) {
|
|
@@ -601,6 +789,23 @@ class ScrollViewComponent {
|
|
|
601
789
|
this.#document.removeEventListener("pointercancel", this.#pointerCancelHandler);
|
|
602
790
|
}
|
|
603
791
|
}
|
|
792
|
+
#endSwipe(event, completed) {
|
|
793
|
+
const swipe = this.#activeSwipe;
|
|
794
|
+
if (swipe?.pointerId !== event.pointerId) {
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
this.#removeSwipeListeners();
|
|
798
|
+
if (!completed) {
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
const deltaX = event.clientX - swipe.startX;
|
|
802
|
+
const deltaY = event.clientY - swipe.startY;
|
|
803
|
+
if (Math.abs(deltaX) < SWIPE_DISTANCE || Math.abs(deltaX) <= Math.abs(deltaY)) {
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
const towardsNext = this.isRtl() ? deltaX > 0 : deltaX < 0;
|
|
807
|
+
this.#navigate(towardsNext ? "right" : "left");
|
|
808
|
+
}
|
|
604
809
|
#ensureDocumentPointerListeners() {
|
|
605
810
|
this.#document.addEventListener("pointerup", this.#pointerUpHandler);
|
|
606
811
|
this.#document.addEventListener("pointercancel", this.#pointerCancelHandler);
|
|
@@ -648,6 +853,19 @@ class ScrollViewComponent {
|
|
|
648
853
|
return ((targetNode != null && control.contains(targetNode)) ||
|
|
649
854
|
(typeof event.composedPath === "function" && event.composedPath().includes(control)));
|
|
650
855
|
}
|
|
856
|
+
#navigate(direction) {
|
|
857
|
+
const count = this.itemCount();
|
|
858
|
+
if (count === 0) {
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
861
|
+
const current = this.#viewIndex();
|
|
862
|
+
const step = direction === "left" ? -1 : 1;
|
|
863
|
+
const next = this.infinite() ? (current + step + count) % count : Math.max(0, Math.min(count - 1, current + step));
|
|
864
|
+
if (next !== current) {
|
|
865
|
+
this.#navigationIntent = direction;
|
|
866
|
+
this.index.set(next);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
651
869
|
#releasePagerPointerCapture(control, pointerId) {
|
|
652
870
|
if (control == null ||
|
|
653
871
|
typeof control.hasPointerCapture !== "function" ||
|
|
@@ -663,6 +881,11 @@ class ScrollViewComponent {
|
|
|
663
881
|
// Do not let an implementation-specific capture race break pager interaction.
|
|
664
882
|
}
|
|
665
883
|
}
|
|
884
|
+
#removeSwipeListeners() {
|
|
885
|
+
this.#activeSwipe = null;
|
|
886
|
+
this.#document.removeEventListener("pointerup", this.#swipeEndHandler);
|
|
887
|
+
this.#document.removeEventListener("pointercancel", this.#swipeCancelHandler);
|
|
888
|
+
}
|
|
666
889
|
#resetPagerScrollState() {
|
|
667
890
|
if (this.#pagerScrollCompletionCleanup) {
|
|
668
891
|
this.#pagerScrollCompletionCleanup();
|
|
@@ -722,80 +945,23 @@ class ScrollViewComponent {
|
|
|
722
945
|
const arrowFreeAvailableWidth = pager.clientWidth;
|
|
723
946
|
this.pagerArrowVisible.set(requiredWidth > arrowFreeAvailableWidth);
|
|
724
947
|
}
|
|
725
|
-
navigate(direction, infinite) {
|
|
726
|
-
if (direction === "left") {
|
|
727
|
-
this.navigateLeft(infinite);
|
|
728
|
-
}
|
|
729
|
-
else {
|
|
730
|
-
this.navigateRight(infinite);
|
|
731
|
-
}
|
|
732
|
-
this.scrollActivePageIntoView();
|
|
733
|
-
}
|
|
734
|
-
navigateLeft(infinite) {
|
|
735
|
-
const currentIndex = this.#viewIndex();
|
|
736
|
-
const dataLength = this.itemCount();
|
|
737
|
-
if (dataLength === 0) {
|
|
738
|
-
return;
|
|
739
|
-
}
|
|
740
|
-
if (infinite) {
|
|
741
|
-
this.index.set((currentIndex - 1 + dataLength) % dataLength);
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
this.index.set(Math.max(0, currentIndex - 1));
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
navigateRight(infinite) {
|
|
748
|
-
const currentIndex = this.#viewIndex();
|
|
749
|
-
const dataLength = this.itemCount();
|
|
750
|
-
if (dataLength === 0) {
|
|
751
|
-
return;
|
|
752
|
-
}
|
|
753
|
-
if (infinite) {
|
|
754
|
-
this.index.set((currentIndex + 1) % dataLength);
|
|
755
|
-
}
|
|
756
|
-
else {
|
|
757
|
-
this.index.set(Math.min(dataLength - 1, currentIndex + 1));
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
scrollActivePageIntoView() {
|
|
761
|
-
this.#resetPagerScrollState();
|
|
762
|
-
asyncScheduler.schedule(() => {
|
|
763
|
-
const element = this.#hostElementRef.nativeElement.querySelector("button[data-active-page='true']");
|
|
764
|
-
if (element) {
|
|
765
|
-
element.scrollIntoView({ behavior: this.scrollBehavior(), block: "nearest", inline: "center" });
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
}
|
|
769
|
-
setSubscriptions() {
|
|
770
|
-
fromEvent(this.#hostElementRef.nativeElement, "keydown")
|
|
771
|
-
.pipe(takeUntilDestroyed(this.#destroyRef), filter(event => event.key === "ArrowLeft" || event.key === "ArrowRight"), tap(event => {
|
|
772
|
-
const isRtl = this.isRtl();
|
|
773
|
-
let direction;
|
|
774
|
-
if (event.key === "ArrowLeft") {
|
|
775
|
-
direction = isRtl ? "right" : "left";
|
|
776
|
-
}
|
|
777
|
-
else {
|
|
778
|
-
direction = isRtl ? "left" : "right";
|
|
779
|
-
}
|
|
780
|
-
this.navigate(direction, this.infinite());
|
|
781
|
-
}))
|
|
782
|
-
.subscribe();
|
|
783
|
-
}
|
|
784
948
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
785
|
-
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 }, 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: { properties: { "class": "baseClass()", "attr.tabindex": "0", "style.height": "scrollViewHeight()", "style.width": "scrollViewWidth()", "attr.role": "'region'", "attr.aria-roledescription": "messages().carousel", "attr.aria-label": "ariaLabel()" } }, queries: [{ propertyName: "contentTemplate", first: true, predicate: TemplateRef, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "pagerElementRef", first: true, predicate: ["pagerElement"], descendants: true, isSignal: true }, { propertyName: "pagerListElementRef", first: true, predicate: ["pagerListElement"], descendants: true, isSignal: true }], ngImport: i0, template: "<div [class]=\"contentClass()\" #contentElement>\n <ul [class]=\"listClass()\">\n @for (item of viewData(); track $index) {\n @if ($index === viewIndex()) {\n <li\n role=\"group\"\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 @let width = contentElement.clientWidth;\n @let height = contentElement.clientHeight;\n <ng-container\n [ngTemplateOutlet]=\"contentTemplate()\"\n [ngTemplateOutletContext]=\"{ $implicit: item.data, width, height }\"></ng-container>\n </li>\n }\n }\n </ul>\n</div>\n<button\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 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]=\"'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()\" #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, pagerItemElement)\"\n #pagerItemElement></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"] }] }); }
|
|
949
|
+
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"] }] }); }
|
|
786
950
|
}
|
|
787
951
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollViewComponent, decorators: [{
|
|
788
952
|
type: Component,
|
|
789
953
|
args: [{ selector: "mona-scroll-view", imports: [NgTemplateOutlet, ScrollViewActivePageDirective], host: {
|
|
790
954
|
"[class]": "baseClass()",
|
|
791
|
-
"[attr.tabindex]": "0",
|
|
955
|
+
"[attr.tabindex]": "itemCount() > 0 ? 0 : null",
|
|
792
956
|
"[style.height]": "scrollViewHeight()",
|
|
793
957
|
"[style.width]": "scrollViewWidth()",
|
|
794
|
-
"[attr.role]": "
|
|
795
|
-
"[attr.aria-roledescription]": "messages().carousel",
|
|
796
|
-
"[attr.aria-label]": "ariaLabel()"
|
|
797
|
-
|
|
798
|
-
|
|
958
|
+
"[attr.role]": "hostRole()",
|
|
959
|
+
"[attr.aria-roledescription]": "itemCount() > 0 ? messages().carousel : null",
|
|
960
|
+
"[attr.aria-label]": "ariaLabel() || null",
|
|
961
|
+
"[attr.aria-labelledby]": "ariaLabelledBy() || null",
|
|
962
|
+
"(keydown)": "onKeydown($event)"
|
|
963
|
+
}, 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"] }]
|
|
964
|
+
}], ctorParameters: () => [], propDecorators: { bareTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }], contentElementRef: [{ type: i0.ViewChild, args: ["contentElement", { isSignal: true }] }], nextArrowRef: [{ type: i0.ViewChild, args: ["nextArrow", { isSignal: true }] }], pagerElementRef: [{ type: i0.ViewChild, args: ["pagerElement", { isSignal: true }] }], pagerListElementRef: [{ type: i0.ViewChild, args: ["pagerListElement", { isSignal: true }] }], previousArrowRef: [{ type: i0.ViewChild, args: ["previousArrow", { isSignal: true }] }], slideDirective: [{ type: i0.ContentChild, args: [i0.forwardRef(() => ScrollViewSlideDirective), { isSignal: true }] }], animate: [{ type: i0.Input, args: [{ isSignal: true, alias: "animate", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], ariaLabelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-labelledby", required: false }] }], arrows: [{ type: i0.Input, args: [{ isSignal: true, alias: "arrows", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: true }] }], index: [{ type: i0.Input, args: [{ isSignal: true, alias: "index", required: false }] }, { type: i0.Output, args: ["indexChange"] }], infinite: [{ type: i0.Input, args: [{ isSignal: true, alias: "infinite", required: false }] }], pageable: [{ type: i0.Input, args: [{ isSignal: true, alias: "pageable", required: false }] }], pagerBlur: [{ type: i0.Input, args: [{ isSignal: true, alias: "pagerBlur", required: false }] }], pagerOverlay: [{ type: i0.Input, args: [{ isSignal: true, alias: "pagerOverlay", required: false }] }], pagerRounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "pagerRounded", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: true }] }] } });
|
|
799
965
|
|
|
800
966
|
/*
|
|
801
967
|
* Public API Surface of @nanahoshi/mona-ui/scroll-view
|
|
@@ -805,5 +971,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
805
971
|
* Generated bundle index. Do not edit.
|
|
806
972
|
*/
|
|
807
973
|
|
|
808
|
-
export { SCROLL_VIEW_DEFAULT_MESSAGES,
|
|
974
|
+
export { SCROLL_VIEW_DEFAULT_MESSAGES, ScrollViewComponent, ScrollViewSlideDirective };
|
|
809
975
|
//# sourceMappingURL=nanahoshi-mona-ui-scroll-view.mjs.map
|