@angular/cdk 9.2.0 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/focus-monitor/focus-monitor.d.ts +6 -0
- package/a11y/index.metadata.json +1 -1
- package/bundles/cdk-a11y.umd.js +71 -64
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-a11y.umd.min.js +8 -8
- package/bundles/cdk-a11y.umd.min.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +108 -79
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.min.js +15 -8
- package/bundles/cdk-drag-drop.umd.min.js.map +1 -1
- package/bundles/cdk-tree.umd.js +8 -4
- package/bundles/cdk-tree.umd.js.map +1 -1
- package/bundles/cdk-tree.umd.min.js +1 -1
- package/bundles/cdk-tree.umd.min.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/bundles/cdk.umd.min.js +1 -1
- package/bundles/cdk.umd.min.js.map +1 -1
- package/drag-drop/client-rect.d.ts +31 -0
- package/drag-drop/directives/config.d.ts +1 -0
- package/drag-drop/directives/drop-list.d.ts +4 -3
- package/drag-drop/drag-ref.d.ts +4 -0
- package/drag-drop/index.metadata.json +1 -1
- package/esm2015/a11y/focus-monitor/focus-monitor.js +71 -65
- package/esm2015/a11y/high-contrast-mode/high-contrast-mode-detector.js +8 -4
- package/esm2015/drag-drop/client-rect.js +75 -0
- package/esm2015/drag-drop/directives/config.js +3 -1
- package/esm2015/drag-drop/directives/drag.js +3 -2
- package/esm2015/drag-drop/directives/drop-list.js +24 -18
- package/esm2015/drag-drop/drag-ref.js +55 -21
- package/esm2015/drag-drop/drop-list-ref.js +5 -64
- package/esm2015/tree/padding.js +9 -10
- package/esm2015/version.js +1 -1
- package/esm5/a11y/focus-monitor/focus-monitor.js +49 -44
- package/esm5/a11y/high-contrast-mode/high-contrast-mode-detector.js +7 -4
- package/esm5/drag-drop/client-rect.js +60 -0
- package/esm5/drag-drop/directives/config.js +1 -1
- package/esm5/drag-drop/directives/drag.js +3 -2
- package/esm5/drag-drop/directives/drop-list.js +13 -10
- package/esm5/drag-drop/drag-ref.js +33 -17
- package/esm5/drag-drop/drop-list-ref.js +5 -54
- package/esm5/tree/padding.js +9 -5
- package/esm5/version.js +1 -1
- package/fesm2015/a11y.js +101 -92
- package/fesm2015/a11y.js.map +1 -1
- package/fesm2015/cdk.js +1 -1
- package/fesm2015/cdk.js.map +1 -1
- package/fesm2015/drag-drop.js +158 -101
- package/fesm2015/drag-drop.js.map +1 -1
- package/fesm2015/tree.js +8 -9
- package/fesm2015/tree.js.map +1 -1
- package/fesm5/a11y.js +71 -64
- package/fesm5/a11y.js.map +1 -1
- package/fesm5/cdk.js +1 -1
- package/fesm5/cdk.js.map +1 -1
- package/fesm5/drag-drop.js +108 -79
- package/fesm5/drag-drop.js.map +1 -1
- package/fesm5/tree.js +8 -4
- package/fesm5/tree.js.map +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/tree/index.metadata.json +1 -1
- package/tree/padding.d.ts +6 -2
package/fesm2015/a11y.js
CHANGED
|
@@ -2653,6 +2653,31 @@ if (false) {
|
|
|
2653
2653
|
CdkAriaLive.prototype._ngZone;
|
|
2654
2654
|
}
|
|
2655
2655
|
|
|
2656
|
+
/**
|
|
2657
|
+
* @fileoverview added by tsickle
|
|
2658
|
+
* Generated from: src/cdk/a11y/fake-mousedown.ts
|
|
2659
|
+
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2660
|
+
*/
|
|
2661
|
+
/**
|
|
2662
|
+
* @license
|
|
2663
|
+
* Copyright Google LLC All Rights Reserved.
|
|
2664
|
+
*
|
|
2665
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
2666
|
+
* found in the LICENSE file at https://angular.io/license
|
|
2667
|
+
*/
|
|
2668
|
+
/**
|
|
2669
|
+
* Screenreaders will often fire fake mousedown events when a focusable element
|
|
2670
|
+
* is activated using the keyboard. We can typically distinguish between these faked
|
|
2671
|
+
* mousedown events and real mousedown events using the "buttons" property. While
|
|
2672
|
+
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
|
|
2673
|
+
* the left mouse button), faked mousedowns will usually set the property value to 0.
|
|
2674
|
+
* @param {?} event
|
|
2675
|
+
* @return {?}
|
|
2676
|
+
*/
|
|
2677
|
+
function isFakeMousedownFromScreenReader(event) {
|
|
2678
|
+
return event.buttons === 0;
|
|
2679
|
+
}
|
|
2680
|
+
|
|
2656
2681
|
/**
|
|
2657
2682
|
* @fileoverview added by tsickle
|
|
2658
2683
|
* Generated from: src/cdk/a11y/focus-monitor/focus-monitor.ts
|
|
@@ -2760,13 +2785,18 @@ class FocusMonitor {
|
|
|
2760
2785
|
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
2761
2786
|
*/
|
|
2762
2787
|
this._documentMousedownListener = (/**
|
|
2788
|
+
* @param {?} event
|
|
2763
2789
|
* @return {?}
|
|
2764
2790
|
*/
|
|
2765
|
-
() => {
|
|
2791
|
+
(event) => {
|
|
2766
2792
|
// On mousedown record the origin only if there is not touch
|
|
2767
2793
|
// target, since a mousedown can happen as a result of a touch event.
|
|
2768
2794
|
if (!this._lastTouchTarget) {
|
|
2769
|
-
|
|
2795
|
+
// In some cases screen readers fire fake `mousedown` events instead of `keydown`.
|
|
2796
|
+
// Resolve the focus source to `keyboard` if we detect one of them.
|
|
2797
|
+
/** @type {?} */
|
|
2798
|
+
const source = isFakeMousedownFromScreenReader(event) ? 'keyboard' : 'mouse';
|
|
2799
|
+
this._setOriginForCurrentEventQueue(source);
|
|
2770
2800
|
}
|
|
2771
2801
|
});
|
|
2772
2802
|
/**
|
|
@@ -2809,6 +2839,24 @@ class FocusMonitor {
|
|
|
2809
2839
|
*/
|
|
2810
2840
|
() => this._windowFocused = false));
|
|
2811
2841
|
});
|
|
2842
|
+
/**
|
|
2843
|
+
* Event listener for `focus` and 'blur' events on the document.
|
|
2844
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
2845
|
+
*/
|
|
2846
|
+
this._documentFocusAndBlurListener = (/**
|
|
2847
|
+
* @param {?} event
|
|
2848
|
+
* @return {?}
|
|
2849
|
+
*/
|
|
2850
|
+
(event) => {
|
|
2851
|
+
/** @type {?} */
|
|
2852
|
+
const target = (/** @type {?} */ (event.target));
|
|
2853
|
+
/** @type {?} */
|
|
2854
|
+
const handler = event.type === 'focus' ? this._onFocus : this._onBlur;
|
|
2855
|
+
// We need to walk up the ancestor chain in order to support `checkChildren`.
|
|
2856
|
+
for (let el = target; el; el = el.parentElement) {
|
|
2857
|
+
handler.call(this, event, el);
|
|
2858
|
+
}
|
|
2859
|
+
});
|
|
2812
2860
|
this._document = document;
|
|
2813
2861
|
this._detectionMode = (options === null || options === void 0 ? void 0 : options.detectionMode) || 0 /* IMMEDIATE */;
|
|
2814
2862
|
}
|
|
@@ -2827,50 +2875,18 @@ class FocusMonitor {
|
|
|
2827
2875
|
// Check if we're already monitoring this element.
|
|
2828
2876
|
if (this._elementInfo.has(nativeElement)) {
|
|
2829
2877
|
/** @type {?} */
|
|
2830
|
-
|
|
2878
|
+
const cachedInfo = this._elementInfo.get(nativeElement);
|
|
2831
2879
|
(/** @type {?} */ (cachedInfo)).checkChildren = checkChildren;
|
|
2832
2880
|
return (/** @type {?} */ (cachedInfo)).subject.asObservable();
|
|
2833
2881
|
}
|
|
2834
2882
|
// Create monitored element info.
|
|
2835
2883
|
/** @type {?} */
|
|
2836
|
-
|
|
2837
|
-
unlisten: (/**
|
|
2838
|
-
* @return {?}
|
|
2839
|
-
*/
|
|
2840
|
-
() => { }),
|
|
2884
|
+
const info = {
|
|
2841
2885
|
checkChildren: checkChildren,
|
|
2842
2886
|
subject: new Subject()
|
|
2843
2887
|
};
|
|
2844
2888
|
this._elementInfo.set(nativeElement, info);
|
|
2845
2889
|
this._incrementMonitoredElementCount();
|
|
2846
|
-
// Start listening. We need to listen in capture phase since focus events don't bubble.
|
|
2847
|
-
/** @type {?} */
|
|
2848
|
-
let focusListener = (/**
|
|
2849
|
-
* @param {?} event
|
|
2850
|
-
* @return {?}
|
|
2851
|
-
*/
|
|
2852
|
-
(event) => this._onFocus(event, nativeElement));
|
|
2853
|
-
/** @type {?} */
|
|
2854
|
-
let blurListener = (/**
|
|
2855
|
-
* @param {?} event
|
|
2856
|
-
* @return {?}
|
|
2857
|
-
*/
|
|
2858
|
-
(event) => this._onBlur(event, nativeElement));
|
|
2859
|
-
this._ngZone.runOutsideAngular((/**
|
|
2860
|
-
* @return {?}
|
|
2861
|
-
*/
|
|
2862
|
-
() => {
|
|
2863
|
-
nativeElement.addEventListener('focus', focusListener, true);
|
|
2864
|
-
nativeElement.addEventListener('blur', blurListener, true);
|
|
2865
|
-
}));
|
|
2866
|
-
// Create an unlisten function for later.
|
|
2867
|
-
info.unlisten = (/**
|
|
2868
|
-
* @return {?}
|
|
2869
|
-
*/
|
|
2870
|
-
() => {
|
|
2871
|
-
nativeElement.removeEventListener('focus', focusListener, true);
|
|
2872
|
-
nativeElement.removeEventListener('blur', blurListener, true);
|
|
2873
|
-
});
|
|
2874
2890
|
return info.subject.asObservable();
|
|
2875
2891
|
}
|
|
2876
2892
|
/**
|
|
@@ -2883,7 +2899,6 @@ class FocusMonitor {
|
|
|
2883
2899
|
/** @type {?} */
|
|
2884
2900
|
const elementInfo = this._elementInfo.get(nativeElement);
|
|
2885
2901
|
if (elementInfo) {
|
|
2886
|
-
elementInfo.unlisten();
|
|
2887
2902
|
elementInfo.subject.complete();
|
|
2888
2903
|
this._setClasses(nativeElement);
|
|
2889
2904
|
this._elementInfo.delete(nativeElement);
|
|
@@ -2950,6 +2965,31 @@ class FocusMonitor {
|
|
|
2950
2965
|
element.classList.remove(className);
|
|
2951
2966
|
}
|
|
2952
2967
|
}
|
|
2968
|
+
/**
|
|
2969
|
+
* @private
|
|
2970
|
+
* @param {?} event
|
|
2971
|
+
* @return {?}
|
|
2972
|
+
*/
|
|
2973
|
+
_getFocusOrigin(event) {
|
|
2974
|
+
// If we couldn't detect a cause for the focus event, it's due to one of three reasons:
|
|
2975
|
+
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
2976
|
+
// the element from before the window blurred.
|
|
2977
|
+
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
2978
|
+
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
2979
|
+
// 'program'.
|
|
2980
|
+
if (this._origin) {
|
|
2981
|
+
return this._origin;
|
|
2982
|
+
}
|
|
2983
|
+
if (this._windowFocused && this._lastFocusOrigin) {
|
|
2984
|
+
return this._lastFocusOrigin;
|
|
2985
|
+
}
|
|
2986
|
+
else if (this._wasCausedByTouch(event)) {
|
|
2987
|
+
return 'touch';
|
|
2988
|
+
}
|
|
2989
|
+
else {
|
|
2990
|
+
return 'program';
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2953
2993
|
/**
|
|
2954
2994
|
* Sets the focus classes on the element based on the given focus origin.
|
|
2955
2995
|
* @private
|
|
@@ -2958,15 +2998,11 @@ class FocusMonitor {
|
|
|
2958
2998
|
* @return {?}
|
|
2959
2999
|
*/
|
|
2960
3000
|
_setClasses(element, origin) {
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
this._toggleClass(element, 'cdk-keyboard-focused', origin === 'keyboard');
|
|
2967
|
-
this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
|
|
2968
|
-
this._toggleClass(element, 'cdk-program-focused', origin === 'program');
|
|
2969
|
-
}
|
|
3001
|
+
this._toggleClass(element, 'cdk-focused', !!origin);
|
|
3002
|
+
this._toggleClass(element, 'cdk-touch-focused', origin === 'touch');
|
|
3003
|
+
this._toggleClass(element, 'cdk-keyboard-focused', origin === 'keyboard');
|
|
3004
|
+
this._toggleClass(element, 'cdk-mouse-focused', origin === 'mouse');
|
|
3005
|
+
this._toggleClass(element, 'cdk-program-focused', origin === 'program');
|
|
2970
3006
|
}
|
|
2971
3007
|
/**
|
|
2972
3008
|
* Sets the origin and schedules an async function to clear it at the end of the event queue.
|
|
@@ -3044,25 +3080,8 @@ class FocusMonitor {
|
|
|
3044
3080
|
if (!elementInfo || (!elementInfo.checkChildren && element !== event.target)) {
|
|
3045
3081
|
return;
|
|
3046
3082
|
}
|
|
3047
|
-
// If we couldn't detect a cause for the focus event, it's due to one of three reasons:
|
|
3048
|
-
// 1) The window has just regained focus, in which case we want to restore the focused state of
|
|
3049
|
-
// the element from before the window blurred.
|
|
3050
|
-
// 2) It was caused by a touch event, in which case we mark the origin as 'touch'.
|
|
3051
|
-
// 3) The element was programmatically focused, in which case we should mark the origin as
|
|
3052
|
-
// 'program'.
|
|
3053
3083
|
/** @type {?} */
|
|
3054
|
-
|
|
3055
|
-
if (!origin) {
|
|
3056
|
-
if (this._windowFocused && this._lastFocusOrigin) {
|
|
3057
|
-
origin = this._lastFocusOrigin;
|
|
3058
|
-
}
|
|
3059
|
-
else if (this._wasCausedByTouch(event)) {
|
|
3060
|
-
origin = 'touch';
|
|
3061
|
-
}
|
|
3062
|
-
else {
|
|
3063
|
-
origin = 'program';
|
|
3064
|
-
}
|
|
3065
|
-
}
|
|
3084
|
+
const origin = this._getFocusOrigin(event);
|
|
3066
3085
|
this._setClasses(element, origin);
|
|
3067
3086
|
this._emitOrigin(elementInfo.subject, origin);
|
|
3068
3087
|
this._lastFocusOrigin = origin;
|
|
@@ -3114,6 +3133,8 @@ class FocusMonitor {
|
|
|
3114
3133
|
const document = this._getDocument();
|
|
3115
3134
|
/** @type {?} */
|
|
3116
3135
|
const window = this._getWindow();
|
|
3136
|
+
document.addEventListener('focus', this._documentFocusAndBlurListener, captureEventListenerOptions);
|
|
3137
|
+
document.addEventListener('blur', this._documentFocusAndBlurListener, captureEventListenerOptions);
|
|
3117
3138
|
document.addEventListener('keydown', this._documentKeydownListener, captureEventListenerOptions);
|
|
3118
3139
|
document.addEventListener('mousedown', this._documentMousedownListener, captureEventListenerOptions);
|
|
3119
3140
|
document.addEventListener('touchstart', this._documentTouchstartListener, captureEventListenerOptions);
|
|
@@ -3132,6 +3153,8 @@ class FocusMonitor {
|
|
|
3132
3153
|
const document = this._getDocument();
|
|
3133
3154
|
/** @type {?} */
|
|
3134
3155
|
const window = this._getWindow();
|
|
3156
|
+
document.removeEventListener('focus', this._documentFocusAndBlurListener, captureEventListenerOptions);
|
|
3157
|
+
document.removeEventListener('blur', this._documentFocusAndBlurListener, captureEventListenerOptions);
|
|
3135
3158
|
document.removeEventListener('keydown', this._documentKeydownListener, captureEventListenerOptions);
|
|
3136
3159
|
document.removeEventListener('mousedown', this._documentMousedownListener, captureEventListenerOptions);
|
|
3137
3160
|
document.removeEventListener('touchstart', this._documentTouchstartListener, captureEventListenerOptions);
|
|
@@ -3250,6 +3273,13 @@ if (false) {
|
|
|
3250
3273
|
* @protected
|
|
3251
3274
|
*/
|
|
3252
3275
|
FocusMonitor.prototype._document;
|
|
3276
|
+
/**
|
|
3277
|
+
* Event listener for `focus` and 'blur' events on the document.
|
|
3278
|
+
* Needs to be an arrow function in order to preserve the context when it gets bound.
|
|
3279
|
+
* @type {?}
|
|
3280
|
+
* @private
|
|
3281
|
+
*/
|
|
3282
|
+
FocusMonitor.prototype._documentFocusAndBlurListener;
|
|
3253
3283
|
/**
|
|
3254
3284
|
* @type {?}
|
|
3255
3285
|
* @private
|
|
@@ -3327,31 +3357,6 @@ if (false) {
|
|
|
3327
3357
|
CdkMonitorFocus.prototype._focusMonitor;
|
|
3328
3358
|
}
|
|
3329
3359
|
|
|
3330
|
-
/**
|
|
3331
|
-
* @fileoverview added by tsickle
|
|
3332
|
-
* Generated from: src/cdk/a11y/fake-mousedown.ts
|
|
3333
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3334
|
-
*/
|
|
3335
|
-
/**
|
|
3336
|
-
* @license
|
|
3337
|
-
* Copyright Google LLC All Rights Reserved.
|
|
3338
|
-
*
|
|
3339
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
3340
|
-
* found in the LICENSE file at https://angular.io/license
|
|
3341
|
-
*/
|
|
3342
|
-
/**
|
|
3343
|
-
* Screenreaders will often fire fake mousedown events when a focusable element
|
|
3344
|
-
* is activated using the keyboard. We can typically distinguish between these faked
|
|
3345
|
-
* mousedown events and real mousedown events using the "buttons" property. While
|
|
3346
|
-
* real mousedowns will indicate the mouse button that was pressed (e.g. "1" for
|
|
3347
|
-
* the left mouse button), faked mousedowns will usually set the property value to 0.
|
|
3348
|
-
* @param {?} event
|
|
3349
|
-
* @return {?}
|
|
3350
|
-
*/
|
|
3351
|
-
function isFakeMousedownFromScreenReader(event) {
|
|
3352
|
-
return event.buttons === 0;
|
|
3353
|
-
}
|
|
3354
|
-
|
|
3355
3360
|
/**
|
|
3356
3361
|
* @fileoverview added by tsickle
|
|
3357
3362
|
* Generated from: src/cdk/a11y/high-contrast-mode/high-contrast-mode-detector.ts
|
|
@@ -3416,11 +3421,15 @@ class HighContrastModeDetector {
|
|
|
3416
3421
|
this._document.body.appendChild(testElement);
|
|
3417
3422
|
// Get the computed style for the background color, collapsing spaces to normalize between
|
|
3418
3423
|
// browsers. Once we get this color, we no longer need the test element. Access the `window`
|
|
3419
|
-
// via the document so we can fake it in tests.
|
|
3424
|
+
// via the document so we can fake it in tests. Note that we have extra null checks, because
|
|
3425
|
+
// this logic will likely run during app bootstrap and throwing can break the entire app.
|
|
3426
|
+
/** @type {?} */
|
|
3427
|
+
const documentWindow = this._document.defaultView || window;
|
|
3420
3428
|
/** @type {?} */
|
|
3421
|
-
const
|
|
3429
|
+
const computedStyle = (documentWindow && documentWindow.getComputedStyle) ?
|
|
3430
|
+
documentWindow.getComputedStyle(testElement) : null;
|
|
3422
3431
|
/** @type {?} */
|
|
3423
|
-
const computedColor = (
|
|
3432
|
+
const computedColor = (computedStyle && computedStyle.backgroundColor || '').replace(/ /g, '');
|
|
3424
3433
|
this._document.body.removeChild(testElement);
|
|
3425
3434
|
switch (computedColor) {
|
|
3426
3435
|
case 'rgb(0,0,0)': return 2 /* WHITE_ON_BLACK */;
|