@angular/cdk 12.2.6 → 12.2.10
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/live-announcer/live-announcer.d.ts +1 -1
- package/bundles/cdk-a11y.umd.js.map +1 -1
- package/bundles/cdk-drag-drop.umd.js +2 -1
- package/bundles/cdk-drag-drop.umd.js.map +1 -1
- package/bundles/cdk-layout.umd.js +9 -5
- package/bundles/cdk-layout.umd.js.map +1 -1
- package/bundles/cdk-overlay.umd.js +22 -23
- package/bundles/cdk-overlay.umd.js.map +1 -1
- package/bundles/cdk-platform.umd.js +28 -0
- package/bundles/cdk-platform.umd.js.map +1 -1
- package/bundles/cdk.umd.js +1 -1
- package/bundles/cdk.umd.js.map +1 -1
- package/esm2015/a11y/focus-monitor/focus-monitor.js +1 -1
- package/esm2015/a11y/live-announcer/live-announcer.js +1 -1
- package/esm2015/drag-drop/drag-ref.js +3 -2
- package/esm2015/layout/media-matcher.js +10 -6
- package/esm2015/overlay/overlay-container.js +8 -15
- package/esm2015/overlay/overlay-ref.js +19 -13
- package/esm2015/platform/features/test-environment.js +27 -0
- package/esm2015/platform/public-api.js +2 -1
- package/esm2015/version.js +1 -1
- 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 +2 -1
- package/fesm2015/drag-drop.js.map +1 -1
- package/fesm2015/layout.js +9 -5
- package/fesm2015/layout.js.map +1 -1
- package/fesm2015/overlay.js +25 -26
- package/fesm2015/overlay.js.map +1 -1
- package/fesm2015/platform.js +28 -1
- package/fesm2015/platform.js.map +1 -1
- package/overlay/index.metadata.json +1 -1
- package/overlay/overlay-container.d.ts +1 -1
- package/overlay/overlay-ref.d.ts +2 -0
- package/package.json +1 -1
- package/platform/features/test-environment.d.ts +9 -0
- package/platform/index.metadata.json +1 -1
- package/platform/public-api.d.ts +1 -0
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
package/fesm2015/layout.js
CHANGED
|
@@ -47,7 +47,7 @@ class MediaMatcher {
|
|
|
47
47
|
* MediaQueryList for the query provided.
|
|
48
48
|
*/
|
|
49
49
|
matchMedia(query) {
|
|
50
|
-
if (this._platform.WEBKIT) {
|
|
50
|
+
if (this._platform.WEBKIT || this._platform.BLINK) {
|
|
51
51
|
createEmptyStyleRule(query);
|
|
52
52
|
}
|
|
53
53
|
return this._matchMedia(query);
|
|
@@ -61,8 +61,13 @@ MediaMatcher.ctorParameters = () => [
|
|
|
61
61
|
{ type: Platform }
|
|
62
62
|
];
|
|
63
63
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
64
|
+
* Creates an empty stylesheet that is used to work around browser inconsistencies related to
|
|
65
|
+
* `matchMedia`. At the time of writing, it handles the following cases:
|
|
66
|
+
* 1. On WebKit browsers, a media query has to have at least one rule in order for `matchMedia`
|
|
67
|
+
* to fire. We work around it by declaring a dummy stylesheet with a `@media` declaration.
|
|
68
|
+
* 2. In some cases Blink browsers will stop firing the `matchMedia` listener if none of the rules
|
|
69
|
+
* inside the `@media` match existing elements on the page. We work around it by having one rule
|
|
70
|
+
* targeting the `body`. See https://github.com/angular/components/issues/23546.
|
|
66
71
|
*/
|
|
67
72
|
function createEmptyStyleRule(query) {
|
|
68
73
|
if (mediaQueriesForWebkitCompatibility.has(query)) {
|
|
@@ -75,8 +80,7 @@ function createEmptyStyleRule(query) {
|
|
|
75
80
|
document.head.appendChild(mediaQueryStyleNode);
|
|
76
81
|
}
|
|
77
82
|
if (mediaQueryStyleNode.sheet) {
|
|
78
|
-
mediaQueryStyleNode.sheet
|
|
79
|
-
.insertRule(`@media ${query} {.fx-query-test{ }}`, 0);
|
|
83
|
+
mediaQueryStyleNode.sheet.insertRule(`@media ${query} {body{ }}`, 0);
|
|
80
84
|
mediaQueriesForWebkitCompatibility.add(query);
|
|
81
85
|
}
|
|
82
86
|
}
|
package/fesm2015/layout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","sources":["../../../../../../src/cdk/layout/layout-module.ts","../../../../../../src/cdk/layout/media-matcher.ts","../../../../../../src/cdk/layout/breakpoints-observer.ts","../../../../../../src/cdk/layout/breakpoints.ts","../../../../../../src/cdk/layout/public-api.ts","../../../../../../src/cdk/layout/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {NgModule} from '@angular/core';\n\n\n@NgModule({})\nexport class LayoutModule {}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {Injectable} from '@angular/core';\nimport {Platform} from '@angular/cdk/platform';\n\n/** Global registry for all dynamically-created, injected media queries. */\nconst mediaQueriesForWebkitCompatibility: Set<string> = new Set<string>();\n\n/** Style tag that holds all of the dynamically-created media queries. */\nlet mediaQueryStyleNode: HTMLStyleElement | undefined;\n\n/** A utility for calling matchMedia queries. */\n@Injectable({providedIn: 'root'})\nexport class MediaMatcher {\n /** The internal matchMedia method to return back a MediaQueryList like object. */\n private _matchMedia: (query: string) => MediaQueryList;\n\n constructor(private _platform: Platform) {\n this._matchMedia = this._platform.isBrowser && window.matchMedia ?\n // matchMedia is bound to the window scope intentionally as it is an illegal invocation to\n // call it from a different scope.\n window.matchMedia.bind(window) :\n noopMatchMedia;\n }\n\n /**\n * Evaluates the given media query and returns the native MediaQueryList from which results\n * can be retrieved.\n * Confirms the layout engine will trigger for the selector query provided and returns the\n * MediaQueryList for the query provided.\n */\n matchMedia(query: string): MediaQueryList {\n if (this._platform.WEBKIT) {\n createEmptyStyleRule(query);\n }\n return this._matchMedia(query);\n }\n}\n\n/**\n * For Webkit engines that only trigger the MediaQueryListListener when\n * there is at least one CSS selector for the respective media query.\n */\nfunction createEmptyStyleRule(query: string) {\n if (mediaQueriesForWebkitCompatibility.has(query)) {\n return;\n }\n\n try {\n if (!mediaQueryStyleNode) {\n mediaQueryStyleNode = document.createElement('style');\n mediaQueryStyleNode.setAttribute('type', 'text/css');\n document.head!.appendChild(mediaQueryStyleNode);\n }\n\n if (mediaQueryStyleNode.sheet) {\n (mediaQueryStyleNode.sheet as CSSStyleSheet)\n .insertRule(`@media ${query} {.fx-query-test{ }}`, 0);\n mediaQueriesForWebkitCompatibility.add(query);\n }\n } catch (e) {\n console.error(e);\n }\n}\n\n/** No-op matchMedia replacement for non-browser platforms. */\nfunction noopMatchMedia(query: string): MediaQueryList {\n // Use `as any` here to avoid adding additional necessary properties for\n // the noop matcher.\n return {\n matches: query === 'all' || query === '',\n media: query,\n addListener: () => {},\n removeListener: () => {}\n } as any;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {coerceArray} from '@angular/cdk/coercion';\nimport {Injectable, NgZone, OnDestroy} from '@angular/core';\nimport {combineLatest, concat, Observable, Observer, Subject} from 'rxjs';\nimport {debounceTime, map, skip, startWith, take, takeUntil} from 'rxjs/operators';\nimport {MediaMatcher} from './media-matcher';\n\n\n/** The current state of a layout breakpoint. */\nexport interface BreakpointState {\n /** Whether the breakpoint is currently matching. */\n matches: boolean;\n /**\n * A key boolean pair for each query provided to the observe method,\n * with its current matched state.\n */\n breakpoints: {\n [key: string]: boolean;\n };\n}\n\n/** The current state of a layout breakpoint. */\ninterface InternalBreakpointState {\n /** Whether the breakpoint is currently matching. */\n matches: boolean;\n /** The media query being to be matched */\n query: string;\n}\n\ninterface Query {\n observable: Observable<InternalBreakpointState>;\n mql: MediaQueryList;\n}\n\n/** Utility for checking the matching state of @media queries. */\n@Injectable({providedIn: 'root'})\nexport class BreakpointObserver implements OnDestroy {\n /** A map of all media queries currently being listened for. */\n private _queries = new Map<string, Query>();\n /** A subject for all other observables to takeUntil based on. */\n private readonly _destroySubject = new Subject<void>();\n\n constructor(private _mediaMatcher: MediaMatcher, private _zone: NgZone) {}\n\n /** Completes the active subject, signalling to all other observables to complete. */\n ngOnDestroy() {\n this._destroySubject.next();\n this._destroySubject.complete();\n }\n\n /**\n * Whether one or more media queries match the current viewport size.\n * @param value One or more media queries to check.\n * @returns Whether any of the media queries match.\n */\n isMatched(value: string | readonly string[]): boolean {\n const queries = splitQueries(coerceArray(value));\n return queries.some(mediaQuery => this._registerQuery(mediaQuery).mql.matches);\n }\n\n /**\n * Gets an observable of results for the given queries that will emit new results for any changes\n * in matching of the given queries.\n * @param value One or more media queries to check.\n * @returns A stream of matches for the given queries.\n */\n observe(value: string | readonly string[]): Observable<BreakpointState> {\n const queries = splitQueries(coerceArray(value));\n const observables = queries.map(query => this._registerQuery(query).observable);\n\n let stateObservable = combineLatest(observables);\n // Emit the first state immediately, and then debounce the subsequent emissions.\n stateObservable = concat(\n stateObservable.pipe(take(1)),\n stateObservable.pipe(skip(1), debounceTime(0)));\n return stateObservable.pipe(map(breakpointStates => {\n const response: BreakpointState = {\n matches: false,\n breakpoints: {},\n };\n breakpointStates.forEach(({matches, query}) => {\n response.matches = response.matches || matches;\n response.breakpoints[query] = matches;\n });\n return response;\n }));\n }\n\n /** Registers a specific query to be listened for. */\n private _registerQuery(query: string): Query {\n // Only set up a new MediaQueryList if it is not already being listened for.\n if (this._queries.has(query)) {\n return this._queries.get(query)!;\n }\n\n const mql = this._mediaMatcher.matchMedia(query);\n\n // Create callback for match changes and add it is as a listener.\n const queryObservable = new Observable((observer: Observer<MediaQueryList>) => {\n // Listener callback methods are wrapped to be placed back in ngZone. Callbacks must be placed\n // back into the zone because matchMedia is only included in Zone.js by loading the\n // webapis-media-query.js file alongside the zone.js file. Additionally, some browsers do not\n // have MediaQueryList inherit from EventTarget, which causes inconsistencies in how Zone.js\n // patches it.\n const handler = (e: any) => this._zone.run(() => observer.next(e));\n mql.addListener(handler);\n\n return () => {\n mql.removeListener(handler);\n };\n }).pipe(\n startWith(mql),\n map(({matches}) => ({query, matches})),\n takeUntil(this._destroySubject)\n );\n\n // Add the MediaQueryList to the set of queries.\n const output = {observable: queryObservable, mql};\n this._queries.set(query, output);\n return output;\n }\n}\n\n/**\n * Split each query string into separate query strings if two queries are provided as comma\n * separated.\n */\nfunction splitQueries(queries: readonly string[]): readonly string[] {\n return queries.map(query => query.split(','))\n .reduce((a1, a2) => a1.concat(a2))\n .map(query => query.trim());\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n// PascalCase is being used as Breakpoints is used like an enum.\n// tslint:disable-next-line:variable-name\nexport const Breakpoints = {\n XSmall: '(max-width: 599.98px)',\n Small: '(min-width: 600px) and (max-width: 959.98px)',\n Medium: '(min-width: 960px) and (max-width: 1279.98px)',\n Large: '(min-width: 1280px) and (max-width: 1919.98px)',\n XLarge: '(min-width: 1920px)',\n\n Handset: '(max-width: 599.98px) and (orientation: portrait), ' +\n '(max-width: 959.98px) and (orientation: landscape)',\n Tablet: '(min-width: 600px) and (max-width: 839.98px) and (orientation: portrait), ' +\n '(min-width: 960px) and (max-width: 1279.98px) and (orientation: landscape)',\n Web: '(min-width: 840px) and (orientation: portrait), ' +\n '(min-width: 1280px) and (orientation: landscape)',\n\n HandsetPortrait: '(max-width: 599.98px) and (orientation: portrait)',\n TabletPortrait: '(min-width: 600px) and (max-width: 839.98px) and (orientation: portrait)',\n WebPortrait: '(min-width: 840px) and (orientation: portrait)',\n\n HandsetLandscape: '(max-width: 959.98px) and (orientation: landscape)',\n TabletLandscape: '(min-width: 960px) and (max-width: 1279.98px) and (orientation: landscape)',\n WebLandscape: '(min-width: 1280px) and (orientation: landscape)',\n};\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport {LayoutModule} from './layout-module';\nexport {BreakpointObserver, BreakpointState} from './breakpoints-observer';\nexport {Breakpoints} from './breakpoints';\nexport {MediaMatcher} from './media-matcher';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;;MAWa,YAAY;;;YADxB,QAAQ,SAAC,EAAE;;;ACVZ;;;;;;;AAUA;AACA,MAAM,kCAAkC,GAAgB,IAAI,GAAG,EAAU,CAAC;AAE1E;AACA,IAAI,mBAAiD,CAAC;AAEtD;MAEa,YAAY;IAIvB,YAAoB,SAAmB;QAAnB,cAAS,GAAT,SAAS,CAAU;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,IAAI,MAAM,CAAC,UAAU;;;YAG9D,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;YAC9B,cAAc,CAAC;KAClB;;;;;;;IAQD,UAAU,CAAC,KAAa;QACtB,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE;YACzB,oBAAoB,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KAChC;;;;YAxBF,UAAU,SAAC,EAAC,UAAU,EAAE,MAAM,EAAC;;;YATxB,QAAQ;;AAoChB;;;;AAIA,SAAS,oBAAoB,CAAC,KAAa;IACzC,IAAI,kCAAkC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACjD,OAAO;KACR;IAED,IAAI;QACF,IAAI,CAAC,mBAAmB,EAAE;YACxB,mBAAmB,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;YACtD,mBAAmB,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;YACrD,QAAQ,CAAC,IAAK,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;SACjD;QAED,IAAI,mBAAmB,CAAC,KAAK,EAAE;YAC5B,mBAAmB,CAAC,KAAuB;iBACvC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;;;"}
|
|
1
|
+
{"version":3,"file":"layout.js","sources":["../../../../../../src/cdk/layout/layout-module.ts","../../../../../../src/cdk/layout/media-matcher.ts","../../../../../../src/cdk/layout/breakpoints-observer.ts","../../../../../../src/cdk/layout/breakpoints.ts","../../../../../../src/cdk/layout/public-api.ts","../../../../../../src/cdk/layout/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {NgModule} from '@angular/core';\n\n\n@NgModule({})\nexport class LayoutModule {}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport {Injectable} from '@angular/core';\nimport {Platform} from '@angular/cdk/platform';\n\n/** Global registry for all dynamically-created, injected media queries. */\nconst mediaQueriesForWebkitCompatibility: Set<string> = new Set<string>();\n\n/** Style tag that holds all of the dynamically-created media queries. */\nlet mediaQueryStyleNode: HTMLStyleElement | undefined;\n\n/** A utility for calling matchMedia queries. */\n@Injectable({providedIn: 'root'})\nexport class MediaMatcher {\n /** The internal matchMedia method to return back a MediaQueryList like object. */\n private _matchMedia: (query: string) => MediaQueryList;\n\n constructor(private _platform: Platform) {\n this._matchMedia = this._platform.isBrowser && window.matchMedia ?\n // matchMedia is bound to the window scope intentionally as it is an illegal invocation to\n // call it from a different scope.\n window.matchMedia.bind(window) :\n noopMatchMedia;\n }\n\n /**\n * Evaluates the given media query and returns the native MediaQueryList from which results\n * can be retrieved.\n * Confirms the layout engine will trigger for the selector query provided and returns the\n * MediaQueryList for the query provided.\n */\n matchMedia(query: string): MediaQueryList {\n if (this._platform.WEBKIT || this._platform.BLINK) {\n createEmptyStyleRule(query);\n }\n return this._matchMedia(query);\n }\n}\n\n/**\n * Creates an empty stylesheet that is used to work around browser inconsistencies related to\n * `matchMedia`. At the time of writing, it handles the following cases:\n * 1. On WebKit browsers, a media query has to have at least one rule in order for `matchMedia`\n * to fire. We work around it by declaring a dummy stylesheet with a `@media` declaration.\n * 2. In some cases Blink browsers will stop firing the `matchMedia` listener if none of the rules\n * inside the `@media` match existing elements on the page. We work around it by having one rule\n * targeting the `body`. See https://github.com/angular/components/issues/23546.\n */\nfunction createEmptyStyleRule(query: string) {\n if (mediaQueriesForWebkitCompatibility.has(query)) {\n return;\n }\n\n try {\n if (!mediaQueryStyleNode) {\n mediaQueryStyleNode = document.createElement('style');\n mediaQueryStyleNode.setAttribute('type', 'text/css');\n document.head!.appendChild(mediaQueryStyleNode);\n }\n\n if (mediaQueryStyleNode.sheet) {\n mediaQueryStyleNode.sheet.insertRule(`@media ${query} {body{ }}`, 0);\n mediaQueriesForWebkitCompatibility.add(query);\n }\n } catch (e) {\n console.error(e);\n }\n}\n\n/** No-op matchMedia replacement for non-browser platforms. */\nfunction noopMatchMedia(query: string): MediaQueryList {\n // Use `as any` here to avoid adding additional necessary properties for\n // the noop matcher.\n return {\n matches: query === 'all' || query === '',\n media: query,\n addListener: () => {},\n removeListener: () => {}\n } as any;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {coerceArray} from '@angular/cdk/coercion';\nimport {Injectable, NgZone, OnDestroy} from '@angular/core';\nimport {combineLatest, concat, Observable, Observer, Subject} from 'rxjs';\nimport {debounceTime, map, skip, startWith, take, takeUntil} from 'rxjs/operators';\nimport {MediaMatcher} from './media-matcher';\n\n\n/** The current state of a layout breakpoint. */\nexport interface BreakpointState {\n /** Whether the breakpoint is currently matching. */\n matches: boolean;\n /**\n * A key boolean pair for each query provided to the observe method,\n * with its current matched state.\n */\n breakpoints: {\n [key: string]: boolean;\n };\n}\n\n/** The current state of a layout breakpoint. */\ninterface InternalBreakpointState {\n /** Whether the breakpoint is currently matching. */\n matches: boolean;\n /** The media query being to be matched */\n query: string;\n}\n\ninterface Query {\n observable: Observable<InternalBreakpointState>;\n mql: MediaQueryList;\n}\n\n/** Utility for checking the matching state of @media queries. */\n@Injectable({providedIn: 'root'})\nexport class BreakpointObserver implements OnDestroy {\n /** A map of all media queries currently being listened for. */\n private _queries = new Map<string, Query>();\n /** A subject for all other observables to takeUntil based on. */\n private readonly _destroySubject = new Subject<void>();\n\n constructor(private _mediaMatcher: MediaMatcher, private _zone: NgZone) {}\n\n /** Completes the active subject, signalling to all other observables to complete. */\n ngOnDestroy() {\n this._destroySubject.next();\n this._destroySubject.complete();\n }\n\n /**\n * Whether one or more media queries match the current viewport size.\n * @param value One or more media queries to check.\n * @returns Whether any of the media queries match.\n */\n isMatched(value: string | readonly string[]): boolean {\n const queries = splitQueries(coerceArray(value));\n return queries.some(mediaQuery => this._registerQuery(mediaQuery).mql.matches);\n }\n\n /**\n * Gets an observable of results for the given queries that will emit new results for any changes\n * in matching of the given queries.\n * @param value One or more media queries to check.\n * @returns A stream of matches for the given queries.\n */\n observe(value: string | readonly string[]): Observable<BreakpointState> {\n const queries = splitQueries(coerceArray(value));\n const observables = queries.map(query => this._registerQuery(query).observable);\n\n let stateObservable = combineLatest(observables);\n // Emit the first state immediately, and then debounce the subsequent emissions.\n stateObservable = concat(\n stateObservable.pipe(take(1)),\n stateObservable.pipe(skip(1), debounceTime(0)));\n return stateObservable.pipe(map(breakpointStates => {\n const response: BreakpointState = {\n matches: false,\n breakpoints: {},\n };\n breakpointStates.forEach(({matches, query}) => {\n response.matches = response.matches || matches;\n response.breakpoints[query] = matches;\n });\n return response;\n }));\n }\n\n /** Registers a specific query to be listened for. */\n private _registerQuery(query: string): Query {\n // Only set up a new MediaQueryList if it is not already being listened for.\n if (this._queries.has(query)) {\n return this._queries.get(query)!;\n }\n\n const mql = this._mediaMatcher.matchMedia(query);\n\n // Create callback for match changes and add it is as a listener.\n const queryObservable = new Observable((observer: Observer<MediaQueryList>) => {\n // Listener callback methods are wrapped to be placed back in ngZone. Callbacks must be placed\n // back into the zone because matchMedia is only included in Zone.js by loading the\n // webapis-media-query.js file alongside the zone.js file. Additionally, some browsers do not\n // have MediaQueryList inherit from EventTarget, which causes inconsistencies in how Zone.js\n // patches it.\n const handler = (e: any) => this._zone.run(() => observer.next(e));\n mql.addListener(handler);\n\n return () => {\n mql.removeListener(handler);\n };\n }).pipe(\n startWith(mql),\n map(({matches}) => ({query, matches})),\n takeUntil(this._destroySubject)\n );\n\n // Add the MediaQueryList to the set of queries.\n const output = {observable: queryObservable, mql};\n this._queries.set(query, output);\n return output;\n }\n}\n\n/**\n * Split each query string into separate query strings if two queries are provided as comma\n * separated.\n */\nfunction splitQueries(queries: readonly string[]): readonly string[] {\n return queries.map(query => query.split(','))\n .reduce((a1, a2) => a1.concat(a2))\n .map(query => query.trim());\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n// PascalCase is being used as Breakpoints is used like an enum.\n// tslint:disable-next-line:variable-name\nexport const Breakpoints = {\n XSmall: '(max-width: 599.98px)',\n Small: '(min-width: 600px) and (max-width: 959.98px)',\n Medium: '(min-width: 960px) and (max-width: 1279.98px)',\n Large: '(min-width: 1280px) and (max-width: 1919.98px)',\n XLarge: '(min-width: 1920px)',\n\n Handset: '(max-width: 599.98px) and (orientation: portrait), ' +\n '(max-width: 959.98px) and (orientation: landscape)',\n Tablet: '(min-width: 600px) and (max-width: 839.98px) and (orientation: portrait), ' +\n '(min-width: 960px) and (max-width: 1279.98px) and (orientation: landscape)',\n Web: '(min-width: 840px) and (orientation: portrait), ' +\n '(min-width: 1280px) and (orientation: landscape)',\n\n HandsetPortrait: '(max-width: 599.98px) and (orientation: portrait)',\n TabletPortrait: '(min-width: 600px) and (max-width: 839.98px) and (orientation: portrait)',\n WebPortrait: '(min-width: 840px) and (orientation: portrait)',\n\n HandsetLandscape: '(max-width: 959.98px) and (orientation: landscape)',\n TabletLandscape: '(min-width: 960px) and (max-width: 1279.98px) and (orientation: landscape)',\n WebLandscape: '(min-width: 1280px) and (orientation: landscape)',\n};\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport {LayoutModule} from './layout-module';\nexport {BreakpointObserver, BreakpointState} from './breakpoints-observer';\nexport {Breakpoints} from './breakpoints';\nexport {MediaMatcher} from './media-matcher';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;AAAA;;;;;;;MAWa,YAAY;;;YADxB,QAAQ,SAAC,EAAE;;;ACVZ;;;;;;;AAUA;AACA,MAAM,kCAAkC,GAAgB,IAAI,GAAG,EAAU,CAAC;AAE1E;AACA,IAAI,mBAAiD,CAAC;AAEtD;MAEa,YAAY;IAIvB,YAAoB,SAAmB;QAAnB,cAAS,GAAT,SAAS,CAAU;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,IAAI,MAAM,CAAC,UAAU;;;YAG9D,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;YAC9B,cAAc,CAAC;KAClB;;;;;;;IAQD,UAAU,CAAC,KAAa;QACtB,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;YACjD,oBAAoB,CAAC,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;KAChC;;;;YAxBF,UAAU,SAAC,EAAC,UAAU,EAAE,MAAM,EAAC;;;YATxB,QAAQ;;AAoChB;;;;;;;;;AASA,SAAS,oBAAoB,CAAC,KAAa;IACzC,IAAI,kCAAkC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACjD,OAAO;KACR;IAED,IAAI;QACF,IAAI,CAAC,mBAAmB,EAAE;YACxB,mBAAmB,GAAG,QAAQ,CAAC,aAAa,CAAC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E,kDAAkD;QAClD,kDAAkD;IAEvD,eAAe,EAAE,mDAAmD;IACpE,cAAc,EAAE,0EAA0E;IAC1F,WAAW,EAAE,gDAAgD;IAE7D,gBAAgB,EAAE,oDAAoD;IACtE,eAAe,EAAE,4EAA4E;IAC7F,YAAY,EAAE,kDAAkD;;;AC7BlE;;;;;;;;ACAA;;;;;;"}
|
package/fesm2015/overlay.js
CHANGED
|
@@ -7,7 +7,7 @@ import * as i0 from '@angular/core';
|
|
|
7
7
|
import { Injectable, NgZone, Inject, Optional, ElementRef, ApplicationRef, ComponentFactoryResolver, Injector, InjectionToken, Directive, EventEmitter, TemplateRef, ViewContainerRef, Input, Output, NgModule } from '@angular/core';
|
|
8
8
|
import { coerceCssPixelValue, coerceArray, coerceBooleanProperty } from '@angular/cdk/coercion';
|
|
9
9
|
import * as i2 from '@angular/cdk/platform';
|
|
10
|
-
import { supportsScrollBehavior, _getEventTarget, Platform } from '@angular/cdk/platform';
|
|
10
|
+
import { supportsScrollBehavior, _getEventTarget, Platform, _isTestEnvironment } from '@angular/cdk/platform';
|
|
11
11
|
import { Directionality, BidiModule } from '@angular/cdk/bidi';
|
|
12
12
|
import { DomPortalOutlet, TemplatePortal, PortalModule } from '@angular/cdk/portal';
|
|
13
13
|
import { Subject, Subscription, merge } from 'rxjs';
|
|
@@ -676,16 +676,6 @@ OverlayOutsideClickDispatcher.ctorParameters = () => [
|
|
|
676
676
|
* Use of this source code is governed by an MIT-style license that can be
|
|
677
677
|
* found in the LICENSE file at https://angular.io/license
|
|
678
678
|
*/
|
|
679
|
-
const globalsForTest = (typeof window !== 'undefined' ? window : {});
|
|
680
|
-
/**
|
|
681
|
-
* Whether we're in a testing environment.
|
|
682
|
-
* TODO(crisbeto): remove this once we have an overlay testing module or Angular starts tearing
|
|
683
|
-
* down the testing `NgModule` (see https://github.com/angular/angular/issues/18831).
|
|
684
|
-
*/
|
|
685
|
-
const isTestEnvironment = (typeof globalsForTest.__karma__ !== 'undefined' && !!globalsForTest.__karma__) ||
|
|
686
|
-
(typeof globalsForTest.jasmine !== 'undefined' && !!globalsForTest.jasmine) ||
|
|
687
|
-
(typeof globalsForTest.jest !== 'undefined' && !!globalsForTest.jest) ||
|
|
688
|
-
(typeof globalsForTest.Mocha !== 'undefined' && !!globalsForTest.Mocha);
|
|
689
679
|
/** Container inside which all overlays will render. */
|
|
690
680
|
class OverlayContainer {
|
|
691
681
|
constructor(document, _platform) {
|
|
@@ -700,7 +690,7 @@ class OverlayContainer {
|
|
|
700
690
|
}
|
|
701
691
|
/**
|
|
702
692
|
* This method returns the overlay container element. It will lazily
|
|
703
|
-
* create the element the first time
|
|
693
|
+
* create the element the first time it is called to facilitate using
|
|
704
694
|
* the container in non-browser environments.
|
|
705
695
|
* @returns the container element
|
|
706
696
|
*/
|
|
@@ -716,7 +706,10 @@ class OverlayContainer {
|
|
|
716
706
|
*/
|
|
717
707
|
_createContainer() {
|
|
718
708
|
const containerClass = 'cdk-overlay-container';
|
|
719
|
-
|
|
709
|
+
// TODO(crisbeto): remove the testing check once we have an overlay testing
|
|
710
|
+
// module or Angular starts tearing down the testing `NgModule`. See:
|
|
711
|
+
// https://github.com/angular/angular/issues/18831
|
|
712
|
+
if (this._platform.isBrowser || _isTestEnvironment()) {
|
|
720
713
|
const oppositePlatformContainers = this._document.querySelectorAll(`.${containerClass}[platform="server"], ` +
|
|
721
714
|
`.${containerClass}[platform="test"]`);
|
|
722
715
|
// Remove any old containers from the opposite platform.
|
|
@@ -736,7 +729,7 @@ class OverlayContainer {
|
|
|
736
729
|
// module which does the cleanup, we try to detect that we're in a test environment and we
|
|
737
730
|
// always clear the container. See #17006.
|
|
738
731
|
// TODO(crisbeto): remove the test environment check once we have an overlay testing module.
|
|
739
|
-
if (
|
|
732
|
+
if (_isTestEnvironment()) {
|
|
740
733
|
container.setAttribute('platform', 'test');
|
|
741
734
|
}
|
|
742
735
|
else if (!this._platform.isBrowser) {
|
|
@@ -898,7 +891,7 @@ class OverlayRef {
|
|
|
898
891
|
this._positionStrategy.dispose();
|
|
899
892
|
}
|
|
900
893
|
this._disposeScrollStrategy();
|
|
901
|
-
this.
|
|
894
|
+
this._disposeBackdrop(this._backdropElement);
|
|
902
895
|
this._locationChanges.unsubscribe();
|
|
903
896
|
this._keyboardDispatcher.remove(this);
|
|
904
897
|
this._portalOutlet.dispose();
|
|
@@ -1072,25 +1065,17 @@ class OverlayRef {
|
|
|
1072
1065
|
}
|
|
1073
1066
|
/** Detaches the backdrop (if any) associated with the overlay. */
|
|
1074
1067
|
detachBackdrop() {
|
|
1075
|
-
|
|
1068
|
+
const backdropToDetach = this._backdropElement;
|
|
1076
1069
|
if (!backdropToDetach) {
|
|
1077
1070
|
return;
|
|
1078
1071
|
}
|
|
1079
1072
|
let timeoutId;
|
|
1080
|
-
|
|
1073
|
+
const finishDetach = () => {
|
|
1081
1074
|
// It may not be attached to anything in certain cases (e.g. unit tests).
|
|
1082
1075
|
if (backdropToDetach) {
|
|
1083
1076
|
backdropToDetach.removeEventListener('click', this._backdropClickHandler);
|
|
1084
1077
|
backdropToDetach.removeEventListener('transitionend', finishDetach);
|
|
1085
|
-
|
|
1086
|
-
backdropToDetach.parentNode.removeChild(backdropToDetach);
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
// It is possible that a new portal has been attached to this overlay since we started
|
|
1090
|
-
// removing the backdrop. If that is the case, only clear the backdrop reference if it
|
|
1091
|
-
// is still the same instance that we started to remove.
|
|
1092
|
-
if (this._backdropElement == backdropToDetach) {
|
|
1093
|
-
this._backdropElement = null;
|
|
1078
|
+
this._disposeBackdrop(backdropToDetach);
|
|
1094
1079
|
}
|
|
1095
1080
|
if (this._config.backdropClass) {
|
|
1096
1081
|
this._toggleClasses(backdropToDetach, this._config.backdropClass, false);
|
|
@@ -1157,6 +1142,20 @@ class OverlayRef {
|
|
|
1157
1142
|
}
|
|
1158
1143
|
}
|
|
1159
1144
|
}
|
|
1145
|
+
/** Removes a backdrop element from the DOM. */
|
|
1146
|
+
_disposeBackdrop(backdrop) {
|
|
1147
|
+
if (backdrop) {
|
|
1148
|
+
if (backdrop.parentNode) {
|
|
1149
|
+
backdrop.parentNode.removeChild(backdrop);
|
|
1150
|
+
}
|
|
1151
|
+
// It is possible that a new portal has been attached to this overlay since we started
|
|
1152
|
+
// removing the backdrop. If that is the case, only clear the backdrop reference if it
|
|
1153
|
+
// is still the same instance that we started to remove.
|
|
1154
|
+
if (this._backdropElement === backdrop) {
|
|
1155
|
+
this._backdropElement = null;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1160
1159
|
}
|
|
1161
1160
|
|
|
1162
1161
|
/**
|