@radix-ng/primitives 0.51.0 → 1.0.0-beta.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/fesm2022/radix-ng-primitives-accordion.mjs +105 -38
- package/fesm2022/radix-ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs +221 -129
- package/fesm2022/radix-ng-primitives-alert-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-arrow.mjs +20 -4
- package/fesm2022/radix-ng-primitives-arrow.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-aspect-ratio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-avatar.mjs +54 -61
- package/fesm2022/radix-ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-button.mjs +123 -0
- package/fesm2022/radix-ng-primitives-button.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-calendar.mjs +95 -83
- package/fesm2022/radix-ng-primitives-calendar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-checkbox.mjs +378 -54
- package/fesm2022/radix-ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-collapsible.mjs +182 -81
- package/fesm2022/radix-ng-primitives-collapsible.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-collection.mjs +40 -57
- package/fesm2022/radix-ng-primitives-collection.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-config.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-context-menu.mjs +140 -424
- package/fesm2022/radix-ng-primitives-context-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-core.mjs +845 -744
- package/fesm2022/radix-ng-primitives-core.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-cropper.mjs +288 -308
- package/fesm2022/radix-ng-primitives-cropper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-date-field.mjs +104 -58
- package/fesm2022/radix-ng-primitives-date-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dialog.mjs +655 -327
- package/fesm2022/radix-ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs +70 -46
- package/fesm2022/radix-ng-primitives-dismissable-layer.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-drawer.mjs +960 -0
- package/fesm2022/radix-ng-primitives-drawer.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-editable.mjs +304 -23
- package/fesm2022/radix-ng-primitives-editable.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-field.mjs +363 -0
- package/fesm2022/radix-ng-primitives-field.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-fieldset.mjs +79 -0
- package/fesm2022/radix-ng-primitives-fieldset.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-focus-scope.mjs +23 -8
- package/fesm2022/radix-ng-primitives-focus-scope.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-input.mjs +172 -0
- package/fesm2022/radix-ng-primitives-input.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-label.mjs +6 -6
- package/fesm2022/radix-ng-primitives-label.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menu.mjs +1907 -363
- package/fesm2022/radix-ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-menubar.mjs +290 -162
- package/fesm2022/radix-ng-primitives-menubar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-meter.mjs +271 -0
- package/fesm2022/radix-ng-primitives-meter.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs +1052 -1553
- package/fesm2022/radix-ng-primitives-navigation-menu.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-number-field.mjs +1102 -367
- package/fesm2022/radix-ng-primitives-number-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-pagination.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popover.mjs +978 -989
- package/fesm2022/radix-ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-popper.mjs +111 -44
- package/fesm2022/radix-ng-primitives-popper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-portal.mjs +34 -10
- package/fesm2022/radix-ng-primitives-portal.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-presence.mjs +134 -246
- package/fesm2022/radix-ng-primitives-presence.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-preview-card.mjs +997 -0
- package/fesm2022/radix-ng-primitives-preview-card.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-progress.mjs +223 -84
- package/fesm2022/radix-ng-primitives-progress.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-radio.mjs +191 -51
- package/fesm2022/radix-ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-roving-focus.mjs +96 -50
- package/fesm2022/radix-ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-scroll-area.mjs +923 -0
- package/fesm2022/radix-ng-primitives-scroll-area.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-select.mjs +791 -509
- package/fesm2022/radix-ng-primitives-select.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-separator.mjs +12 -35
- package/fesm2022/radix-ng-primitives-separator.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-slider.mjs +969 -717
- package/fesm2022/radix-ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-stepper.mjs +15 -19
- package/fesm2022/radix-ng-primitives-stepper.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-switch.mjs +125 -113
- package/fesm2022/radix-ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tabs.mjs +390 -108
- package/fesm2022/radix-ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-time-field.mjs +55 -46
- package/fesm2022/radix-ng-primitives-time-field.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toast.mjs +839 -0
- package/fesm2022/radix-ng-primitives-toast.mjs.map +1 -0
- package/fesm2022/radix-ng-primitives-toggle-group.mjs +121 -247
- package/fesm2022/radix-ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toggle.mjs +98 -61
- package/fesm2022/radix-ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-toolbar.mjs +303 -92
- package/fesm2022/radix-ng-primitives-toolbar.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-tooltip.mjs +699 -1072
- package/fesm2022/radix-ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/radix-ng-primitives-visually-hidden.mjs +25 -66
- package/fesm2022/radix-ng-primitives-visually-hidden.mjs.map +1 -1
- package/meter/README.md +3 -0
- package/navigation-menu/README.md +2 -1
- package/package.json +39 -18
- package/portal/README.md +2 -0
- package/preview-card/README.md +3 -0
- package/schematics/collection.json +1 -0
- package/schematics/ng-add/index.d.ts +3 -2
- package/schematics/ng-add/index.js +62 -31
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/package-config.d.ts +4 -2
- package/schematics/ng-add/package-config.js +10 -2
- package/schematics/ng-add/package-config.js.map +1 -1
- package/schematics/ng-add/schema.d.ts +3 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +14 -0
- package/select/README.md +2 -0
- package/types/radix-ng-primitives-accordion.d.ts +51 -16
- package/types/radix-ng-primitives-alert-dialog.d.ts +95 -38
- package/types/radix-ng-primitives-arrow.d.ts +1 -1
- package/types/radix-ng-primitives-aspect-ratio.d.ts +1 -1
- package/types/radix-ng-primitives-avatar.d.ts +7 -11
- package/types/radix-ng-primitives-button.d.ts +73 -0
- package/types/radix-ng-primitives-calendar.d.ts +39 -20
- package/types/radix-ng-primitives-checkbox.d.ts +204 -35
- package/types/radix-ng-primitives-collapsible.d.ts +114 -40
- package/types/radix-ng-primitives-collection.d.ts +38 -34
- package/types/radix-ng-primitives-config.d.ts +1 -1
- package/types/radix-ng-primitives-context-menu.d.ts +61 -116
- package/types/radix-ng-primitives-core.d.ts +345 -235
- package/types/radix-ng-primitives-cropper.d.ts +89 -56
- package/types/radix-ng-primitives-date-field.d.ts +49 -28
- package/types/radix-ng-primitives-dialog.d.ts +283 -165
- package/types/radix-ng-primitives-dismissable-layer.d.ts +15 -7
- package/types/radix-ng-primitives-drawer.d.ts +426 -0
- package/types/radix-ng-primitives-editable.d.ts +91 -14
- package/types/radix-ng-primitives-field.d.ts +374 -0
- package/types/radix-ng-primitives-fieldset.d.ts +49 -0
- package/types/radix-ng-primitives-focus-scope.d.ts +15 -6
- package/types/radix-ng-primitives-input.d.ts +87 -0
- package/types/radix-ng-primitives-label.d.ts +0 -1
- package/types/radix-ng-primitives-menu.d.ts +584 -99
- package/types/radix-ng-primitives-menubar.d.ts +61 -50
- package/types/radix-ng-primitives-meter.d.ts +194 -0
- package/types/radix-ng-primitives-navigation-menu.d.ts +422 -340
- package/types/radix-ng-primitives-number-field.d.ts +405 -145
- package/types/radix-ng-primitives-pagination.d.ts +2 -2
- package/types/radix-ng-primitives-popover.d.ts +366 -351
- package/types/radix-ng-primitives-popper.d.ts +68 -11
- package/types/radix-ng-primitives-portal.d.ts +14 -6
- package/types/radix-ng-primitives-presence.d.ts +28 -76
- package/types/radix-ng-primitives-preview-card.d.ts +359 -0
- package/types/radix-ng-primitives-progress.d.ts +175 -48
- package/types/radix-ng-primitives-radio.d.ts +55 -25
- package/types/radix-ng-primitives-roving-focus.d.ts +33 -23
- package/types/radix-ng-primitives-scroll-area.d.ts +253 -0
- package/types/radix-ng-primitives-select.d.ts +475 -177
- package/types/radix-ng-primitives-separator.d.ts +7 -32
- package/types/radix-ng-primitives-slider.d.ts +315 -201
- package/types/radix-ng-primitives-stepper.d.ts +5 -7
- package/types/radix-ng-primitives-switch.d.ts +86 -71
- package/types/radix-ng-primitives-tabs.d.ts +213 -79
- package/types/radix-ng-primitives-time-field.d.ts +42 -27
- package/types/radix-ng-primitives-toast.d.ts +378 -0
- package/types/radix-ng-primitives-toggle-group.d.ts +86 -164
- package/types/radix-ng-primitives-toggle.d.ts +43 -53
- package/types/radix-ng-primitives-toolbar.d.ts +164 -38
- package/types/radix-ng-primitives-tooltip.d.ts +348 -384
- package/types/radix-ng-primitives-visually-hidden.d.ts +19 -19
- package/dropdown-menu/README.md +0 -1
- package/fesm2022/radix-ng-primitives-dropdown-menu.mjs +0 -581
- package/fesm2022/radix-ng-primitives-dropdown-menu.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-hover-card.mjs +0 -1238
- package/fesm2022/radix-ng-primitives-hover-card.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-select2.mjs +0 -897
- package/fesm2022/radix-ng-primitives-select2.mjs.map +0 -1
- package/fesm2022/radix-ng-primitives-tooltip2.mjs +0 -735
- package/fesm2022/radix-ng-primitives-tooltip2.mjs.map +0 -1
- package/hover-card/README.md +0 -3
- package/select2/README.md +0 -3
- package/tooltip2/README.md +0 -3
- package/types/radix-ng-primitives-dropdown-menu.d.ts +0 -171
- package/types/radix-ng-primitives-hover-card.d.ts +0 -471
- package/types/radix-ng-primitives-select2.d.ts +0 -511
- package/types/radix-ng-primitives-tooltip2.d.ts +0 -325
|
@@ -0,0 +1,960 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { signal, computed, Injectable, Directive, inject, input, model, booleanAttribute, output, effect, untracked, assertInInjectionContext, DestroyRef, ElementRef, Injector, NgModule } from '@angular/core';
|
|
3
|
+
import * as i1 from '@radix-ng/primitives/dialog';
|
|
4
|
+
import { RdxDialogRoot, RdxDialogBackdrop, RdxDialogClose, RdxDialogDescription, injectRdxDialogRootContext, RdxDialogPopup, RdxDialogPortal, RdxDialogPortalPresence, RdxDialogTitle, RdxDialogTrigger, RdxDialogViewport, RdxDialogHandle, createRdxDialogHandle } from '@radix-ng/primitives/dialog';
|
|
5
|
+
import { createContext, clamp, usePointerDrag, elementSize } from '@radix-ng/primitives/core';
|
|
6
|
+
export { usePointerDrag } from '@radix-ng/primitives/core';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* App-level coordinator that tracks every open drawer so background content can react to them
|
|
10
|
+
* (the page-scale / indent effect). Provide it once near the app root with
|
|
11
|
+
* {@link provideRdxDrawerProvider} or the `[rdxDrawerProvider]` directive; drawers that find it in
|
|
12
|
+
* their injector register while open. It is optional — drawers work without it.
|
|
13
|
+
*/
|
|
14
|
+
class RdxDrawerProvider {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.stack = signal([], ...(ngDevMode ? [{ debugName: "stack" }] : /* istanbul ignore next */ []));
|
|
17
|
+
/** Number of open drawers. */
|
|
18
|
+
this.count = computed(() => this.stack().length, ...(ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []));
|
|
19
|
+
/** Whether any drawer is open. */
|
|
20
|
+
this.active = computed(() => this.count() > 0, ...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
|
|
21
|
+
/** The most recently opened (frontmost) drawer, or `null`. */
|
|
22
|
+
this.frontmost = computed(() => this.stack().at(-1) ?? null, ...(ngDevMode ? [{ debugName: "frontmost" }] : /* istanbul ignore next */ []));
|
|
23
|
+
/** The frontmost drawer's measured size (px), or `0` when none is open. */
|
|
24
|
+
this.frontmostHeight = computed(() => this.frontmost()?.height() ?? 0, ...(ngDevMode ? [{ debugName: "frontmostHeight" }] : /* istanbul ignore next */ []));
|
|
25
|
+
}
|
|
26
|
+
/** Register an open drawer; returns a disposer that removes it. */
|
|
27
|
+
register(registration) {
|
|
28
|
+
this.stack.update((stack) => [...stack, registration]);
|
|
29
|
+
return () => this.stack.update((stack) => stack.filter((entry) => entry !== registration));
|
|
30
|
+
}
|
|
31
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
32
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerProvider }); }
|
|
33
|
+
}
|
|
34
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerProvider, decorators: [{
|
|
35
|
+
type: Injectable
|
|
36
|
+
}] });
|
|
37
|
+
/** Provide a {@link RdxDrawerProvider} for an app (e.g. in `app.config.ts`). */
|
|
38
|
+
function provideRdxDrawerProvider() {
|
|
39
|
+
return [RdxDrawerProvider];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Hosts a {@link RdxDrawerProvider} for its subtree. Put it on a wrapping element so descendant
|
|
43
|
+
* drawer roots and `rdxDrawerIndent*` parts share one coordinator.
|
|
44
|
+
*/
|
|
45
|
+
class RdxDrawerProviderDirective {
|
|
46
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerProviderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
47
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerProviderDirective, isStandalone: true, selector: "[rdxDrawerProvider]", providers: [RdxDrawerProvider], exportAs: ["rdxDrawerProvider"], ngImport: i0 }); }
|
|
48
|
+
}
|
|
49
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerProviderDirective, decorators: [{
|
|
50
|
+
type: Directive,
|
|
51
|
+
args: [{
|
|
52
|
+
selector: '[rdxDrawerProvider]',
|
|
53
|
+
exportAs: 'rdxDrawerProvider',
|
|
54
|
+
providers: [RdxDrawerProvider]
|
|
55
|
+
}]
|
|
56
|
+
}] });
|
|
57
|
+
|
|
58
|
+
const [injectRdxDrawerRootContext, provideRdxDrawerRootContext] = createContext('RdxDrawerRootContext');
|
|
59
|
+
const context = () => {
|
|
60
|
+
const root = inject(RdxDrawerRoot);
|
|
61
|
+
return {
|
|
62
|
+
swipeDirection: root.swipeDirection,
|
|
63
|
+
swipeProgress: root.swipeProgress.asReadonly(),
|
|
64
|
+
setSwipeProgress: (value) => root.swipeProgress.set(value),
|
|
65
|
+
snapPoints: root.normalizedSnapPoints,
|
|
66
|
+
hasSnapPoints: root.hasSnapPoints,
|
|
67
|
+
activeSnapPoint: root.snapPoint,
|
|
68
|
+
sequentialSnap: root.snapToSequentialPoints,
|
|
69
|
+
setActiveSnapPoint: (value, emit) => root.setActiveSnapPoint(value, emit),
|
|
70
|
+
nestedDrawerOpen: root.nestedDrawerOpen,
|
|
71
|
+
nestedDrawerCount: root.nestedDrawerCount,
|
|
72
|
+
frontmostHeight: root.frontmostHeight,
|
|
73
|
+
reportPopupHeight: (height) => root.popupHeight.set(height)
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Groups all parts of the drawer.
|
|
78
|
+
*
|
|
79
|
+
* Composes the Dialog primitive directly (modal-by-default but user-overridable) and layers the
|
|
80
|
+
* drawer-specific swipe and snap-point contract on top via {@link RdxDrawerRootContext}. Modality,
|
|
81
|
+
* dismissal and detached-trigger handling are the dialog's: the `modal`, `disablePointerDismissal`
|
|
82
|
+
* and `handle` inputs are proxied straight through, so a drawer is a modal dialog the user can make
|
|
83
|
+
* non-modal.
|
|
84
|
+
*/
|
|
85
|
+
class RdxDrawerRoot {
|
|
86
|
+
constructor() {
|
|
87
|
+
this.dialog = inject(RdxDialogRoot);
|
|
88
|
+
this.provider = inject(RdxDrawerProvider, { optional: true });
|
|
89
|
+
/** The popup's measured size (px) along its dismiss axis, reported by the popup. */
|
|
90
|
+
this.popupHeight = signal(0, ...(ngDevMode ? [{ debugName: "popupHeight" }] : /* istanbul ignore next */ []));
|
|
91
|
+
/**
|
|
92
|
+
* Direction a swipe travels to dismiss the drawer. The visual side of the drawer is consumer
|
|
93
|
+
* CSS; this controls the dismiss gesture and the `data-swipe-direction` styling hook.
|
|
94
|
+
*/
|
|
95
|
+
this.swipeDirection = input('down', ...(ngDevMode ? [{ debugName: "swipeDirection" }] : /* istanbul ignore next */ []));
|
|
96
|
+
/**
|
|
97
|
+
* Resting positions the drawer snaps to along the dismiss axis. Order ascending by openness; the
|
|
98
|
+
* last entry is the default the drawer opens to. Omit for a plain open/closed drawer.
|
|
99
|
+
*/
|
|
100
|
+
this.snapPoints = input(...(ngDevMode ? [undefined, { debugName: "snapPoints" }] : /* istanbul ignore next */ []));
|
|
101
|
+
/** The active snap point (controlled / uncontrolled with `[(snapPoint)]`). */
|
|
102
|
+
this.snapPoint = model(null, ...(ngDevMode ? [{ debugName: "snapPoint" }] : /* istanbul ignore next */ []));
|
|
103
|
+
/** The snap point the drawer opens to when uncontrolled; defaults to the most open point. */
|
|
104
|
+
this.defaultSnapPoint = input(...(ngDevMode ? [undefined, { debugName: "defaultSnapPoint" }] : /* istanbul ignore next */ []));
|
|
105
|
+
/** Step at most one snap point per release instead of letting velocity skip points. */
|
|
106
|
+
this.snapToSequentialPoints = input(false, { ...(ngDevMode ? { debugName: "snapToSequentialPoints" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
107
|
+
/** Emits when the active snap point changes through a gesture. */
|
|
108
|
+
this.onSnapPointChange = output();
|
|
109
|
+
/** 0..1 progress of the active dismiss gesture, written by the popup's swipe engine. */
|
|
110
|
+
this.swipeProgress = signal(0, ...(ngDevMode ? [{ debugName: "swipeProgress" }] : /* istanbul ignore next */ []));
|
|
111
|
+
this.normalizedSnapPoints = computed(() => this.snapPoints() ?? [], ...(ngDevMode ? [{ debugName: "normalizedSnapPoints" }] : /* istanbul ignore next */ []));
|
|
112
|
+
this.hasSnapPoints = computed(() => this.normalizedSnapPoints().length > 0, ...(ngDevMode ? [{ debugName: "hasSnapPoints" }] : /* istanbul ignore next */ []));
|
|
113
|
+
/** Whether a drawer nested inside this one is open (reuses the dialog's nesting detection). */
|
|
114
|
+
this.nestedDrawerOpen = this.dialog.nestedDialogOpen;
|
|
115
|
+
/** Number of open drawers nested inside this one. */
|
|
116
|
+
this.nestedDrawerCount = this.dialog.nestedOpenCount.asReadonly();
|
|
117
|
+
/** The app-wide frontmost drawer's measured size (px); `0` without a provider. */
|
|
118
|
+
this.frontmostHeight = computed(() => this.provider?.frontmostHeight() ?? 0, ...(ngDevMode ? [{ debugName: "frontmostHeight" }] : /* istanbul ignore next */ []));
|
|
119
|
+
/** Whether the drawer is open (read-only mirror of the composed dialog state). */
|
|
120
|
+
this.open = this.dialog.open;
|
|
121
|
+
/** The active trigger's id. */
|
|
122
|
+
this.triggerId = this.dialog.triggerId;
|
|
123
|
+
/** Payload of the active trigger. */
|
|
124
|
+
this.payload = this.dialog.payload;
|
|
125
|
+
// Apply the default snap point when opening without one set. The active snap point is left
|
|
126
|
+
// untouched on close: clearing it would clobber a controlled `[(snapPoint)]` binding, and an
|
|
127
|
+
// uncontrolled drawer simply reopens where it was left.
|
|
128
|
+
effect(() => {
|
|
129
|
+
const open = this.dialog.open();
|
|
130
|
+
untracked(() => {
|
|
131
|
+
const points = this.normalizedSnapPoints();
|
|
132
|
+
if (open && this.snapPoint() === null && points.length > 0) {
|
|
133
|
+
this.snapPoint.set(this.defaultSnapPoint() ?? points[points.length - 1]);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
// Reset live swipe progress when closed so a reopened drawer never starts mid-gesture.
|
|
138
|
+
effect(() => {
|
|
139
|
+
if (!this.dialog.open()) {
|
|
140
|
+
untracked(() => this.swipeProgress.set(0));
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
// Register with the optional app-level provider while open so background content can react.
|
|
144
|
+
effect((onCleanup) => {
|
|
145
|
+
if (this.dialog.open() && this.provider) {
|
|
146
|
+
onCleanup(untracked(() => this.provider.register({ id: this.dialog.contentId, height: this.popupHeight.asReadonly() })));
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
setActiveSnapPoint(value, emit) {
|
|
151
|
+
this.snapPoint.set(value);
|
|
152
|
+
if (emit) {
|
|
153
|
+
this.onSnapPointChange.emit(value);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerRoot, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
157
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxDrawerRoot, isStandalone: true, selector: "[rdxDrawerRoot]", inputs: { swipeDirection: { classPropertyName: "swipeDirection", publicName: "swipeDirection", isSignal: true, isRequired: false, transformFunction: null }, snapPoints: { classPropertyName: "snapPoints", publicName: "snapPoints", isSignal: true, isRequired: false, transformFunction: null }, snapPoint: { classPropertyName: "snapPoint", publicName: "snapPoint", isSignal: true, isRequired: false, transformFunction: null }, defaultSnapPoint: { classPropertyName: "defaultSnapPoint", publicName: "defaultSnapPoint", isSignal: true, isRequired: false, transformFunction: null }, snapToSequentialPoints: { classPropertyName: "snapToSequentialPoints", publicName: "snapToSequentialPoints", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { snapPoint: "snapPointChange", onSnapPointChange: "onSnapPointChange" }, providers: [provideRdxDrawerRootContext(context)], exportAs: ["rdxDrawerRoot"], hostDirectives: [{ directive: i1.RdxDialogRoot, inputs: ["open", "open", "defaultOpen", "defaultOpen", "triggerId", "triggerId", "defaultTriggerId", "defaultTriggerId", "handle", "handle", "modal", "modal", "disablePointerDismissal", "disablePointerDismissal"], outputs: ["openChange", "openChange", "triggerIdChange", "triggerIdChange", "onOpenChange", "onOpenChange", "onOpenChangeComplete", "onOpenChangeComplete"] }], ngImport: i0 }); }
|
|
158
|
+
}
|
|
159
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerRoot, decorators: [{
|
|
160
|
+
type: Directive,
|
|
161
|
+
args: [{
|
|
162
|
+
selector: '[rdxDrawerRoot]',
|
|
163
|
+
exportAs: 'rdxDrawerRoot',
|
|
164
|
+
hostDirectives: [
|
|
165
|
+
{
|
|
166
|
+
directive: RdxDialogRoot,
|
|
167
|
+
inputs: [
|
|
168
|
+
'open',
|
|
169
|
+
'defaultOpen',
|
|
170
|
+
'triggerId',
|
|
171
|
+
'defaultTriggerId',
|
|
172
|
+
'handle',
|
|
173
|
+
'modal',
|
|
174
|
+
'disablePointerDismissal'
|
|
175
|
+
],
|
|
176
|
+
outputs: ['openChange', 'triggerIdChange', 'onOpenChange', 'onOpenChangeComplete']
|
|
177
|
+
}
|
|
178
|
+
],
|
|
179
|
+
providers: [provideRdxDrawerRootContext(context)]
|
|
180
|
+
}]
|
|
181
|
+
}], ctorParameters: () => [], propDecorators: { swipeDirection: [{ type: i0.Input, args: [{ isSignal: true, alias: "swipeDirection", required: false }] }], snapPoints: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapPoints", required: false }] }], snapPoint: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapPoint", required: false }] }, { type: i0.Output, args: ["snapPointChange"] }], defaultSnapPoint: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultSnapPoint", required: false }] }], snapToSequentialPoints: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapToSequentialPoints", required: false }] }], onSnapPointChange: [{ type: i0.Output, args: ["onSnapPointChange"] }] } });
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* An overlay displayed beneath the drawer popup.
|
|
185
|
+
*
|
|
186
|
+
* Composes the dialog backdrop and additionally exposes `--drawer-swipe-progress` (0..1) so the
|
|
187
|
+
* consumer can fade it in step with the dismiss gesture.
|
|
188
|
+
*/
|
|
189
|
+
class RdxDrawerBackdrop {
|
|
190
|
+
constructor() {
|
|
191
|
+
this.drawerContext = injectRdxDrawerRootContext();
|
|
192
|
+
}
|
|
193
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerBackdrop, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
194
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerBackdrop, isStandalone: true, selector: "[rdxDrawerBackdrop]", host: { properties: { "style.--drawer-swipe-progress": "drawerContext.swipeProgress()", "attr.data-nested-drawer-open": "drawerContext.nestedDrawerOpen() ? \"\" : undefined" } }, exportAs: ["rdxDrawerBackdrop"], hostDirectives: [{ directive: i1.RdxDialogBackdrop }], ngImport: i0 }); }
|
|
195
|
+
}
|
|
196
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerBackdrop, decorators: [{
|
|
197
|
+
type: Directive,
|
|
198
|
+
args: [{
|
|
199
|
+
selector: '[rdxDrawerBackdrop]',
|
|
200
|
+
exportAs: 'rdxDrawerBackdrop',
|
|
201
|
+
hostDirectives: [RdxDialogBackdrop],
|
|
202
|
+
host: {
|
|
203
|
+
'[style.--drawer-swipe-progress]': 'drawerContext.swipeProgress()',
|
|
204
|
+
'[attr.data-nested-drawer-open]': 'drawerContext.nestedDrawerOpen() ? "" : undefined'
|
|
205
|
+
}
|
|
206
|
+
}]
|
|
207
|
+
}] });
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A button that closes the drawer.
|
|
211
|
+
*/
|
|
212
|
+
class RdxDrawerClose {
|
|
213
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerClose, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
214
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerClose, isStandalone: true, selector: "button[rdxDrawerClose]", exportAs: ["rdxDrawerClose"], hostDirectives: [{ directive: i1.RdxDialogClose }], ngImport: i0 }); }
|
|
215
|
+
}
|
|
216
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerClose, decorators: [{
|
|
217
|
+
type: Directive,
|
|
218
|
+
args: [{
|
|
219
|
+
selector: 'button[rdxDrawerClose]',
|
|
220
|
+
exportAs: 'rdxDrawerClose',
|
|
221
|
+
hostDirectives: [RdxDialogClose]
|
|
222
|
+
}]
|
|
223
|
+
}] });
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The scrollable body of the drawer.
|
|
227
|
+
*
|
|
228
|
+
* A structural marker so the anatomy matches Base UI. The popup's swipe engine yields to scrolling
|
|
229
|
+
* inside this region automatically (it only starts a dismiss gesture when the scroll is at its
|
|
230
|
+
* edge), so no extra wiring is needed. Opt individual elements out of swiping with the
|
|
231
|
+
* `data-base-ui-swipe-ignore` attribute.
|
|
232
|
+
*/
|
|
233
|
+
class RdxDrawerContent {
|
|
234
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerContent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
235
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerContent, isStandalone: true, selector: "[rdxDrawerContent]", exportAs: ["rdxDrawerContent"], ngImport: i0 }); }
|
|
236
|
+
}
|
|
237
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerContent, decorators: [{
|
|
238
|
+
type: Directive,
|
|
239
|
+
args: [{
|
|
240
|
+
selector: '[rdxDrawerContent]',
|
|
241
|
+
exportAs: 'rdxDrawerContent'
|
|
242
|
+
}]
|
|
243
|
+
}] });
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* An accessible description announced when the drawer is opened.
|
|
247
|
+
*/
|
|
248
|
+
class RdxDrawerDescription {
|
|
249
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerDescription, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
250
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerDescription, isStandalone: true, selector: "[rdxDrawerDescription]", exportAs: ["rdxDrawerDescription"], hostDirectives: [{ directive: i1.RdxDialogDescription }], ngImport: i0 }); }
|
|
251
|
+
}
|
|
252
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerDescription, decorators: [{
|
|
253
|
+
type: Directive,
|
|
254
|
+
args: [{
|
|
255
|
+
selector: '[rdxDrawerDescription]',
|
|
256
|
+
exportAs: 'rdxDrawerDescription',
|
|
257
|
+
hostDirectives: [RdxDialogDescription]
|
|
258
|
+
}]
|
|
259
|
+
}] });
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Background content that scales/indents while any drawer is open.
|
|
263
|
+
*
|
|
264
|
+
* Reads the nearest {@link RdxDrawerProvider} and exposes styling hooks; the visual transform is
|
|
265
|
+
* consumer CSS (headless):
|
|
266
|
+
* - `[data-active]` — present while at least one drawer is open.
|
|
267
|
+
* - `--nested-drawers` — the number of open drawers.
|
|
268
|
+
* - `--drawer-frontmost-height` — the frontmost drawer's measured size, in pixels.
|
|
269
|
+
*/
|
|
270
|
+
class RdxDrawerIndent {
|
|
271
|
+
constructor() {
|
|
272
|
+
this.provider = inject(RdxDrawerProvider, { optional: true });
|
|
273
|
+
}
|
|
274
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerIndent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
275
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerIndent, isStandalone: true, selector: "[rdxDrawerIndent]", host: { properties: { "attr.data-active": "provider?.active() ? \"\" : undefined", "style.--nested-drawers": "provider?.count() ?? 0", "style.--drawer-frontmost-height": "(provider?.frontmostHeight() ?? 0) + \"px\"" } }, exportAs: ["rdxDrawerIndent"], ngImport: i0 }); }
|
|
276
|
+
}
|
|
277
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerIndent, decorators: [{
|
|
278
|
+
type: Directive,
|
|
279
|
+
args: [{
|
|
280
|
+
selector: '[rdxDrawerIndent]',
|
|
281
|
+
exportAs: 'rdxDrawerIndent',
|
|
282
|
+
host: {
|
|
283
|
+
'[attr.data-active]': 'provider?.active() ? "" : undefined',
|
|
284
|
+
'[style.--nested-drawers]': 'provider?.count() ?? 0',
|
|
285
|
+
'[style.--drawer-frontmost-height]': '(provider?.frontmostHeight() ?? 0) + "px"'
|
|
286
|
+
}
|
|
287
|
+
}]
|
|
288
|
+
}] });
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* The page background layer that scales/indents while any drawer is open.
|
|
292
|
+
*
|
|
293
|
+
* Behaves like {@link RdxDrawerIndent} (same `[data-active]` / `--nested-drawers` /
|
|
294
|
+
* `--drawer-frontmost-height` contract); kept as a distinct part so the page backdrop and the
|
|
295
|
+
* indented content can be styled independently, mirroring Base UI.
|
|
296
|
+
*/
|
|
297
|
+
class RdxDrawerIndentBackground {
|
|
298
|
+
constructor() {
|
|
299
|
+
this.provider = inject(RdxDrawerProvider, { optional: true });
|
|
300
|
+
}
|
|
301
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerIndentBackground, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
302
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerIndentBackground, isStandalone: true, selector: "[rdxDrawerIndentBackground]", host: { properties: { "attr.data-active": "provider?.active() ? \"\" : undefined", "style.--nested-drawers": "provider?.count() ?? 0", "style.--drawer-frontmost-height": "(provider?.frontmostHeight() ?? 0) + \"px\"" } }, exportAs: ["rdxDrawerIndentBackground"], ngImport: i0 }); }
|
|
303
|
+
}
|
|
304
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerIndentBackground, decorators: [{
|
|
305
|
+
type: Directive,
|
|
306
|
+
args: [{
|
|
307
|
+
selector: '[rdxDrawerIndentBackground]',
|
|
308
|
+
exportAs: 'rdxDrawerIndentBackground',
|
|
309
|
+
host: {
|
|
310
|
+
'[attr.data-active]': 'provider?.active() ? "" : undefined',
|
|
311
|
+
'[style.--nested-drawers]': 'provider?.count() ?? 0',
|
|
312
|
+
'[style.--drawer-frontmost-height]': '(provider?.frontmostHeight() ?? 0) + "px"'
|
|
313
|
+
}
|
|
314
|
+
}]
|
|
315
|
+
}] });
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Resolve a snap point to the number of pixels of the drawer revealed at that point. `rootFontSize`
|
|
319
|
+
* (px) resolves `rem` units; it defaults to the CSS initial value of `16`.
|
|
320
|
+
*/
|
|
321
|
+
function snapPointReveal(value, size, rootFontSize = 16) {
|
|
322
|
+
if (typeof value === 'number') {
|
|
323
|
+
return value > 0 && value <= 1 ? value * size : clamp(value, 0, size);
|
|
324
|
+
}
|
|
325
|
+
const trimmed = value.trim();
|
|
326
|
+
if (trimmed.endsWith('%')) {
|
|
327
|
+
return clamp((parseFloat(trimmed) / 100) * size, 0, size);
|
|
328
|
+
}
|
|
329
|
+
const parsed = parseFloat(trimmed);
|
|
330
|
+
if (Number.isNaN(parsed)) {
|
|
331
|
+
return size;
|
|
332
|
+
}
|
|
333
|
+
if (trimmed.endsWith('rem')) {
|
|
334
|
+
return clamp(parsed * rootFontSize, 0, size);
|
|
335
|
+
}
|
|
336
|
+
// A bare unit-less value still follows the number rule (`<= 1` is a fraction).
|
|
337
|
+
return trimmed.endsWith('px')
|
|
338
|
+
? clamp(parsed, 0, size)
|
|
339
|
+
: parsed > 0 && parsed <= 1
|
|
340
|
+
? parsed * size
|
|
341
|
+
: clamp(parsed, 0, size);
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Build the snap entries for a given drawer size, sorted by openness (most open / smallest offset
|
|
345
|
+
* first). `offset = size - reveal`, so a fully-revealed point sits at offset `0`.
|
|
346
|
+
*/
|
|
347
|
+
function buildSnapEntries(values, size, rootFontSize = 16) {
|
|
348
|
+
return values
|
|
349
|
+
.map((value) => {
|
|
350
|
+
const reveal = snapPointReveal(value, size, rootFontSize);
|
|
351
|
+
return { value, reveal, offset: clamp(size - reveal, 0, size) };
|
|
352
|
+
})
|
|
353
|
+
.sort((a, b) => a.offset - b.offset);
|
|
354
|
+
}
|
|
355
|
+
/** How many milliseconds of momentum a release's velocity projects forward when picking a target. */
|
|
356
|
+
const MOMENTUM_MS = 120;
|
|
357
|
+
/** Pick the snap point (or dismissal) a release lands on. */
|
|
358
|
+
function resolveSnapTarget(options) {
|
|
359
|
+
const { offsets, activeIndex, projected, velocity, size, sequential, canDismiss } = options;
|
|
360
|
+
if (sequential) {
|
|
361
|
+
const active = offsets[activeIndex] ?? 0;
|
|
362
|
+
if (projected > active) {
|
|
363
|
+
const next = activeIndex + 1 < offsets.length ? offsets[activeIndex + 1] : canDismiss ? size : active;
|
|
364
|
+
const midpoint = (active + next) / 2;
|
|
365
|
+
if (projected >= midpoint) {
|
|
366
|
+
if (activeIndex + 1 >= offsets.length) {
|
|
367
|
+
return canDismiss ? { dismiss: true } : { index: activeIndex };
|
|
368
|
+
}
|
|
369
|
+
return { index: activeIndex + 1 };
|
|
370
|
+
}
|
|
371
|
+
return { index: activeIndex };
|
|
372
|
+
}
|
|
373
|
+
const previous = activeIndex - 1 >= 0 ? offsets[activeIndex - 1] : 0;
|
|
374
|
+
const midpoint = (previous + active) / 2;
|
|
375
|
+
return projected <= midpoint && activeIndex - 1 >= 0 ? { index: activeIndex - 1 } : { index: activeIndex };
|
|
376
|
+
}
|
|
377
|
+
const target = projected + velocity * MOMENTUM_MS;
|
|
378
|
+
let bestIndex = 0;
|
|
379
|
+
let bestDistance = Infinity;
|
|
380
|
+
offsets.forEach((offset, index) => {
|
|
381
|
+
const distance = Math.abs(offset - target);
|
|
382
|
+
if (distance < bestDistance) {
|
|
383
|
+
bestDistance = distance;
|
|
384
|
+
bestIndex = index;
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
if (canDismiss && Math.abs(size - target) < bestDistance) {
|
|
388
|
+
return { dismiss: true };
|
|
389
|
+
}
|
|
390
|
+
return { index: bestIndex };
|
|
391
|
+
}
|
|
392
|
+
/** The unit translate vector pointing toward dismissal for a direction. */
|
|
393
|
+
function dismissUnitVector(direction) {
|
|
394
|
+
switch (direction) {
|
|
395
|
+
case 'down':
|
|
396
|
+
return { x: 0, y: 1 };
|
|
397
|
+
case 'up':
|
|
398
|
+
return { x: 0, y: -1 };
|
|
399
|
+
case 'right':
|
|
400
|
+
return { x: 1, y: 0 };
|
|
401
|
+
case 'left':
|
|
402
|
+
return { x: -1, y: 0 };
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// The pointer-drag lifecycle now lives in core so other gesture primitives (e.g. toast) can share it.
|
|
407
|
+
// Re-exported here to keep the drawer's internal imports and public API stable.
|
|
408
|
+
|
|
409
|
+
/** iOS-style rubber-band resistance for dragging *past* the fully-open position. */
|
|
410
|
+
const RUBBER_BAND_CONSTANT = 0.55;
|
|
411
|
+
/** Idle time (ms) since the last movement past which a release counts as a hold, not a flick. */
|
|
412
|
+
const FLICK_IDLE_MS = 66;
|
|
413
|
+
const rubberBand = (distance, dimension) => dimension <= 0 ? 0 : (1 - 1 / ((Math.abs(distance) * RUBBER_BAND_CONSTANT) / dimension + 1)) * dimension;
|
|
414
|
+
const isVertical = (direction) => direction === 'up' || direction === 'down';
|
|
415
|
+
/**
|
|
416
|
+
* Whether a scrollable region between `target` and `boundary` can still scroll in the direction the
|
|
417
|
+
* swipe would reveal — in which case the gesture must yield to scrolling instead of dismissing.
|
|
418
|
+
*/
|
|
419
|
+
function scrollGuards(target, boundary, direction) {
|
|
420
|
+
let node = target;
|
|
421
|
+
while (node && node !== boundary) {
|
|
422
|
+
if (node instanceof HTMLElement) {
|
|
423
|
+
const style = getComputedStyle(node);
|
|
424
|
+
const vertical = isVertical(direction);
|
|
425
|
+
const overflow = vertical ? style.overflowY : style.overflowX;
|
|
426
|
+
if (overflow === 'auto' || overflow === 'scroll') {
|
|
427
|
+
const scrollPos = vertical ? node.scrollTop : node.scrollLeft;
|
|
428
|
+
const maxScroll = vertical
|
|
429
|
+
? node.scrollHeight - node.clientHeight
|
|
430
|
+
: node.scrollWidth - node.clientWidth;
|
|
431
|
+
// Pulling the drawer in the dismiss direction reveals the *start* edge for
|
|
432
|
+
// down/right and the *end* edge for up/left; only swipe when already at that edge.
|
|
433
|
+
const atStartEdge = scrollPos <= 0;
|
|
434
|
+
const atEndEdge = scrollPos >= maxScroll - 1;
|
|
435
|
+
const needsStartEdge = direction === 'down' || direction === 'right';
|
|
436
|
+
if (maxScroll > 0 && (needsStartEdge ? !atStartEdge : !atEndEdge)) {
|
|
437
|
+
return true;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
node = node.parentElement;
|
|
442
|
+
}
|
|
443
|
+
return false;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Headless swipe gesture for the drawer popup: dismiss, snap-back, and movement between snap points.
|
|
447
|
+
*
|
|
448
|
+
* Writes a small contract the consumer styles against (no transform is applied for you, keeping the
|
|
449
|
+
* primitive headless):
|
|
450
|
+
* - `--drawer-swipe-movement-x` / `--drawer-swipe-movement-y` — signed px offset along the axis,
|
|
451
|
+
* including the active snap point's resting offset while idle.
|
|
452
|
+
* - `--drawer-swipe-strength` — 0..1 live dismiss progress (`0` at rest).
|
|
453
|
+
* - `[data-swiping]` — present while a gesture is active (drive `transition: none` off this).
|
|
454
|
+
* - `[data-swipe-direction]` — the active direction.
|
|
455
|
+
* - `[data-swipe-dismiss]` — present briefly when a release commits to dismissal.
|
|
456
|
+
*
|
|
457
|
+
* While idle the movement variables hold the active snap offset; releasing without dismissing writes
|
|
458
|
+
* the target offset so the consumer's `transition` animates between snap points and home.
|
|
459
|
+
*
|
|
460
|
+
* Must be called from an injection context (a directive/component constructor).
|
|
461
|
+
*/
|
|
462
|
+
function useDrawerSwipe(config) {
|
|
463
|
+
assertInInjectionContext(useDrawerSwipe);
|
|
464
|
+
const element = () => config.element();
|
|
465
|
+
const axisSize = () => (isVertical(config.direction()) ? element().offsetHeight : element().offsetWidth);
|
|
466
|
+
let active = false;
|
|
467
|
+
let startX = 0;
|
|
468
|
+
let startY = 0;
|
|
469
|
+
let startOffset = 0;
|
|
470
|
+
let pendingProjected = 0;
|
|
471
|
+
let lastProjected = 0;
|
|
472
|
+
let lastTime = 0;
|
|
473
|
+
let velocity = 0;
|
|
474
|
+
let rafId = 0;
|
|
475
|
+
const cancelRaf = () => {
|
|
476
|
+
if (rafId) {
|
|
477
|
+
cancelAnimationFrame(rafId);
|
|
478
|
+
rafId = 0;
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
/** Write the movement variables for a translate magnitude (px) and a 0..1 dismiss strength. */
|
|
482
|
+
const writeMovement = (offset, strength) => {
|
|
483
|
+
const unit = dismissUnitVector(config.direction());
|
|
484
|
+
const el = element();
|
|
485
|
+
el.style.setProperty('--drawer-swipe-movement-x', `${unit.x * offset}px`);
|
|
486
|
+
el.style.setProperty('--drawer-swipe-movement-y', `${unit.y * offset}px`);
|
|
487
|
+
el.style.setProperty('--drawer-swipe-strength', `${strength}`);
|
|
488
|
+
};
|
|
489
|
+
const writeLive = () => {
|
|
490
|
+
rafId = 0;
|
|
491
|
+
const size = axisSize();
|
|
492
|
+
const visual = pendingProjected >= 0 ? pendingProjected : -rubberBand(pendingProjected, size);
|
|
493
|
+
const strength = clamp(pendingProjected / (size || 1), 0, 1);
|
|
494
|
+
writeMovement(visual, strength);
|
|
495
|
+
config.onProgress?.(strength);
|
|
496
|
+
};
|
|
497
|
+
const scheduleWrite = () => {
|
|
498
|
+
if (!rafId) {
|
|
499
|
+
rafId = requestAnimationFrame(writeLive);
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
/** Settle to a resting snap offset (animates via the consumer's transition); rest is not dismissing. */
|
|
503
|
+
const settleTo = (offset) => {
|
|
504
|
+
cancelRaf();
|
|
505
|
+
writeMovement(offset, 0);
|
|
506
|
+
config.onProgress?.(0);
|
|
507
|
+
};
|
|
508
|
+
usePointerDrag({
|
|
509
|
+
canStart: (event) => {
|
|
510
|
+
if (!config.enabled()) {
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
const target = event.target;
|
|
514
|
+
if (target?.closest('[data-base-ui-swipe-ignore]')) {
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
return !scrollGuards(target, element(), config.direction());
|
|
518
|
+
},
|
|
519
|
+
onStart: (event) => {
|
|
520
|
+
active = true;
|
|
521
|
+
startX = event.clientX;
|
|
522
|
+
startY = event.clientY;
|
|
523
|
+
startOffset = config.restingOffset();
|
|
524
|
+
pendingProjected = startOffset;
|
|
525
|
+
lastProjected = startOffset;
|
|
526
|
+
lastTime = event.timeStamp;
|
|
527
|
+
velocity = 0;
|
|
528
|
+
const el = element();
|
|
529
|
+
el.setAttribute('data-swiping', '');
|
|
530
|
+
el.removeAttribute('data-swipe-dismiss');
|
|
531
|
+
},
|
|
532
|
+
onMove: (event) => {
|
|
533
|
+
// Abort if the drawer closed mid-drag; the end handler settles back.
|
|
534
|
+
if (!config.enabled()) {
|
|
535
|
+
return false;
|
|
536
|
+
}
|
|
537
|
+
const unit = dismissUnitVector(config.direction());
|
|
538
|
+
const drag = (event.clientX - startX) * unit.x + (event.clientY - startY) * unit.y;
|
|
539
|
+
pendingProjected = startOffset + drag;
|
|
540
|
+
const dt = event.timeStamp - lastTime;
|
|
541
|
+
if (dt > 0) {
|
|
542
|
+
velocity = (pendingProjected - lastProjected) / dt;
|
|
543
|
+
lastProjected = pendingProjected;
|
|
544
|
+
lastTime = event.timeStamp;
|
|
545
|
+
}
|
|
546
|
+
scheduleWrite();
|
|
547
|
+
return true;
|
|
548
|
+
},
|
|
549
|
+
onEnd: (event, committed) => {
|
|
550
|
+
active = false;
|
|
551
|
+
cancelRaf();
|
|
552
|
+
element().removeAttribute('data-swiping');
|
|
553
|
+
// A pause before lift is a hold, not a flick: drop stale velocity.
|
|
554
|
+
if (event.timeStamp - lastTime > FLICK_IDLE_MS) {
|
|
555
|
+
velocity = 0;
|
|
556
|
+
}
|
|
557
|
+
const release = config.resolveRelease(pendingProjected, velocity, committed && config.enabled());
|
|
558
|
+
if (release.type === 'dismiss') {
|
|
559
|
+
element().setAttribute('data-swipe-dismiss', '');
|
|
560
|
+
config.onDismiss(event);
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
settleTo(release.offset);
|
|
564
|
+
}
|
|
565
|
+
});
|
|
566
|
+
// Keep the idle resting offset in sync with snap state and reset live progress to 0 at rest.
|
|
567
|
+
// Skipped while dragging (the gesture owns the variables) and writes nothing while closed so the
|
|
568
|
+
// exit keyframe starts from the last visible offset.
|
|
569
|
+
effect(() => {
|
|
570
|
+
const offset = config.restingOffset();
|
|
571
|
+
const enabled = config.enabled();
|
|
572
|
+
if (active) {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
if (enabled) {
|
|
576
|
+
writeMovement(offset, 0);
|
|
577
|
+
}
|
|
578
|
+
config.onProgress?.(0);
|
|
579
|
+
});
|
|
580
|
+
inject(DestroyRef).onDestroy(cancelRaf);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** Fraction of the drawer size a plain (no-snap) release must pass to dismiss. */
|
|
584
|
+
const DISMISS_FRACTION = 0.5;
|
|
585
|
+
/** Dismiss-axis velocity (px/ms) past which a plain release dismisses regardless of distance. */
|
|
586
|
+
const DISMISS_VELOCITY = 0.4;
|
|
587
|
+
/** Root font size (px) for resolving `rem` snap points; `16` (the CSS initial value) outside the browser. */
|
|
588
|
+
function rootFontSize() {
|
|
589
|
+
if (typeof document === 'undefined') {
|
|
590
|
+
return 16;
|
|
591
|
+
}
|
|
592
|
+
return parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* A container for the drawer contents.
|
|
596
|
+
*
|
|
597
|
+
* Composes the dialog popup (focus trap, dismissal, scroll lock, a11y wiring) and owns the drawer
|
|
598
|
+
* gesture on top of it: swipe-to-dismiss, snap-back, and movement between snap points. The gesture
|
|
599
|
+
* publishes a CSS-variable / data-attribute contract (see {@link useDrawerSwipe}); the consumer
|
|
600
|
+
* styles the actual transform and snap-back transition off it, keeping the primitive headless.
|
|
601
|
+
*/
|
|
602
|
+
class RdxDrawerPopup {
|
|
603
|
+
constructor() {
|
|
604
|
+
this.drawerContext = injectRdxDrawerRootContext();
|
|
605
|
+
this.dialogContext = injectRdxDialogRootContext();
|
|
606
|
+
this.elementRef = inject(ElementRef);
|
|
607
|
+
this.element = this.elementRef.nativeElement;
|
|
608
|
+
/** Live popup size (px); a ResizeObserver keeps it current so snap geometry never goes stale. */
|
|
609
|
+
this.size = elementSize({ elementRef: this.elementRef, injector: inject(Injector) });
|
|
610
|
+
/** Snap entries for the current size; built once and shared by the offset/expanded reads. */
|
|
611
|
+
this.snapEntries = computed(() => buildSnapEntries(this.drawerContext.snapPoints(), this.axisSize(), rootFontSize()), ...(ngDevMode ? [{ debugName: "snapEntries" }] : /* istanbul ignore next */ []));
|
|
612
|
+
/** Resting translate magnitude (px) of the active snap point; `0` when fully open / no snaps. */
|
|
613
|
+
this.restingOffset = computed(() => {
|
|
614
|
+
const active = this.drawerContext.activeSnapPoint();
|
|
615
|
+
if (active === null || !this.drawerContext.hasSnapPoints()) {
|
|
616
|
+
return 0;
|
|
617
|
+
}
|
|
618
|
+
return this.snapEntries().find((candidate) => candidate.value === active)?.offset ?? 0;
|
|
619
|
+
}, ...(ngDevMode ? [{ debugName: "restingOffset" }] : /* istanbul ignore next */ []));
|
|
620
|
+
/** Whether the active snap point is the most open one. */
|
|
621
|
+
this.expanded = computed(() => {
|
|
622
|
+
const active = this.drawerContext.activeSnapPoint();
|
|
623
|
+
if (active === null || !this.drawerContext.hasSnapPoints()) {
|
|
624
|
+
return false;
|
|
625
|
+
}
|
|
626
|
+
const entries = this.snapEntries();
|
|
627
|
+
return entries.length > 0 && entries[0].value === active;
|
|
628
|
+
}, ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
629
|
+
/** The frontmost nested drawer's height for `--drawer-frontmost-height`, or unset when none. */
|
|
630
|
+
this.frontmostHeightPx = computed(() => {
|
|
631
|
+
const height = this.drawerContext.frontmostHeight();
|
|
632
|
+
return this.drawerContext.nestedDrawerOpen() && height > 0 ? `${height}px` : null;
|
|
633
|
+
}, ...(ngDevMode ? [{ debugName: "frontmostHeightPx" }] : /* istanbul ignore next */ []));
|
|
634
|
+
useDrawerSwipe({
|
|
635
|
+
element: () => this.element,
|
|
636
|
+
direction: this.drawerContext.swipeDirection,
|
|
637
|
+
enabled: computed(() => this.dialogContext.isOpen()),
|
|
638
|
+
restingOffset: this.restingOffset,
|
|
639
|
+
resolveRelease: (projected, velocity, canDismiss) => this.resolveRelease(projected, velocity, canDismiss),
|
|
640
|
+
onDismiss: (event) => this.dialogContext.close('swipe', event),
|
|
641
|
+
onProgress: (strength) => this.drawerContext.setSwipeProgress(strength)
|
|
642
|
+
});
|
|
643
|
+
// Publish informational snap variables and report the measured size to the provider.
|
|
644
|
+
effect(() => {
|
|
645
|
+
const offset = this.restingOffset();
|
|
646
|
+
const size = this.axisSize();
|
|
647
|
+
if (!this.dialogContext.isOpen()) {
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
this.element.style.setProperty('--drawer-height', `${size}px`);
|
|
651
|
+
this.element.style.setProperty('--drawer-snap-point-offset', `${offset}px`);
|
|
652
|
+
this.drawerContext.reportPopupHeight(size);
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
axisSize() {
|
|
656
|
+
const direction = this.drawerContext.swipeDirection();
|
|
657
|
+
const size = this.size();
|
|
658
|
+
return direction === 'up' || direction === 'down' ? size.height : size.width;
|
|
659
|
+
}
|
|
660
|
+
resolveRelease(projected, velocity, canDismiss) {
|
|
661
|
+
const size = this.axisSize();
|
|
662
|
+
const dismissAllowed = canDismiss && !this.dialogContext.disablePointerDismissal();
|
|
663
|
+
if (!this.drawerContext.hasSnapPoints()) {
|
|
664
|
+
const strength = projected / (size || 1);
|
|
665
|
+
return dismissAllowed && (strength >= DISMISS_FRACTION || velocity >= DISMISS_VELOCITY)
|
|
666
|
+
? { type: 'dismiss' }
|
|
667
|
+
: { type: 'snap', offset: 0 };
|
|
668
|
+
}
|
|
669
|
+
const entries = this.snapEntries();
|
|
670
|
+
const offsets = entries.map((entry) => entry.offset);
|
|
671
|
+
const active = this.drawerContext.activeSnapPoint();
|
|
672
|
+
const activeIndex = Math.max(0, entries.findIndex((entry) => entry.value === active));
|
|
673
|
+
const target = resolveSnapTarget({
|
|
674
|
+
offsets,
|
|
675
|
+
activeIndex,
|
|
676
|
+
projected,
|
|
677
|
+
velocity,
|
|
678
|
+
size,
|
|
679
|
+
sequential: this.drawerContext.sequentialSnap(),
|
|
680
|
+
canDismiss: dismissAllowed
|
|
681
|
+
});
|
|
682
|
+
if ('dismiss' in target) {
|
|
683
|
+
return { type: 'dismiss' };
|
|
684
|
+
}
|
|
685
|
+
const entry = entries[target.index];
|
|
686
|
+
if (entry.value !== active) {
|
|
687
|
+
this.drawerContext.setActiveSnapPoint(entry.value, true);
|
|
688
|
+
}
|
|
689
|
+
return { type: 'snap', offset: entry.offset };
|
|
690
|
+
}
|
|
691
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerPopup, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
692
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerPopup, isStandalone: true, selector: "[rdxDrawerPopup]", host: { properties: { "attr.data-swipe-direction": "drawerContext.swipeDirection()", "attr.data-expanded": "expanded() ? \"\" : undefined", "attr.data-nested-drawer-open": "drawerContext.nestedDrawerOpen() ? \"\" : undefined", "style.--nested-drawers": "drawerContext.nestedDrawerCount()", "style.--drawer-frontmost-height": "frontmostHeightPx()" } }, exportAs: ["rdxDrawerPopup"], hostDirectives: [{ directive: i1.RdxDialogPopup, outputs: ["escapeKeyDown", "escapeKeyDown", "pointerDownOutside", "pointerDownOutside", "focusOutside", "focusOutside", "interactOutside", "interactOutside", "openAutoFocus", "openAutoFocus", "closeAutoFocus", "closeAutoFocus"] }], ngImport: i0 }); }
|
|
693
|
+
}
|
|
694
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerPopup, decorators: [{
|
|
695
|
+
type: Directive,
|
|
696
|
+
args: [{
|
|
697
|
+
selector: '[rdxDrawerPopup]',
|
|
698
|
+
exportAs: 'rdxDrawerPopup',
|
|
699
|
+
hostDirectives: [
|
|
700
|
+
{
|
|
701
|
+
directive: RdxDialogPopup,
|
|
702
|
+
outputs: [
|
|
703
|
+
'escapeKeyDown',
|
|
704
|
+
'pointerDownOutside',
|
|
705
|
+
'focusOutside',
|
|
706
|
+
'interactOutside',
|
|
707
|
+
'openAutoFocus',
|
|
708
|
+
'closeAutoFocus'
|
|
709
|
+
]
|
|
710
|
+
}
|
|
711
|
+
],
|
|
712
|
+
host: {
|
|
713
|
+
'[attr.data-swipe-direction]': 'drawerContext.swipeDirection()',
|
|
714
|
+
'[attr.data-expanded]': 'expanded() ? "" : undefined',
|
|
715
|
+
'[attr.data-nested-drawer-open]': 'drawerContext.nestedDrawerOpen() ? "" : undefined',
|
|
716
|
+
'[style.--nested-drawers]': 'drawerContext.nestedDrawerCount()',
|
|
717
|
+
'[style.--drawer-frontmost-height]': 'frontmostHeightPx()'
|
|
718
|
+
}
|
|
719
|
+
}]
|
|
720
|
+
}], ctorParameters: () => [] });
|
|
721
|
+
|
|
722
|
+
/**
|
|
723
|
+
* Moves the drawer to a different part of the DOM. Defaults to `document.body`.
|
|
724
|
+
*/
|
|
725
|
+
class RdxDrawerPortal {
|
|
726
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerPortal, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
727
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerPortal, isStandalone: true, selector: "[rdxDrawerPortal]", exportAs: ["rdxDrawerPortal"], hostDirectives: [{ directive: i1.RdxDialogPortal, inputs: ["container", "container"] }], ngImport: i0 }); }
|
|
728
|
+
}
|
|
729
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerPortal, decorators: [{
|
|
730
|
+
type: Directive,
|
|
731
|
+
args: [{
|
|
732
|
+
selector: '[rdxDrawerPortal]',
|
|
733
|
+
exportAs: 'rdxDrawerPortal',
|
|
734
|
+
hostDirectives: [
|
|
735
|
+
{
|
|
736
|
+
directive: RdxDialogPortal,
|
|
737
|
+
inputs: ['container']
|
|
738
|
+
}
|
|
739
|
+
]
|
|
740
|
+
}]
|
|
741
|
+
}] });
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Mounts the portal while the drawer is open and waits for CSS exit keyframes before unmounting.
|
|
745
|
+
*/
|
|
746
|
+
class RdxDrawerPortalPresence {
|
|
747
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerPortalPresence, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
748
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerPortalPresence, isStandalone: true, selector: "ng-template[rdxDrawerPortalPresence]", hostDirectives: [{ directive: i1.RdxDialogPortalPresence }], ngImport: i0 }); }
|
|
749
|
+
}
|
|
750
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerPortalPresence, decorators: [{
|
|
751
|
+
type: Directive,
|
|
752
|
+
args: [{
|
|
753
|
+
selector: 'ng-template[rdxDrawerPortalPresence]',
|
|
754
|
+
hostDirectives: [RdxDialogPortalPresence]
|
|
755
|
+
}]
|
|
756
|
+
}] });
|
|
757
|
+
|
|
758
|
+
/** Pointer travel (px) inward past which the swipe area opens the drawer. */
|
|
759
|
+
const OPEN_THRESHOLD = 30;
|
|
760
|
+
/** Inward pointer travel (toward the open drawer) for a given direction and pointer delta. */
|
|
761
|
+
function inwardDistance(direction, dx, dy) {
|
|
762
|
+
switch (direction) {
|
|
763
|
+
case 'down':
|
|
764
|
+
return -dy;
|
|
765
|
+
case 'up':
|
|
766
|
+
return dy;
|
|
767
|
+
case 'left':
|
|
768
|
+
return dx;
|
|
769
|
+
case 'right':
|
|
770
|
+
return -dx;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* An off-canvas region (typically pinned to a screen edge) that opens the drawer when swiped inward.
|
|
775
|
+
*
|
|
776
|
+
* Phase 1 opens on a threshold crossing rather than following the pointer live (the popup is not
|
|
777
|
+
* mounted while closed); the live-follow open will land with snap points. Shares the drawer's
|
|
778
|
+
* pointer-drag lifecycle so capture/cancel handling stays consistent with the popup gesture.
|
|
779
|
+
*/
|
|
780
|
+
class RdxDrawerSwipeArea {
|
|
781
|
+
constructor() {
|
|
782
|
+
this.drawerContext = injectRdxDrawerRootContext();
|
|
783
|
+
this.dialogContext = injectRdxDialogRootContext();
|
|
784
|
+
/** Direction the swipe area opens from; defaults to the root's `swipeDirection`. */
|
|
785
|
+
this.swipeDirection = input(...(ngDevMode ? [undefined, { debugName: "swipeDirection" }] : /* istanbul ignore next */ []));
|
|
786
|
+
/** Whether the swipe area should ignore user interaction. */
|
|
787
|
+
this.disabled = input(false, { ...(ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
788
|
+
this.isOpen = computed(() => this.dialogContext.isOpen(), ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
789
|
+
this.direction = computed(() => this.swipeDirection() ?? this.drawerContext.swipeDirection(), ...(ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []));
|
|
790
|
+
this.swiping = signal(false, ...(ngDevMode ? [{ debugName: "swiping" }] : /* istanbul ignore next */ []));
|
|
791
|
+
this.startX = 0;
|
|
792
|
+
this.startY = 0;
|
|
793
|
+
usePointerDrag({
|
|
794
|
+
canStart: () => !this.disabled() && !this.isOpen(),
|
|
795
|
+
onStart: (event) => {
|
|
796
|
+
this.startX = event.clientX;
|
|
797
|
+
this.startY = event.clientY;
|
|
798
|
+
this.swiping.set(true);
|
|
799
|
+
},
|
|
800
|
+
onMove: (event) => {
|
|
801
|
+
if (this.disabled()) {
|
|
802
|
+
return false;
|
|
803
|
+
}
|
|
804
|
+
const distance = inwardDistance(this.direction(), event.clientX - this.startX, event.clientY - this.startY);
|
|
805
|
+
if (distance >= OPEN_THRESHOLD) {
|
|
806
|
+
this.dialogContext.open(undefined, undefined, undefined, 'swipe', event);
|
|
807
|
+
return false;
|
|
808
|
+
}
|
|
809
|
+
return true;
|
|
810
|
+
},
|
|
811
|
+
onEnd: () => this.swiping.set(false)
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerSwipeArea, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
815
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.9", type: RdxDrawerSwipeArea, isStandalone: true, selector: "[rdxDrawerSwipeArea]", inputs: { swipeDirection: { classPropertyName: "swipeDirection", publicName: "swipeDirection", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.data-open": "isOpen() ? \"\" : undefined", "attr.data-closed": "isOpen() ? undefined : \"\"", "attr.data-disabled": "disabled() ? \"\" : undefined", "attr.data-swiping": "swiping() ? \"\" : undefined", "attr.data-swipe-direction": "direction()" } }, exportAs: ["rdxDrawerSwipeArea"], ngImport: i0 }); }
|
|
816
|
+
}
|
|
817
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerSwipeArea, decorators: [{
|
|
818
|
+
type: Directive,
|
|
819
|
+
args: [{
|
|
820
|
+
selector: '[rdxDrawerSwipeArea]',
|
|
821
|
+
exportAs: 'rdxDrawerSwipeArea',
|
|
822
|
+
host: {
|
|
823
|
+
'[attr.data-open]': 'isOpen() ? "" : undefined',
|
|
824
|
+
'[attr.data-closed]': 'isOpen() ? undefined : ""',
|
|
825
|
+
'[attr.data-disabled]': 'disabled() ? "" : undefined',
|
|
826
|
+
'[attr.data-swiping]': 'swiping() ? "" : undefined',
|
|
827
|
+
'[attr.data-swipe-direction]': 'direction()'
|
|
828
|
+
}
|
|
829
|
+
}]
|
|
830
|
+
}], ctorParameters: () => [], propDecorators: { swipeDirection: [{ type: i0.Input, args: [{ isSignal: true, alias: "swipeDirection", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }] } });
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* An accessible title announced when the drawer is opened.
|
|
834
|
+
*/
|
|
835
|
+
class RdxDrawerTitle {
|
|
836
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerTitle, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
837
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerTitle, isStandalone: true, selector: "[rdxDrawerTitle]", exportAs: ["rdxDrawerTitle"], hostDirectives: [{ directive: i1.RdxDialogTitle }], ngImport: i0 }); }
|
|
838
|
+
}
|
|
839
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerTitle, decorators: [{
|
|
840
|
+
type: Directive,
|
|
841
|
+
args: [{
|
|
842
|
+
selector: '[rdxDrawerTitle]',
|
|
843
|
+
exportAs: 'rdxDrawerTitle',
|
|
844
|
+
hostDirectives: [RdxDialogTitle]
|
|
845
|
+
}]
|
|
846
|
+
}] });
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* A button that opens the drawer. Behaves exactly like the dialog trigger.
|
|
850
|
+
*/
|
|
851
|
+
class RdxDrawerTrigger {
|
|
852
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
853
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerTrigger, isStandalone: true, selector: "button[rdxDrawerTrigger]", exportAs: ["rdxDrawerTrigger"], hostDirectives: [{ directive: i1.RdxDialogTrigger, inputs: ["handle", "handle", "payload", "payload", "id", "id", "disabled", "disabled"] }], ngImport: i0 }); }
|
|
854
|
+
}
|
|
855
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerTrigger, decorators: [{
|
|
856
|
+
type: Directive,
|
|
857
|
+
args: [{
|
|
858
|
+
selector: 'button[rdxDrawerTrigger]',
|
|
859
|
+
exportAs: 'rdxDrawerTrigger',
|
|
860
|
+
hostDirectives: [
|
|
861
|
+
{
|
|
862
|
+
directive: RdxDialogTrigger,
|
|
863
|
+
inputs: ['handle', 'payload', 'id', 'disabled']
|
|
864
|
+
}
|
|
865
|
+
]
|
|
866
|
+
}]
|
|
867
|
+
}] });
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* A positioning container for the drawer popup that can be made scrollable.
|
|
871
|
+
*
|
|
872
|
+
* Exposes the dialog viewport's `data-nested` / `data-nested-dialog-open` state for styling.
|
|
873
|
+
*/
|
|
874
|
+
class RdxDrawerViewport {
|
|
875
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerViewport, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
876
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.9", type: RdxDrawerViewport, isStandalone: true, selector: "[rdxDrawerViewport]", exportAs: ["rdxDrawerViewport"], hostDirectives: [{ directive: i1.RdxDialogViewport }], ngImport: i0 }); }
|
|
877
|
+
}
|
|
878
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerViewport, decorators: [{
|
|
879
|
+
type: Directive,
|
|
880
|
+
args: [{
|
|
881
|
+
selector: '[rdxDrawerViewport]',
|
|
882
|
+
exportAs: 'rdxDrawerViewport',
|
|
883
|
+
hostDirectives: [RdxDialogViewport]
|
|
884
|
+
}]
|
|
885
|
+
}] });
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Connects a drawer root with trigger elements rendered elsewhere in the DOM.
|
|
889
|
+
*
|
|
890
|
+
* Drawers reuse the dialog handle implementation unchanged.
|
|
891
|
+
*/
|
|
892
|
+
const RdxDrawerHandle = RdxDialogHandle;
|
|
893
|
+
function createRdxDrawerHandle() {
|
|
894
|
+
return createRdxDialogHandle();
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
const drawerImports = [
|
|
898
|
+
RdxDrawerProviderDirective,
|
|
899
|
+
RdxDrawerRoot,
|
|
900
|
+
RdxDrawerTrigger,
|
|
901
|
+
RdxDrawerSwipeArea,
|
|
902
|
+
RdxDrawerPortalPresence,
|
|
903
|
+
RdxDrawerPortal,
|
|
904
|
+
RdxDrawerBackdrop,
|
|
905
|
+
RdxDrawerViewport,
|
|
906
|
+
RdxDrawerPopup,
|
|
907
|
+
RdxDrawerContent,
|
|
908
|
+
RdxDrawerTitle,
|
|
909
|
+
RdxDrawerDescription,
|
|
910
|
+
RdxDrawerClose,
|
|
911
|
+
RdxDrawerIndent,
|
|
912
|
+
RdxDrawerIndentBackground
|
|
913
|
+
];
|
|
914
|
+
class RdxDrawerModule {
|
|
915
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
916
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerModule, imports: [RdxDrawerProviderDirective,
|
|
917
|
+
RdxDrawerRoot,
|
|
918
|
+
RdxDrawerTrigger,
|
|
919
|
+
RdxDrawerSwipeArea,
|
|
920
|
+
RdxDrawerPortalPresence,
|
|
921
|
+
RdxDrawerPortal,
|
|
922
|
+
RdxDrawerBackdrop,
|
|
923
|
+
RdxDrawerViewport,
|
|
924
|
+
RdxDrawerPopup,
|
|
925
|
+
RdxDrawerContent,
|
|
926
|
+
RdxDrawerTitle,
|
|
927
|
+
RdxDrawerDescription,
|
|
928
|
+
RdxDrawerClose,
|
|
929
|
+
RdxDrawerIndent,
|
|
930
|
+
RdxDrawerIndentBackground], exports: [RdxDrawerProviderDirective,
|
|
931
|
+
RdxDrawerRoot,
|
|
932
|
+
RdxDrawerTrigger,
|
|
933
|
+
RdxDrawerSwipeArea,
|
|
934
|
+
RdxDrawerPortalPresence,
|
|
935
|
+
RdxDrawerPortal,
|
|
936
|
+
RdxDrawerBackdrop,
|
|
937
|
+
RdxDrawerViewport,
|
|
938
|
+
RdxDrawerPopup,
|
|
939
|
+
RdxDrawerContent,
|
|
940
|
+
RdxDrawerTitle,
|
|
941
|
+
RdxDrawerDescription,
|
|
942
|
+
RdxDrawerClose,
|
|
943
|
+
RdxDrawerIndent,
|
|
944
|
+
RdxDrawerIndentBackground] }); }
|
|
945
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerModule }); }
|
|
946
|
+
}
|
|
947
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: RdxDrawerModule, decorators: [{
|
|
948
|
+
type: NgModule,
|
|
949
|
+
args: [{
|
|
950
|
+
imports: [...drawerImports],
|
|
951
|
+
exports: [...drawerImports]
|
|
952
|
+
}]
|
|
953
|
+
}] });
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Generated bundle index. Do not edit.
|
|
957
|
+
*/
|
|
958
|
+
|
|
959
|
+
export { RdxDrawerBackdrop, RdxDrawerClose, RdxDrawerContent, RdxDrawerDescription, RdxDrawerHandle, RdxDrawerIndent, RdxDrawerIndentBackground, RdxDrawerModule, RdxDrawerPopup, RdxDrawerPortal, RdxDrawerPortalPresence, RdxDrawerProvider, RdxDrawerProviderDirective, RdxDrawerRoot, RdxDrawerSwipeArea, RdxDrawerTitle, RdxDrawerTrigger, RdxDrawerViewport, buildSnapEntries, createRdxDrawerHandle, dismissUnitVector, drawerImports, injectRdxDrawerRootContext, provideRdxDrawerProvider, provideRdxDrawerRootContext, resolveSnapTarget, snapPointReveal, useDrawerSwipe };
|
|
960
|
+
//# sourceMappingURL=radix-ng-primitives-drawer.mjs.map
|