@acorex/cdk 19.13.4 → 19.13.5
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/drag-drop/lib/drag.directive.d.ts +22 -6
- package/drawer/lib/drawer-item.directive.d.ts +4 -2
- package/fesm2022/acorex-cdk-carousel.mjs +3 -3
- package/fesm2022/acorex-cdk-carousel.mjs.map +1 -1
- package/fesm2022/acorex-cdk-collapse.mjs +19 -19
- package/fesm2022/acorex-cdk-collapse.mjs.map +1 -1
- package/fesm2022/acorex-cdk-dom.mjs +3 -3
- package/fesm2022/acorex-cdk-dom.mjs.map +1 -1
- package/fesm2022/acorex-cdk-drag-drop.mjs +301 -65
- package/fesm2022/acorex-cdk-drag-drop.mjs.map +1 -1
- package/fesm2022/acorex-cdk-drawer.mjs +35 -18
- package/fesm2022/acorex-cdk-drawer.mjs.map +1 -1
- package/fesm2022/acorex-cdk-focus-trap.mjs +3 -3
- package/fesm2022/acorex-cdk-focus-trap.mjs.map +1 -1
- package/fesm2022/acorex-cdk-list-navigation.mjs +10 -10
- package/fesm2022/acorex-cdk-list-navigation.mjs.map +1 -1
- package/fesm2022/acorex-cdk-outline.mjs +10 -10
- package/fesm2022/acorex-cdk-outline.mjs.map +1 -1
- package/fesm2022/acorex-cdk-overlay.mjs +3 -3
- package/fesm2022/acorex-cdk-overlay.mjs.map +1 -1
- package/fesm2022/acorex-cdk-pan-view.mjs +3 -3
- package/fesm2022/acorex-cdk-pan-view.mjs.map +1 -1
- package/fesm2022/acorex-cdk-resizable.mjs +3 -3
- package/fesm2022/acorex-cdk-resizable.mjs.map +1 -1
- package/fesm2022/acorex-cdk-selection.mjs +10 -10
- package/fesm2022/acorex-cdk-selection.mjs.map +1 -1
- package/fesm2022/acorex-cdk-sliding-item.mjs +7 -7
- package/fesm2022/acorex-cdk-sliding-item.mjs.map +1 -1
- package/fesm2022/acorex-cdk-sticky.mjs +3 -3
- package/fesm2022/acorex-cdk-sticky.mjs.map +1 -1
- package/fesm2022/acorex-cdk-virtual-scroll.mjs +10 -10
- package/fesm2022/acorex-cdk-virtual-scroll.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, signal, Directive, NgZone, contentChild, input, output, computed, effect, NgModule } from '@angular/core';
|
|
3
|
-
import { DOCUMENT } from '@angular/common';
|
|
2
|
+
import { inject, ElementRef, signal, Directive, NgZone, Renderer2, PLATFORM_ID, contentChild, input, output, computed, effect, RendererStyleFlags2, NgModule } from '@angular/core';
|
|
3
|
+
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
4
4
|
import { clamp } from 'lodash-es';
|
|
5
5
|
|
|
6
6
|
class AXDragHandleDirective {
|
|
@@ -8,10 +8,10 @@ class AXDragHandleDirective {
|
|
|
8
8
|
this.el = inject(ElementRef);
|
|
9
9
|
this.element = signal(this.el.nativeElement);
|
|
10
10
|
}
|
|
11
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
12
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.
|
|
11
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDragHandleDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
12
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.10", type: AXDragHandleDirective, isStandalone: true, selector: "[axDragHandle]", ngImport: i0 }); }
|
|
13
13
|
}
|
|
14
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
14
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDragHandleDirective, decorators: [{
|
|
15
15
|
type: Directive,
|
|
16
16
|
args: [{
|
|
17
17
|
selector: '[axDragHandle]',
|
|
@@ -22,20 +22,30 @@ class AXDragDirective {
|
|
|
22
22
|
constructor() {
|
|
23
23
|
this.zone = inject(NgZone);
|
|
24
24
|
this.document = inject(DOCUMENT);
|
|
25
|
+
this.renderer = inject(Renderer2);
|
|
26
|
+
this.platformId = inject(PLATFORM_ID);
|
|
25
27
|
this.el = inject(ElementRef);
|
|
26
28
|
this.handleDirective = contentChild(AXDragHandleDirective);
|
|
29
|
+
this.dragData = input();
|
|
27
30
|
this.dragDisabled = input(false);
|
|
31
|
+
this.dragElementClone = input(false);
|
|
28
32
|
this.dropZoneGroup = input();
|
|
29
33
|
this.dragStartDelay = input();
|
|
30
34
|
this.dragResetOnDblClick = input(true);
|
|
31
35
|
this.dragLockAxis = input(null);
|
|
36
|
+
this.dragCursor = input('move');
|
|
32
37
|
this.dragBoundary = input();
|
|
33
38
|
this.dragPositionChanged = output();
|
|
34
|
-
this.isDragging = signal(false);
|
|
35
39
|
this.currentAxis = signal({ x: 0, y: 0 });
|
|
40
|
+
this.currentCloneAxis = signal({ x: 0, y: 0 });
|
|
41
|
+
this.clonedElement = signal(null);
|
|
42
|
+
this.element = signal(this.el.nativeElement);
|
|
43
|
+
this.elementOpacity = signal('1');
|
|
44
|
+
this.isMoving = signal(false);
|
|
45
|
+
this.isDragging = signal(false);
|
|
36
46
|
this.isDelayStarted = signal(false);
|
|
37
47
|
this.dragStartOffset = signal({ x: 0, y: 0 });
|
|
38
|
-
this.
|
|
48
|
+
this.clonePointerOffset = signal({ x: 0, y: 0 });
|
|
39
49
|
this.prevDropZone = signal(null);
|
|
40
50
|
this.boundaryElement = computed(() => {
|
|
41
51
|
const boundary = this.dragBoundary();
|
|
@@ -47,40 +57,75 @@ class AXDragDirective {
|
|
|
47
57
|
}
|
|
48
58
|
return boundary instanceof ElementRef ? boundary.nativeElement : boundary;
|
|
49
59
|
});
|
|
50
|
-
this.elementRect = computed(() =>
|
|
60
|
+
this.elementRect = computed(() => {
|
|
61
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
62
|
+
return null; // Or some default/mock DOMRect-like object if needed for type safety
|
|
63
|
+
}
|
|
64
|
+
return this.element().getBoundingClientRect();
|
|
65
|
+
});
|
|
66
|
+
this.boundaryRect = computed(() => {
|
|
67
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return this.boundaryElement()?.getBoundingClientRect();
|
|
71
|
+
});
|
|
51
72
|
this.handle = computed(() => this.handleDirective()?.element() ?? this.element());
|
|
52
|
-
this.boundaryRect = computed(() => this.boundaryElement()?.getBoundingClientRect());
|
|
53
73
|
this.boundHandleDblClick = this.handleDblClick.bind(this);
|
|
54
74
|
this.boundHandlePointerUp = this.handlePointerUp.bind(this);
|
|
55
75
|
this.boundHandlePointerDown = this.handlePointerDown.bind(this);
|
|
56
76
|
this.boundHandlePointerMove = this.handlePointerMove.bind(this);
|
|
57
|
-
effect(() => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
77
|
+
this.#dragDisabledEffect = effect(() => {
|
|
78
|
+
if (this.dragCursor() === 'none') {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (!this.dragDisabled()) {
|
|
82
|
+
this.renderer.setStyle(this.handle(), 'cursor', this.dragCursor());
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
this.renderer.removeStyle(this.handle(), 'cursor');
|
|
86
|
+
}
|
|
61
87
|
});
|
|
62
88
|
}
|
|
89
|
+
#dragDisabledEffect;
|
|
63
90
|
ngOnInit() {
|
|
64
|
-
this.
|
|
65
|
-
this.
|
|
66
|
-
|
|
67
|
-
|
|
91
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
92
|
+
this.zone.runOutsideAngular(() => {
|
|
93
|
+
this.handle().addEventListener('dblclick', this.boundHandleDblClick);
|
|
94
|
+
this.handle().addEventListener('pointerdown', this.boundHandlePointerDown);
|
|
95
|
+
});
|
|
96
|
+
this.renderer.setStyle(this.element(), 'z-index', '1');
|
|
97
|
+
this.elementOpacity.set(getComputedStyle(this.element()).opacity);
|
|
98
|
+
}
|
|
68
99
|
}
|
|
69
100
|
ngOnDestroy() {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
101
|
+
if (isPlatformBrowser(this.platformId)) {
|
|
102
|
+
this.handle().removeEventListener('dblclick', this.boundHandleDblClick);
|
|
103
|
+
this.handle().removeEventListener('pointerdown', this.boundHandlePointerDown);
|
|
104
|
+
this.removeDocumentListeners();
|
|
105
|
+
if (this.dragElementClone()) {
|
|
106
|
+
this.removeCloneElement();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
73
109
|
}
|
|
74
110
|
handlePointerDown(e) {
|
|
111
|
+
if (!isPlatformBrowser(this.platformId))
|
|
112
|
+
return;
|
|
75
113
|
if (this.dragDisabled() || e.button !== 0)
|
|
76
114
|
return;
|
|
77
|
-
this.
|
|
115
|
+
switch (this.dragCursor()) {
|
|
116
|
+
case 'move':
|
|
117
|
+
this.renderer.setStyle(this.element(), 'cursor', 'move');
|
|
118
|
+
break;
|
|
119
|
+
case 'grab':
|
|
120
|
+
this.renderer.setStyle(this.element(), 'cursor', 'grabbing');
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
78
123
|
e.preventDefault();
|
|
79
124
|
e.stopPropagation();
|
|
80
125
|
this.isDragging.set(true);
|
|
81
126
|
this.dragStartOffset.set({ x: e.clientX - this.currentAxis().x, y: e.clientY - this.currentAxis().y });
|
|
82
|
-
this.element()
|
|
83
|
-
this.element()
|
|
127
|
+
this.renderer.setStyle(this.element(), 'userSelect', 'none');
|
|
128
|
+
this.renderer.setStyle(this.element(), 'touchAction', 'none');
|
|
84
129
|
this.element().setPointerCapture(e.pointerId);
|
|
85
130
|
this.addDocumentListeners();
|
|
86
131
|
if (this.dragStartDelay()) {
|
|
@@ -90,19 +135,40 @@ class AXDragDirective {
|
|
|
90
135
|
}, this.dragStartDelay());
|
|
91
136
|
}
|
|
92
137
|
this.dropZoneHoverHandler(e);
|
|
138
|
+
if (this.dragElementClone()) {
|
|
139
|
+
const elementRect = this.element().getBoundingClientRect();
|
|
140
|
+
this.clonePointerOffset.set({
|
|
141
|
+
x: e.clientX - elementRect.left,
|
|
142
|
+
y: e.clientY - elementRect.top,
|
|
143
|
+
});
|
|
144
|
+
this.createCloneElement(this.element());
|
|
145
|
+
}
|
|
93
146
|
}
|
|
94
147
|
handlePointerUp(e) {
|
|
95
|
-
if (!this.
|
|
148
|
+
if (!isPlatformBrowser(this.platformId))
|
|
149
|
+
return;
|
|
150
|
+
if (!this.isDragging()) {
|
|
96
151
|
return;
|
|
97
|
-
|
|
98
|
-
|
|
152
|
+
}
|
|
153
|
+
if (this.handleDirective()) {
|
|
154
|
+
this.renderer.removeStyle(this.element(), 'cursor');
|
|
155
|
+
}
|
|
156
|
+
if (this.dragCursor() === 'grab') {
|
|
157
|
+
this.renderer.setStyle(this.element(), 'cursor', 'grab');
|
|
158
|
+
}
|
|
99
159
|
this.isDragging.set(false);
|
|
100
|
-
this.element()
|
|
101
|
-
this.element()
|
|
160
|
+
this.renderer.removeStyle(this.element(), 'userSelect');
|
|
161
|
+
this.renderer.removeStyle(this.element(), 'touchAction');
|
|
102
162
|
this.element().releasePointerCapture(e.pointerId);
|
|
103
163
|
this.removeDocumentListeners();
|
|
104
|
-
this.
|
|
105
|
-
|
|
164
|
+
if (this.isMoving()) {
|
|
165
|
+
this.preventClicking();
|
|
166
|
+
this.isMoving.set(false);
|
|
167
|
+
this.dropZoneDropHandler(e);
|
|
168
|
+
}
|
|
169
|
+
if (this.dragElementClone()) {
|
|
170
|
+
this.removeCloneElement();
|
|
171
|
+
}
|
|
106
172
|
}
|
|
107
173
|
/**
|
|
108
174
|
* Prevent click events immediately following pointerup, especially on touch devices
|
|
@@ -122,6 +188,8 @@ class AXDragDirective {
|
|
|
122
188
|
this.setPosition(0, 0);
|
|
123
189
|
}
|
|
124
190
|
handlePointerMove(e) {
|
|
191
|
+
if (!isPlatformBrowser(this.platformId))
|
|
192
|
+
return;
|
|
125
193
|
if (!this.isDragging())
|
|
126
194
|
return;
|
|
127
195
|
if (this.isDelayStarted()) {
|
|
@@ -129,9 +197,17 @@ class AXDragDirective {
|
|
|
129
197
|
return;
|
|
130
198
|
}
|
|
131
199
|
e.preventDefault();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
200
|
+
this.isMoving.set(true);
|
|
201
|
+
if (this.dragElementClone()) {
|
|
202
|
+
const newCloneX = e.clientX - this.clonePointerOffset().x;
|
|
203
|
+
const newCloneY = e.clientY - this.clonePointerOffset().y;
|
|
204
|
+
this.setClonePosition(newCloneX, newCloneY);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
const newX = e.clientX - this.dragStartOffset().x;
|
|
208
|
+
const newY = e.clientY - this.dragStartOffset().y;
|
|
209
|
+
this.setPosition(newX, newY);
|
|
210
|
+
}
|
|
135
211
|
this.dropZoneHoverHandler(e);
|
|
136
212
|
}
|
|
137
213
|
dropZoneHoverHandler(e) {
|
|
@@ -140,27 +216,25 @@ class AXDragDirective {
|
|
|
140
216
|
this.leavePrevDropZone(e);
|
|
141
217
|
return;
|
|
142
218
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
219
|
+
const dropZone = dropZones[0];
|
|
220
|
+
if (!this.dropZoneValidation(dropZone, e) || dropZone.isHovered()) {
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (this.prevDropZone() && this.prevDropZone() !== dropZone) {
|
|
224
|
+
this.leavePrevDropZone(e);
|
|
225
|
+
}
|
|
226
|
+
this.prevDropZone.set(dropZone);
|
|
227
|
+
dropZone.onElementHover.emit({ sender: dropZone, dropped: this, nativeEvent: e, state: 'enter' });
|
|
228
|
+
dropZone.isHovered.set(true);
|
|
154
229
|
}
|
|
155
230
|
dropZoneDropHandler(e) {
|
|
156
231
|
const dropZones = this.getDropZonesFromPoint(e.clientX, e.clientY);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
232
|
+
const dropZone = dropZones[0];
|
|
233
|
+
if (!this.dropZoneValidation(dropZone, e)) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
dropZone.isHovered.set(false);
|
|
237
|
+
dropZone.onElementDrop.emit({ sender: dropZone, dropped: this, nativeEvent: e });
|
|
164
238
|
}
|
|
165
239
|
getDropZonesFromPoint(x, y) {
|
|
166
240
|
const elementsFromPoint = this.document.elementsFromPoint(x, y);
|
|
@@ -176,6 +250,10 @@ class AXDragDirective {
|
|
|
176
250
|
});
|
|
177
251
|
}
|
|
178
252
|
dropZoneValidation(dropZone, e) {
|
|
253
|
+
// There is a dropzone
|
|
254
|
+
if (!dropZone) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
179
257
|
// They are in the same group
|
|
180
258
|
const dragGroup = this.dropZoneGroup();
|
|
181
259
|
const dropGroup = dropZone.dropZoneGroup();
|
|
@@ -184,7 +262,7 @@ class AXDragDirective {
|
|
|
184
262
|
}
|
|
185
263
|
// Draggable element is under mouse
|
|
186
264
|
const elementsFromPoint = this.document.elementsFromPoint(e.clientX, e.clientY);
|
|
187
|
-
if (!elementsFromPoint.includes(this.element())) {
|
|
265
|
+
if (!elementsFromPoint.includes(this.element()) && !this.clonedElement()) {
|
|
188
266
|
return false;
|
|
189
267
|
}
|
|
190
268
|
return true;
|
|
@@ -201,8 +279,8 @@ class AXDragDirective {
|
|
|
201
279
|
setPosition(x, y) {
|
|
202
280
|
let constrainedX = x;
|
|
203
281
|
let constrainedY = y;
|
|
204
|
-
const boundaryRect = this.boundaryRect();
|
|
205
282
|
const elementRect = this.elementRect();
|
|
283
|
+
const boundaryRect = this.boundaryRect();
|
|
206
284
|
if (boundaryRect && elementRect) {
|
|
207
285
|
const minX = boundaryRect.left - elementRect.left;
|
|
208
286
|
const minY = boundaryRect.top - elementRect.top;
|
|
@@ -219,10 +297,166 @@ class AXDragDirective {
|
|
|
219
297
|
constrainedX = 0;
|
|
220
298
|
}
|
|
221
299
|
this.currentAxis.set({ x: constrainedX, y: constrainedY });
|
|
222
|
-
this.element()
|
|
300
|
+
this.renderer.setStyle(this.element(), 'translate', `${constrainedX}px ${constrainedY}px`);
|
|
223
301
|
this.dragPositionChanged.emit(this.currentAxis());
|
|
224
302
|
}
|
|
303
|
+
setClonePosition(x, y) {
|
|
304
|
+
let constrainedX = x;
|
|
305
|
+
let constrainedY = y;
|
|
306
|
+
const cloneEl = this.clonedElement();
|
|
307
|
+
const boundaryRect = this.boundaryElement()?.getBoundingClientRect();
|
|
308
|
+
if (boundaryRect && cloneEl) {
|
|
309
|
+
const cloneWidth = cloneEl.offsetWidth;
|
|
310
|
+
const cloneHeight = cloneEl.offsetHeight;
|
|
311
|
+
const minAllowedX = boundaryRect.left;
|
|
312
|
+
const maxAllowedX = boundaryRect.right - cloneWidth;
|
|
313
|
+
const minAllowedY = boundaryRect.top;
|
|
314
|
+
const maxAllowedY = boundaryRect.bottom - cloneHeight;
|
|
315
|
+
constrainedX = clamp(x, minAllowedX, maxAllowedX);
|
|
316
|
+
constrainedY = clamp(y, minAllowedY, maxAllowedY);
|
|
317
|
+
}
|
|
318
|
+
const lockAxis = this.dragLockAxis();
|
|
319
|
+
if (lockAxis === 'x') {
|
|
320
|
+
constrainedY = 0;
|
|
321
|
+
}
|
|
322
|
+
if (lockAxis === 'y') {
|
|
323
|
+
constrainedX = 0;
|
|
324
|
+
}
|
|
325
|
+
this.currentCloneAxis.set({ x: constrainedX, y: constrainedY });
|
|
326
|
+
this.renderer.setStyle(this.clonedElement(), 'translate', `${constrainedX}px ${constrainedY}px`);
|
|
327
|
+
this.dragPositionChanged.emit(this.currentCloneAxis());
|
|
328
|
+
}
|
|
329
|
+
createCloneElement(originalElement) {
|
|
330
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
331
|
+
this.clonedElement.set(null);
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
const clonedElement = originalElement.cloneNode(true);
|
|
335
|
+
const applyComputedStylesRecursive = (source, target) => {
|
|
336
|
+
if (!isPlatformBrowser(this.platformId))
|
|
337
|
+
return;
|
|
338
|
+
const computedStyles = window.getComputedStyle(source);
|
|
339
|
+
if (computedStyles.cssText && target.style.cssText !== undefined) {
|
|
340
|
+
// Check if cssText is supported and writable
|
|
341
|
+
// More efficient path if cssText is fully supported
|
|
342
|
+
let tempCssText = computedStyles.cssText;
|
|
343
|
+
// Remove problematic properties for the ROOT clone before assigning
|
|
344
|
+
if (target === clonedElement) {
|
|
345
|
+
tempCssText = tempCssText
|
|
346
|
+
.replace(/position:[^;]+;/gi, '')
|
|
347
|
+
.replace(/top:[^;]+;/gi, '')
|
|
348
|
+
.replace(/left:[^;]+;/gi, '')
|
|
349
|
+
.replace(/right:[^;]+;/gi, '')
|
|
350
|
+
.replace(/bottom:[^;]+;/gi, '')
|
|
351
|
+
.replace(/width:[^;]+;/gi, '')
|
|
352
|
+
.replace(/height:[^;]+;/gi, '')
|
|
353
|
+
.replace(/margin[^;]*:[^;]+;/gi, '')
|
|
354
|
+
.replace(/transform:[^;]+;/gi, '')
|
|
355
|
+
.replace(/translate:[^;]+;/gi, '')
|
|
356
|
+
.replace(/z-index:[^;]+;/gi, '')
|
|
357
|
+
.replace(/opacity:[^;]+;/gi, '');
|
|
358
|
+
}
|
|
359
|
+
// For ALL elements in the clone tree, ensure pointer-events is not copied from source,
|
|
360
|
+
// as the root clone will have 'pointer-events: none' and we want that to cascade.
|
|
361
|
+
tempCssText = tempCssText.replace(/pointer-events:[^;]+;/gi, '');
|
|
362
|
+
// Prepend existing inline styles (from cloneNode) to the computed styles.
|
|
363
|
+
// This gives inline styles higher precedence if there's a conflict not covered by the removals above.
|
|
364
|
+
// However, for most cases, we want computed styles to define the look.
|
|
365
|
+
// A safer bet might be to set properties individually or fully overwrite.
|
|
366
|
+
// For simplicity now, let's assume this ordering is acceptable or refine if needed.
|
|
367
|
+
// target.style.cssText = tempCssText + target.style.cssText;
|
|
368
|
+
// SAFER: Overwrite with computed, then re-apply critical ones.
|
|
369
|
+
target.style.cssText = tempCssText;
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
// Fallback for browsers where cssText is not reliable or for more granular control
|
|
373
|
+
for (let i = 0; i < computedStyles.length; i++) {
|
|
374
|
+
const propName = computedStyles[i];
|
|
375
|
+
// Universal exclusion:
|
|
376
|
+
// For ALL elements in the clone tree (root and children), we don't want to copy 'pointer-events'
|
|
377
|
+
// because the root clonedElement will have 'pointer-events: none' set later, and we want that to cascade.
|
|
378
|
+
if (propName === 'pointer-events') {
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
// Specific exclusions for the ROOT clone only, as these are set manually later.
|
|
382
|
+
if (target === clonedElement &&
|
|
383
|
+
(propName === 'position' ||
|
|
384
|
+
propName === 'top' ||
|
|
385
|
+
propName === 'left' ||
|
|
386
|
+
propName === 'right' ||
|
|
387
|
+
propName === 'bottom' ||
|
|
388
|
+
propName === 'width' ||
|
|
389
|
+
propName === 'height' ||
|
|
390
|
+
propName.startsWith('margin') || // Catches margin, margin-top, etc.
|
|
391
|
+
propName === 'transform' ||
|
|
392
|
+
propName === 'translate' ||
|
|
393
|
+
propName === 'z-index' ||
|
|
394
|
+
propName === 'opacity')) {
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
// cssText += `${propName}: ${computedStyles.getPropertyValue(propName)}; `; // Building cssText string
|
|
398
|
+
// More robust: set property directly
|
|
399
|
+
try {
|
|
400
|
+
target.style.setProperty(propName, computedStyles.getPropertyValue(propName), computedStyles.getPropertyPriority(propName));
|
|
401
|
+
}
|
|
402
|
+
catch (e) {
|
|
403
|
+
// console.warn(`Could not set style property ${propName} on cloned element`, e);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
// if (!target.style.cssText && cssText) { // only apply if cssText was not directly set
|
|
407
|
+
// target.style.cssText = cssText + target.style.cssText;
|
|
408
|
+
// }
|
|
409
|
+
}
|
|
410
|
+
// Recursively apply to children
|
|
411
|
+
const sourceChildren = Array.from(source.children);
|
|
412
|
+
const targetChildren = Array.from(target.children);
|
|
413
|
+
for (let i = 0; i < sourceChildren.length; i++) {
|
|
414
|
+
if (sourceChildren[i] instanceof HTMLElement && targetChildren[i] instanceof HTMLElement) {
|
|
415
|
+
applyComputedStylesRecursive(sourceChildren[i], targetChildren[i]);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
applyComputedStylesRecursive(originalElement, clonedElement);
|
|
420
|
+
if (clonedElement.id) {
|
|
421
|
+
this.renderer.removeAttribute(clonedElement, 'id');
|
|
422
|
+
}
|
|
423
|
+
this.renderer.setStyle(originalElement, 'opacity', '0.75');
|
|
424
|
+
const originalRect = originalElement.getBoundingClientRect();
|
|
425
|
+
this.renderer.setStyle(clonedElement, 'position', 'fixed', RendererStyleFlags2.Important);
|
|
426
|
+
this.renderer.setStyle(clonedElement, 'left', '0px');
|
|
427
|
+
this.renderer.setStyle(clonedElement, 'top', '0px');
|
|
428
|
+
this.renderer.setStyle(clonedElement, 'width', `${originalRect.width}px`);
|
|
429
|
+
this.renderer.setStyle(clonedElement, 'height', `${originalRect.height}px`);
|
|
430
|
+
this.renderer.setStyle(clonedElement, 'margin', '0');
|
|
431
|
+
this.renderer.setStyle(clonedElement, 'box-sizing', 'border-box');
|
|
432
|
+
this.renderer.setStyle(clonedElement, 'opacity', '0.75');
|
|
433
|
+
this.renderer.setStyle(clonedElement, 'z-index', '10000');
|
|
434
|
+
// This is the crucial part for the ROOT clone.
|
|
435
|
+
// Because we prevented 'pointer-events' from being copied in applyComputedStylesRecursive,
|
|
436
|
+
// this style will effectively apply to the entire clone tree.
|
|
437
|
+
this.renderer.setStyle(clonedElement, 'pointer-events', 'none', RendererStyleFlags2.Important);
|
|
438
|
+
this.renderer.setStyle(clonedElement, 'user-select', 'none');
|
|
439
|
+
this.renderer.setStyle(clonedElement, 'touch-action', 'none');
|
|
440
|
+
this.renderer.setStyle(clonedElement, 'translate', `${originalRect.left}px ${originalRect.top}px`);
|
|
441
|
+
this.renderer.appendChild(this.document.body, clonedElement);
|
|
442
|
+
this.clonedElement.set(clonedElement);
|
|
443
|
+
this.currentCloneAxis.set({ x: originalRect.left, y: originalRect.top });
|
|
444
|
+
return clonedElement;
|
|
445
|
+
}
|
|
446
|
+
removeCloneElement() {
|
|
447
|
+
if (!isPlatformBrowser(this.platformId))
|
|
448
|
+
return;
|
|
449
|
+
this.renderer.setStyle(this.element(), 'opacity', this.elementOpacity());
|
|
450
|
+
const clone = this.clonedElement();
|
|
451
|
+
if (clone && clone.parentNode === this.document.body) {
|
|
452
|
+
this.renderer.removeChild(this.document.body, clone);
|
|
453
|
+
}
|
|
454
|
+
this.clonedElement.set(null);
|
|
455
|
+
this.currentCloneAxis.set({ x: 0, y: 0 });
|
|
456
|
+
}
|
|
225
457
|
addDocumentListeners() {
|
|
458
|
+
if (!isPlatformBrowser(this.platformId))
|
|
459
|
+
return;
|
|
226
460
|
this.zone.runOutsideAngular(() => {
|
|
227
461
|
this.document.addEventListener('pointermove', this.boundHandlePointerMove, { passive: false });
|
|
228
462
|
this.document.addEventListener('pointerup', this.boundHandlePointerUp);
|
|
@@ -230,21 +464,23 @@ class AXDragDirective {
|
|
|
230
464
|
});
|
|
231
465
|
}
|
|
232
466
|
removeDocumentListeners() {
|
|
467
|
+
if (!isPlatformBrowser(this.platformId))
|
|
468
|
+
return;
|
|
233
469
|
this.zone.runOutsideAngular(() => {
|
|
234
470
|
this.document.removeEventListener('pointermove', this.boundHandlePointerMove);
|
|
235
471
|
this.document.removeEventListener('pointerup', this.boundHandlePointerUp);
|
|
236
472
|
this.document.removeEventListener('pointercancel', this.boundHandlePointerUp);
|
|
237
473
|
});
|
|
238
474
|
}
|
|
239
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
240
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "19.2.
|
|
475
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDragDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
476
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "19.2.10", type: AXDragDirective, isStandalone: true, selector: "[axDrag]", inputs: { dragData: { classPropertyName: "dragData", publicName: "dragData", isSignal: true, isRequired: false, transformFunction: null }, dragDisabled: { classPropertyName: "dragDisabled", publicName: "dragDisabled", isSignal: true, isRequired: false, transformFunction: null }, dragElementClone: { classPropertyName: "dragElementClone", publicName: "dragElementClone", isSignal: true, isRequired: false, transformFunction: null }, dropZoneGroup: { classPropertyName: "dropZoneGroup", publicName: "dropZoneGroup", isSignal: true, isRequired: false, transformFunction: null }, dragStartDelay: { classPropertyName: "dragStartDelay", publicName: "dragStartDelay", isSignal: true, isRequired: false, transformFunction: null }, dragResetOnDblClick: { classPropertyName: "dragResetOnDblClick", publicName: "dragResetOnDblClick", isSignal: true, isRequired: false, transformFunction: null }, dragLockAxis: { classPropertyName: "dragLockAxis", publicName: "dragLockAxis", isSignal: true, isRequired: false, transformFunction: null }, dragCursor: { classPropertyName: "dragCursor", publicName: "dragCursor", isSignal: true, isRequired: false, transformFunction: null }, dragBoundary: { classPropertyName: "dragBoundary", publicName: "dragBoundary", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dragPositionChanged: "dragPositionChanged" }, queries: [{ propertyName: "handleDirective", first: true, predicate: AXDragHandleDirective, descendants: true, isSignal: true }], ngImport: i0 }); }
|
|
241
477
|
}
|
|
242
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
478
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDragDirective, decorators: [{
|
|
243
479
|
type: Directive,
|
|
244
480
|
args: [{
|
|
245
481
|
selector: '[axDrag]',
|
|
246
482
|
}]
|
|
247
|
-
}]
|
|
483
|
+
}] });
|
|
248
484
|
|
|
249
485
|
class AXDropZoneDirective {
|
|
250
486
|
constructor() {
|
|
@@ -259,10 +495,10 @@ class AXDropZoneDirective {
|
|
|
259
495
|
this.element()['__axContext__'] = this;
|
|
260
496
|
this.element().dataset['dropZone'] = 'true';
|
|
261
497
|
}
|
|
262
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
263
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.
|
|
498
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDropZoneDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
499
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.10", type: AXDropZoneDirective, isStandalone: true, selector: "[axDropZone]", inputs: { dropZoneGroup: { classPropertyName: "dropZoneGroup", publicName: "dropZoneGroup", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onElementDrop: "onElementDrop", onElementHover: "onElementHover" }, exportAs: ["axDropZone"], ngImport: i0 }); }
|
|
264
500
|
}
|
|
265
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
501
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDropZoneDirective, decorators: [{
|
|
266
502
|
type: Directive,
|
|
267
503
|
args: [{
|
|
268
504
|
selector: '[axDropZone]',
|
|
@@ -272,11 +508,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.9", ngImpor
|
|
|
272
508
|
|
|
273
509
|
const COMPONENT = [AXDragDirective, AXDragHandleDirective, AXDropZoneDirective];
|
|
274
510
|
class AXDragDropModule {
|
|
275
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.
|
|
276
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.
|
|
277
|
-
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.
|
|
511
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDragDropModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
512
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.10", ngImport: i0, type: AXDragDropModule, imports: [AXDragDirective, AXDragHandleDirective, AXDropZoneDirective], exports: [AXDragDirective, AXDragHandleDirective, AXDropZoneDirective] }); }
|
|
513
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDragDropModule }); }
|
|
278
514
|
}
|
|
279
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.
|
|
515
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXDragDropModule, decorators: [{
|
|
280
516
|
type: NgModule,
|
|
281
517
|
args: [{
|
|
282
518
|
imports: [...COMPONENT],
|