1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/cdk/coercion'), require('rxjs'), require('rxjs/operators'), require('@angular/cdk/platform')) :
|
3 | typeof define === 'function' && define.amd ? define('@angular/cdk/layout', ['exports', '@angular/core', '@angular/cdk/coercion', 'rxjs', 'rxjs/operators', '@angular/cdk/platform'], factory) :
|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.cdk = global.ng.cdk || {}, global.ng.cdk.layout = {}), global.ng.core, global.ng.cdk.coercion, global.rxjs, global.rxjs.operators, global.ng.cdk.platform));
|
5 | }(this, (function (exports, i0, coercion, rxjs, operators, i1) { 'use strict';
|
6 |
|
7 | function _interopNamespace(e) {
|
8 | if (e && e.__esModule) return e;
|
9 | var n = Object.create(null);
|
10 | if (e) {
|
11 | Object.keys(e).forEach(function (k) {
|
12 | if (k !== 'default') {
|
13 | var d = Object.getOwnPropertyDescriptor(e, k);
|
14 | Object.defineProperty(n, k, d.get ? d : {
|
15 | enumerable: true,
|
16 | get: function () {
|
17 | return e[k];
|
18 | }
|
19 | });
|
20 | }
|
21 | });
|
22 | }
|
23 | n['default'] = e;
|
24 | return Object.freeze(n);
|
25 | }
|
26 |
|
27 | var i0__namespace = _interopNamespace(i0);
|
28 | var i1__namespace = _interopNamespace(i1);
|
29 |
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | var LayoutModule = (function () {
|
38 | function LayoutModule() {
|
39 | }
|
40 | return LayoutModule;
|
41 | }());
|
42 | LayoutModule.decorators = [
|
43 | { type: i0.NgModule, args: [{},] }
|
44 | ];
|
45 |
|
46 | |
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | var mediaQueriesForWebkitCompatibility = new Set();
|
55 |
|
56 | var mediaQueryStyleNode;
|
57 |
|
58 | var MediaMatcher = (function () {
|
59 | function MediaMatcher(_platform) {
|
60 | this._platform = _platform;
|
61 | this._matchMedia = this._platform.isBrowser && window.matchMedia ?
|
62 |
|
63 |
|
64 | window.matchMedia.bind(window) :
|
65 | noopMatchMedia;
|
66 | }
|
67 | |
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | MediaMatcher.prototype.matchMedia = function (query) {
|
74 | if (this._platform.WEBKIT) {
|
75 | createEmptyStyleRule(query);
|
76 | }
|
77 | return this._matchMedia(query);
|
78 | };
|
79 | return MediaMatcher;
|
80 | }());
|
81 | MediaMatcher.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function MediaMatcher_Factory() { return new MediaMatcher(i0__namespace.ɵɵinject(i1__namespace.Platform)); }, token: MediaMatcher, providedIn: "root" });
|
82 | MediaMatcher.decorators = [
|
83 | { type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
84 | ];
|
85 | MediaMatcher.ctorParameters = function () { return [
|
86 | { type: i1.Platform }
|
87 | ]; };
|
88 | |
89 |
|
90 |
|
91 |
|
92 | function createEmptyStyleRule(query) {
|
93 | if (mediaQueriesForWebkitCompatibility.has(query)) {
|
94 | return;
|
95 | }
|
96 | try {
|
97 | if (!mediaQueryStyleNode) {
|
98 | mediaQueryStyleNode = document.createElement('style');
|
99 | mediaQueryStyleNode.setAttribute('type', 'text/css');
|
100 | document.head.appendChild(mediaQueryStyleNode);
|
101 | }
|
102 | if (mediaQueryStyleNode.sheet) {
|
103 | mediaQueryStyleNode.sheet
|
104 | .insertRule("@media " + query + " {.fx-query-test{ }}", 0);
|
105 | mediaQueriesForWebkitCompatibility.add(query);
|
106 | }
|
107 | }
|
108 | catch (e) {
|
109 | console.error(e);
|
110 | }
|
111 | }
|
112 |
|
113 | function noopMatchMedia(query) {
|
114 |
|
115 |
|
116 | return {
|
117 | matches: query === 'all' || query === '',
|
118 | media: query,
|
119 | addListener: function () { },
|
120 | removeListener: function () { }
|
121 | };
|
122 | }
|
123 |
|
124 | |
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 | var BreakpointObserver = (function () {
|
133 | function BreakpointObserver(_mediaMatcher, _zone) {
|
134 | this._mediaMatcher = _mediaMatcher;
|
135 | this._zone = _zone;
|
136 |
|
137 | this._queries = new Map();
|
138 |
|
139 | this._destroySubject = new rxjs.Subject();
|
140 | }
|
141 |
|
142 | BreakpointObserver.prototype.ngOnDestroy = function () {
|
143 | this._destroySubject.next();
|
144 | this._destroySubject.complete();
|
145 | };
|
146 | |
147 |
|
148 |
|
149 |
|
150 |
|
151 | BreakpointObserver.prototype.isMatched = function (value) {
|
152 | var _this = this;
|
153 | var queries = splitQueries(coercion.coerceArray(value));
|
154 | return queries.some(function (mediaQuery) { return _this._registerQuery(mediaQuery).mql.matches; });
|
155 | };
|
156 | |
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 | BreakpointObserver.prototype.observe = function (value) {
|
163 | var _this = this;
|
164 | var queries = splitQueries(coercion.coerceArray(value));
|
165 | var observables = queries.map(function (query) { return _this._registerQuery(query).observable; });
|
166 | var stateObservable = rxjs.combineLatest(observables);
|
167 |
|
168 | stateObservable = rxjs.concat(stateObservable.pipe(operators.take(1)), stateObservable.pipe(operators.skip(1), operators.debounceTime(0)));
|
169 | return stateObservable.pipe(operators.map(function (breakpointStates) {
|
170 | var response = {
|
171 | matches: false,
|
172 | breakpoints: {},
|
173 | };
|
174 | breakpointStates.forEach(function (_a) {
|
175 | var matches = _a.matches, query = _a.query;
|
176 | response.matches = response.matches || matches;
|
177 | response.breakpoints[query] = matches;
|
178 | });
|
179 | return response;
|
180 | }));
|
181 | };
|
182 |
|
183 | BreakpointObserver.prototype._registerQuery = function (query) {
|
184 | var _this = this;
|
185 |
|
186 | if (this._queries.has(query)) {
|
187 | return this._queries.get(query);
|
188 | }
|
189 | var mql = this._mediaMatcher.matchMedia(query);
|
190 |
|
191 | var queryObservable = new rxjs.Observable(function (observer) {
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 | var handler = function (e) { return _this._zone.run(function () { return observer.next(e); }); };
|
198 | mql.addListener(handler);
|
199 | return function () {
|
200 | mql.removeListener(handler);
|
201 | };
|
202 | }).pipe(operators.startWith(mql), operators.map(function (_a) {
|
203 | var matches = _a.matches;
|
204 | return ({ query: query, matches: matches });
|
205 | }), operators.takeUntil(this._destroySubject));
|
206 |
|
207 | var output = { observable: queryObservable, mql: mql };
|
208 | this._queries.set(query, output);
|
209 | return output;
|
210 | };
|
211 | return BreakpointObserver;
|
212 | }());
|
213 | BreakpointObserver.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function BreakpointObserver_Factory() { return new BreakpointObserver(i0__namespace.ɵɵinject(MediaMatcher), i0__namespace.ɵɵinject(i0__namespace.NgZone)); }, token: BreakpointObserver, providedIn: "root" });
|
214 | BreakpointObserver.decorators = [
|
215 | { type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
216 | ];
|
217 | BreakpointObserver.ctorParameters = function () { return [
|
218 | { type: MediaMatcher },
|
219 | { type: i0.NgZone }
|
220 | ]; };
|
221 | |
222 |
|
223 |
|
224 |
|
225 | function splitQueries(queries) {
|
226 | return queries.map(function (query) { return query.split(','); })
|
227 | .reduce(function (a1, a2) { return a1.concat(a2); })
|
228 | .map(function (query) { return query.trim(); });
|
229 | }
|
230 |
|
231 | |
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 | var Breakpoints = {
|
241 | XSmall: '(max-width: 599.98px)',
|
242 | Small: '(min-width: 600px) and (max-width: 959.98px)',
|
243 | Medium: '(min-width: 960px) and (max-width: 1279.98px)',
|
244 | Large: '(min-width: 1280px) and (max-width: 1919.98px)',
|
245 | XLarge: '(min-width: 1920px)',
|
246 | Handset: '(max-width: 599.98px) and (orientation: portrait), ' +
|
247 | '(max-width: 959.98px) and (orientation: landscape)',
|
248 | Tablet: '(min-width: 600px) and (max-width: 839.98px) and (orientation: portrait), ' +
|
249 | '(min-width: 960px) and (max-width: 1279.98px) and (orientation: landscape)',
|
250 | Web: '(min-width: 840px) and (orientation: portrait), ' +
|
251 | '(min-width: 1280px) and (orientation: landscape)',
|
252 | HandsetPortrait: '(max-width: 599.98px) and (orientation: portrait)',
|
253 | TabletPortrait: '(min-width: 600px) and (max-width: 839.98px) and (orientation: portrait)',
|
254 | WebPortrait: '(min-width: 840px) and (orientation: portrait)',
|
255 | HandsetLandscape: '(max-width: 959.98px) and (orientation: landscape)',
|
256 | TabletLandscape: '(min-width: 960px) and (max-width: 1279.98px) and (orientation: landscape)',
|
257 | WebLandscape: '(min-width: 1280px) and (orientation: landscape)',
|
258 | };
|
259 |
|
260 | |
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 | |
269 |
|
270 |
|
271 |
|
272 | exports.BreakpointObserver = BreakpointObserver;
|
273 | exports.Breakpoints = Breakpoints;
|
274 | exports.LayoutModule = LayoutModule;
|
275 | exports.MediaMatcher = MediaMatcher;
|
276 |
|
277 | Object.defineProperty(exports, '__esModule', { value: true });
|
278 |
|
279 | })));
|
280 |
|