@nanahoshi/mona-ui 0.5.0 → 0.6.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, inject, DestroyRef, DOCUMENT, viewChild, ViewContainerRef, computed, signal,
|
|
2
|
+
import { InjectionToken, inject, DestroyRef, DOCUMENT, viewChild, ViewContainerRef, computed, signal, TemplateRef, Component, Injector, ElementRef, Injectable, input, output, effect } from '@angular/core';
|
|
3
3
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
4
|
import { rxTimeout } from '@nanahoshi/mona-ui/internal';
|
|
5
5
|
import { take, asapScheduler, Subject, ReplaySubject, asyncScheduler, fromEvent, takeUntil, Subscription, filter, tap, exhaustMap, merge } from 'rxjs';
|
|
@@ -46,6 +46,22 @@ const fadePopupAnimation = {
|
|
|
46
46
|
enter: "mona-popup-fade-enter",
|
|
47
47
|
leave: "mona-popup-fade-leave"
|
|
48
48
|
};
|
|
49
|
+
const slideFromRightPopupAnimation = {
|
|
50
|
+
enter: "mona-popup-slide-from-right-enter",
|
|
51
|
+
leave: "mona-popup-slide-to-right-leave"
|
|
52
|
+
};
|
|
53
|
+
const slideFromLeftPopupAnimation = {
|
|
54
|
+
enter: "mona-popup-slide-from-left-enter",
|
|
55
|
+
leave: "mona-popup-slide-to-left-leave"
|
|
56
|
+
};
|
|
57
|
+
const slideFromTopPopupAnimation = {
|
|
58
|
+
enter: "mona-popup-slide-from-top-enter",
|
|
59
|
+
leave: "mona-popup-slide-to-top-leave"
|
|
60
|
+
};
|
|
61
|
+
const slideFromBottomPopupAnimation = {
|
|
62
|
+
enter: "mona-popup-slide-from-bottom-enter",
|
|
63
|
+
leave: "mona-popup-slide-to-bottom-leave"
|
|
64
|
+
};
|
|
49
65
|
|
|
50
66
|
const PopupDataInjectionToken = new InjectionToken("PopupInjectionToken");
|
|
51
67
|
const PopupSettingsInjectionToken = new InjectionToken("PopupSettingsInjectionToken");
|
|
@@ -87,31 +103,19 @@ class PopupWrapperComponent {
|
|
|
87
103
|
...(ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []));
|
|
88
104
|
this.visible = signal(true, /* @ts-ignore */
|
|
89
105
|
...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
90
|
-
this.wrapperClass = signal(
|
|
106
|
+
this.wrapperClass = signal(this.#popupSettings.popupWrapperClass instanceof Array
|
|
107
|
+
? this.#popupSettings.popupWrapperClass.join(" ")
|
|
108
|
+
: (this.#popupSettings.popupWrapperClass ?? ""), /* @ts-ignore */
|
|
91
109
|
...(ngDevMode ? [{ debugName: "wrapperClass" }] : /* istanbul ignore next */ []));
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
this.wrapperClass.set(this.#popupSettings.popupWrapperClass);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
this.#popupReference.closeStart$
|
|
103
|
-
.pipe(take(1), takeUntilDestroyed(this.#destroyRef))
|
|
104
|
-
.subscribe(event => {
|
|
105
|
-
this.#closeEvent = event;
|
|
106
|
-
const animationElement = this.animationElement().nativeElement;
|
|
107
|
-
this.visible.set(false);
|
|
108
|
-
if (!this.leaveAnimationClasses()) {
|
|
109
|
-
this.#completeClose();
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
this.#document.defaultView?.setTimeout(() => this.#startFallbackTimer(animationElement));
|
|
113
|
-
});
|
|
110
|
+
this.#popupReference.closeStart$.pipe(take(1), takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
|
|
111
|
+
this.#closeEvent = event;
|
|
112
|
+
const animationElement = this.animationElement().nativeElement;
|
|
113
|
+
this.visible.set(false);
|
|
114
|
+
if (!this.leaveAnimationClasses()) {
|
|
115
|
+
this.#completeClose();
|
|
116
|
+
return;
|
|
114
117
|
}
|
|
118
|
+
this.#document.defaultView?.setTimeout(() => this.#startFallbackTimer(animationElement));
|
|
115
119
|
});
|
|
116
120
|
this.#destroyRef.onDestroy(() => this.#clearFallbackTimer());
|
|
117
121
|
}
|
|
@@ -123,6 +127,11 @@ class PopupWrapperComponent {
|
|
|
123
127
|
}
|
|
124
128
|
return this.componentOutlet().createComponent(content, { injector });
|
|
125
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Only completion events are observed. A cancellation is also raised when the enter animation is
|
|
132
|
+
* replaced by the leave animation, so treating it as completion would dispose the overlay before
|
|
133
|
+
* the leave animation had a chance to play. {@link #startFallbackTimer} covers genuine cancellations.
|
|
134
|
+
*/
|
|
126
135
|
onNativeLeaveComplete(event) {
|
|
127
136
|
if (event.target !== event.currentTarget) {
|
|
128
137
|
return;
|
|
@@ -203,13 +212,13 @@ class PopupWrapperComponent {
|
|
|
203
212
|
this.#fallbackTimer = win.setTimeout(() => this.#completeClose(), duration + 50);
|
|
204
213
|
}
|
|
205
214
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopupWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
206
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: PopupWrapperComponent, isStandalone: true, selector: "mona-popup-wrapper", host: { properties: { "class": "hostClasses()" } }, viewQueries: [{ propertyName: "animationElement", first: true, predicate: ["animationElement"], descendants: true, isSignal: true }, { propertyName: "componentOutlet", first: true, predicate: ["componentOutlet"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "@if (visible()) {\n <div\n #animationElement\n class=\"w-full h-full origin-center\"\n [animate.enter]=\"enterAnimationClasses()\"\n [animate.leave]=\"leaveAnimationClasses()\"\n (
|
|
215
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: PopupWrapperComponent, isStandalone: true, selector: "mona-popup-wrapper", host: { properties: { "class": "hostClasses()" } }, viewQueries: [{ propertyName: "animationElement", first: true, predicate: ["animationElement"], descendants: true, isSignal: true }, { propertyName: "componentOutlet", first: true, predicate: ["componentOutlet"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "@if (visible()) {\n <div\n #animationElement\n class=\"w-full h-full origin-center\"\n [animate.enter]=\"enterAnimationClasses()\"\n [animate.leave]=\"leaveAnimationClasses()\"\n (animationend)=\"onNativeLeaveComplete($event)\"\n (transitionend)=\"onNativeLeaveComplete($event)\">\n @if (templateRef()) {\n <ng-container [ngTemplateOutlet]=\"templateRef()\"></ng-container>\n }\n <ng-container #componentOutlet></ng-container>\n </div>\n}\n", styles: [":host{display:block}:host(.mona-popup-constrain-height){min-height:0;max-height:inherit;overflow:clip}:host(.mona-popup-constrain-height)>div{display:flex;min-height:0;max-height:inherit;overflow:clip}.mona-popup-enter{animation:mona-popup-scale-in .15s cubic-bezier(.4,0,.2,1)}.mona-popup-leave{animation:mona-popup-scale-out .15s cubic-bezier(.4,0,.2,1)}.mona-dropdown-popup-enter{animation:mona-dropdown-popup-scale-in .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-dropdown-popup-leave{animation:mona-dropdown-popup-scale-out .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-popup-fade-enter{animation:mona-popup-fade-in 50ms ease-in}.mona-popup-fade-leave{animation:mona-popup-fade-out .15s ease-out}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-fill-mode:both;backface-visibility:hidden;will-change:transform}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter{animation-duration:.32s;animation-timing-function:cubic-bezier(.25,.46,.45,.94)}.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-duration:.24s;animation-timing-function:cubic-bezier(.4,0,1,1)}.mona-popup-slide-from-right-enter{animation-name:mona-popup-slide-from-right}.mona-popup-slide-to-right-leave{animation-name:mona-popup-slide-to-right}.mona-popup-slide-from-left-enter{animation-name:mona-popup-slide-from-left}.mona-popup-slide-to-left-leave{animation-name:mona-popup-slide-to-left}.mona-popup-slide-from-top-enter{animation-name:mona-popup-slide-from-top}.mona-popup-slide-to-top-leave{animation-name:mona-popup-slide-to-top}.mona-popup-slide-from-bottom-enter{animation-name:mona-popup-slide-from-bottom}.mona-popup-slide-to-bottom-leave{animation-name:mona-popup-slide-to-bottom}@keyframes mona-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-dropdown-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-dropdown-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-popup-fade-in{0%{opacity:0}to{opacity:1}}@keyframes mona-popup-fade-out{0%{opacity:1}to{opacity:0}}@keyframes mona-popup-slide-from-right{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-right{0%{transform:translate(0)}to{transform:translate(100%)}}@keyframes mona-popup-slide-from-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-left{0%{transform:translate(0)}to{transform:translate(-100%)}}@keyframes mona-popup-slide-from-top{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-top{0%{transform:translateY(0)}to{transform:translateY(-100%)}}@keyframes mona-popup-slide-from-bottom{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-bottom{0%{transform:translateY(0)}to{transform:translateY(100%)}}@media(prefers-reduced-motion:reduce){.mona-popup-enter,.mona-popup-leave,.mona-dropdown-popup-enter,.mona-dropdown-popup-leave,.mona-popup-fade-enter,.mona-popup-fade-leave,.mona-popup-slide-from-right-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-from-left-enter,.mona-popup-slide-to-left-leave,.mona-popup-slide-from-top-enter,.mona-popup-slide-to-top-leave,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-bottom-leave{animation-duration:1ms}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
|
|
207
216
|
}
|
|
208
217
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopupWrapperComponent, decorators: [{
|
|
209
218
|
type: Component,
|
|
210
219
|
args: [{ selector: "mona-popup-wrapper", imports: [NgTemplateOutlet], host: {
|
|
211
220
|
"[class]": "hostClasses()"
|
|
212
|
-
}, template: "@if (visible()) {\n <div\n #animationElement\n class=\"w-full h-full origin-center\"\n [animate.enter]=\"enterAnimationClasses()\"\n [animate.leave]=\"leaveAnimationClasses()\"\n (
|
|
221
|
+
}, template: "@if (visible()) {\n <div\n #animationElement\n class=\"w-full h-full origin-center\"\n [animate.enter]=\"enterAnimationClasses()\"\n [animate.leave]=\"leaveAnimationClasses()\"\n (animationend)=\"onNativeLeaveComplete($event)\"\n (transitionend)=\"onNativeLeaveComplete($event)\">\n @if (templateRef()) {\n <ng-container [ngTemplateOutlet]=\"templateRef()\"></ng-container>\n }\n <ng-container #componentOutlet></ng-container>\n </div>\n}\n", styles: [":host{display:block}:host(.mona-popup-constrain-height){min-height:0;max-height:inherit;overflow:clip}:host(.mona-popup-constrain-height)>div{display:flex;min-height:0;max-height:inherit;overflow:clip}.mona-popup-enter{animation:mona-popup-scale-in .15s cubic-bezier(.4,0,.2,1)}.mona-popup-leave{animation:mona-popup-scale-out .15s cubic-bezier(.4,0,.2,1)}.mona-dropdown-popup-enter{animation:mona-dropdown-popup-scale-in .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-dropdown-popup-leave{animation:mona-dropdown-popup-scale-out .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-popup-fade-enter{animation:mona-popup-fade-in 50ms ease-in}.mona-popup-fade-leave{animation:mona-popup-fade-out .15s ease-out}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-fill-mode:both;backface-visibility:hidden;will-change:transform}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter{animation-duration:.32s;animation-timing-function:cubic-bezier(.25,.46,.45,.94)}.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-duration:.24s;animation-timing-function:cubic-bezier(.4,0,1,1)}.mona-popup-slide-from-right-enter{animation-name:mona-popup-slide-from-right}.mona-popup-slide-to-right-leave{animation-name:mona-popup-slide-to-right}.mona-popup-slide-from-left-enter{animation-name:mona-popup-slide-from-left}.mona-popup-slide-to-left-leave{animation-name:mona-popup-slide-to-left}.mona-popup-slide-from-top-enter{animation-name:mona-popup-slide-from-top}.mona-popup-slide-to-top-leave{animation-name:mona-popup-slide-to-top}.mona-popup-slide-from-bottom-enter{animation-name:mona-popup-slide-from-bottom}.mona-popup-slide-to-bottom-leave{animation-name:mona-popup-slide-to-bottom}@keyframes mona-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-dropdown-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-dropdown-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-popup-fade-in{0%{opacity:0}to{opacity:1}}@keyframes mona-popup-fade-out{0%{opacity:1}to{opacity:0}}@keyframes mona-popup-slide-from-right{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-right{0%{transform:translate(0)}to{transform:translate(100%)}}@keyframes mona-popup-slide-from-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-left{0%{transform:translate(0)}to{transform:translate(-100%)}}@keyframes mona-popup-slide-from-top{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-top{0%{transform:translateY(0)}to{transform:translateY(-100%)}}@keyframes mona-popup-slide-from-bottom{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-bottom{0%{transform:translateY(0)}to{transform:translateY(100%)}}@media(prefers-reduced-motion:reduce){.mona-popup-enter,.mona-popup-leave,.mona-dropdown-popup-enter,.mona-dropdown-popup-leave,.mona-popup-fade-enter,.mona-popup-fade-leave,.mona-popup-slide-from-right-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-from-left-enter,.mona-popup-slide-to-left-leave,.mona-popup-slide-from-top-enter,.mona-popup-slide-to-top-leave,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-bottom-leave{animation-duration:1ms}}\n"] }]
|
|
213
222
|
}], ctorParameters: () => [], propDecorators: { animationElement: [{ type: i0.ViewChild, args: ["animationElement", { isSignal: true }] }], componentOutlet: [{ type: i0.ViewChild, args: ["componentOutlet", { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
|
|
214
223
|
|
|
215
224
|
class PopupRef {
|
|
@@ -631,7 +640,8 @@ class PopupService {
|
|
|
631
640
|
width: settings.width,
|
|
632
641
|
panelClass,
|
|
633
642
|
backdropClass: settings.backdropClass ?? "transparent",
|
|
634
|
-
direction
|
|
643
|
+
direction,
|
|
644
|
+
scrollStrategy: settings.blockScroll ? this.#overlay.scrollStrategies.block() : undefined
|
|
635
645
|
}));
|
|
636
646
|
}
|
|
637
647
|
createPositionStrategy(settings) {
|
|
@@ -671,6 +681,7 @@ class PopupService {
|
|
|
671
681
|
this.attachContent(settings, popupReference, overlayRef, injector);
|
|
672
682
|
const subscription = this.setupCloseSubscriptions(settings, popupReference, overlayRef);
|
|
673
683
|
this.setupCleanupSubscription(popupReference, subscription, settings, originallyFocusedElement);
|
|
684
|
+
this.setupBackdropFadeOut(settings, popupReference, overlayRef);
|
|
674
685
|
if (settings.closeOnScroll) {
|
|
675
686
|
this.setupScrollClosing(settings, popupReference, overlayRef);
|
|
676
687
|
}
|
|
@@ -794,6 +805,16 @@ class PopupService {
|
|
|
794
805
|
backdropSubject.complete();
|
|
795
806
|
});
|
|
796
807
|
}
|
|
808
|
+
/**
|
|
809
|
+
* Starts the backdrop fade-out as soon as the close begins, so it runs alongside the popup's leave
|
|
810
|
+
* animation. Without it the backdrop stays fully opaque until `dispose()` removes it in one frame.
|
|
811
|
+
*/
|
|
812
|
+
setupBackdropFadeOut(settings, popupReference, overlayRef) {
|
|
813
|
+
if (!settings.hasBackdrop) {
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
popupReference.closeStart.pipe(take(1)).subscribe(() => overlayRef.detachBackdrop());
|
|
817
|
+
}
|
|
797
818
|
setupCleanupSubscription(popupReference, subscription, settings, originallyFocusedElement) {
|
|
798
819
|
popupReference.closed.pipe(take(1)).subscribe(() => {
|
|
799
820
|
subscription?.unsubscribe();
|
|
@@ -1317,5 +1338,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImpor
|
|
|
1317
1338
|
* Generated bundle index. Do not edit.
|
|
1318
1339
|
*/
|
|
1319
1340
|
|
|
1320
|
-
export { PopupCloseEvent, PopupCloseSource, PopupComponent, PopupDataInjectionToken, PopupRef, PopupService, defaultPopupAnimation, dropdownPopupAnimation, fadePopupAnimation };
|
|
1341
|
+
export { PopupCloseEvent, PopupCloseSource, PopupComponent, PopupDataInjectionToken, PopupRef, PopupService, defaultPopupAnimation, dropdownPopupAnimation, fadePopupAnimation, slideFromBottomPopupAnimation, slideFromLeftPopupAnimation, slideFromRightPopupAnimation, slideFromTopPopupAnimation };
|
|
1321
1342
|
//# sourceMappingURL=nanahoshi-mona-ui-popup.mjs.map
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { CdkTrapFocus } from '@angular/cdk/a11y';
|
|
2
|
+
import { GlobalPositionStrategy } from '@angular/cdk/overlay';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { inject, DestroyRef, DOCUMENT, Injector, viewChild, computed, input, output, afterNextRender, effect, Component } from '@angular/core';
|
|
5
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
6
|
+
import { LucideX } from '@lucide/angular';
|
|
7
|
+
import { ButtonDirective } from '@nanahoshi/mona-ui/button';
|
|
8
|
+
import { classInputToClass } from '@nanahoshi/mona-ui/common';
|
|
9
|
+
import { themeOverlaySurfaceClasses, createElementControlId } from '@nanahoshi/mona-ui/internal';
|
|
10
|
+
import { PopupService, PopupCloseEvent, PopupCloseSource, slideFromLeftPopupAnimation, slideFromBottomPopupAnimation, slideFromRightPopupAnimation, slideFromTopPopupAnimation } from '@nanahoshi/mona-ui/popup';
|
|
11
|
+
import { take } from 'rxjs';
|
|
12
|
+
import { twMerge } from 'tailwind-merge';
|
|
13
|
+
import { cva } from 'class-variance-authority';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* `overflow-clip` rather than `overflow-hidden` is deliberate. `hidden` would make the sheet a scroll
|
|
17
|
+
* container, letting the browser scroll it to reveal content that takes focus while the enter animation
|
|
18
|
+
* still has the sheet translated off-screen, which cancels the animation. `clip` cannot scroll.
|
|
19
|
+
*/
|
|
20
|
+
const sheetBaseVariants = cva(`
|
|
21
|
+
relative flex h-full w-full min-w-0 min-h-0 max-h-[inherit] flex-col overflow-clip
|
|
22
|
+
pt-[env(safe-area-inset-top)] pr-[env(safe-area-inset-right)]
|
|
23
|
+
pb-[env(safe-area-inset-bottom)] pl-[env(safe-area-inset-left)]
|
|
24
|
+
${themeOverlaySurfaceClasses} text-foreground
|
|
25
|
+
shadow-(--shadow-overlay) outline-none
|
|
26
|
+
`, {
|
|
27
|
+
variants: {
|
|
28
|
+
side: {
|
|
29
|
+
top: "border-b border-border",
|
|
30
|
+
right: "border-l border-border",
|
|
31
|
+
bottom: "border-t border-border",
|
|
32
|
+
left: "border-r border-border"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
side: "right"
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const sheetHeaderVariants = cva(`flex shrink-0 items-start gap-3 p-4`);
|
|
40
|
+
const sheetTitleVariants = cva(`text-lg font-semibold leading-none tracking-tight`);
|
|
41
|
+
const sheetDescriptionVariants = cva(`mt-1.5 text-sm text-muted-foreground`);
|
|
42
|
+
const sheetContentVariants = cva(`
|
|
43
|
+
min-w-0 min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 pb-4
|
|
44
|
+
[scrollbar-color:var(--color-scrollbar-thumb)_var(--color-scrollbar-track)] [scrollbar-width:thin]
|
|
45
|
+
`);
|
|
46
|
+
/** 2.75rem keeps the close button at the WCAG 2.5.5 minimum target size. */
|
|
47
|
+
const sheetCloseButtonVariants = cva(`min-h-11 min-w-11 shrink-0`);
|
|
48
|
+
|
|
49
|
+
class SheetComponent {
|
|
50
|
+
#destroyRef;
|
|
51
|
+
#document;
|
|
52
|
+
#injector;
|
|
53
|
+
#popupService;
|
|
54
|
+
#destroyed;
|
|
55
|
+
#horizontal;
|
|
56
|
+
#popupRef;
|
|
57
|
+
constructor() {
|
|
58
|
+
this.#destroyRef = inject(DestroyRef);
|
|
59
|
+
this.#document = inject(DOCUMENT);
|
|
60
|
+
this.#injector = inject(Injector);
|
|
61
|
+
this.#popupService = inject(PopupService);
|
|
62
|
+
this.#destroyed = false;
|
|
63
|
+
this.#horizontal = false;
|
|
64
|
+
this.sheetTemplate = viewChild.required("sheetTemplate", /* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [{ debugName: "sheetTemplate" }] : /* istanbul ignore next */ []));
|
|
66
|
+
this.baseClass = computed(() => {
|
|
67
|
+
const variantClass = sheetBaseVariants({ side: this.side() });
|
|
68
|
+
const userClass = classInputToClass(this.userClass());
|
|
69
|
+
return twMerge(variantClass, userClass);
|
|
70
|
+
}, /* @ts-ignore */
|
|
71
|
+
...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
|
|
72
|
+
this.closeButtonClass = computed(() => sheetCloseButtonVariants(), /* @ts-ignore */
|
|
73
|
+
...(ngDevMode ? [{ debugName: "closeButtonClass" }] : /* istanbul ignore next */ []));
|
|
74
|
+
this.contentClass = computed(() => sheetContentVariants(), /* @ts-ignore */
|
|
75
|
+
...(ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []));
|
|
76
|
+
this.descriptionClass = computed(() => sheetDescriptionVariants(), /* @ts-ignore */
|
|
77
|
+
...(ngDevMode ? [{ debugName: "descriptionClass" }] : /* istanbul ignore next */ []));
|
|
78
|
+
this.descriptionId = createElementControlId();
|
|
79
|
+
this.headerClass = computed(() => sheetHeaderVariants(), /* @ts-ignore */
|
|
80
|
+
...(ngDevMode ? [{ debugName: "headerClass" }] : /* istanbul ignore next */ []));
|
|
81
|
+
this.titleClass = computed(() => sheetTitleVariants(), /* @ts-ignore */
|
|
82
|
+
...(ngDevMode ? [{ debugName: "titleClass" }] : /* istanbul ignore next */ []));
|
|
83
|
+
this.titleId = createElementControlId();
|
|
84
|
+
/** @description Accessible name used when no visible title is provided. */
|
|
85
|
+
this.ariaLabel = input(/* @ts-ignore */
|
|
86
|
+
...(ngDevMode ? [undefined, { debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
|
|
87
|
+
/** @description Whether the close button is displayed. @default true */
|
|
88
|
+
this.closable = input(true, /* @ts-ignore */
|
|
89
|
+
...(ngDevMode ? [{ debugName: "closable" }] : /* istanbul ignore next */ []));
|
|
90
|
+
/** @description Emitted before the sheet closes. Call preventDefault() to keep it open. */
|
|
91
|
+
this.close = output();
|
|
92
|
+
/** @description Whether clicking the backdrop requests that the sheet close. @default true */
|
|
93
|
+
this.closeOnBackdropClick = input(true, /* @ts-ignore */
|
|
94
|
+
...(ngDevMode ? [{ debugName: "closeOnBackdropClick" }] : /* istanbul ignore next */ []));
|
|
95
|
+
/** @description Whether pressing Escape requests that the sheet close. @default true */
|
|
96
|
+
this.closeOnEscape = input(true, /* @ts-ignore */
|
|
97
|
+
...(ngDevMode ? [{ debugName: "closeOnEscape" }] : /* istanbul ignore next */ []));
|
|
98
|
+
/** @description Emitted after the leave animation completes and the popup is disposed. */
|
|
99
|
+
this.closed = output();
|
|
100
|
+
/** @description Supporting text displayed below the title. */
|
|
101
|
+
this.description = input(/* @ts-ignore */
|
|
102
|
+
...(ngDevMode ? [undefined, { debugName: "description" }] : /* istanbul ignore next */ []));
|
|
103
|
+
/** @description Explicit sheet height. Numbers are interpreted as pixels. */
|
|
104
|
+
this.height = input(/* @ts-ignore */
|
|
105
|
+
...(ngDevMode ? [undefined, { debugName: "height" }] : /* istanbul ignore next */ []));
|
|
106
|
+
/** @description Edge of the viewport from which the sheet opens. @default "right" */
|
|
107
|
+
this.side = input("right", /* @ts-ignore */
|
|
108
|
+
...(ngDevMode ? [{ debugName: "side" }] : /* istanbul ignore next */ []));
|
|
109
|
+
/** @description Title displayed in the sheet header and used as its accessible name. */
|
|
110
|
+
this.title = input(/* @ts-ignore */
|
|
111
|
+
...(ngDevMode ? [undefined, { debugName: "title" }] : /* istanbul ignore next */ []));
|
|
112
|
+
this.userClass = input(undefined, { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class",
|
|
113
|
+
transform: value => classInputToClass(value) });
|
|
114
|
+
/** @description Explicit sheet width. Numbers are interpreted as pixels. */
|
|
115
|
+
this.width = input(/* @ts-ignore */
|
|
116
|
+
...(ngDevMode ? [undefined, { debugName: "width" }] : /* istanbul ignore next */ []));
|
|
117
|
+
afterNextRender({
|
|
118
|
+
read: () => this.#open()
|
|
119
|
+
});
|
|
120
|
+
this.#destroyRef.onDestroy(() => {
|
|
121
|
+
this.#destroyed = true;
|
|
122
|
+
this.#popupRef?.close();
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
closeSheet() {
|
|
126
|
+
this.#popupRef?.close(new PopupCloseEvent({ via: PopupCloseSource.CloseButton }));
|
|
127
|
+
}
|
|
128
|
+
/** Escape and backdrop clicks reach the popup unconditionally, so their inputs are honoured here. */
|
|
129
|
+
#isSuppressedCloseSource(via) {
|
|
130
|
+
return ((via === PopupCloseSource.Escape && !this.closeOnEscape()) ||
|
|
131
|
+
(via === PopupCloseSource.BackdropClick && !this.closeOnBackdropClick()));
|
|
132
|
+
}
|
|
133
|
+
#open() {
|
|
134
|
+
const activeElement = this.#document.activeElement;
|
|
135
|
+
const anchor = activeElement instanceof HTMLElement ? activeElement : this.#document.body;
|
|
136
|
+
const side = this.side();
|
|
137
|
+
this.#horizontal = side === "left" || side === "right";
|
|
138
|
+
this.#popupRef = this.#popupService.create({
|
|
139
|
+
anchor,
|
|
140
|
+
animation: this.#resolveAnimation(side),
|
|
141
|
+
backdropClass: [
|
|
142
|
+
"fixed",
|
|
143
|
+
"inset-0",
|
|
144
|
+
"bg-background/50",
|
|
145
|
+
"backdrop-blur-xs",
|
|
146
|
+
// Keeps the backdrop fade in step with the sheet's slide-out instead of the CDK default of 400ms.
|
|
147
|
+
"[transition-duration:240ms]!"
|
|
148
|
+
],
|
|
149
|
+
blockScroll: true,
|
|
150
|
+
/*
|
|
151
|
+
* Both close paths are wired up even when the matching input is currently `false`. PopupService
|
|
152
|
+
* decides once, at creation, whether to listen at all, so opting out there would freeze these
|
|
153
|
+
* inputs at their initial values. Vetoing in `beforeClose` instead keeps them live.
|
|
154
|
+
*/
|
|
155
|
+
closeOnBackdropClick: true,
|
|
156
|
+
closeOnEscape: true,
|
|
157
|
+
closeOnOutsideClick: false,
|
|
158
|
+
content: this.sheetTemplate(),
|
|
159
|
+
hasBackdrop: true,
|
|
160
|
+
height: this.#resolveHeight(),
|
|
161
|
+
maxHeight: this.#horizontal ? "100dvh" : "90dvh",
|
|
162
|
+
maxWidth: "100dvw",
|
|
163
|
+
popupClass: "overflow-clip",
|
|
164
|
+
popupWrapperClass: "mona-popup-constrain-height",
|
|
165
|
+
positionStrategy: "global",
|
|
166
|
+
restoreFocus: true,
|
|
167
|
+
width: this.#resolveWidth()
|
|
168
|
+
});
|
|
169
|
+
this.#positionOverlay(this.#popupRef, side);
|
|
170
|
+
this.#trackSize(this.#popupRef);
|
|
171
|
+
this.#popupRef.beforeClose.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
|
|
172
|
+
if (this.#isSuppressedCloseSource(event.via)) {
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!this.#destroyed) {
|
|
177
|
+
this.close.emit(event);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
this.#popupRef.closed.pipe(take(1), takeUntilDestroyed(this.#destroyRef)).subscribe(() => this.closed.emit());
|
|
181
|
+
}
|
|
182
|
+
#positionOverlay(ref, side) {
|
|
183
|
+
const strategy = ref.overlayRef.getConfig().positionStrategy;
|
|
184
|
+
if (!(strategy instanceof GlobalPositionStrategy)) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
switch (side) {
|
|
188
|
+
case "top":
|
|
189
|
+
strategy.top("0").left("0");
|
|
190
|
+
break;
|
|
191
|
+
case "right":
|
|
192
|
+
strategy.top("0").right("0");
|
|
193
|
+
break;
|
|
194
|
+
case "bottom":
|
|
195
|
+
strategy.bottom("0").left("0");
|
|
196
|
+
break;
|
|
197
|
+
case "left":
|
|
198
|
+
strategy.top("0").left("0");
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
ref.overlayRef.updatePosition();
|
|
202
|
+
}
|
|
203
|
+
#resolveAnimation(side) {
|
|
204
|
+
switch (side) {
|
|
205
|
+
case "top":
|
|
206
|
+
return slideFromTopPopupAnimation;
|
|
207
|
+
case "right":
|
|
208
|
+
return slideFromRightPopupAnimation;
|
|
209
|
+
case "bottom":
|
|
210
|
+
return slideFromBottomPopupAnimation;
|
|
211
|
+
case "left":
|
|
212
|
+
return slideFromLeftPopupAnimation;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
#resolveHeight() {
|
|
216
|
+
return this.height() ?? (this.#horizontal ? "100dvh" : "auto");
|
|
217
|
+
}
|
|
218
|
+
#resolveWidth() {
|
|
219
|
+
return this.width() ?? (this.#horizontal ? "min(100dvw, 24rem)" : "100dvw");
|
|
220
|
+
}
|
|
221
|
+
/** Keeps the overlay in sync with later `width`/`height` changes; `side` stays fixed at open time. */
|
|
222
|
+
#trackSize(ref) {
|
|
223
|
+
effect(() => ref.overlayRef.updateSize({ height: this.#resolveHeight(), width: this.#resolveWidth() }), {
|
|
224
|
+
injector: this.#injector
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SheetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
228
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SheetComponent, isStandalone: true, selector: "mona-sheet", inputs: { ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, closable: { classPropertyName: "closable", publicName: "closable", isSignal: true, isRequired: false, transformFunction: null }, closeOnBackdropClick: { classPropertyName: "closeOnBackdropClick", publicName: "closeOnBackdropClick", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "closeOnEscape", isSignal: true, isRequired: false, transformFunction: null }, description: { classPropertyName: "description", publicName: "description", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, side: { classPropertyName: "side", publicName: "side", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", 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: false, transformFunction: null } }, outputs: { close: "close", closed: "closed" }, host: { classAttribute: "hidden" }, viewQueries: [{ propertyName: "sheetTemplate", first: true, predicate: ["sheetTemplate"], descendants: true, isSignal: true }], ngImport: i0, template: "<ng-template #sheetTemplate>\n <section\n cdkTrapFocus\n [cdkTrapFocusAutoCapture]=\"true\"\n [class]=\"baseClass()\"\n role=\"dialog\"\n aria-modal=\"true\"\n tabindex=\"-1\"\n [attr.aria-labelledby]=\"title() ? titleId : null\"\n [attr.aria-describedby]=\"description() ? descriptionId : null\"\n [attr.aria-label]=\"!title() ? ariaLabel() : null\">\n @if (title() || description() || closable()) {\n <header [class]=\"headerClass()\">\n <div class=\"min-w-0 flex-1\">\n @if (title()) {\n <h2 [id]=\"titleId\" [class]=\"titleClass()\">{{ title() }}</h2>\n }\n @if (description()) {\n <p [id]=\"descriptionId\" [class]=\"descriptionClass()\">{{ description() }}</p>\n }\n </div>\n @if (closable()) {\n <button\n monaButton\n type=\"button\"\n look=\"ghost\"\n [iconOnly]=\"true\"\n aria-label=\"Close sheet\"\n size=\"small\"\n [class]=\"closeButtonClass()\"\n (click)=\"closeSheet()\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n }\n </header>\n }\n <div [class]=\"contentClass()\">\n <ng-content></ng-content>\n </div>\n </section>\n</ng-template>\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "class"], outputs: ["disabledChange", "loadingChange", "lookChange", "selectedChange"] }, { kind: "directive", type: CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { kind: "component", type: LucideX, selector: "svg[lucideX]" }] }); }
|
|
229
|
+
}
|
|
230
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SheetComponent, decorators: [{
|
|
231
|
+
type: Component,
|
|
232
|
+
args: [{ selector: "mona-sheet", imports: [ButtonDirective, CdkTrapFocus, LucideX], host: {
|
|
233
|
+
class: "hidden"
|
|
234
|
+
}, template: "<ng-template #sheetTemplate>\n <section\n cdkTrapFocus\n [cdkTrapFocusAutoCapture]=\"true\"\n [class]=\"baseClass()\"\n role=\"dialog\"\n aria-modal=\"true\"\n tabindex=\"-1\"\n [attr.aria-labelledby]=\"title() ? titleId : null\"\n [attr.aria-describedby]=\"description() ? descriptionId : null\"\n [attr.aria-label]=\"!title() ? ariaLabel() : null\">\n @if (title() || description() || closable()) {\n <header [class]=\"headerClass()\">\n <div class=\"min-w-0 flex-1\">\n @if (title()) {\n <h2 [id]=\"titleId\" [class]=\"titleClass()\">{{ title() }}</h2>\n }\n @if (description()) {\n <p [id]=\"descriptionId\" [class]=\"descriptionClass()\">{{ description() }}</p>\n }\n </div>\n @if (closable()) {\n <button\n monaButton\n type=\"button\"\n look=\"ghost\"\n [iconOnly]=\"true\"\n aria-label=\"Close sheet\"\n size=\"small\"\n [class]=\"closeButtonClass()\"\n (click)=\"closeSheet()\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n }\n </header>\n }\n <div [class]=\"contentClass()\">\n <ng-content></ng-content>\n </div>\n </section>\n</ng-template>\n" }]
|
|
235
|
+
}], ctorParameters: () => [], propDecorators: { sheetTemplate: [{ type: i0.ViewChild, args: ["sheetTemplate", { isSignal: true }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], close: [{ type: i0.Output, args: ["close"] }], closeOnBackdropClick: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnBackdropClick", required: false }] }], closeOnEscape: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnEscape", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }], description: [{ type: i0.Input, args: [{ isSignal: true, alias: "description", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], side: [{ type: i0.Input, args: [{ isSignal: true, alias: "side", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }] } });
|
|
236
|
+
|
|
237
|
+
/*
|
|
238
|
+
* Public API Surface of @nanahoshi/mona-ui/sheet
|
|
239
|
+
*/
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Generated bundle index. Do not edit.
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
export { SheetComponent };
|
|
246
|
+
//# sourceMappingURL=nanahoshi-mona-ui-sheet.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nanahoshi/mona-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A very light Angular UI framework",
|
|
5
5
|
"author": "Nanahoshi",
|
|
6
6
|
"repository": {
|
|
@@ -265,6 +265,10 @@
|
|
|
265
265
|
"types": "./types/nanahoshi-mona-ui-scroll-view.d.ts",
|
|
266
266
|
"default": "./fesm2022/nanahoshi-mona-ui-scroll-view.mjs"
|
|
267
267
|
},
|
|
268
|
+
"./sheet": {
|
|
269
|
+
"types": "./types/nanahoshi-mona-ui-sheet.d.ts",
|
|
270
|
+
"default": "./fesm2022/nanahoshi-mona-ui-sheet.mjs"
|
|
271
|
+
},
|
|
268
272
|
"./sidebar": {
|
|
269
273
|
"types": "./types/nanahoshi-mona-ui-sidebar.d.ts",
|
|
270
274
|
"default": "./fesm2022/nanahoshi-mona-ui-sidebar.mjs"
|
|
@@ -134,6 +134,12 @@ interface PopupSettings<T = unknown, C = void> {
|
|
|
134
134
|
* @type {string | string[]}
|
|
135
135
|
*/
|
|
136
136
|
backdropClass?: string | string[];
|
|
137
|
+
/**
|
|
138
|
+
* Whether scrolling behind the popup should be blocked while it is open.
|
|
139
|
+
* Default: false.
|
|
140
|
+
* @type {boolean}
|
|
141
|
+
*/
|
|
142
|
+
blockScroll?: boolean;
|
|
137
143
|
/**
|
|
138
144
|
* The content to display in the popup.
|
|
139
145
|
* @type {TemplateRef | ComponentType}
|
|
@@ -461,6 +467,11 @@ declare class PopupService {
|
|
|
461
467
|
private resolveAnchor;
|
|
462
468
|
private restoreFocusToAnchor;
|
|
463
469
|
private setupBackdropCloseSubscription;
|
|
470
|
+
/**
|
|
471
|
+
* Starts the backdrop fade-out as soon as the close begins, so it runs alongside the popup's leave
|
|
472
|
+
* animation. Without it the backdrop stays fully opaque until `dispose()` removes it in one frame.
|
|
473
|
+
*/
|
|
474
|
+
private setupBackdropFadeOut;
|
|
464
475
|
private setupCleanupSubscription;
|
|
465
476
|
private setupCloseSubscriptions;
|
|
466
477
|
private setupEscapeKeyListener;
|
|
@@ -478,8 +489,12 @@ declare class PopupService {
|
|
|
478
489
|
declare const defaultPopupAnimation: Required<PopupAnimationSettings>;
|
|
479
490
|
declare const dropdownPopupAnimation: Required<PopupAnimationSettings>;
|
|
480
491
|
declare const fadePopupAnimation: Required<PopupAnimationSettings>;
|
|
492
|
+
declare const slideFromRightPopupAnimation: Required<PopupAnimationSettings>;
|
|
493
|
+
declare const slideFromLeftPopupAnimation: Required<PopupAnimationSettings>;
|
|
494
|
+
declare const slideFromTopPopupAnimation: Required<PopupAnimationSettings>;
|
|
495
|
+
declare const slideFromBottomPopupAnimation: Required<PopupAnimationSettings>;
|
|
481
496
|
|
|
482
497
|
declare const PopupDataInjectionToken: InjectionToken<unknown>;
|
|
483
498
|
|
|
484
|
-
export { PopupCloseEvent, PopupCloseSource, PopupComponent, PopupDataInjectionToken, PopupRef, PopupService, defaultPopupAnimation, dropdownPopupAnimation, fadePopupAnimation };
|
|
499
|
+
export { PopupCloseEvent, PopupCloseSource, PopupComponent, PopupDataInjectionToken, PopupRef, PopupService, defaultPopupAnimation, dropdownPopupAnimation, fadePopupAnimation, slideFromBottomPopupAnimation, slideFromLeftPopupAnimation, slideFromRightPopupAnimation, slideFromTopPopupAnimation };
|
|
485
500
|
export type { ConnectionPoint, PopupAnchor, PopupAnimationSettings, PopupOffset, PopupSettings };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { ClassInputType } from '@nanahoshi/mona-ui/common';
|
|
3
|
+
import { PopupCloseEvent } from '@nanahoshi/mona-ui/popup';
|
|
4
|
+
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
5
|
+
import { VariantInputs } from '@nanahoshi/mona-ui/internal';
|
|
6
|
+
import { VariantProps } from 'class-variance-authority';
|
|
7
|
+
|
|
8
|
+
type SheetSide = "top" | "right" | "bottom" | "left";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* `overflow-clip` rather than `overflow-hidden` is deliberate. `hidden` would make the sheet a scroll
|
|
12
|
+
* container, letting the browser scroll it to reveal content that takes focus while the enter animation
|
|
13
|
+
* still has the sheet translated off-screen, which cancels the animation. `clip` cannot scroll.
|
|
14
|
+
*/
|
|
15
|
+
declare const sheetBaseVariants: (props?: ({
|
|
16
|
+
side?: "top" | "right" | "bottom" | "left" | null | undefined;
|
|
17
|
+
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
18
|
+
type SheetVariantProps = VariantProps<typeof sheetBaseVariants>;
|
|
19
|
+
type SheetVariantInput = VariantInputs<SheetVariantProps>;
|
|
20
|
+
|
|
21
|
+
declare class SheetComponent implements SheetVariantInput {
|
|
22
|
+
#private;
|
|
23
|
+
private readonly sheetTemplate;
|
|
24
|
+
protected readonly baseClass: _angular_core.Signal<string>;
|
|
25
|
+
protected readonly closeButtonClass: _angular_core.Signal<string>;
|
|
26
|
+
protected readonly contentClass: _angular_core.Signal<string>;
|
|
27
|
+
protected readonly descriptionClass: _angular_core.Signal<string>;
|
|
28
|
+
protected readonly descriptionId: string;
|
|
29
|
+
protected readonly headerClass: _angular_core.Signal<string>;
|
|
30
|
+
protected readonly titleClass: _angular_core.Signal<string>;
|
|
31
|
+
protected readonly titleId: string;
|
|
32
|
+
/** @description Accessible name used when no visible title is provided. */
|
|
33
|
+
readonly ariaLabel: _angular_core.InputSignal<string | undefined>;
|
|
34
|
+
/** @description Whether the close button is displayed. @default true */
|
|
35
|
+
readonly closable: _angular_core.InputSignal<boolean>;
|
|
36
|
+
/** @description Emitted before the sheet closes. Call preventDefault() to keep it open. */
|
|
37
|
+
readonly close: _angular_core.OutputEmitterRef<PopupCloseEvent<unknown>>;
|
|
38
|
+
/** @description Whether clicking the backdrop requests that the sheet close. @default true */
|
|
39
|
+
readonly closeOnBackdropClick: _angular_core.InputSignal<boolean>;
|
|
40
|
+
/** @description Whether pressing Escape requests that the sheet close. @default true */
|
|
41
|
+
readonly closeOnEscape: _angular_core.InputSignal<boolean>;
|
|
42
|
+
/** @description Emitted after the leave animation completes and the popup is disposed. */
|
|
43
|
+
readonly closed: _angular_core.OutputEmitterRef<void>;
|
|
44
|
+
/** @description Supporting text displayed below the title. */
|
|
45
|
+
readonly description: _angular_core.InputSignal<string | undefined>;
|
|
46
|
+
/** @description Explicit sheet height. Numbers are interpreted as pixels. */
|
|
47
|
+
readonly height: _angular_core.InputSignal<string | number | undefined>;
|
|
48
|
+
/** @description Edge of the viewport from which the sheet opens. @default "right" */
|
|
49
|
+
readonly side: _angular_core.InputSignal<SheetSide>;
|
|
50
|
+
/** @description Title displayed in the sheet header and used as its accessible name. */
|
|
51
|
+
readonly title: _angular_core.InputSignal<string | undefined>;
|
|
52
|
+
readonly userClass: _angular_core.InputSignalWithTransform<string | undefined, ClassInputType>;
|
|
53
|
+
/** @description Explicit sheet width. Numbers are interpreted as pixels. */
|
|
54
|
+
readonly width: _angular_core.InputSignal<string | number | undefined>;
|
|
55
|
+
constructor();
|
|
56
|
+
protected closeSheet(): void;
|
|
57
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<SheetComponent, never>;
|
|
58
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<SheetComponent, "mona-sheet", never, { "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "closable": { "alias": "closable"; "required": false; "isSignal": true; }; "closeOnBackdropClick": { "alias": "closeOnBackdropClick"; "required": false; "isSignal": true; }; "closeOnEscape": { "alias": "closeOnEscape"; "required": false; "isSignal": true; }; "description": { "alias": "description"; "required": false; "isSignal": true; }; "height": { "alias": "height"; "required": false; "isSignal": true; }; "side": { "alias": "side"; "required": false; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "userClass": { "alias": "class"; "required": false; "isSignal": true; }; "width": { "alias": "width"; "required": false; "isSignal": true; }; }, { "close": "close"; "closed": "closed"; }, never, ["*"], true, never>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { SheetComponent };
|
|
62
|
+
export type { SheetSide };
|