@mxtommy/kip 3.9.0-beta.2 → 3.9.0-beta.21
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/.github/copilot-instructions.md +1 -1
- package/.github/instructions/angular.instructions.md +46 -0
- package/README.md +49 -12
- package/package.json +2 -4
- package/public/3rdpartylicenses.txt +77 -77
- package/public/app-help.component.css.map +7 -0
- package/public/app.component.css.map +7 -0
- package/public/assets/help-docs/configuration.md +4 -4
- package/public/assets/help-docs/dashboards.md +4 -2
- package/public/assets/svg/icons.svg +1 -1
- package/public/boolean-control-config.component.css.map +7 -0
- package/public/boolean-multicontrol-options.component.css.map +7 -0
- package/public/chunk-3EWIS24B.js +5237 -0
- package/public/chunk-3EWIS24B.js.map +1 -0
- package/public/chunk-3VR3EA35.js +1022 -0
- package/public/chunk-3VR3EA35.js.map +1 -0
- package/public/chunk-63ILPRXC.js +2091 -0
- package/public/chunk-63ILPRXC.js.map +1 -0
- package/public/chunk-65ZWQBS6.js +3102 -0
- package/public/chunk-65ZWQBS6.js.map +1 -0
- package/public/chunk-B3LKEWZP.js +4950 -0
- package/public/chunk-B3LKEWZP.js.map +1 -0
- package/public/chunk-BIBIW64D.js +16773 -0
- package/public/chunk-BIBIW64D.js.map +1 -0
- package/public/chunk-BM53SC5N.js +77 -0
- package/public/chunk-BM53SC5N.js.map +7 -0
- package/public/chunk-D7ILNFDM.js +3059 -0
- package/public/chunk-D7ILNFDM.js.map +1 -0
- package/public/chunk-E24UNLSJ.js +2228 -0
- package/public/chunk-E24UNLSJ.js.map +1 -0
- package/public/chunk-J42S2ELC.js +5927 -0
- package/public/chunk-J42S2ELC.js.map +1 -0
- package/public/chunk-KC22A6VH.js +17 -0
- package/public/chunk-KC22A6VH.js.map +7 -0
- package/public/chunk-MCEJWZB2.js +116 -0
- package/public/chunk-MCEJWZB2.js.map +1 -0
- package/public/chunk-NBF6SE6O.js +89 -0
- package/public/chunk-NBF6SE6O.js.map +7 -0
- package/public/chunk-QC7VGVAR.js +343 -0
- package/public/chunk-QC7VGVAR.js.map +7 -0
- package/public/chunk-SDOP6T56.js +42377 -0
- package/public/chunk-SDOP6T56.js.map +1 -0
- package/public/chunk-U2DCSTRY.js +159 -0
- package/public/chunk-U2DCSTRY.js.map +7 -0
- package/public/chunk-UHVNAEXC.js +4752 -0
- package/public/chunk-UHVNAEXC.js.map +1 -0
- package/public/chunk-UQYTD5AC.js +2723 -0
- package/public/chunk-UQYTD5AC.js.map +1 -0
- package/public/chunk-XSABJ5NZ.js +272 -0
- package/public/chunk-XSABJ5NZ.js.map +7 -0
- package/public/chunk-Y6N6O2IP.js +19852 -0
- package/public/chunk-Y6N6O2IP.js.map +1 -0
- package/public/chunk-YGJLBLOX.js +2708 -0
- package/public/chunk-YGJLBLOX.js.map +1 -0
- package/public/chunk-YT33DHC3.js +591 -0
- package/public/chunk-YT33DHC3.js.map +7 -0
- package/public/chunk-YZXYVP72.js +4934 -0
- package/public/chunk-YZXYVP72.js.map +1 -0
- package/public/chunk-ZEHRDSTB.js +13727 -0
- package/public/chunk-ZEHRDSTB.js.map +1 -0
- package/public/config.component.css.map +7 -0
- package/public/dashboard-scroller.component.css.map +7 -0
- package/public/dashboard.component.css.map +7 -0
- package/public/dashboards-editor.component.css.map +7 -0
- package/public/data-inspector-row.component.css.map +7 -0
- package/public/data-inspector.component.css.map +7 -0
- package/public/dataset-chart-options.component.css.map +7 -0
- package/public/datasets.component.css.map +7 -0
- package/public/dialog-confirmation.component.css.map +7 -0
- package/public/dialog-dashboard-page-editor.component.css.map +7 -0
- package/public/dialog-frame.component.css.map +7 -0
- package/public/dialog-name.component.css.map +7 -0
- package/public/display-chart-options.component.css.map +7 -0
- package/public/display.component.css.map +7 -0
- package/public/gauge-steel.component.css.map +7 -0
- package/public/home.component.css.map +7 -0
- package/public/index.html +19 -17
- package/public/main.js +36423 -0
- package/public/main.js.map +1 -0
- package/public/menu-actions.component.css.map +7 -0
- package/public/menu-notifications.component.css.map +7 -0
- package/public/minichart.component.css.map +7 -0
- package/public/modal-user-credential.component.css.map +7 -0
- package/public/modal-widget-config.component.css.map +7 -0
- package/public/notification-badge.component.css.map +7 -0
- package/public/page-header.component.css.map +7 -0
- package/public/path-control-config.component.css.map +7 -0
- package/public/paths-options.component.css.map +7 -0
- package/public/polyfills.js +4422 -0
- package/public/polyfills.js.map +1 -0
- package/public/select-autopilot.component.css.map +7 -0
- package/public/select-icon.component.css.map +7 -0
- package/public/settings.component.css.map +7 -0
- package/public/signalk.component.css.map +7 -0
- package/public/styles.css +1651 -0
- package/public/styles.css.map +7 -0
- package/public/svg-autopilot.component.css.map +7 -0
- package/public/svg-racesteer.component.css.map +7 -0
- package/public/svg-simple-linear-gauge.component.css.map +7 -0
- package/public/svg-windsteer.component.css.map +7 -0
- package/public/tile-large-icon.component.css.map +7 -0
- package/public/units.component.css.map +7 -0
- package/public/upgrade-config.component.css.map +7 -0
- package/public/widget-autopilot.component.css.map +7 -0
- package/public/widget-boolean-switch.component.css.map +7 -0
- package/public/widget-datetime.component.css.map +7 -0
- package/public/widget-freeboardsk.component.css.map +7 -0
- package/public/widget-gauge-ng-compass.component.css.map +7 -0
- package/public/widget-gauge-ng-linear.component.css.map +7 -0
- package/public/widget-gauge-ng-radial.component.css.map +7 -0
- package/public/widget-gauge-steel.component.css.map +7 -0
- package/public/widget-horizon.component.css.map +7 -0
- package/public/widget-host.component.css.map +7 -0
- package/public/widget-iframe.component.css.map +7 -0
- package/public/widget-label.component.css.map +7 -0
- package/public/widget-list-card.component.css.map +7 -0
- package/public/widget-numeric.component.css.map +7 -0
- package/public/widget-position.component.css.map +7 -0
- package/public/widget-race-timer.component.css.map +7 -0
- package/public/widget-racer-line.component.css.map +7 -0
- package/public/widget-racer-timer.component.css.map +7 -0
- package/public/widget-simple-linear.component.css.map +7 -0
- package/public/widget-slider.component.css.map +7 -0
- package/public/widget-text.component.css.map +7 -0
- package/public/widget-title.component.css.map +7 -0
- package/public/widget-tutorial.component.css.map +7 -0
- package/public/widgets-list.component.css.map +7 -0
- package/public/assets/hammer.min.js +0 -7
- package/public/chunk-2YVW3TBK.js +0 -2
- package/public/chunk-35L7BBBD.js +0 -15
- package/public/chunk-3LEMFOCV.js +0 -3
- package/public/chunk-3LJAKLLW.js +0 -1
- package/public/chunk-4JJLPUET.js +0 -60
- package/public/chunk-CBUY7NMR.js +0 -2
- package/public/chunk-CQXWGD3T.js +0 -2
- package/public/chunk-EUFDL4TJ.js +0 -6
- package/public/chunk-FBFTGVZ6.js +0 -1
- package/public/chunk-HCXH72CD.js +0 -5
- package/public/chunk-JY3WVS7C.js +0 -2
- package/public/chunk-KTDDP73O.js +0 -2
- package/public/chunk-NMEZOCU2.js +0 -1
- package/public/chunk-NS2FPVWM.js +0 -4
- package/public/chunk-OSYHJB4F.js +0 -11
- package/public/chunk-PKNLASTF.js +0 -4
- package/public/chunk-Q2Y75POI.js +0 -1
- package/public/chunk-RRTCHHRC.js +0 -3
- package/public/chunk-TA4GACKT.js +0 -4
- package/public/chunk-TXPLRBW5.js +0 -2
- package/public/chunk-VHFBF47T.js +0 -1
- package/public/chunk-VYUMZVH2.js +0 -2
- package/public/chunk-XRGAX4LS.js +0 -2
- package/public/chunk-YNJRIFUM.js +0 -1
- package/public/chunk-ZBCOJLI4.js +0 -6
- package/public/main-XM5EHMUE.js +0 -50
- package/public/polyfills-KH22MU6U.js +0 -2
- package/public/styles-RECKN66R.css +0 -1
- /package/public/media/{KFOlCnqEu92Fr1MmEU9fABc4AMP6lbBP-ILKS6RVC.woff2 → KFOlCnqEu92Fr1MmEU9fABc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmEU9fBBc4AMP6lQ-MJ3CERJ6.woff2 → KFOlCnqEu92Fr1MmEU9fBBc4AMP6lQ.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmEU9fBxc4AMP6lbBP-UW3XWY7P.woff2 → KFOlCnqEu92Fr1MmEU9fBxc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmEU9fCBc4AMP6lbBP-U3JTBV4H.woff2 → KFOlCnqEu92Fr1MmEU9fCBc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmEU9fCRc4AMP6lbBP-36ULTGLY.woff2 → KFOlCnqEu92Fr1MmEU9fCRc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmEU9fChc4AMP6lbBP-5NJLO2HW.woff2 → KFOlCnqEu92Fr1MmEU9fChc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmEU9fCxc4AMP6lbBP-2EL65J2O.woff2 → KFOlCnqEu92Fr1MmEU9fCxc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmSU5fABc4AMP6lbBP-XWLWMQVU.woff2 → KFOlCnqEu92Fr1MmSU5fABc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmSU5fBBc4AMP6lQ-PWGJWDFE.woff2 → KFOlCnqEu92Fr1MmSU5fBBc4AMP6lQ.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmSU5fBxc4AMP6lbBP-ITB7NUJC.woff2 → KFOlCnqEu92Fr1MmSU5fBxc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmSU5fCBc4AMP6lbBP-32PLHKPQ.woff2 → KFOlCnqEu92Fr1MmSU5fCBc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmSU5fCRc4AMP6lbBP-QPSNQEDD.woff2 → KFOlCnqEu92Fr1MmSU5fCRc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmSU5fChc4AMP6lbBP-JKBSJZY3.woff2 → KFOlCnqEu92Fr1MmSU5fChc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOlCnqEu92Fr1MmSU5fCxc4AMP6lbBP-OG5AHRIX.woff2 → KFOlCnqEu92Fr1MmSU5fCxc4AMP6lbBP.woff2} +0 -0
- /package/public/media/{KFOmCnqEu92Fr1Mu4WxKKTU1Kvnz-PPTELUJT.woff2 → KFOmCnqEu92Fr1Mu4WxKKTU1Kvnz.woff2} +0 -0
- /package/public/media/{KFOmCnqEu92Fr1Mu4mxKKTU1Kg-SNGEW7FX.woff2 → KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2} +0 -0
- /package/public/media/{KFOmCnqEu92Fr1Mu5mxKKTU1Kvnz-DRL4U32S.woff2 → KFOmCnqEu92Fr1Mu5mxKKTU1Kvnz.woff2} +0 -0
- /package/public/media/{KFOmCnqEu92Fr1Mu72xKKTU1Kvnz-PRJ7OQMU.woff2 → KFOmCnqEu92Fr1Mu72xKKTU1Kvnz.woff2} +0 -0
- /package/public/media/{KFOmCnqEu92Fr1Mu7GxKKTU1Kvnz-HW6RMPJ3.woff2 → KFOmCnqEu92Fr1Mu7GxKKTU1Kvnz.woff2} +0 -0
- /package/public/media/{KFOmCnqEu92Fr1Mu7WxKKTU1Kvnz-KZD6JQRT.woff2 → KFOmCnqEu92Fr1Mu7WxKKTU1Kvnz.woff2} +0 -0
- /package/public/media/{KFOmCnqEu92Fr1Mu7mxKKTU1Kvnz-Z72STTMG.woff2 → KFOmCnqEu92Fr1Mu7mxKKTU1Kvnz.woff2} +0 -0
- /package/public/media/{flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ-CN2J7AYH.woff2 → flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2} +0 -0
|
@@ -0,0 +1,4752 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DashboardService,
|
|
3
|
+
DialogService,
|
|
4
|
+
GestureDirective,
|
|
5
|
+
MAT_BOTTOM_SHEET_DATA,
|
|
6
|
+
MatActionList,
|
|
7
|
+
MatBottomSheet,
|
|
8
|
+
MatBottomSheetModule,
|
|
9
|
+
MatBottomSheetRef,
|
|
10
|
+
MatListItem,
|
|
11
|
+
MatListItemIcon,
|
|
12
|
+
MatListModule,
|
|
13
|
+
TileLargeIconComponent,
|
|
14
|
+
uiEventService
|
|
15
|
+
} from "./chunk-ZEHRDSTB.js";
|
|
16
|
+
import "./chunk-D7ILNFDM.js";
|
|
17
|
+
import "./chunk-63ILPRXC.js";
|
|
18
|
+
import "./chunk-E24UNLSJ.js";
|
|
19
|
+
import "./chunk-65ZWQBS6.js";
|
|
20
|
+
import {
|
|
21
|
+
Router
|
|
22
|
+
} from "./chunk-J42S2ELC.js";
|
|
23
|
+
import {
|
|
24
|
+
DomSanitizer,
|
|
25
|
+
MatIcon,
|
|
26
|
+
MatIconModule,
|
|
27
|
+
MatIconRegistry
|
|
28
|
+
} from "./chunk-UQYTD5AC.js";
|
|
29
|
+
import {
|
|
30
|
+
AppService
|
|
31
|
+
} from "./chunk-QC7VGVAR.js";
|
|
32
|
+
import {
|
|
33
|
+
MatDividerModule
|
|
34
|
+
} from "./chunk-MCEJWZB2.js";
|
|
35
|
+
import "./chunk-BIBIW64D.js";
|
|
36
|
+
import {
|
|
37
|
+
BehaviorSubject,
|
|
38
|
+
BreakpointObserver,
|
|
39
|
+
Breakpoints,
|
|
40
|
+
CdkScrollableModule,
|
|
41
|
+
ChangeDetectionStrategy,
|
|
42
|
+
ChangeDetectorRef,
|
|
43
|
+
Component,
|
|
44
|
+
DOCUMENT,
|
|
45
|
+
Directionality,
|
|
46
|
+
Directive,
|
|
47
|
+
ElementRef,
|
|
48
|
+
EventEmitter,
|
|
49
|
+
HostListener,
|
|
50
|
+
Injectable,
|
|
51
|
+
InjectionToken,
|
|
52
|
+
Injector,
|
|
53
|
+
Input,
|
|
54
|
+
MatButtonModule,
|
|
55
|
+
MatFabButton,
|
|
56
|
+
MatIconButton,
|
|
57
|
+
MatRipple,
|
|
58
|
+
MatRippleModule,
|
|
59
|
+
NgModule,
|
|
60
|
+
NgZone,
|
|
61
|
+
Observable,
|
|
62
|
+
Output,
|
|
63
|
+
RendererFactory2,
|
|
64
|
+
ScrollDispatcher,
|
|
65
|
+
Subject,
|
|
66
|
+
Subscription,
|
|
67
|
+
TemplateRef,
|
|
68
|
+
ViewContainerRef,
|
|
69
|
+
ViewEncapsulation,
|
|
70
|
+
ViewportRuler,
|
|
71
|
+
_CdkPrivateStyleLoader,
|
|
72
|
+
_IdGenerator,
|
|
73
|
+
_getEventTarget,
|
|
74
|
+
_getShadowRoot,
|
|
75
|
+
afterNextRender,
|
|
76
|
+
animationFrameScheduler,
|
|
77
|
+
booleanAttribute,
|
|
78
|
+
coerceArray,
|
|
79
|
+
coerceElement,
|
|
80
|
+
coerceNumberProperty,
|
|
81
|
+
computed,
|
|
82
|
+
inject,
|
|
83
|
+
interval,
|
|
84
|
+
isFakeMousedownFromScreenReader,
|
|
85
|
+
isFakeTouchstartFromScreenReader,
|
|
86
|
+
map,
|
|
87
|
+
merge,
|
|
88
|
+
numberAttribute,
|
|
89
|
+
setClassMetadata,
|
|
90
|
+
signal,
|
|
91
|
+
startWith,
|
|
92
|
+
switchMap,
|
|
93
|
+
take,
|
|
94
|
+
takeUntil,
|
|
95
|
+
tap,
|
|
96
|
+
toSignal,
|
|
97
|
+
ɵsetClassDebugInfo,
|
|
98
|
+
ɵɵNgOnChangesFeature,
|
|
99
|
+
ɵɵProvidersFeature,
|
|
100
|
+
ɵɵadvance,
|
|
101
|
+
ɵɵattribute,
|
|
102
|
+
ɵɵclassMap,
|
|
103
|
+
ɵɵclassProp,
|
|
104
|
+
ɵɵconditional,
|
|
105
|
+
ɵɵconditionalCreate,
|
|
106
|
+
ɵɵdefineComponent,
|
|
107
|
+
ɵɵdefineDirective,
|
|
108
|
+
ɵɵdefineInjectable,
|
|
109
|
+
ɵɵdefineInjector,
|
|
110
|
+
ɵɵdefineNgModule,
|
|
111
|
+
ɵɵelement,
|
|
112
|
+
ɵɵelementEnd,
|
|
113
|
+
ɵɵelementStart,
|
|
114
|
+
ɵɵgetCurrentView,
|
|
115
|
+
ɵɵlistener,
|
|
116
|
+
ɵɵnextContext,
|
|
117
|
+
ɵɵproperty,
|
|
118
|
+
ɵɵrepeater,
|
|
119
|
+
ɵɵrepeaterCreate,
|
|
120
|
+
ɵɵresetView,
|
|
121
|
+
ɵɵresolveDocument,
|
|
122
|
+
ɵɵrestoreView,
|
|
123
|
+
ɵɵstyleProp,
|
|
124
|
+
ɵɵtext,
|
|
125
|
+
ɵɵtextInterpolate
|
|
126
|
+
} from "./chunk-SDOP6T56.js";
|
|
127
|
+
|
|
128
|
+
// node_modules/@angular/cdk/fesm2022/drag-drop.mjs
|
|
129
|
+
function deepCloneNode(node) {
|
|
130
|
+
const clone = node.cloneNode(true);
|
|
131
|
+
const descendantsWithId = clone.querySelectorAll("[id]");
|
|
132
|
+
const nodeName = node.nodeName.toLowerCase();
|
|
133
|
+
clone.removeAttribute("id");
|
|
134
|
+
for (let i = 0; i < descendantsWithId.length; i++) {
|
|
135
|
+
descendantsWithId[i].removeAttribute("id");
|
|
136
|
+
}
|
|
137
|
+
if (nodeName === "canvas") {
|
|
138
|
+
transferCanvasData(node, clone);
|
|
139
|
+
} else if (nodeName === "input" || nodeName === "select" || nodeName === "textarea") {
|
|
140
|
+
transferInputData(node, clone);
|
|
141
|
+
}
|
|
142
|
+
transferData("canvas", node, clone, transferCanvasData);
|
|
143
|
+
transferData("input, textarea, select", node, clone, transferInputData);
|
|
144
|
+
return clone;
|
|
145
|
+
}
|
|
146
|
+
function transferData(selector, node, clone, callback) {
|
|
147
|
+
const descendantElements = node.querySelectorAll(selector);
|
|
148
|
+
if (descendantElements.length) {
|
|
149
|
+
const cloneElements = clone.querySelectorAll(selector);
|
|
150
|
+
for (let i = 0; i < descendantElements.length; i++) {
|
|
151
|
+
callback(descendantElements[i], cloneElements[i]);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
var cloneUniqueId = 0;
|
|
156
|
+
function transferInputData(source, clone) {
|
|
157
|
+
if (clone.type !== "file") {
|
|
158
|
+
clone.value = source.value;
|
|
159
|
+
}
|
|
160
|
+
if (clone.type === "radio" && clone.name) {
|
|
161
|
+
clone.name = `mat-clone-${clone.name}-${cloneUniqueId++}`;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function transferCanvasData(source, clone) {
|
|
165
|
+
const context = clone.getContext("2d");
|
|
166
|
+
if (context) {
|
|
167
|
+
try {
|
|
168
|
+
context.drawImage(source, 0, 0);
|
|
169
|
+
} catch {
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function getMutableClientRect(element) {
|
|
174
|
+
const rect = element.getBoundingClientRect();
|
|
175
|
+
return {
|
|
176
|
+
top: rect.top,
|
|
177
|
+
right: rect.right,
|
|
178
|
+
bottom: rect.bottom,
|
|
179
|
+
left: rect.left,
|
|
180
|
+
width: rect.width,
|
|
181
|
+
height: rect.height,
|
|
182
|
+
x: rect.x,
|
|
183
|
+
y: rect.y
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function isInsideClientRect(clientRect, x, y) {
|
|
187
|
+
const {
|
|
188
|
+
top,
|
|
189
|
+
bottom,
|
|
190
|
+
left,
|
|
191
|
+
right
|
|
192
|
+
} = clientRect;
|
|
193
|
+
return y >= top && y <= bottom && x >= left && x <= right;
|
|
194
|
+
}
|
|
195
|
+
function isOverflowingParent(parentRect, childRect) {
|
|
196
|
+
const isLeftOverflowing = childRect.left < parentRect.left;
|
|
197
|
+
const isRightOverflowing = childRect.left + childRect.width > parentRect.right;
|
|
198
|
+
const isTopOverflowing = childRect.top < parentRect.top;
|
|
199
|
+
const isBottomOverflowing = childRect.top + childRect.height > parentRect.bottom;
|
|
200
|
+
return isLeftOverflowing || isRightOverflowing || isTopOverflowing || isBottomOverflowing;
|
|
201
|
+
}
|
|
202
|
+
function adjustDomRect(domRect, top, left) {
|
|
203
|
+
domRect.top += top;
|
|
204
|
+
domRect.bottom = domRect.top + domRect.height;
|
|
205
|
+
domRect.left += left;
|
|
206
|
+
domRect.right = domRect.left + domRect.width;
|
|
207
|
+
}
|
|
208
|
+
function isPointerNearDomRect(rect, threshold, pointerX, pointerY) {
|
|
209
|
+
const {
|
|
210
|
+
top,
|
|
211
|
+
right,
|
|
212
|
+
bottom,
|
|
213
|
+
left,
|
|
214
|
+
width,
|
|
215
|
+
height
|
|
216
|
+
} = rect;
|
|
217
|
+
const xThreshold = width * threshold;
|
|
218
|
+
const yThreshold = height * threshold;
|
|
219
|
+
return pointerY > top - yThreshold && pointerY < bottom + yThreshold && pointerX > left - xThreshold && pointerX < right + xThreshold;
|
|
220
|
+
}
|
|
221
|
+
var ParentPositionTracker = class {
|
|
222
|
+
_document;
|
|
223
|
+
/** Cached positions of the scrollable parent elements. */
|
|
224
|
+
positions = /* @__PURE__ */ new Map();
|
|
225
|
+
constructor(_document) {
|
|
226
|
+
this._document = _document;
|
|
227
|
+
}
|
|
228
|
+
/** Clears the cached positions. */
|
|
229
|
+
clear() {
|
|
230
|
+
this.positions.clear();
|
|
231
|
+
}
|
|
232
|
+
/** Caches the positions. Should be called at the beginning of a drag sequence. */
|
|
233
|
+
cache(elements) {
|
|
234
|
+
this.clear();
|
|
235
|
+
this.positions.set(this._document, {
|
|
236
|
+
scrollPosition: this.getViewportScrollPosition()
|
|
237
|
+
});
|
|
238
|
+
elements.forEach((element) => {
|
|
239
|
+
this.positions.set(element, {
|
|
240
|
+
scrollPosition: {
|
|
241
|
+
top: element.scrollTop,
|
|
242
|
+
left: element.scrollLeft
|
|
243
|
+
},
|
|
244
|
+
clientRect: getMutableClientRect(element)
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/** Handles scrolling while a drag is taking place. */
|
|
249
|
+
handleScroll(event) {
|
|
250
|
+
const target = _getEventTarget(event);
|
|
251
|
+
const cachedPosition = this.positions.get(target);
|
|
252
|
+
if (!cachedPosition) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
const scrollPosition = cachedPosition.scrollPosition;
|
|
256
|
+
let newTop;
|
|
257
|
+
let newLeft;
|
|
258
|
+
if (target === this._document) {
|
|
259
|
+
const viewportScrollPosition = this.getViewportScrollPosition();
|
|
260
|
+
newTop = viewportScrollPosition.top;
|
|
261
|
+
newLeft = viewportScrollPosition.left;
|
|
262
|
+
} else {
|
|
263
|
+
newTop = target.scrollTop;
|
|
264
|
+
newLeft = target.scrollLeft;
|
|
265
|
+
}
|
|
266
|
+
const topDifference = scrollPosition.top - newTop;
|
|
267
|
+
const leftDifference = scrollPosition.left - newLeft;
|
|
268
|
+
this.positions.forEach((position, node) => {
|
|
269
|
+
if (position.clientRect && target !== node && target.contains(node)) {
|
|
270
|
+
adjustDomRect(position.clientRect, topDifference, leftDifference);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
scrollPosition.top = newTop;
|
|
274
|
+
scrollPosition.left = newLeft;
|
|
275
|
+
return {
|
|
276
|
+
top: topDifference,
|
|
277
|
+
left: leftDifference
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Gets the scroll position of the viewport. Note that we use the scrollX and scrollY directly,
|
|
282
|
+
* instead of going through the `ViewportRuler`, because the first value the ruler looks at is
|
|
283
|
+
* the top/left offset of the `document.documentElement` which works for most cases, but breaks
|
|
284
|
+
* if the element is offset by something like the `BlockScrollStrategy`.
|
|
285
|
+
*/
|
|
286
|
+
getViewportScrollPosition() {
|
|
287
|
+
return {
|
|
288
|
+
top: window.scrollY,
|
|
289
|
+
left: window.scrollX
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
function getRootNode(viewRef, _document) {
|
|
294
|
+
const rootNodes = viewRef.rootNodes;
|
|
295
|
+
if (rootNodes.length === 1 && rootNodes[0].nodeType === _document.ELEMENT_NODE) {
|
|
296
|
+
return rootNodes[0];
|
|
297
|
+
}
|
|
298
|
+
const wrapper = _document.createElement("div");
|
|
299
|
+
rootNodes.forEach((node) => wrapper.appendChild(node));
|
|
300
|
+
return wrapper;
|
|
301
|
+
}
|
|
302
|
+
function extendStyles(dest, source, importantProperties2) {
|
|
303
|
+
for (let key in source) {
|
|
304
|
+
if (source.hasOwnProperty(key)) {
|
|
305
|
+
const value = source[key];
|
|
306
|
+
if (value) {
|
|
307
|
+
dest.setProperty(key, value, importantProperties2?.has(key) ? "important" : "");
|
|
308
|
+
} else {
|
|
309
|
+
dest.removeProperty(key);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return dest;
|
|
314
|
+
}
|
|
315
|
+
function toggleNativeDragInteractions(element, enable) {
|
|
316
|
+
const userSelect = enable ? "" : "none";
|
|
317
|
+
extendStyles(element.style, {
|
|
318
|
+
"touch-action": enable ? "" : "none",
|
|
319
|
+
"-webkit-user-drag": enable ? "" : "none",
|
|
320
|
+
"-webkit-tap-highlight-color": enable ? "" : "transparent",
|
|
321
|
+
"user-select": userSelect,
|
|
322
|
+
"-ms-user-select": userSelect,
|
|
323
|
+
"-webkit-user-select": userSelect,
|
|
324
|
+
"-moz-user-select": userSelect
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
function toggleVisibility(element, enable, importantProperties2) {
|
|
328
|
+
extendStyles(element.style, {
|
|
329
|
+
position: enable ? "" : "fixed",
|
|
330
|
+
top: enable ? "" : "0",
|
|
331
|
+
opacity: enable ? "" : "0",
|
|
332
|
+
left: enable ? "" : "-999em"
|
|
333
|
+
}, importantProperties2);
|
|
334
|
+
}
|
|
335
|
+
function combineTransforms(transform, initialTransform) {
|
|
336
|
+
return initialTransform && initialTransform != "none" ? transform + " " + initialTransform : transform;
|
|
337
|
+
}
|
|
338
|
+
function matchElementSize(target, sourceRect) {
|
|
339
|
+
target.style.width = `${sourceRect.width}px`;
|
|
340
|
+
target.style.height = `${sourceRect.height}px`;
|
|
341
|
+
target.style.transform = getTransform(sourceRect.left, sourceRect.top);
|
|
342
|
+
}
|
|
343
|
+
function getTransform(x, y) {
|
|
344
|
+
return `translate3d(${Math.round(x)}px, ${Math.round(y)}px, 0)`;
|
|
345
|
+
}
|
|
346
|
+
function parseCssTimeUnitsToMs(value) {
|
|
347
|
+
const multiplier = value.toLowerCase().indexOf("ms") > -1 ? 1 : 1e3;
|
|
348
|
+
return parseFloat(value) * multiplier;
|
|
349
|
+
}
|
|
350
|
+
function getTransformTransitionDurationInMs(element) {
|
|
351
|
+
const computedStyle = getComputedStyle(element);
|
|
352
|
+
const transitionedProperties = parseCssPropertyValue(computedStyle, "transition-property");
|
|
353
|
+
const property = transitionedProperties.find((prop) => prop === "transform" || prop === "all");
|
|
354
|
+
if (!property) {
|
|
355
|
+
return 0;
|
|
356
|
+
}
|
|
357
|
+
const propertyIndex = transitionedProperties.indexOf(property);
|
|
358
|
+
const rawDurations = parseCssPropertyValue(computedStyle, "transition-duration");
|
|
359
|
+
const rawDelays = parseCssPropertyValue(computedStyle, "transition-delay");
|
|
360
|
+
return parseCssTimeUnitsToMs(rawDurations[propertyIndex]) + parseCssTimeUnitsToMs(rawDelays[propertyIndex]);
|
|
361
|
+
}
|
|
362
|
+
function parseCssPropertyValue(computedStyle, name) {
|
|
363
|
+
const value = computedStyle.getPropertyValue(name);
|
|
364
|
+
return value.split(",").map((part) => part.trim());
|
|
365
|
+
}
|
|
366
|
+
var importantProperties = /* @__PURE__ */ new Set([
|
|
367
|
+
// Needs to be important, because some `mat-table` sets `position: sticky !important`. See #22781.
|
|
368
|
+
"position"
|
|
369
|
+
]);
|
|
370
|
+
var PreviewRef = class {
|
|
371
|
+
_document;
|
|
372
|
+
_rootElement;
|
|
373
|
+
_direction;
|
|
374
|
+
_initialDomRect;
|
|
375
|
+
_previewTemplate;
|
|
376
|
+
_previewClass;
|
|
377
|
+
_pickupPositionOnPage;
|
|
378
|
+
_initialTransform;
|
|
379
|
+
_zIndex;
|
|
380
|
+
_renderer;
|
|
381
|
+
/** Reference to the view of the preview element. */
|
|
382
|
+
_previewEmbeddedView;
|
|
383
|
+
/** Reference to the preview element. */
|
|
384
|
+
_preview;
|
|
385
|
+
get element() {
|
|
386
|
+
return this._preview;
|
|
387
|
+
}
|
|
388
|
+
constructor(_document, _rootElement, _direction, _initialDomRect, _previewTemplate, _previewClass, _pickupPositionOnPage, _initialTransform, _zIndex, _renderer) {
|
|
389
|
+
this._document = _document;
|
|
390
|
+
this._rootElement = _rootElement;
|
|
391
|
+
this._direction = _direction;
|
|
392
|
+
this._initialDomRect = _initialDomRect;
|
|
393
|
+
this._previewTemplate = _previewTemplate;
|
|
394
|
+
this._previewClass = _previewClass;
|
|
395
|
+
this._pickupPositionOnPage = _pickupPositionOnPage;
|
|
396
|
+
this._initialTransform = _initialTransform;
|
|
397
|
+
this._zIndex = _zIndex;
|
|
398
|
+
this._renderer = _renderer;
|
|
399
|
+
}
|
|
400
|
+
attach(parent) {
|
|
401
|
+
this._preview = this._createPreview();
|
|
402
|
+
parent.appendChild(this._preview);
|
|
403
|
+
if (supportsPopover(this._preview)) {
|
|
404
|
+
this._preview["showPopover"]();
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
destroy() {
|
|
408
|
+
this._preview.remove();
|
|
409
|
+
this._previewEmbeddedView?.destroy();
|
|
410
|
+
this._preview = this._previewEmbeddedView = null;
|
|
411
|
+
}
|
|
412
|
+
setTransform(value) {
|
|
413
|
+
this._preview.style.transform = value;
|
|
414
|
+
}
|
|
415
|
+
getBoundingClientRect() {
|
|
416
|
+
return this._preview.getBoundingClientRect();
|
|
417
|
+
}
|
|
418
|
+
addClass(className) {
|
|
419
|
+
this._preview.classList.add(className);
|
|
420
|
+
}
|
|
421
|
+
getTransitionDuration() {
|
|
422
|
+
return getTransformTransitionDurationInMs(this._preview);
|
|
423
|
+
}
|
|
424
|
+
addEventListener(name, handler) {
|
|
425
|
+
return this._renderer.listen(this._preview, name, handler);
|
|
426
|
+
}
|
|
427
|
+
_createPreview() {
|
|
428
|
+
const previewConfig = this._previewTemplate;
|
|
429
|
+
const previewClass = this._previewClass;
|
|
430
|
+
const previewTemplate = previewConfig ? previewConfig.template : null;
|
|
431
|
+
let preview;
|
|
432
|
+
if (previewTemplate && previewConfig) {
|
|
433
|
+
const rootRect = previewConfig.matchSize ? this._initialDomRect : null;
|
|
434
|
+
const viewRef = previewConfig.viewContainer.createEmbeddedView(previewTemplate, previewConfig.context);
|
|
435
|
+
viewRef.detectChanges();
|
|
436
|
+
preview = getRootNode(viewRef, this._document);
|
|
437
|
+
this._previewEmbeddedView = viewRef;
|
|
438
|
+
if (previewConfig.matchSize) {
|
|
439
|
+
matchElementSize(preview, rootRect);
|
|
440
|
+
} else {
|
|
441
|
+
preview.style.transform = getTransform(this._pickupPositionOnPage.x, this._pickupPositionOnPage.y);
|
|
442
|
+
}
|
|
443
|
+
} else {
|
|
444
|
+
preview = deepCloneNode(this._rootElement);
|
|
445
|
+
matchElementSize(preview, this._initialDomRect);
|
|
446
|
+
if (this._initialTransform) {
|
|
447
|
+
preview.style.transform = this._initialTransform;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
extendStyles(preview.style, {
|
|
451
|
+
// It's important that we disable the pointer events on the preview, because
|
|
452
|
+
// it can throw off the `document.elementFromPoint` calls in the `CdkDropList`.
|
|
453
|
+
"pointer-events": "none",
|
|
454
|
+
// If the preview has a margin, it can throw off our positioning so we reset it. The reset
|
|
455
|
+
// value for `margin-right` needs to be `auto` when opened as a popover, because our
|
|
456
|
+
// positioning is always top/left based, but native popover seems to position itself
|
|
457
|
+
// to the top/right if `<html>` or `<body>` have `dir="rtl"` (see #29604). Setting it
|
|
458
|
+
// to `auto` pushed it to the top/left corner in RTL and is a noop in LTR.
|
|
459
|
+
"margin": supportsPopover(preview) ? "0 auto 0 0" : "0",
|
|
460
|
+
"position": "fixed",
|
|
461
|
+
"top": "0",
|
|
462
|
+
"left": "0",
|
|
463
|
+
"z-index": this._zIndex + ""
|
|
464
|
+
}, importantProperties);
|
|
465
|
+
toggleNativeDragInteractions(preview, false);
|
|
466
|
+
preview.classList.add("cdk-drag-preview");
|
|
467
|
+
preview.setAttribute("popover", "manual");
|
|
468
|
+
preview.setAttribute("dir", this._direction);
|
|
469
|
+
if (previewClass) {
|
|
470
|
+
if (Array.isArray(previewClass)) {
|
|
471
|
+
previewClass.forEach((className) => preview.classList.add(className));
|
|
472
|
+
} else {
|
|
473
|
+
preview.classList.add(previewClass);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return preview;
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
function supportsPopover(element) {
|
|
480
|
+
return "showPopover" in element;
|
|
481
|
+
}
|
|
482
|
+
var passiveEventListenerOptions = {
|
|
483
|
+
passive: true
|
|
484
|
+
};
|
|
485
|
+
var activeEventListenerOptions = {
|
|
486
|
+
passive: false
|
|
487
|
+
};
|
|
488
|
+
var activeCapturingEventOptions$1 = {
|
|
489
|
+
passive: false,
|
|
490
|
+
capture: true
|
|
491
|
+
};
|
|
492
|
+
var MOUSE_EVENT_IGNORE_TIME = 800;
|
|
493
|
+
var PLACEHOLDER_CLASS = "cdk-drag-placeholder";
|
|
494
|
+
var dragImportantProperties = /* @__PURE__ */ new Set([
|
|
495
|
+
// Needs to be important, because some `mat-table` sets `position: sticky !important`. See #22781.
|
|
496
|
+
"position"
|
|
497
|
+
]);
|
|
498
|
+
var DragRef = class {
|
|
499
|
+
_config;
|
|
500
|
+
_document;
|
|
501
|
+
_ngZone;
|
|
502
|
+
_viewportRuler;
|
|
503
|
+
_dragDropRegistry;
|
|
504
|
+
_renderer;
|
|
505
|
+
_rootElementCleanups;
|
|
506
|
+
_cleanupShadowRootSelectStart;
|
|
507
|
+
/** Element displayed next to the user's pointer while the element is dragged. */
|
|
508
|
+
_preview;
|
|
509
|
+
/** Container into which to insert the preview. */
|
|
510
|
+
_previewContainer;
|
|
511
|
+
/** Reference to the view of the placeholder element. */
|
|
512
|
+
_placeholderRef;
|
|
513
|
+
/** Element that is rendered instead of the draggable item while it is being sorted. */
|
|
514
|
+
_placeholder;
|
|
515
|
+
/** Coordinates within the element at which the user picked up the element. */
|
|
516
|
+
_pickupPositionInElement;
|
|
517
|
+
/** Coordinates on the page at which the user picked up the element. */
|
|
518
|
+
_pickupPositionOnPage;
|
|
519
|
+
/**
|
|
520
|
+
* Marker node used to save the place in the DOM where the element was
|
|
521
|
+
* picked up so that it can be restored at the end of the drag sequence.
|
|
522
|
+
*/
|
|
523
|
+
_marker;
|
|
524
|
+
/**
|
|
525
|
+
* Element indicating the position from which the item was picked up initially.
|
|
526
|
+
*/
|
|
527
|
+
_anchor = null;
|
|
528
|
+
/**
|
|
529
|
+
* CSS `transform` applied to the element when it isn't being dragged. We need a
|
|
530
|
+
* passive transform in order for the dragged element to retain its new position
|
|
531
|
+
* after the user has stopped dragging and because we need to know the relative
|
|
532
|
+
* position in case they start dragging again. This corresponds to `element.style.transform`.
|
|
533
|
+
*/
|
|
534
|
+
_passiveTransform = {
|
|
535
|
+
x: 0,
|
|
536
|
+
y: 0
|
|
537
|
+
};
|
|
538
|
+
/** CSS `transform` that is applied to the element while it's being dragged. */
|
|
539
|
+
_activeTransform = {
|
|
540
|
+
x: 0,
|
|
541
|
+
y: 0
|
|
542
|
+
};
|
|
543
|
+
/** Inline `transform` value that the element had before the first dragging sequence. */
|
|
544
|
+
_initialTransform;
|
|
545
|
+
/**
|
|
546
|
+
* Whether the dragging sequence has been started. Doesn't
|
|
547
|
+
* necessarily mean that the element has been moved.
|
|
548
|
+
*/
|
|
549
|
+
_hasStartedDragging = signal(false);
|
|
550
|
+
/** Whether the element has moved since the user started dragging it. */
|
|
551
|
+
_hasMoved;
|
|
552
|
+
/** Drop container in which the DragRef resided when dragging began. */
|
|
553
|
+
_initialContainer;
|
|
554
|
+
/** Index at which the item started in its initial container. */
|
|
555
|
+
_initialIndex;
|
|
556
|
+
/** Cached positions of scrollable parent elements. */
|
|
557
|
+
_parentPositions;
|
|
558
|
+
/** Emits when the item is being moved. */
|
|
559
|
+
_moveEvents = new Subject();
|
|
560
|
+
/** Keeps track of the direction in which the user is dragging along each axis. */
|
|
561
|
+
_pointerDirectionDelta;
|
|
562
|
+
/** Pointer position at which the last change in the delta occurred. */
|
|
563
|
+
_pointerPositionAtLastDirectionChange;
|
|
564
|
+
/** Position of the pointer at the last pointer event. */
|
|
565
|
+
_lastKnownPointerPosition;
|
|
566
|
+
/**
|
|
567
|
+
* Root DOM node of the drag instance. This is the element that will
|
|
568
|
+
* be moved around as the user is dragging.
|
|
569
|
+
*/
|
|
570
|
+
_rootElement;
|
|
571
|
+
/**
|
|
572
|
+
* Nearest ancestor SVG, relative to which coordinates are calculated if dragging SVGElement
|
|
573
|
+
*/
|
|
574
|
+
_ownerSVGElement;
|
|
575
|
+
/**
|
|
576
|
+
* Inline style value of `-webkit-tap-highlight-color` at the time the
|
|
577
|
+
* dragging was started. Used to restore the value once we're done dragging.
|
|
578
|
+
*/
|
|
579
|
+
_rootElementTapHighlight;
|
|
580
|
+
/** Subscription to pointer movement events. */
|
|
581
|
+
_pointerMoveSubscription = Subscription.EMPTY;
|
|
582
|
+
/** Subscription to the event that is dispatched when the user lifts their pointer. */
|
|
583
|
+
_pointerUpSubscription = Subscription.EMPTY;
|
|
584
|
+
/** Subscription to the viewport being scrolled. */
|
|
585
|
+
_scrollSubscription = Subscription.EMPTY;
|
|
586
|
+
/** Subscription to the viewport being resized. */
|
|
587
|
+
_resizeSubscription = Subscription.EMPTY;
|
|
588
|
+
/**
|
|
589
|
+
* Time at which the last touch event occurred. Used to avoid firing the same
|
|
590
|
+
* events multiple times on touch devices where the browser will fire a fake
|
|
591
|
+
* mouse event for each touch event, after a certain time.
|
|
592
|
+
*/
|
|
593
|
+
_lastTouchEventTime;
|
|
594
|
+
/** Time at which the last dragging sequence was started. */
|
|
595
|
+
_dragStartTime;
|
|
596
|
+
/** Cached reference to the boundary element. */
|
|
597
|
+
_boundaryElement = null;
|
|
598
|
+
/** Whether the native dragging interactions have been enabled on the root element. */
|
|
599
|
+
_nativeInteractionsEnabled = true;
|
|
600
|
+
/** Client rect of the root element when the dragging sequence has started. */
|
|
601
|
+
_initialDomRect;
|
|
602
|
+
/** Cached dimensions of the preview element. Should be read via `_getPreviewRect`. */
|
|
603
|
+
_previewRect;
|
|
604
|
+
/** Cached dimensions of the boundary element. */
|
|
605
|
+
_boundaryRect;
|
|
606
|
+
/** Element that will be used as a template to create the draggable item's preview. */
|
|
607
|
+
_previewTemplate;
|
|
608
|
+
/** Template for placeholder element rendered to show where a draggable would be dropped. */
|
|
609
|
+
_placeholderTemplate;
|
|
610
|
+
/** Elements that can be used to drag the draggable item. */
|
|
611
|
+
_handles = [];
|
|
612
|
+
/** Registered handles that are currently disabled. */
|
|
613
|
+
_disabledHandles = /* @__PURE__ */ new Set();
|
|
614
|
+
/** Droppable container that the draggable is a part of. */
|
|
615
|
+
_dropContainer;
|
|
616
|
+
/** Layout direction of the item. */
|
|
617
|
+
_direction = "ltr";
|
|
618
|
+
/** Ref that the current drag item is nested in. */
|
|
619
|
+
_parentDragRef;
|
|
620
|
+
/**
|
|
621
|
+
* Cached shadow root that the element is placed in. `null` means that the element isn't in
|
|
622
|
+
* the shadow DOM and `undefined` means that it hasn't been resolved yet. Should be read via
|
|
623
|
+
* `_getShadowRoot`, not directly.
|
|
624
|
+
*/
|
|
625
|
+
_cachedShadowRoot;
|
|
626
|
+
/** Axis along which dragging is locked. */
|
|
627
|
+
lockAxis;
|
|
628
|
+
/**
|
|
629
|
+
* Amount of milliseconds to wait after the user has put their
|
|
630
|
+
* pointer down before starting to drag the element.
|
|
631
|
+
*/
|
|
632
|
+
dragStartDelay = 0;
|
|
633
|
+
/** Class to be added to the preview element. */
|
|
634
|
+
previewClass;
|
|
635
|
+
/**
|
|
636
|
+
* If the parent of the dragged element has a `scale` transform, it can throw off the
|
|
637
|
+
* positioning when the user starts dragging. Use this input to notify the CDK of the scale.
|
|
638
|
+
*/
|
|
639
|
+
scale = 1;
|
|
640
|
+
/** Whether starting to drag this element is disabled. */
|
|
641
|
+
get disabled() {
|
|
642
|
+
return this._disabled || !!(this._dropContainer && this._dropContainer.disabled);
|
|
643
|
+
}
|
|
644
|
+
set disabled(value) {
|
|
645
|
+
if (value !== this._disabled) {
|
|
646
|
+
this._disabled = value;
|
|
647
|
+
this._toggleNativeDragInteractions();
|
|
648
|
+
this._handles.forEach((handle) => toggleNativeDragInteractions(handle, value));
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
_disabled = false;
|
|
652
|
+
/** Emits as the drag sequence is being prepared. */
|
|
653
|
+
beforeStarted = new Subject();
|
|
654
|
+
/** Emits when the user starts dragging the item. */
|
|
655
|
+
started = new Subject();
|
|
656
|
+
/** Emits when the user has released a drag item, before any animations have started. */
|
|
657
|
+
released = new Subject();
|
|
658
|
+
/** Emits when the user stops dragging an item in the container. */
|
|
659
|
+
ended = new Subject();
|
|
660
|
+
/** Emits when the user has moved the item into a new container. */
|
|
661
|
+
entered = new Subject();
|
|
662
|
+
/** Emits when the user removes the item its container by dragging it into another container. */
|
|
663
|
+
exited = new Subject();
|
|
664
|
+
/** Emits when the user drops the item inside a container. */
|
|
665
|
+
dropped = new Subject();
|
|
666
|
+
/**
|
|
667
|
+
* Emits as the user is dragging the item. Use with caution,
|
|
668
|
+
* because this event will fire for every pixel that the user has dragged.
|
|
669
|
+
*/
|
|
670
|
+
moved = this._moveEvents;
|
|
671
|
+
/** Arbitrary data that can be attached to the drag item. */
|
|
672
|
+
data;
|
|
673
|
+
/**
|
|
674
|
+
* Function that can be used to customize the logic of how the position of the drag item
|
|
675
|
+
* is limited while it's being dragged. Gets called with a point containing the current position
|
|
676
|
+
* of the user's pointer on the page, a reference to the item being dragged and its dimensions.
|
|
677
|
+
* Should return a point describing where the item should be rendered.
|
|
678
|
+
*/
|
|
679
|
+
constrainPosition;
|
|
680
|
+
constructor(element, _config, _document, _ngZone, _viewportRuler, _dragDropRegistry, _renderer) {
|
|
681
|
+
this._config = _config;
|
|
682
|
+
this._document = _document;
|
|
683
|
+
this._ngZone = _ngZone;
|
|
684
|
+
this._viewportRuler = _viewportRuler;
|
|
685
|
+
this._dragDropRegistry = _dragDropRegistry;
|
|
686
|
+
this._renderer = _renderer;
|
|
687
|
+
this.withRootElement(element).withParent(_config.parentDragRef || null);
|
|
688
|
+
this._parentPositions = new ParentPositionTracker(_document);
|
|
689
|
+
_dragDropRegistry.registerDragItem(this);
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* Returns the element that is being used as a placeholder
|
|
693
|
+
* while the current element is being dragged.
|
|
694
|
+
*/
|
|
695
|
+
getPlaceholderElement() {
|
|
696
|
+
return this._placeholder;
|
|
697
|
+
}
|
|
698
|
+
/** Returns the root draggable element. */
|
|
699
|
+
getRootElement() {
|
|
700
|
+
return this._rootElement;
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* Gets the currently-visible element that represents the drag item.
|
|
704
|
+
* While dragging this is the placeholder, otherwise it's the root element.
|
|
705
|
+
*/
|
|
706
|
+
getVisibleElement() {
|
|
707
|
+
return this.isDragging() ? this.getPlaceholderElement() : this.getRootElement();
|
|
708
|
+
}
|
|
709
|
+
/** Registers the handles that can be used to drag the element. */
|
|
710
|
+
withHandles(handles) {
|
|
711
|
+
this._handles = handles.map((handle) => coerceElement(handle));
|
|
712
|
+
this._handles.forEach((handle) => toggleNativeDragInteractions(handle, this.disabled));
|
|
713
|
+
this._toggleNativeDragInteractions();
|
|
714
|
+
const disabledHandles = /* @__PURE__ */ new Set();
|
|
715
|
+
this._disabledHandles.forEach((handle) => {
|
|
716
|
+
if (this._handles.indexOf(handle) > -1) {
|
|
717
|
+
disabledHandles.add(handle);
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
this._disabledHandles = disabledHandles;
|
|
721
|
+
return this;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Registers the template that should be used for the drag preview.
|
|
725
|
+
* @param template Template that from which to stamp out the preview.
|
|
726
|
+
*/
|
|
727
|
+
withPreviewTemplate(template) {
|
|
728
|
+
this._previewTemplate = template;
|
|
729
|
+
return this;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Registers the template that should be used for the drag placeholder.
|
|
733
|
+
* @param template Template that from which to stamp out the placeholder.
|
|
734
|
+
*/
|
|
735
|
+
withPlaceholderTemplate(template) {
|
|
736
|
+
this._placeholderTemplate = template;
|
|
737
|
+
return this;
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
* Sets an alternate drag root element. The root element is the element that will be moved as
|
|
741
|
+
* the user is dragging. Passing an alternate root element is useful when trying to enable
|
|
742
|
+
* dragging on an element that you might not have access to.
|
|
743
|
+
*/
|
|
744
|
+
withRootElement(rootElement) {
|
|
745
|
+
const element = coerceElement(rootElement);
|
|
746
|
+
if (element !== this._rootElement) {
|
|
747
|
+
this._removeRootElementListeners();
|
|
748
|
+
const renderer = this._renderer;
|
|
749
|
+
this._rootElementCleanups = this._ngZone.runOutsideAngular(() => [renderer.listen(element, "mousedown", this._pointerDown, activeEventListenerOptions), renderer.listen(element, "touchstart", this._pointerDown, passiveEventListenerOptions), renderer.listen(element, "dragstart", this._nativeDragStart, activeEventListenerOptions)]);
|
|
750
|
+
this._initialTransform = void 0;
|
|
751
|
+
this._rootElement = element;
|
|
752
|
+
}
|
|
753
|
+
if (typeof SVGElement !== "undefined" && this._rootElement instanceof SVGElement) {
|
|
754
|
+
this._ownerSVGElement = this._rootElement.ownerSVGElement;
|
|
755
|
+
}
|
|
756
|
+
return this;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Element to which the draggable's position will be constrained.
|
|
760
|
+
*/
|
|
761
|
+
withBoundaryElement(boundaryElement) {
|
|
762
|
+
this._boundaryElement = boundaryElement ? coerceElement(boundaryElement) : null;
|
|
763
|
+
this._resizeSubscription.unsubscribe();
|
|
764
|
+
if (boundaryElement) {
|
|
765
|
+
this._resizeSubscription = this._viewportRuler.change(10).subscribe(() => this._containInsideBoundaryOnResize());
|
|
766
|
+
}
|
|
767
|
+
return this;
|
|
768
|
+
}
|
|
769
|
+
/** Sets the parent ref that the ref is nested in. */
|
|
770
|
+
withParent(parent) {
|
|
771
|
+
this._parentDragRef = parent;
|
|
772
|
+
return this;
|
|
773
|
+
}
|
|
774
|
+
/** Removes the dragging functionality from the DOM element. */
|
|
775
|
+
dispose() {
|
|
776
|
+
this._removeRootElementListeners();
|
|
777
|
+
if (this.isDragging()) {
|
|
778
|
+
this._rootElement?.remove();
|
|
779
|
+
}
|
|
780
|
+
this._marker?.remove();
|
|
781
|
+
this._destroyPreview();
|
|
782
|
+
this._destroyPlaceholder();
|
|
783
|
+
this._dragDropRegistry.removeDragItem(this);
|
|
784
|
+
this._removeListeners();
|
|
785
|
+
this.beforeStarted.complete();
|
|
786
|
+
this.started.complete();
|
|
787
|
+
this.released.complete();
|
|
788
|
+
this.ended.complete();
|
|
789
|
+
this.entered.complete();
|
|
790
|
+
this.exited.complete();
|
|
791
|
+
this.dropped.complete();
|
|
792
|
+
this._moveEvents.complete();
|
|
793
|
+
this._handles = [];
|
|
794
|
+
this._disabledHandles.clear();
|
|
795
|
+
this._dropContainer = void 0;
|
|
796
|
+
this._resizeSubscription.unsubscribe();
|
|
797
|
+
this._parentPositions.clear();
|
|
798
|
+
this._boundaryElement = this._rootElement = this._ownerSVGElement = this._placeholderTemplate = this._previewTemplate = this._marker = this._parentDragRef = null;
|
|
799
|
+
}
|
|
800
|
+
/** Checks whether the element is currently being dragged. */
|
|
801
|
+
isDragging() {
|
|
802
|
+
return this._hasStartedDragging() && this._dragDropRegistry.isDragging(this);
|
|
803
|
+
}
|
|
804
|
+
/** Resets a standalone drag item to its initial position. */
|
|
805
|
+
reset() {
|
|
806
|
+
this._rootElement.style.transform = this._initialTransform || "";
|
|
807
|
+
this._activeTransform = {
|
|
808
|
+
x: 0,
|
|
809
|
+
y: 0
|
|
810
|
+
};
|
|
811
|
+
this._passiveTransform = {
|
|
812
|
+
x: 0,
|
|
813
|
+
y: 0
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
/** Resets drag item to end of boundary element. */
|
|
817
|
+
resetToBoundary() {
|
|
818
|
+
if (
|
|
819
|
+
// can be null if the drag item was never dragged.
|
|
820
|
+
this._boundaryElement && this._rootElement && // check if we are overflowing off our boundary element
|
|
821
|
+
isOverflowingParent(this._boundaryElement.getBoundingClientRect(), this._rootElement.getBoundingClientRect())
|
|
822
|
+
) {
|
|
823
|
+
const parentRect = this._boundaryElement.getBoundingClientRect();
|
|
824
|
+
const childRect = this._rootElement.getBoundingClientRect();
|
|
825
|
+
let offsetX = 0;
|
|
826
|
+
let offsetY = 0;
|
|
827
|
+
if (childRect.left < parentRect.left) {
|
|
828
|
+
offsetX = parentRect.left - childRect.left;
|
|
829
|
+
} else if (childRect.right > parentRect.right) {
|
|
830
|
+
offsetX = parentRect.right - childRect.right;
|
|
831
|
+
}
|
|
832
|
+
if (childRect.top < parentRect.top) {
|
|
833
|
+
offsetY = parentRect.top - childRect.top;
|
|
834
|
+
} else if (childRect.bottom > parentRect.bottom) {
|
|
835
|
+
offsetY = parentRect.bottom - childRect.bottom;
|
|
836
|
+
}
|
|
837
|
+
const currentLeft = this._activeTransform.x;
|
|
838
|
+
const currentTop = this._activeTransform.y;
|
|
839
|
+
let x = currentLeft + offsetX, y = currentTop + offsetY;
|
|
840
|
+
this._rootElement.style.transform = getTransform(x, y);
|
|
841
|
+
this._activeTransform = {
|
|
842
|
+
x,
|
|
843
|
+
y
|
|
844
|
+
};
|
|
845
|
+
this._passiveTransform = {
|
|
846
|
+
x,
|
|
847
|
+
y
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Sets a handle as disabled. While a handle is disabled, it'll capture and interrupt dragging.
|
|
853
|
+
* @param handle Handle element that should be disabled.
|
|
854
|
+
*/
|
|
855
|
+
disableHandle(handle) {
|
|
856
|
+
if (!this._disabledHandles.has(handle) && this._handles.indexOf(handle) > -1) {
|
|
857
|
+
this._disabledHandles.add(handle);
|
|
858
|
+
toggleNativeDragInteractions(handle, true);
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Enables a handle, if it has been disabled.
|
|
863
|
+
* @param handle Handle element to be enabled.
|
|
864
|
+
*/
|
|
865
|
+
enableHandle(handle) {
|
|
866
|
+
if (this._disabledHandles.has(handle)) {
|
|
867
|
+
this._disabledHandles.delete(handle);
|
|
868
|
+
toggleNativeDragInteractions(handle, this.disabled);
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
/** Sets the layout direction of the draggable item. */
|
|
872
|
+
withDirection(direction) {
|
|
873
|
+
this._direction = direction;
|
|
874
|
+
return this;
|
|
875
|
+
}
|
|
876
|
+
/** Sets the container that the item is part of. */
|
|
877
|
+
_withDropContainer(container) {
|
|
878
|
+
this._dropContainer = container;
|
|
879
|
+
}
|
|
880
|
+
/**
|
|
881
|
+
* Gets the current position in pixels the draggable outside of a drop container.
|
|
882
|
+
*/
|
|
883
|
+
getFreeDragPosition() {
|
|
884
|
+
const position = this.isDragging() ? this._activeTransform : this._passiveTransform;
|
|
885
|
+
return {
|
|
886
|
+
x: position.x,
|
|
887
|
+
y: position.y
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
/**
|
|
891
|
+
* Sets the current position in pixels the draggable outside of a drop container.
|
|
892
|
+
* @param value New position to be set.
|
|
893
|
+
*/
|
|
894
|
+
setFreeDragPosition(value) {
|
|
895
|
+
this._activeTransform = {
|
|
896
|
+
x: 0,
|
|
897
|
+
y: 0
|
|
898
|
+
};
|
|
899
|
+
this._passiveTransform.x = value.x;
|
|
900
|
+
this._passiveTransform.y = value.y;
|
|
901
|
+
if (!this._dropContainer) {
|
|
902
|
+
this._applyRootElementTransform(value.x, value.y);
|
|
903
|
+
}
|
|
904
|
+
return this;
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Sets the container into which to insert the preview element.
|
|
908
|
+
* @param value Container into which to insert the preview.
|
|
909
|
+
*/
|
|
910
|
+
withPreviewContainer(value) {
|
|
911
|
+
this._previewContainer = value;
|
|
912
|
+
return this;
|
|
913
|
+
}
|
|
914
|
+
/** Updates the item's sort order based on the last-known pointer position. */
|
|
915
|
+
_sortFromLastPointerPosition() {
|
|
916
|
+
const position = this._lastKnownPointerPosition;
|
|
917
|
+
if (position && this._dropContainer) {
|
|
918
|
+
this._updateActiveDropContainer(this._getConstrainedPointerPosition(position), position);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
/** Unsubscribes from the global subscriptions. */
|
|
922
|
+
_removeListeners() {
|
|
923
|
+
this._pointerMoveSubscription.unsubscribe();
|
|
924
|
+
this._pointerUpSubscription.unsubscribe();
|
|
925
|
+
this._scrollSubscription.unsubscribe();
|
|
926
|
+
this._cleanupShadowRootSelectStart?.();
|
|
927
|
+
this._cleanupShadowRootSelectStart = void 0;
|
|
928
|
+
}
|
|
929
|
+
/** Destroys the preview element and its ViewRef. */
|
|
930
|
+
_destroyPreview() {
|
|
931
|
+
this._preview?.destroy();
|
|
932
|
+
this._preview = null;
|
|
933
|
+
}
|
|
934
|
+
/** Destroys the placeholder element and its ViewRef. */
|
|
935
|
+
_destroyPlaceholder() {
|
|
936
|
+
this._anchor?.remove();
|
|
937
|
+
this._placeholder?.remove();
|
|
938
|
+
this._placeholderRef?.destroy();
|
|
939
|
+
this._placeholder = this._anchor = this._placeholderRef = null;
|
|
940
|
+
}
|
|
941
|
+
/** Handler for the `mousedown`/`touchstart` events. */
|
|
942
|
+
_pointerDown = (event) => {
|
|
943
|
+
this.beforeStarted.next();
|
|
944
|
+
if (this._handles.length) {
|
|
945
|
+
const targetHandle = this._getTargetHandle(event);
|
|
946
|
+
if (targetHandle && !this._disabledHandles.has(targetHandle) && !this.disabled) {
|
|
947
|
+
this._initializeDragSequence(targetHandle, event);
|
|
948
|
+
}
|
|
949
|
+
} else if (!this.disabled) {
|
|
950
|
+
this._initializeDragSequence(this._rootElement, event);
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
/** Handler that is invoked when the user moves their pointer after they've initiated a drag. */
|
|
954
|
+
_pointerMove = (event) => {
|
|
955
|
+
const pointerPosition = this._getPointerPositionOnPage(event);
|
|
956
|
+
if (!this._hasStartedDragging()) {
|
|
957
|
+
const distanceX = Math.abs(pointerPosition.x - this._pickupPositionOnPage.x);
|
|
958
|
+
const distanceY = Math.abs(pointerPosition.y - this._pickupPositionOnPage.y);
|
|
959
|
+
const isOverThreshold = distanceX + distanceY >= this._config.dragStartThreshold;
|
|
960
|
+
if (isOverThreshold) {
|
|
961
|
+
const isDelayElapsed = Date.now() >= this._dragStartTime + this._getDragStartDelay(event);
|
|
962
|
+
const container = this._dropContainer;
|
|
963
|
+
if (!isDelayElapsed) {
|
|
964
|
+
this._endDragSequence(event);
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
if (!container || !container.isDragging() && !container.isReceiving()) {
|
|
968
|
+
if (event.cancelable) {
|
|
969
|
+
event.preventDefault();
|
|
970
|
+
}
|
|
971
|
+
this._hasStartedDragging.set(true);
|
|
972
|
+
this._ngZone.run(() => this._startDragSequence(event));
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
if (event.cancelable) {
|
|
978
|
+
event.preventDefault();
|
|
979
|
+
}
|
|
980
|
+
const constrainedPointerPosition = this._getConstrainedPointerPosition(pointerPosition);
|
|
981
|
+
this._hasMoved = true;
|
|
982
|
+
this._lastKnownPointerPosition = pointerPosition;
|
|
983
|
+
this._updatePointerDirectionDelta(constrainedPointerPosition);
|
|
984
|
+
if (this._dropContainer) {
|
|
985
|
+
this._updateActiveDropContainer(constrainedPointerPosition, pointerPosition);
|
|
986
|
+
} else {
|
|
987
|
+
const offset = this.constrainPosition ? this._initialDomRect : this._pickupPositionOnPage;
|
|
988
|
+
const activeTransform = this._activeTransform;
|
|
989
|
+
activeTransform.x = constrainedPointerPosition.x - offset.x + this._passiveTransform.x;
|
|
990
|
+
activeTransform.y = constrainedPointerPosition.y - offset.y + this._passiveTransform.y;
|
|
991
|
+
this._applyRootElementTransform(activeTransform.x, activeTransform.y);
|
|
992
|
+
}
|
|
993
|
+
if (this._moveEvents.observers.length) {
|
|
994
|
+
this._ngZone.run(() => {
|
|
995
|
+
this._moveEvents.next({
|
|
996
|
+
source: this,
|
|
997
|
+
pointerPosition: constrainedPointerPosition,
|
|
998
|
+
event,
|
|
999
|
+
distance: this._getDragDistance(constrainedPointerPosition),
|
|
1000
|
+
delta: this._pointerDirectionDelta
|
|
1001
|
+
});
|
|
1002
|
+
});
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
/** Handler that is invoked when the user lifts their pointer up, after initiating a drag. */
|
|
1006
|
+
_pointerUp = (event) => {
|
|
1007
|
+
this._endDragSequence(event);
|
|
1008
|
+
};
|
|
1009
|
+
/**
|
|
1010
|
+
* Clears subscriptions and stops the dragging sequence.
|
|
1011
|
+
* @param event Browser event object that ended the sequence.
|
|
1012
|
+
*/
|
|
1013
|
+
_endDragSequence(event) {
|
|
1014
|
+
if (!this._dragDropRegistry.isDragging(this)) {
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
this._removeListeners();
|
|
1018
|
+
this._dragDropRegistry.stopDragging(this);
|
|
1019
|
+
this._toggleNativeDragInteractions();
|
|
1020
|
+
if (this._handles) {
|
|
1021
|
+
this._rootElement.style.webkitTapHighlightColor = this._rootElementTapHighlight;
|
|
1022
|
+
}
|
|
1023
|
+
if (!this._hasStartedDragging()) {
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
this.released.next({
|
|
1027
|
+
source: this,
|
|
1028
|
+
event
|
|
1029
|
+
});
|
|
1030
|
+
if (this._dropContainer) {
|
|
1031
|
+
this._dropContainer._stopScrolling();
|
|
1032
|
+
this._animatePreviewToPlaceholder().then(() => {
|
|
1033
|
+
this._cleanupDragArtifacts(event);
|
|
1034
|
+
this._cleanupCachedDimensions();
|
|
1035
|
+
this._dragDropRegistry.stopDragging(this);
|
|
1036
|
+
});
|
|
1037
|
+
} else {
|
|
1038
|
+
this._passiveTransform.x = this._activeTransform.x;
|
|
1039
|
+
const pointerPosition = this._getPointerPositionOnPage(event);
|
|
1040
|
+
this._passiveTransform.y = this._activeTransform.y;
|
|
1041
|
+
this._ngZone.run(() => {
|
|
1042
|
+
this.ended.next({
|
|
1043
|
+
source: this,
|
|
1044
|
+
distance: this._getDragDistance(pointerPosition),
|
|
1045
|
+
dropPoint: pointerPosition,
|
|
1046
|
+
event
|
|
1047
|
+
});
|
|
1048
|
+
});
|
|
1049
|
+
this._cleanupCachedDimensions();
|
|
1050
|
+
this._dragDropRegistry.stopDragging(this);
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
/** Starts the dragging sequence. */
|
|
1054
|
+
_startDragSequence(event) {
|
|
1055
|
+
if (isTouchEvent(event)) {
|
|
1056
|
+
this._lastTouchEventTime = Date.now();
|
|
1057
|
+
}
|
|
1058
|
+
this._toggleNativeDragInteractions();
|
|
1059
|
+
const shadowRoot = this._getShadowRoot();
|
|
1060
|
+
const dropContainer = this._dropContainer;
|
|
1061
|
+
if (shadowRoot) {
|
|
1062
|
+
this._ngZone.runOutsideAngular(() => {
|
|
1063
|
+
this._cleanupShadowRootSelectStart = this._renderer.listen(shadowRoot, "selectstart", shadowDomSelectStart, activeCapturingEventOptions$1);
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
if (dropContainer) {
|
|
1067
|
+
const element = this._rootElement;
|
|
1068
|
+
const parent = element.parentNode;
|
|
1069
|
+
const placeholder = this._placeholder = this._createPlaceholderElement();
|
|
1070
|
+
const marker = this._marker = this._marker || this._document.createComment(typeof ngDevMode === "undefined" || ngDevMode ? "cdk-drag-marker" : "");
|
|
1071
|
+
parent.insertBefore(marker, element);
|
|
1072
|
+
this._initialTransform = element.style.transform || "";
|
|
1073
|
+
this._preview = new PreviewRef(this._document, this._rootElement, this._direction, this._initialDomRect, this._previewTemplate || null, this.previewClass || null, this._pickupPositionOnPage, this._initialTransform, this._config.zIndex || 1e3, this._renderer);
|
|
1074
|
+
this._preview.attach(this._getPreviewInsertionPoint(parent, shadowRoot));
|
|
1075
|
+
toggleVisibility(element, false, dragImportantProperties);
|
|
1076
|
+
this._document.body.appendChild(parent.replaceChild(placeholder, element));
|
|
1077
|
+
this.started.next({
|
|
1078
|
+
source: this,
|
|
1079
|
+
event
|
|
1080
|
+
});
|
|
1081
|
+
dropContainer.start();
|
|
1082
|
+
this._initialContainer = dropContainer;
|
|
1083
|
+
this._initialIndex = dropContainer.getItemIndex(this);
|
|
1084
|
+
} else {
|
|
1085
|
+
this.started.next({
|
|
1086
|
+
source: this,
|
|
1087
|
+
event
|
|
1088
|
+
});
|
|
1089
|
+
this._initialContainer = this._initialIndex = void 0;
|
|
1090
|
+
}
|
|
1091
|
+
this._parentPositions.cache(dropContainer ? dropContainer.getScrollableParents() : []);
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* Sets up the different variables and subscriptions
|
|
1095
|
+
* that will be necessary for the dragging sequence.
|
|
1096
|
+
* @param referenceElement Element that started the drag sequence.
|
|
1097
|
+
* @param event Browser event object that started the sequence.
|
|
1098
|
+
*/
|
|
1099
|
+
_initializeDragSequence(referenceElement, event) {
|
|
1100
|
+
if (this._parentDragRef) {
|
|
1101
|
+
event.stopPropagation();
|
|
1102
|
+
}
|
|
1103
|
+
const isDragging = this.isDragging();
|
|
1104
|
+
const isTouchSequence = isTouchEvent(event);
|
|
1105
|
+
const isAuxiliaryMouseButton = !isTouchSequence && event.button !== 0;
|
|
1106
|
+
const rootElement = this._rootElement;
|
|
1107
|
+
const target = _getEventTarget(event);
|
|
1108
|
+
const isSyntheticEvent = !isTouchSequence && this._lastTouchEventTime && this._lastTouchEventTime + MOUSE_EVENT_IGNORE_TIME > Date.now();
|
|
1109
|
+
const isFakeEvent = isTouchSequence ? isFakeTouchstartFromScreenReader(event) : isFakeMousedownFromScreenReader(event);
|
|
1110
|
+
if (target && target.draggable && event.type === "mousedown") {
|
|
1111
|
+
event.preventDefault();
|
|
1112
|
+
}
|
|
1113
|
+
if (isDragging || isAuxiliaryMouseButton || isSyntheticEvent || isFakeEvent) {
|
|
1114
|
+
return;
|
|
1115
|
+
}
|
|
1116
|
+
if (this._handles.length) {
|
|
1117
|
+
const rootStyles = rootElement.style;
|
|
1118
|
+
this._rootElementTapHighlight = rootStyles.webkitTapHighlightColor || "";
|
|
1119
|
+
rootStyles.webkitTapHighlightColor = "transparent";
|
|
1120
|
+
}
|
|
1121
|
+
this._hasMoved = false;
|
|
1122
|
+
this._hasStartedDragging.set(this._hasMoved);
|
|
1123
|
+
this._removeListeners();
|
|
1124
|
+
this._initialDomRect = this._rootElement.getBoundingClientRect();
|
|
1125
|
+
this._pointerMoveSubscription = this._dragDropRegistry.pointerMove.subscribe(this._pointerMove);
|
|
1126
|
+
this._pointerUpSubscription = this._dragDropRegistry.pointerUp.subscribe(this._pointerUp);
|
|
1127
|
+
this._scrollSubscription = this._dragDropRegistry.scrolled(this._getShadowRoot()).subscribe((scrollEvent) => this._updateOnScroll(scrollEvent));
|
|
1128
|
+
if (this._boundaryElement) {
|
|
1129
|
+
this._boundaryRect = getMutableClientRect(this._boundaryElement);
|
|
1130
|
+
}
|
|
1131
|
+
const previewTemplate = this._previewTemplate;
|
|
1132
|
+
this._pickupPositionInElement = previewTemplate && previewTemplate.template && !previewTemplate.matchSize ? {
|
|
1133
|
+
x: 0,
|
|
1134
|
+
y: 0
|
|
1135
|
+
} : this._getPointerPositionInElement(this._initialDomRect, referenceElement, event);
|
|
1136
|
+
const pointerPosition = this._pickupPositionOnPage = this._lastKnownPointerPosition = this._getPointerPositionOnPage(event);
|
|
1137
|
+
this._pointerDirectionDelta = {
|
|
1138
|
+
x: 0,
|
|
1139
|
+
y: 0
|
|
1140
|
+
};
|
|
1141
|
+
this._pointerPositionAtLastDirectionChange = {
|
|
1142
|
+
x: pointerPosition.x,
|
|
1143
|
+
y: pointerPosition.y
|
|
1144
|
+
};
|
|
1145
|
+
this._dragStartTime = Date.now();
|
|
1146
|
+
this._dragDropRegistry.startDragging(this, event);
|
|
1147
|
+
}
|
|
1148
|
+
/** Cleans up the DOM artifacts that were added to facilitate the element being dragged. */
|
|
1149
|
+
_cleanupDragArtifacts(event) {
|
|
1150
|
+
toggleVisibility(this._rootElement, true, dragImportantProperties);
|
|
1151
|
+
this._marker.parentNode.replaceChild(this._rootElement, this._marker);
|
|
1152
|
+
this._destroyPreview();
|
|
1153
|
+
this._destroyPlaceholder();
|
|
1154
|
+
this._initialDomRect = this._boundaryRect = this._previewRect = this._initialTransform = void 0;
|
|
1155
|
+
this._ngZone.run(() => {
|
|
1156
|
+
const container = this._dropContainer;
|
|
1157
|
+
const currentIndex = container.getItemIndex(this);
|
|
1158
|
+
const pointerPosition = this._getPointerPositionOnPage(event);
|
|
1159
|
+
const distance = this._getDragDistance(pointerPosition);
|
|
1160
|
+
const isPointerOverContainer = container._isOverContainer(pointerPosition.x, pointerPosition.y);
|
|
1161
|
+
this.ended.next({
|
|
1162
|
+
source: this,
|
|
1163
|
+
distance,
|
|
1164
|
+
dropPoint: pointerPosition,
|
|
1165
|
+
event
|
|
1166
|
+
});
|
|
1167
|
+
this.dropped.next({
|
|
1168
|
+
item: this,
|
|
1169
|
+
currentIndex,
|
|
1170
|
+
previousIndex: this._initialIndex,
|
|
1171
|
+
container,
|
|
1172
|
+
previousContainer: this._initialContainer,
|
|
1173
|
+
isPointerOverContainer,
|
|
1174
|
+
distance,
|
|
1175
|
+
dropPoint: pointerPosition,
|
|
1176
|
+
event
|
|
1177
|
+
});
|
|
1178
|
+
container.drop(this, currentIndex, this._initialIndex, this._initialContainer, isPointerOverContainer, distance, pointerPosition, event);
|
|
1179
|
+
this._dropContainer = this._initialContainer;
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Updates the item's position in its drop container, or moves it
|
|
1184
|
+
* into a new one, depending on its current drag position.
|
|
1185
|
+
*/
|
|
1186
|
+
_updateActiveDropContainer({
|
|
1187
|
+
x,
|
|
1188
|
+
y
|
|
1189
|
+
}, {
|
|
1190
|
+
x: rawX,
|
|
1191
|
+
y: rawY
|
|
1192
|
+
}) {
|
|
1193
|
+
let newContainer = this._initialContainer._getSiblingContainerFromPosition(this, x, y);
|
|
1194
|
+
if (!newContainer && this._dropContainer !== this._initialContainer && this._initialContainer._isOverContainer(x, y)) {
|
|
1195
|
+
newContainer = this._initialContainer;
|
|
1196
|
+
}
|
|
1197
|
+
if (newContainer && newContainer !== this._dropContainer) {
|
|
1198
|
+
this._ngZone.run(() => {
|
|
1199
|
+
const exitIndex = this._dropContainer.getItemIndex(this);
|
|
1200
|
+
const nextItemElement = this._dropContainer.getItemAtIndex(exitIndex + 1)?.getVisibleElement() || null;
|
|
1201
|
+
this.exited.next({
|
|
1202
|
+
item: this,
|
|
1203
|
+
container: this._dropContainer
|
|
1204
|
+
});
|
|
1205
|
+
this._dropContainer.exit(this);
|
|
1206
|
+
this._conditionallyInsertAnchor(newContainer, this._dropContainer, nextItemElement);
|
|
1207
|
+
this._dropContainer = newContainer;
|
|
1208
|
+
this._dropContainer.enter(
|
|
1209
|
+
this,
|
|
1210
|
+
x,
|
|
1211
|
+
y,
|
|
1212
|
+
// If we're re-entering the initial container and sorting is disabled,
|
|
1213
|
+
// put item the into its starting index to begin with.
|
|
1214
|
+
newContainer === this._initialContainer && newContainer.sortingDisabled ? this._initialIndex : void 0
|
|
1215
|
+
);
|
|
1216
|
+
this.entered.next({
|
|
1217
|
+
item: this,
|
|
1218
|
+
container: newContainer,
|
|
1219
|
+
currentIndex: newContainer.getItemIndex(this)
|
|
1220
|
+
});
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
if (this.isDragging()) {
|
|
1224
|
+
this._dropContainer._startScrollingIfNecessary(rawX, rawY);
|
|
1225
|
+
this._dropContainer._sortItem(this, x, y, this._pointerDirectionDelta);
|
|
1226
|
+
if (this.constrainPosition) {
|
|
1227
|
+
this._applyPreviewTransform(x, y);
|
|
1228
|
+
} else {
|
|
1229
|
+
this._applyPreviewTransform(x - this._pickupPositionInElement.x, y - this._pickupPositionInElement.y);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Animates the preview element from its current position to the location of the drop placeholder.
|
|
1235
|
+
* @returns Promise that resolves when the animation completes.
|
|
1236
|
+
*/
|
|
1237
|
+
_animatePreviewToPlaceholder() {
|
|
1238
|
+
if (!this._hasMoved) {
|
|
1239
|
+
return Promise.resolve();
|
|
1240
|
+
}
|
|
1241
|
+
const placeholderRect = this._placeholder.getBoundingClientRect();
|
|
1242
|
+
this._preview.addClass("cdk-drag-animating");
|
|
1243
|
+
this._applyPreviewTransform(placeholderRect.left, placeholderRect.top);
|
|
1244
|
+
const duration = this._preview.getTransitionDuration();
|
|
1245
|
+
if (duration === 0) {
|
|
1246
|
+
return Promise.resolve();
|
|
1247
|
+
}
|
|
1248
|
+
return this._ngZone.runOutsideAngular(() => {
|
|
1249
|
+
return new Promise((resolve) => {
|
|
1250
|
+
const handler = (event) => {
|
|
1251
|
+
if (!event || this._preview && _getEventTarget(event) === this._preview.element && event.propertyName === "transform") {
|
|
1252
|
+
cleanupListener();
|
|
1253
|
+
resolve();
|
|
1254
|
+
clearTimeout(timeout);
|
|
1255
|
+
}
|
|
1256
|
+
};
|
|
1257
|
+
const timeout = setTimeout(handler, duration * 1.5);
|
|
1258
|
+
const cleanupListener = this._preview.addEventListener("transitionend", handler);
|
|
1259
|
+
});
|
|
1260
|
+
});
|
|
1261
|
+
}
|
|
1262
|
+
/** Creates an element that will be shown instead of the current element while dragging. */
|
|
1263
|
+
_createPlaceholderElement() {
|
|
1264
|
+
const placeholderConfig = this._placeholderTemplate;
|
|
1265
|
+
const placeholderTemplate = placeholderConfig ? placeholderConfig.template : null;
|
|
1266
|
+
let placeholder;
|
|
1267
|
+
if (placeholderTemplate) {
|
|
1268
|
+
this._placeholderRef = placeholderConfig.viewContainer.createEmbeddedView(placeholderTemplate, placeholderConfig.context);
|
|
1269
|
+
this._placeholderRef.detectChanges();
|
|
1270
|
+
placeholder = getRootNode(this._placeholderRef, this._document);
|
|
1271
|
+
} else {
|
|
1272
|
+
placeholder = deepCloneNode(this._rootElement);
|
|
1273
|
+
}
|
|
1274
|
+
placeholder.style.pointerEvents = "none";
|
|
1275
|
+
placeholder.classList.add(PLACEHOLDER_CLASS);
|
|
1276
|
+
return placeholder;
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Figures out the coordinates at which an element was picked up.
|
|
1280
|
+
* @param referenceElement Element that initiated the dragging.
|
|
1281
|
+
* @param event Event that initiated the dragging.
|
|
1282
|
+
*/
|
|
1283
|
+
_getPointerPositionInElement(elementRect, referenceElement, event) {
|
|
1284
|
+
const handleElement = referenceElement === this._rootElement ? null : referenceElement;
|
|
1285
|
+
const referenceRect = handleElement ? handleElement.getBoundingClientRect() : elementRect;
|
|
1286
|
+
const point = isTouchEvent(event) ? event.targetTouches[0] : event;
|
|
1287
|
+
const scrollPosition = this._getViewportScrollPosition();
|
|
1288
|
+
const x = point.pageX - referenceRect.left - scrollPosition.left;
|
|
1289
|
+
const y = point.pageY - referenceRect.top - scrollPosition.top;
|
|
1290
|
+
return {
|
|
1291
|
+
x: referenceRect.left - elementRect.left + x,
|
|
1292
|
+
y: referenceRect.top - elementRect.top + y
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
/** Determines the point of the page that was touched by the user. */
|
|
1296
|
+
_getPointerPositionOnPage(event) {
|
|
1297
|
+
const scrollPosition = this._getViewportScrollPosition();
|
|
1298
|
+
const point = isTouchEvent(event) ? (
|
|
1299
|
+
// `touches` will be empty for start/end events so we have to fall back to `changedTouches`.
|
|
1300
|
+
// Also note that on real devices we're guaranteed for either `touches` or `changedTouches`
|
|
1301
|
+
// to have a value, but Firefox in device emulation mode has a bug where both can be empty
|
|
1302
|
+
// for `touchstart` and `touchend` so we fall back to a dummy object in order to avoid
|
|
1303
|
+
// throwing an error. The value returned here will be incorrect, but since this only
|
|
1304
|
+
// breaks inside a developer tool and the value is only used for secondary information,
|
|
1305
|
+
// we can get away with it. See https://bugzilla.mozilla.org/show_bug.cgi?id=1615824.
|
|
1306
|
+
event.touches[0] || event.changedTouches[0] || {
|
|
1307
|
+
pageX: 0,
|
|
1308
|
+
pageY: 0
|
|
1309
|
+
}
|
|
1310
|
+
) : event;
|
|
1311
|
+
const x = point.pageX - scrollPosition.left;
|
|
1312
|
+
const y = point.pageY - scrollPosition.top;
|
|
1313
|
+
if (this._ownerSVGElement) {
|
|
1314
|
+
const svgMatrix = this._ownerSVGElement.getScreenCTM();
|
|
1315
|
+
if (svgMatrix) {
|
|
1316
|
+
const svgPoint = this._ownerSVGElement.createSVGPoint();
|
|
1317
|
+
svgPoint.x = x;
|
|
1318
|
+
svgPoint.y = y;
|
|
1319
|
+
return svgPoint.matrixTransform(svgMatrix.inverse());
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
return {
|
|
1323
|
+
x,
|
|
1324
|
+
y
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
/** Gets the pointer position on the page, accounting for any position constraints. */
|
|
1328
|
+
_getConstrainedPointerPosition(point) {
|
|
1329
|
+
const dropContainerLock = this._dropContainer ? this._dropContainer.lockAxis : null;
|
|
1330
|
+
let {
|
|
1331
|
+
x,
|
|
1332
|
+
y
|
|
1333
|
+
} = this.constrainPosition ? this.constrainPosition(point, this, this._initialDomRect, this._pickupPositionInElement) : point;
|
|
1334
|
+
if (this.lockAxis === "x" || dropContainerLock === "x") {
|
|
1335
|
+
y = this._pickupPositionOnPage.y - (this.constrainPosition ? this._pickupPositionInElement.y : 0);
|
|
1336
|
+
} else if (this.lockAxis === "y" || dropContainerLock === "y") {
|
|
1337
|
+
x = this._pickupPositionOnPage.x - (this.constrainPosition ? this._pickupPositionInElement.x : 0);
|
|
1338
|
+
}
|
|
1339
|
+
if (this._boundaryRect) {
|
|
1340
|
+
const {
|
|
1341
|
+
x: pickupX,
|
|
1342
|
+
y: pickupY
|
|
1343
|
+
} = !this.constrainPosition ? this._pickupPositionInElement : {
|
|
1344
|
+
x: 0,
|
|
1345
|
+
y: 0
|
|
1346
|
+
};
|
|
1347
|
+
const boundaryRect = this._boundaryRect;
|
|
1348
|
+
const {
|
|
1349
|
+
width: previewWidth,
|
|
1350
|
+
height: previewHeight
|
|
1351
|
+
} = this._getPreviewRect();
|
|
1352
|
+
const minY = boundaryRect.top + pickupY;
|
|
1353
|
+
const maxY = boundaryRect.bottom - (previewHeight - pickupY);
|
|
1354
|
+
const minX = boundaryRect.left + pickupX;
|
|
1355
|
+
const maxX = boundaryRect.right - (previewWidth - pickupX);
|
|
1356
|
+
x = clamp$1(x, minX, maxX);
|
|
1357
|
+
y = clamp$1(y, minY, maxY);
|
|
1358
|
+
}
|
|
1359
|
+
return {
|
|
1360
|
+
x,
|
|
1361
|
+
y
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
/** Updates the current drag delta, based on the user's current pointer position on the page. */
|
|
1365
|
+
_updatePointerDirectionDelta(pointerPositionOnPage) {
|
|
1366
|
+
const {
|
|
1367
|
+
x,
|
|
1368
|
+
y
|
|
1369
|
+
} = pointerPositionOnPage;
|
|
1370
|
+
const delta = this._pointerDirectionDelta;
|
|
1371
|
+
const positionSinceLastChange = this._pointerPositionAtLastDirectionChange;
|
|
1372
|
+
const changeX = Math.abs(x - positionSinceLastChange.x);
|
|
1373
|
+
const changeY = Math.abs(y - positionSinceLastChange.y);
|
|
1374
|
+
if (changeX > this._config.pointerDirectionChangeThreshold) {
|
|
1375
|
+
delta.x = x > positionSinceLastChange.x ? 1 : -1;
|
|
1376
|
+
positionSinceLastChange.x = x;
|
|
1377
|
+
}
|
|
1378
|
+
if (changeY > this._config.pointerDirectionChangeThreshold) {
|
|
1379
|
+
delta.y = y > positionSinceLastChange.y ? 1 : -1;
|
|
1380
|
+
positionSinceLastChange.y = y;
|
|
1381
|
+
}
|
|
1382
|
+
return delta;
|
|
1383
|
+
}
|
|
1384
|
+
/** Toggles the native drag interactions, based on how many handles are registered. */
|
|
1385
|
+
_toggleNativeDragInteractions() {
|
|
1386
|
+
if (!this._rootElement || !this._handles) {
|
|
1387
|
+
return;
|
|
1388
|
+
}
|
|
1389
|
+
const shouldEnable = this._handles.length > 0 || !this.isDragging();
|
|
1390
|
+
if (shouldEnable !== this._nativeInteractionsEnabled) {
|
|
1391
|
+
this._nativeInteractionsEnabled = shouldEnable;
|
|
1392
|
+
toggleNativeDragInteractions(this._rootElement, shouldEnable);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
/** Removes the manually-added event listeners from the root element. */
|
|
1396
|
+
_removeRootElementListeners() {
|
|
1397
|
+
this._rootElementCleanups?.forEach((cleanup) => cleanup());
|
|
1398
|
+
this._rootElementCleanups = void 0;
|
|
1399
|
+
}
|
|
1400
|
+
/**
|
|
1401
|
+
* Applies a `transform` to the root element, taking into account any existing transforms on it.
|
|
1402
|
+
* @param x New transform value along the X axis.
|
|
1403
|
+
* @param y New transform value along the Y axis.
|
|
1404
|
+
*/
|
|
1405
|
+
_applyRootElementTransform(x, y) {
|
|
1406
|
+
const scale = 1 / this.scale;
|
|
1407
|
+
const transform = getTransform(x * scale, y * scale);
|
|
1408
|
+
const styles = this._rootElement.style;
|
|
1409
|
+
if (this._initialTransform == null) {
|
|
1410
|
+
this._initialTransform = styles.transform && styles.transform != "none" ? styles.transform : "";
|
|
1411
|
+
}
|
|
1412
|
+
styles.transform = combineTransforms(transform, this._initialTransform);
|
|
1413
|
+
}
|
|
1414
|
+
/**
|
|
1415
|
+
* Applies a `transform` to the preview, taking into account any existing transforms on it.
|
|
1416
|
+
* @param x New transform value along the X axis.
|
|
1417
|
+
* @param y New transform value along the Y axis.
|
|
1418
|
+
*/
|
|
1419
|
+
_applyPreviewTransform(x, y) {
|
|
1420
|
+
const initialTransform = this._previewTemplate?.template ? void 0 : this._initialTransform;
|
|
1421
|
+
const transform = getTransform(x, y);
|
|
1422
|
+
this._preview.setTransform(combineTransforms(transform, initialTransform));
|
|
1423
|
+
}
|
|
1424
|
+
/**
|
|
1425
|
+
* Gets the distance that the user has dragged during the current drag sequence.
|
|
1426
|
+
* @param currentPosition Current position of the user's pointer.
|
|
1427
|
+
*/
|
|
1428
|
+
_getDragDistance(currentPosition) {
|
|
1429
|
+
const pickupPosition = this._pickupPositionOnPage;
|
|
1430
|
+
if (pickupPosition) {
|
|
1431
|
+
return {
|
|
1432
|
+
x: currentPosition.x - pickupPosition.x,
|
|
1433
|
+
y: currentPosition.y - pickupPosition.y
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
return {
|
|
1437
|
+
x: 0,
|
|
1438
|
+
y: 0
|
|
1439
|
+
};
|
|
1440
|
+
}
|
|
1441
|
+
/** Cleans up any cached element dimensions that we don't need after dragging has stopped. */
|
|
1442
|
+
_cleanupCachedDimensions() {
|
|
1443
|
+
this._boundaryRect = this._previewRect = void 0;
|
|
1444
|
+
this._parentPositions.clear();
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* Checks whether the element is still inside its boundary after the viewport has been resized.
|
|
1448
|
+
* If not, the position is adjusted so that the element fits again.
|
|
1449
|
+
*/
|
|
1450
|
+
_containInsideBoundaryOnResize() {
|
|
1451
|
+
let {
|
|
1452
|
+
x,
|
|
1453
|
+
y
|
|
1454
|
+
} = this._passiveTransform;
|
|
1455
|
+
if (x === 0 && y === 0 || this.isDragging() || !this._boundaryElement) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
const elementRect = this._rootElement.getBoundingClientRect();
|
|
1459
|
+
const boundaryRect = this._boundaryElement.getBoundingClientRect();
|
|
1460
|
+
if (boundaryRect.width === 0 && boundaryRect.height === 0 || elementRect.width === 0 && elementRect.height === 0) {
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
const leftOverflow = boundaryRect.left - elementRect.left;
|
|
1464
|
+
const rightOverflow = elementRect.right - boundaryRect.right;
|
|
1465
|
+
const topOverflow = boundaryRect.top - elementRect.top;
|
|
1466
|
+
const bottomOverflow = elementRect.bottom - boundaryRect.bottom;
|
|
1467
|
+
if (boundaryRect.width > elementRect.width) {
|
|
1468
|
+
if (leftOverflow > 0) {
|
|
1469
|
+
x += leftOverflow;
|
|
1470
|
+
}
|
|
1471
|
+
if (rightOverflow > 0) {
|
|
1472
|
+
x -= rightOverflow;
|
|
1473
|
+
}
|
|
1474
|
+
} else {
|
|
1475
|
+
x = 0;
|
|
1476
|
+
}
|
|
1477
|
+
if (boundaryRect.height > elementRect.height) {
|
|
1478
|
+
if (topOverflow > 0) {
|
|
1479
|
+
y += topOverflow;
|
|
1480
|
+
}
|
|
1481
|
+
if (bottomOverflow > 0) {
|
|
1482
|
+
y -= bottomOverflow;
|
|
1483
|
+
}
|
|
1484
|
+
} else {
|
|
1485
|
+
y = 0;
|
|
1486
|
+
}
|
|
1487
|
+
if (x !== this._passiveTransform.x || y !== this._passiveTransform.y) {
|
|
1488
|
+
this.setFreeDragPosition({
|
|
1489
|
+
y,
|
|
1490
|
+
x
|
|
1491
|
+
});
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
/** Gets the drag start delay, based on the event type. */
|
|
1495
|
+
_getDragStartDelay(event) {
|
|
1496
|
+
const value = this.dragStartDelay;
|
|
1497
|
+
if (typeof value === "number") {
|
|
1498
|
+
return value;
|
|
1499
|
+
} else if (isTouchEvent(event)) {
|
|
1500
|
+
return value.touch;
|
|
1501
|
+
}
|
|
1502
|
+
return value ? value.mouse : 0;
|
|
1503
|
+
}
|
|
1504
|
+
/** Updates the internal state of the draggable element when scrolling has occurred. */
|
|
1505
|
+
_updateOnScroll(event) {
|
|
1506
|
+
const scrollDifference = this._parentPositions.handleScroll(event);
|
|
1507
|
+
if (scrollDifference) {
|
|
1508
|
+
const target = _getEventTarget(event);
|
|
1509
|
+
if (this._boundaryRect && target !== this._boundaryElement && target.contains(this._boundaryElement)) {
|
|
1510
|
+
adjustDomRect(this._boundaryRect, scrollDifference.top, scrollDifference.left);
|
|
1511
|
+
}
|
|
1512
|
+
this._pickupPositionOnPage.x += scrollDifference.left;
|
|
1513
|
+
this._pickupPositionOnPage.y += scrollDifference.top;
|
|
1514
|
+
if (!this._dropContainer) {
|
|
1515
|
+
this._activeTransform.x -= scrollDifference.left;
|
|
1516
|
+
this._activeTransform.y -= scrollDifference.top;
|
|
1517
|
+
this._applyRootElementTransform(this._activeTransform.x, this._activeTransform.y);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
/** Gets the scroll position of the viewport. */
|
|
1522
|
+
_getViewportScrollPosition() {
|
|
1523
|
+
return this._parentPositions.positions.get(this._document)?.scrollPosition || this._parentPositions.getViewportScrollPosition();
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* Lazily resolves and returns the shadow root of the element. We do this in a function, rather
|
|
1527
|
+
* than saving it in property directly on init, because we want to resolve it as late as possible
|
|
1528
|
+
* in order to ensure that the element has been moved into the shadow DOM. Doing it inside the
|
|
1529
|
+
* constructor might be too early if the element is inside of something like `ngFor` or `ngIf`.
|
|
1530
|
+
*/
|
|
1531
|
+
_getShadowRoot() {
|
|
1532
|
+
if (this._cachedShadowRoot === void 0) {
|
|
1533
|
+
this._cachedShadowRoot = _getShadowRoot(this._rootElement);
|
|
1534
|
+
}
|
|
1535
|
+
return this._cachedShadowRoot;
|
|
1536
|
+
}
|
|
1537
|
+
/** Gets the element into which the drag preview should be inserted. */
|
|
1538
|
+
_getPreviewInsertionPoint(initialParent, shadowRoot) {
|
|
1539
|
+
const previewContainer = this._previewContainer || "global";
|
|
1540
|
+
if (previewContainer === "parent") {
|
|
1541
|
+
return initialParent;
|
|
1542
|
+
}
|
|
1543
|
+
if (previewContainer === "global") {
|
|
1544
|
+
const documentRef = this._document;
|
|
1545
|
+
return shadowRoot || documentRef.fullscreenElement || documentRef.webkitFullscreenElement || documentRef.mozFullScreenElement || documentRef.msFullscreenElement || documentRef.body;
|
|
1546
|
+
}
|
|
1547
|
+
return coerceElement(previewContainer);
|
|
1548
|
+
}
|
|
1549
|
+
/** Lazily resolves and returns the dimensions of the preview. */
|
|
1550
|
+
_getPreviewRect() {
|
|
1551
|
+
if (!this._previewRect || !this._previewRect.width && !this._previewRect.height) {
|
|
1552
|
+
this._previewRect = this._preview ? this._preview.getBoundingClientRect() : this._initialDomRect;
|
|
1553
|
+
}
|
|
1554
|
+
return this._previewRect;
|
|
1555
|
+
}
|
|
1556
|
+
/** Handles a native `dragstart` event. */
|
|
1557
|
+
_nativeDragStart = (event) => {
|
|
1558
|
+
if (this._handles.length) {
|
|
1559
|
+
const targetHandle = this._getTargetHandle(event);
|
|
1560
|
+
if (targetHandle && !this._disabledHandles.has(targetHandle) && !this.disabled) {
|
|
1561
|
+
event.preventDefault();
|
|
1562
|
+
}
|
|
1563
|
+
} else if (!this.disabled) {
|
|
1564
|
+
event.preventDefault();
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
/** Gets a handle that is the target of an event. */
|
|
1568
|
+
_getTargetHandle(event) {
|
|
1569
|
+
return this._handles.find((handle) => {
|
|
1570
|
+
return event.target && (event.target === handle || handle.contains(event.target));
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
/** Inserts the anchor element, if it's valid. */
|
|
1574
|
+
_conditionallyInsertAnchor(newContainer, exitContainer, nextItemElement) {
|
|
1575
|
+
if (newContainer === this._initialContainer) {
|
|
1576
|
+
this._anchor?.remove();
|
|
1577
|
+
this._anchor = null;
|
|
1578
|
+
} else if (exitContainer === this._initialContainer && exitContainer.hasAnchor) {
|
|
1579
|
+
const anchor = this._anchor ??= deepCloneNode(this._placeholder);
|
|
1580
|
+
anchor.classList.remove(PLACEHOLDER_CLASS);
|
|
1581
|
+
anchor.classList.add("cdk-drag-anchor");
|
|
1582
|
+
anchor.style.transform = "";
|
|
1583
|
+
if (nextItemElement) {
|
|
1584
|
+
nextItemElement.before(anchor);
|
|
1585
|
+
} else {
|
|
1586
|
+
coerceElement(exitContainer.element).appendChild(anchor);
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
function clamp$1(value, min, max) {
|
|
1592
|
+
return Math.max(min, Math.min(max, value));
|
|
1593
|
+
}
|
|
1594
|
+
function isTouchEvent(event) {
|
|
1595
|
+
return event.type[0] === "t";
|
|
1596
|
+
}
|
|
1597
|
+
function shadowDomSelectStart(event) {
|
|
1598
|
+
event.preventDefault();
|
|
1599
|
+
}
|
|
1600
|
+
function moveItemInArray(array, fromIndex, toIndex) {
|
|
1601
|
+
const from = clamp(fromIndex, array.length - 1);
|
|
1602
|
+
const to = clamp(toIndex, array.length - 1);
|
|
1603
|
+
if (from === to) {
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
const target = array[from];
|
|
1607
|
+
const delta = to < from ? -1 : 1;
|
|
1608
|
+
for (let i = from; i !== to; i += delta) {
|
|
1609
|
+
array[i] = array[i + delta];
|
|
1610
|
+
}
|
|
1611
|
+
array[to] = target;
|
|
1612
|
+
}
|
|
1613
|
+
function clamp(value, max) {
|
|
1614
|
+
return Math.max(0, Math.min(max, value));
|
|
1615
|
+
}
|
|
1616
|
+
var SingleAxisSortStrategy = class {
|
|
1617
|
+
_dragDropRegistry;
|
|
1618
|
+
/** Root element container of the drop list. */
|
|
1619
|
+
_element;
|
|
1620
|
+
/** Function used to determine if an item can be sorted into a specific index. */
|
|
1621
|
+
_sortPredicate;
|
|
1622
|
+
/** Cache of the dimensions of all the items inside the container. */
|
|
1623
|
+
_itemPositions = [];
|
|
1624
|
+
/**
|
|
1625
|
+
* Draggable items that are currently active inside the container. Includes the items
|
|
1626
|
+
* that were there at the start of the sequence, as well as any items that have been dragged
|
|
1627
|
+
* in, but haven't been dropped yet.
|
|
1628
|
+
*/
|
|
1629
|
+
_activeDraggables;
|
|
1630
|
+
/** Direction in which the list is oriented. */
|
|
1631
|
+
orientation = "vertical";
|
|
1632
|
+
/** Layout direction of the drop list. */
|
|
1633
|
+
direction;
|
|
1634
|
+
constructor(_dragDropRegistry) {
|
|
1635
|
+
this._dragDropRegistry = _dragDropRegistry;
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* Keeps track of the item that was last swapped with the dragged item, as well as what direction
|
|
1639
|
+
* the pointer was moving in when the swap occurred and whether the user's pointer continued to
|
|
1640
|
+
* overlap with the swapped item after the swapping occurred.
|
|
1641
|
+
*/
|
|
1642
|
+
_previousSwap = {
|
|
1643
|
+
drag: null,
|
|
1644
|
+
delta: 0,
|
|
1645
|
+
overlaps: false
|
|
1646
|
+
};
|
|
1647
|
+
/**
|
|
1648
|
+
* To be called when the drag sequence starts.
|
|
1649
|
+
* @param items Items that are currently in the list.
|
|
1650
|
+
*/
|
|
1651
|
+
start(items) {
|
|
1652
|
+
this.withItems(items);
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* To be called when an item is being sorted.
|
|
1656
|
+
* @param item Item to be sorted.
|
|
1657
|
+
* @param pointerX Position of the item along the X axis.
|
|
1658
|
+
* @param pointerY Position of the item along the Y axis.
|
|
1659
|
+
* @param pointerDelta Direction in which the pointer is moving along each axis.
|
|
1660
|
+
*/
|
|
1661
|
+
sort(item, pointerX, pointerY, pointerDelta) {
|
|
1662
|
+
const siblings = this._itemPositions;
|
|
1663
|
+
const newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY, pointerDelta);
|
|
1664
|
+
if (newIndex === -1 && siblings.length > 0) {
|
|
1665
|
+
return null;
|
|
1666
|
+
}
|
|
1667
|
+
const isHorizontal = this.orientation === "horizontal";
|
|
1668
|
+
const currentIndex = siblings.findIndex((currentItem) => currentItem.drag === item);
|
|
1669
|
+
const siblingAtNewPosition = siblings[newIndex];
|
|
1670
|
+
const currentPosition = siblings[currentIndex].clientRect;
|
|
1671
|
+
const newPosition = siblingAtNewPosition.clientRect;
|
|
1672
|
+
const delta = currentIndex > newIndex ? 1 : -1;
|
|
1673
|
+
const itemOffset = this._getItemOffsetPx(currentPosition, newPosition, delta);
|
|
1674
|
+
const siblingOffset = this._getSiblingOffsetPx(currentIndex, siblings, delta);
|
|
1675
|
+
const oldOrder = siblings.slice();
|
|
1676
|
+
moveItemInArray(siblings, currentIndex, newIndex);
|
|
1677
|
+
siblings.forEach((sibling, index) => {
|
|
1678
|
+
if (oldOrder[index] === sibling) {
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
const isDraggedItem = sibling.drag === item;
|
|
1682
|
+
const offset = isDraggedItem ? itemOffset : siblingOffset;
|
|
1683
|
+
const elementToOffset = isDraggedItem ? item.getPlaceholderElement() : sibling.drag.getRootElement();
|
|
1684
|
+
sibling.offset += offset;
|
|
1685
|
+
const transformAmount = Math.round(sibling.offset * (1 / sibling.drag.scale));
|
|
1686
|
+
if (isHorizontal) {
|
|
1687
|
+
elementToOffset.style.transform = combineTransforms(`translate3d(${transformAmount}px, 0, 0)`, sibling.initialTransform);
|
|
1688
|
+
adjustDomRect(sibling.clientRect, 0, offset);
|
|
1689
|
+
} else {
|
|
1690
|
+
elementToOffset.style.transform = combineTransforms(`translate3d(0, ${transformAmount}px, 0)`, sibling.initialTransform);
|
|
1691
|
+
adjustDomRect(sibling.clientRect, offset, 0);
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
this._previousSwap.overlaps = isInsideClientRect(newPosition, pointerX, pointerY);
|
|
1695
|
+
this._previousSwap.drag = siblingAtNewPosition.drag;
|
|
1696
|
+
this._previousSwap.delta = isHorizontal ? pointerDelta.x : pointerDelta.y;
|
|
1697
|
+
return {
|
|
1698
|
+
previousIndex: currentIndex,
|
|
1699
|
+
currentIndex: newIndex
|
|
1700
|
+
};
|
|
1701
|
+
}
|
|
1702
|
+
/**
|
|
1703
|
+
* Called when an item is being moved into the container.
|
|
1704
|
+
* @param item Item that was moved into the container.
|
|
1705
|
+
* @param pointerX Position of the item along the X axis.
|
|
1706
|
+
* @param pointerY Position of the item along the Y axis.
|
|
1707
|
+
* @param index Index at which the item entered. If omitted, the container will try to figure it
|
|
1708
|
+
* out automatically.
|
|
1709
|
+
*/
|
|
1710
|
+
enter(item, pointerX, pointerY, index) {
|
|
1711
|
+
const newIndex = index == null || index < 0 ? (
|
|
1712
|
+
// We use the coordinates of where the item entered the drop
|
|
1713
|
+
// zone to figure out at which index it should be inserted.
|
|
1714
|
+
this._getItemIndexFromPointerPosition(item, pointerX, pointerY)
|
|
1715
|
+
) : index;
|
|
1716
|
+
const activeDraggables = this._activeDraggables;
|
|
1717
|
+
const currentIndex = activeDraggables.indexOf(item);
|
|
1718
|
+
const placeholder = item.getPlaceholderElement();
|
|
1719
|
+
let newPositionReference = activeDraggables[newIndex];
|
|
1720
|
+
if (newPositionReference === item) {
|
|
1721
|
+
newPositionReference = activeDraggables[newIndex + 1];
|
|
1722
|
+
}
|
|
1723
|
+
if (!newPositionReference && (newIndex == null || newIndex === -1 || newIndex < activeDraggables.length - 1) && this._shouldEnterAsFirstChild(pointerX, pointerY)) {
|
|
1724
|
+
newPositionReference = activeDraggables[0];
|
|
1725
|
+
}
|
|
1726
|
+
if (currentIndex > -1) {
|
|
1727
|
+
activeDraggables.splice(currentIndex, 1);
|
|
1728
|
+
}
|
|
1729
|
+
if (newPositionReference && !this._dragDropRegistry.isDragging(newPositionReference)) {
|
|
1730
|
+
const element = newPositionReference.getRootElement();
|
|
1731
|
+
element.parentElement.insertBefore(placeholder, element);
|
|
1732
|
+
activeDraggables.splice(newIndex, 0, item);
|
|
1733
|
+
} else {
|
|
1734
|
+
this._element.appendChild(placeholder);
|
|
1735
|
+
activeDraggables.push(item);
|
|
1736
|
+
}
|
|
1737
|
+
placeholder.style.transform = "";
|
|
1738
|
+
this._cacheItemPositions();
|
|
1739
|
+
}
|
|
1740
|
+
/** Sets the items that are currently part of the list. */
|
|
1741
|
+
withItems(items) {
|
|
1742
|
+
this._activeDraggables = items.slice();
|
|
1743
|
+
this._cacheItemPositions();
|
|
1744
|
+
}
|
|
1745
|
+
/** Assigns a sort predicate to the strategy. */
|
|
1746
|
+
withSortPredicate(predicate) {
|
|
1747
|
+
this._sortPredicate = predicate;
|
|
1748
|
+
}
|
|
1749
|
+
/** Resets the strategy to its initial state before dragging was started. */
|
|
1750
|
+
reset() {
|
|
1751
|
+
this._activeDraggables?.forEach((item) => {
|
|
1752
|
+
const rootElement = item.getRootElement();
|
|
1753
|
+
if (rootElement) {
|
|
1754
|
+
const initialTransform = this._itemPositions.find((p) => p.drag === item)?.initialTransform;
|
|
1755
|
+
rootElement.style.transform = initialTransform || "";
|
|
1756
|
+
}
|
|
1757
|
+
});
|
|
1758
|
+
this._itemPositions = [];
|
|
1759
|
+
this._activeDraggables = [];
|
|
1760
|
+
this._previousSwap.drag = null;
|
|
1761
|
+
this._previousSwap.delta = 0;
|
|
1762
|
+
this._previousSwap.overlaps = false;
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* Gets a snapshot of items currently in the list.
|
|
1766
|
+
* Can include items that we dragged in from another list.
|
|
1767
|
+
*/
|
|
1768
|
+
getActiveItemsSnapshot() {
|
|
1769
|
+
return this._activeDraggables;
|
|
1770
|
+
}
|
|
1771
|
+
/** Gets the index of a specific item. */
|
|
1772
|
+
getItemIndex(item) {
|
|
1773
|
+
return this._getVisualItemPositions().findIndex((currentItem) => currentItem.drag === item);
|
|
1774
|
+
}
|
|
1775
|
+
/** Gets the item at a specific index. */
|
|
1776
|
+
getItemAtIndex(index) {
|
|
1777
|
+
return this._getVisualItemPositions()[index]?.drag || null;
|
|
1778
|
+
}
|
|
1779
|
+
/** Used to notify the strategy that the scroll position has changed. */
|
|
1780
|
+
updateOnScroll(topDifference, leftDifference) {
|
|
1781
|
+
this._itemPositions.forEach(({
|
|
1782
|
+
clientRect
|
|
1783
|
+
}) => {
|
|
1784
|
+
adjustDomRect(clientRect, topDifference, leftDifference);
|
|
1785
|
+
});
|
|
1786
|
+
this._itemPositions.forEach(({
|
|
1787
|
+
drag
|
|
1788
|
+
}) => {
|
|
1789
|
+
if (this._dragDropRegistry.isDragging(drag)) {
|
|
1790
|
+
drag._sortFromLastPointerPosition();
|
|
1791
|
+
}
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
withElementContainer(container) {
|
|
1795
|
+
this._element = container;
|
|
1796
|
+
}
|
|
1797
|
+
/** Refreshes the position cache of the items and sibling containers. */
|
|
1798
|
+
_cacheItemPositions() {
|
|
1799
|
+
const isHorizontal = this.orientation === "horizontal";
|
|
1800
|
+
this._itemPositions = this._activeDraggables.map((drag) => {
|
|
1801
|
+
const elementToMeasure = drag.getVisibleElement();
|
|
1802
|
+
return {
|
|
1803
|
+
drag,
|
|
1804
|
+
offset: 0,
|
|
1805
|
+
initialTransform: elementToMeasure.style.transform || "",
|
|
1806
|
+
clientRect: getMutableClientRect(elementToMeasure)
|
|
1807
|
+
};
|
|
1808
|
+
}).sort((a, b) => {
|
|
1809
|
+
return isHorizontal ? a.clientRect.left - b.clientRect.left : a.clientRect.top - b.clientRect.top;
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
_getVisualItemPositions() {
|
|
1813
|
+
return this.orientation === "horizontal" && this.direction === "rtl" ? this._itemPositions.slice().reverse() : this._itemPositions;
|
|
1814
|
+
}
|
|
1815
|
+
/**
|
|
1816
|
+
* Gets the offset in pixels by which the item that is being dragged should be moved.
|
|
1817
|
+
* @param currentPosition Current position of the item.
|
|
1818
|
+
* @param newPosition Position of the item where the current item should be moved.
|
|
1819
|
+
* @param delta Direction in which the user is moving.
|
|
1820
|
+
*/
|
|
1821
|
+
_getItemOffsetPx(currentPosition, newPosition, delta) {
|
|
1822
|
+
const isHorizontal = this.orientation === "horizontal";
|
|
1823
|
+
let itemOffset = isHorizontal ? newPosition.left - currentPosition.left : newPosition.top - currentPosition.top;
|
|
1824
|
+
if (delta === -1) {
|
|
1825
|
+
itemOffset += isHorizontal ? newPosition.width - currentPosition.width : newPosition.height - currentPosition.height;
|
|
1826
|
+
}
|
|
1827
|
+
return itemOffset;
|
|
1828
|
+
}
|
|
1829
|
+
/**
|
|
1830
|
+
* Gets the offset in pixels by which the items that aren't being dragged should be moved.
|
|
1831
|
+
* @param currentIndex Index of the item currently being dragged.
|
|
1832
|
+
* @param siblings All of the items in the list.
|
|
1833
|
+
* @param delta Direction in which the user is moving.
|
|
1834
|
+
*/
|
|
1835
|
+
_getSiblingOffsetPx(currentIndex, siblings, delta) {
|
|
1836
|
+
const isHorizontal = this.orientation === "horizontal";
|
|
1837
|
+
const currentPosition = siblings[currentIndex].clientRect;
|
|
1838
|
+
const immediateSibling = siblings[currentIndex + delta * -1];
|
|
1839
|
+
let siblingOffset = currentPosition[isHorizontal ? "width" : "height"] * delta;
|
|
1840
|
+
if (immediateSibling) {
|
|
1841
|
+
const start = isHorizontal ? "left" : "top";
|
|
1842
|
+
const end = isHorizontal ? "right" : "bottom";
|
|
1843
|
+
if (delta === -1) {
|
|
1844
|
+
siblingOffset -= immediateSibling.clientRect[start] - currentPosition[end];
|
|
1845
|
+
} else {
|
|
1846
|
+
siblingOffset += currentPosition[start] - immediateSibling.clientRect[end];
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
return siblingOffset;
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Checks if pointer is entering in the first position
|
|
1853
|
+
* @param pointerX Position of the user's pointer along the X axis.
|
|
1854
|
+
* @param pointerY Position of the user's pointer along the Y axis.
|
|
1855
|
+
*/
|
|
1856
|
+
_shouldEnterAsFirstChild(pointerX, pointerY) {
|
|
1857
|
+
if (!this._activeDraggables.length) {
|
|
1858
|
+
return false;
|
|
1859
|
+
}
|
|
1860
|
+
const itemPositions = this._itemPositions;
|
|
1861
|
+
const isHorizontal = this.orientation === "horizontal";
|
|
1862
|
+
const reversed = itemPositions[0].drag !== this._activeDraggables[0];
|
|
1863
|
+
if (reversed) {
|
|
1864
|
+
const lastItemRect = itemPositions[itemPositions.length - 1].clientRect;
|
|
1865
|
+
return isHorizontal ? pointerX >= lastItemRect.right : pointerY >= lastItemRect.bottom;
|
|
1866
|
+
} else {
|
|
1867
|
+
const firstItemRect = itemPositions[0].clientRect;
|
|
1868
|
+
return isHorizontal ? pointerX <= firstItemRect.left : pointerY <= firstItemRect.top;
|
|
1869
|
+
}
|
|
1870
|
+
}
|
|
1871
|
+
/**
|
|
1872
|
+
* Gets the index of an item in the drop container, based on the position of the user's pointer.
|
|
1873
|
+
* @param item Item that is being sorted.
|
|
1874
|
+
* @param pointerX Position of the user's pointer along the X axis.
|
|
1875
|
+
* @param pointerY Position of the user's pointer along the Y axis.
|
|
1876
|
+
* @param delta Direction in which the user is moving their pointer.
|
|
1877
|
+
*/
|
|
1878
|
+
_getItemIndexFromPointerPosition(item, pointerX, pointerY, delta) {
|
|
1879
|
+
const isHorizontal = this.orientation === "horizontal";
|
|
1880
|
+
const index = this._itemPositions.findIndex(({
|
|
1881
|
+
drag,
|
|
1882
|
+
clientRect
|
|
1883
|
+
}) => {
|
|
1884
|
+
if (drag === item) {
|
|
1885
|
+
return false;
|
|
1886
|
+
}
|
|
1887
|
+
if (delta) {
|
|
1888
|
+
const direction = isHorizontal ? delta.x : delta.y;
|
|
1889
|
+
if (drag === this._previousSwap.drag && this._previousSwap.overlaps && direction === this._previousSwap.delta) {
|
|
1890
|
+
return false;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
return isHorizontal ? (
|
|
1894
|
+
// Round these down since most browsers report client rects with
|
|
1895
|
+
// sub-pixel precision, whereas the pointer coordinates are rounded to pixels.
|
|
1896
|
+
pointerX >= Math.floor(clientRect.left) && pointerX < Math.floor(clientRect.right)
|
|
1897
|
+
) : pointerY >= Math.floor(clientRect.top) && pointerY < Math.floor(clientRect.bottom);
|
|
1898
|
+
});
|
|
1899
|
+
return index === -1 || !this._sortPredicate(index, item) ? -1 : index;
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
var MixedSortStrategy = class {
|
|
1903
|
+
_document;
|
|
1904
|
+
_dragDropRegistry;
|
|
1905
|
+
/** Root element container of the drop list. */
|
|
1906
|
+
_element;
|
|
1907
|
+
/** Function used to determine if an item can be sorted into a specific index. */
|
|
1908
|
+
_sortPredicate;
|
|
1909
|
+
/** Lazily-resolved root node containing the list. Use `_getRootNode` to read this. */
|
|
1910
|
+
_rootNode;
|
|
1911
|
+
/**
|
|
1912
|
+
* Draggable items that are currently active inside the container. Includes the items
|
|
1913
|
+
* that were there at the start of the sequence, as well as any items that have been dragged
|
|
1914
|
+
* in, but haven't been dropped yet.
|
|
1915
|
+
*/
|
|
1916
|
+
_activeItems;
|
|
1917
|
+
/**
|
|
1918
|
+
* Keeps track of the item that was last swapped with the dragged item, as well as what direction
|
|
1919
|
+
* the pointer was moving in when the swap occurred and whether the user's pointer continued to
|
|
1920
|
+
* overlap with the swapped item after the swapping occurred.
|
|
1921
|
+
*/
|
|
1922
|
+
_previousSwap = {
|
|
1923
|
+
drag: null,
|
|
1924
|
+
deltaX: 0,
|
|
1925
|
+
deltaY: 0,
|
|
1926
|
+
overlaps: false
|
|
1927
|
+
};
|
|
1928
|
+
/**
|
|
1929
|
+
* Keeps track of the relationship between a node and its next sibling. This information
|
|
1930
|
+
* is used to restore the DOM to the order it was in before dragging started.
|
|
1931
|
+
*/
|
|
1932
|
+
_relatedNodes = [];
|
|
1933
|
+
constructor(_document, _dragDropRegistry) {
|
|
1934
|
+
this._document = _document;
|
|
1935
|
+
this._dragDropRegistry = _dragDropRegistry;
|
|
1936
|
+
}
|
|
1937
|
+
/**
|
|
1938
|
+
* To be called when the drag sequence starts.
|
|
1939
|
+
* @param items Items that are currently in the list.
|
|
1940
|
+
*/
|
|
1941
|
+
start(items) {
|
|
1942
|
+
const childNodes = this._element.childNodes;
|
|
1943
|
+
this._relatedNodes = [];
|
|
1944
|
+
for (let i = 0; i < childNodes.length; i++) {
|
|
1945
|
+
const node = childNodes[i];
|
|
1946
|
+
this._relatedNodes.push([node, node.nextSibling]);
|
|
1947
|
+
}
|
|
1948
|
+
this.withItems(items);
|
|
1949
|
+
}
|
|
1950
|
+
/**
|
|
1951
|
+
* To be called when an item is being sorted.
|
|
1952
|
+
* @param item Item to be sorted.
|
|
1953
|
+
* @param pointerX Position of the item along the X axis.
|
|
1954
|
+
* @param pointerY Position of the item along the Y axis.
|
|
1955
|
+
* @param pointerDelta Direction in which the pointer is moving along each axis.
|
|
1956
|
+
*/
|
|
1957
|
+
sort(item, pointerX, pointerY, pointerDelta) {
|
|
1958
|
+
const newIndex = this._getItemIndexFromPointerPosition(item, pointerX, pointerY);
|
|
1959
|
+
const previousSwap = this._previousSwap;
|
|
1960
|
+
if (newIndex === -1 || this._activeItems[newIndex] === item) {
|
|
1961
|
+
return null;
|
|
1962
|
+
}
|
|
1963
|
+
const toSwapWith = this._activeItems[newIndex];
|
|
1964
|
+
if (previousSwap.drag === toSwapWith && previousSwap.overlaps && previousSwap.deltaX === pointerDelta.x && previousSwap.deltaY === pointerDelta.y) {
|
|
1965
|
+
return null;
|
|
1966
|
+
}
|
|
1967
|
+
const previousIndex = this.getItemIndex(item);
|
|
1968
|
+
const current = item.getPlaceholderElement();
|
|
1969
|
+
const overlapElement = toSwapWith.getRootElement();
|
|
1970
|
+
if (newIndex > previousIndex) {
|
|
1971
|
+
overlapElement.after(current);
|
|
1972
|
+
} else {
|
|
1973
|
+
overlapElement.before(current);
|
|
1974
|
+
}
|
|
1975
|
+
moveItemInArray(this._activeItems, previousIndex, newIndex);
|
|
1976
|
+
const newOverlapElement = this._getRootNode().elementFromPoint(pointerX, pointerY);
|
|
1977
|
+
previousSwap.deltaX = pointerDelta.x;
|
|
1978
|
+
previousSwap.deltaY = pointerDelta.y;
|
|
1979
|
+
previousSwap.drag = toSwapWith;
|
|
1980
|
+
previousSwap.overlaps = overlapElement === newOverlapElement || overlapElement.contains(newOverlapElement);
|
|
1981
|
+
return {
|
|
1982
|
+
previousIndex,
|
|
1983
|
+
currentIndex: newIndex
|
|
1984
|
+
};
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* Called when an item is being moved into the container.
|
|
1988
|
+
* @param item Item that was moved into the container.
|
|
1989
|
+
* @param pointerX Position of the item along the X axis.
|
|
1990
|
+
* @param pointerY Position of the item along the Y axis.
|
|
1991
|
+
* @param index Index at which the item entered. If omitted, the container will try to figure it
|
|
1992
|
+
* out automatically.
|
|
1993
|
+
*/
|
|
1994
|
+
enter(item, pointerX, pointerY, index) {
|
|
1995
|
+
const currentIndex = this._activeItems.indexOf(item);
|
|
1996
|
+
if (currentIndex > -1) {
|
|
1997
|
+
this._activeItems.splice(currentIndex, 1);
|
|
1998
|
+
}
|
|
1999
|
+
let enterIndex = index == null || index < 0 ? this._getItemIndexFromPointerPosition(item, pointerX, pointerY) : index;
|
|
2000
|
+
if (enterIndex === -1) {
|
|
2001
|
+
enterIndex = this._getClosestItemIndexToPointer(item, pointerX, pointerY);
|
|
2002
|
+
}
|
|
2003
|
+
const targetItem = this._activeItems[enterIndex];
|
|
2004
|
+
if (targetItem && !this._dragDropRegistry.isDragging(targetItem)) {
|
|
2005
|
+
this._activeItems.splice(enterIndex, 0, item);
|
|
2006
|
+
targetItem.getRootElement().before(item.getPlaceholderElement());
|
|
2007
|
+
} else {
|
|
2008
|
+
this._activeItems.push(item);
|
|
2009
|
+
this._element.appendChild(item.getPlaceholderElement());
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
/** Sets the items that are currently part of the list. */
|
|
2013
|
+
withItems(items) {
|
|
2014
|
+
this._activeItems = items.slice();
|
|
2015
|
+
}
|
|
2016
|
+
/** Assigns a sort predicate to the strategy. */
|
|
2017
|
+
withSortPredicate(predicate) {
|
|
2018
|
+
this._sortPredicate = predicate;
|
|
2019
|
+
}
|
|
2020
|
+
/** Resets the strategy to its initial state before dragging was started. */
|
|
2021
|
+
reset() {
|
|
2022
|
+
const root = this._element;
|
|
2023
|
+
const previousSwap = this._previousSwap;
|
|
2024
|
+
for (let i = this._relatedNodes.length - 1; i > -1; i--) {
|
|
2025
|
+
const [node, nextSibling] = this._relatedNodes[i];
|
|
2026
|
+
if (node.parentNode === root && node.nextSibling !== nextSibling) {
|
|
2027
|
+
if (nextSibling === null) {
|
|
2028
|
+
root.appendChild(node);
|
|
2029
|
+
} else if (nextSibling.parentNode === root) {
|
|
2030
|
+
root.insertBefore(node, nextSibling);
|
|
2031
|
+
}
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
this._relatedNodes = [];
|
|
2035
|
+
this._activeItems = [];
|
|
2036
|
+
previousSwap.drag = null;
|
|
2037
|
+
previousSwap.deltaX = previousSwap.deltaY = 0;
|
|
2038
|
+
previousSwap.overlaps = false;
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
2041
|
+
* Gets a snapshot of items currently in the list.
|
|
2042
|
+
* Can include items that we dragged in from another list.
|
|
2043
|
+
*/
|
|
2044
|
+
getActiveItemsSnapshot() {
|
|
2045
|
+
return this._activeItems;
|
|
2046
|
+
}
|
|
2047
|
+
/** Gets the index of a specific item. */
|
|
2048
|
+
getItemIndex(item) {
|
|
2049
|
+
return this._activeItems.indexOf(item);
|
|
2050
|
+
}
|
|
2051
|
+
/** Gets the item at a specific index. */
|
|
2052
|
+
getItemAtIndex(index) {
|
|
2053
|
+
return this._activeItems[index] || null;
|
|
2054
|
+
}
|
|
2055
|
+
/** Used to notify the strategy that the scroll position has changed. */
|
|
2056
|
+
updateOnScroll() {
|
|
2057
|
+
this._activeItems.forEach((item) => {
|
|
2058
|
+
if (this._dragDropRegistry.isDragging(item)) {
|
|
2059
|
+
item._sortFromLastPointerPosition();
|
|
2060
|
+
}
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
2063
|
+
withElementContainer(container) {
|
|
2064
|
+
if (container !== this._element) {
|
|
2065
|
+
this._element = container;
|
|
2066
|
+
this._rootNode = void 0;
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
/**
|
|
2070
|
+
* Gets the index of an item in the drop container, based on the position of the user's pointer.
|
|
2071
|
+
* @param item Item that is being sorted.
|
|
2072
|
+
* @param pointerX Position of the user's pointer along the X axis.
|
|
2073
|
+
* @param pointerY Position of the user's pointer along the Y axis.
|
|
2074
|
+
* @param delta Direction in which the user is moving their pointer.
|
|
2075
|
+
*/
|
|
2076
|
+
_getItemIndexFromPointerPosition(item, pointerX, pointerY) {
|
|
2077
|
+
const elementAtPoint = this._getRootNode().elementFromPoint(Math.floor(pointerX), Math.floor(pointerY));
|
|
2078
|
+
const index = elementAtPoint ? this._activeItems.findIndex((item2) => {
|
|
2079
|
+
const root = item2.getRootElement();
|
|
2080
|
+
return elementAtPoint === root || root.contains(elementAtPoint);
|
|
2081
|
+
}) : -1;
|
|
2082
|
+
return index === -1 || !this._sortPredicate(index, item) ? -1 : index;
|
|
2083
|
+
}
|
|
2084
|
+
/** Lazily resolves the list's root node. */
|
|
2085
|
+
_getRootNode() {
|
|
2086
|
+
if (!this._rootNode) {
|
|
2087
|
+
this._rootNode = _getShadowRoot(this._element) || this._document;
|
|
2088
|
+
}
|
|
2089
|
+
return this._rootNode;
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Finds the index of the item that's closest to the item being dragged.
|
|
2093
|
+
* @param item Item being dragged.
|
|
2094
|
+
* @param pointerX Position of the user's pointer along the X axis.
|
|
2095
|
+
* @param pointerY Position of the user's pointer along the Y axis.
|
|
2096
|
+
*/
|
|
2097
|
+
_getClosestItemIndexToPointer(item, pointerX, pointerY) {
|
|
2098
|
+
if (this._activeItems.length === 0) {
|
|
2099
|
+
return -1;
|
|
2100
|
+
}
|
|
2101
|
+
if (this._activeItems.length === 1) {
|
|
2102
|
+
return 0;
|
|
2103
|
+
}
|
|
2104
|
+
let minDistance = Infinity;
|
|
2105
|
+
let minIndex = -1;
|
|
2106
|
+
for (let i = 0; i < this._activeItems.length; i++) {
|
|
2107
|
+
const current = this._activeItems[i];
|
|
2108
|
+
if (current !== item) {
|
|
2109
|
+
const {
|
|
2110
|
+
x,
|
|
2111
|
+
y
|
|
2112
|
+
} = current.getRootElement().getBoundingClientRect();
|
|
2113
|
+
const distance = Math.hypot(pointerX - x, pointerY - y);
|
|
2114
|
+
if (distance < minDistance) {
|
|
2115
|
+
minDistance = distance;
|
|
2116
|
+
minIndex = i;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
}
|
|
2120
|
+
return minIndex;
|
|
2121
|
+
}
|
|
2122
|
+
};
|
|
2123
|
+
var DROP_PROXIMITY_THRESHOLD = 0.05;
|
|
2124
|
+
var SCROLL_PROXIMITY_THRESHOLD = 0.05;
|
|
2125
|
+
var AutoScrollVerticalDirection;
|
|
2126
|
+
(function(AutoScrollVerticalDirection2) {
|
|
2127
|
+
AutoScrollVerticalDirection2[AutoScrollVerticalDirection2["NONE"] = 0] = "NONE";
|
|
2128
|
+
AutoScrollVerticalDirection2[AutoScrollVerticalDirection2["UP"] = 1] = "UP";
|
|
2129
|
+
AutoScrollVerticalDirection2[AutoScrollVerticalDirection2["DOWN"] = 2] = "DOWN";
|
|
2130
|
+
})(AutoScrollVerticalDirection || (AutoScrollVerticalDirection = {}));
|
|
2131
|
+
var AutoScrollHorizontalDirection;
|
|
2132
|
+
(function(AutoScrollHorizontalDirection2) {
|
|
2133
|
+
AutoScrollHorizontalDirection2[AutoScrollHorizontalDirection2["NONE"] = 0] = "NONE";
|
|
2134
|
+
AutoScrollHorizontalDirection2[AutoScrollHorizontalDirection2["LEFT"] = 1] = "LEFT";
|
|
2135
|
+
AutoScrollHorizontalDirection2[AutoScrollHorizontalDirection2["RIGHT"] = 2] = "RIGHT";
|
|
2136
|
+
})(AutoScrollHorizontalDirection || (AutoScrollHorizontalDirection = {}));
|
|
2137
|
+
var DropListRef = class {
|
|
2138
|
+
_dragDropRegistry;
|
|
2139
|
+
_ngZone;
|
|
2140
|
+
_viewportRuler;
|
|
2141
|
+
/** Element that the drop list is attached to. */
|
|
2142
|
+
element;
|
|
2143
|
+
/** Whether starting a dragging sequence from this container is disabled. */
|
|
2144
|
+
disabled = false;
|
|
2145
|
+
/** Whether sorting items within the list is disabled. */
|
|
2146
|
+
sortingDisabled = false;
|
|
2147
|
+
/** Locks the position of the draggable elements inside the container along the specified axis. */
|
|
2148
|
+
lockAxis;
|
|
2149
|
+
/**
|
|
2150
|
+
* Whether auto-scrolling the view when the user
|
|
2151
|
+
* moves their pointer close to the edges is disabled.
|
|
2152
|
+
*/
|
|
2153
|
+
autoScrollDisabled = false;
|
|
2154
|
+
/** Number of pixels to scroll for each frame when auto-scrolling an element. */
|
|
2155
|
+
autoScrollStep = 2;
|
|
2156
|
+
/**
|
|
2157
|
+
* Whether the items in the list should leave an anchor node when leaving the initial container.
|
|
2158
|
+
*/
|
|
2159
|
+
hasAnchor = false;
|
|
2160
|
+
/**
|
|
2161
|
+
* Function that is used to determine whether an item
|
|
2162
|
+
* is allowed to be moved into a drop container.
|
|
2163
|
+
*/
|
|
2164
|
+
enterPredicate = () => true;
|
|
2165
|
+
/** Function that is used to determine whether an item can be sorted into a particular index. */
|
|
2166
|
+
sortPredicate = () => true;
|
|
2167
|
+
/** Emits right before dragging has started. */
|
|
2168
|
+
beforeStarted = new Subject();
|
|
2169
|
+
/**
|
|
2170
|
+
* Emits when the user has moved a new drag item into this container.
|
|
2171
|
+
*/
|
|
2172
|
+
entered = new Subject();
|
|
2173
|
+
/**
|
|
2174
|
+
* Emits when the user removes an item from the container
|
|
2175
|
+
* by dragging it into another container.
|
|
2176
|
+
*/
|
|
2177
|
+
exited = new Subject();
|
|
2178
|
+
/** Emits when the user drops an item inside the container. */
|
|
2179
|
+
dropped = new Subject();
|
|
2180
|
+
/** Emits as the user is swapping items while actively dragging. */
|
|
2181
|
+
sorted = new Subject();
|
|
2182
|
+
/** Emits when a dragging sequence is started in a list connected to the current one. */
|
|
2183
|
+
receivingStarted = new Subject();
|
|
2184
|
+
/** Emits when a dragging sequence is stopped from a list connected to the current one. */
|
|
2185
|
+
receivingStopped = new Subject();
|
|
2186
|
+
/** Arbitrary data that can be attached to the drop list. */
|
|
2187
|
+
data;
|
|
2188
|
+
/** Element that is the direct parent of the drag items. */
|
|
2189
|
+
_container;
|
|
2190
|
+
/** Whether an item in the list is being dragged. */
|
|
2191
|
+
_isDragging = false;
|
|
2192
|
+
/** Keeps track of the positions of any parent scrollable elements. */
|
|
2193
|
+
_parentPositions;
|
|
2194
|
+
/** Strategy being used to sort items within the list. */
|
|
2195
|
+
_sortStrategy;
|
|
2196
|
+
/** Cached `DOMRect` of the drop list. */
|
|
2197
|
+
_domRect;
|
|
2198
|
+
/** Draggable items in the container. */
|
|
2199
|
+
_draggables = [];
|
|
2200
|
+
/** Drop lists that are connected to the current one. */
|
|
2201
|
+
_siblings = [];
|
|
2202
|
+
/** Connected siblings that currently have a dragged item. */
|
|
2203
|
+
_activeSiblings = /* @__PURE__ */ new Set();
|
|
2204
|
+
/** Subscription to the window being scrolled. */
|
|
2205
|
+
_viewportScrollSubscription = Subscription.EMPTY;
|
|
2206
|
+
/** Vertical direction in which the list is currently scrolling. */
|
|
2207
|
+
_verticalScrollDirection = AutoScrollVerticalDirection.NONE;
|
|
2208
|
+
/** Horizontal direction in which the list is currently scrolling. */
|
|
2209
|
+
_horizontalScrollDirection = AutoScrollHorizontalDirection.NONE;
|
|
2210
|
+
/** Node that is being auto-scrolled. */
|
|
2211
|
+
_scrollNode;
|
|
2212
|
+
/** Used to signal to the current auto-scroll sequence when to stop. */
|
|
2213
|
+
_stopScrollTimers = new Subject();
|
|
2214
|
+
/** Shadow root of the current element. Necessary for `elementFromPoint` to resolve correctly. */
|
|
2215
|
+
_cachedShadowRoot = null;
|
|
2216
|
+
/** Reference to the document. */
|
|
2217
|
+
_document;
|
|
2218
|
+
/** Elements that can be scrolled while the user is dragging. */
|
|
2219
|
+
_scrollableElements = [];
|
|
2220
|
+
/** Initial value for the element's `scroll-snap-type` style. */
|
|
2221
|
+
_initialScrollSnap;
|
|
2222
|
+
/** Direction of the list's layout. */
|
|
2223
|
+
_direction = "ltr";
|
|
2224
|
+
constructor(element, _dragDropRegistry, _document, _ngZone, _viewportRuler) {
|
|
2225
|
+
this._dragDropRegistry = _dragDropRegistry;
|
|
2226
|
+
this._ngZone = _ngZone;
|
|
2227
|
+
this._viewportRuler = _viewportRuler;
|
|
2228
|
+
const coercedElement = this.element = coerceElement(element);
|
|
2229
|
+
this._document = _document;
|
|
2230
|
+
this.withOrientation("vertical").withElementContainer(coercedElement);
|
|
2231
|
+
_dragDropRegistry.registerDropContainer(this);
|
|
2232
|
+
this._parentPositions = new ParentPositionTracker(_document);
|
|
2233
|
+
}
|
|
2234
|
+
/** Removes the drop list functionality from the DOM element. */
|
|
2235
|
+
dispose() {
|
|
2236
|
+
this._stopScrolling();
|
|
2237
|
+
this._stopScrollTimers.complete();
|
|
2238
|
+
this._viewportScrollSubscription.unsubscribe();
|
|
2239
|
+
this.beforeStarted.complete();
|
|
2240
|
+
this.entered.complete();
|
|
2241
|
+
this.exited.complete();
|
|
2242
|
+
this.dropped.complete();
|
|
2243
|
+
this.sorted.complete();
|
|
2244
|
+
this.receivingStarted.complete();
|
|
2245
|
+
this.receivingStopped.complete();
|
|
2246
|
+
this._activeSiblings.clear();
|
|
2247
|
+
this._scrollNode = null;
|
|
2248
|
+
this._parentPositions.clear();
|
|
2249
|
+
this._dragDropRegistry.removeDropContainer(this);
|
|
2250
|
+
}
|
|
2251
|
+
/** Whether an item from this list is currently being dragged. */
|
|
2252
|
+
isDragging() {
|
|
2253
|
+
return this._isDragging;
|
|
2254
|
+
}
|
|
2255
|
+
/** Starts dragging an item. */
|
|
2256
|
+
start() {
|
|
2257
|
+
this._draggingStarted();
|
|
2258
|
+
this._notifyReceivingSiblings();
|
|
2259
|
+
}
|
|
2260
|
+
/**
|
|
2261
|
+
* Attempts to move an item into the container.
|
|
2262
|
+
* @param item Item that was moved into the container.
|
|
2263
|
+
* @param pointerX Position of the item along the X axis.
|
|
2264
|
+
* @param pointerY Position of the item along the Y axis.
|
|
2265
|
+
* @param index Index at which the item entered. If omitted, the container will try to figure it
|
|
2266
|
+
* out automatically.
|
|
2267
|
+
*/
|
|
2268
|
+
enter(item, pointerX, pointerY, index) {
|
|
2269
|
+
this._draggingStarted();
|
|
2270
|
+
if (index == null && this.sortingDisabled) {
|
|
2271
|
+
index = this._draggables.indexOf(item);
|
|
2272
|
+
}
|
|
2273
|
+
this._sortStrategy.enter(item, pointerX, pointerY, index);
|
|
2274
|
+
this._cacheParentPositions();
|
|
2275
|
+
this._notifyReceivingSiblings();
|
|
2276
|
+
this.entered.next({
|
|
2277
|
+
item,
|
|
2278
|
+
container: this,
|
|
2279
|
+
currentIndex: this.getItemIndex(item)
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2282
|
+
/**
|
|
2283
|
+
* Removes an item from the container after it was dragged into another container by the user.
|
|
2284
|
+
* @param item Item that was dragged out.
|
|
2285
|
+
*/
|
|
2286
|
+
exit(item) {
|
|
2287
|
+
this._reset();
|
|
2288
|
+
this.exited.next({
|
|
2289
|
+
item,
|
|
2290
|
+
container: this
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
/**
|
|
2294
|
+
* Drops an item into this container.
|
|
2295
|
+
* @param item Item being dropped into the container.
|
|
2296
|
+
* @param currentIndex Index at which the item should be inserted.
|
|
2297
|
+
* @param previousIndex Index of the item when dragging started.
|
|
2298
|
+
* @param previousContainer Container from which the item got dragged in.
|
|
2299
|
+
* @param isPointerOverContainer Whether the user's pointer was over the
|
|
2300
|
+
* container when the item was dropped.
|
|
2301
|
+
* @param distance Distance the user has dragged since the start of the dragging sequence.
|
|
2302
|
+
* @param event Event that triggered the dropping sequence.
|
|
2303
|
+
*
|
|
2304
|
+
* @breaking-change 15.0.0 `previousIndex` and `event` parameters to become required.
|
|
2305
|
+
*/
|
|
2306
|
+
drop(item, currentIndex, previousIndex, previousContainer, isPointerOverContainer, distance, dropPoint, event = {}) {
|
|
2307
|
+
this._reset();
|
|
2308
|
+
this.dropped.next({
|
|
2309
|
+
item,
|
|
2310
|
+
currentIndex,
|
|
2311
|
+
previousIndex,
|
|
2312
|
+
container: this,
|
|
2313
|
+
previousContainer,
|
|
2314
|
+
isPointerOverContainer,
|
|
2315
|
+
distance,
|
|
2316
|
+
dropPoint,
|
|
2317
|
+
event
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
/**
|
|
2321
|
+
* Sets the draggable items that are a part of this list.
|
|
2322
|
+
* @param items Items that are a part of this list.
|
|
2323
|
+
*/
|
|
2324
|
+
withItems(items) {
|
|
2325
|
+
const previousItems = this._draggables;
|
|
2326
|
+
this._draggables = items;
|
|
2327
|
+
items.forEach((item) => item._withDropContainer(this));
|
|
2328
|
+
if (this.isDragging()) {
|
|
2329
|
+
const draggedItems = previousItems.filter((item) => item.isDragging());
|
|
2330
|
+
if (draggedItems.every((item) => items.indexOf(item) === -1)) {
|
|
2331
|
+
this._reset();
|
|
2332
|
+
} else {
|
|
2333
|
+
this._sortStrategy.withItems(this._draggables);
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
return this;
|
|
2337
|
+
}
|
|
2338
|
+
/** Sets the layout direction of the drop list. */
|
|
2339
|
+
withDirection(direction) {
|
|
2340
|
+
this._direction = direction;
|
|
2341
|
+
if (this._sortStrategy instanceof SingleAxisSortStrategy) {
|
|
2342
|
+
this._sortStrategy.direction = direction;
|
|
2343
|
+
}
|
|
2344
|
+
return this;
|
|
2345
|
+
}
|
|
2346
|
+
/**
|
|
2347
|
+
* Sets the containers that are connected to this one. When two or more containers are
|
|
2348
|
+
* connected, the user will be allowed to transfer items between them.
|
|
2349
|
+
* @param connectedTo Other containers that the current containers should be connected to.
|
|
2350
|
+
*/
|
|
2351
|
+
connectedTo(connectedTo) {
|
|
2352
|
+
this._siblings = connectedTo.slice();
|
|
2353
|
+
return this;
|
|
2354
|
+
}
|
|
2355
|
+
/**
|
|
2356
|
+
* Sets the orientation of the container.
|
|
2357
|
+
* @param orientation New orientation for the container.
|
|
2358
|
+
*/
|
|
2359
|
+
withOrientation(orientation) {
|
|
2360
|
+
if (orientation === "mixed") {
|
|
2361
|
+
this._sortStrategy = new MixedSortStrategy(this._document, this._dragDropRegistry);
|
|
2362
|
+
} else {
|
|
2363
|
+
const strategy = new SingleAxisSortStrategy(this._dragDropRegistry);
|
|
2364
|
+
strategy.direction = this._direction;
|
|
2365
|
+
strategy.orientation = orientation;
|
|
2366
|
+
this._sortStrategy = strategy;
|
|
2367
|
+
}
|
|
2368
|
+
this._sortStrategy.withElementContainer(this._container);
|
|
2369
|
+
this._sortStrategy.withSortPredicate((index, item) => this.sortPredicate(index, item, this));
|
|
2370
|
+
return this;
|
|
2371
|
+
}
|
|
2372
|
+
/**
|
|
2373
|
+
* Sets which parent elements are can be scrolled while the user is dragging.
|
|
2374
|
+
* @param elements Elements that can be scrolled.
|
|
2375
|
+
*/
|
|
2376
|
+
withScrollableParents(elements) {
|
|
2377
|
+
const element = this._container;
|
|
2378
|
+
this._scrollableElements = elements.indexOf(element) === -1 ? [element, ...elements] : elements.slice();
|
|
2379
|
+
return this;
|
|
2380
|
+
}
|
|
2381
|
+
/**
|
|
2382
|
+
* Configures the drop list so that a different element is used as the container for the
|
|
2383
|
+
* dragged items. This is useful for the cases when one might not have control over the
|
|
2384
|
+
* full DOM that sets up the dragging.
|
|
2385
|
+
* Note that the alternate container needs to be a descendant of the drop list.
|
|
2386
|
+
* @param container New element container to be assigned.
|
|
2387
|
+
*/
|
|
2388
|
+
withElementContainer(container) {
|
|
2389
|
+
if (container === this._container) {
|
|
2390
|
+
return this;
|
|
2391
|
+
}
|
|
2392
|
+
const element = coerceElement(this.element);
|
|
2393
|
+
if ((typeof ngDevMode === "undefined" || ngDevMode) && container !== element && !element.contains(container)) {
|
|
2394
|
+
throw new Error("Invalid DOM structure for drop list. Alternate container element must be a descendant of the drop list.");
|
|
2395
|
+
}
|
|
2396
|
+
const oldContainerIndex = this._scrollableElements.indexOf(this._container);
|
|
2397
|
+
const newContainerIndex = this._scrollableElements.indexOf(container);
|
|
2398
|
+
if (oldContainerIndex > -1) {
|
|
2399
|
+
this._scrollableElements.splice(oldContainerIndex, 1);
|
|
2400
|
+
}
|
|
2401
|
+
if (newContainerIndex > -1) {
|
|
2402
|
+
this._scrollableElements.splice(newContainerIndex, 1);
|
|
2403
|
+
}
|
|
2404
|
+
if (this._sortStrategy) {
|
|
2405
|
+
this._sortStrategy.withElementContainer(container);
|
|
2406
|
+
}
|
|
2407
|
+
this._cachedShadowRoot = null;
|
|
2408
|
+
this._scrollableElements.unshift(container);
|
|
2409
|
+
this._container = container;
|
|
2410
|
+
return this;
|
|
2411
|
+
}
|
|
2412
|
+
/** Gets the scrollable parents that are registered with this drop container. */
|
|
2413
|
+
getScrollableParents() {
|
|
2414
|
+
return this._scrollableElements;
|
|
2415
|
+
}
|
|
2416
|
+
/**
|
|
2417
|
+
* Figures out the index of an item in the container.
|
|
2418
|
+
* @param item Item whose index should be determined.
|
|
2419
|
+
*/
|
|
2420
|
+
getItemIndex(item) {
|
|
2421
|
+
return this._isDragging ? this._sortStrategy.getItemIndex(item) : this._draggables.indexOf(item);
|
|
2422
|
+
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Gets the item at a specific index.
|
|
2425
|
+
* @param index Index at which to retrieve the item.
|
|
2426
|
+
*/
|
|
2427
|
+
getItemAtIndex(index) {
|
|
2428
|
+
return this._isDragging ? this._sortStrategy.getItemAtIndex(index) : this._draggables[index] || null;
|
|
2429
|
+
}
|
|
2430
|
+
/**
|
|
2431
|
+
* Whether the list is able to receive the item that
|
|
2432
|
+
* is currently being dragged inside a connected drop list.
|
|
2433
|
+
*/
|
|
2434
|
+
isReceiving() {
|
|
2435
|
+
return this._activeSiblings.size > 0;
|
|
2436
|
+
}
|
|
2437
|
+
/**
|
|
2438
|
+
* Sorts an item inside the container based on its position.
|
|
2439
|
+
* @param item Item to be sorted.
|
|
2440
|
+
* @param pointerX Position of the item along the X axis.
|
|
2441
|
+
* @param pointerY Position of the item along the Y axis.
|
|
2442
|
+
* @param pointerDelta Direction in which the pointer is moving along each axis.
|
|
2443
|
+
*/
|
|
2444
|
+
_sortItem(item, pointerX, pointerY, pointerDelta) {
|
|
2445
|
+
if (this.sortingDisabled || !this._domRect || !isPointerNearDomRect(this._domRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
|
|
2446
|
+
return;
|
|
2447
|
+
}
|
|
2448
|
+
const result = this._sortStrategy.sort(item, pointerX, pointerY, pointerDelta);
|
|
2449
|
+
if (result) {
|
|
2450
|
+
this.sorted.next({
|
|
2451
|
+
previousIndex: result.previousIndex,
|
|
2452
|
+
currentIndex: result.currentIndex,
|
|
2453
|
+
container: this,
|
|
2454
|
+
item
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
/**
|
|
2459
|
+
* Checks whether the user's pointer is close to the edges of either the
|
|
2460
|
+
* viewport or the drop list and starts the auto-scroll sequence.
|
|
2461
|
+
* @param pointerX User's pointer position along the x axis.
|
|
2462
|
+
* @param pointerY User's pointer position along the y axis.
|
|
2463
|
+
*/
|
|
2464
|
+
_startScrollingIfNecessary(pointerX, pointerY) {
|
|
2465
|
+
if (this.autoScrollDisabled) {
|
|
2466
|
+
return;
|
|
2467
|
+
}
|
|
2468
|
+
let scrollNode;
|
|
2469
|
+
let verticalScrollDirection = AutoScrollVerticalDirection.NONE;
|
|
2470
|
+
let horizontalScrollDirection = AutoScrollHorizontalDirection.NONE;
|
|
2471
|
+
this._parentPositions.positions.forEach((position, element) => {
|
|
2472
|
+
if (element === this._document || !position.clientRect || scrollNode) {
|
|
2473
|
+
return;
|
|
2474
|
+
}
|
|
2475
|
+
if (isPointerNearDomRect(position.clientRect, DROP_PROXIMITY_THRESHOLD, pointerX, pointerY)) {
|
|
2476
|
+
[verticalScrollDirection, horizontalScrollDirection] = getElementScrollDirections(element, position.clientRect, this._direction, pointerX, pointerY);
|
|
2477
|
+
if (verticalScrollDirection || horizontalScrollDirection) {
|
|
2478
|
+
scrollNode = element;
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
});
|
|
2482
|
+
if (!verticalScrollDirection && !horizontalScrollDirection) {
|
|
2483
|
+
const {
|
|
2484
|
+
width,
|
|
2485
|
+
height
|
|
2486
|
+
} = this._viewportRuler.getViewportSize();
|
|
2487
|
+
const domRect = {
|
|
2488
|
+
width,
|
|
2489
|
+
height,
|
|
2490
|
+
top: 0,
|
|
2491
|
+
right: width,
|
|
2492
|
+
bottom: height,
|
|
2493
|
+
left: 0
|
|
2494
|
+
};
|
|
2495
|
+
verticalScrollDirection = getVerticalScrollDirection(domRect, pointerY);
|
|
2496
|
+
horizontalScrollDirection = getHorizontalScrollDirection(domRect, pointerX);
|
|
2497
|
+
scrollNode = window;
|
|
2498
|
+
}
|
|
2499
|
+
if (scrollNode && (verticalScrollDirection !== this._verticalScrollDirection || horizontalScrollDirection !== this._horizontalScrollDirection || scrollNode !== this._scrollNode)) {
|
|
2500
|
+
this._verticalScrollDirection = verticalScrollDirection;
|
|
2501
|
+
this._horizontalScrollDirection = horizontalScrollDirection;
|
|
2502
|
+
this._scrollNode = scrollNode;
|
|
2503
|
+
if ((verticalScrollDirection || horizontalScrollDirection) && scrollNode) {
|
|
2504
|
+
this._ngZone.runOutsideAngular(this._startScrollInterval);
|
|
2505
|
+
} else {
|
|
2506
|
+
this._stopScrolling();
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2509
|
+
}
|
|
2510
|
+
/** Stops any currently-running auto-scroll sequences. */
|
|
2511
|
+
_stopScrolling() {
|
|
2512
|
+
this._stopScrollTimers.next();
|
|
2513
|
+
}
|
|
2514
|
+
/** Starts the dragging sequence within the list. */
|
|
2515
|
+
_draggingStarted() {
|
|
2516
|
+
const styles = this._container.style;
|
|
2517
|
+
this.beforeStarted.next();
|
|
2518
|
+
this._isDragging = true;
|
|
2519
|
+
if ((typeof ngDevMode === "undefined" || ngDevMode) && // Prevent the check from running on apps not using an alternate container. Ideally we
|
|
2520
|
+
// would always run it, but introducing it at this stage would be a breaking change.
|
|
2521
|
+
this._container !== coerceElement(this.element)) {
|
|
2522
|
+
for (const drag of this._draggables) {
|
|
2523
|
+
if (!drag.isDragging() && drag.getVisibleElement().parentNode !== this._container) {
|
|
2524
|
+
throw new Error("Invalid DOM structure for drop list. All items must be placed directly inside of the element container.");
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
this._initialScrollSnap = styles.msScrollSnapType || styles.scrollSnapType || "";
|
|
2529
|
+
styles.scrollSnapType = styles.msScrollSnapType = "none";
|
|
2530
|
+
this._sortStrategy.start(this._draggables);
|
|
2531
|
+
this._cacheParentPositions();
|
|
2532
|
+
this._viewportScrollSubscription.unsubscribe();
|
|
2533
|
+
this._listenToScrollEvents();
|
|
2534
|
+
}
|
|
2535
|
+
/** Caches the positions of the configured scrollable parents. */
|
|
2536
|
+
_cacheParentPositions() {
|
|
2537
|
+
this._parentPositions.cache(this._scrollableElements);
|
|
2538
|
+
this._domRect = this._parentPositions.positions.get(this._container).clientRect;
|
|
2539
|
+
}
|
|
2540
|
+
/** Resets the container to its initial state. */
|
|
2541
|
+
_reset() {
|
|
2542
|
+
this._isDragging = false;
|
|
2543
|
+
const styles = this._container.style;
|
|
2544
|
+
styles.scrollSnapType = styles.msScrollSnapType = this._initialScrollSnap;
|
|
2545
|
+
this._siblings.forEach((sibling) => sibling._stopReceiving(this));
|
|
2546
|
+
this._sortStrategy.reset();
|
|
2547
|
+
this._stopScrolling();
|
|
2548
|
+
this._viewportScrollSubscription.unsubscribe();
|
|
2549
|
+
this._parentPositions.clear();
|
|
2550
|
+
}
|
|
2551
|
+
/** Starts the interval that'll auto-scroll the element. */
|
|
2552
|
+
_startScrollInterval = () => {
|
|
2553
|
+
this._stopScrolling();
|
|
2554
|
+
interval(0, animationFrameScheduler).pipe(takeUntil(this._stopScrollTimers)).subscribe(() => {
|
|
2555
|
+
const node = this._scrollNode;
|
|
2556
|
+
const scrollStep = this.autoScrollStep;
|
|
2557
|
+
if (this._verticalScrollDirection === AutoScrollVerticalDirection.UP) {
|
|
2558
|
+
node.scrollBy(0, -scrollStep);
|
|
2559
|
+
} else if (this._verticalScrollDirection === AutoScrollVerticalDirection.DOWN) {
|
|
2560
|
+
node.scrollBy(0, scrollStep);
|
|
2561
|
+
}
|
|
2562
|
+
if (this._horizontalScrollDirection === AutoScrollHorizontalDirection.LEFT) {
|
|
2563
|
+
node.scrollBy(-scrollStep, 0);
|
|
2564
|
+
} else if (this._horizontalScrollDirection === AutoScrollHorizontalDirection.RIGHT) {
|
|
2565
|
+
node.scrollBy(scrollStep, 0);
|
|
2566
|
+
}
|
|
2567
|
+
});
|
|
2568
|
+
};
|
|
2569
|
+
/**
|
|
2570
|
+
* Checks whether the user's pointer is positioned over the container.
|
|
2571
|
+
* @param x Pointer position along the X axis.
|
|
2572
|
+
* @param y Pointer position along the Y axis.
|
|
2573
|
+
*/
|
|
2574
|
+
_isOverContainer(x, y) {
|
|
2575
|
+
return this._domRect != null && isInsideClientRect(this._domRect, x, y);
|
|
2576
|
+
}
|
|
2577
|
+
/**
|
|
2578
|
+
* Figures out whether an item should be moved into a sibling
|
|
2579
|
+
* drop container, based on its current position.
|
|
2580
|
+
* @param item Drag item that is being moved.
|
|
2581
|
+
* @param x Position of the item along the X axis.
|
|
2582
|
+
* @param y Position of the item along the Y axis.
|
|
2583
|
+
*/
|
|
2584
|
+
_getSiblingContainerFromPosition(item, x, y) {
|
|
2585
|
+
return this._siblings.find((sibling) => sibling._canReceive(item, x, y));
|
|
2586
|
+
}
|
|
2587
|
+
/**
|
|
2588
|
+
* Checks whether the drop list can receive the passed-in item.
|
|
2589
|
+
* @param item Item that is being dragged into the list.
|
|
2590
|
+
* @param x Position of the item along the X axis.
|
|
2591
|
+
* @param y Position of the item along the Y axis.
|
|
2592
|
+
*/
|
|
2593
|
+
_canReceive(item, x, y) {
|
|
2594
|
+
if (!this._domRect || !isInsideClientRect(this._domRect, x, y) || !this.enterPredicate(item, this)) {
|
|
2595
|
+
return false;
|
|
2596
|
+
}
|
|
2597
|
+
const elementFromPoint = this._getShadowRoot().elementFromPoint(x, y);
|
|
2598
|
+
if (!elementFromPoint) {
|
|
2599
|
+
return false;
|
|
2600
|
+
}
|
|
2601
|
+
return elementFromPoint === this._container || this._container.contains(elementFromPoint);
|
|
2602
|
+
}
|
|
2603
|
+
/**
|
|
2604
|
+
* Called by one of the connected drop lists when a dragging sequence has started.
|
|
2605
|
+
* @param sibling Sibling in which dragging has started.
|
|
2606
|
+
*/
|
|
2607
|
+
_startReceiving(sibling, items) {
|
|
2608
|
+
const activeSiblings = this._activeSiblings;
|
|
2609
|
+
if (!activeSiblings.has(sibling) && items.every((item) => {
|
|
2610
|
+
return this.enterPredicate(item, this) || this._draggables.indexOf(item) > -1;
|
|
2611
|
+
})) {
|
|
2612
|
+
activeSiblings.add(sibling);
|
|
2613
|
+
this._cacheParentPositions();
|
|
2614
|
+
this._listenToScrollEvents();
|
|
2615
|
+
this.receivingStarted.next({
|
|
2616
|
+
initiator: sibling,
|
|
2617
|
+
receiver: this,
|
|
2618
|
+
items
|
|
2619
|
+
});
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
/**
|
|
2623
|
+
* Called by a connected drop list when dragging has stopped.
|
|
2624
|
+
* @param sibling Sibling whose dragging has stopped.
|
|
2625
|
+
*/
|
|
2626
|
+
_stopReceiving(sibling) {
|
|
2627
|
+
this._activeSiblings.delete(sibling);
|
|
2628
|
+
this._viewportScrollSubscription.unsubscribe();
|
|
2629
|
+
this.receivingStopped.next({
|
|
2630
|
+
initiator: sibling,
|
|
2631
|
+
receiver: this
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
/**
|
|
2635
|
+
* Starts listening to scroll events on the viewport.
|
|
2636
|
+
* Used for updating the internal state of the list.
|
|
2637
|
+
*/
|
|
2638
|
+
_listenToScrollEvents() {
|
|
2639
|
+
this._viewportScrollSubscription = this._dragDropRegistry.scrolled(this._getShadowRoot()).subscribe((event) => {
|
|
2640
|
+
if (this.isDragging()) {
|
|
2641
|
+
const scrollDifference = this._parentPositions.handleScroll(event);
|
|
2642
|
+
if (scrollDifference) {
|
|
2643
|
+
this._sortStrategy.updateOnScroll(scrollDifference.top, scrollDifference.left);
|
|
2644
|
+
}
|
|
2645
|
+
} else if (this.isReceiving()) {
|
|
2646
|
+
this._cacheParentPositions();
|
|
2647
|
+
}
|
|
2648
|
+
});
|
|
2649
|
+
}
|
|
2650
|
+
/**
|
|
2651
|
+
* Lazily resolves and returns the shadow root of the element. We do this in a function, rather
|
|
2652
|
+
* than saving it in property directly on init, because we want to resolve it as late as possible
|
|
2653
|
+
* in order to ensure that the element has been moved into the shadow DOM. Doing it inside the
|
|
2654
|
+
* constructor might be too early if the element is inside of something like `ngFor` or `ngIf`.
|
|
2655
|
+
*/
|
|
2656
|
+
_getShadowRoot() {
|
|
2657
|
+
if (!this._cachedShadowRoot) {
|
|
2658
|
+
const shadowRoot = _getShadowRoot(this._container);
|
|
2659
|
+
this._cachedShadowRoot = shadowRoot || this._document;
|
|
2660
|
+
}
|
|
2661
|
+
return this._cachedShadowRoot;
|
|
2662
|
+
}
|
|
2663
|
+
/** Notifies any siblings that may potentially receive the item. */
|
|
2664
|
+
_notifyReceivingSiblings() {
|
|
2665
|
+
const draggedItems = this._sortStrategy.getActiveItemsSnapshot().filter((item) => item.isDragging());
|
|
2666
|
+
this._siblings.forEach((sibling) => sibling._startReceiving(this, draggedItems));
|
|
2667
|
+
}
|
|
2668
|
+
};
|
|
2669
|
+
function getVerticalScrollDirection(clientRect, pointerY) {
|
|
2670
|
+
const {
|
|
2671
|
+
top,
|
|
2672
|
+
bottom,
|
|
2673
|
+
height
|
|
2674
|
+
} = clientRect;
|
|
2675
|
+
const yThreshold = height * SCROLL_PROXIMITY_THRESHOLD;
|
|
2676
|
+
if (pointerY >= top - yThreshold && pointerY <= top + yThreshold) {
|
|
2677
|
+
return AutoScrollVerticalDirection.UP;
|
|
2678
|
+
} else if (pointerY >= bottom - yThreshold && pointerY <= bottom + yThreshold) {
|
|
2679
|
+
return AutoScrollVerticalDirection.DOWN;
|
|
2680
|
+
}
|
|
2681
|
+
return AutoScrollVerticalDirection.NONE;
|
|
2682
|
+
}
|
|
2683
|
+
function getHorizontalScrollDirection(clientRect, pointerX) {
|
|
2684
|
+
const {
|
|
2685
|
+
left,
|
|
2686
|
+
right,
|
|
2687
|
+
width
|
|
2688
|
+
} = clientRect;
|
|
2689
|
+
const xThreshold = width * SCROLL_PROXIMITY_THRESHOLD;
|
|
2690
|
+
if (pointerX >= left - xThreshold && pointerX <= left + xThreshold) {
|
|
2691
|
+
return AutoScrollHorizontalDirection.LEFT;
|
|
2692
|
+
} else if (pointerX >= right - xThreshold && pointerX <= right + xThreshold) {
|
|
2693
|
+
return AutoScrollHorizontalDirection.RIGHT;
|
|
2694
|
+
}
|
|
2695
|
+
return AutoScrollHorizontalDirection.NONE;
|
|
2696
|
+
}
|
|
2697
|
+
function getElementScrollDirections(element, clientRect, direction, pointerX, pointerY) {
|
|
2698
|
+
const computedVertical = getVerticalScrollDirection(clientRect, pointerY);
|
|
2699
|
+
const computedHorizontal = getHorizontalScrollDirection(clientRect, pointerX);
|
|
2700
|
+
let verticalScrollDirection = AutoScrollVerticalDirection.NONE;
|
|
2701
|
+
let horizontalScrollDirection = AutoScrollHorizontalDirection.NONE;
|
|
2702
|
+
if (computedVertical) {
|
|
2703
|
+
const scrollTop = element.scrollTop;
|
|
2704
|
+
if (computedVertical === AutoScrollVerticalDirection.UP) {
|
|
2705
|
+
if (scrollTop > 0) {
|
|
2706
|
+
verticalScrollDirection = AutoScrollVerticalDirection.UP;
|
|
2707
|
+
}
|
|
2708
|
+
} else if (element.scrollHeight - scrollTop > element.clientHeight) {
|
|
2709
|
+
verticalScrollDirection = AutoScrollVerticalDirection.DOWN;
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
if (computedHorizontal) {
|
|
2713
|
+
const scrollLeft = element.scrollLeft;
|
|
2714
|
+
if (direction === "rtl") {
|
|
2715
|
+
if (computedHorizontal === AutoScrollHorizontalDirection.RIGHT) {
|
|
2716
|
+
if (scrollLeft < 0) {
|
|
2717
|
+
horizontalScrollDirection = AutoScrollHorizontalDirection.RIGHT;
|
|
2718
|
+
}
|
|
2719
|
+
} else if (element.scrollWidth + scrollLeft > element.clientWidth) {
|
|
2720
|
+
horizontalScrollDirection = AutoScrollHorizontalDirection.LEFT;
|
|
2721
|
+
}
|
|
2722
|
+
} else {
|
|
2723
|
+
if (computedHorizontal === AutoScrollHorizontalDirection.LEFT) {
|
|
2724
|
+
if (scrollLeft > 0) {
|
|
2725
|
+
horizontalScrollDirection = AutoScrollHorizontalDirection.LEFT;
|
|
2726
|
+
}
|
|
2727
|
+
} else if (element.scrollWidth - scrollLeft > element.clientWidth) {
|
|
2728
|
+
horizontalScrollDirection = AutoScrollHorizontalDirection.RIGHT;
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2732
|
+
return [verticalScrollDirection, horizontalScrollDirection];
|
|
2733
|
+
}
|
|
2734
|
+
var capturingEventOptions = {
|
|
2735
|
+
capture: true
|
|
2736
|
+
};
|
|
2737
|
+
var activeCapturingEventOptions = {
|
|
2738
|
+
passive: false,
|
|
2739
|
+
capture: true
|
|
2740
|
+
};
|
|
2741
|
+
var _ResetsLoader = class __ResetsLoader {
|
|
2742
|
+
static \u0275fac = function _ResetsLoader_Factory(__ngFactoryType__) {
|
|
2743
|
+
return new (__ngFactoryType__ || __ResetsLoader)();
|
|
2744
|
+
};
|
|
2745
|
+
static \u0275cmp = /* @__PURE__ */ \u0275\u0275defineComponent({
|
|
2746
|
+
type: __ResetsLoader,
|
|
2747
|
+
selectors: [["ng-component"]],
|
|
2748
|
+
hostAttrs: ["cdk-drag-resets-container", ""],
|
|
2749
|
+
decls: 0,
|
|
2750
|
+
vars: 0,
|
|
2751
|
+
template: function _ResetsLoader_Template(rf, ctx) {
|
|
2752
|
+
},
|
|
2753
|
+
styles: ["@layer cdk-resets{.cdk-drag-preview{background:none;border:none;padding:0;color:inherit;inset:auto}}.cdk-drag-placeholder *,.cdk-drag-preview *{pointer-events:none !important}\n"],
|
|
2754
|
+
encapsulation: 2,
|
|
2755
|
+
changeDetection: 0
|
|
2756
|
+
});
|
|
2757
|
+
};
|
|
2758
|
+
(() => {
|
|
2759
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(_ResetsLoader, [{
|
|
2760
|
+
type: Component,
|
|
2761
|
+
args: [{
|
|
2762
|
+
encapsulation: ViewEncapsulation.None,
|
|
2763
|
+
template: "",
|
|
2764
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
2765
|
+
host: {
|
|
2766
|
+
"cdk-drag-resets-container": ""
|
|
2767
|
+
},
|
|
2768
|
+
styles: ["@layer cdk-resets{.cdk-drag-preview{background:none;border:none;padding:0;color:inherit;inset:auto}}.cdk-drag-placeholder *,.cdk-drag-preview *{pointer-events:none !important}\n"]
|
|
2769
|
+
}]
|
|
2770
|
+
}], null, null);
|
|
2771
|
+
})();
|
|
2772
|
+
var DragDropRegistry = class _DragDropRegistry {
|
|
2773
|
+
_ngZone = inject(NgZone);
|
|
2774
|
+
_document = inject(DOCUMENT);
|
|
2775
|
+
_styleLoader = inject(_CdkPrivateStyleLoader);
|
|
2776
|
+
_renderer = inject(RendererFactory2).createRenderer(null, null);
|
|
2777
|
+
_cleanupDocumentTouchmove;
|
|
2778
|
+
_scroll = new Subject();
|
|
2779
|
+
/** Registered drop container instances. */
|
|
2780
|
+
_dropInstances = /* @__PURE__ */ new Set();
|
|
2781
|
+
/** Registered drag item instances. */
|
|
2782
|
+
_dragInstances = /* @__PURE__ */ new Set();
|
|
2783
|
+
/** Drag item instances that are currently being dragged. */
|
|
2784
|
+
_activeDragInstances = signal([]);
|
|
2785
|
+
/** Keeps track of the event listeners that we've bound to the `document`. */
|
|
2786
|
+
_globalListeners;
|
|
2787
|
+
/**
|
|
2788
|
+
* Predicate function to check if an item is being dragged. Moved out into a property,
|
|
2789
|
+
* because it'll be called a lot and we don't want to create a new function every time.
|
|
2790
|
+
*/
|
|
2791
|
+
_draggingPredicate = (item) => item.isDragging();
|
|
2792
|
+
/**
|
|
2793
|
+
* Map tracking DOM nodes and their corresponding drag directives. Note that this is different
|
|
2794
|
+
* from looking through the `_dragInstances` and getting their root node, because the root node
|
|
2795
|
+
* isn't necessarily the node that the directive is set on.
|
|
2796
|
+
*/
|
|
2797
|
+
_domNodesToDirectives = null;
|
|
2798
|
+
/**
|
|
2799
|
+
* Emits the `touchmove` or `mousemove` events that are dispatched
|
|
2800
|
+
* while the user is dragging a drag item instance.
|
|
2801
|
+
*/
|
|
2802
|
+
pointerMove = new Subject();
|
|
2803
|
+
/**
|
|
2804
|
+
* Emits the `touchend` or `mouseup` events that are dispatched
|
|
2805
|
+
* while the user is dragging a drag item instance.
|
|
2806
|
+
*/
|
|
2807
|
+
pointerUp = new Subject();
|
|
2808
|
+
constructor() {
|
|
2809
|
+
}
|
|
2810
|
+
/** Adds a drop container to the registry. */
|
|
2811
|
+
registerDropContainer(drop) {
|
|
2812
|
+
if (!this._dropInstances.has(drop)) {
|
|
2813
|
+
this._dropInstances.add(drop);
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
/** Adds a drag item instance to the registry. */
|
|
2817
|
+
registerDragItem(drag) {
|
|
2818
|
+
this._dragInstances.add(drag);
|
|
2819
|
+
if (this._dragInstances.size === 1) {
|
|
2820
|
+
this._ngZone.runOutsideAngular(() => {
|
|
2821
|
+
this._cleanupDocumentTouchmove?.();
|
|
2822
|
+
this._cleanupDocumentTouchmove = this._renderer.listen(this._document, "touchmove", this._persistentTouchmoveListener, activeCapturingEventOptions);
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
}
|
|
2826
|
+
/** Removes a drop container from the registry. */
|
|
2827
|
+
removeDropContainer(drop) {
|
|
2828
|
+
this._dropInstances.delete(drop);
|
|
2829
|
+
}
|
|
2830
|
+
/** Removes a drag item instance from the registry. */
|
|
2831
|
+
removeDragItem(drag) {
|
|
2832
|
+
this._dragInstances.delete(drag);
|
|
2833
|
+
this.stopDragging(drag);
|
|
2834
|
+
if (this._dragInstances.size === 0) {
|
|
2835
|
+
this._cleanupDocumentTouchmove?.();
|
|
2836
|
+
}
|
|
2837
|
+
}
|
|
2838
|
+
/**
|
|
2839
|
+
* Starts the dragging sequence for a drag instance.
|
|
2840
|
+
* @param drag Drag instance which is being dragged.
|
|
2841
|
+
* @param event Event that initiated the dragging.
|
|
2842
|
+
*/
|
|
2843
|
+
startDragging(drag, event) {
|
|
2844
|
+
if (this._activeDragInstances().indexOf(drag) > -1) {
|
|
2845
|
+
return;
|
|
2846
|
+
}
|
|
2847
|
+
this._styleLoader.load(_ResetsLoader);
|
|
2848
|
+
this._activeDragInstances.update((instances) => [...instances, drag]);
|
|
2849
|
+
if (this._activeDragInstances().length === 1) {
|
|
2850
|
+
const isTouchEvent2 = event.type.startsWith("touch");
|
|
2851
|
+
const endEventHandler = (e) => this.pointerUp.next(e);
|
|
2852
|
+
const toBind = [
|
|
2853
|
+
// Use capturing so that we pick up scroll changes in any scrollable nodes that aren't
|
|
2854
|
+
// the document. See https://github.com/angular/components/issues/17144.
|
|
2855
|
+
["scroll", (e) => this._scroll.next(e), capturingEventOptions],
|
|
2856
|
+
// Preventing the default action on `mousemove` isn't enough to disable text selection
|
|
2857
|
+
// on Safari so we need to prevent the selection event as well. Alternatively this can
|
|
2858
|
+
// be done by setting `user-select: none` on the `body`, however it has causes a style
|
|
2859
|
+
// recalculation which can be expensive on pages with a lot of elements.
|
|
2860
|
+
["selectstart", this._preventDefaultWhileDragging, activeCapturingEventOptions]
|
|
2861
|
+
];
|
|
2862
|
+
if (isTouchEvent2) {
|
|
2863
|
+
toBind.push(["touchend", endEventHandler, capturingEventOptions], ["touchcancel", endEventHandler, capturingEventOptions]);
|
|
2864
|
+
} else {
|
|
2865
|
+
toBind.push(["mouseup", endEventHandler, capturingEventOptions]);
|
|
2866
|
+
}
|
|
2867
|
+
if (!isTouchEvent2) {
|
|
2868
|
+
toBind.push(["mousemove", (e) => this.pointerMove.next(e), activeCapturingEventOptions]);
|
|
2869
|
+
}
|
|
2870
|
+
this._ngZone.runOutsideAngular(() => {
|
|
2871
|
+
this._globalListeners = toBind.map(([name, handler, options]) => this._renderer.listen(this._document, name, handler, options));
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
/** Stops dragging a drag item instance. */
|
|
2876
|
+
stopDragging(drag) {
|
|
2877
|
+
this._activeDragInstances.update((instances) => {
|
|
2878
|
+
const index = instances.indexOf(drag);
|
|
2879
|
+
if (index > -1) {
|
|
2880
|
+
instances.splice(index, 1);
|
|
2881
|
+
return [...instances];
|
|
2882
|
+
}
|
|
2883
|
+
return instances;
|
|
2884
|
+
});
|
|
2885
|
+
if (this._activeDragInstances().length === 0) {
|
|
2886
|
+
this._clearGlobalListeners();
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
/** Gets whether a drag item instance is currently being dragged. */
|
|
2890
|
+
isDragging(drag) {
|
|
2891
|
+
return this._activeDragInstances().indexOf(drag) > -1;
|
|
2892
|
+
}
|
|
2893
|
+
/**
|
|
2894
|
+
* Gets a stream that will emit when any element on the page is scrolled while an item is being
|
|
2895
|
+
* dragged.
|
|
2896
|
+
* @param shadowRoot Optional shadow root that the current dragging sequence started from.
|
|
2897
|
+
* Top-level listeners won't pick up events coming from the shadow DOM so this parameter can
|
|
2898
|
+
* be used to include an additional top-level listener at the shadow root level.
|
|
2899
|
+
*/
|
|
2900
|
+
scrolled(shadowRoot) {
|
|
2901
|
+
const streams = [this._scroll];
|
|
2902
|
+
if (shadowRoot && shadowRoot !== this._document) {
|
|
2903
|
+
streams.push(new Observable((observer) => {
|
|
2904
|
+
return this._ngZone.runOutsideAngular(() => {
|
|
2905
|
+
const cleanup = this._renderer.listen(shadowRoot, "scroll", (event) => {
|
|
2906
|
+
if (this._activeDragInstances().length) {
|
|
2907
|
+
observer.next(event);
|
|
2908
|
+
}
|
|
2909
|
+
}, capturingEventOptions);
|
|
2910
|
+
return () => {
|
|
2911
|
+
cleanup();
|
|
2912
|
+
};
|
|
2913
|
+
});
|
|
2914
|
+
}));
|
|
2915
|
+
}
|
|
2916
|
+
return merge(...streams);
|
|
2917
|
+
}
|
|
2918
|
+
/**
|
|
2919
|
+
* Tracks the DOM node which has a draggable directive.
|
|
2920
|
+
* @param node Node to track.
|
|
2921
|
+
* @param dragRef Drag directive set on the node.
|
|
2922
|
+
*/
|
|
2923
|
+
registerDirectiveNode(node, dragRef) {
|
|
2924
|
+
this._domNodesToDirectives ??= /* @__PURE__ */ new WeakMap();
|
|
2925
|
+
this._domNodesToDirectives.set(node, dragRef);
|
|
2926
|
+
}
|
|
2927
|
+
/**
|
|
2928
|
+
* Stops tracking a draggable directive node.
|
|
2929
|
+
* @param node Node to stop tracking.
|
|
2930
|
+
*/
|
|
2931
|
+
removeDirectiveNode(node) {
|
|
2932
|
+
this._domNodesToDirectives?.delete(node);
|
|
2933
|
+
}
|
|
2934
|
+
/**
|
|
2935
|
+
* Gets the drag directive corresponding to a specific DOM node, if any.
|
|
2936
|
+
* @param node Node for which to do the lookup.
|
|
2937
|
+
*/
|
|
2938
|
+
getDragDirectiveForNode(node) {
|
|
2939
|
+
return this._domNodesToDirectives?.get(node) || null;
|
|
2940
|
+
}
|
|
2941
|
+
ngOnDestroy() {
|
|
2942
|
+
this._dragInstances.forEach((instance) => this.removeDragItem(instance));
|
|
2943
|
+
this._dropInstances.forEach((instance) => this.removeDropContainer(instance));
|
|
2944
|
+
this._domNodesToDirectives = null;
|
|
2945
|
+
this._clearGlobalListeners();
|
|
2946
|
+
this.pointerMove.complete();
|
|
2947
|
+
this.pointerUp.complete();
|
|
2948
|
+
}
|
|
2949
|
+
/**
|
|
2950
|
+
* Event listener that will prevent the default browser action while the user is dragging.
|
|
2951
|
+
* @param event Event whose default action should be prevented.
|
|
2952
|
+
*/
|
|
2953
|
+
_preventDefaultWhileDragging = (event) => {
|
|
2954
|
+
if (this._activeDragInstances().length > 0) {
|
|
2955
|
+
event.preventDefault();
|
|
2956
|
+
}
|
|
2957
|
+
};
|
|
2958
|
+
/** Event listener for `touchmove` that is bound even if no dragging is happening. */
|
|
2959
|
+
_persistentTouchmoveListener = (event) => {
|
|
2960
|
+
if (this._activeDragInstances().length > 0) {
|
|
2961
|
+
if (this._activeDragInstances().some(this._draggingPredicate)) {
|
|
2962
|
+
event.preventDefault();
|
|
2963
|
+
}
|
|
2964
|
+
this.pointerMove.next(event);
|
|
2965
|
+
}
|
|
2966
|
+
};
|
|
2967
|
+
/** Clears out the global event listeners from the `document`. */
|
|
2968
|
+
_clearGlobalListeners() {
|
|
2969
|
+
this._globalListeners?.forEach((cleanup) => cleanup());
|
|
2970
|
+
this._globalListeners = void 0;
|
|
2971
|
+
}
|
|
2972
|
+
static \u0275fac = function DragDropRegistry_Factory(__ngFactoryType__) {
|
|
2973
|
+
return new (__ngFactoryType__ || _DragDropRegistry)();
|
|
2974
|
+
};
|
|
2975
|
+
static \u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({
|
|
2976
|
+
token: _DragDropRegistry,
|
|
2977
|
+
factory: _DragDropRegistry.\u0275fac,
|
|
2978
|
+
providedIn: "root"
|
|
2979
|
+
});
|
|
2980
|
+
};
|
|
2981
|
+
(() => {
|
|
2982
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DragDropRegistry, [{
|
|
2983
|
+
type: Injectable,
|
|
2984
|
+
args: [{
|
|
2985
|
+
providedIn: "root"
|
|
2986
|
+
}]
|
|
2987
|
+
}], () => [], null);
|
|
2988
|
+
})();
|
|
2989
|
+
var DEFAULT_CONFIG = {
|
|
2990
|
+
dragStartThreshold: 5,
|
|
2991
|
+
pointerDirectionChangeThreshold: 5
|
|
2992
|
+
};
|
|
2993
|
+
var DragDrop = class _DragDrop {
|
|
2994
|
+
_document = inject(DOCUMENT);
|
|
2995
|
+
_ngZone = inject(NgZone);
|
|
2996
|
+
_viewportRuler = inject(ViewportRuler);
|
|
2997
|
+
_dragDropRegistry = inject(DragDropRegistry);
|
|
2998
|
+
_renderer = inject(RendererFactory2).createRenderer(null, null);
|
|
2999
|
+
constructor() {
|
|
3000
|
+
}
|
|
3001
|
+
/**
|
|
3002
|
+
* Turns an element into a draggable item.
|
|
3003
|
+
* @param element Element to which to attach the dragging functionality.
|
|
3004
|
+
* @param config Object used to configure the dragging behavior.
|
|
3005
|
+
*/
|
|
3006
|
+
createDrag(element, config = DEFAULT_CONFIG) {
|
|
3007
|
+
return new DragRef(element, config, this._document, this._ngZone, this._viewportRuler, this._dragDropRegistry, this._renderer);
|
|
3008
|
+
}
|
|
3009
|
+
/**
|
|
3010
|
+
* Turns an element into a drop list.
|
|
3011
|
+
* @param element Element to which to attach the drop list functionality.
|
|
3012
|
+
*/
|
|
3013
|
+
createDropList(element) {
|
|
3014
|
+
return new DropListRef(element, this._dragDropRegistry, this._document, this._ngZone, this._viewportRuler);
|
|
3015
|
+
}
|
|
3016
|
+
static \u0275fac = function DragDrop_Factory(__ngFactoryType__) {
|
|
3017
|
+
return new (__ngFactoryType__ || _DragDrop)();
|
|
3018
|
+
};
|
|
3019
|
+
static \u0275prov = /* @__PURE__ */ \u0275\u0275defineInjectable({
|
|
3020
|
+
token: _DragDrop,
|
|
3021
|
+
factory: _DragDrop.\u0275fac,
|
|
3022
|
+
providedIn: "root"
|
|
3023
|
+
});
|
|
3024
|
+
};
|
|
3025
|
+
(() => {
|
|
3026
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DragDrop, [{
|
|
3027
|
+
type: Injectable,
|
|
3028
|
+
args: [{
|
|
3029
|
+
providedIn: "root"
|
|
3030
|
+
}]
|
|
3031
|
+
}], () => [], null);
|
|
3032
|
+
})();
|
|
3033
|
+
var CDK_DRAG_PARENT = new InjectionToken("CDK_DRAG_PARENT");
|
|
3034
|
+
function assertElementNode(node, name) {
|
|
3035
|
+
if (node.nodeType !== 1) {
|
|
3036
|
+
throw Error(`${name} must be attached to an element node. Currently attached to "${node.nodeName}".`);
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
var CDK_DRAG_HANDLE = new InjectionToken("CdkDragHandle");
|
|
3040
|
+
var CdkDragHandle = class _CdkDragHandle {
|
|
3041
|
+
element = inject(ElementRef);
|
|
3042
|
+
_parentDrag = inject(CDK_DRAG_PARENT, {
|
|
3043
|
+
optional: true,
|
|
3044
|
+
skipSelf: true
|
|
3045
|
+
});
|
|
3046
|
+
_dragDropRegistry = inject(DragDropRegistry);
|
|
3047
|
+
/** Emits when the state of the handle has changed. */
|
|
3048
|
+
_stateChanges = new Subject();
|
|
3049
|
+
/** Whether starting to drag through this handle is disabled. */
|
|
3050
|
+
get disabled() {
|
|
3051
|
+
return this._disabled;
|
|
3052
|
+
}
|
|
3053
|
+
set disabled(value) {
|
|
3054
|
+
this._disabled = value;
|
|
3055
|
+
this._stateChanges.next(this);
|
|
3056
|
+
}
|
|
3057
|
+
_disabled = false;
|
|
3058
|
+
constructor() {
|
|
3059
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) {
|
|
3060
|
+
assertElementNode(this.element.nativeElement, "cdkDragHandle");
|
|
3061
|
+
}
|
|
3062
|
+
this._parentDrag?._addHandle(this);
|
|
3063
|
+
}
|
|
3064
|
+
ngAfterViewInit() {
|
|
3065
|
+
if (!this._parentDrag) {
|
|
3066
|
+
let parent = this.element.nativeElement.parentElement;
|
|
3067
|
+
while (parent) {
|
|
3068
|
+
const ref = this._dragDropRegistry.getDragDirectiveForNode(parent);
|
|
3069
|
+
if (ref) {
|
|
3070
|
+
this._parentDrag = ref;
|
|
3071
|
+
ref._addHandle(this);
|
|
3072
|
+
break;
|
|
3073
|
+
}
|
|
3074
|
+
parent = parent.parentElement;
|
|
3075
|
+
}
|
|
3076
|
+
}
|
|
3077
|
+
}
|
|
3078
|
+
ngOnDestroy() {
|
|
3079
|
+
this._parentDrag?._removeHandle(this);
|
|
3080
|
+
this._stateChanges.complete();
|
|
3081
|
+
}
|
|
3082
|
+
static \u0275fac = function CdkDragHandle_Factory(__ngFactoryType__) {
|
|
3083
|
+
return new (__ngFactoryType__ || _CdkDragHandle)();
|
|
3084
|
+
};
|
|
3085
|
+
static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({
|
|
3086
|
+
type: _CdkDragHandle,
|
|
3087
|
+
selectors: [["", "cdkDragHandle", ""]],
|
|
3088
|
+
hostAttrs: [1, "cdk-drag-handle"],
|
|
3089
|
+
inputs: {
|
|
3090
|
+
disabled: [2, "cdkDragHandleDisabled", "disabled", booleanAttribute]
|
|
3091
|
+
},
|
|
3092
|
+
features: [\u0275\u0275ProvidersFeature([{
|
|
3093
|
+
provide: CDK_DRAG_HANDLE,
|
|
3094
|
+
useExisting: _CdkDragHandle
|
|
3095
|
+
}])]
|
|
3096
|
+
});
|
|
3097
|
+
};
|
|
3098
|
+
(() => {
|
|
3099
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CdkDragHandle, [{
|
|
3100
|
+
type: Directive,
|
|
3101
|
+
args: [{
|
|
3102
|
+
selector: "[cdkDragHandle]",
|
|
3103
|
+
host: {
|
|
3104
|
+
"class": "cdk-drag-handle"
|
|
3105
|
+
},
|
|
3106
|
+
providers: [{
|
|
3107
|
+
provide: CDK_DRAG_HANDLE,
|
|
3108
|
+
useExisting: CdkDragHandle
|
|
3109
|
+
}]
|
|
3110
|
+
}]
|
|
3111
|
+
}], () => [], {
|
|
3112
|
+
disabled: [{
|
|
3113
|
+
type: Input,
|
|
3114
|
+
args: [{
|
|
3115
|
+
alias: "cdkDragHandleDisabled",
|
|
3116
|
+
transform: booleanAttribute
|
|
3117
|
+
}]
|
|
3118
|
+
}]
|
|
3119
|
+
});
|
|
3120
|
+
})();
|
|
3121
|
+
var CDK_DRAG_CONFIG = new InjectionToken("CDK_DRAG_CONFIG");
|
|
3122
|
+
var CDK_DROP_LIST = new InjectionToken("CdkDropList");
|
|
3123
|
+
var CdkDrag = class _CdkDrag {
|
|
3124
|
+
element = inject(ElementRef);
|
|
3125
|
+
dropContainer = inject(CDK_DROP_LIST, {
|
|
3126
|
+
optional: true,
|
|
3127
|
+
skipSelf: true
|
|
3128
|
+
});
|
|
3129
|
+
_ngZone = inject(NgZone);
|
|
3130
|
+
_viewContainerRef = inject(ViewContainerRef);
|
|
3131
|
+
_dir = inject(Directionality, {
|
|
3132
|
+
optional: true
|
|
3133
|
+
});
|
|
3134
|
+
_changeDetectorRef = inject(ChangeDetectorRef);
|
|
3135
|
+
_selfHandle = inject(CDK_DRAG_HANDLE, {
|
|
3136
|
+
optional: true,
|
|
3137
|
+
self: true
|
|
3138
|
+
});
|
|
3139
|
+
_parentDrag = inject(CDK_DRAG_PARENT, {
|
|
3140
|
+
optional: true,
|
|
3141
|
+
skipSelf: true
|
|
3142
|
+
});
|
|
3143
|
+
_dragDropRegistry = inject(DragDropRegistry);
|
|
3144
|
+
_destroyed = new Subject();
|
|
3145
|
+
_handles = new BehaviorSubject([]);
|
|
3146
|
+
_previewTemplate;
|
|
3147
|
+
_placeholderTemplate;
|
|
3148
|
+
/** Reference to the underlying drag instance. */
|
|
3149
|
+
_dragRef;
|
|
3150
|
+
/** Arbitrary data to attach to this drag instance. */
|
|
3151
|
+
data;
|
|
3152
|
+
/** Locks the position of the dragged element along the specified axis. */
|
|
3153
|
+
lockAxis;
|
|
3154
|
+
/**
|
|
3155
|
+
* Selector that will be used to determine the root draggable element, starting from
|
|
3156
|
+
* the `cdkDrag` element and going up the DOM. Passing an alternate root element is useful
|
|
3157
|
+
* when trying to enable dragging on an element that you might not have access to.
|
|
3158
|
+
*/
|
|
3159
|
+
rootElementSelector;
|
|
3160
|
+
/**
|
|
3161
|
+
* Node or selector that will be used to determine the element to which the draggable's
|
|
3162
|
+
* position will be constrained. If a string is passed in, it'll be used as a selector that
|
|
3163
|
+
* will be matched starting from the element's parent and going up the DOM until a match
|
|
3164
|
+
* has been found.
|
|
3165
|
+
*/
|
|
3166
|
+
boundaryElement;
|
|
3167
|
+
/**
|
|
3168
|
+
* Amount of milliseconds to wait after the user has put their
|
|
3169
|
+
* pointer down before starting to drag the element.
|
|
3170
|
+
*/
|
|
3171
|
+
dragStartDelay;
|
|
3172
|
+
/**
|
|
3173
|
+
* Sets the position of a `CdkDrag` that is outside of a drop container.
|
|
3174
|
+
* Can be used to restore the element's position for a returning user.
|
|
3175
|
+
*/
|
|
3176
|
+
freeDragPosition;
|
|
3177
|
+
/** Whether starting to drag this element is disabled. */
|
|
3178
|
+
get disabled() {
|
|
3179
|
+
return this._disabled || !!(this.dropContainer && this.dropContainer.disabled);
|
|
3180
|
+
}
|
|
3181
|
+
set disabled(value) {
|
|
3182
|
+
this._disabled = value;
|
|
3183
|
+
this._dragRef.disabled = this._disabled;
|
|
3184
|
+
}
|
|
3185
|
+
_disabled;
|
|
3186
|
+
/**
|
|
3187
|
+
* Function that can be used to customize the logic of how the position of the drag item
|
|
3188
|
+
* is limited while it's being dragged. Gets called with a point containing the current position
|
|
3189
|
+
* of the user's pointer on the page, a reference to the item being dragged and its dimensions.
|
|
3190
|
+
* Should return a point describing where the item should be rendered.
|
|
3191
|
+
*/
|
|
3192
|
+
constrainPosition;
|
|
3193
|
+
/** Class to be added to the preview element. */
|
|
3194
|
+
previewClass;
|
|
3195
|
+
/**
|
|
3196
|
+
* Configures the place into which the preview of the item will be inserted. Can be configured
|
|
3197
|
+
* globally through `CDK_DROP_LIST`. Possible values:
|
|
3198
|
+
* - `global` - Preview will be inserted at the bottom of the `<body>`. The advantage is that
|
|
3199
|
+
* you don't have to worry about `overflow: hidden` or `z-index`, but the item won't retain
|
|
3200
|
+
* its inherited styles.
|
|
3201
|
+
* - `parent` - Preview will be inserted into the parent of the drag item. The advantage is that
|
|
3202
|
+
* inherited styles will be preserved, but it may be clipped by `overflow: hidden` or not be
|
|
3203
|
+
* visible due to `z-index`. Furthermore, the preview is going to have an effect over selectors
|
|
3204
|
+
* like `:nth-child` and some flexbox configurations.
|
|
3205
|
+
* - `ElementRef<HTMLElement> | HTMLElement` - Preview will be inserted into a specific element.
|
|
3206
|
+
* Same advantages and disadvantages as `parent`.
|
|
3207
|
+
*/
|
|
3208
|
+
previewContainer;
|
|
3209
|
+
/**
|
|
3210
|
+
* If the parent of the dragged element has a `scale` transform, it can throw off the
|
|
3211
|
+
* positioning when the user starts dragging. Use this input to notify the CDK of the scale.
|
|
3212
|
+
*/
|
|
3213
|
+
scale = 1;
|
|
3214
|
+
/** Emits when the user starts dragging the item. */
|
|
3215
|
+
started = new EventEmitter();
|
|
3216
|
+
/** Emits when the user has released a drag item, before any animations have started. */
|
|
3217
|
+
released = new EventEmitter();
|
|
3218
|
+
/** Emits when the user stops dragging an item in the container. */
|
|
3219
|
+
ended = new EventEmitter();
|
|
3220
|
+
/** Emits when the user has moved the item into a new container. */
|
|
3221
|
+
entered = new EventEmitter();
|
|
3222
|
+
/** Emits when the user removes the item its container by dragging it into another container. */
|
|
3223
|
+
exited = new EventEmitter();
|
|
3224
|
+
/** Emits when the user drops the item inside a container. */
|
|
3225
|
+
dropped = new EventEmitter();
|
|
3226
|
+
/**
|
|
3227
|
+
* Emits as the user is dragging the item. Use with caution,
|
|
3228
|
+
* because this event will fire for every pixel that the user has dragged.
|
|
3229
|
+
*/
|
|
3230
|
+
moved = new Observable((observer) => {
|
|
3231
|
+
const subscription = this._dragRef.moved.pipe(map((movedEvent) => ({
|
|
3232
|
+
source: this,
|
|
3233
|
+
pointerPosition: movedEvent.pointerPosition,
|
|
3234
|
+
event: movedEvent.event,
|
|
3235
|
+
delta: movedEvent.delta,
|
|
3236
|
+
distance: movedEvent.distance
|
|
3237
|
+
}))).subscribe(observer);
|
|
3238
|
+
return () => {
|
|
3239
|
+
subscription.unsubscribe();
|
|
3240
|
+
};
|
|
3241
|
+
});
|
|
3242
|
+
_injector = inject(Injector);
|
|
3243
|
+
constructor() {
|
|
3244
|
+
const dropContainer = this.dropContainer;
|
|
3245
|
+
const config = inject(CDK_DRAG_CONFIG, {
|
|
3246
|
+
optional: true
|
|
3247
|
+
});
|
|
3248
|
+
const dragDrop = inject(DragDrop);
|
|
3249
|
+
this._dragRef = dragDrop.createDrag(this.element, {
|
|
3250
|
+
dragStartThreshold: config && config.dragStartThreshold != null ? config.dragStartThreshold : 5,
|
|
3251
|
+
pointerDirectionChangeThreshold: config && config.pointerDirectionChangeThreshold != null ? config.pointerDirectionChangeThreshold : 5,
|
|
3252
|
+
zIndex: config?.zIndex
|
|
3253
|
+
});
|
|
3254
|
+
this._dragRef.data = this;
|
|
3255
|
+
this._dragDropRegistry.registerDirectiveNode(this.element.nativeElement, this);
|
|
3256
|
+
if (config) {
|
|
3257
|
+
this._assignDefaults(config);
|
|
3258
|
+
}
|
|
3259
|
+
if (dropContainer) {
|
|
3260
|
+
dropContainer.addItem(this);
|
|
3261
|
+
dropContainer._dropListRef.beforeStarted.pipe(takeUntil(this._destroyed)).subscribe(() => {
|
|
3262
|
+
this._dragRef.scale = this.scale;
|
|
3263
|
+
});
|
|
3264
|
+
}
|
|
3265
|
+
this._syncInputs(this._dragRef);
|
|
3266
|
+
this._handleEvents(this._dragRef);
|
|
3267
|
+
}
|
|
3268
|
+
/**
|
|
3269
|
+
* Returns the element that is being used as a placeholder
|
|
3270
|
+
* while the current element is being dragged.
|
|
3271
|
+
*/
|
|
3272
|
+
getPlaceholderElement() {
|
|
3273
|
+
return this._dragRef.getPlaceholderElement();
|
|
3274
|
+
}
|
|
3275
|
+
/** Returns the root draggable element. */
|
|
3276
|
+
getRootElement() {
|
|
3277
|
+
return this._dragRef.getRootElement();
|
|
3278
|
+
}
|
|
3279
|
+
/** Resets a standalone drag item to its initial position. */
|
|
3280
|
+
reset() {
|
|
3281
|
+
this._dragRef.reset();
|
|
3282
|
+
}
|
|
3283
|
+
/** Resets drag item to end of boundary element. */
|
|
3284
|
+
resetToBoundary() {
|
|
3285
|
+
this._dragRef.resetToBoundary();
|
|
3286
|
+
}
|
|
3287
|
+
/**
|
|
3288
|
+
* Gets the pixel coordinates of the draggable outside of a drop container.
|
|
3289
|
+
*/
|
|
3290
|
+
getFreeDragPosition() {
|
|
3291
|
+
return this._dragRef.getFreeDragPosition();
|
|
3292
|
+
}
|
|
3293
|
+
/**
|
|
3294
|
+
* Sets the current position in pixels the draggable outside of a drop container.
|
|
3295
|
+
* @param value New position to be set.
|
|
3296
|
+
*/
|
|
3297
|
+
setFreeDragPosition(value) {
|
|
3298
|
+
this._dragRef.setFreeDragPosition(value);
|
|
3299
|
+
}
|
|
3300
|
+
ngAfterViewInit() {
|
|
3301
|
+
afterNextRender(() => {
|
|
3302
|
+
this._updateRootElement();
|
|
3303
|
+
this._setupHandlesListener();
|
|
3304
|
+
this._dragRef.scale = this.scale;
|
|
3305
|
+
if (this.freeDragPosition) {
|
|
3306
|
+
this._dragRef.setFreeDragPosition(this.freeDragPosition);
|
|
3307
|
+
}
|
|
3308
|
+
}, {
|
|
3309
|
+
injector: this._injector
|
|
3310
|
+
});
|
|
3311
|
+
}
|
|
3312
|
+
ngOnChanges(changes) {
|
|
3313
|
+
const rootSelectorChange = changes["rootElementSelector"];
|
|
3314
|
+
const positionChange = changes["freeDragPosition"];
|
|
3315
|
+
if (rootSelectorChange && !rootSelectorChange.firstChange) {
|
|
3316
|
+
this._updateRootElement();
|
|
3317
|
+
}
|
|
3318
|
+
this._dragRef.scale = this.scale;
|
|
3319
|
+
if (positionChange && !positionChange.firstChange && this.freeDragPosition) {
|
|
3320
|
+
this._dragRef.setFreeDragPosition(this.freeDragPosition);
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
ngOnDestroy() {
|
|
3324
|
+
if (this.dropContainer) {
|
|
3325
|
+
this.dropContainer.removeItem(this);
|
|
3326
|
+
}
|
|
3327
|
+
this._dragDropRegistry.removeDirectiveNode(this.element.nativeElement);
|
|
3328
|
+
this._ngZone.runOutsideAngular(() => {
|
|
3329
|
+
this._handles.complete();
|
|
3330
|
+
this._destroyed.next();
|
|
3331
|
+
this._destroyed.complete();
|
|
3332
|
+
this._dragRef.dispose();
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
_addHandle(handle) {
|
|
3336
|
+
const handles = this._handles.getValue();
|
|
3337
|
+
handles.push(handle);
|
|
3338
|
+
this._handles.next(handles);
|
|
3339
|
+
}
|
|
3340
|
+
_removeHandle(handle) {
|
|
3341
|
+
const handles = this._handles.getValue();
|
|
3342
|
+
const index = handles.indexOf(handle);
|
|
3343
|
+
if (index > -1) {
|
|
3344
|
+
handles.splice(index, 1);
|
|
3345
|
+
this._handles.next(handles);
|
|
3346
|
+
}
|
|
3347
|
+
}
|
|
3348
|
+
_setPreviewTemplate(preview) {
|
|
3349
|
+
this._previewTemplate = preview;
|
|
3350
|
+
}
|
|
3351
|
+
_resetPreviewTemplate(preview) {
|
|
3352
|
+
if (preview === this._previewTemplate) {
|
|
3353
|
+
this._previewTemplate = null;
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
_setPlaceholderTemplate(placeholder) {
|
|
3357
|
+
this._placeholderTemplate = placeholder;
|
|
3358
|
+
}
|
|
3359
|
+
_resetPlaceholderTemplate(placeholder) {
|
|
3360
|
+
if (placeholder === this._placeholderTemplate) {
|
|
3361
|
+
this._placeholderTemplate = null;
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
/** Syncs the root element with the `DragRef`. */
|
|
3365
|
+
_updateRootElement() {
|
|
3366
|
+
const element = this.element.nativeElement;
|
|
3367
|
+
let rootElement = element;
|
|
3368
|
+
if (this.rootElementSelector) {
|
|
3369
|
+
rootElement = element.closest !== void 0 ? element.closest(this.rootElementSelector) : (
|
|
3370
|
+
// Comment tag doesn't have closest method, so use parent's one.
|
|
3371
|
+
element.parentElement?.closest(this.rootElementSelector)
|
|
3372
|
+
);
|
|
3373
|
+
}
|
|
3374
|
+
if (rootElement && (typeof ngDevMode === "undefined" || ngDevMode)) {
|
|
3375
|
+
assertElementNode(rootElement, "cdkDrag");
|
|
3376
|
+
}
|
|
3377
|
+
this._dragRef.withRootElement(rootElement || element);
|
|
3378
|
+
}
|
|
3379
|
+
/** Gets the boundary element, based on the `boundaryElement` value. */
|
|
3380
|
+
_getBoundaryElement() {
|
|
3381
|
+
const boundary = this.boundaryElement;
|
|
3382
|
+
if (!boundary) {
|
|
3383
|
+
return null;
|
|
3384
|
+
}
|
|
3385
|
+
if (typeof boundary === "string") {
|
|
3386
|
+
return this.element.nativeElement.closest(boundary);
|
|
3387
|
+
}
|
|
3388
|
+
return coerceElement(boundary);
|
|
3389
|
+
}
|
|
3390
|
+
/** Syncs the inputs of the CdkDrag with the options of the underlying DragRef. */
|
|
3391
|
+
_syncInputs(ref) {
|
|
3392
|
+
ref.beforeStarted.subscribe(() => {
|
|
3393
|
+
if (!ref.isDragging()) {
|
|
3394
|
+
const dir = this._dir;
|
|
3395
|
+
const dragStartDelay = this.dragStartDelay;
|
|
3396
|
+
const placeholder = this._placeholderTemplate ? {
|
|
3397
|
+
template: this._placeholderTemplate.templateRef,
|
|
3398
|
+
context: this._placeholderTemplate.data,
|
|
3399
|
+
viewContainer: this._viewContainerRef
|
|
3400
|
+
} : null;
|
|
3401
|
+
const preview = this._previewTemplate ? {
|
|
3402
|
+
template: this._previewTemplate.templateRef,
|
|
3403
|
+
context: this._previewTemplate.data,
|
|
3404
|
+
matchSize: this._previewTemplate.matchSize,
|
|
3405
|
+
viewContainer: this._viewContainerRef
|
|
3406
|
+
} : null;
|
|
3407
|
+
ref.disabled = this.disabled;
|
|
3408
|
+
ref.lockAxis = this.lockAxis;
|
|
3409
|
+
ref.scale = this.scale;
|
|
3410
|
+
ref.dragStartDelay = typeof dragStartDelay === "object" && dragStartDelay ? dragStartDelay : coerceNumberProperty(dragStartDelay);
|
|
3411
|
+
ref.constrainPosition = this.constrainPosition;
|
|
3412
|
+
ref.previewClass = this.previewClass;
|
|
3413
|
+
ref.withBoundaryElement(this._getBoundaryElement()).withPlaceholderTemplate(placeholder).withPreviewTemplate(preview).withPreviewContainer(this.previewContainer || "global");
|
|
3414
|
+
if (dir) {
|
|
3415
|
+
ref.withDirection(dir.value);
|
|
3416
|
+
}
|
|
3417
|
+
}
|
|
3418
|
+
});
|
|
3419
|
+
ref.beforeStarted.pipe(take(1)).subscribe(() => {
|
|
3420
|
+
if (this._parentDrag) {
|
|
3421
|
+
ref.withParent(this._parentDrag._dragRef);
|
|
3422
|
+
return;
|
|
3423
|
+
}
|
|
3424
|
+
let parent = this.element.nativeElement.parentElement;
|
|
3425
|
+
while (parent) {
|
|
3426
|
+
const parentDrag = this._dragDropRegistry.getDragDirectiveForNode(parent);
|
|
3427
|
+
if (parentDrag) {
|
|
3428
|
+
ref.withParent(parentDrag._dragRef);
|
|
3429
|
+
break;
|
|
3430
|
+
}
|
|
3431
|
+
parent = parent.parentElement;
|
|
3432
|
+
}
|
|
3433
|
+
});
|
|
3434
|
+
}
|
|
3435
|
+
/** Handles the events from the underlying `DragRef`. */
|
|
3436
|
+
_handleEvents(ref) {
|
|
3437
|
+
ref.started.subscribe((startEvent) => {
|
|
3438
|
+
this.started.emit({
|
|
3439
|
+
source: this,
|
|
3440
|
+
event: startEvent.event
|
|
3441
|
+
});
|
|
3442
|
+
this._changeDetectorRef.markForCheck();
|
|
3443
|
+
});
|
|
3444
|
+
ref.released.subscribe((releaseEvent) => {
|
|
3445
|
+
this.released.emit({
|
|
3446
|
+
source: this,
|
|
3447
|
+
event: releaseEvent.event
|
|
3448
|
+
});
|
|
3449
|
+
});
|
|
3450
|
+
ref.ended.subscribe((endEvent) => {
|
|
3451
|
+
this.ended.emit({
|
|
3452
|
+
source: this,
|
|
3453
|
+
distance: endEvent.distance,
|
|
3454
|
+
dropPoint: endEvent.dropPoint,
|
|
3455
|
+
event: endEvent.event
|
|
3456
|
+
});
|
|
3457
|
+
this._changeDetectorRef.markForCheck();
|
|
3458
|
+
});
|
|
3459
|
+
ref.entered.subscribe((enterEvent) => {
|
|
3460
|
+
this.entered.emit({
|
|
3461
|
+
container: enterEvent.container.data,
|
|
3462
|
+
item: this,
|
|
3463
|
+
currentIndex: enterEvent.currentIndex
|
|
3464
|
+
});
|
|
3465
|
+
});
|
|
3466
|
+
ref.exited.subscribe((exitEvent) => {
|
|
3467
|
+
this.exited.emit({
|
|
3468
|
+
container: exitEvent.container.data,
|
|
3469
|
+
item: this
|
|
3470
|
+
});
|
|
3471
|
+
});
|
|
3472
|
+
ref.dropped.subscribe((dropEvent) => {
|
|
3473
|
+
this.dropped.emit({
|
|
3474
|
+
previousIndex: dropEvent.previousIndex,
|
|
3475
|
+
currentIndex: dropEvent.currentIndex,
|
|
3476
|
+
previousContainer: dropEvent.previousContainer.data,
|
|
3477
|
+
container: dropEvent.container.data,
|
|
3478
|
+
isPointerOverContainer: dropEvent.isPointerOverContainer,
|
|
3479
|
+
item: this,
|
|
3480
|
+
distance: dropEvent.distance,
|
|
3481
|
+
dropPoint: dropEvent.dropPoint,
|
|
3482
|
+
event: dropEvent.event
|
|
3483
|
+
});
|
|
3484
|
+
});
|
|
3485
|
+
}
|
|
3486
|
+
/** Assigns the default input values based on a provided config object. */
|
|
3487
|
+
_assignDefaults(config) {
|
|
3488
|
+
const {
|
|
3489
|
+
lockAxis,
|
|
3490
|
+
dragStartDelay,
|
|
3491
|
+
constrainPosition,
|
|
3492
|
+
previewClass,
|
|
3493
|
+
boundaryElement,
|
|
3494
|
+
draggingDisabled,
|
|
3495
|
+
rootElementSelector,
|
|
3496
|
+
previewContainer
|
|
3497
|
+
} = config;
|
|
3498
|
+
this.disabled = draggingDisabled == null ? false : draggingDisabled;
|
|
3499
|
+
this.dragStartDelay = dragStartDelay || 0;
|
|
3500
|
+
if (lockAxis) {
|
|
3501
|
+
this.lockAxis = lockAxis;
|
|
3502
|
+
}
|
|
3503
|
+
if (constrainPosition) {
|
|
3504
|
+
this.constrainPosition = constrainPosition;
|
|
3505
|
+
}
|
|
3506
|
+
if (previewClass) {
|
|
3507
|
+
this.previewClass = previewClass;
|
|
3508
|
+
}
|
|
3509
|
+
if (boundaryElement) {
|
|
3510
|
+
this.boundaryElement = boundaryElement;
|
|
3511
|
+
}
|
|
3512
|
+
if (rootElementSelector) {
|
|
3513
|
+
this.rootElementSelector = rootElementSelector;
|
|
3514
|
+
}
|
|
3515
|
+
if (previewContainer) {
|
|
3516
|
+
this.previewContainer = previewContainer;
|
|
3517
|
+
}
|
|
3518
|
+
}
|
|
3519
|
+
/** Sets up the listener that syncs the handles with the drag ref. */
|
|
3520
|
+
_setupHandlesListener() {
|
|
3521
|
+
this._handles.pipe(
|
|
3522
|
+
// Sync the new handles with the DragRef.
|
|
3523
|
+
tap((handles) => {
|
|
3524
|
+
const handleElements = handles.map((handle) => handle.element);
|
|
3525
|
+
if (this._selfHandle && this.rootElementSelector) {
|
|
3526
|
+
handleElements.push(this.element);
|
|
3527
|
+
}
|
|
3528
|
+
this._dragRef.withHandles(handleElements);
|
|
3529
|
+
}),
|
|
3530
|
+
// Listen if the state of any of the handles changes.
|
|
3531
|
+
switchMap((handles) => {
|
|
3532
|
+
return merge(...handles.map((item) => item._stateChanges.pipe(startWith(item))));
|
|
3533
|
+
}),
|
|
3534
|
+
takeUntil(this._destroyed)
|
|
3535
|
+
).subscribe((handleInstance) => {
|
|
3536
|
+
const dragRef = this._dragRef;
|
|
3537
|
+
const handle = handleInstance.element.nativeElement;
|
|
3538
|
+
handleInstance.disabled ? dragRef.disableHandle(handle) : dragRef.enableHandle(handle);
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
static \u0275fac = function CdkDrag_Factory(__ngFactoryType__) {
|
|
3542
|
+
return new (__ngFactoryType__ || _CdkDrag)();
|
|
3543
|
+
};
|
|
3544
|
+
static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({
|
|
3545
|
+
type: _CdkDrag,
|
|
3546
|
+
selectors: [["", "cdkDrag", ""]],
|
|
3547
|
+
hostAttrs: [1, "cdk-drag"],
|
|
3548
|
+
hostVars: 4,
|
|
3549
|
+
hostBindings: function CdkDrag_HostBindings(rf, ctx) {
|
|
3550
|
+
if (rf & 2) {
|
|
3551
|
+
\u0275\u0275classProp("cdk-drag-disabled", ctx.disabled)("cdk-drag-dragging", ctx._dragRef.isDragging());
|
|
3552
|
+
}
|
|
3553
|
+
},
|
|
3554
|
+
inputs: {
|
|
3555
|
+
data: [0, "cdkDragData", "data"],
|
|
3556
|
+
lockAxis: [0, "cdkDragLockAxis", "lockAxis"],
|
|
3557
|
+
rootElementSelector: [0, "cdkDragRootElement", "rootElementSelector"],
|
|
3558
|
+
boundaryElement: [0, "cdkDragBoundary", "boundaryElement"],
|
|
3559
|
+
dragStartDelay: [0, "cdkDragStartDelay", "dragStartDelay"],
|
|
3560
|
+
freeDragPosition: [0, "cdkDragFreeDragPosition", "freeDragPosition"],
|
|
3561
|
+
disabled: [2, "cdkDragDisabled", "disabled", booleanAttribute],
|
|
3562
|
+
constrainPosition: [0, "cdkDragConstrainPosition", "constrainPosition"],
|
|
3563
|
+
previewClass: [0, "cdkDragPreviewClass", "previewClass"],
|
|
3564
|
+
previewContainer: [0, "cdkDragPreviewContainer", "previewContainer"],
|
|
3565
|
+
scale: [2, "cdkDragScale", "scale", numberAttribute]
|
|
3566
|
+
},
|
|
3567
|
+
outputs: {
|
|
3568
|
+
started: "cdkDragStarted",
|
|
3569
|
+
released: "cdkDragReleased",
|
|
3570
|
+
ended: "cdkDragEnded",
|
|
3571
|
+
entered: "cdkDragEntered",
|
|
3572
|
+
exited: "cdkDragExited",
|
|
3573
|
+
dropped: "cdkDragDropped",
|
|
3574
|
+
moved: "cdkDragMoved"
|
|
3575
|
+
},
|
|
3576
|
+
exportAs: ["cdkDrag"],
|
|
3577
|
+
features: [\u0275\u0275ProvidersFeature([{
|
|
3578
|
+
provide: CDK_DRAG_PARENT,
|
|
3579
|
+
useExisting: _CdkDrag
|
|
3580
|
+
}]), \u0275\u0275NgOnChangesFeature]
|
|
3581
|
+
});
|
|
3582
|
+
};
|
|
3583
|
+
(() => {
|
|
3584
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CdkDrag, [{
|
|
3585
|
+
type: Directive,
|
|
3586
|
+
args: [{
|
|
3587
|
+
selector: "[cdkDrag]",
|
|
3588
|
+
exportAs: "cdkDrag",
|
|
3589
|
+
host: {
|
|
3590
|
+
"class": "cdk-drag",
|
|
3591
|
+
"[class.cdk-drag-disabled]": "disabled",
|
|
3592
|
+
"[class.cdk-drag-dragging]": "_dragRef.isDragging()"
|
|
3593
|
+
},
|
|
3594
|
+
providers: [{
|
|
3595
|
+
provide: CDK_DRAG_PARENT,
|
|
3596
|
+
useExisting: CdkDrag
|
|
3597
|
+
}]
|
|
3598
|
+
}]
|
|
3599
|
+
}], () => [], {
|
|
3600
|
+
data: [{
|
|
3601
|
+
type: Input,
|
|
3602
|
+
args: ["cdkDragData"]
|
|
3603
|
+
}],
|
|
3604
|
+
lockAxis: [{
|
|
3605
|
+
type: Input,
|
|
3606
|
+
args: ["cdkDragLockAxis"]
|
|
3607
|
+
}],
|
|
3608
|
+
rootElementSelector: [{
|
|
3609
|
+
type: Input,
|
|
3610
|
+
args: ["cdkDragRootElement"]
|
|
3611
|
+
}],
|
|
3612
|
+
boundaryElement: [{
|
|
3613
|
+
type: Input,
|
|
3614
|
+
args: ["cdkDragBoundary"]
|
|
3615
|
+
}],
|
|
3616
|
+
dragStartDelay: [{
|
|
3617
|
+
type: Input,
|
|
3618
|
+
args: ["cdkDragStartDelay"]
|
|
3619
|
+
}],
|
|
3620
|
+
freeDragPosition: [{
|
|
3621
|
+
type: Input,
|
|
3622
|
+
args: ["cdkDragFreeDragPosition"]
|
|
3623
|
+
}],
|
|
3624
|
+
disabled: [{
|
|
3625
|
+
type: Input,
|
|
3626
|
+
args: [{
|
|
3627
|
+
alias: "cdkDragDisabled",
|
|
3628
|
+
transform: booleanAttribute
|
|
3629
|
+
}]
|
|
3630
|
+
}],
|
|
3631
|
+
constrainPosition: [{
|
|
3632
|
+
type: Input,
|
|
3633
|
+
args: ["cdkDragConstrainPosition"]
|
|
3634
|
+
}],
|
|
3635
|
+
previewClass: [{
|
|
3636
|
+
type: Input,
|
|
3637
|
+
args: ["cdkDragPreviewClass"]
|
|
3638
|
+
}],
|
|
3639
|
+
previewContainer: [{
|
|
3640
|
+
type: Input,
|
|
3641
|
+
args: ["cdkDragPreviewContainer"]
|
|
3642
|
+
}],
|
|
3643
|
+
scale: [{
|
|
3644
|
+
type: Input,
|
|
3645
|
+
args: [{
|
|
3646
|
+
alias: "cdkDragScale",
|
|
3647
|
+
transform: numberAttribute
|
|
3648
|
+
}]
|
|
3649
|
+
}],
|
|
3650
|
+
started: [{
|
|
3651
|
+
type: Output,
|
|
3652
|
+
args: ["cdkDragStarted"]
|
|
3653
|
+
}],
|
|
3654
|
+
released: [{
|
|
3655
|
+
type: Output,
|
|
3656
|
+
args: ["cdkDragReleased"]
|
|
3657
|
+
}],
|
|
3658
|
+
ended: [{
|
|
3659
|
+
type: Output,
|
|
3660
|
+
args: ["cdkDragEnded"]
|
|
3661
|
+
}],
|
|
3662
|
+
entered: [{
|
|
3663
|
+
type: Output,
|
|
3664
|
+
args: ["cdkDragEntered"]
|
|
3665
|
+
}],
|
|
3666
|
+
exited: [{
|
|
3667
|
+
type: Output,
|
|
3668
|
+
args: ["cdkDragExited"]
|
|
3669
|
+
}],
|
|
3670
|
+
dropped: [{
|
|
3671
|
+
type: Output,
|
|
3672
|
+
args: ["cdkDragDropped"]
|
|
3673
|
+
}],
|
|
3674
|
+
moved: [{
|
|
3675
|
+
type: Output,
|
|
3676
|
+
args: ["cdkDragMoved"]
|
|
3677
|
+
}]
|
|
3678
|
+
});
|
|
3679
|
+
})();
|
|
3680
|
+
var CDK_DROP_LIST_GROUP = new InjectionToken("CdkDropListGroup");
|
|
3681
|
+
var CdkDropListGroup = class _CdkDropListGroup {
|
|
3682
|
+
/** Drop lists registered inside the group. */
|
|
3683
|
+
_items = /* @__PURE__ */ new Set();
|
|
3684
|
+
/** Whether starting a dragging sequence from inside this group is disabled. */
|
|
3685
|
+
disabled = false;
|
|
3686
|
+
ngOnDestroy() {
|
|
3687
|
+
this._items.clear();
|
|
3688
|
+
}
|
|
3689
|
+
static \u0275fac = function CdkDropListGroup_Factory(__ngFactoryType__) {
|
|
3690
|
+
return new (__ngFactoryType__ || _CdkDropListGroup)();
|
|
3691
|
+
};
|
|
3692
|
+
static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({
|
|
3693
|
+
type: _CdkDropListGroup,
|
|
3694
|
+
selectors: [["", "cdkDropListGroup", ""]],
|
|
3695
|
+
inputs: {
|
|
3696
|
+
disabled: [2, "cdkDropListGroupDisabled", "disabled", booleanAttribute]
|
|
3697
|
+
},
|
|
3698
|
+
exportAs: ["cdkDropListGroup"],
|
|
3699
|
+
features: [\u0275\u0275ProvidersFeature([{
|
|
3700
|
+
provide: CDK_DROP_LIST_GROUP,
|
|
3701
|
+
useExisting: _CdkDropListGroup
|
|
3702
|
+
}])]
|
|
3703
|
+
});
|
|
3704
|
+
};
|
|
3705
|
+
(() => {
|
|
3706
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CdkDropListGroup, [{
|
|
3707
|
+
type: Directive,
|
|
3708
|
+
args: [{
|
|
3709
|
+
selector: "[cdkDropListGroup]",
|
|
3710
|
+
exportAs: "cdkDropListGroup",
|
|
3711
|
+
providers: [{
|
|
3712
|
+
provide: CDK_DROP_LIST_GROUP,
|
|
3713
|
+
useExisting: CdkDropListGroup
|
|
3714
|
+
}]
|
|
3715
|
+
}]
|
|
3716
|
+
}], null, {
|
|
3717
|
+
disabled: [{
|
|
3718
|
+
type: Input,
|
|
3719
|
+
args: [{
|
|
3720
|
+
alias: "cdkDropListGroupDisabled",
|
|
3721
|
+
transform: booleanAttribute
|
|
3722
|
+
}]
|
|
3723
|
+
}]
|
|
3724
|
+
});
|
|
3725
|
+
})();
|
|
3726
|
+
var CdkDropList = class _CdkDropList {
|
|
3727
|
+
element = inject(ElementRef);
|
|
3728
|
+
_changeDetectorRef = inject(ChangeDetectorRef);
|
|
3729
|
+
_scrollDispatcher = inject(ScrollDispatcher);
|
|
3730
|
+
_dir = inject(Directionality, {
|
|
3731
|
+
optional: true
|
|
3732
|
+
});
|
|
3733
|
+
_group = inject(CDK_DROP_LIST_GROUP, {
|
|
3734
|
+
optional: true,
|
|
3735
|
+
skipSelf: true
|
|
3736
|
+
});
|
|
3737
|
+
/** Refs that have been synced with the drop ref most recently. */
|
|
3738
|
+
_latestSortedRefs;
|
|
3739
|
+
/** Emits when the list has been destroyed. */
|
|
3740
|
+
_destroyed = new Subject();
|
|
3741
|
+
/** Whether the element's scrollable parents have been resolved. */
|
|
3742
|
+
_scrollableParentsResolved;
|
|
3743
|
+
/** Keeps track of the drop lists that are currently on the page. */
|
|
3744
|
+
static _dropLists = [];
|
|
3745
|
+
/** Reference to the underlying drop list instance. */
|
|
3746
|
+
_dropListRef;
|
|
3747
|
+
/**
|
|
3748
|
+
* Other draggable containers that this container is connected to and into which the
|
|
3749
|
+
* container's items can be transferred. Can either be references to other drop containers,
|
|
3750
|
+
* or their unique IDs.
|
|
3751
|
+
*/
|
|
3752
|
+
connectedTo = [];
|
|
3753
|
+
/** Arbitrary data to attach to this container. */
|
|
3754
|
+
data;
|
|
3755
|
+
/** Direction in which the list is oriented. */
|
|
3756
|
+
orientation;
|
|
3757
|
+
/**
|
|
3758
|
+
* Unique ID for the drop zone. Can be used as a reference
|
|
3759
|
+
* in the `connectedTo` of another `CdkDropList`.
|
|
3760
|
+
*/
|
|
3761
|
+
id = inject(_IdGenerator).getId("cdk-drop-list-");
|
|
3762
|
+
/** Locks the position of the draggable elements inside the container along the specified axis. */
|
|
3763
|
+
lockAxis;
|
|
3764
|
+
/** Whether starting a dragging sequence from this container is disabled. */
|
|
3765
|
+
get disabled() {
|
|
3766
|
+
return this._disabled || !!this._group && this._group.disabled;
|
|
3767
|
+
}
|
|
3768
|
+
set disabled(value) {
|
|
3769
|
+
this._dropListRef.disabled = this._disabled = value;
|
|
3770
|
+
}
|
|
3771
|
+
_disabled;
|
|
3772
|
+
/** Whether sorting within this drop list is disabled. */
|
|
3773
|
+
sortingDisabled;
|
|
3774
|
+
/**
|
|
3775
|
+
* Function that is used to determine whether an item
|
|
3776
|
+
* is allowed to be moved into a drop container.
|
|
3777
|
+
*/
|
|
3778
|
+
enterPredicate = () => true;
|
|
3779
|
+
/** Functions that is used to determine whether an item can be sorted into a particular index. */
|
|
3780
|
+
sortPredicate = () => true;
|
|
3781
|
+
/** Whether to auto-scroll the view when the user moves their pointer close to the edges. */
|
|
3782
|
+
autoScrollDisabled;
|
|
3783
|
+
/** Number of pixels to scroll for each frame when auto-scrolling an element. */
|
|
3784
|
+
autoScrollStep;
|
|
3785
|
+
/**
|
|
3786
|
+
* Selector that will be used to resolve an alternate element container for the drop list.
|
|
3787
|
+
* Passing an alternate container is useful for the cases where one might not have control
|
|
3788
|
+
* over the parent node of the draggable items within the list (e.g. due to content projection).
|
|
3789
|
+
* This allows for usages like:
|
|
3790
|
+
*
|
|
3791
|
+
* ```
|
|
3792
|
+
* <div cdkDropList cdkDropListElementContainer=".inner">
|
|
3793
|
+
* <div class="inner">
|
|
3794
|
+
* <div cdkDrag></div>
|
|
3795
|
+
* </div>
|
|
3796
|
+
* </div>
|
|
3797
|
+
* ```
|
|
3798
|
+
*/
|
|
3799
|
+
elementContainerSelector;
|
|
3800
|
+
/**
|
|
3801
|
+
* By default when an item leaves its initial container, its placeholder will be transferred
|
|
3802
|
+
* to the new container. If that's not desirable for your use case, you can enable this option
|
|
3803
|
+
* which will clone the placeholder and leave it inside the original container. If the item is
|
|
3804
|
+
* returned to the initial container, the anchor element will be removed automatically.
|
|
3805
|
+
*
|
|
3806
|
+
* The cloned placeholder can be styled by targeting the `cdk-drag-anchor` class.
|
|
3807
|
+
*
|
|
3808
|
+
* This option is useful in combination with `cdkDropListSortingDisabled` to implement copying
|
|
3809
|
+
* behavior in a drop list.
|
|
3810
|
+
*/
|
|
3811
|
+
hasAnchor;
|
|
3812
|
+
/** Emits when the user drops an item inside the container. */
|
|
3813
|
+
dropped = new EventEmitter();
|
|
3814
|
+
/**
|
|
3815
|
+
* Emits when the user has moved a new drag item into this container.
|
|
3816
|
+
*/
|
|
3817
|
+
entered = new EventEmitter();
|
|
3818
|
+
/**
|
|
3819
|
+
* Emits when the user removes an item from the container
|
|
3820
|
+
* by dragging it into another container.
|
|
3821
|
+
*/
|
|
3822
|
+
exited = new EventEmitter();
|
|
3823
|
+
/** Emits as the user is swapping items while actively dragging. */
|
|
3824
|
+
sorted = new EventEmitter();
|
|
3825
|
+
/**
|
|
3826
|
+
* Keeps track of the items that are registered with this container. Historically we used to
|
|
3827
|
+
* do this with a `ContentChildren` query, however queries don't handle transplanted views very
|
|
3828
|
+
* well which means that we can't handle cases like dragging the headers of a `mat-table`
|
|
3829
|
+
* correctly. What we do instead is to have the items register themselves with the container
|
|
3830
|
+
* and then we sort them based on their position in the DOM.
|
|
3831
|
+
*/
|
|
3832
|
+
_unsortedItems = /* @__PURE__ */ new Set();
|
|
3833
|
+
constructor() {
|
|
3834
|
+
const dragDrop = inject(DragDrop);
|
|
3835
|
+
const config = inject(CDK_DRAG_CONFIG, {
|
|
3836
|
+
optional: true
|
|
3837
|
+
});
|
|
3838
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) {
|
|
3839
|
+
assertElementNode(this.element.nativeElement, "cdkDropList");
|
|
3840
|
+
}
|
|
3841
|
+
this._dropListRef = dragDrop.createDropList(this.element);
|
|
3842
|
+
this._dropListRef.data = this;
|
|
3843
|
+
if (config) {
|
|
3844
|
+
this._assignDefaults(config);
|
|
3845
|
+
}
|
|
3846
|
+
this._dropListRef.enterPredicate = (drag, drop) => {
|
|
3847
|
+
return this.enterPredicate(drag.data, drop.data);
|
|
3848
|
+
};
|
|
3849
|
+
this._dropListRef.sortPredicate = (index, drag, drop) => {
|
|
3850
|
+
return this.sortPredicate(index, drag.data, drop.data);
|
|
3851
|
+
};
|
|
3852
|
+
this._setupInputSyncSubscription(this._dropListRef);
|
|
3853
|
+
this._handleEvents(this._dropListRef);
|
|
3854
|
+
_CdkDropList._dropLists.push(this);
|
|
3855
|
+
if (this._group) {
|
|
3856
|
+
this._group._items.add(this);
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
/** Registers an items with the drop list. */
|
|
3860
|
+
addItem(item) {
|
|
3861
|
+
this._unsortedItems.add(item);
|
|
3862
|
+
item._dragRef._withDropContainer(this._dropListRef);
|
|
3863
|
+
if (this._dropListRef.isDragging()) {
|
|
3864
|
+
this._syncItemsWithRef(this.getSortedItems().map((item2) => item2._dragRef));
|
|
3865
|
+
}
|
|
3866
|
+
}
|
|
3867
|
+
/** Removes an item from the drop list. */
|
|
3868
|
+
removeItem(item) {
|
|
3869
|
+
this._unsortedItems.delete(item);
|
|
3870
|
+
if (this._latestSortedRefs) {
|
|
3871
|
+
const index = this._latestSortedRefs.indexOf(item._dragRef);
|
|
3872
|
+
if (index > -1) {
|
|
3873
|
+
this._latestSortedRefs.splice(index, 1);
|
|
3874
|
+
this._syncItemsWithRef(this._latestSortedRefs);
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3878
|
+
/** Gets the registered items in the list, sorted by their position in the DOM. */
|
|
3879
|
+
getSortedItems() {
|
|
3880
|
+
return Array.from(this._unsortedItems).sort((a, b) => {
|
|
3881
|
+
const documentPosition = a._dragRef.getVisibleElement().compareDocumentPosition(b._dragRef.getVisibleElement());
|
|
3882
|
+
return documentPosition & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
3883
|
+
});
|
|
3884
|
+
}
|
|
3885
|
+
ngOnDestroy() {
|
|
3886
|
+
const index = _CdkDropList._dropLists.indexOf(this);
|
|
3887
|
+
if (index > -1) {
|
|
3888
|
+
_CdkDropList._dropLists.splice(index, 1);
|
|
3889
|
+
}
|
|
3890
|
+
if (this._group) {
|
|
3891
|
+
this._group._items.delete(this);
|
|
3892
|
+
}
|
|
3893
|
+
this._latestSortedRefs = void 0;
|
|
3894
|
+
this._unsortedItems.clear();
|
|
3895
|
+
this._dropListRef.dispose();
|
|
3896
|
+
this._destroyed.next();
|
|
3897
|
+
this._destroyed.complete();
|
|
3898
|
+
}
|
|
3899
|
+
/** Syncs the inputs of the CdkDropList with the options of the underlying DropListRef. */
|
|
3900
|
+
_setupInputSyncSubscription(ref) {
|
|
3901
|
+
if (this._dir) {
|
|
3902
|
+
this._dir.change.pipe(startWith(this._dir.value), takeUntil(this._destroyed)).subscribe((value) => ref.withDirection(value));
|
|
3903
|
+
}
|
|
3904
|
+
ref.beforeStarted.subscribe(() => {
|
|
3905
|
+
const siblings = coerceArray(this.connectedTo).map((drop) => {
|
|
3906
|
+
if (typeof drop === "string") {
|
|
3907
|
+
const correspondingDropList = _CdkDropList._dropLists.find((list) => list.id === drop);
|
|
3908
|
+
if (!correspondingDropList && (typeof ngDevMode === "undefined" || ngDevMode)) {
|
|
3909
|
+
console.warn(`CdkDropList could not find connected drop list with id "${drop}"`);
|
|
3910
|
+
}
|
|
3911
|
+
return correspondingDropList;
|
|
3912
|
+
}
|
|
3913
|
+
return drop;
|
|
3914
|
+
});
|
|
3915
|
+
if (this._group) {
|
|
3916
|
+
this._group._items.forEach((drop) => {
|
|
3917
|
+
if (siblings.indexOf(drop) === -1) {
|
|
3918
|
+
siblings.push(drop);
|
|
3919
|
+
}
|
|
3920
|
+
});
|
|
3921
|
+
}
|
|
3922
|
+
if (!this._scrollableParentsResolved) {
|
|
3923
|
+
const scrollableParents = this._scrollDispatcher.getAncestorScrollContainers(this.element).map((scrollable) => scrollable.getElementRef().nativeElement);
|
|
3924
|
+
this._dropListRef.withScrollableParents(scrollableParents);
|
|
3925
|
+
this._scrollableParentsResolved = true;
|
|
3926
|
+
}
|
|
3927
|
+
if (this.elementContainerSelector) {
|
|
3928
|
+
const container = this.element.nativeElement.querySelector(this.elementContainerSelector);
|
|
3929
|
+
if (!container && (typeof ngDevMode === "undefined" || ngDevMode)) {
|
|
3930
|
+
throw new Error(`CdkDropList could not find an element container matching the selector "${this.elementContainerSelector}"`);
|
|
3931
|
+
}
|
|
3932
|
+
ref.withElementContainer(container);
|
|
3933
|
+
}
|
|
3934
|
+
ref.disabled = this.disabled;
|
|
3935
|
+
ref.lockAxis = this.lockAxis;
|
|
3936
|
+
ref.sortingDisabled = this.sortingDisabled;
|
|
3937
|
+
ref.autoScrollDisabled = this.autoScrollDisabled;
|
|
3938
|
+
ref.autoScrollStep = coerceNumberProperty(this.autoScrollStep, 2);
|
|
3939
|
+
ref.hasAnchor = this.hasAnchor;
|
|
3940
|
+
ref.connectedTo(siblings.filter((drop) => drop && drop !== this).map((list) => list._dropListRef)).withOrientation(this.orientation);
|
|
3941
|
+
});
|
|
3942
|
+
}
|
|
3943
|
+
/** Handles events from the underlying DropListRef. */
|
|
3944
|
+
_handleEvents(ref) {
|
|
3945
|
+
ref.beforeStarted.subscribe(() => {
|
|
3946
|
+
this._syncItemsWithRef(this.getSortedItems().map((item) => item._dragRef));
|
|
3947
|
+
this._changeDetectorRef.markForCheck();
|
|
3948
|
+
});
|
|
3949
|
+
ref.entered.subscribe((event) => {
|
|
3950
|
+
this.entered.emit({
|
|
3951
|
+
container: this,
|
|
3952
|
+
item: event.item.data,
|
|
3953
|
+
currentIndex: event.currentIndex
|
|
3954
|
+
});
|
|
3955
|
+
});
|
|
3956
|
+
ref.exited.subscribe((event) => {
|
|
3957
|
+
this.exited.emit({
|
|
3958
|
+
container: this,
|
|
3959
|
+
item: event.item.data
|
|
3960
|
+
});
|
|
3961
|
+
this._changeDetectorRef.markForCheck();
|
|
3962
|
+
});
|
|
3963
|
+
ref.sorted.subscribe((event) => {
|
|
3964
|
+
this.sorted.emit({
|
|
3965
|
+
previousIndex: event.previousIndex,
|
|
3966
|
+
currentIndex: event.currentIndex,
|
|
3967
|
+
container: this,
|
|
3968
|
+
item: event.item.data
|
|
3969
|
+
});
|
|
3970
|
+
});
|
|
3971
|
+
ref.dropped.subscribe((dropEvent) => {
|
|
3972
|
+
this.dropped.emit({
|
|
3973
|
+
previousIndex: dropEvent.previousIndex,
|
|
3974
|
+
currentIndex: dropEvent.currentIndex,
|
|
3975
|
+
previousContainer: dropEvent.previousContainer.data,
|
|
3976
|
+
container: dropEvent.container.data,
|
|
3977
|
+
item: dropEvent.item.data,
|
|
3978
|
+
isPointerOverContainer: dropEvent.isPointerOverContainer,
|
|
3979
|
+
distance: dropEvent.distance,
|
|
3980
|
+
dropPoint: dropEvent.dropPoint,
|
|
3981
|
+
event: dropEvent.event
|
|
3982
|
+
});
|
|
3983
|
+
this._changeDetectorRef.markForCheck();
|
|
3984
|
+
});
|
|
3985
|
+
merge(ref.receivingStarted, ref.receivingStopped).subscribe(() => this._changeDetectorRef.markForCheck());
|
|
3986
|
+
}
|
|
3987
|
+
/** Assigns the default input values based on a provided config object. */
|
|
3988
|
+
_assignDefaults(config) {
|
|
3989
|
+
const {
|
|
3990
|
+
lockAxis,
|
|
3991
|
+
draggingDisabled,
|
|
3992
|
+
sortingDisabled,
|
|
3993
|
+
listAutoScrollDisabled,
|
|
3994
|
+
listOrientation
|
|
3995
|
+
} = config;
|
|
3996
|
+
this.disabled = draggingDisabled == null ? false : draggingDisabled;
|
|
3997
|
+
this.sortingDisabled = sortingDisabled == null ? false : sortingDisabled;
|
|
3998
|
+
this.autoScrollDisabled = listAutoScrollDisabled == null ? false : listAutoScrollDisabled;
|
|
3999
|
+
this.orientation = listOrientation || "vertical";
|
|
4000
|
+
if (lockAxis) {
|
|
4001
|
+
this.lockAxis = lockAxis;
|
|
4002
|
+
}
|
|
4003
|
+
}
|
|
4004
|
+
/** Syncs up the registered drag items with underlying drop list ref. */
|
|
4005
|
+
_syncItemsWithRef(items) {
|
|
4006
|
+
this._latestSortedRefs = items;
|
|
4007
|
+
this._dropListRef.withItems(items);
|
|
4008
|
+
}
|
|
4009
|
+
static \u0275fac = function CdkDropList_Factory(__ngFactoryType__) {
|
|
4010
|
+
return new (__ngFactoryType__ || _CdkDropList)();
|
|
4011
|
+
};
|
|
4012
|
+
static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({
|
|
4013
|
+
type: _CdkDropList,
|
|
4014
|
+
selectors: [["", "cdkDropList", ""], ["cdk-drop-list"]],
|
|
4015
|
+
hostAttrs: [1, "cdk-drop-list"],
|
|
4016
|
+
hostVars: 7,
|
|
4017
|
+
hostBindings: function CdkDropList_HostBindings(rf, ctx) {
|
|
4018
|
+
if (rf & 2) {
|
|
4019
|
+
\u0275\u0275attribute("id", ctx.id);
|
|
4020
|
+
\u0275\u0275classProp("cdk-drop-list-disabled", ctx.disabled)("cdk-drop-list-dragging", ctx._dropListRef.isDragging())("cdk-drop-list-receiving", ctx._dropListRef.isReceiving());
|
|
4021
|
+
}
|
|
4022
|
+
},
|
|
4023
|
+
inputs: {
|
|
4024
|
+
connectedTo: [0, "cdkDropListConnectedTo", "connectedTo"],
|
|
4025
|
+
data: [0, "cdkDropListData", "data"],
|
|
4026
|
+
orientation: [0, "cdkDropListOrientation", "orientation"],
|
|
4027
|
+
id: "id",
|
|
4028
|
+
lockAxis: [0, "cdkDropListLockAxis", "lockAxis"],
|
|
4029
|
+
disabled: [2, "cdkDropListDisabled", "disabled", booleanAttribute],
|
|
4030
|
+
sortingDisabled: [2, "cdkDropListSortingDisabled", "sortingDisabled", booleanAttribute],
|
|
4031
|
+
enterPredicate: [0, "cdkDropListEnterPredicate", "enterPredicate"],
|
|
4032
|
+
sortPredicate: [0, "cdkDropListSortPredicate", "sortPredicate"],
|
|
4033
|
+
autoScrollDisabled: [2, "cdkDropListAutoScrollDisabled", "autoScrollDisabled", booleanAttribute],
|
|
4034
|
+
autoScrollStep: [0, "cdkDropListAutoScrollStep", "autoScrollStep"],
|
|
4035
|
+
elementContainerSelector: [0, "cdkDropListElementContainer", "elementContainerSelector"],
|
|
4036
|
+
hasAnchor: [2, "cdkDropListHasAnchor", "hasAnchor", booleanAttribute]
|
|
4037
|
+
},
|
|
4038
|
+
outputs: {
|
|
4039
|
+
dropped: "cdkDropListDropped",
|
|
4040
|
+
entered: "cdkDropListEntered",
|
|
4041
|
+
exited: "cdkDropListExited",
|
|
4042
|
+
sorted: "cdkDropListSorted"
|
|
4043
|
+
},
|
|
4044
|
+
exportAs: ["cdkDropList"],
|
|
4045
|
+
features: [\u0275\u0275ProvidersFeature([
|
|
4046
|
+
// Prevent child drop lists from picking up the same group as their parent.
|
|
4047
|
+
{
|
|
4048
|
+
provide: CDK_DROP_LIST_GROUP,
|
|
4049
|
+
useValue: void 0
|
|
4050
|
+
},
|
|
4051
|
+
{
|
|
4052
|
+
provide: CDK_DROP_LIST,
|
|
4053
|
+
useExisting: _CdkDropList
|
|
4054
|
+
}
|
|
4055
|
+
])]
|
|
4056
|
+
});
|
|
4057
|
+
};
|
|
4058
|
+
(() => {
|
|
4059
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CdkDropList, [{
|
|
4060
|
+
type: Directive,
|
|
4061
|
+
args: [{
|
|
4062
|
+
selector: "[cdkDropList], cdk-drop-list",
|
|
4063
|
+
exportAs: "cdkDropList",
|
|
4064
|
+
providers: [
|
|
4065
|
+
// Prevent child drop lists from picking up the same group as their parent.
|
|
4066
|
+
{
|
|
4067
|
+
provide: CDK_DROP_LIST_GROUP,
|
|
4068
|
+
useValue: void 0
|
|
4069
|
+
},
|
|
4070
|
+
{
|
|
4071
|
+
provide: CDK_DROP_LIST,
|
|
4072
|
+
useExisting: CdkDropList
|
|
4073
|
+
}
|
|
4074
|
+
],
|
|
4075
|
+
host: {
|
|
4076
|
+
"class": "cdk-drop-list",
|
|
4077
|
+
"[attr.id]": "id",
|
|
4078
|
+
"[class.cdk-drop-list-disabled]": "disabled",
|
|
4079
|
+
"[class.cdk-drop-list-dragging]": "_dropListRef.isDragging()",
|
|
4080
|
+
"[class.cdk-drop-list-receiving]": "_dropListRef.isReceiving()"
|
|
4081
|
+
}
|
|
4082
|
+
}]
|
|
4083
|
+
}], () => [], {
|
|
4084
|
+
connectedTo: [{
|
|
4085
|
+
type: Input,
|
|
4086
|
+
args: ["cdkDropListConnectedTo"]
|
|
4087
|
+
}],
|
|
4088
|
+
data: [{
|
|
4089
|
+
type: Input,
|
|
4090
|
+
args: ["cdkDropListData"]
|
|
4091
|
+
}],
|
|
4092
|
+
orientation: [{
|
|
4093
|
+
type: Input,
|
|
4094
|
+
args: ["cdkDropListOrientation"]
|
|
4095
|
+
}],
|
|
4096
|
+
id: [{
|
|
4097
|
+
type: Input
|
|
4098
|
+
}],
|
|
4099
|
+
lockAxis: [{
|
|
4100
|
+
type: Input,
|
|
4101
|
+
args: ["cdkDropListLockAxis"]
|
|
4102
|
+
}],
|
|
4103
|
+
disabled: [{
|
|
4104
|
+
type: Input,
|
|
4105
|
+
args: [{
|
|
4106
|
+
alias: "cdkDropListDisabled",
|
|
4107
|
+
transform: booleanAttribute
|
|
4108
|
+
}]
|
|
4109
|
+
}],
|
|
4110
|
+
sortingDisabled: [{
|
|
4111
|
+
type: Input,
|
|
4112
|
+
args: [{
|
|
4113
|
+
alias: "cdkDropListSortingDisabled",
|
|
4114
|
+
transform: booleanAttribute
|
|
4115
|
+
}]
|
|
4116
|
+
}],
|
|
4117
|
+
enterPredicate: [{
|
|
4118
|
+
type: Input,
|
|
4119
|
+
args: ["cdkDropListEnterPredicate"]
|
|
4120
|
+
}],
|
|
4121
|
+
sortPredicate: [{
|
|
4122
|
+
type: Input,
|
|
4123
|
+
args: ["cdkDropListSortPredicate"]
|
|
4124
|
+
}],
|
|
4125
|
+
autoScrollDisabled: [{
|
|
4126
|
+
type: Input,
|
|
4127
|
+
args: [{
|
|
4128
|
+
alias: "cdkDropListAutoScrollDisabled",
|
|
4129
|
+
transform: booleanAttribute
|
|
4130
|
+
}]
|
|
4131
|
+
}],
|
|
4132
|
+
autoScrollStep: [{
|
|
4133
|
+
type: Input,
|
|
4134
|
+
args: ["cdkDropListAutoScrollStep"]
|
|
4135
|
+
}],
|
|
4136
|
+
elementContainerSelector: [{
|
|
4137
|
+
type: Input,
|
|
4138
|
+
args: ["cdkDropListElementContainer"]
|
|
4139
|
+
}],
|
|
4140
|
+
hasAnchor: [{
|
|
4141
|
+
type: Input,
|
|
4142
|
+
args: [{
|
|
4143
|
+
alias: "cdkDropListHasAnchor",
|
|
4144
|
+
transform: booleanAttribute
|
|
4145
|
+
}]
|
|
4146
|
+
}],
|
|
4147
|
+
dropped: [{
|
|
4148
|
+
type: Output,
|
|
4149
|
+
args: ["cdkDropListDropped"]
|
|
4150
|
+
}],
|
|
4151
|
+
entered: [{
|
|
4152
|
+
type: Output,
|
|
4153
|
+
args: ["cdkDropListEntered"]
|
|
4154
|
+
}],
|
|
4155
|
+
exited: [{
|
|
4156
|
+
type: Output,
|
|
4157
|
+
args: ["cdkDropListExited"]
|
|
4158
|
+
}],
|
|
4159
|
+
sorted: [{
|
|
4160
|
+
type: Output,
|
|
4161
|
+
args: ["cdkDropListSorted"]
|
|
4162
|
+
}]
|
|
4163
|
+
});
|
|
4164
|
+
})();
|
|
4165
|
+
var CDK_DRAG_PREVIEW = new InjectionToken("CdkDragPreview");
|
|
4166
|
+
var CdkDragPreview = class _CdkDragPreview {
|
|
4167
|
+
templateRef = inject(TemplateRef);
|
|
4168
|
+
_drag = inject(CDK_DRAG_PARENT, {
|
|
4169
|
+
optional: true
|
|
4170
|
+
});
|
|
4171
|
+
/** Context data to be added to the preview template instance. */
|
|
4172
|
+
data;
|
|
4173
|
+
/** Whether the preview should preserve the same size as the item that is being dragged. */
|
|
4174
|
+
matchSize = false;
|
|
4175
|
+
constructor() {
|
|
4176
|
+
this._drag?._setPreviewTemplate(this);
|
|
4177
|
+
}
|
|
4178
|
+
ngOnDestroy() {
|
|
4179
|
+
this._drag?._resetPreviewTemplate(this);
|
|
4180
|
+
}
|
|
4181
|
+
static \u0275fac = function CdkDragPreview_Factory(__ngFactoryType__) {
|
|
4182
|
+
return new (__ngFactoryType__ || _CdkDragPreview)();
|
|
4183
|
+
};
|
|
4184
|
+
static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({
|
|
4185
|
+
type: _CdkDragPreview,
|
|
4186
|
+
selectors: [["ng-template", "cdkDragPreview", ""]],
|
|
4187
|
+
inputs: {
|
|
4188
|
+
data: "data",
|
|
4189
|
+
matchSize: [2, "matchSize", "matchSize", booleanAttribute]
|
|
4190
|
+
},
|
|
4191
|
+
features: [\u0275\u0275ProvidersFeature([{
|
|
4192
|
+
provide: CDK_DRAG_PREVIEW,
|
|
4193
|
+
useExisting: _CdkDragPreview
|
|
4194
|
+
}])]
|
|
4195
|
+
});
|
|
4196
|
+
};
|
|
4197
|
+
(() => {
|
|
4198
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CdkDragPreview, [{
|
|
4199
|
+
type: Directive,
|
|
4200
|
+
args: [{
|
|
4201
|
+
selector: "ng-template[cdkDragPreview]",
|
|
4202
|
+
providers: [{
|
|
4203
|
+
provide: CDK_DRAG_PREVIEW,
|
|
4204
|
+
useExisting: CdkDragPreview
|
|
4205
|
+
}]
|
|
4206
|
+
}]
|
|
4207
|
+
}], () => [], {
|
|
4208
|
+
data: [{
|
|
4209
|
+
type: Input
|
|
4210
|
+
}],
|
|
4211
|
+
matchSize: [{
|
|
4212
|
+
type: Input,
|
|
4213
|
+
args: [{
|
|
4214
|
+
transform: booleanAttribute
|
|
4215
|
+
}]
|
|
4216
|
+
}]
|
|
4217
|
+
});
|
|
4218
|
+
})();
|
|
4219
|
+
var CDK_DRAG_PLACEHOLDER = new InjectionToken("CdkDragPlaceholder");
|
|
4220
|
+
var CdkDragPlaceholder = class _CdkDragPlaceholder {
|
|
4221
|
+
templateRef = inject(TemplateRef);
|
|
4222
|
+
_drag = inject(CDK_DRAG_PARENT, {
|
|
4223
|
+
optional: true
|
|
4224
|
+
});
|
|
4225
|
+
/** Context data to be added to the placeholder template instance. */
|
|
4226
|
+
data;
|
|
4227
|
+
constructor() {
|
|
4228
|
+
this._drag?._setPlaceholderTemplate(this);
|
|
4229
|
+
}
|
|
4230
|
+
ngOnDestroy() {
|
|
4231
|
+
this._drag?._resetPlaceholderTemplate(this);
|
|
4232
|
+
}
|
|
4233
|
+
static \u0275fac = function CdkDragPlaceholder_Factory(__ngFactoryType__) {
|
|
4234
|
+
return new (__ngFactoryType__ || _CdkDragPlaceholder)();
|
|
4235
|
+
};
|
|
4236
|
+
static \u0275dir = /* @__PURE__ */ \u0275\u0275defineDirective({
|
|
4237
|
+
type: _CdkDragPlaceholder,
|
|
4238
|
+
selectors: [["ng-template", "cdkDragPlaceholder", ""]],
|
|
4239
|
+
inputs: {
|
|
4240
|
+
data: "data"
|
|
4241
|
+
},
|
|
4242
|
+
features: [\u0275\u0275ProvidersFeature([{
|
|
4243
|
+
provide: CDK_DRAG_PLACEHOLDER,
|
|
4244
|
+
useExisting: _CdkDragPlaceholder
|
|
4245
|
+
}])]
|
|
4246
|
+
});
|
|
4247
|
+
};
|
|
4248
|
+
(() => {
|
|
4249
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(CdkDragPlaceholder, [{
|
|
4250
|
+
type: Directive,
|
|
4251
|
+
args: [{
|
|
4252
|
+
selector: "ng-template[cdkDragPlaceholder]",
|
|
4253
|
+
providers: [{
|
|
4254
|
+
provide: CDK_DRAG_PLACEHOLDER,
|
|
4255
|
+
useExisting: CdkDragPlaceholder
|
|
4256
|
+
}]
|
|
4257
|
+
}]
|
|
4258
|
+
}], () => [], {
|
|
4259
|
+
data: [{
|
|
4260
|
+
type: Input
|
|
4261
|
+
}]
|
|
4262
|
+
});
|
|
4263
|
+
})();
|
|
4264
|
+
var DRAG_DROP_DIRECTIVES = [CdkDropList, CdkDropListGroup, CdkDrag, CdkDragHandle, CdkDragPreview, CdkDragPlaceholder];
|
|
4265
|
+
var DragDropModule = class _DragDropModule {
|
|
4266
|
+
static \u0275fac = function DragDropModule_Factory(__ngFactoryType__) {
|
|
4267
|
+
return new (__ngFactoryType__ || _DragDropModule)();
|
|
4268
|
+
};
|
|
4269
|
+
static \u0275mod = /* @__PURE__ */ \u0275\u0275defineNgModule({
|
|
4270
|
+
type: _DragDropModule,
|
|
4271
|
+
imports: [CdkDropList, CdkDropListGroup, CdkDrag, CdkDragHandle, CdkDragPreview, CdkDragPlaceholder],
|
|
4272
|
+
exports: [CdkScrollableModule, CdkDropList, CdkDropListGroup, CdkDrag, CdkDragHandle, CdkDragPreview, CdkDragPlaceholder]
|
|
4273
|
+
});
|
|
4274
|
+
static \u0275inj = /* @__PURE__ */ \u0275\u0275defineInjector({
|
|
4275
|
+
providers: [DragDrop],
|
|
4276
|
+
imports: [CdkScrollableModule]
|
|
4277
|
+
});
|
|
4278
|
+
};
|
|
4279
|
+
(() => {
|
|
4280
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DragDropModule, [{
|
|
4281
|
+
type: NgModule,
|
|
4282
|
+
args: [{
|
|
4283
|
+
imports: DRAG_DROP_DIRECTIVES,
|
|
4284
|
+
exports: [CdkScrollableModule, ...DRAG_DROP_DIRECTIVES],
|
|
4285
|
+
providers: [DragDrop]
|
|
4286
|
+
}]
|
|
4287
|
+
}], null, null);
|
|
4288
|
+
})();
|
|
4289
|
+
|
|
4290
|
+
// src/app/core/components/dashboards-manage-bottom-sheet/dashboards-manage-bottom-sheet.component.ts
|
|
4291
|
+
function DashboardsManageBottomSheetComponent_Conditional_11_Template(rf, ctx) {
|
|
4292
|
+
if (rf & 1) {
|
|
4293
|
+
const _r1 = \u0275\u0275getCurrentView();
|
|
4294
|
+
\u0275\u0275elementStart(0, "button", 0);
|
|
4295
|
+
\u0275\u0275listener("click", function DashboardsManageBottomSheetComponent_Conditional_11_Template_button_click_0_listener() {
|
|
4296
|
+
\u0275\u0275restoreView(_r1);
|
|
4297
|
+
const ctx_r1 = \u0275\u0275nextContext();
|
|
4298
|
+
return \u0275\u0275resetView(ctx_r1.clickAction("cancel"));
|
|
4299
|
+
});
|
|
4300
|
+
\u0275\u0275elementStart(1, "mat-icon", 1);
|
|
4301
|
+
\u0275\u0275text(2, "close");
|
|
4302
|
+
\u0275\u0275elementEnd();
|
|
4303
|
+
\u0275\u0275elementStart(3, "span");
|
|
4304
|
+
\u0275\u0275text(4, "Close");
|
|
4305
|
+
\u0275\u0275elementEnd()();
|
|
4306
|
+
}
|
|
4307
|
+
}
|
|
4308
|
+
var DashboardsManageBottomSheetComponent = class _DashboardsManageBottomSheetComponent {
|
|
4309
|
+
_bottomSheetRef = inject(MatBottomSheetRef);
|
|
4310
|
+
data = inject(MAT_BOTTOM_SHEET_DATA);
|
|
4311
|
+
showCancel = !!(this.data && this.data.showCancel);
|
|
4312
|
+
clickAction(action) {
|
|
4313
|
+
this._bottomSheetRef.dismiss(action);
|
|
4314
|
+
}
|
|
4315
|
+
static \u0275fac = function DashboardsManageBottomSheetComponent_Factory(__ngFactoryType__) {
|
|
4316
|
+
return new (__ngFactoryType__ || _DashboardsManageBottomSheetComponent)();
|
|
4317
|
+
};
|
|
4318
|
+
static \u0275cmp = /* @__PURE__ */ \u0275\u0275defineComponent({ type: _DashboardsManageBottomSheetComponent, selectors: [["dashboards-manage-bottom-sheet"]], decls: 12, vars: 1, consts: [["mat-list-item", "", 3, "click"], ["matListItemIcon", ""], ["mat-list-item", ""]], template: function DashboardsManageBottomSheetComponent_Template(rf, ctx) {
|
|
4319
|
+
if (rf & 1) {
|
|
4320
|
+
\u0275\u0275elementStart(0, "mat-action-list")(1, "button", 0);
|
|
4321
|
+
\u0275\u0275listener("click", function DashboardsManageBottomSheetComponent_Template_button_click_1_listener() {
|
|
4322
|
+
return ctx.clickAction("duplicate");
|
|
4323
|
+
});
|
|
4324
|
+
\u0275\u0275elementStart(2, "mat-icon", 1);
|
|
4325
|
+
\u0275\u0275text(3, "content_copy");
|
|
4326
|
+
\u0275\u0275elementEnd();
|
|
4327
|
+
\u0275\u0275elementStart(4, "span");
|
|
4328
|
+
\u0275\u0275text(5, "Duplicate");
|
|
4329
|
+
\u0275\u0275elementEnd()();
|
|
4330
|
+
\u0275\u0275elementStart(6, "button", 0);
|
|
4331
|
+
\u0275\u0275listener("click", function DashboardsManageBottomSheetComponent_Template_button_click_6_listener() {
|
|
4332
|
+
return ctx.clickAction("delete");
|
|
4333
|
+
});
|
|
4334
|
+
\u0275\u0275elementStart(7, "mat-icon", 1);
|
|
4335
|
+
\u0275\u0275text(8, "delete_forever");
|
|
4336
|
+
\u0275\u0275elementEnd();
|
|
4337
|
+
\u0275\u0275elementStart(9, "span");
|
|
4338
|
+
\u0275\u0275text(10, "Delete");
|
|
4339
|
+
\u0275\u0275elementEnd()();
|
|
4340
|
+
\u0275\u0275conditionalCreate(11, DashboardsManageBottomSheetComponent_Conditional_11_Template, 5, 0, "button", 2);
|
|
4341
|
+
\u0275\u0275elementEnd();
|
|
4342
|
+
}
|
|
4343
|
+
if (rf & 2) {
|
|
4344
|
+
\u0275\u0275advance(11);
|
|
4345
|
+
\u0275\u0275conditional(ctx.showCancel ? 11 : -1);
|
|
4346
|
+
}
|
|
4347
|
+
}, dependencies: [MatListModule, MatActionList, MatListItem, MatListItemIcon, MatIconModule, MatIcon], encapsulation: 2 });
|
|
4348
|
+
};
|
|
4349
|
+
(() => {
|
|
4350
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DashboardsManageBottomSheetComponent, [{
|
|
4351
|
+
type: Component,
|
|
4352
|
+
args: [{ selector: "dashboards-manage-bottom-sheet", imports: [MatListModule, MatIconModule], template: `<mat-action-list>
|
|
4353
|
+
<button mat-list-item (click)="clickAction('duplicate')">
|
|
4354
|
+
<mat-icon matListItemIcon>content_copy</mat-icon>
|
|
4355
|
+
<span>Duplicate</span>
|
|
4356
|
+
</button>
|
|
4357
|
+
<button mat-list-item (click)="clickAction('delete')">
|
|
4358
|
+
<mat-icon matListItemIcon>delete_forever</mat-icon>
|
|
4359
|
+
<span>Delete</span>
|
|
4360
|
+
</button>
|
|
4361
|
+
@if (showCancel) {
|
|
4362
|
+
<button mat-list-item (click)="clickAction('cancel')">
|
|
4363
|
+
<mat-icon matListItemIcon>close</mat-icon>
|
|
4364
|
+
<span>Close</span>
|
|
4365
|
+
</button>
|
|
4366
|
+
}
|
|
4367
|
+
</mat-action-list>
|
|
4368
|
+
` }]
|
|
4369
|
+
}], null, null);
|
|
4370
|
+
})();
|
|
4371
|
+
(() => {
|
|
4372
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && \u0275setClassDebugInfo(DashboardsManageBottomSheetComponent, { className: "DashboardsManageBottomSheetComponent", filePath: "src/app/core/components/dashboards-manage-bottom-sheet/dashboards-manage-bottom-sheet.component.ts", lineNumber: 12 });
|
|
4373
|
+
})();
|
|
4374
|
+
|
|
4375
|
+
// src/app/core/components/dashboards-editor/dashboards-editor.component.ts
|
|
4376
|
+
var _forTrack0 = ($index, $item) => $item.id;
|
|
4377
|
+
function DashboardsEditorComponent_For_2_Template(rf, ctx) {
|
|
4378
|
+
if (rf & 1) {
|
|
4379
|
+
const _r1 = \u0275\u0275getCurrentView();
|
|
4380
|
+
\u0275\u0275elementStart(0, "div", 5);
|
|
4381
|
+
\u0275\u0275listener("cdkDragStarted", function DashboardsEditorComponent_For_2_Template_div_cdkDragStarted_0_listener() {
|
|
4382
|
+
\u0275\u0275restoreView(_r1);
|
|
4383
|
+
const ctx_r1 = \u0275\u0275nextContext();
|
|
4384
|
+
return \u0275\u0275resetView(ctx_r1.dragStart());
|
|
4385
|
+
})("cdkDragMoved", function DashboardsEditorComponent_For_2_Template_div_cdkDragMoved_0_listener($event) {
|
|
4386
|
+
\u0275\u0275restoreView(_r1);
|
|
4387
|
+
const ctx_r1 = \u0275\u0275nextContext();
|
|
4388
|
+
return \u0275\u0275resetView(ctx_r1.onDragMoved($event));
|
|
4389
|
+
})("cdkDragEnded", function DashboardsEditorComponent_For_2_Template_div_cdkDragEnded_0_listener() {
|
|
4390
|
+
\u0275\u0275restoreView(_r1);
|
|
4391
|
+
const ctx_r1 = \u0275\u0275nextContext();
|
|
4392
|
+
return \u0275\u0275resetView(ctx_r1.dragEnd());
|
|
4393
|
+
})("press", function DashboardsEditorComponent_For_2_Template_div_press_0_listener($event) {
|
|
4394
|
+
const \u0275$index_3_r3 = \u0275\u0275restoreView(_r1).$index;
|
|
4395
|
+
const ctx_r1 = \u0275\u0275nextContext();
|
|
4396
|
+
return \u0275\u0275resetView(ctx_r1.onPress(\u0275$index_3_r3, $event));
|
|
4397
|
+
})("doubletap", function DashboardsEditorComponent_For_2_Template_div_doubletap_0_listener() {
|
|
4398
|
+
const \u0275$index_3_r3 = \u0275\u0275restoreView(_r1).$index;
|
|
4399
|
+
const ctx_r1 = \u0275\u0275nextContext();
|
|
4400
|
+
return \u0275\u0275resetView(ctx_r1.editDashboard(\u0275$index_3_r3));
|
|
4401
|
+
});
|
|
4402
|
+
\u0275\u0275elementStart(1, "div", 6);
|
|
4403
|
+
\u0275\u0275text(2);
|
|
4404
|
+
\u0275\u0275elementEnd();
|
|
4405
|
+
\u0275\u0275elementStart(3, "div");
|
|
4406
|
+
\u0275\u0275element(4, "mat-icon", 7);
|
|
4407
|
+
\u0275\u0275elementEnd();
|
|
4408
|
+
\u0275\u0275elementStart(5, "p", 8);
|
|
4409
|
+
\u0275\u0275text(6);
|
|
4410
|
+
\u0275\u0275elementEnd()();
|
|
4411
|
+
}
|
|
4412
|
+
if (rf & 2) {
|
|
4413
|
+
const dashboard_r4 = ctx.$implicit;
|
|
4414
|
+
const \u0275$index_3_r3 = ctx.$index;
|
|
4415
|
+
const ctx_r1 = \u0275\u0275nextContext();
|
|
4416
|
+
\u0275\u0275property("cdkDragDisabled", ctx_r1._sheetOpen || ctx_r1.suppressDrag);
|
|
4417
|
+
\u0275\u0275advance(2);
|
|
4418
|
+
\u0275\u0275textInterpolate(\u0275$index_3_r3 + 1);
|
|
4419
|
+
\u0275\u0275advance(2);
|
|
4420
|
+
\u0275\u0275styleProp("width", 72, "px")("height", 72, "px");
|
|
4421
|
+
\u0275\u0275property("svgIcon", dashboard_r4.icon || "dashboard");
|
|
4422
|
+
\u0275\u0275advance(2);
|
|
4423
|
+
\u0275\u0275textInterpolate(dashboard_r4.name);
|
|
4424
|
+
}
|
|
4425
|
+
}
|
|
4426
|
+
var DashboardsEditorComponent = class _DashboardsEditorComponent {
|
|
4427
|
+
pageTitle = "Dashboards";
|
|
4428
|
+
_bottomSheet = inject(MatBottomSheet);
|
|
4429
|
+
_dashboard = inject(DashboardService);
|
|
4430
|
+
_uiEvent = inject(uiEventService);
|
|
4431
|
+
_dialog = inject(DialogService);
|
|
4432
|
+
_iconRegistry = inject(MatIconRegistry);
|
|
4433
|
+
_sanitizer = inject(DomSanitizer);
|
|
4434
|
+
/** True while bottom sheet open */
|
|
4435
|
+
_sheetOpen = false;
|
|
4436
|
+
/** Suppress starting a drag after a press consumed the pointer */
|
|
4437
|
+
suppressDrag = false;
|
|
4438
|
+
// Drag / press coordination flags
|
|
4439
|
+
_dragActive = false;
|
|
4440
|
+
// true between dragStart and dragEnd
|
|
4441
|
+
_dragMoved = false;
|
|
4442
|
+
// becomes true once movement surpasses threshold
|
|
4443
|
+
_dragSuppressThresholdPx = 4;
|
|
4444
|
+
// movement to treat as a real drag
|
|
4445
|
+
ngOnInit() {
|
|
4446
|
+
this.registerIconSet();
|
|
4447
|
+
}
|
|
4448
|
+
registerIconSet() {
|
|
4449
|
+
this._iconRegistry.addSvgIconSet(this._sanitizer.bypassSecurityTrustResourceUrl("assets/svg/icons.svg"));
|
|
4450
|
+
}
|
|
4451
|
+
addDashboard() {
|
|
4452
|
+
this._dialog.openDashboardPageEditorDialog({
|
|
4453
|
+
title: "New Dashboard",
|
|
4454
|
+
name: `Dashboard ${this._dashboard.dashboards().length + 1}`,
|
|
4455
|
+
icon: "dashboard",
|
|
4456
|
+
confirmBtnText: "Create",
|
|
4457
|
+
cancelBtnText: "Cancel"
|
|
4458
|
+
}).afterClosed().subscribe((data) => {
|
|
4459
|
+
if (!data) {
|
|
4460
|
+
return;
|
|
4461
|
+
}
|
|
4462
|
+
this._dashboard.add(data.name, [], data.icon);
|
|
4463
|
+
});
|
|
4464
|
+
}
|
|
4465
|
+
openBottomSheet(index) {
|
|
4466
|
+
const isLinuxFirefox = typeof navigator !== "undefined" && /Linux/.test(navigator.platform) && /Firefox/.test(navigator.userAgent);
|
|
4467
|
+
const sheetRef = this._bottomSheet.open(DashboardsManageBottomSheetComponent, isLinuxFirefox ? { disableClose: true, data: { showCancel: true } } : {});
|
|
4468
|
+
sheetRef.afterDismissed().subscribe((action) => {
|
|
4469
|
+
this._sheetOpen = false;
|
|
4470
|
+
switch (action) {
|
|
4471
|
+
case "delete":
|
|
4472
|
+
this.deleteDashboard(index);
|
|
4473
|
+
break;
|
|
4474
|
+
case "duplicate":
|
|
4475
|
+
this.duplicateDashboard(index, `${this._dashboard.dashboards()[index].name}`);
|
|
4476
|
+
break;
|
|
4477
|
+
default:
|
|
4478
|
+
break;
|
|
4479
|
+
}
|
|
4480
|
+
});
|
|
4481
|
+
}
|
|
4482
|
+
editDashboard(itemIndex) {
|
|
4483
|
+
const dashboard = this._dashboard.dashboards()[itemIndex];
|
|
4484
|
+
this._dialog.openDashboardPageEditorDialog({
|
|
4485
|
+
title: "Dashboard Details",
|
|
4486
|
+
name: dashboard.name,
|
|
4487
|
+
icon: dashboard.icon || "dashboard",
|
|
4488
|
+
confirmBtnText: "Save",
|
|
4489
|
+
cancelBtnText: "Cancel"
|
|
4490
|
+
}).afterClosed().subscribe((data) => {
|
|
4491
|
+
if (!data) {
|
|
4492
|
+
return;
|
|
4493
|
+
}
|
|
4494
|
+
this._dashboard.update(itemIndex, data.name, data.icon);
|
|
4495
|
+
});
|
|
4496
|
+
}
|
|
4497
|
+
deleteDashboard(index) {
|
|
4498
|
+
this._dashboard.delete(index);
|
|
4499
|
+
}
|
|
4500
|
+
duplicateDashboard(itemIndex, currentName) {
|
|
4501
|
+
const originalDashboard = this._dashboard.dashboards()[itemIndex];
|
|
4502
|
+
this._dialog.openDashboardPageEditorDialog({
|
|
4503
|
+
title: "Duplicate Dashboard",
|
|
4504
|
+
name: `${currentName} copy`,
|
|
4505
|
+
icon: originalDashboard.icon || "dashboard",
|
|
4506
|
+
confirmBtnText: "Save",
|
|
4507
|
+
cancelBtnText: "Cancel"
|
|
4508
|
+
}).afterClosed().subscribe((data) => {
|
|
4509
|
+
if (!data) {
|
|
4510
|
+
return;
|
|
4511
|
+
}
|
|
4512
|
+
this._dashboard.duplicate(itemIndex, data.name, data.icon);
|
|
4513
|
+
});
|
|
4514
|
+
}
|
|
4515
|
+
drop(event) {
|
|
4516
|
+
this._dashboard.dashboards.update((dashboards) => {
|
|
4517
|
+
const updatedDashboards = [...dashboards];
|
|
4518
|
+
moveItemInArray(updatedDashboards, event.previousIndex, event.currentIndex);
|
|
4519
|
+
const currentActive = this._dashboard.activeDashboard();
|
|
4520
|
+
if (currentActive === event.previousIndex) {
|
|
4521
|
+
this._dashboard.activeDashboard.set(event.currentIndex);
|
|
4522
|
+
} else if (currentActive > event.previousIndex && currentActive <= event.currentIndex) {
|
|
4523
|
+
this._dashboard.activeDashboard.set(currentActive - 1);
|
|
4524
|
+
} else if (currentActive < event.previousIndex && currentActive >= event.currentIndex) {
|
|
4525
|
+
this._dashboard.activeDashboard.set(currentActive + 1);
|
|
4526
|
+
}
|
|
4527
|
+
return updatedDashboards;
|
|
4528
|
+
});
|
|
4529
|
+
}
|
|
4530
|
+
dragStart() {
|
|
4531
|
+
if (this._sheetOpen || this.suppressDrag)
|
|
4532
|
+
return;
|
|
4533
|
+
this._uiEvent.isDragging.set(true);
|
|
4534
|
+
this._dragActive = true;
|
|
4535
|
+
this._dragMoved = false;
|
|
4536
|
+
}
|
|
4537
|
+
dragEnd() {
|
|
4538
|
+
this._uiEvent.isDragging.set(false);
|
|
4539
|
+
this._dragActive = false;
|
|
4540
|
+
setTimeout(() => {
|
|
4541
|
+
this._dragMoved = false;
|
|
4542
|
+
}, 60);
|
|
4543
|
+
}
|
|
4544
|
+
onDragMoved(ev) {
|
|
4545
|
+
if (!this._dragActive || this._dragMoved)
|
|
4546
|
+
return;
|
|
4547
|
+
const dist = Math.hypot(ev.distance.x, ev.distance.y);
|
|
4548
|
+
if (dist > this._dragSuppressThresholdPx) {
|
|
4549
|
+
this._dragMoved = true;
|
|
4550
|
+
}
|
|
4551
|
+
}
|
|
4552
|
+
onPress(index, e) {
|
|
4553
|
+
e.preventDefault();
|
|
4554
|
+
e.stopPropagation();
|
|
4555
|
+
if (this._dragMoved)
|
|
4556
|
+
return;
|
|
4557
|
+
this.cancelPointerSequence();
|
|
4558
|
+
this.openBottomSheet(index);
|
|
4559
|
+
}
|
|
4560
|
+
cancelPointerSequence() {
|
|
4561
|
+
this.suppressDrag = true;
|
|
4562
|
+
this._dragActive = false;
|
|
4563
|
+
this._dragMoved = false;
|
|
4564
|
+
["pointerup", "mouseup", "touchend"].forEach((type) => {
|
|
4565
|
+
document.dispatchEvent(new Event(type, { bubbles: true }));
|
|
4566
|
+
});
|
|
4567
|
+
}
|
|
4568
|
+
_onPointerRelease() {
|
|
4569
|
+
if (!this._sheetOpen) {
|
|
4570
|
+
this.suppressDrag = false;
|
|
4571
|
+
}
|
|
4572
|
+
}
|
|
4573
|
+
static \u0275fac = function DashboardsEditorComponent_Factory(__ngFactoryType__) {
|
|
4574
|
+
return new (__ngFactoryType__ || _DashboardsEditorComponent)();
|
|
4575
|
+
};
|
|
4576
|
+
static \u0275cmp = /* @__PURE__ */ \u0275\u0275defineComponent({ type: _DashboardsEditorComponent, selectors: [["dashboards-editor"]], hostBindings: function DashboardsEditorComponent_HostBindings(rf, ctx) {
|
|
4577
|
+
if (rf & 1) {
|
|
4578
|
+
\u0275\u0275listener("mouseup", function DashboardsEditorComponent_mouseup_HostBindingHandler() {
|
|
4579
|
+
return ctx._onPointerRelease();
|
|
4580
|
+
}, \u0275\u0275resolveDocument)("touchend", function DashboardsEditorComponent_touchend_HostBindingHandler() {
|
|
4581
|
+
return ctx._onPointerRelease();
|
|
4582
|
+
}, \u0275\u0275resolveDocument);
|
|
4583
|
+
}
|
|
4584
|
+
}, decls: 10, vars: 0, consts: [["cdkDropList", "", "cdkDropListOrientation", "mixed", 1, "dashboard-manage", 3, "cdkDropListDropped"], ["kipGestures", "", "matRipple", "", "cdkDrag", "", "cdkDragBoundary", ".dashboard-manage", 1, "dashboard-card", "dashboard-item", 3, "cdkDragDisabled"], [1, "dashboard-card", "dashboard-item-add", "dashboard-add-btn"], ["mat-fab", "", 3, "click"], [2, "margin-top", "10px"], ["kipGestures", "", "matRipple", "", "cdkDrag", "", "cdkDragBoundary", ".dashboard-manage", 1, "dashboard-card", "dashboard-item", 3, "cdkDragStarted", "cdkDragMoved", "cdkDragEnded", "press", "doubletap", "cdkDragDisabled"], [1, "item-index"], ["aria-hidden", "false", 1, "dashboard-icon", 3, "svgIcon"], [1, "dashboard-name"]], template: function DashboardsEditorComponent_Template(rf, ctx) {
|
|
4585
|
+
if (rf & 1) {
|
|
4586
|
+
\u0275\u0275elementStart(0, "div", 0);
|
|
4587
|
+
\u0275\u0275listener("cdkDropListDropped", function DashboardsEditorComponent_Template_div_cdkDropListDropped_0_listener($event) {
|
|
4588
|
+
return ctx.drop($event);
|
|
4589
|
+
});
|
|
4590
|
+
\u0275\u0275repeaterCreate(1, DashboardsEditorComponent_For_2_Template, 7, 8, "div", 1, _forTrack0);
|
|
4591
|
+
\u0275\u0275elementStart(3, "div", 2)(4, "button", 3);
|
|
4592
|
+
\u0275\u0275listener("click", function DashboardsEditorComponent_Template_button_click_4_listener() {
|
|
4593
|
+
return ctx.addDashboard();
|
|
4594
|
+
});
|
|
4595
|
+
\u0275\u0275elementStart(5, "mat-icon");
|
|
4596
|
+
\u0275\u0275text(6, "add_box");
|
|
4597
|
+
\u0275\u0275elementEnd()();
|
|
4598
|
+
\u0275\u0275elementStart(7, "p", 4)(8, "i");
|
|
4599
|
+
\u0275\u0275text(9, "Add Dashboard");
|
|
4600
|
+
\u0275\u0275elementEnd()()()();
|
|
4601
|
+
}
|
|
4602
|
+
if (rf & 2) {
|
|
4603
|
+
\u0275\u0275advance();
|
|
4604
|
+
\u0275\u0275repeater(ctx._dashboard.dashboards());
|
|
4605
|
+
}
|
|
4606
|
+
}, dependencies: [MatBottomSheetModule, MatButtonModule, MatFabButton, MatIconModule, MatIcon, CdkDropList, CdkDrag, MatRippleModule, MatRipple, GestureDirective], styles: ["\n\n[_nghost-%COMP%] {\n display: block;\n width: 100%;\n height: 100%;\n overflow-y: auto;\n scroll-behavior: smooth;\n}\n.dashboard-manage[_ngcontent-%COMP%] {\n box-sizing: border-box;\n padding: 0px 60px;\n width: 100%;\n height: 100%;\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n justify-content: space-around;\n overflow-y: auto;\n scroll-behavior: smooth;\n}\n.dashboard-card[_ngcontent-%COMP%] {\n position: relative;\n height: 200px;\n width: 300px;\n margin: 10px;\n border-radius: 15px;\n padding: 10px;\n align-content: center;\n text-align: center;\n border: 2px solid transparent;\n}\n.dashboard-item[_ngcontent-%COMP%] {\n background-color: var(--mat-sys-surface-container-highest);\n}\n.dashboard-item[_ngcontent-%COMP%]:hover {\n border: 2px solid var(--mat-sys-outline);\n cursor: pointer;\n}\n.dashboard-item-add[_ngcontent-%COMP%] {\n background-color: var(--mat-sys-surface-container);\n border: 1px solid var(--mat-sys-surface-container-highest);\n}\n.dashboard-add-btn[_ngcontent-%COMP%] {\n align-content: center;\n text-align: center;\n border: dashed 1px var(--mat-sys-outline);\n}\n.item-index[_ngcontent-%COMP%] {\n position: absolute;\n top: 20px;\n left: 20px;\n display: inline-flex;\n flex-wrap: wrap;\n height: 42px;\n width: 42px;\n background-color: var(--mat-sys-tertiary-fixed);\n color: var(--mat-sys-surface-bright);\n border-radius: 50%;\n align-content: center;\n align-items: center;\n justify-content: center;\n font-weight: bold;\n font-size: 1.25em;\n z-index: 1;\n}\n.dashboard-icon[_ngcontent-%COMP%] {\n opacity: 0.5;\n}\n.dashboard-name[_ngcontent-%COMP%] {\n margin-top: 10px;\n margin-bottom: 0;\n font-size: 1.1em;\n}\n.cdk-drag-preview[_ngcontent-%COMP%] {\n box-sizing: border-box;\n border-radius: 4px;\n box-shadow:\n 0 5px 5px -3px var(--mat-sys-on-primary-container),\n 0 8px 10px 1px var(--mat-sys-on-primary-container),\n 0 3px 14px 2px var(--mat-sys-on-primary-container);\n}\n.cdk-drag-placeholder[_ngcontent-%COMP%] {\n opacity: 0;\n}\n.cdk-drag-animating[_ngcontent-%COMP%] {\n transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);\n}\n/*# sourceMappingURL=dashboards-editor.component.css.map */"] });
|
|
4607
|
+
};
|
|
4608
|
+
(() => {
|
|
4609
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(DashboardsEditorComponent, [{
|
|
4610
|
+
type: Component,
|
|
4611
|
+
args: [{ selector: "dashboards-editor", standalone: true, imports: [MatBottomSheetModule, MatButtonModule, MatIconModule, CdkDropList, CdkDrag, MatRippleModule, GestureDirective], template: `<div class="dashboard-manage" cdkDropList cdkDropListOrientation="mixed" (cdkDropListDropped)="drop($event)">
|
|
4612
|
+
@for (dashboard of _dashboard.dashboards(); track dashboard.id; let index = $index) {
|
|
4613
|
+
<div class="dashboard-card dashboard-item"
|
|
4614
|
+
kipGestures
|
|
4615
|
+
matRipple
|
|
4616
|
+
cdkDrag
|
|
4617
|
+
[cdkDragDisabled]="_sheetOpen || suppressDrag"
|
|
4618
|
+
cdkDragBoundary=".dashboard-manage"
|
|
4619
|
+
(cdkDragStarted)="dragStart()" (cdkDragMoved)="onDragMoved($event)" (cdkDragEnded)="dragEnd()"
|
|
4620
|
+
(press)="onPress(index, $event)"
|
|
4621
|
+
(doubletap)="editDashboard(index)">
|
|
4622
|
+
<div class="item-index">{{index + 1}}</div>
|
|
4623
|
+
<div >
|
|
4624
|
+
<mat-icon class="dashboard-icon"
|
|
4625
|
+
[svgIcon]="dashboard.icon || 'dashboard'"
|
|
4626
|
+
[style.width.px]="72"
|
|
4627
|
+
[style.height.px]="72"
|
|
4628
|
+
aria-hidden="false"
|
|
4629
|
+
></mat-icon>
|
|
4630
|
+
</div>
|
|
4631
|
+
<p class="dashboard-name">{{dashboard.name}}</p>
|
|
4632
|
+
</div>
|
|
4633
|
+
}
|
|
4634
|
+
<div class="dashboard-card dashboard-item-add dashboard-add-btn">
|
|
4635
|
+
<button mat-fab (click)="addDashboard()">
|
|
4636
|
+
<mat-icon>add_box</mat-icon>
|
|
4637
|
+
</button>
|
|
4638
|
+
<p style="margin-top: 10px;"><i>Add Dashboard</i></p>
|
|
4639
|
+
</div>
|
|
4640
|
+
</div>
|
|
4641
|
+
`, styles: ["/* src/app/core/components/dashboards-editor/dashboards-editor.component.scss */\n:host {\n display: block;\n width: 100%;\n height: 100%;\n overflow-y: auto;\n scroll-behavior: smooth;\n}\n.dashboard-manage {\n box-sizing: border-box;\n padding: 0px 60px;\n width: 100%;\n height: 100%;\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n justify-content: space-around;\n overflow-y: auto;\n scroll-behavior: smooth;\n}\n.dashboard-card {\n position: relative;\n height: 200px;\n width: 300px;\n margin: 10px;\n border-radius: 15px;\n padding: 10px;\n align-content: center;\n text-align: center;\n border: 2px solid transparent;\n}\n.dashboard-item {\n background-color: var(--mat-sys-surface-container-highest);\n}\n.dashboard-item:hover {\n border: 2px solid var(--mat-sys-outline);\n cursor: pointer;\n}\n.dashboard-item-add {\n background-color: var(--mat-sys-surface-container);\n border: 1px solid var(--mat-sys-surface-container-highest);\n}\n.dashboard-add-btn {\n align-content: center;\n text-align: center;\n border: dashed 1px var(--mat-sys-outline);\n}\n.item-index {\n position: absolute;\n top: 20px;\n left: 20px;\n display: inline-flex;\n flex-wrap: wrap;\n height: 42px;\n width: 42px;\n background-color: var(--mat-sys-tertiary-fixed);\n color: var(--mat-sys-surface-bright);\n border-radius: 50%;\n align-content: center;\n align-items: center;\n justify-content: center;\n font-weight: bold;\n font-size: 1.25em;\n z-index: 1;\n}\n.dashboard-icon {\n opacity: 0.5;\n}\n.dashboard-name {\n margin-top: 10px;\n margin-bottom: 0;\n font-size: 1.1em;\n}\n.cdk-drag-preview {\n box-sizing: border-box;\n border-radius: 4px;\n box-shadow:\n 0 5px 5px -3px var(--mat-sys-on-primary-container),\n 0 8px 10px 1px var(--mat-sys-on-primary-container),\n 0 3px 14px 2px var(--mat-sys-on-primary-container);\n}\n.cdk-drag-placeholder {\n opacity: 0;\n}\n.cdk-drag-animating {\n transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);\n}\n/*# sourceMappingURL=dashboards-editor.component.css.map */\n"] }]
|
|
4642
|
+
}], null, { _onPointerRelease: [{
|
|
4643
|
+
type: HostListener,
|
|
4644
|
+
args: ["document:mouseup"]
|
|
4645
|
+
}, {
|
|
4646
|
+
type: HostListener,
|
|
4647
|
+
args: ["document:touchend"]
|
|
4648
|
+
}] });
|
|
4649
|
+
})();
|
|
4650
|
+
(() => {
|
|
4651
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && \u0275setClassDebugInfo(DashboardsEditorComponent, { className: "DashboardsEditorComponent", filePath: "src/app/core/components/dashboards-editor/dashboards-editor.component.ts", lineNumber: 22 });
|
|
4652
|
+
})();
|
|
4653
|
+
|
|
4654
|
+
// src/app/core/components/home/home.component.ts
|
|
4655
|
+
var HomeComponent = class _HomeComponent {
|
|
4656
|
+
_router = inject(Router);
|
|
4657
|
+
app = inject(AppService);
|
|
4658
|
+
_responsive = inject(BreakpointObserver);
|
|
4659
|
+
_isPhonePortrait = toSignal(this._responsive.observe(Breakpoints.HandsetPortrait));
|
|
4660
|
+
_isPhoneLandscape = toSignal(this._responsive.observe(Breakpoints.HandsetLandscape));
|
|
4661
|
+
isPhonePortrait = computed(() => this._isPhonePortrait().matches, ...ngDevMode ? [{ debugName: "isPhonePortrait" }] : []);
|
|
4662
|
+
isPhoneLandscape = computed(() => this._isPhoneLandscape().matches, ...ngDevMode ? [{ debugName: "isPhoneLandscape" }] : []);
|
|
4663
|
+
closePage() {
|
|
4664
|
+
this._router.navigate(["/dashboard"]);
|
|
4665
|
+
}
|
|
4666
|
+
onActionItem(action) {
|
|
4667
|
+
switch (action) {
|
|
4668
|
+
case "help":
|
|
4669
|
+
this._router.navigate(["/help"]);
|
|
4670
|
+
break;
|
|
4671
|
+
case "datainspector":
|
|
4672
|
+
this._router.navigate(["/data"]);
|
|
4673
|
+
break;
|
|
4674
|
+
case "datasets":
|
|
4675
|
+
this._router.navigate(["/datasets"]);
|
|
4676
|
+
break;
|
|
4677
|
+
case "settings":
|
|
4678
|
+
this._router.navigate(["/settings"]);
|
|
4679
|
+
break;
|
|
4680
|
+
default:
|
|
4681
|
+
break;
|
|
4682
|
+
}
|
|
4683
|
+
}
|
|
4684
|
+
static \u0275fac = function HomeComponent_Factory(__ngFactoryType__) {
|
|
4685
|
+
return new (__ngFactoryType__ || _HomeComponent)();
|
|
4686
|
+
};
|
|
4687
|
+
static \u0275cmp = /* @__PURE__ */ \u0275\u0275defineComponent({ type: _HomeComponent, selectors: [["home"]], decls: 10, vars: 15, consts: [[1, "home-container"], [1, "actions-header-container"], [1, "actions-buttons-container"], ["tabindex", "0", "svgIcon", "settings", "label", "Settings", 3, "click", "iconOnly", "compact", "iconSize"], ["tabindex", "0", "svgIcon", "troubleshoot", "label", "Data Inspector", 3, "click", "iconOnly", "compact", "iconSize"], ["tabindex", "0", "svgIcon", "help-center", "label", "Help", 3, "click", "iconOnly", "compact", "iconSize"], ["mat-icon-button", "", 1, "dialog-close-icon", 3, "click"], [1, "dashboards-editor"]], template: function HomeComponent_Template(rf, ctx) {
|
|
4688
|
+
if (rf & 1) {
|
|
4689
|
+
\u0275\u0275elementStart(0, "div", 0)(1, "div", 1)(2, "div", 2)(3, "tile-large-icon", 3);
|
|
4690
|
+
\u0275\u0275listener("click", function HomeComponent_Template_tile_large_icon_click_3_listener() {
|
|
4691
|
+
return ctx.onActionItem("settings");
|
|
4692
|
+
});
|
|
4693
|
+
\u0275\u0275elementEnd();
|
|
4694
|
+
\u0275\u0275elementStart(4, "tile-large-icon", 4);
|
|
4695
|
+
\u0275\u0275listener("click", function HomeComponent_Template_tile_large_icon_click_4_listener() {
|
|
4696
|
+
return ctx.onActionItem("datainspector");
|
|
4697
|
+
});
|
|
4698
|
+
\u0275\u0275elementEnd();
|
|
4699
|
+
\u0275\u0275elementStart(5, "tile-large-icon", 5);
|
|
4700
|
+
\u0275\u0275listener("click", function HomeComponent_Template_tile_large_icon_click_5_listener() {
|
|
4701
|
+
return ctx.onActionItem("help");
|
|
4702
|
+
});
|
|
4703
|
+
\u0275\u0275elementEnd()();
|
|
4704
|
+
\u0275\u0275elementStart(6, "button", 6);
|
|
4705
|
+
\u0275\u0275listener("click", function HomeComponent_Template_button_click_6_listener() {
|
|
4706
|
+
return ctx.closePage();
|
|
4707
|
+
});
|
|
4708
|
+
\u0275\u0275elementStart(7, "mat-icon");
|
|
4709
|
+
\u0275\u0275text(8, "close");
|
|
4710
|
+
\u0275\u0275elementEnd()()();
|
|
4711
|
+
\u0275\u0275element(9, "dashboards-editor", 7);
|
|
4712
|
+
\u0275\u0275elementEnd();
|
|
4713
|
+
}
|
|
4714
|
+
if (rf & 2) {
|
|
4715
|
+
\u0275\u0275advance(3);
|
|
4716
|
+
\u0275\u0275classMap(`${ctx.isPhoneLandscape() ? "no-label" : "with-label"}`);
|
|
4717
|
+
\u0275\u0275property("iconOnly", ctx.isPhoneLandscape())("compact", true)("iconSize", 48);
|
|
4718
|
+
\u0275\u0275advance();
|
|
4719
|
+
\u0275\u0275classMap(`${ctx.isPhoneLandscape() ? "no-label" : "with-label"}`);
|
|
4720
|
+
\u0275\u0275property("iconOnly", ctx.isPhoneLandscape())("compact", true)("iconSize", 48);
|
|
4721
|
+
\u0275\u0275advance();
|
|
4722
|
+
\u0275\u0275classMap(`${ctx.isPhoneLandscape() ? "no-label" : "with-label"}`);
|
|
4723
|
+
\u0275\u0275property("iconOnly", ctx.isPhoneLandscape())("compact", true)("iconSize", 48);
|
|
4724
|
+
}
|
|
4725
|
+
}, dependencies: [MatIconModule, MatIcon, MatButtonModule, MatIconButton, TileLargeIconComponent, MatDividerModule, DashboardsEditorComponent], styles: ["\n\n[_nghost-%COMP%] {\n display: block;\n width: 100%;\n height: 100%;\n}\n.home-container[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n.actions-header-container[_ngcontent-%COMP%] {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n width: 100%;\n padding: 5px 0px 5px 10px;\n}\n.with-label[_ngcontent-%COMP%] {\n height: 80px;\n width: 90px;\n}\n.no-label[_ngcontent-%COMP%] {\n height: 58px;\n width: 63px;\n}\n.dashboard-editor[_ngcontent-%COMP%] {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n}\n.actions-buttons-container[_ngcontent-%COMP%] {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n gap: 5px;\n}\n.dialog-close-icon[_ngcontent-%COMP%] {\n margin-right: 15px;\n margin-top: 6px;\n}\n.mat-mdc-dialog-content[_ngcontent-%COMP%] {\n max-height: max-content;\n}\n/*# sourceMappingURL=home.component.css.map */"] });
|
|
4726
|
+
};
|
|
4727
|
+
(() => {
|
|
4728
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && setClassMetadata(HomeComponent, [{
|
|
4729
|
+
type: Component,
|
|
4730
|
+
args: [{ selector: "home", imports: [MatIconModule, MatButtonModule, TileLargeIconComponent, MatDividerModule, DashboardsEditorComponent, DashboardsEditorComponent], template: `<div class="home-container">
|
|
4731
|
+
<div class="actions-header-container">
|
|
4732
|
+
<div class="actions-buttons-container">
|
|
4733
|
+
<tile-large-icon [class]="\`\${isPhoneLandscape() ? 'no-label' : 'with-label'}\`" tabindex="0" [iconOnly]="isPhoneLandscape()" [compact]="true" svgIcon="settings" [iconSize]="48" label="Settings" (click)="onActionItem('settings')"/>
|
|
4734
|
+
<tile-large-icon [class]="\`\${isPhoneLandscape() ? 'no-label' : 'with-label'}\`" tabindex="0" [iconOnly]="isPhoneLandscape()" [compact]="true" svgIcon="troubleshoot" [iconSize]="48" label="Data Inspector" (click)="onActionItem('datainspector')"/>
|
|
4735
|
+
<tile-large-icon [class]="\`\${isPhoneLandscape() ? 'no-label' : 'with-label'}\`" tabindex="0" [iconOnly]="isPhoneLandscape()" [compact]="true" svgIcon="help-center" [iconSize]="48" label="Help" (click)="onActionItem('help')"/>
|
|
4736
|
+
</div>
|
|
4737
|
+
<button mat-icon-button class="dialog-close-icon" (click)="closePage()">
|
|
4738
|
+
<mat-icon>close</mat-icon>
|
|
4739
|
+
</button>
|
|
4740
|
+
</div>
|
|
4741
|
+
<dashboards-editor class="dashboards-editor" />
|
|
4742
|
+
</div>
|
|
4743
|
+
`, styles: ["/* src/app/core/components/home/home.component.scss */\n:host {\n display: block;\n width: 100%;\n height: 100%;\n}\n.home-container {\n display: flex;\n flex-direction: column;\n height: 100%;\n}\n.actions-header-container {\n display: flex;\n justify-content: space-between;\n align-items: flex-start;\n width: 100%;\n padding: 5px 0px 5px 10px;\n}\n.with-label {\n height: 80px;\n width: 90px;\n}\n.no-label {\n height: 58px;\n width: 63px;\n}\n.dashboard-editor {\n flex: 1 1 auto;\n min-height: 0;\n overflow: auto;\n}\n.actions-buttons-container {\n display: flex;\n flex-direction: row;\n flex-wrap: nowrap;\n gap: 5px;\n}\n.dialog-close-icon {\n margin-right: 15px;\n margin-top: 6px;\n}\n.mat-mdc-dialog-content {\n max-height: max-content;\n}\n/*# sourceMappingURL=home.component.css.map */\n"] }]
|
|
4744
|
+
}], null, null);
|
|
4745
|
+
})();
|
|
4746
|
+
(() => {
|
|
4747
|
+
(typeof ngDevMode === "undefined" || ngDevMode) && \u0275setClassDebugInfo(HomeComponent, { className: "HomeComponent", filePath: "src/app/core/components/home/home.component.ts", lineNumber: 18 });
|
|
4748
|
+
})();
|
|
4749
|
+
export {
|
|
4750
|
+
HomeComponent
|
|
4751
|
+
};
|
|
4752
|
+
//# sourceMappingURL=chunk-UHVNAEXC.js.map
|