@angular/cdk 17.3.6 → 17.3.8
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/index.d.ts +4 -0
- package/esm2022/drag-drop/drag-drop.mjs +35 -2
- package/esm2022/drag-drop/preview-ref.mjs +11 -32
- package/esm2022/menu/context-menu-trigger.mjs +2 -2
- package/esm2022/menu/menu-trigger-base.mjs +12 -1
- package/esm2022/menu/menu-trigger.mjs +2 -2
- package/esm2022/version.mjs +1 -1
- package/fesm2022/cdk.mjs +1 -1
- package/fesm2022/cdk.mjs.map +1 -1
- package/fesm2022/drag-drop.mjs +44 -32
- package/fesm2022/drag-drop.mjs.map +1 -1
- package/fesm2022/menu.mjs +13 -3
- package/fesm2022/menu.mjs.map +1 -1
- package/menu/index.d.ts +6 -0
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
package/fesm2022/drag-drop.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Inject, InjectionToken, booleanAttribute, Directive, Optional, SkipSelf, Input, EventEmitter, Self, Output,
|
|
2
|
+
import { Injectable, Inject, Component, ViewEncapsulation, ChangeDetectionStrategy, inject, ApplicationRef, EnvironmentInjector, createComponent, InjectionToken, booleanAttribute, Directive, Optional, SkipSelf, Input, EventEmitter, Self, Output, NgModule } from '@angular/core';
|
|
3
3
|
import { DOCUMENT } from '@angular/common';
|
|
4
4
|
import * as i1 from '@angular/cdk/scrolling';
|
|
5
5
|
import { CdkScrollableModule } from '@angular/cdk/scrolling';
|
|
@@ -335,19 +335,18 @@ class PreviewRef {
|
|
|
335
335
|
this._zIndex = _zIndex;
|
|
336
336
|
}
|
|
337
337
|
attach(parent) {
|
|
338
|
-
this._wrapper = this._createWrapper();
|
|
339
338
|
this._preview = this._createPreview();
|
|
340
|
-
|
|
341
|
-
parent.appendChild(this._wrapper);
|
|
339
|
+
parent.appendChild(this._preview);
|
|
342
340
|
// The null check is necessary for browsers that don't support the popover API.
|
|
343
|
-
|
|
344
|
-
|
|
341
|
+
// Note that we use a string access for compatibility with Closure.
|
|
342
|
+
if ('showPopover' in this._preview) {
|
|
343
|
+
this._preview['showPopover']();
|
|
345
344
|
}
|
|
346
345
|
}
|
|
347
346
|
destroy() {
|
|
348
|
-
this.
|
|
347
|
+
this._preview.remove();
|
|
349
348
|
this._previewEmbeddedView?.destroy();
|
|
350
|
-
this._preview = this.
|
|
349
|
+
this._preview = this._previewEmbeddedView = null;
|
|
351
350
|
}
|
|
352
351
|
setTransform(value) {
|
|
353
352
|
this._preview.style.transform = value;
|
|
@@ -367,29 +366,6 @@ class PreviewRef {
|
|
|
367
366
|
removeEventListener(name, handler) {
|
|
368
367
|
this._preview.removeEventListener(name, handler);
|
|
369
368
|
}
|
|
370
|
-
_createWrapper() {
|
|
371
|
-
const wrapper = this._document.createElement('div');
|
|
372
|
-
wrapper.setAttribute('popover', 'manual');
|
|
373
|
-
wrapper.setAttribute('dir', this._direction);
|
|
374
|
-
wrapper.classList.add('cdk-drag-preview-container');
|
|
375
|
-
extendStyles(wrapper.style, {
|
|
376
|
-
// This is redundant, but we need it for browsers that don't support the popover API.
|
|
377
|
-
'position': 'fixed',
|
|
378
|
-
'top': '0',
|
|
379
|
-
'left': '0',
|
|
380
|
-
'width': '100%',
|
|
381
|
-
'height': '100%',
|
|
382
|
-
'z-index': this._zIndex + '',
|
|
383
|
-
// Reset the user agent styles.
|
|
384
|
-
'background': 'none',
|
|
385
|
-
'border': 'none',
|
|
386
|
-
'pointer-events': 'none',
|
|
387
|
-
'margin': '0',
|
|
388
|
-
'padding': '0',
|
|
389
|
-
});
|
|
390
|
-
toggleNativeDragInteractions(wrapper, false);
|
|
391
|
-
return wrapper;
|
|
392
|
-
}
|
|
393
369
|
_createPreview() {
|
|
394
370
|
const previewConfig = this._previewTemplate;
|
|
395
371
|
const previewClass = this._previewClass;
|
|
@@ -423,12 +399,15 @@ class PreviewRef {
|
|
|
423
399
|
'pointer-events': 'none',
|
|
424
400
|
// We have to reset the margin, because it can throw off positioning relative to the viewport.
|
|
425
401
|
'margin': '0',
|
|
426
|
-
'position': '
|
|
402
|
+
'position': 'fixed',
|
|
427
403
|
'top': '0',
|
|
428
404
|
'left': '0',
|
|
405
|
+
'z-index': this._zIndex + '',
|
|
429
406
|
}, importantProperties);
|
|
430
407
|
toggleNativeDragInteractions(preview, false);
|
|
431
408
|
preview.classList.add('cdk-drag-preview');
|
|
409
|
+
preview.setAttribute('popover', 'manual');
|
|
410
|
+
preview.setAttribute('dir', this._direction);
|
|
432
411
|
if (previewClass) {
|
|
433
412
|
if (Array.isArray(previewClass)) {
|
|
434
413
|
previewClass.forEach(className => preview.classList.add(className));
|
|
@@ -2720,6 +2699,20 @@ const DEFAULT_CONFIG = {
|
|
|
2720
2699
|
dragStartThreshold: 5,
|
|
2721
2700
|
pointerDirectionChangeThreshold: 5,
|
|
2722
2701
|
};
|
|
2702
|
+
/** Keeps track of the apps currently containing badges. */
|
|
2703
|
+
const activeApps = new Set();
|
|
2704
|
+
/**
|
|
2705
|
+
* Component used to load the drag&drop reset styles.
|
|
2706
|
+
* @docs-private
|
|
2707
|
+
*/
|
|
2708
|
+
class _ResetsLoader {
|
|
2709
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: _ResetsLoader, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2710
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.0", type: _ResetsLoader, isStandalone: true, selector: "ng-component", host: { attributes: { "cdk-drag-resets-container": "" } }, ngImport: i0, template: '', isInline: true, styles: ["@layer cdk-resets{.cdk-drag-preview{background:none;border:none;padding:0;color:inherit}}"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
2711
|
+
}
|
|
2712
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: _ResetsLoader, decorators: [{
|
|
2713
|
+
type: Component,
|
|
2714
|
+
args: [{ standalone: true, encapsulation: ViewEncapsulation.None, template: '', changeDetection: ChangeDetectionStrategy.OnPush, host: { 'cdk-drag-resets-container': '' }, styles: ["@layer cdk-resets{.cdk-drag-preview{background:none;border:none;padding:0;color:inherit}}"] }]
|
|
2715
|
+
}] });
|
|
2723
2716
|
/**
|
|
2724
2717
|
* Service that allows for drag-and-drop functionality to be attached to DOM elements.
|
|
2725
2718
|
*/
|
|
@@ -2729,6 +2722,8 @@ class DragDrop {
|
|
|
2729
2722
|
this._ngZone = _ngZone;
|
|
2730
2723
|
this._viewportRuler = _viewportRuler;
|
|
2731
2724
|
this._dragDropRegistry = _dragDropRegistry;
|
|
2725
|
+
this._appRef = inject(ApplicationRef);
|
|
2726
|
+
this._environmentInjector = inject(EnvironmentInjector);
|
|
2732
2727
|
}
|
|
2733
2728
|
/**
|
|
2734
2729
|
* Turns an element into a draggable item.
|
|
@@ -2736,6 +2731,7 @@ class DragDrop {
|
|
|
2736
2731
|
* @param config Object used to configure the dragging behavior.
|
|
2737
2732
|
*/
|
|
2738
2733
|
createDrag(element, config = DEFAULT_CONFIG) {
|
|
2734
|
+
this._loadResets();
|
|
2739
2735
|
return new DragRef(element, config, this._document, this._ngZone, this._viewportRuler, this._dragDropRegistry);
|
|
2740
2736
|
}
|
|
2741
2737
|
/**
|
|
@@ -2745,6 +2741,22 @@ class DragDrop {
|
|
|
2745
2741
|
createDropList(element) {
|
|
2746
2742
|
return new DropListRef(element, this._dragDropRegistry, this._document, this._ngZone, this._viewportRuler);
|
|
2747
2743
|
}
|
|
2744
|
+
// TODO(crisbeto): abstract this away into something reusable.
|
|
2745
|
+
/** Loads the CSS resets needed for the module to work correctly. */
|
|
2746
|
+
_loadResets() {
|
|
2747
|
+
if (!activeApps.has(this._appRef)) {
|
|
2748
|
+
activeApps.add(this._appRef);
|
|
2749
|
+
const componentRef = createComponent(_ResetsLoader, {
|
|
2750
|
+
environmentInjector: this._environmentInjector,
|
|
2751
|
+
});
|
|
2752
|
+
this._appRef.onDestroy(() => {
|
|
2753
|
+
activeApps.delete(this._appRef);
|
|
2754
|
+
if (activeApps.size === 0) {
|
|
2755
|
+
componentRef.destroy();
|
|
2756
|
+
}
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2748
2760
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: DragDrop, deps: [{ token: DOCUMENT }, { token: i0.NgZone }, { token: i1.ViewportRuler }, { token: DragDropRegistry }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2749
2761
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.2.0", ngImport: i0, type: DragDrop, providedIn: 'root' }); }
|
|
2750
2762
|
}
|