@coolon/angular-ui-powerups 16.1.0-alpha.318 → 16.1.0-alpha.319
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/assets/interaction.scss +2 -2
- package/esm2022/lib/interaction/components/activity-actions/activity-actions.component.mjs +10 -4
- package/esm2022/lib/interaction/components/activity-container/activity-container.component.mjs +1 -1
- package/esm2022/lib/interaction/services/hosted-interaction-context.mjs +6 -1
- package/esm2022/lib/interaction/services/mat-bottom-sheet-interaction/bottom-sheet-interaction-context.mjs +21 -3
- package/esm2022/lib/interaction/services/mat-bottom-sheet-interaction/sheet-swipe.mjs +133 -0
- package/fesm2022/coolon-angular-ui-powerups.mjs +166 -5
- package/fesm2022/coolon-angular-ui-powerups.mjs.map +1 -1
- package/lib/interaction/components/activity-actions/activity-actions.component.d.ts +6 -0
- package/lib/interaction/components/activity-container/activity-container.component.d.ts +1 -1
- package/lib/interaction/services/hosted-interaction-context.d.ts +2 -0
- package/lib/interaction/services/mat-bottom-sheet-interaction/bottom-sheet-interaction-context.d.ts +2 -1
- package/lib/interaction/services/mat-bottom-sheet-interaction/sheet-swipe.d.ts +48 -0
- package/package.json +1 -1
|
@@ -69,6 +69,7 @@ import { style, trigger, transition, animate, group, query } from '@angular/anim
|
|
|
69
69
|
import { MatCardModule } from '@angular/material/card';
|
|
70
70
|
import * as i3$3 from '@angular/material/list';
|
|
71
71
|
import { MatListModule } from '@angular/material/list';
|
|
72
|
+
import { Subject } from 'rxjs';
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
75
|
* `matTooltip` that also renders inside a detached change-detection subtree — i.e. inside an
|
|
@@ -9254,6 +9255,11 @@ class ActivityActionsComponent extends DisposableComponent {
|
|
|
9254
9255
|
this.faces = style;
|
|
9255
9256
|
}
|
|
9256
9257
|
layout = ActivityActionsComponent.Layout.BLOCK;
|
|
9258
|
+
/**
|
|
9259
|
+
* Where the buttons sit. 'start' and 'end' put both at that end, the content filling the rest; 'stretch' puts cancel
|
|
9260
|
+
* at the start and confirm at the end, the content between them. 'fill' shares the bar's width between the buttons, so
|
|
9261
|
+
* a lone button spans it, as the one action at the foot of a phone's sheet does; the content sits above them.
|
|
9262
|
+
*/
|
|
9257
9263
|
align = ActivityActionsComponent.Align.STRETCH;
|
|
9258
9264
|
alignContent = ActivityActionsComponent.AlignContent.CENTER;
|
|
9259
9265
|
activityContext = this.inject(ActivityContext, {
|
|
@@ -9279,7 +9285,7 @@ class ActivityActionsComponent extends DisposableComponent {
|
|
|
9279
9285
|
this.cancelCommandComponent.requestFocus();
|
|
9280
9286
|
}
|
|
9281
9287
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: ActivityActionsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
9282
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.9", type: ActivityActionsComponent, selector: "aup-activity-actions", inputs: { confirmCommand: "confirmCommand", cancelCommand: "cancelCommand", faces: "faces", confirmFace: "confirmFace", cancelFace: "cancelFace", style: "style", layout: "layout", align: "align", alignContent: "alignContent" }, host: { properties: { "attr.layout": "this.layout", "attr.align": "this.align", "attr.align-content": "this.alignContent" } }, viewQueries: [{ propertyName: "confirmCommandComponent", first: true, predicate: ["confirmCommandComponent"], descendants: true }, { propertyName: "cancelCommandComponent", first: true, predicate: ["cancelCommandComponent"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"content\">\n <ng-content></ng-content>\n</div>\n<ng-container *ngIf=\"hasCancelFace()\">\n <aup-command #cancelCommandComponent class=\"cancel\" [command]=\"cancelCommand\" [face]=\"cancelFace\" data-cy=\"cancel-command\"></aup-command>\n</ng-container>\n<ng-container *ngIf=\"hasConfirmFace()\">\n <aup-command #confirmCommandComponent class=\"confirm\" [command]=\"confirmCommand\" [face]=\"confirmFace\" data-cy=\"confirm-command\"></aup-command>\n</ng-container>\n", styles: [":host{display:grid;grid-template-rows:auto;align-items:center;justify-content:end;--resolved-activity-actions-gap: var(--activity-actions-gap, 8px);grid-gap:var(--resolved-activity-actions-gap)}:host[layout=block][align=start]{grid-template-areas:\"cancel confirm content\";grid-template-columns:auto auto 1fr}:host[layout=block][align=start] .confirm{margin-left:var(--resolved-activity-actions-gap)}:host[layout=block][align=end]{grid-template-areas:\"content cancel confirm\";grid-template-columns:1fr auto auto}:host[layout=block][align=end] .confirm{margin-left:var(--resolved-activity-actions-gap)}:host[layout=block][align=stretch]{grid-template-areas:\"cancel content confirm\";grid-template-columns:auto 1fr auto}:host[layout=inline]{grid-template-areas:\"confirm cancel content\";grid-template-columns:auto auto 1fr}:host[layout=inline] .cancel{margin-left:var(--resolved-activity-actions-gap)}:host .cancel{grid-area:cancel}:host .confirm{grid-area:confirm}:host .content{display:flex;flex-direction:row;align-items:center}:host[align-content=start] .content{justify-items:start}:host[align-content=end]{justify-items:end}:host[align-content=center]{justify-items:center}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: CommandComponent, selector: "aup-command", inputs: ["command", "face$", "face", "busyFace$", "busyFace", "alignFace", "density", "fill", "labelOverflow"] }] });
|
|
9288
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.9", type: ActivityActionsComponent, selector: "aup-activity-actions", inputs: { confirmCommand: "confirmCommand", cancelCommand: "cancelCommand", faces: "faces", confirmFace: "confirmFace", cancelFace: "cancelFace", style: "style", layout: "layout", align: "align", alignContent: "alignContent" }, host: { properties: { "attr.layout": "this.layout", "attr.align": "this.align", "attr.align-content": "this.alignContent" } }, viewQueries: [{ propertyName: "confirmCommandComponent", first: true, predicate: ["confirmCommandComponent"], descendants: true }, { propertyName: "cancelCommandComponent", first: true, predicate: ["cancelCommandComponent"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div class=\"content\">\n <ng-content></ng-content>\n</div>\n<ng-container *ngIf=\"hasCancelFace()\">\n <aup-command #cancelCommandComponent class=\"cancel\" [command]=\"cancelCommand\" [face]=\"cancelFace\" data-cy=\"cancel-command\"></aup-command>\n</ng-container>\n<ng-container *ngIf=\"hasConfirmFace()\">\n <aup-command #confirmCommandComponent class=\"confirm\" [command]=\"confirmCommand\" [face]=\"confirmFace\" data-cy=\"confirm-command\"></aup-command>\n</ng-container>\n", styles: [":host{display:grid;grid-template-rows:auto;align-items:center;justify-content:end;--resolved-activity-actions-gap: var(--activity-actions-gap, 8px);grid-gap:var(--resolved-activity-actions-gap)}:host[layout=block][align=start]{grid-template-areas:\"cancel confirm content\";grid-template-columns:auto auto 1fr}:host[layout=block][align=start] .confirm{margin-left:var(--resolved-activity-actions-gap)}:host[layout=block][align=end]{grid-template-areas:\"content cancel confirm\";grid-template-columns:1fr auto auto}:host[layout=block][align=end] .confirm{margin-left:var(--resolved-activity-actions-gap)}:host[layout=block][align=stretch]{grid-template-areas:\"cancel content confirm\";grid-template-columns:auto 1fr auto}:host[layout=block][align=fill]{display:flex;flex-wrap:wrap}:host[layout=block][align=fill] .content{flex:1 0 100%}:host[layout=block][align=fill] .content:empty{display:none}:host[layout=block][align=fill] .cancel,:host[layout=block][align=fill] .confirm{flex:1 1 0}:host[layout=inline]{grid-template-areas:\"confirm cancel content\";grid-template-columns:auto auto 1fr}:host[layout=inline] .cancel{margin-left:var(--resolved-activity-actions-gap)}:host .cancel{grid-area:cancel}:host .confirm{grid-area:confirm}:host .content{display:flex;flex-direction:row;align-items:center}:host[align-content=start] .content{justify-items:start}:host[align-content=end]{justify-items:end}:host[align-content=center]{justify-items:center}\n"], dependencies: [{ kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: CommandComponent, selector: "aup-command", inputs: ["command", "face$", "face", "busyFace$", "busyFace", "alignFace", "density", "fill", "labelOverflow"] }] });
|
|
9283
9289
|
}
|
|
9284
9290
|
__decorate([
|
|
9285
9291
|
Proxify(),
|
|
@@ -9291,7 +9297,7 @@ __decorate([
|
|
|
9291
9297
|
], ActivityActionsComponent.prototype, "cancelCommand", null);
|
|
9292
9298
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImport: i0, type: ActivityActionsComponent, decorators: [{
|
|
9293
9299
|
type: Component,
|
|
9294
|
-
args: [{ selector: 'aup-activity-actions', template: "<div class=\"content\">\n <ng-content></ng-content>\n</div>\n<ng-container *ngIf=\"hasCancelFace()\">\n <aup-command #cancelCommandComponent class=\"cancel\" [command]=\"cancelCommand\" [face]=\"cancelFace\" data-cy=\"cancel-command\"></aup-command>\n</ng-container>\n<ng-container *ngIf=\"hasConfirmFace()\">\n <aup-command #confirmCommandComponent class=\"confirm\" [command]=\"confirmCommand\" [face]=\"confirmFace\" data-cy=\"confirm-command\"></aup-command>\n</ng-container>\n", styles: [":host{display:grid;grid-template-rows:auto;align-items:center;justify-content:end;--resolved-activity-actions-gap: var(--activity-actions-gap, 8px);grid-gap:var(--resolved-activity-actions-gap)}:host[layout=block][align=start]{grid-template-areas:\"cancel confirm content\";grid-template-columns:auto auto 1fr}:host[layout=block][align=start] .confirm{margin-left:var(--resolved-activity-actions-gap)}:host[layout=block][align=end]{grid-template-areas:\"content cancel confirm\";grid-template-columns:1fr auto auto}:host[layout=block][align=end] .confirm{margin-left:var(--resolved-activity-actions-gap)}:host[layout=block][align=stretch]{grid-template-areas:\"cancel content confirm\";grid-template-columns:auto 1fr auto}:host[layout=inline]{grid-template-areas:\"confirm cancel content\";grid-template-columns:auto auto 1fr}:host[layout=inline] .cancel{margin-left:var(--resolved-activity-actions-gap)}:host .cancel{grid-area:cancel}:host .confirm{grid-area:confirm}:host .content{display:flex;flex-direction:row;align-items:center}:host[align-content=start] .content{justify-items:start}:host[align-content=end]{justify-items:end}:host[align-content=center]{justify-items:center}\n"] }]
|
|
9300
|
+
args: [{ selector: 'aup-activity-actions', template: "<div class=\"content\">\n <ng-content></ng-content>\n</div>\n<ng-container *ngIf=\"hasCancelFace()\">\n <aup-command #cancelCommandComponent class=\"cancel\" [command]=\"cancelCommand\" [face]=\"cancelFace\" data-cy=\"cancel-command\"></aup-command>\n</ng-container>\n<ng-container *ngIf=\"hasConfirmFace()\">\n <aup-command #confirmCommandComponent class=\"confirm\" [command]=\"confirmCommand\" [face]=\"confirmFace\" data-cy=\"confirm-command\"></aup-command>\n</ng-container>\n", styles: [":host{display:grid;grid-template-rows:auto;align-items:center;justify-content:end;--resolved-activity-actions-gap: var(--activity-actions-gap, 8px);grid-gap:var(--resolved-activity-actions-gap)}:host[layout=block][align=start]{grid-template-areas:\"cancel confirm content\";grid-template-columns:auto auto 1fr}:host[layout=block][align=start] .confirm{margin-left:var(--resolved-activity-actions-gap)}:host[layout=block][align=end]{grid-template-areas:\"content cancel confirm\";grid-template-columns:1fr auto auto}:host[layout=block][align=end] .confirm{margin-left:var(--resolved-activity-actions-gap)}:host[layout=block][align=stretch]{grid-template-areas:\"cancel content confirm\";grid-template-columns:auto 1fr auto}:host[layout=block][align=fill]{display:flex;flex-wrap:wrap}:host[layout=block][align=fill] .content{flex:1 0 100%}:host[layout=block][align=fill] .content:empty{display:none}:host[layout=block][align=fill] .cancel,:host[layout=block][align=fill] .confirm{flex:1 1 0}:host[layout=inline]{grid-template-areas:\"confirm cancel content\";grid-template-columns:auto auto 1fr}:host[layout=inline] .cancel{margin-left:var(--resolved-activity-actions-gap)}:host .cancel{grid-area:cancel}:host .confirm{grid-area:confirm}:host .content{display:flex;flex-direction:row;align-items:center}:host[align-content=start] .content{justify-items:start}:host[align-content=end]{justify-items:end}:host[align-content=center]{justify-items:center}\n"] }]
|
|
9295
9301
|
}], ctorParameters: function () { return []; }, propDecorators: { confirmCommandComponent: [{
|
|
9296
9302
|
type: ViewChild,
|
|
9297
9303
|
args: ["confirmCommandComponent"]
|
|
@@ -9334,7 +9340,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImpor
|
|
|
9334
9340
|
ActivityActionsComponent.Align = Enum({
|
|
9335
9341
|
START: 'start',
|
|
9336
9342
|
STRETCH: 'stretch',
|
|
9337
|
-
END: 'end'
|
|
9343
|
+
END: 'end',
|
|
9344
|
+
FILL: 'fill'
|
|
9338
9345
|
});
|
|
9339
9346
|
ActivityActionsComponent.AlignContent = Enum({
|
|
9340
9347
|
START: 'start',
|
|
@@ -15886,6 +15893,11 @@ class HostedInteractionContext extends AbstractInteractionContext {
|
|
|
15886
15893
|
}
|
|
15887
15894
|
}
|
|
15888
15895
|
});
|
|
15896
|
+
host.swipedClosed?.().subscribe(() => {
|
|
15897
|
+
if (this.canClose(activityContainer, options)) {
|
|
15898
|
+
activityContainer.cancelActiveActivity();
|
|
15899
|
+
}
|
|
15900
|
+
});
|
|
15889
15901
|
host.afterClosed().subscribe(() => {
|
|
15890
15902
|
if (activityContainer.isActive()) {
|
|
15891
15903
|
activityContainer.cancelActiveActivity();
|
|
@@ -15990,10 +16002,144 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.9", ngImpor
|
|
|
15990
16002
|
args: [MAT_DIALOG_DEFAULT_OPTIONS]
|
|
15991
16003
|
}] }]; } });
|
|
15992
16004
|
|
|
16005
|
+
/**
|
|
16006
|
+
* Lets a sheet be swiped down to close, as a phone's sheets are.
|
|
16007
|
+
*
|
|
16008
|
+
* A drag starts only in the sheet's top strip, its handle and its activity's title, so it never takes over a scroll in
|
|
16009
|
+
* the activity's body. The sheet follows the pointer down. Released a third of its height down, or flicked down, it
|
|
16010
|
+
* asks to close, as Escape does; otherwise it springs back. A sheet whose activity does not let it close
|
|
16011
|
+
* springs back too.
|
|
16012
|
+
*
|
|
16013
|
+
* The drag moves the sheet's overlay pane rather than the sheet itself. Material animates the sheet's own position as
|
|
16014
|
+
* it closes, so a sheet that closes slides on down from where the drag left it.
|
|
16015
|
+
*/
|
|
16016
|
+
class SheetSwipe {
|
|
16017
|
+
sheet;
|
|
16018
|
+
pane;
|
|
16019
|
+
requestClose;
|
|
16020
|
+
closing;
|
|
16021
|
+
tracking;
|
|
16022
|
+
offset;
|
|
16023
|
+
listeners;
|
|
16024
|
+
/**
|
|
16025
|
+
* @param sheet the sheet's container, which holds the handle and the activity.
|
|
16026
|
+
* @param pane the overlay pane holding the sheet, which the drag moves.
|
|
16027
|
+
* @param requestClose asks the sheet to close, as Escape does. The sheet closes only if its activity allows.
|
|
16028
|
+
* @param closing whether the sheet has begun to close.
|
|
16029
|
+
*/
|
|
16030
|
+
constructor(sheet, pane, requestClose, closing) {
|
|
16031
|
+
this.sheet = sheet;
|
|
16032
|
+
this.pane = pane;
|
|
16033
|
+
this.requestClose = requestClose;
|
|
16034
|
+
this.closing = closing;
|
|
16035
|
+
this.listeners = [
|
|
16036
|
+
['pointerdown', (e) => this.pointerDown(e)],
|
|
16037
|
+
['pointermove', (e) => this.pointerMove(e)],
|
|
16038
|
+
['pointerup', (e) => this.pointerUp(e)],
|
|
16039
|
+
['pointercancel', () => this.springBack()],
|
|
16040
|
+
// A touch in the strip would otherwise start the browser's own pan, or a pull to refresh, and cancel the drag.
|
|
16041
|
+
['touchmove', (e) => this.tracking && e.preventDefault(), { passive: false }],
|
|
16042
|
+
];
|
|
16043
|
+
this.listeners.forEach(([type, listener, options]) => sheet.addEventListener(type, listener, options));
|
|
16044
|
+
}
|
|
16045
|
+
dispose() {
|
|
16046
|
+
this.listeners.forEach(([type, listener, options]) => this.sheet.removeEventListener(type, listener, options));
|
|
16047
|
+
}
|
|
16048
|
+
pointerDown(event) {
|
|
16049
|
+
if (!event.isPrimary || event.button !== 0 || !this.inTopStrip(event)) {
|
|
16050
|
+
return;
|
|
16051
|
+
}
|
|
16052
|
+
this.tracking = { pointerId: event.pointerId, startY: event.clientY, lastY: event.clientY, lastTime: event.timeStamp, speed: 0 };
|
|
16053
|
+
}
|
|
16054
|
+
pointerMove(event) {
|
|
16055
|
+
const tracking = this.tracking;
|
|
16056
|
+
if (!tracking || event.pointerId !== tracking.pointerId) {
|
|
16057
|
+
return;
|
|
16058
|
+
}
|
|
16059
|
+
const distance = event.clientY - tracking.startY;
|
|
16060
|
+
if (this.offset === undefined) {
|
|
16061
|
+
if (Math.abs(distance) < SheetSwipe.START_DISTANCE) {
|
|
16062
|
+
return;
|
|
16063
|
+
}
|
|
16064
|
+
if (distance < 0) {
|
|
16065
|
+
// A sheet already as tall as its activity has nowhere to go up.
|
|
16066
|
+
this.tracking = undefined;
|
|
16067
|
+
return;
|
|
16068
|
+
}
|
|
16069
|
+
this.sheet.setPointerCapture?.(event.pointerId);
|
|
16070
|
+
this.pane.style.transition = 'none';
|
|
16071
|
+
}
|
|
16072
|
+
const elapsed = event.timeStamp - tracking.lastTime;
|
|
16073
|
+
if (elapsed > 0) {
|
|
16074
|
+
tracking.speed = (event.clientY - tracking.lastY) / elapsed;
|
|
16075
|
+
}
|
|
16076
|
+
tracking.lastY = event.clientY;
|
|
16077
|
+
tracking.lastTime = event.timeStamp;
|
|
16078
|
+
this.offset = Math.max(0, distance);
|
|
16079
|
+
this.pane.style.transform = `translateY(${this.offset}px)`;
|
|
16080
|
+
}
|
|
16081
|
+
pointerUp(event) {
|
|
16082
|
+
const tracking = this.tracking;
|
|
16083
|
+
const offset = this.offset;
|
|
16084
|
+
this.tracking = undefined;
|
|
16085
|
+
if (!tracking || event.pointerId !== tracking.pointerId || offset === undefined) {
|
|
16086
|
+
return;
|
|
16087
|
+
}
|
|
16088
|
+
this.swallowNextClick();
|
|
16089
|
+
// A pointer held still before letting go has stopped, however fast it last moved.
|
|
16090
|
+
const flicked = event.timeStamp - tracking.lastTime < SheetSwipe.FLICK_WINDOW && tracking.speed >= SheetSwipe.FLICK_SPEED;
|
|
16091
|
+
if (flicked || offset >= this.sheet.getBoundingClientRect().height * SheetSwipe.CLOSE_FRACTION) {
|
|
16092
|
+
this.requestClose(event);
|
|
16093
|
+
// Closing cancels the activity first, which settles in a later microtask; a sheet still open after that stays.
|
|
16094
|
+
setTimeout(() => this.closing() || this.springBack());
|
|
16095
|
+
}
|
|
16096
|
+
else {
|
|
16097
|
+
this.springBack();
|
|
16098
|
+
}
|
|
16099
|
+
}
|
|
16100
|
+
springBack() {
|
|
16101
|
+
this.tracking = undefined;
|
|
16102
|
+
this.offset = undefined;
|
|
16103
|
+
const reduceMotion = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
16104
|
+
this.pane.style.transition = reduceMotion ? 'none' : 'transform 200ms ease-out';
|
|
16105
|
+
this.pane.style.transform = '';
|
|
16106
|
+
}
|
|
16107
|
+
/** The handle sits in the sheet's top padding, above the activity; the title is the activity's own top strip. */
|
|
16108
|
+
inTopStrip(event) {
|
|
16109
|
+
const target = event.target;
|
|
16110
|
+
if (target?.closest?.('aup-activity-title')) {
|
|
16111
|
+
return true;
|
|
16112
|
+
}
|
|
16113
|
+
return event.clientY - this.sheet.getBoundingClientRect().top < SheetSwipe.HANDLE_STRIP_HEIGHT;
|
|
16114
|
+
}
|
|
16115
|
+
/** A drag that started on a button in the title must not also press it. The click, if any, follows pointerup at once. */
|
|
16116
|
+
swallowNextClick() {
|
|
16117
|
+
const swallow = (click) => {
|
|
16118
|
+
click.stopPropagation();
|
|
16119
|
+
click.preventDefault();
|
|
16120
|
+
};
|
|
16121
|
+
this.sheet.addEventListener('click', swallow, { capture: true, once: true });
|
|
16122
|
+
setTimeout(() => this.sheet.removeEventListener('click', swallow, { capture: true }));
|
|
16123
|
+
}
|
|
16124
|
+
}
|
|
16125
|
+
(function (SheetSwipe) {
|
|
16126
|
+
/** How far, in px, a pointer moves before it drags the sheet rather than taps what is under it. */
|
|
16127
|
+
SheetSwipe.START_DISTANCE = 6;
|
|
16128
|
+
/** The share of its height a sheet is dragged down before letting go closes it. */
|
|
16129
|
+
SheetSwipe.CLOSE_FRACTION = 1 / 3;
|
|
16130
|
+
/** The downward speed, in px per millisecond, at which letting go closes a sheet however far it was dragged. */
|
|
16131
|
+
SheetSwipe.FLICK_SPEED = 0.5;
|
|
16132
|
+
/** How long, in milliseconds, before letting go the pointer's speed is measured for a flick. */
|
|
16133
|
+
SheetSwipe.FLICK_WINDOW = 100;
|
|
16134
|
+
/** The height, in px, of the strip at the sheet's top that holds its handle. */
|
|
16135
|
+
SheetSwipe.HANDLE_STRIP_HEIGHT = 24;
|
|
16136
|
+
})(SheetSwipe || (SheetSwipe = {}));
|
|
16137
|
+
|
|
15993
16138
|
/**
|
|
15994
16139
|
* Runs each activity in a sheet that rises from the foot of the screen, as a phone shows a choice. The
|
|
15995
16140
|
* sheet is as tall as its activity, up to most of the screen. An activity started from inside one
|
|
15996
|
-
* slides in over it in the same sheet, and its own Back returns to the one before.
|
|
16141
|
+
* slides in over it in the same sheet, and its own Back returns to the one before. A swipe down from
|
|
16142
|
+
* its handle or title closes it as Escape does (see `SheetSwipe`).
|
|
15997
16143
|
*/
|
|
15998
16144
|
class BottomSheetInteractionContext extends HostedInteractionContext {
|
|
15999
16145
|
bottomSheet;
|
|
@@ -16014,12 +16160,27 @@ class BottomSheetInteractionContext extends HostedInteractionContext {
|
|
|
16014
16160
|
const activityContainer = sheetRef.instance;
|
|
16015
16161
|
// A dialog's container fills the dialog; a sheet's takes its height from the activity in it.
|
|
16016
16162
|
activityContainer.dynamicHeight = true;
|
|
16163
|
+
let closing = false;
|
|
16164
|
+
const swipedClosed$ = new Subject();
|
|
16165
|
+
let swipe;
|
|
16166
|
+
sheetRef.afterOpened().subscribe(() => {
|
|
16167
|
+
const sheet = activityContainer.elementRef.nativeElement.closest('.mat-bottom-sheet-container');
|
|
16168
|
+
const pane = sheet?.closest('.bottom-sheet-interaction-context');
|
|
16169
|
+
if (sheet && pane) {
|
|
16170
|
+
swipe = new SheetSwipe(sheet, pane, event => swipedClosed$.next(event), () => closing);
|
|
16171
|
+
}
|
|
16172
|
+
});
|
|
16173
|
+
sheetRef.afterDismissed().subscribe(() => swipe?.dispose());
|
|
16017
16174
|
return {
|
|
16018
16175
|
activityContainer,
|
|
16019
|
-
close: () =>
|
|
16176
|
+
close: () => {
|
|
16177
|
+
closing = true;
|
|
16178
|
+
sheetRef.dismiss();
|
|
16179
|
+
},
|
|
16020
16180
|
afterOpened: () => sheetRef.afterOpened(),
|
|
16021
16181
|
afterClosed: () => sheetRef.afterDismissed(),
|
|
16022
16182
|
backdropClick: () => sheetRef.backdropClick(),
|
|
16183
|
+
swipedClosed: () => swipedClosed$,
|
|
16023
16184
|
keydownEvents: () => sheetRef.keydownEvents(),
|
|
16024
16185
|
updateSize: () => undefined,
|
|
16025
16186
|
};
|