UNPKG

30.5 kBJavaScriptView Raw
1import * as i3 from '@angular/cdk/observers';
2import { ObserversModule } from '@angular/cdk/observers';
3import * as i0 from '@angular/core';
4import { InjectionToken, forwardRef, EventEmitter, Directive, Input, Output, Component, ViewEncapsulation, ChangeDetectionStrategy, Attribute, Inject, Optional, ViewChild, NgModule } from '@angular/core';
5import * as i2 from '@angular/material/core';
6import { mixinTabIndex, mixinColor, mixinDisableRipple, mixinDisabled, MatRippleModule, MatCommonModule } from '@angular/material/core';
7import * as i1 from '@angular/cdk/a11y';
8import { coerceBooleanProperty } from '@angular/cdk/coercion';
9import { NG_VALUE_ACCESSOR, NG_VALIDATORS, CheckboxRequiredValidator } from '@angular/forms';
10import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
11
12/**
13 * @license
14 * Copyright Google LLC All Rights Reserved.
15 *
16 * Use of this source code is governed by an MIT-style license that can be
17 * found in the LICENSE file at https://angular.io/license
18 */
19/** Injection token to be used to override the default options for `mat-slide-toggle`. */
20const MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS = new InjectionToken('mat-slide-toggle-default-options', {
21 providedIn: 'root',
22 factory: () => ({ disableToggleValue: false }),
23});
24
25/**
26 * @license
27 * Copyright Google LLC All Rights Reserved.
28 *
29 * Use of this source code is governed by an MIT-style license that can be
30 * found in the LICENSE file at https://angular.io/license
31 */
32// Increasing integer for generating unique ids for slide-toggle components.
33let nextUniqueId = 0;
34/** @docs-private */
35const MAT_SLIDE_TOGGLE_VALUE_ACCESSOR = {
36 provide: NG_VALUE_ACCESSOR,
37 useExisting: forwardRef(() => MatSlideToggle),
38 multi: true,
39};
40/** Change event object emitted by a MatSlideToggle. */
41class MatSlideToggleChange {
42 constructor(
43 /** The source MatSlideToggle of the event. */
44 source,
45 /** The new `checked` value of the MatSlideToggle. */
46 checked) {
47 this.source = source;
48 this.checked = checked;
49 }
50}
51// Boilerplate for applying mixins to MatSlideToggle.
52/** @docs-private */
53const _MatSlideToggleMixinBase = mixinTabIndex(mixinColor(mixinDisableRipple(mixinDisabled(class {
54 constructor(_elementRef) {
55 this._elementRef = _elementRef;
56 }
57}))));
58class _MatSlideToggleBase extends _MatSlideToggleMixinBase {
59 constructor(elementRef, _focusMonitor, _changeDetectorRef, tabIndex, defaults, animationMode, idPrefix) {
60 super(elementRef);
61 this._focusMonitor = _focusMonitor;
62 this._changeDetectorRef = _changeDetectorRef;
63 this.defaults = defaults;
64 this._onChange = (_) => { };
65 this._onTouched = () => { };
66 this._required = false;
67 this._checked = false;
68 /** Name value will be applied to the input element if present. */
69 this.name = null;
70 /** Whether the label should appear after or before the slide-toggle. Defaults to 'after'. */
71 this.labelPosition = 'after';
72 /** Used to set the aria-label attribute on the underlying input element. */
73 this.ariaLabel = null;
74 /** Used to set the aria-labelledby attribute on the underlying input element. */
75 this.ariaLabelledby = null;
76 /** An event will be dispatched each time the slide-toggle changes its value. */
77 this.change = new EventEmitter();
78 /**
79 * An event will be dispatched each time the slide-toggle input is toggled.
80 * This event is always emitted when the user toggles the slide toggle, but this does not mean
81 * the slide toggle's value has changed.
82 */
83 this.toggleChange = new EventEmitter();
84 this.tabIndex = parseInt(tabIndex) || 0;
85 this.color = this.defaultColor = defaults.color || 'accent';
86 this._noopAnimations = animationMode === 'NoopAnimations';
87 this.id = this._uniqueId = `${idPrefix}${++nextUniqueId}`;
88 }
89 /** Whether the slide-toggle is required. */
90 get required() {
91 return this._required;
92 }
93 set required(value) {
94 this._required = coerceBooleanProperty(value);
95 }
96 /** Whether the slide-toggle element is checked or not. */
97 get checked() {
98 return this._checked;
99 }
100 set checked(value) {
101 this._checked = coerceBooleanProperty(value);
102 this._changeDetectorRef.markForCheck();
103 }
104 /** Returns the unique id for the visual hidden input. */
105 get inputId() {
106 return `${this.id || this._uniqueId}-input`;
107 }
108 ngAfterContentInit() {
109 this._focusMonitor.monitor(this._elementRef, true).subscribe(focusOrigin => {
110 if (focusOrigin === 'keyboard' || focusOrigin === 'program') {
111 this._focused = true;
112 }
113 else if (!focusOrigin) {
114 // When a focused element becomes disabled, the browser *immediately* fires a blur event.
115 // Angular does not expect events to be raised during change detection, so any state
116 // change (such as a form control's ng-touched) will cause a changed-after-checked error.
117 // See https://github.com/angular/angular/issues/17793. To work around this, we defer
118 // telling the form control it has been touched until the next tick.
119 Promise.resolve().then(() => {
120 this._focused = false;
121 this._onTouched();
122 this._changeDetectorRef.markForCheck();
123 });
124 }
125 });
126 }
127 ngOnDestroy() {
128 this._focusMonitor.stopMonitoring(this._elementRef);
129 }
130 /** Implemented as part of ControlValueAccessor. */
131 writeValue(value) {
132 this.checked = !!value;
133 }
134 /** Implemented as part of ControlValueAccessor. */
135 registerOnChange(fn) {
136 this._onChange = fn;
137 }
138 /** Implemented as part of ControlValueAccessor. */
139 registerOnTouched(fn) {
140 this._onTouched = fn;
141 }
142 /** Implemented as a part of ControlValueAccessor. */
143 setDisabledState(isDisabled) {
144 this.disabled = isDisabled;
145 this._changeDetectorRef.markForCheck();
146 }
147 /** Toggles the checked state of the slide-toggle. */
148 toggle() {
149 this.checked = !this.checked;
150 this._onChange(this.checked);
151 }
152 /**
153 * Emits a change event on the `change` output. Also notifies the FormControl about the change.
154 */
155 _emitChangeEvent() {
156 this._onChange(this.checked);
157 this.change.emit(this._createChangeEvent(this.checked));
158 }
159}
160_MatSlideToggleBase.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: _MatSlideToggleBase, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
161_MatSlideToggleBase.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: _MatSlideToggleBase, inputs: { name: "name", id: "id", labelPosition: "labelPosition", ariaLabel: ["aria-label", "ariaLabel"], ariaLabelledby: ["aria-labelledby", "ariaLabelledby"], ariaDescribedby: ["aria-describedby", "ariaDescribedby"], required: "required", checked: "checked" }, outputs: { change: "change", toggleChange: "toggleChange" }, usesInheritance: true, ngImport: i0 });
162i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: _MatSlideToggleBase, decorators: [{
163 type: Directive
164 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.FocusMonitor }, { type: i0.ChangeDetectorRef }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }]; }, propDecorators: { name: [{
165 type: Input
166 }], id: [{
167 type: Input
168 }], labelPosition: [{
169 type: Input
170 }], ariaLabel: [{
171 type: Input,
172 args: ['aria-label']
173 }], ariaLabelledby: [{
174 type: Input,
175 args: ['aria-labelledby']
176 }], ariaDescribedby: [{
177 type: Input,
178 args: ['aria-describedby']
179 }], required: [{
180 type: Input
181 }], checked: [{
182 type: Input
183 }], change: [{
184 type: Output
185 }], toggleChange: [{
186 type: Output
187 }] } });
188/** Represents a slidable "switch" toggle that can be moved between on and off. */
189class MatSlideToggle extends _MatSlideToggleBase {
190 constructor(elementRef, focusMonitor, changeDetectorRef, tabIndex, defaults, animationMode) {
191 super(elementRef, focusMonitor, changeDetectorRef, tabIndex, defaults, animationMode, 'mat-slide-toggle-');
192 }
193 _createChangeEvent(isChecked) {
194 return new MatSlideToggleChange(this, isChecked);
195 }
196 /** Method being called whenever the underlying input emits a change event. */
197 _onChangeEvent(event) {
198 // We always have to stop propagation on the change event.
199 // Otherwise the change event, from the input element, will bubble up and
200 // emit its event object to the component's `change` output.
201 event.stopPropagation();
202 this.toggleChange.emit();
203 // When the slide toggle's config disables toggle change event by setting
204 // `disableToggleValue: true`, the slide toggle's value does not change, and the
205 // checked state of the underlying input needs to be changed back.
206 if (this.defaults.disableToggleValue) {
207 this._inputElement.nativeElement.checked = this.checked;
208 return;
209 }
210 // Sync the value from the underlying input element with the component instance.
211 this.checked = this._inputElement.nativeElement.checked;
212 // Emit our custom change event only if the underlying input emitted one. This ensures that
213 // there is no change event, when the checked state changes programmatically.
214 this._emitChangeEvent();
215 }
216 /** Method being called whenever the slide-toggle has been clicked. */
217 _onInputClick(event) {
218 // We have to stop propagation for click events on the visual hidden input element.
219 // By default, when a user clicks on a label element, a generated click event will be
220 // dispatched on the associated input element. Since we are using a label element as our
221 // root container, the click event on the `slide-toggle` will be executed twice.
222 // The real click event will bubble up, and the generated click event also tries to bubble up.
223 // This will lead to multiple click events.
224 // Preventing bubbling for the second event will solve that issue.
225 event.stopPropagation();
226 }
227 /** Focuses the slide-toggle. */
228 focus(options, origin) {
229 if (origin) {
230 this._focusMonitor.focusVia(this._inputElement, origin, options);
231 }
232 else {
233 this._inputElement.nativeElement.focus(options);
234 }
235 }
236 /** Method being called whenever the label text changes. */
237 _onLabelTextChange() {
238 // Since the event of the `cdkObserveContent` directive runs outside of the zone, the
239 // slide-toggle component will be only marked for check, but no actual change detection runs
240 // automatically. Instead of going back into the zone in order to trigger a change detection
241 // which causes *all* components to be checked (if explicitly marked or not using OnPush),
242 // we only trigger an explicit change detection for the slide-toggle view and its children.
243 this._changeDetectorRef.detectChanges();
244 }
245}
246MatSlideToggle.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatSlideToggle, deps: [{ token: i0.ElementRef }, { token: i1.FocusMonitor }, { token: i0.ChangeDetectorRef }, { token: 'tabindex', attribute: true }, { token: MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS }, { token: ANIMATION_MODULE_TYPE, optional: true }], target: i0.ɵɵFactoryTarget.Component });
247MatSlideToggle.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.1", type: MatSlideToggle, selector: "mat-slide-toggle", inputs: { disabled: "disabled", disableRipple: "disableRipple", color: "color", tabIndex: "tabIndex" }, host: { properties: { "id": "id", "attr.tabindex": "null", "attr.aria-label": "null", "attr.aria-labelledby": "null", "attr.name": "null", "class.mat-checked": "checked", "class.mat-disabled": "disabled", "class.mat-slide-toggle-label-before": "labelPosition == \"before\"", "class._mat-animation-noopable": "_noopAnimations" }, classAttribute: "mat-slide-toggle" }, providers: [MAT_SLIDE_TOGGLE_VALUE_ACCESSOR], viewQueries: [{ propertyName: "_inputElement", first: true, predicate: ["input"], descendants: true }], exportAs: ["matSlideToggle"], usesInheritance: true, ngImport: i0, template: "<label [attr.for]=\"inputId\" class=\"mat-slide-toggle-label\" #label>\n <span class=\"mat-slide-toggle-bar\"\n [class.mat-slide-toggle-bar-no-side-margin]=\"!labelContent.textContent || !labelContent.textContent.trim()\">\n\n <input #input class=\"mat-slide-toggle-input cdk-visually-hidden\" type=\"checkbox\"\n role=\"switch\"\n [id]=\"inputId\"\n [required]=\"required\"\n [tabIndex]=\"tabIndex\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n [attr.name]=\"name\"\n [attr.aria-checked]=\"checked\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-describedby]=\"ariaDescribedby\"\n (change)=\"_onChangeEvent($event)\"\n (click)=\"_onInputClick($event)\">\n\n <span class=\"mat-slide-toggle-thumb-container\">\n <span class=\"mat-slide-toggle-thumb\"></span>\n <span class=\"mat-slide-toggle-ripple mat-focus-indicator\" mat-ripple\n [matRippleTrigger]=\"label\"\n [matRippleDisabled]=\"disableRipple || disabled\"\n [matRippleCentered]=\"true\"\n [matRippleRadius]=\"20\"\n [matRippleAnimation]=\"{enterDuration: _noopAnimations ? 0 : 150}\">\n\n <span class=\"mat-ripple-element mat-slide-toggle-persistent-ripple\"></span>\n </span>\n </span>\n\n </span>\n\n <span class=\"mat-slide-toggle-content\" #labelContent (cdkObserveContent)=\"_onLabelTextChange()\">\n <!-- Add an invisible span so JAWS can read the label -->\n <span style=\"display:none\">&nbsp;</span>\n <ng-content></ng-content>\n </span>\n</label>\n", styles: [".mat-slide-toggle{display:inline-block;height:24px;max-width:100%;line-height:24px;white-space:nowrap;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mat-slide-toggle.mat-checked .mat-slide-toggle-thumb-container{transform:translate3d(16px, 0, 0)}[dir=rtl] .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb-container{transform:translate3d(-16px, 0, 0)}.mat-slide-toggle.mat-disabled{opacity:.38}.mat-slide-toggle.mat-disabled .mat-slide-toggle-label,.mat-slide-toggle.mat-disabled .mat-slide-toggle-thumb-container{cursor:default}.mat-slide-toggle-label{-webkit-user-select:none;user-select:none;display:flex;flex:1;flex-direction:row;align-items:center;height:inherit;cursor:pointer}.mat-slide-toggle-content{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mat-slide-toggle-label-before .mat-slide-toggle-label{order:1}.mat-slide-toggle-label-before .mat-slide-toggle-bar{order:2}[dir=rtl] .mat-slide-toggle-label-before .mat-slide-toggle-bar,.mat-slide-toggle-bar{margin-right:8px;margin-left:0}[dir=rtl] .mat-slide-toggle-bar,.mat-slide-toggle-label-before .mat-slide-toggle-bar{margin-left:8px;margin-right:0}.mat-slide-toggle-bar-no-side-margin{margin-left:0;margin-right:0}.mat-slide-toggle-thumb-container{position:absolute;z-index:1;width:20px;height:20px;top:-3px;left:0;transform:translate3d(0, 0, 0);transition:all 80ms linear;transition-property:transform}._mat-animation-noopable .mat-slide-toggle-thumb-container{transition:none}[dir=rtl] .mat-slide-toggle-thumb-container{left:auto;right:0}.mat-slide-toggle-thumb{height:20px;width:20px;border-radius:50%;display:block}.mat-slide-toggle-bar{position:relative;width:36px;height:14px;flex-shrink:0;border-radius:8px}.mat-slide-toggle-input{bottom:0;left:10px}[dir=rtl] .mat-slide-toggle-input{left:auto;right:10px}.mat-slide-toggle-bar,.mat-slide-toggle-thumb{transition:all 80ms linear;transition-property:background-color;transition-delay:50ms}._mat-animation-noopable .mat-slide-toggle-bar,._mat-animation-noopable .mat-slide-toggle-thumb{transition:none}.mat-slide-toggle .mat-slide-toggle-ripple{position:absolute;top:calc(50% - 20px);left:calc(50% - 20px);height:40px;width:40px;z-index:1;pointer-events:none}.mat-slide-toggle .mat-slide-toggle-ripple .mat-ripple-element:not(.mat-slide-toggle-persistent-ripple){opacity:.12}.mat-slide-toggle-persistent-ripple{width:100%;height:100%;transform:none}.mat-slide-toggle-bar:hover .mat-slide-toggle-persistent-ripple{opacity:.04}.mat-slide-toggle:not(.mat-disabled).cdk-keyboard-focused .mat-slide-toggle-persistent-ripple{opacity:.12}.mat-slide-toggle-persistent-ripple,.mat-slide-toggle.mat-disabled .mat-slide-toggle-bar:hover .mat-slide-toggle-persistent-ripple{opacity:0}@media(hover: none){.mat-slide-toggle-bar:hover .mat-slide-toggle-persistent-ripple{display:none}}.cdk-high-contrast-active .mat-slide-toggle-thumb,.cdk-high-contrast-active .mat-slide-toggle-bar{border:1px solid}.cdk-high-contrast-active .mat-slide-toggle.cdk-keyboard-focused .mat-slide-toggle-bar{outline:2px dotted;outline-offset:5px}"], dependencies: [{ kind: "directive", type: i2.MatRipple, selector: "[mat-ripple], [matRipple]", inputs: ["matRippleColor", "matRippleUnbounded", "matRippleCentered", "matRippleRadius", "matRippleAnimation", "matRippleDisabled", "matRippleTrigger"], exportAs: ["matRipple"] }, { kind: "directive", type: i3.CdkObserveContent, selector: "[cdkObserveContent]", inputs: ["cdkObserveContentDisabled", "debounce"], outputs: ["cdkObserveContent"], exportAs: ["cdkObserveContent"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
248i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatSlideToggle, decorators: [{
249 type: Component,
250 args: [{ selector: 'mat-slide-toggle', exportAs: 'matSlideToggle', host: {
251 'class': 'mat-slide-toggle',
252 '[id]': 'id',
253 // Needs to be removed since it causes some a11y issues (see #21266).
254 '[attr.tabindex]': 'null',
255 '[attr.aria-label]': 'null',
256 '[attr.aria-labelledby]': 'null',
257 '[attr.name]': 'null',
258 '[class.mat-checked]': 'checked',
259 '[class.mat-disabled]': 'disabled',
260 '[class.mat-slide-toggle-label-before]': 'labelPosition == "before"',
261 '[class._mat-animation-noopable]': '_noopAnimations',
262 }, providers: [MAT_SLIDE_TOGGLE_VALUE_ACCESSOR], inputs: ['disabled', 'disableRipple', 'color', 'tabIndex'], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<label [attr.for]=\"inputId\" class=\"mat-slide-toggle-label\" #label>\n <span class=\"mat-slide-toggle-bar\"\n [class.mat-slide-toggle-bar-no-side-margin]=\"!labelContent.textContent || !labelContent.textContent.trim()\">\n\n <input #input class=\"mat-slide-toggle-input cdk-visually-hidden\" type=\"checkbox\"\n role=\"switch\"\n [id]=\"inputId\"\n [required]=\"required\"\n [tabIndex]=\"tabIndex\"\n [checked]=\"checked\"\n [disabled]=\"disabled\"\n [attr.name]=\"name\"\n [attr.aria-checked]=\"checked\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-describedby]=\"ariaDescribedby\"\n (change)=\"_onChangeEvent($event)\"\n (click)=\"_onInputClick($event)\">\n\n <span class=\"mat-slide-toggle-thumb-container\">\n <span class=\"mat-slide-toggle-thumb\"></span>\n <span class=\"mat-slide-toggle-ripple mat-focus-indicator\" mat-ripple\n [matRippleTrigger]=\"label\"\n [matRippleDisabled]=\"disableRipple || disabled\"\n [matRippleCentered]=\"true\"\n [matRippleRadius]=\"20\"\n [matRippleAnimation]=\"{enterDuration: _noopAnimations ? 0 : 150}\">\n\n <span class=\"mat-ripple-element mat-slide-toggle-persistent-ripple\"></span>\n </span>\n </span>\n\n </span>\n\n <span class=\"mat-slide-toggle-content\" #labelContent (cdkObserveContent)=\"_onLabelTextChange()\">\n <!-- Add an invisible span so JAWS can read the label -->\n <span style=\"display:none\">&nbsp;</span>\n <ng-content></ng-content>\n </span>\n</label>\n", styles: [".mat-slide-toggle{display:inline-block;height:24px;max-width:100%;line-height:24px;white-space:nowrap;outline:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mat-slide-toggle.mat-checked .mat-slide-toggle-thumb-container{transform:translate3d(16px, 0, 0)}[dir=rtl] .mat-slide-toggle.mat-checked .mat-slide-toggle-thumb-container{transform:translate3d(-16px, 0, 0)}.mat-slide-toggle.mat-disabled{opacity:.38}.mat-slide-toggle.mat-disabled .mat-slide-toggle-label,.mat-slide-toggle.mat-disabled .mat-slide-toggle-thumb-container{cursor:default}.mat-slide-toggle-label{-webkit-user-select:none;user-select:none;display:flex;flex:1;flex-direction:row;align-items:center;height:inherit;cursor:pointer}.mat-slide-toggle-content{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.mat-slide-toggle-label-before .mat-slide-toggle-label{order:1}.mat-slide-toggle-label-before .mat-slide-toggle-bar{order:2}[dir=rtl] .mat-slide-toggle-label-before .mat-slide-toggle-bar,.mat-slide-toggle-bar{margin-right:8px;margin-left:0}[dir=rtl] .mat-slide-toggle-bar,.mat-slide-toggle-label-before .mat-slide-toggle-bar{margin-left:8px;margin-right:0}.mat-slide-toggle-bar-no-side-margin{margin-left:0;margin-right:0}.mat-slide-toggle-thumb-container{position:absolute;z-index:1;width:20px;height:20px;top:-3px;left:0;transform:translate3d(0, 0, 0);transition:all 80ms linear;transition-property:transform}._mat-animation-noopable .mat-slide-toggle-thumb-container{transition:none}[dir=rtl] .mat-slide-toggle-thumb-container{left:auto;right:0}.mat-slide-toggle-thumb{height:20px;width:20px;border-radius:50%;display:block}.mat-slide-toggle-bar{position:relative;width:36px;height:14px;flex-shrink:0;border-radius:8px}.mat-slide-toggle-input{bottom:0;left:10px}[dir=rtl] .mat-slide-toggle-input{left:auto;right:10px}.mat-slide-toggle-bar,.mat-slide-toggle-thumb{transition:all 80ms linear;transition-property:background-color;transition-delay:50ms}._mat-animation-noopable .mat-slide-toggle-bar,._mat-animation-noopable .mat-slide-toggle-thumb{transition:none}.mat-slide-toggle .mat-slide-toggle-ripple{position:absolute;top:calc(50% - 20px);left:calc(50% - 20px);height:40px;width:40px;z-index:1;pointer-events:none}.mat-slide-toggle .mat-slide-toggle-ripple .mat-ripple-element:not(.mat-slide-toggle-persistent-ripple){opacity:.12}.mat-slide-toggle-persistent-ripple{width:100%;height:100%;transform:none}.mat-slide-toggle-bar:hover .mat-slide-toggle-persistent-ripple{opacity:.04}.mat-slide-toggle:not(.mat-disabled).cdk-keyboard-focused .mat-slide-toggle-persistent-ripple{opacity:.12}.mat-slide-toggle-persistent-ripple,.mat-slide-toggle.mat-disabled .mat-slide-toggle-bar:hover .mat-slide-toggle-persistent-ripple{opacity:0}@media(hover: none){.mat-slide-toggle-bar:hover .mat-slide-toggle-persistent-ripple{display:none}}.cdk-high-contrast-active .mat-slide-toggle-thumb,.cdk-high-contrast-active .mat-slide-toggle-bar{border:1px solid}.cdk-high-contrast-active .mat-slide-toggle.cdk-keyboard-focused .mat-slide-toggle-bar{outline:2px dotted;outline-offset:5px}"] }]
263 }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i1.FocusMonitor }, { type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
264 type: Attribute,
265 args: ['tabindex']
266 }] }, { type: undefined, decorators: [{
267 type: Inject,
268 args: [MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS]
269 }] }, { type: undefined, decorators: [{
270 type: Optional
271 }, {
272 type: Inject,
273 args: [ANIMATION_MODULE_TYPE]
274 }] }]; }, propDecorators: { _inputElement: [{
275 type: ViewChild,
276 args: ['input']
277 }] } });
278
279/**
280 * @license
281 * Copyright Google LLC All Rights Reserved.
282 *
283 * Use of this source code is governed by an MIT-style license that can be
284 * found in the LICENSE file at https://angular.io/license
285 */
286const MAT_SLIDE_TOGGLE_REQUIRED_VALIDATOR = {
287 provide: NG_VALIDATORS,
288 useExisting: forwardRef(() => MatSlideToggleRequiredValidator),
289 multi: true,
290};
291/**
292 * Validator for Material slide-toggle components with the required attribute in a
293 * template-driven form. The default validator for required form controls asserts
294 * that the control value is not undefined but that is not appropriate for a slide-toggle
295 * where the value is always defined.
296 *
297 * Required slide-toggle form controls are valid when checked.
298 */
299class MatSlideToggleRequiredValidator extends CheckboxRequiredValidator {
300}
301MatSlideToggleRequiredValidator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatSlideToggleRequiredValidator, deps: null, target: i0.ɵɵFactoryTarget.Directive });
302MatSlideToggleRequiredValidator.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.1", type: MatSlideToggleRequiredValidator, selector: "mat-slide-toggle[required][formControlName],\n mat-slide-toggle[required][formControl], mat-slide-toggle[required][ngModel]", providers: [MAT_SLIDE_TOGGLE_REQUIRED_VALIDATOR], usesInheritance: true, ngImport: i0 });
303i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatSlideToggleRequiredValidator, decorators: [{
304 type: Directive,
305 args: [{
306 selector: `mat-slide-toggle[required][formControlName],
307 mat-slide-toggle[required][formControl], mat-slide-toggle[required][ngModel]`,
308 providers: [MAT_SLIDE_TOGGLE_REQUIRED_VALIDATOR],
309 }]
310 }] });
311
312/**
313 * @license
314 * Copyright Google LLC All Rights Reserved.
315 *
316 * Use of this source code is governed by an MIT-style license that can be
317 * found in the LICENSE file at https://angular.io/license
318 */
319/** This module is used by both original and MDC-based slide-toggle implementations. */
320class _MatSlideToggleRequiredValidatorModule {
321}
322_MatSlideToggleRequiredValidatorModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: _MatSlideToggleRequiredValidatorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
323_MatSlideToggleRequiredValidatorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.1", ngImport: i0, type: _MatSlideToggleRequiredValidatorModule, declarations: [MatSlideToggleRequiredValidator], exports: [MatSlideToggleRequiredValidator] });
324_MatSlideToggleRequiredValidatorModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: _MatSlideToggleRequiredValidatorModule });
325i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: _MatSlideToggleRequiredValidatorModule, decorators: [{
326 type: NgModule,
327 args: [{
328 exports: [MatSlideToggleRequiredValidator],
329 declarations: [MatSlideToggleRequiredValidator],
330 }]
331 }] });
332class MatSlideToggleModule {
333}
334MatSlideToggleModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatSlideToggleModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
335MatSlideToggleModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.1", ngImport: i0, type: MatSlideToggleModule, declarations: [MatSlideToggle], imports: [_MatSlideToggleRequiredValidatorModule, MatRippleModule,
336 MatCommonModule,
337 ObserversModule], exports: [_MatSlideToggleRequiredValidatorModule, MatSlideToggle, MatCommonModule] });
338MatSlideToggleModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatSlideToggleModule, imports: [_MatSlideToggleRequiredValidatorModule,
339 MatRippleModule,
340 MatCommonModule,
341 ObserversModule, _MatSlideToggleRequiredValidatorModule, MatCommonModule] });
342i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.1", ngImport: i0, type: MatSlideToggleModule, decorators: [{
343 type: NgModule,
344 args: [{
345 imports: [
346 _MatSlideToggleRequiredValidatorModule,
347 MatRippleModule,
348 MatCommonModule,
349 ObserversModule,
350 ],
351 exports: [_MatSlideToggleRequiredValidatorModule, MatSlideToggle, MatCommonModule],
352 declarations: [MatSlideToggle],
353 }]
354 }] });
355
356/**
357 * @license
358 * Copyright Google LLC All Rights Reserved.
359 *
360 * Use of this source code is governed by an MIT-style license that can be
361 * found in the LICENSE file at https://angular.io/license
362 */
363
364/**
365 * @license
366 * Copyright Google LLC All Rights Reserved.
367 *
368 * Use of this source code is governed by an MIT-style license that can be
369 * found in the LICENSE file at https://angular.io/license
370 */
371
372/**
373 * Generated bundle index. Do not edit.
374 */
375
376export { MAT_SLIDE_TOGGLE_DEFAULT_OPTIONS, MAT_SLIDE_TOGGLE_REQUIRED_VALIDATOR, MAT_SLIDE_TOGGLE_VALUE_ACCESSOR, MatSlideToggle, MatSlideToggleChange, MatSlideToggleModule, MatSlideToggleRequiredValidator, _MatSlideToggleBase, _MatSlideToggleRequiredValidatorModule };
377//# sourceMappingURL=slide-toggle.mjs.map