/** * @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/cdk/a11y'), require('@angular/cdk/bidi'), require('@angular/cdk/coercion'), require('@angular/forms'), require('@angular/material/core'), require('@angular/platform-browser/animations'), require('@angular/cdk/observers'), require('@angular/platform-browser')) : typeof define === 'function' && define.amd ? define('@angular/material/slide-toggle', ['exports', '@angular/core', '@angular/cdk/a11y', '@angular/cdk/bidi', '@angular/cdk/coercion', '@angular/forms', '@angular/material/core', '@angular/platform-browser/animations', '@angular/cdk/observers', '@angular/platform-browser'], factory) : (factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.slideToggle = {}),global.ng.core,global.ng.cdk.a11y,global.ng.cdk.bidi,global.ng.cdk.coercion,global.ng.forms,global.ng.material.core,global.ng.platformBrowser.animations,global.ng.cdk.observers,global.ng.platformBrowser)); }(this, (function (exports,core,a11y,bidi,coercion,forms,core$1,animations,observers,platformBrowser) { 'use strict'; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * Injection token to be used to override the default options for `mat-slide-toggle`. * @type {?} */ var MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS = new core.InjectionToken('mat-slide-toggle-default-options', { providedIn: 'root', factory: (/** * @return {?} */ function () { return ({ disableToggleValue: false, disableDragValue: false }); }) }); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ // Increasing integer for generating unique ids for slide-toggle components. /** @type {?} */ var nextUniqueId = 0; /** * \@docs-private * @type {?} */ var MAT_SLIDE_TOGGLE_VALUE_ACCESSOR = { provide: forms.NG_VALUE_ACCESSOR, useExisting: core.forwardRef((/** * @return {?} */ function () { return MatSlideToggle; })), multi: true }; /** * Change event object emitted by a MatSlideToggle. */ var /** * Change event object emitted by a MatSlideToggle. */ MatSlideToggleChange = /** @class */ (function () { function MatSlideToggleChange(source, checked) { this.source = source; this.checked = checked; } return MatSlideToggleChange; }()); // Boilerplate for applying mixins to MatSlideToggle. /** * \@docs-private */ var // Boilerplate for applying mixins to MatSlideToggle. /** * \@docs-private */ MatSlideToggleBase = /** @class */ (function () { function MatSlideToggleBase(_elementRef) { this._elementRef = _elementRef; } return MatSlideToggleBase; }()); /** @type {?} */ var _MatSlideToggleMixinBase = core$1.mixinTabIndex(core$1.mixinColor(core$1.mixinDisableRipple(core$1.mixinDisabled(MatSlideToggleBase)), 'accent')); /** * Represents a slidable "switch" toggle that can be moved between on and off. */ var MatSlideToggle = /** @class */ (function (_super) { __extends(MatSlideToggle, _super); function MatSlideToggle(elementRef, _focusMonitor, _changeDetectorRef, tabIndex, _ngZone, defaults, _animationMode, _dir) { var _this = _super.call(this, elementRef) || this; _this._focusMonitor = _focusMonitor; _this._changeDetectorRef = _changeDetectorRef; _this._ngZone = _ngZone; _this.defaults = defaults; _this._animationMode = _animationMode; _this._dir = _dir; _this._onChange = (/** * @param {?} _ * @return {?} */ function (_) { }); _this._onTouched = (/** * @return {?} */ function () { }); _this._uniqueId = "mat-slide-toggle-" + ++nextUniqueId; _this._required = false; _this._checked = false; /** * Whether the thumb is currently being dragged. */ _this._dragging = false; /** * Name value will be applied to the input element if present. */ _this.name = null; /** * A unique id for the slide-toggle input. If none is supplied, it will be auto-generated. */ _this.id = _this._uniqueId; /** * Whether the label should appear after or before the slide-toggle. Defaults to 'after'. */ _this.labelPosition = 'after'; /** * Used to set the aria-label attribute on the underlying input element. */ _this.ariaLabel = null; /** * Used to set the aria-labelledby attribute on the underlying input element. */ _this.ariaLabelledby = null; /** * An event will be dispatched each time the slide-toggle changes its value. */ _this.change = new core.EventEmitter(); /** * An event will be dispatched each time the slide-toggle input is toggled. * This event is always emitted when the user toggles the slide toggle, but this does not mean * the slide toggle's value has changed. The event does not fire when the user drags to change * the slide toggle value. */ _this.toggleChange = new core.EventEmitter(); /** * An event will be dispatched each time the slide-toggle is dragged. * This event is always emitted when the user drags the slide toggle to make a change greater * than 50%. It does not mean the slide toggle's value is changed. The event is not emitted when * the user toggles the slide toggle to change its value. */ _this.dragChange = new core.EventEmitter(); _this.tabIndex = parseInt(tabIndex) || 0; return _this; } Object.defineProperty(MatSlideToggle.prototype, "required", { /** Whether the slide-toggle is required. */ get: /** * Whether the slide-toggle is required. * @return {?} */ function () { return this._required; }, set: /** * @param {?} value * @return {?} */ function (value) { this._required = coercion.coerceBooleanProperty(value); }, enumerable: true, configurable: true }); Object.defineProperty(MatSlideToggle.prototype, "checked", { /** Whether the slide-toggle element is checked or not. */ get: /** * Whether the slide-toggle element is checked or not. * @return {?} */ function () { return this._checked; }, set: /** * @param {?} value * @return {?} */ function (value) { this._checked = coercion.coerceBooleanProperty(value); this._changeDetectorRef.markForCheck(); }, enumerable: true, configurable: true }); Object.defineProperty(MatSlideToggle.prototype, "inputId", { /** Returns the unique id for the visual hidden input. */ get: /** * Returns the unique id for the visual hidden input. * @return {?} */ function () { return (this.id || this._uniqueId) + "-input"; }, enumerable: true, configurable: true }); /** * @return {?} */ MatSlideToggle.prototype.ngAfterContentInit = /** * @return {?} */ function () { var _this = this; this._focusMonitor .monitor(this._elementRef, true) .subscribe((/** * @param {?} focusOrigin * @return {?} */ function (focusOrigin) { if (!focusOrigin) { // When a focused element becomes disabled, the browser *immediately* fires a blur event. // Angular does not expect events to be raised during change detection, so any state // change (such as a form control's 'ng-touched') will cause a changed-after-checked // error. See https://github.com/angular/angular/issues/17793. To work around this, // we defer telling the form control it has been touched until the next tick. Promise.resolve().then((/** * @return {?} */ function () { return _this._onTouched(); })); } })); }; /** * @return {?} */ MatSlideToggle.prototype.ngOnDestroy = /** * @return {?} */ function () { this._focusMonitor.stopMonitoring(this._elementRef); }; /** Method being called whenever the underlying input emits a change event. */ /** * Method being called whenever the underlying input emits a change event. * @param {?} event * @return {?} */ MatSlideToggle.prototype._onChangeEvent = /** * Method being called whenever the underlying input emits a change event. * @param {?} event * @return {?} */ function (event) { // We always have to stop propagation on the change event. // Otherwise the change event, from the input element, will bubble up and // emit its event object to the component's `change` output. event.stopPropagation(); if (!this._dragging) { this.toggleChange.emit(); } // Releasing the pointer over the `