@nanahoshi/mona-ui 0.24.11 → 0.25.1
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/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 +183 -30
- package/fesm2022/nanahoshi-mona-ui-button.mjs +45 -9
- 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 +5 -0
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +112 -31
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +130 -88
- 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 +39 -4
- 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 +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +33 -4
- 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 +281 -111
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +126 -36
- 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 +2 -2
- 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 +472 -84
- 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 +33 -4
- package/locales/ar-sa/ar-sa.messages.json +33 -4
- package/locales/de-de/de-de.messages.json +33 -4
- package/locales/es-es/es-es.messages.json +33 -4
- package/locales/fr-fr/fr-fr.messages.json +33 -4
- package/locales/id-id/id-id.messages.json +33 -4
- package/locales/it-it/it-it.messages.json +33 -4
- package/locales/ja-jp/ja-jp.messages.json +33 -4
- package/locales/ko-kr/ko-kr.messages.json +33 -4
- package/locales/pt-br/pt-br.messages.json +33 -4
- package/locales/ru-ru/ru-ru.messages.json +33 -4
- package/locales/tr-tr/tr-tr.messages.json +33 -4
- package/locales/zh-cn/zh-cn.messages.json +33 -4
- package/locales/zh-tw/zh-tw.messages.json +33 -4
- package/package.json +2 -1
- package/styles.css +166 -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-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 +38 -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 +29 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +29 -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,22 +26,24 @@ 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
|
|
38
36
|
px-1
|
|
39
37
|
cursor-pointer select-none
|
|
40
|
-
bg-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-focus-indicator/35
|
|
38
|
+
bg-transparent text-foreground
|
|
39
|
+
forced-colors:bg-[Canvas]
|
|
40
|
+
focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus-indicator
|
|
44
41
|
[&_svg]:stroke-current
|
|
42
|
+
[&_svg]:drop-shadow-[0_0_1px_var(--color-surface),0_0_4px_var(--color-surface)]
|
|
43
|
+
[&_svg]:opacity-70
|
|
44
|
+
[&_svg]:transition-opacity [&_svg]:duration-(--mona-motion-standard) [&_svg]:ease-out
|
|
45
|
+
hover:[&_svg]:opacity-100 active:[&_svg]:opacity-100 focus-visible:[&_svg]:opacity-100
|
|
46
|
+
contrast-more:[&_svg]:opacity-100 forced-colors:[&_svg]:opacity-100
|
|
45
47
|
`, {
|
|
46
48
|
variants: {
|
|
47
49
|
hidden: {
|
|
@@ -76,15 +78,15 @@ const scrollViewPagerListThemeVariants = cva(`
|
|
|
76
78
|
const scrollViewPagerListItemThemeVariants = cva(`
|
|
77
79
|
h-3 w-3 flex-none basis-3
|
|
78
80
|
cursor-pointer
|
|
79
|
-
bg-
|
|
81
|
+
bg-transparent border border-muted-foreground
|
|
80
82
|
transition-colors
|
|
81
83
|
not-last:me-3
|
|
82
84
|
hover:bg-muted-foreground/60 active:bg-foreground
|
|
83
|
-
focus-visible:outline-
|
|
85
|
+
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator
|
|
84
86
|
`, {
|
|
85
87
|
variants: {
|
|
86
88
|
active: {
|
|
87
|
-
true: "!bg-foreground hover:!bg-foreground",
|
|
89
|
+
true: "!bg-foreground hover:!bg-foreground !border-foreground forced-color-adjust-none forced-colors:!bg-[CanvasText] forced-colors:!border-[CanvasText]",
|
|
88
90
|
false: ""
|
|
89
91
|
},
|
|
90
92
|
pagerRounded: {
|
|
@@ -103,7 +105,7 @@ const scrollViewPagerArrowThemeVariants = cva(`
|
|
|
103
105
|
font-medium text-muted-foreground
|
|
104
106
|
transition-colors duration-(--mona-motion-standard) ease-out
|
|
105
107
|
hover:bg-hover hover:text-foreground active:bg-active
|
|
106
|
-
focus-visible:outline-
|
|
108
|
+
focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-focus-indicator
|
|
107
109
|
[&_svg]:stroke-current
|
|
108
110
|
`);
|
|
109
111
|
|
|
@@ -133,6 +135,34 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
133
135
|
}]
|
|
134
136
|
}], propDecorators: { active: [{ type: i0.Input, args: [{ isSignal: true, alias: "active", required: true }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: true }] }] } });
|
|
135
137
|
|
|
138
|
+
/**
|
|
139
|
+
* @description Marks the template that renders each slide. Bind `[monaScrollViewSlide]` to the same data as the scroll
|
|
140
|
+
* view, and `let-item` takes its type from it.
|
|
141
|
+
*/
|
|
142
|
+
class ScrollViewSlideDirective {
|
|
143
|
+
constructor() {
|
|
144
|
+
/**
|
|
145
|
+
* @description The scroll view's data, bound only so that `let-item` takes its type from it. Leave it empty for
|
|
146
|
+
* `unknown`.
|
|
147
|
+
* @default ""
|
|
148
|
+
*/
|
|
149
|
+
this.monaScrollViewSlide = input("", /* @ts-ignore */
|
|
150
|
+
...(ngDevMode ? [{ debugName: "monaScrollViewSlide" }] : /* istanbul ignore next */ []));
|
|
151
|
+
this.templateRef = inject(TemplateRef);
|
|
152
|
+
}
|
|
153
|
+
static ngTemplateContextGuard(_dir, _ctx) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollViewSlideDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
157
|
+
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 }); }
|
|
158
|
+
}
|
|
159
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollViewSlideDirective, decorators: [{
|
|
160
|
+
type: Directive,
|
|
161
|
+
args: [{
|
|
162
|
+
selector: "ng-template[monaScrollViewSlide]"
|
|
163
|
+
}]
|
|
164
|
+
}], propDecorators: { monaScrollViewSlide: [{ type: i0.Input, args: [{ isSignal: true, alias: "monaScrollViewSlide", required: false }] }] } });
|
|
165
|
+
|
|
136
166
|
// Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
|
|
137
167
|
// Edit the JSON file and run `npm run generate:locale-catalogs`.
|
|
138
168
|
function localizeNumber(value, options) {
|
|
@@ -143,12 +173,17 @@ const SCROLL_VIEW_DEFAULT_MESSAGES = {
|
|
|
143
173
|
nextPage: "Next page",
|
|
144
174
|
page: (current) => `Page ${localizeNumber(current)}`,
|
|
145
175
|
pageOf: (current, total) => `Page ${localizeNumber(current)} of ${localizeNumber(total)}`,
|
|
176
|
+
pages: "Pages",
|
|
146
177
|
previousPage: "Previous page",
|
|
147
178
|
scrollPagerNext: "Scroll pager next",
|
|
148
179
|
scrollPagerPrevious: "Scroll pager previous",
|
|
149
180
|
slide: "slide"
|
|
150
181
|
};
|
|
151
182
|
|
|
183
|
+
/** How far a touch has to travel, in pixels, to count as a swipe. */
|
|
184
|
+
const SWIPE_DISTANCE = 40;
|
|
185
|
+
/** Where a horizontal drag belongs to the control under it and not to the carousel. */
|
|
186
|
+
const SWIPE_EXEMPT_SELECTOR = "input, select, textarea, [contenteditable], [role='slider'], [role='scrollbar']";
|
|
152
187
|
function normalizeScrollViewIndex(rawIndex, itemCount, infinite) {
|
|
153
188
|
if (itemCount <= 0) {
|
|
154
189
|
return 0;
|
|
@@ -172,11 +207,16 @@ class ScrollViewComponent {
|
|
|
172
207
|
#prefersReducedMotion;
|
|
173
208
|
#rejectedPagerPointers;
|
|
174
209
|
#scroll$;
|
|
210
|
+
#swipeCancelHandler;
|
|
211
|
+
#swipeEndHandler;
|
|
175
212
|
#suppressedPagerClickPointerIds;
|
|
176
213
|
#viewIndex;
|
|
177
214
|
#activePagerPointerControl;
|
|
178
215
|
#activePagerPointerId;
|
|
216
|
+
#activeSwipe;
|
|
179
217
|
#continuousTicked;
|
|
218
|
+
#navigationIntent;
|
|
219
|
+
#pagerCentered;
|
|
180
220
|
#pagerScrollCompletionCleanup;
|
|
181
221
|
#pagerScrollContext;
|
|
182
222
|
#resizeObserver;
|
|
@@ -193,6 +233,8 @@ class ScrollViewComponent {
|
|
|
193
233
|
...(ngDevMode ? [{ debugName: "#prefersReducedMotion" }] : /* istanbul ignore next */ []));
|
|
194
234
|
this.#rejectedPagerPointers = new Map();
|
|
195
235
|
this.#scroll$ = new Subject();
|
|
236
|
+
this.#swipeCancelHandler = (event) => this.#endSwipe(event, false);
|
|
237
|
+
this.#swipeEndHandler = (event) => this.#endSwipe(event, true);
|
|
196
238
|
this.#suppressedPagerClickPointerIds = new Set();
|
|
197
239
|
this.#viewIndex = computed(() => {
|
|
198
240
|
return normalizeScrollViewIndex(this.index(), this.itemCount(), this.infinite());
|
|
@@ -200,7 +242,10 @@ class ScrollViewComponent {
|
|
|
200
242
|
...(ngDevMode ? [{ debugName: "#viewIndex" }] : /* istanbul ignore next */ []));
|
|
201
243
|
this.#activePagerPointerControl = null;
|
|
202
244
|
this.#activePagerPointerId = null;
|
|
245
|
+
this.#activeSwipe = null;
|
|
203
246
|
this.#continuousTicked = false;
|
|
247
|
+
this.#navigationIntent = null;
|
|
248
|
+
this.#pagerCentered = false;
|
|
204
249
|
this.#pagerScrollCompletionCleanup = null;
|
|
205
250
|
this.#pagerScrollContext = null;
|
|
206
251
|
this.#resizeObserver = null;
|
|
@@ -209,12 +254,8 @@ class ScrollViewComponent {
|
|
|
209
254
|
return typeof animate === "boolean" ? (animate ? 500 : 0) : animate;
|
|
210
255
|
}, /* @ts-ignore */
|
|
211
256
|
...(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 */ []));
|
|
257
|
+
this.bareTemplate = contentChild(TemplateRef, /* @ts-ignore */
|
|
258
|
+
...(ngDevMode ? [{ debugName: "bareTemplate" }] : /* istanbul ignore next */ []));
|
|
218
259
|
this.baseClass = computed(() => {
|
|
219
260
|
const rounded = this.rounded();
|
|
220
261
|
const variantClass = scrollViewBaseThemeVariants({ rounded });
|
|
@@ -226,7 +267,9 @@ class ScrollViewComponent {
|
|
|
226
267
|
return scrollViewContentThemeVariants();
|
|
227
268
|
}, /* @ts-ignore */
|
|
228
269
|
...(ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []));
|
|
229
|
-
this.
|
|
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 */
|
|
230
273
|
...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
|
|
231
274
|
this.enterAnimation = computed(() => {
|
|
232
275
|
const isRtl = this.isRtl();
|
|
@@ -235,6 +278,8 @@ class ScrollViewComponent {
|
|
|
235
278
|
return effectiveDir === "right" ? "slide-in-from-right" : "slide-in-from-left";
|
|
236
279
|
}, /* @ts-ignore */
|
|
237
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 */ []));
|
|
238
283
|
this.isRtl = computed(() => this.#direction() === "rtl", /* @ts-ignore */
|
|
239
284
|
...(ngDevMode ? [{ debugName: "isRtl" }] : /* istanbul ignore next */ []));
|
|
240
285
|
this.itemCount = computed(() => this.viewData().length, /* @ts-ignore */
|
|
@@ -247,17 +292,18 @@ class ScrollViewComponent {
|
|
|
247
292
|
}, /* @ts-ignore */
|
|
248
293
|
...(ngDevMode ? [{ debugName: "leaveAnimation" }] : /* istanbul ignore next */ []));
|
|
249
294
|
this.leftArrowClass = computed(() => {
|
|
250
|
-
const count = this.itemCount();
|
|
251
|
-
const hidden = !this.arrows() || count <= 1 || !(this.infinite() || this.viewIndex() !== 0);
|
|
252
295
|
const side = this.isRtl() ? "right" : "left";
|
|
253
|
-
return scrollViewArrowThemeVariants({ hidden, side });
|
|
296
|
+
return scrollViewArrowThemeVariants({ hidden: this.previousArrowHidden(), side });
|
|
254
297
|
}, /* @ts-ignore */
|
|
255
298
|
...(ngDevMode ? [{ debugName: "leftArrowClass" }] : /* istanbul ignore next */ []));
|
|
256
|
-
this.listClass = computed(() => {
|
|
257
|
-
return scrollViewListThemeVariants();
|
|
258
|
-
}, /* @ts-ignore */
|
|
259
|
-
...(ngDevMode ? [{ debugName: "listClass" }] : /* istanbul ignore next */ []));
|
|
260
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 */ []));
|
|
261
307
|
this.pagerArrowClass = computed(() => {
|
|
262
308
|
return scrollViewPagerArrowThemeVariants();
|
|
263
309
|
}, /* @ts-ignore */
|
|
@@ -281,11 +327,15 @@ class ScrollViewComponent {
|
|
|
281
327
|
...(ngDevMode ? [{ debugName: "pagerListContainerClass" }] : /* istanbul ignore next */ []));
|
|
282
328
|
this.pagerListElementRef = viewChild("pagerListElement", /* @ts-ignore */
|
|
283
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 */ []));
|
|
284
336
|
this.rightArrowClass = computed(() => {
|
|
285
|
-
const count = this.itemCount();
|
|
286
|
-
const hidden = !this.arrows() || count <= 1 || !(this.infinite() || this.viewIndex() !== count - 1);
|
|
287
337
|
const side = this.isRtl() ? "left" : "right";
|
|
288
|
-
return scrollViewArrowThemeVariants({ hidden, side });
|
|
338
|
+
return scrollViewArrowThemeVariants({ hidden: this.nextArrowHidden(), side });
|
|
289
339
|
}, /* @ts-ignore */
|
|
290
340
|
...(ngDevMode ? [{ debugName: "rightArrowClass" }] : /* istanbul ignore next */ []));
|
|
291
341
|
this.scrollBehavior = computed(() => this.#prefersReducedMotion() ? "instant" : "smooth", /* @ts-ignore */
|
|
@@ -300,6 +350,14 @@ class ScrollViewComponent {
|
|
|
300
350
|
return toCssValue(width);
|
|
301
351
|
}, /* @ts-ignore */
|
|
302
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 */ []));
|
|
303
361
|
this.viewData = computed(() => {
|
|
304
362
|
const data = this.data();
|
|
305
363
|
return select(data, d => ({ data: d })).toImmutableSet();
|
|
@@ -314,7 +372,18 @@ class ScrollViewComponent {
|
|
|
314
372
|
this.animate = input(true, /* @ts-ignore */
|
|
315
373
|
...(ngDevMode ? [{ debugName: "animate" }] : /* istanbul ignore next */ []));
|
|
316
374
|
/**
|
|
317
|
-
* @description
|
|
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.
|
|
318
387
|
* @default false
|
|
319
388
|
*/
|
|
320
389
|
this.arrows = input(false, /* @ts-ignore */
|
|
@@ -343,12 +412,13 @@ class ScrollViewComponent {
|
|
|
343
412
|
this.infinite = input(false, /* @ts-ignore */
|
|
344
413
|
...(ngDevMode ? [{ debugName: "infinite" }] : /* istanbul ignore next */ []));
|
|
345
414
|
/**
|
|
346
|
-
* @description
|
|
415
|
+
* @description Shows the pager. A swipe is a gesture, so give pointer users arrows or a pager too.
|
|
416
|
+
* @default false
|
|
347
417
|
*/
|
|
348
418
|
this.pageable = input(false, /* @ts-ignore */
|
|
349
419
|
...(ngDevMode ? [{ debugName: "pageable" }] : /* istanbul ignore next */ []));
|
|
350
420
|
/**
|
|
351
|
-
* @description Sets the background blur of the pager in pixels.
|
|
421
|
+
* @description Sets the background blur of the pager in pixels. It doesn't apply with `pagerOverlay` set to `"none"`.
|
|
352
422
|
* @default 3
|
|
353
423
|
*/
|
|
354
424
|
this.pagerBlur = input(3, /* @ts-ignore */
|
|
@@ -392,9 +462,15 @@ class ScrollViewComponent {
|
|
|
392
462
|
}
|
|
393
463
|
});
|
|
394
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
|
+
}
|
|
395
470
|
const infinite = this.infinite();
|
|
396
471
|
const totalItems = this.itemCount();
|
|
397
|
-
|
|
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) {
|
|
398
474
|
const lastIndex = totalItems - 1;
|
|
399
475
|
if (prevIndex === lastIndex && index === 0) {
|
|
400
476
|
return "right";
|
|
@@ -416,7 +492,18 @@ class ScrollViewComponent {
|
|
|
416
492
|
mediaQuery.addEventListener("change", onPreferenceChange);
|
|
417
493
|
this.#destroyRef.onDestroy(() => mediaQuery.removeEventListener("change", onPreferenceChange));
|
|
418
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
|
+
});
|
|
419
505
|
this.#destroyRef.onDestroy(() => {
|
|
506
|
+
this.#removeSwipeListeners();
|
|
420
507
|
this.#stopContinuousScroll();
|
|
421
508
|
this.#resetPagerScrollState();
|
|
422
509
|
this.#scroll$.complete();
|
|
@@ -459,18 +546,98 @@ class ScrollViewComponent {
|
|
|
459
546
|
}
|
|
460
547
|
}
|
|
461
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
|
+
});
|
|
462
580
|
afterNextRender(() => {
|
|
463
|
-
this.
|
|
464
|
-
|
|
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
|
+
}
|
|
465
604
|
});
|
|
466
605
|
}
|
|
467
606
|
onArrowClick(direction) {
|
|
468
|
-
this
|
|
607
|
+
this.#navigate(direction);
|
|
469
608
|
}
|
|
470
|
-
|
|
471
|
-
this
|
|
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) {
|
|
472
640
|
this.index.set(index);
|
|
473
|
-
element.scrollIntoView({ behavior: this.scrollBehavior(), block: "nearest", inline: "center" });
|
|
474
641
|
}
|
|
475
642
|
onPagerClick(event, element, direction) {
|
|
476
643
|
if (event.button !== 0) {
|
|
@@ -543,6 +710,19 @@ class ScrollViewComponent {
|
|
|
543
710
|
this.#scrollPagerBy(element, direction);
|
|
544
711
|
});
|
|
545
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
|
+
}
|
|
546
726
|
#armPagerScrollCompletion(element) {
|
|
547
727
|
if (this.#pagerScrollCompletionCleanup) {
|
|
548
728
|
this.#pagerScrollCompletionCleanup();
|
|
@@ -588,6 +768,18 @@ class ScrollViewComponent {
|
|
|
588
768
|
};
|
|
589
769
|
}
|
|
590
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
|
+
}
|
|
591
783
|
#cleanupDocumentPointerListenersIfNeeded() {
|
|
592
784
|
let hasDownRejected = false;
|
|
593
785
|
for (const p of this.#rejectedPagerPointers.values()) {
|
|
@@ -601,6 +793,23 @@ class ScrollViewComponent {
|
|
|
601
793
|
this.#document.removeEventListener("pointercancel", this.#pointerCancelHandler);
|
|
602
794
|
}
|
|
603
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
|
+
}
|
|
604
813
|
#ensureDocumentPointerListeners() {
|
|
605
814
|
this.#document.addEventListener("pointerup", this.#pointerUpHandler);
|
|
606
815
|
this.#document.addEventListener("pointercancel", this.#pointerCancelHandler);
|
|
@@ -648,6 +857,19 @@ class ScrollViewComponent {
|
|
|
648
857
|
return ((targetNode != null && control.contains(targetNode)) ||
|
|
649
858
|
(typeof event.composedPath === "function" && event.composedPath().includes(control)));
|
|
650
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
|
+
}
|
|
651
873
|
#releasePagerPointerCapture(control, pointerId) {
|
|
652
874
|
if (control == null ||
|
|
653
875
|
typeof control.hasPointerCapture !== "function" ||
|
|
@@ -663,6 +885,11 @@ class ScrollViewComponent {
|
|
|
663
885
|
// Do not let an implementation-specific capture race break pager interaction.
|
|
664
886
|
}
|
|
665
887
|
}
|
|
888
|
+
#removeSwipeListeners() {
|
|
889
|
+
this.#activeSwipe = null;
|
|
890
|
+
this.#document.removeEventListener("pointerup", this.#swipeEndHandler);
|
|
891
|
+
this.#document.removeEventListener("pointercancel", this.#swipeCancelHandler);
|
|
892
|
+
}
|
|
666
893
|
#resetPagerScrollState() {
|
|
667
894
|
if (this.#pagerScrollCompletionCleanup) {
|
|
668
895
|
this.#pagerScrollCompletionCleanup();
|
|
@@ -722,80 +949,23 @@ class ScrollViewComponent {
|
|
|
722
949
|
const arrowFreeAvailableWidth = pager.clientWidth;
|
|
723
950
|
this.pagerArrowVisible.set(requiredWidth > arrowFreeAvailableWidth);
|
|
724
951
|
}
|
|
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
952
|
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"] }] }); }
|
|
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"] }] }); }
|
|
786
954
|
}
|
|
787
955
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: ScrollViewComponent, decorators: [{
|
|
788
956
|
type: Component,
|
|
789
957
|
args: [{ selector: "mona-scroll-view", imports: [NgTemplateOutlet, ScrollViewActivePageDirective], host: {
|
|
790
958
|
"[class]": "baseClass()",
|
|
791
|
-
"[attr.tabindex]": "0",
|
|
959
|
+
"[attr.tabindex]": "itemCount() > 0 ? 0 : null",
|
|
792
960
|
"[style.height]": "scrollViewHeight()",
|
|
793
961
|
"[style.width]": "scrollViewWidth()",
|
|
794
|
-
"[attr.role]": "
|
|
795
|
-
"[attr.aria-roledescription]": "messages().carousel",
|
|
796
|
-
"[attr.aria-label]": "ariaLabel()"
|
|
797
|
-
|
|
798
|
-
|
|
962
|
+
"[attr.role]": "hostRole()",
|
|
963
|
+
"[attr.aria-roledescription]": "itemCount() > 0 ? messages().carousel : null",
|
|
964
|
+
"[attr.aria-label]": "ariaLabel() || null",
|
|
965
|
+
"[attr.aria-labelledby]": "ariaLabelledBy() || null",
|
|
966
|
+
"(keydown)": "onKeydown($event)"
|
|
967
|
+
}, 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"] }]
|
|
968
|
+
}], 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
969
|
|
|
800
970
|
/*
|
|
801
971
|
* Public API Surface of @nanahoshi/mona-ui/scroll-view
|
|
@@ -805,5 +975,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
805
975
|
* Generated bundle index. Do not edit.
|
|
806
976
|
*/
|
|
807
977
|
|
|
808
|
-
export { SCROLL_VIEW_DEFAULT_MESSAGES,
|
|
978
|
+
export { SCROLL_VIEW_DEFAULT_MESSAGES, ScrollViewComponent, ScrollViewSlideDirective };
|
|
809
979
|
//# sourceMappingURL=nanahoshi-mona-ui-scroll-view.mjs.map
|