UNPKG

@angular/cdk

Version:

Angular Material Component Development Kit

198 lines (190 loc) 7.18 kB
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common')) : typeof define === 'function' && define.amd ? define('@angular/cdk/platform', ['exports', '@angular/core', '@angular/common'], factory) : (factory((global.ng = global.ng || {}, global.ng.cdk = global.ng.cdk || {}, global.ng.cdk.platform = {}),global.ng.core,global.ng.common)); }(this, (function (exports,core,common) { 'use strict'; /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ // Whether the current platform supports the V8 Break Iterator. The V8 check // is necessary to detect all Blink based browsers. var /** @type {?} */ hasV8BreakIterator = (typeof Intl !== 'undefined' && (/** @type {?} */ (Intl)).v8BreakIterator); /** * Service to detect the current platform by comparing the userAgent strings and * checking browser-specific global properties. */ var Platform = /** @class */ (function () { /** * @breaking-change v7.0.0 remove optional decorator */ function Platform(_platformId) { this._platformId = _platformId; /** * Whether the Angular application is being rendered in the browser. * We want to use the Angular platform check because if the Document is shimmed * without the navigator, the following checks will fail. This is preferred because * sometimes the Document may be shimmed without the user's knowledge or intention */ this.isBrowser = this._platformId ? common.isPlatformBrowser(this._platformId) : typeof document === 'object' && !!document; /** * Whether the current browser is Microsoft Edge. */ this.EDGE = this.isBrowser && /(edge)/i.test(navigator.userAgent); /** * Whether the current rendering engine is Microsoft Trident. */ this.TRIDENT = this.isBrowser && /(msie|trident)/i.test(navigator.userAgent); /** * Whether the current rendering engine is Blink. */ this.BLINK = this.isBrowser && (!!((/** @type {?} */ (window)).chrome || hasV8BreakIterator) && typeof CSS !== 'undefined' && !this.EDGE && !this.TRIDENT); /** * Whether the current rendering engine is WebKit. */ this.WEBKIT = this.isBrowser && /AppleWebKit/i.test(navigator.userAgent) && !this.BLINK && !this.EDGE && !this.TRIDENT; /** * Whether the current platform is Apple iOS. */ this.IOS = this.isBrowser && /iPad|iPhone|iPod/.test(navigator.userAgent) && !(/** @type {?} */ (window)).MSStream; /** * Whether the current browser is Firefox. */ this.FIREFOX = this.isBrowser && /(firefox|minefield)/i.test(navigator.userAgent); /** * Whether the current platform is Android. */ this.ANDROID = this.isBrowser && /android/i.test(navigator.userAgent) && !this.TRIDENT; /** * Whether the current browser is Safari. */ this.SAFARI = this.isBrowser && /safari/i.test(navigator.userAgent) && this.WEBKIT; } Platform.decorators = [ { type: core.Injectable, args: [{ providedIn: 'root' },] }, ]; /** @nocollapse */ Platform.ctorParameters = function () { return [ { type: Object, decorators: [{ type: core.Optional }, { type: core.Inject, args: [core.PLATFORM_ID,] },] }, ]; }; /** @nocollapse */ Platform.ngInjectableDef = core.defineInjectable({ factory: function Platform_Factory() { return new Platform(core.inject(core.PLATFORM_ID, 8)); }, token: Platform, providedIn: "root" }); return Platform; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ /** * Cached result of whether the user's browser supports passive event listeners. */ var /** @type {?} */ supportsPassiveEvents; /** * Checks whether the user's browser supports passive event listeners. * See: https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md * @return {?} */ function supportsPassiveEventListeners() { if (supportsPassiveEvents == null && typeof window !== 'undefined') { try { window.addEventListener('test', /** @type {?} */ ((null)), Object.defineProperty({}, 'passive', { get: function () { return supportsPassiveEvents = true; } })); } finally { supportsPassiveEvents = supportsPassiveEvents || false; } } return supportsPassiveEvents; } /** * Check whether the browser supports scroll behaviors. * @return {?} */ function supportsScrollBehavior() { return !!(document && document.documentElement && document.documentElement.style && 'scrollBehavior' in document.documentElement.style); } /** * Cached result Set of input types support by the current browser. */ var /** @type {?} */ supportedInputTypes; /** * Types of `<input>` that *might* be supported. */ var /** @type {?} */ candidateInputTypes = [ 'color', 'button', 'checkbox', 'date', 'datetime-local', 'email', 'file', 'hidden', 'image', 'month', 'number', 'password', 'radio', 'range', 'reset', 'search', 'submit', 'tel', 'text', 'time', 'url', 'week', ]; /** * @return {?} The input types supported by this browser. */ function getSupportedInputTypes() { // Result is cached. if (supportedInputTypes) { return supportedInputTypes; } // We can't check if an input type is not supported until we're on the browser, so say that // everything is supported when not on the browser. We don't use `Platform` here since it's // just a helper function and can't inject it. if (typeof document !== 'object' || !document) { supportedInputTypes = new Set(candidateInputTypes); return supportedInputTypes; } var /** @type {?} */ featureTestInput = document.createElement('input'); supportedInputTypes = new Set(candidateInputTypes.filter(function (value) { featureTestInput.setAttribute('type', value); return featureTestInput.type === value; })); return supportedInputTypes; } /** * @fileoverview added by tsickle * @suppress {checkTypes} checked by tsc */ var PlatformModule = /** @class */ (function () { function PlatformModule() { } PlatformModule.decorators = [ { type: core.NgModule }, ]; return PlatformModule; }()); exports.Platform = Platform; exports.supportsPassiveEventListeners = supportsPassiveEventListeners; exports.supportsScrollBehavior = supportsScrollBehavior; exports.getSupportedInputTypes = getSupportedInputTypes; exports.PlatformModule = PlatformModule; Object.defineProperty(exports, '__esModule', { value: true }); }))); //# sourceMappingURL=cdk-platform.umd.js.map