mn-angular-lib 2.0.34 → 2.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/fesm2022/mn-angular-lib-alert.mjs +515 -527
  2. package/fesm2022/mn-angular-lib-alert.mjs.map +1 -1
  3. package/fesm2022/mn-angular-lib-bottom-sheet.mjs +264 -357
  4. package/fesm2022/mn-angular-lib-bottom-sheet.mjs.map +1 -1
  5. package/fesm2022/mn-angular-lib-button.mjs +819 -382
  6. package/fesm2022/mn-angular-lib-button.mjs.map +1 -1
  7. package/fesm2022/mn-angular-lib-calendar-core.mjs +240 -365
  8. package/fesm2022/mn-angular-lib-calendar-core.mjs.map +1 -1
  9. package/fesm2022/mn-angular-lib-calendar.mjs +1691 -1545
  10. package/fesm2022/mn-angular-lib-calendar.mjs.map +1 -1
  11. package/fesm2022/mn-angular-lib-collection.mjs +2367 -2796
  12. package/fesm2022/mn-angular-lib-collection.mjs.map +1 -1
  13. package/fesm2022/mn-angular-lib-core.mjs +693 -1241
  14. package/fesm2022/mn-angular-lib-core.mjs.map +1 -1
  15. package/fesm2022/mn-angular-lib-display.mjs +679 -712
  16. package/fesm2022/mn-angular-lib-display.mjs.map +1 -1
  17. package/fesm2022/mn-angular-lib-forms.mjs +3671 -4647
  18. package/fesm2022/mn-angular-lib-forms.mjs.map +1 -1
  19. package/fesm2022/mn-angular-lib-keyboard.mjs +221 -190
  20. package/fesm2022/mn-angular-lib-keyboard.mjs.map +1 -1
  21. package/fesm2022/mn-angular-lib-modal-core.mjs +711 -896
  22. package/fesm2022/mn-angular-lib-modal-core.mjs.map +1 -1
  23. package/fesm2022/mn-angular-lib-modal-ui.mjs +2089 -2035
  24. package/fesm2022/mn-angular-lib-modal-ui.mjs.map +1 -1
  25. package/fesm2022/mn-angular-lib-modal.mjs +76 -121
  26. package/fesm2022/mn-angular-lib-modal.mjs.map +1 -1
  27. package/fesm2022/mn-angular-lib-rich-text-editor.mjs +289 -277
  28. package/fesm2022/mn-angular-lib-rich-text-editor.mjs.map +1 -1
  29. package/fesm2022/mn-angular-lib-segmented.mjs +189 -241
  30. package/fesm2022/mn-angular-lib-segmented.mjs.map +1 -1
  31. package/fesm2022/mn-angular-lib-tab.mjs +409 -642
  32. package/fesm2022/mn-angular-lib-tab.mjs.map +1 -1
  33. package/fesm2022/mn-angular-lib.mjs +16 -29
  34. package/package.json +1 -1
  35. package/types/mn-angular-lib-alert.d.ts +239 -241
  36. package/types/mn-angular-lib-bottom-sheet.d.ts +190 -150
  37. package/types/mn-angular-lib-button.d.ts +319 -317
  38. package/types/mn-angular-lib-calendar-core.d.ts +199 -209
  39. package/types/mn-angular-lib-calendar.d.ts +656 -511
  40. package/types/mn-angular-lib-collection.d.ts +1649 -1585
  41. package/types/mn-angular-lib-core.d.ts +524 -535
  42. package/types/mn-angular-lib-display.d.ts +946 -886
  43. package/types/mn-angular-lib-forms.d.ts +3012 -3013
  44. package/types/mn-angular-lib-keyboard.d.ts +125 -85
  45. package/types/mn-angular-lib-modal-core.d.ts +978 -994
  46. package/types/mn-angular-lib-modal-ui.d.ts +541 -493
  47. package/types/mn-angular-lib-modal.d.ts +24 -27
  48. package/types/mn-angular-lib-rich-text-editor.d.ts +131 -98
  49. package/types/mn-angular-lib-segmented.d.ts +354 -341
  50. package/types/mn-angular-lib-tab.d.ts +345 -336
  51. package/types/mn-angular-lib.d.ts +16 -16
  52. package/fesm2022/mn-angular-lib.mjs.map +0 -1
@@ -1,358 +1,265 @@
1
- import * as i0 from '@angular/core';
2
- import { EventEmitter, inject, ChangeDetectorRef, ElementRef, viewChild, HostBinding, Output, Input, Component } from '@angular/core';
3
- import { NgClass } from '@angular/common';
4
- import { MN_IN_BOTTOM_SHEET } from 'mn-angular-lib/core';
5
-
6
- /**
7
- * A viewport-anchored bottom sheet — the mobile presentation shared by the modal
8
- * shell and the multi-select dropdown.
9
- *
10
- * It owns only the sheet *chrome and gestures*: a bottom-anchored, full-width,
11
- * rounded-top surface with an optional dimming backdrop and drag grabber, a
12
- * slide-up entrance, swipe/flick-to-dismiss, and a promise-based slide-down exit.
13
- * It is deliberately presentational: the body is projected via `<ng-content>`, and
14
- * dismissal is reported through {@link dismiss} for the host to act on (run a close
15
- * guard, tear down its overlay, …) rather than being handled here.
16
- *
17
- * Positioning is `position: fixed` against the viewport, so the host relocates itself
18
- * to `document.body` on init and blocks scrolling behind it while open. Both are
19
- * unconditional: rendering viewport-fixed chrome in place made correctness depend on
20
- * where a consumer happened to write the tag. A `transform`/`filter`/`contain`
21
- * ancestor becomes the containing block and pushes the sheet to the middle of the
22
- * screen — which a *stacked* modal did to its own sheet — and, because `position:
23
- * fixed` moves where an element paints but not where it sits in the DOM, a gesture on
24
- * the backdrop still scrolled whichever ancestor was the scroll container.
25
- *
26
- * The multi-select and dropdown used to do the relocating themselves; that is why the
27
- * behaviour reads as new here but is not new to them.
28
- */
29
- class MnBottomSheet {
30
- /** Tailwind's `sm` breakpoint — at or below this the swipe gesture is armed.
31
- * Kept in step with the same constant in the modal shell and multi-select. */
32
- static SHEET_MAX_WIDTH = 639.98;
33
- /** Drag distance (px) past which a release dismisses regardless of speed. */
34
- static SWIPE_DISMISS_THRESHOLD = 150;
35
- /** Downward release speed (px/ms) above which a short drag still dismisses — a "flick". */
36
- static FLICK_VELOCITY = 0.5;
37
- /** Minimum drag distance (px) a flick must cover, so an incidental fast tap never dismisses. */
38
- static FLICK_MIN_DISTANCE = 32;
39
- /** Upper bound for the exit wait if no `transitionend` fires (e.g. animation suppressed). */
40
- static CLOSE_FALLBACK_MS = 700;
41
- /** Whether to render the dimming backdrop behind the sheet (default: true).
42
- * A host that already paints its own backdrop (the modal shell) sets this false. */
43
- showBackdrop = true;
44
- /** Whether to render the drag grabber handle that arms swipe-to-dismiss (default: true). */
45
- showGrabber = true;
46
- /** Whether the sheet can be dismissed by the user via swipe/flick or backdrop tap
47
- * (default: true). When false the gestures are inert and the backdrop is non-closing. */
48
- dismissible = true;
49
- /** Optional `min-height` floor (px) for the container, so filtering its content
50
- * shorter cannot shrink the sheet mid-interaction. Null leaves it content-sized. */
51
- minHeightPx = null;
52
- /** Cap on the sheet height as a fraction of the viewport, in vh (default: 80). */
53
- maxHeightVh = 80;
54
- /** Extra class(es) applied to the sheet container, so a host can attach the hooks
55
- * its own CSS depends on (e.g. the modal shell's `modal-container`). */
56
- containerClass = '';
57
- /** Accessible name for the sheet dialog. */
58
- ariaLabel;
59
- /** Id of the element that labels this dialog (takes precedence over `ariaLabel`). */
60
- ariaLabelledby;
61
- /**
62
- * When true, the sheet grows to its `maxHeightVh` while the host app marks the soft
63
- * keyboard open (a `.mn-keyboard-open` class on a document ancestor), guaranteeing
64
- * scroll room to lift a focused field above an overlaying keyboard. Off by default so
65
- * a keyboard opened over an unrelated sheet (a multi-select search) does not resize it.
66
- */
67
- growWithKeyboard = false;
68
- /**
69
- * Optional async gate consulted before a user-initiated dismissal (swipe/flick/backdrop
70
- * tap) is committed. Resolving false aborts the dismissal and springs the sheet back —
71
- * used by the modal to run its close guard (e.g. an unsaved-changes prompt). A
72
- * programmatic {@link startClosing} bypasses it.
73
- */
74
- dismissGuard;
75
- /**
76
- * Emitted once the user has dismissed the sheet — after the slide-down exit has
77
- * finished, so the host can remove the sheet from the DOM without cutting the
78
- * animation short. The host decides what dismissal means (close, run a guard, …).
79
- */
80
- dismiss = new EventEmitter();
81
- /** Current downward drag offset (px) applied to the sheet while swiping. */
82
- sheetDragY = 0;
83
- /** True while the user is actively dragging the grabber (disables the snap transition). */
84
- isDraggingSheet = false;
85
- /** True once a dismissal has committed — the sheet glides off-screen via its transition. */
86
- isDismissing = false;
87
- cdr = inject(ChangeDetectorRef);
88
- el = inject(ElementRef);
89
- /** The sheet container element, used to measure its height and drive the exit. */
90
- containerRef = viewChild('container', /* @ts-ignore */
91
- ...(ngDevMode ? [{ debugName: "containerRef" }] : /* istanbul ignore next */ []));
92
- dragStartY = 0;
93
- /** The two most recent (y, timestamp) pointer samples, for estimating flick velocity.
94
- * `t` uses the event timestamp (monotonic), so no wall-clock is read. */
95
- lastSample = null;
96
- prevSample = null;
97
- /** In-flight exit animation, so a swipe-dismiss and a follow-up programmatic
98
- * {@link startClosing} share one glide instead of re-triggering it. */
99
- exitPromise = null;
100
- /** The host node once moved to `document.body`, so it is only detached if we moved it. */
101
- portalledHost = null;
102
- /** Blocks scroll gestures aimed at anything behind the sheet, while it is open. */
103
- scrollGuard = null;
104
- /** Moves the host out to `document.body` and stops the page behind scrolling. */
105
- ngOnInit() {
106
- if (typeof document === 'undefined')
107
- return;
108
- const host = this.el.nativeElement;
109
- document.body.appendChild(host);
110
- this.portalledHost = host;
111
- this.lockScroll();
112
- }
113
- /**
114
- * Stops pointer scrolling behind the sheet for as long as it is open.
115
- *
116
- * Cancels the gesture rather than setting `overflow: hidden` on `document.body`: an
117
- * app whose scroll container is a layout element (a `<main>`, a drawer body) leaves
118
- * `body` unscrollable, so locking it there is a no-op and the page still slides about
119
- * under the sheet. Cancelling `wheel` and `touchmove` before anything acts on them
120
- * holds regardless of which element does the scrolling.
121
- *
122
- * Gestures that begin inside the sheet are let through so its own content still
123
- * scrolls; `overscroll-behavior: contain` keeps those from chaining out at the ends.
124
- *
125
- * Pointer input only. Page Down and the arrows still reach the page behind when focus
126
- * is left there — closing that needs either a key filter or moving focus into the
127
- * sheet, and neither belongs in this change.
128
- */
129
- lockScroll() {
130
- const guard = (event) => {
131
- const target = event.target;
132
- const container = this.containerRef()?.nativeElement;
133
- if (container && target && container.contains(target))
134
- return;
135
- // Only cancellable events can be stopped; a passive listener elsewhere in the
136
- // chain would otherwise log a console error for a no-op preventDefault.
137
- if (event.cancelable)
138
- event.preventDefault();
139
- };
140
- // Capture phase, so the gesture is cancelled before any scroller sees it.
141
- document.addEventListener('wheel', guard, { capture: true, passive: false });
142
- document.addEventListener('touchmove', guard, { capture: true, passive: false });
143
- this.scrollGuard = guard;
144
- }
145
- /** Releases the scroll guard. Idempotent. */
146
- unlockScroll() {
147
- if (!this.scrollGuard)
148
- return;
149
- document.removeEventListener('wheel', this.scrollGuard, { capture: true });
150
- document.removeEventListener('touchmove', this.scrollGuard, { capture: true });
151
- this.scrollGuard = null;
152
- }
153
- /**
154
- * Detaches the relocated host.
155
- *
156
- * Angular tears a view down by removing the nodes it created from their parent; a
157
- * host we moved to `body` is no longer among the parent's children, so without
158
- * this the sheet would outlive the view that declared it.
159
- */
160
- ngOnDestroy() {
161
- this.unlockScroll();
162
- this.portalledHost?.remove();
163
- this.portalledHost = null;
164
- }
165
- get hostClasses() {
166
- return (`mn-bottom-sheet${this.isDismissing ? ' is-dismissing' : ''}` +
167
- `${this.growWithKeyboard ? ' grow-with-keyboard' : ''}`);
168
- }
169
- /** Whether the viewport is currently narrow enough for the sheet to accept a swipe. */
170
- get isNarrow() {
171
- return typeof window === 'undefined' || window.innerWidth <= MnBottomSheet.SHEET_MAX_WIDTH;
172
- }
173
- onSheetPointerDown(event) {
174
- if (!this.dismissible || !this.isNarrow)
175
- return;
176
- // Don't hijack drags that begin on an interactive control inside the sheet.
177
- if (event.target.closest('button, input, textarea, select, a'))
178
- return;
179
- this.isDraggingSheet = true;
180
- this.dragStartY = event.clientY;
181
- // Seed the velocity window so a fast flick that releases on the first move still measures.
182
- this.lastSample = { y: event.clientY, t: event.timeStamp };
183
- this.prevSample = this.lastSample;
184
- event.target.setPointerCapture(event.pointerId);
185
- }
186
- onSheetPointerMove(event) {
187
- if (!this.isDraggingSheet)
188
- return;
189
- // Only track downward movement.
190
- this.sheetDragY = Math.max(0, event.clientY - this.dragStartY);
191
- this.prevSample = this.lastSample;
192
- this.lastSample = { y: event.clientY, t: event.timeStamp };
193
- }
194
- onSheetPointerUp() {
195
- if (!this.isDraggingSheet)
196
- return;
197
- this.isDraggingSheet = false;
198
- if (this.shouldDismiss()) {
199
- void this.attemptDismiss();
200
- }
201
- else {
202
- this.snapBack();
203
- }
204
- this.lastSample = null;
205
- this.prevSample = null;
206
- }
207
- onBackdropClick() {
208
- void this.attemptDismiss();
209
- }
210
- /**
211
- * Plays the slide-down exit and resolves once it has finished. Exposed so a host that
212
- * dismisses the sheet programmatically (not via a gesture) can await the same exit
213
- * before tearing the sheet down. Idempotent: a swipe-dismiss already in flight and a
214
- * subsequent programmatic close share the one glide rather than restarting it.
215
- */
216
- startClosing() {
217
- return this.playExit();
218
- }
219
- /**
220
- * Runs the optional {@link dismissGuard}, then either commits the dismissal (glide out
221
- * + emit) or springs the sheet back if the guard rejects. A non-dismissible sheet never
222
- * gets here from a gesture, but the guard is still short-circuited defensively.
223
- */
224
- async attemptDismiss() {
225
- if (!this.dismissible)
226
- return;
227
- if (this.dismissGuard) {
228
- const allowed = await this.dismissGuard();
229
- if (!allowed) {
230
- this.snapBack();
231
- this.cdr.detectChanges();
232
- return;
233
- }
234
- }
235
- this.commitDismiss();
236
- }
237
- /** Whether the release should dismiss: a long-enough drag OR a fast downward flick. */
238
- shouldDismiss() {
239
- if (this.sheetDragY > MnBottomSheet.SWIPE_DISMISS_THRESHOLD) {
240
- return true;
241
- }
242
- return (this.releaseVelocity() > MnBottomSheet.FLICK_VELOCITY &&
243
- this.sheetDragY > MnBottomSheet.FLICK_MIN_DISTANCE);
244
- }
245
- /** Downward release speed (px/ms) from the last two pointer samples; 0 when unusable. */
246
- releaseVelocity() {
247
- if (!this.lastSample || !this.prevSample)
248
- return 0;
249
- const dt = this.lastSample.t - this.prevSample.t;
250
- if (dt <= 0)
251
- return 0;
252
- return (this.lastSample.y - this.prevSample.y) / dt;
253
- }
254
- /** Springs the sheet back to its resting position after a drag that didn't dismiss. */
255
- snapBack() {
256
- this.sheetDragY = 0;
257
- }
258
- /**
259
- * Commits a dismissal: glides the sheet the rest of the way off-screen, then emits
260
- * {@link dismiss} once the exit animation settles. Continuing the gesture (rather than
261
- * snapping back to 0 first) keeps a swipe feeling like one unbroken motion.
262
- */
263
- commitDismiss() {
264
- void this.playExit().then(() => this.dismiss.emit());
265
- }
266
- /** Commits the exit animation exactly once and returns the shared in-flight promise.
267
- * Short-circuits under reduced motion and falls back to a timeout if no event fires. */
268
- playExit() {
269
- if (this.exitPromise)
270
- return this.exitPromise;
271
- this.isDismissing = true;
272
- this.sheetDragY = window.innerHeight;
273
- this.cdr.detectChanges();
274
- this.exitPromise = this.awaitExit();
275
- return this.exitPromise;
276
- }
277
- /** Waits for the container's exit transition to end, with a reduced-motion short-circuit
278
- * and a fallback timeout so it always resolves. */
279
- awaitExit() {
280
- return new Promise((resolve) => {
281
- if (this.prefersReducedMotion()) {
282
- resolve();
283
- return;
284
- }
285
- const container = this.containerRef()?.nativeElement ??
286
- this.el.nativeElement.querySelector('.mn-sheet-container');
287
- if (!container) {
288
- resolve();
289
- return;
290
- }
291
- let settled = false;
292
- const done = (event) => {
293
- // Ignore end events bubbling up from descendant transitions.
294
- if (event && event.target !== container)
295
- return;
296
- if (settled)
297
- return;
298
- settled = true;
299
- container.removeEventListener('transitionend', done);
300
- clearTimeout(fallback);
301
- resolve();
302
- };
303
- container.addEventListener('transitionend', done);
304
- const fallback = setTimeout(done, MnBottomSheet.CLOSE_FALLBACK_MS);
305
- });
306
- }
307
- prefersReducedMotion() {
308
- return (typeof window !== 'undefined' &&
309
- typeof window.matchMedia === 'function' &&
310
- window.matchMedia('(prefers-reduced-motion: reduce)').matches);
311
- }
312
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnBottomSheet, deps: [], target: i0.ɵɵFactoryTarget.Component });
313
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: MnBottomSheet, isStandalone: true, selector: "mn-bottom-sheet", inputs: { showBackdrop: "showBackdrop", showGrabber: "showGrabber", dismissible: "dismissible", minHeightPx: "minHeightPx", maxHeightVh: "maxHeightVh", containerClass: "containerClass", ariaLabel: "ariaLabel", ariaLabelledby: "ariaLabelledby", growWithKeyboard: "growWithKeyboard", dismissGuard: "dismissGuard" }, outputs: { dismiss: "dismiss" }, host: { properties: { "class": "this.hostClasses" } }, providers: [{ provide: MN_IN_BOTTOM_SHEET, useValue: true }], viewQueries: [{ propertyName: "containerRef", first: true, predicate: ["container"], descendants: true, isSignal: true }], ngImport: i0, template: "@if (showBackdrop) {\n <!-- Dims the page behind the sheet. Tapping it dismisses when the sheet is dismissible. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div (click)=\"onBackdropClick()\" class=\"mn-sheet-backdrop fixed inset-0 z-9998 bg-black/40\"></div>\n}\n\n<div\n #container\n [attr.aria-label]=\"ariaLabelledby ? null : (ariaLabel || null)\"\n [attr.aria-labelledby]=\"ariaLabelledby || null\"\n [class.sheet-dragging]=\"isDraggingSheet\"\n [ngClass]=\"containerClass\"\n [style.--mn-sheet-max]=\"maxHeightVh + 'vh'\"\n [style.max-height.vh]=\"maxHeightVh\"\n [style.min-height.px]=\"minHeightPx\"\n [style.transform]=\"sheetDragY ? 'translateY(' + sheetDragY + 'px)' : null\"\n aria-modal=\"true\"\n class=\"mn-sheet-container fixed inset-x-0 bottom-0 z-9999 flex flex-col bg-base-100 border-t border-base-300 rounded-t-2xl shadow-lg\"\n role=\"dialog\"\n tabindex=\"-1\"\n>\n @if (showGrabber) {\n <!-- Drag handle for swipe-to-dismiss. The gesture is armed on the whole handle;\n drags starting on a control inside the projected content are ignored. -->\n <div\n (pointercancel)=\"onSheetPointerUp()\"\n (pointerdown)=\"onSheetPointerDown($event)\"\n (pointermove)=\"onSheetPointerMove($event)\"\n (pointerup)=\"onSheetPointerUp()\"\n class=\"flex justify-center pt-2 pb-1 touch-none cursor-grab shrink-0\"\n >\n <div class=\"h-1.5 w-10 rounded-full bg-base-300\"></div>\n </div>\n }\n\n <ng-content></ng-content>\n</div>\n", styles: [":host{--mn-sheet-ease: cubic-bezier(.32, .72, 0, 1);display:contents}.mn-sheet-container{padding-bottom:calc(.75rem + env(safe-area-inset-bottom));overscroll-behavior:contain;min-height:0;transition:transform .35s var(--mn-sheet-ease),min-height .25s var(--mn-sheet-ease);animation:mn-sheet-in .35s var(--mn-sheet-ease)}:host(.grow-with-keyboard):host-context(.mn-keyboard-open) .mn-sheet-container{min-height:var(--mn-sheet-max, 92vh)}.mn-sheet-container.sheet-dragging{transition:none}.mn-sheet-backdrop{animation:mn-sheet-backdrop-in .2s ease-out}:host(.is-dismissing) .mn-sheet-container{animation:none}@keyframes mn-sheet-in{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes mn-sheet-backdrop-in{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.mn-sheet-container,.mn-sheet-backdrop{animation-duration:.01ms!important;transition-duration:.01ms!important}}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
314
- }
315
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnBottomSheet, decorators: [{
316
- type: Component,
317
- args: [{ selector: 'mn-bottom-sheet', standalone: true, imports: [NgClass], providers: [{ provide: MN_IN_BOTTOM_SHEET, useValue: true }], template: "@if (showBackdrop) {\n <!-- Dims the page behind the sheet. Tapping it dismisses when the sheet is dismissible. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div (click)=\"onBackdropClick()\" class=\"mn-sheet-backdrop fixed inset-0 z-9998 bg-black/40\"></div>\n}\n\n<div\n #container\n [attr.aria-label]=\"ariaLabelledby ? null : (ariaLabel || null)\"\n [attr.aria-labelledby]=\"ariaLabelledby || null\"\n [class.sheet-dragging]=\"isDraggingSheet\"\n [ngClass]=\"containerClass\"\n [style.--mn-sheet-max]=\"maxHeightVh + 'vh'\"\n [style.max-height.vh]=\"maxHeightVh\"\n [style.min-height.px]=\"minHeightPx\"\n [style.transform]=\"sheetDragY ? 'translateY(' + sheetDragY + 'px)' : null\"\n aria-modal=\"true\"\n class=\"mn-sheet-container fixed inset-x-0 bottom-0 z-9999 flex flex-col bg-base-100 border-t border-base-300 rounded-t-2xl shadow-lg\"\n role=\"dialog\"\n tabindex=\"-1\"\n>\n @if (showGrabber) {\n <!-- Drag handle for swipe-to-dismiss. The gesture is armed on the whole handle;\n drags starting on a control inside the projected content are ignored. -->\n <div\n (pointercancel)=\"onSheetPointerUp()\"\n (pointerdown)=\"onSheetPointerDown($event)\"\n (pointermove)=\"onSheetPointerMove($event)\"\n (pointerup)=\"onSheetPointerUp()\"\n class=\"flex justify-center pt-2 pb-1 touch-none cursor-grab shrink-0\"\n >\n <div class=\"h-1.5 w-10 rounded-full bg-base-300\"></div>\n </div>\n }\n\n <ng-content></ng-content>\n</div>\n", styles: [":host{--mn-sheet-ease: cubic-bezier(.32, .72, 0, 1);display:contents}.mn-sheet-container{padding-bottom:calc(.75rem + env(safe-area-inset-bottom));overscroll-behavior:contain;min-height:0;transition:transform .35s var(--mn-sheet-ease),min-height .25s var(--mn-sheet-ease);animation:mn-sheet-in .35s var(--mn-sheet-ease)}:host(.grow-with-keyboard):host-context(.mn-keyboard-open) .mn-sheet-container{min-height:var(--mn-sheet-max, 92vh)}.mn-sheet-container.sheet-dragging{transition:none}.mn-sheet-backdrop{animation:mn-sheet-backdrop-in .2s ease-out}:host(.is-dismissing) .mn-sheet-container{animation:none}@keyframes mn-sheet-in{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes mn-sheet-backdrop-in{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.mn-sheet-container,.mn-sheet-backdrop{animation-duration:.01ms!important;transition-duration:.01ms!important}}\n"] }]
318
- }], propDecorators: { showBackdrop: [{
319
- type: Input
320
- }], showGrabber: [{
321
- type: Input
322
- }], dismissible: [{
323
- type: Input
324
- }], minHeightPx: [{
325
- type: Input
326
- }], maxHeightVh: [{
327
- type: Input
328
- }], containerClass: [{
329
- type: Input
330
- }], ariaLabel: [{
331
- type: Input
332
- }], ariaLabelledby: [{
333
- type: Input
334
- }], growWithKeyboard: [{
335
- type: Input
336
- }], dismissGuard: [{
337
- type: Input
338
- }], dismiss: [{
339
- type: Output
340
- }], containerRef: [{ type: i0.ViewChild, args: ['container', { isSignal: true }] }], hostClasses: [{
341
- type: HostBinding,
342
- args: ['class']
343
- }] } });
344
-
345
- /**
346
- * Public API of the `mn-angular-lib/bottom-sheet` entry point: the bottom sheet.
347
- *
348
- * Each entry point is its own module in the published package, so a consumer's bundler
349
- * splits it into the chunk that uses it instead of loading the whole library at startup.
350
- * The root `mn-angular-lib` entry re-exports every entry point.
351
- */
352
-
353
- /**
354
- * Generated bundle index. Do not edit.
355
- */
356
-
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectorRef, Component, ElementRef, EventEmitter, HostBinding, Input, Output, inject, viewChild } from "@angular/core";
3
+ import { NgClass } from "@angular/common";
4
+ import { MN_IN_BOTTOM_SHEET } from "mn-angular-lib/core";
5
+ var MnBottomSheet = class MnBottomSheet {
6
+ static SHEET_MAX_WIDTH = 639.98;
7
+ static SWIPE_DISMISS_THRESHOLD = 150;
8
+ static FLICK_VELOCITY = .5;
9
+ static FLICK_MIN_DISTANCE = 32;
10
+ static CLOSE_FALLBACK_MS = 700;
11
+ showBackdrop = true;
12
+ showGrabber = true;
13
+ dismissible = true;
14
+ minHeightPx = null;
15
+ maxHeightVh = 80;
16
+ containerClass = "";
17
+ ariaLabel;
18
+ ariaLabelledby;
19
+ growWithKeyboard = false;
20
+ dismissGuard;
21
+ dismiss = new EventEmitter();
22
+ sheetDragY = 0;
23
+ isDraggingSheet = false;
24
+ isDismissing = false;
25
+ cdr = inject(ChangeDetectorRef);
26
+ el = inject(ElementRef);
27
+ containerRef = viewChild("container", ...ngDevMode ? [{ debugName: "containerRef" }] : /* istanbul ignore next */ []);
28
+ dragStartY = 0;
29
+ lastSample = null;
30
+ prevSample = null;
31
+ exitPromise = null;
32
+ portalledHost = null;
33
+ scrollGuard = null;
34
+ ngOnInit() {
35
+ if (typeof document === "undefined") return;
36
+ const host = this.el.nativeElement;
37
+ document.body.appendChild(host);
38
+ this.portalledHost = host;
39
+ this.lockScroll();
40
+ }
41
+ lockScroll() {
42
+ const guard = (event) => {
43
+ const target = event.target;
44
+ const container = this.containerRef()?.nativeElement;
45
+ if (container && target && container.contains(target)) return;
46
+ if (event.cancelable) event.preventDefault();
47
+ };
48
+ document.addEventListener("wheel", guard, {
49
+ capture: true,
50
+ passive: false
51
+ });
52
+ document.addEventListener("touchmove", guard, {
53
+ capture: true,
54
+ passive: false
55
+ });
56
+ this.scrollGuard = guard;
57
+ }
58
+ unlockScroll() {
59
+ if (!this.scrollGuard) return;
60
+ document.removeEventListener("wheel", this.scrollGuard, { capture: true });
61
+ document.removeEventListener("touchmove", this.scrollGuard, { capture: true });
62
+ this.scrollGuard = null;
63
+ }
64
+ ngOnDestroy() {
65
+ this.unlockScroll();
66
+ this.portalledHost?.remove();
67
+ this.portalledHost = null;
68
+ }
69
+ get hostClasses() {
70
+ return `mn-bottom-sheet${this.isDismissing ? " is-dismissing" : ""}${this.growWithKeyboard ? " grow-with-keyboard" : ""}`;
71
+ }
72
+ get isNarrow() {
73
+ return typeof window === "undefined" || window.innerWidth <= MnBottomSheet.SHEET_MAX_WIDTH;
74
+ }
75
+ onSheetPointerDown(event) {
76
+ if (!this.dismissible || !this.isNarrow) return;
77
+ if (event.target.closest("button, input, textarea, select, a")) return;
78
+ this.isDraggingSheet = true;
79
+ this.dragStartY = event.clientY;
80
+ this.lastSample = {
81
+ y: event.clientY,
82
+ t: event.timeStamp
83
+ };
84
+ this.prevSample = this.lastSample;
85
+ event.target.setPointerCapture(event.pointerId);
86
+ }
87
+ onSheetPointerMove(event) {
88
+ if (!this.isDraggingSheet) return;
89
+ this.sheetDragY = Math.max(0, event.clientY - this.dragStartY);
90
+ this.prevSample = this.lastSample;
91
+ this.lastSample = {
92
+ y: event.clientY,
93
+ t: event.timeStamp
94
+ };
95
+ }
96
+ onSheetPointerUp() {
97
+ if (!this.isDraggingSheet) return;
98
+ this.isDraggingSheet = false;
99
+ if (this.shouldDismiss()) this.attemptDismiss();
100
+ else this.snapBack();
101
+ this.lastSample = null;
102
+ this.prevSample = null;
103
+ }
104
+ onBackdropClick() {
105
+ this.attemptDismiss();
106
+ }
107
+ startClosing() {
108
+ return this.playExit();
109
+ }
110
+ async attemptDismiss() {
111
+ if (!this.dismissible) return;
112
+ if (this.dismissGuard) {
113
+ if (!await this.dismissGuard()) {
114
+ this.snapBack();
115
+ this.cdr.detectChanges();
116
+ return;
117
+ }
118
+ }
119
+ this.commitDismiss();
120
+ }
121
+ shouldDismiss() {
122
+ if (this.sheetDragY > MnBottomSheet.SWIPE_DISMISS_THRESHOLD) return true;
123
+ return this.releaseVelocity() > MnBottomSheet.FLICK_VELOCITY && this.sheetDragY > MnBottomSheet.FLICK_MIN_DISTANCE;
124
+ }
125
+ releaseVelocity() {
126
+ if (!this.lastSample || !this.prevSample) return 0;
127
+ const dt = this.lastSample.t - this.prevSample.t;
128
+ if (dt <= 0) return 0;
129
+ return (this.lastSample.y - this.prevSample.y) / dt;
130
+ }
131
+ snapBack() {
132
+ this.sheetDragY = 0;
133
+ }
134
+ commitDismiss() {
135
+ this.playExit().then(() => this.dismiss.emit());
136
+ }
137
+ playExit() {
138
+ if (this.exitPromise) return this.exitPromise;
139
+ this.isDismissing = true;
140
+ this.sheetDragY = window.innerHeight;
141
+ this.cdr.detectChanges();
142
+ this.exitPromise = this.awaitExit();
143
+ return this.exitPromise;
144
+ }
145
+ awaitExit() {
146
+ return new Promise((resolve) => {
147
+ if (this.prefersReducedMotion()) {
148
+ resolve();
149
+ return;
150
+ }
151
+ const container = this.containerRef()?.nativeElement ?? this.el.nativeElement.querySelector(".mn-sheet-container");
152
+ if (!container) {
153
+ resolve();
154
+ return;
155
+ }
156
+ let settled = false;
157
+ const done = (event) => {
158
+ if (event && event.target !== container) return;
159
+ if (settled) return;
160
+ settled = true;
161
+ container.removeEventListener("transitionend", done);
162
+ clearTimeout(fallback);
163
+ resolve();
164
+ };
165
+ container.addEventListener("transitionend", done);
166
+ const fallback = setTimeout(done, MnBottomSheet.CLOSE_FALLBACK_MS);
167
+ });
168
+ }
169
+ prefersReducedMotion() {
170
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
171
+ }
172
+ static ɵfac = i0.ɵɵngDeclareFactory({
173
+ minVersion: "12.0.0",
174
+ version: "22.2.2",
175
+ ngImport: i0,
176
+ type: MnBottomSheet,
177
+ deps: [],
178
+ target: i0.ɵɵFactoryTarget.Component
179
+ });
180
+ static ɵcmp = i0.ɵɵngDeclareComponent({
181
+ minVersion: "17.0.0",
182
+ version: "22.2.2",
183
+ type: MnBottomSheet,
184
+ isStandalone: true,
185
+ selector: "mn-bottom-sheet",
186
+ inputs: {
187
+ showBackdrop: "showBackdrop",
188
+ showGrabber: "showGrabber",
189
+ dismissible: "dismissible",
190
+ minHeightPx: "minHeightPx",
191
+ maxHeightVh: "maxHeightVh",
192
+ containerClass: "containerClass",
193
+ ariaLabel: "ariaLabel",
194
+ ariaLabelledby: "ariaLabelledby",
195
+ growWithKeyboard: "growWithKeyboard",
196
+ dismissGuard: "dismissGuard"
197
+ },
198
+ outputs: { dismiss: "dismiss" },
199
+ host: { properties: { "class": "this.hostClasses" } },
200
+ providers: [{
201
+ provide: MN_IN_BOTTOM_SHEET,
202
+ useValue: true
203
+ }],
204
+ viewQueries: [{
205
+ propertyName: "containerRef",
206
+ first: true,
207
+ predicate: ["container"],
208
+ descendants: true,
209
+ isSignal: true
210
+ }],
211
+ ngImport: i0,
212
+ template: "@if (showBackdrop) {\n <!-- Dims the page behind the sheet. Tapping it dismisses when the sheet is dismissible. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div (click)=\"onBackdropClick()\" class=\"mn-sheet-backdrop fixed inset-0 z-9998 bg-black/40\"></div>\n}\n\n<div\n #container\n [attr.aria-label]=\"ariaLabelledby ? null : (ariaLabel || null)\"\n [attr.aria-labelledby]=\"ariaLabelledby || null\"\n [class.sheet-dragging]=\"isDraggingSheet\"\n [ngClass]=\"containerClass\"\n [style.--mn-sheet-max]=\"maxHeightVh + 'vh'\"\n [style.max-height.vh]=\"maxHeightVh\"\n [style.min-height.px]=\"minHeightPx\"\n [style.transform]=\"sheetDragY ? 'translateY(' + sheetDragY + 'px)' : null\"\n aria-modal=\"true\"\n class=\"mn-sheet-container fixed inset-x-0 bottom-0 z-9999 flex flex-col bg-base-100 border-t border-base-300 rounded-t-2xl shadow-lg\"\n role=\"dialog\"\n tabindex=\"-1\"\n>\n @if (showGrabber) {\n <!-- Drag handle for swipe-to-dismiss. The gesture is armed on the whole handle;\n drags starting on a control inside the projected content are ignored. -->\n <div\n (pointercancel)=\"onSheetPointerUp()\"\n (pointerdown)=\"onSheetPointerDown($event)\"\n (pointermove)=\"onSheetPointerMove($event)\"\n (pointerup)=\"onSheetPointerUp()\"\n class=\"flex justify-center pt-2 pb-1 touch-none cursor-grab shrink-0\"\n >\n <div class=\"h-1.5 w-10 rounded-full bg-base-300\"></div>\n </div>\n }\n\n <ng-content></ng-content>\n</div>\n",
213
+ styles: [":host{--mn-sheet-ease: cubic-bezier(.32, .72, 0, 1);display:contents}.mn-sheet-container{padding-bottom:calc(.75rem + env(safe-area-inset-bottom));overscroll-behavior:contain;min-height:0;transition:transform .35s var(--mn-sheet-ease),min-height .25s var(--mn-sheet-ease);animation:mn-sheet-in .35s var(--mn-sheet-ease)}:host(.grow-with-keyboard):host-context(.mn-keyboard-open) .mn-sheet-container{min-height:var(--mn-sheet-max, 92vh)}.mn-sheet-container.sheet-dragging{transition:none}.mn-sheet-backdrop{animation:mn-sheet-backdrop-in .2s ease-out}:host(.is-dismissing) .mn-sheet-container{animation:none}@keyframes mn-sheet-in{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes mn-sheet-backdrop-in{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.mn-sheet-container,.mn-sheet-backdrop{animation-duration:.01ms!important;transition-duration:.01ms!important}}\n"],
214
+ dependencies: [{
215
+ kind: "directive",
216
+ type: NgClass,
217
+ selector: "[ngClass]",
218
+ inputs: ["class", "ngClass"]
219
+ }]
220
+ });
221
+ };
222
+ i0.ɵɵngDeclareClassMetadata({
223
+ minVersion: "12.0.0",
224
+ version: "22.2.2",
225
+ ngImport: i0,
226
+ type: MnBottomSheet,
227
+ decorators: [{
228
+ type: Component,
229
+ args: [{
230
+ selector: "mn-bottom-sheet",
231
+ standalone: true,
232
+ imports: [NgClass],
233
+ providers: [{
234
+ provide: MN_IN_BOTTOM_SHEET,
235
+ useValue: true
236
+ }],
237
+ template: "@if (showBackdrop) {\n <!-- Dims the page behind the sheet. Tapping it dismisses when the sheet is dismissible. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div (click)=\"onBackdropClick()\" class=\"mn-sheet-backdrop fixed inset-0 z-9998 bg-black/40\"></div>\n}\n\n<div\n #container\n [attr.aria-label]=\"ariaLabelledby ? null : (ariaLabel || null)\"\n [attr.aria-labelledby]=\"ariaLabelledby || null\"\n [class.sheet-dragging]=\"isDraggingSheet\"\n [ngClass]=\"containerClass\"\n [style.--mn-sheet-max]=\"maxHeightVh + 'vh'\"\n [style.max-height.vh]=\"maxHeightVh\"\n [style.min-height.px]=\"minHeightPx\"\n [style.transform]=\"sheetDragY ? 'translateY(' + sheetDragY + 'px)' : null\"\n aria-modal=\"true\"\n class=\"mn-sheet-container fixed inset-x-0 bottom-0 z-9999 flex flex-col bg-base-100 border-t border-base-300 rounded-t-2xl shadow-lg\"\n role=\"dialog\"\n tabindex=\"-1\"\n>\n @if (showGrabber) {\n <!-- Drag handle for swipe-to-dismiss. The gesture is armed on the whole handle;\n drags starting on a control inside the projected content are ignored. -->\n <div\n (pointercancel)=\"onSheetPointerUp()\"\n (pointerdown)=\"onSheetPointerDown($event)\"\n (pointermove)=\"onSheetPointerMove($event)\"\n (pointerup)=\"onSheetPointerUp()\"\n class=\"flex justify-center pt-2 pb-1 touch-none cursor-grab shrink-0\"\n >\n <div class=\"h-1.5 w-10 rounded-full bg-base-300\"></div>\n </div>\n }\n\n <ng-content></ng-content>\n</div>\n",
238
+ styles: [":host{--mn-sheet-ease: cubic-bezier(.32, .72, 0, 1);display:contents}.mn-sheet-container{padding-bottom:calc(.75rem + env(safe-area-inset-bottom));overscroll-behavior:contain;min-height:0;transition:transform .35s var(--mn-sheet-ease),min-height .25s var(--mn-sheet-ease);animation:mn-sheet-in .35s var(--mn-sheet-ease)}:host(.grow-with-keyboard):host-context(.mn-keyboard-open) .mn-sheet-container{min-height:var(--mn-sheet-max, 92vh)}.mn-sheet-container.sheet-dragging{transition:none}.mn-sheet-backdrop{animation:mn-sheet-backdrop-in .2s ease-out}:host(.is-dismissing) .mn-sheet-container{animation:none}@keyframes mn-sheet-in{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes mn-sheet-backdrop-in{0%{opacity:0}to{opacity:1}}@media(prefers-reduced-motion:reduce){.mn-sheet-container,.mn-sheet-backdrop{animation-duration:.01ms!important;transition-duration:.01ms!important}}\n"]
239
+ }]
240
+ }],
241
+ propDecorators: {
242
+ showBackdrop: [{ type: Input }],
243
+ showGrabber: [{ type: Input }],
244
+ dismissible: [{ type: Input }],
245
+ minHeightPx: [{ type: Input }],
246
+ maxHeightVh: [{ type: Input }],
247
+ containerClass: [{ type: Input }],
248
+ ariaLabel: [{ type: Input }],
249
+ ariaLabelledby: [{ type: Input }],
250
+ growWithKeyboard: [{ type: Input }],
251
+ dismissGuard: [{ type: Input }],
252
+ dismiss: [{ type: Output }],
253
+ containerRef: [{
254
+ type: i0.ViewChild,
255
+ args: ["container", { isSignal: true }]
256
+ }],
257
+ hostClasses: [{
258
+ type: HostBinding,
259
+ args: ["class"]
260
+ }]
261
+ }
262
+ });
357
263
  export { MnBottomSheet };
358
- //# sourceMappingURL=mn-angular-lib-bottom-sheet.mjs.map
264
+
265
+ //# sourceMappingURL=mn-angular-lib-bottom-sheet.mjs.map