[6a3a178] | 1 | import { FocusMonitor } from '@angular/cdk/a11y';
|
---|
| 2 | import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
---|
| 3 | import { InjectionToken, forwardRef, EventEmitter, Component, ViewEncapsulation, ChangeDetectionStrategy, ElementRef, ChangeDetectorRef, NgZone, Attribute, Optional, Inject, Input, Output, ViewChild, Directive, NgModule } from '@angular/core';
|
---|
| 4 | import { NG_VALUE_ACCESSOR, NG_VALIDATORS, CheckboxRequiredValidator } from '@angular/forms';
|
---|
| 5 | import { mixinTabIndex, mixinColor, mixinDisableRipple, mixinDisabled, MatRipple, MatRippleModule, MatCommonModule } from '@angular/material/core';
|
---|
| 6 | import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
|
---|
| 7 | import { ObserversModule } from '@angular/cdk/observers';
|
---|
| 8 |
|
---|
| 9 | /**
|
---|
| 10 | * @license
|
---|
| 11 | * Copyright Google LLC All Rights Reserved.
|
---|
| 12 | *
|
---|
| 13 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 14 | * found in the LICENSE file at https://angular.io/license
|
---|
| 15 | */
|
---|
| 16 | /** Injection token to be used to override the default options for `mat-checkbox`. */
|
---|
| 17 | const MAT_CHECKBOX_DEFAULT_OPTIONS = new InjectionToken('mat-checkbox-default-options', {
|
---|
| 18 | providedIn: 'root',
|
---|
| 19 | factory: MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY
|
---|
| 20 | });
|
---|
| 21 | /** @docs-private */
|
---|
| 22 | function MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY() {
|
---|
| 23 | return {
|
---|
| 24 | color: 'accent',
|
---|
| 25 | clickAction: 'check-indeterminate',
|
---|
| 26 | };
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | /**
|
---|
| 30 | * @license
|
---|
| 31 | * Copyright Google LLC All Rights Reserved.
|
---|
| 32 | *
|
---|
| 33 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 34 | * found in the LICENSE file at https://angular.io/license
|
---|
| 35 | */
|
---|
| 36 | // Increasing integer for generating unique ids for checkbox components.
|
---|
| 37 | let nextUniqueId = 0;
|
---|
| 38 | // Default checkbox configuration.
|
---|
| 39 | const defaults = MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY();
|
---|
| 40 | /**
|
---|
| 41 | * Provider Expression that allows mat-checkbox to register as a ControlValueAccessor.
|
---|
| 42 | * This allows it to support [(ngModel)].
|
---|
| 43 | * @docs-private
|
---|
| 44 | */
|
---|
| 45 | const MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR = {
|
---|
| 46 | provide: NG_VALUE_ACCESSOR,
|
---|
| 47 | useExisting: forwardRef(() => MatCheckbox),
|
---|
| 48 | multi: true
|
---|
| 49 | };
|
---|
| 50 | /** Change event object emitted by MatCheckbox. */
|
---|
| 51 | class MatCheckboxChange {
|
---|
| 52 | }
|
---|
| 53 | // Boilerplate for applying mixins to MatCheckbox.
|
---|
| 54 | /** @docs-private */
|
---|
| 55 | const _MatCheckboxBase = mixinTabIndex(mixinColor(mixinDisableRipple(mixinDisabled(class {
|
---|
| 56 | constructor(_elementRef) {
|
---|
| 57 | this._elementRef = _elementRef;
|
---|
| 58 | }
|
---|
| 59 | }))));
|
---|
| 60 | /**
|
---|
| 61 | * A material design checkbox component. Supports all of the functionality of an HTML5 checkbox,
|
---|
| 62 | * and exposes a similar API. A MatCheckbox can be either checked, unchecked, indeterminate, or
|
---|
| 63 | * disabled. Note that all additional accessibility attributes are taken care of by the component,
|
---|
| 64 | * so there is no need to provide them yourself. However, if you want to omit a label and still
|
---|
| 65 | * have the checkbox be accessible, you may supply an [aria-label] input.
|
---|
| 66 | * See: https://material.io/design/components/selection-controls.html
|
---|
| 67 | */
|
---|
| 68 | class MatCheckbox extends _MatCheckboxBase {
|
---|
| 69 | constructor(elementRef, _changeDetectorRef, _focusMonitor, _ngZone, tabIndex, _animationMode, _options) {
|
---|
| 70 | super(elementRef);
|
---|
| 71 | this._changeDetectorRef = _changeDetectorRef;
|
---|
| 72 | this._focusMonitor = _focusMonitor;
|
---|
| 73 | this._ngZone = _ngZone;
|
---|
| 74 | this._animationMode = _animationMode;
|
---|
| 75 | this._options = _options;
|
---|
| 76 | /**
|
---|
| 77 | * Attached to the aria-label attribute of the host element. In most cases, aria-labelledby will
|
---|
| 78 | * take precedence so this may be omitted.
|
---|
| 79 | */
|
---|
| 80 | this.ariaLabel = '';
|
---|
| 81 | /**
|
---|
| 82 | * Users can specify the `aria-labelledby` attribute which will be forwarded to the input element
|
---|
| 83 | */
|
---|
| 84 | this.ariaLabelledby = null;
|
---|
| 85 | this._uniqueId = `mat-checkbox-${++nextUniqueId}`;
|
---|
| 86 | /** A unique id for the checkbox input. If none is supplied, it will be auto-generated. */
|
---|
| 87 | this.id = this._uniqueId;
|
---|
| 88 | /** Whether the label should appear after or before the checkbox. Defaults to 'after' */
|
---|
| 89 | this.labelPosition = 'after';
|
---|
| 90 | /** Name value will be applied to the input element if present */
|
---|
| 91 | this.name = null;
|
---|
| 92 | /** Event emitted when the checkbox's `checked` value changes. */
|
---|
| 93 | this.change = new EventEmitter();
|
---|
| 94 | /** Event emitted when the checkbox's `indeterminate` value changes. */
|
---|
| 95 | this.indeterminateChange = new EventEmitter();
|
---|
| 96 | /**
|
---|
| 97 | * Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor.
|
---|
| 98 | * @docs-private
|
---|
| 99 | */
|
---|
| 100 | this._onTouched = () => { };
|
---|
| 101 | this._currentAnimationClass = '';
|
---|
| 102 | this._currentCheckState = 0 /* Init */;
|
---|
| 103 | this._controlValueAccessorChangeFn = () => { };
|
---|
| 104 | this._checked = false;
|
---|
| 105 | this._disabled = false;
|
---|
| 106 | this._indeterminate = false;
|
---|
| 107 | this._options = this._options || defaults;
|
---|
| 108 | this.color = this.defaultColor = this._options.color || defaults.color;
|
---|
| 109 | this.tabIndex = parseInt(tabIndex) || 0;
|
---|
| 110 | }
|
---|
| 111 | /** Returns the unique id for the visual hidden input. */
|
---|
| 112 | get inputId() { return `${this.id || this._uniqueId}-input`; }
|
---|
| 113 | /** Whether the checkbox is required. */
|
---|
| 114 | get required() { return this._required; }
|
---|
| 115 | set required(value) { this._required = coerceBooleanProperty(value); }
|
---|
| 116 | ngAfterViewInit() {
|
---|
| 117 | this._focusMonitor.monitor(this._elementRef, true).subscribe(focusOrigin => {
|
---|
| 118 | if (!focusOrigin) {
|
---|
| 119 | // When a focused element becomes disabled, the browser *immediately* fires a blur event.
|
---|
| 120 | // Angular does not expect events to be raised during change detection, so any state change
|
---|
| 121 | // (such as a form control's 'ng-touched') will cause a changed-after-checked error.
|
---|
| 122 | // See https://github.com/angular/angular/issues/17793. To work around this, we defer
|
---|
| 123 | // telling the form control it has been touched until the next tick.
|
---|
| 124 | Promise.resolve().then(() => {
|
---|
| 125 | this._onTouched();
|
---|
| 126 | this._changeDetectorRef.markForCheck();
|
---|
| 127 | });
|
---|
| 128 | }
|
---|
| 129 | });
|
---|
| 130 | this._syncIndeterminate(this._indeterminate);
|
---|
| 131 | }
|
---|
| 132 | // TODO: Delete next major revision.
|
---|
| 133 | ngAfterViewChecked() { }
|
---|
| 134 | ngOnDestroy() {
|
---|
| 135 | this._focusMonitor.stopMonitoring(this._elementRef);
|
---|
| 136 | }
|
---|
| 137 | /**
|
---|
| 138 | * Whether the checkbox is checked.
|
---|
| 139 | */
|
---|
| 140 | get checked() { return this._checked; }
|
---|
| 141 | set checked(value) {
|
---|
| 142 | if (value != this.checked) {
|
---|
| 143 | this._checked = value;
|
---|
| 144 | this._changeDetectorRef.markForCheck();
|
---|
| 145 | }
|
---|
| 146 | }
|
---|
| 147 | /**
|
---|
| 148 | * Whether the checkbox is disabled. This fully overrides the implementation provided by
|
---|
| 149 | * mixinDisabled, but the mixin is still required because mixinTabIndex requires it.
|
---|
| 150 | */
|
---|
| 151 | get disabled() { return this._disabled; }
|
---|
| 152 | set disabled(value) {
|
---|
| 153 | const newValue = coerceBooleanProperty(value);
|
---|
| 154 | if (newValue !== this.disabled) {
|
---|
| 155 | this._disabled = newValue;
|
---|
| 156 | this._changeDetectorRef.markForCheck();
|
---|
| 157 | }
|
---|
| 158 | }
|
---|
| 159 | /**
|
---|
| 160 | * Whether the checkbox is indeterminate. This is also known as "mixed" mode and can be used to
|
---|
| 161 | * represent a checkbox with three states, e.g. a checkbox that represents a nested list of
|
---|
| 162 | * checkable items. Note that whenever checkbox is manually clicked, indeterminate is immediately
|
---|
| 163 | * set to false.
|
---|
| 164 | */
|
---|
| 165 | get indeterminate() { return this._indeterminate; }
|
---|
| 166 | set indeterminate(value) {
|
---|
| 167 | const changed = value != this._indeterminate;
|
---|
| 168 | this._indeterminate = coerceBooleanProperty(value);
|
---|
| 169 | if (changed) {
|
---|
| 170 | if (this._indeterminate) {
|
---|
| 171 | this._transitionCheckState(3 /* Indeterminate */);
|
---|
| 172 | }
|
---|
| 173 | else {
|
---|
| 174 | this._transitionCheckState(this.checked ? 1 /* Checked */ : 2 /* Unchecked */);
|
---|
| 175 | }
|
---|
| 176 | this.indeterminateChange.emit(this._indeterminate);
|
---|
| 177 | }
|
---|
| 178 | this._syncIndeterminate(this._indeterminate);
|
---|
| 179 | }
|
---|
| 180 | _isRippleDisabled() {
|
---|
| 181 | return this.disableRipple || this.disabled;
|
---|
| 182 | }
|
---|
| 183 | /** Method being called whenever the label text changes. */
|
---|
| 184 | _onLabelTextChange() {
|
---|
| 185 | // Since the event of the `cdkObserveContent` directive runs outside of the zone, the checkbox
|
---|
| 186 | // component will be only marked for check, but no actual change detection runs automatically.
|
---|
| 187 | // Instead of going back into the zone in order to trigger a change detection which causes
|
---|
| 188 | // *all* components to be checked (if explicitly marked or not using OnPush), we only trigger
|
---|
| 189 | // an explicit change detection for the checkbox view and its children.
|
---|
| 190 | this._changeDetectorRef.detectChanges();
|
---|
| 191 | }
|
---|
| 192 | // Implemented as part of ControlValueAccessor.
|
---|
| 193 | writeValue(value) {
|
---|
| 194 | this.checked = !!value;
|
---|
| 195 | }
|
---|
| 196 | // Implemented as part of ControlValueAccessor.
|
---|
| 197 | registerOnChange(fn) {
|
---|
| 198 | this._controlValueAccessorChangeFn = fn;
|
---|
| 199 | }
|
---|
| 200 | // Implemented as part of ControlValueAccessor.
|
---|
| 201 | registerOnTouched(fn) {
|
---|
| 202 | this._onTouched = fn;
|
---|
| 203 | }
|
---|
| 204 | // Implemented as part of ControlValueAccessor.
|
---|
| 205 | setDisabledState(isDisabled) {
|
---|
| 206 | this.disabled = isDisabled;
|
---|
| 207 | }
|
---|
| 208 | _getAriaChecked() {
|
---|
| 209 | if (this.checked) {
|
---|
| 210 | return 'true';
|
---|
| 211 | }
|
---|
| 212 | return this.indeterminate ? 'mixed' : 'false';
|
---|
| 213 | }
|
---|
| 214 | _transitionCheckState(newState) {
|
---|
| 215 | let oldState = this._currentCheckState;
|
---|
| 216 | let element = this._elementRef.nativeElement;
|
---|
| 217 | if (oldState === newState) {
|
---|
| 218 | return;
|
---|
| 219 | }
|
---|
| 220 | if (this._currentAnimationClass.length > 0) {
|
---|
| 221 | element.classList.remove(this._currentAnimationClass);
|
---|
| 222 | }
|
---|
| 223 | this._currentAnimationClass = this._getAnimationClassForCheckStateTransition(oldState, newState);
|
---|
| 224 | this._currentCheckState = newState;
|
---|
| 225 | if (this._currentAnimationClass.length > 0) {
|
---|
| 226 | element.classList.add(this._currentAnimationClass);
|
---|
| 227 | // Remove the animation class to avoid animation when the checkbox is moved between containers
|
---|
| 228 | const animationClass = this._currentAnimationClass;
|
---|
| 229 | this._ngZone.runOutsideAngular(() => {
|
---|
| 230 | setTimeout(() => {
|
---|
| 231 | element.classList.remove(animationClass);
|
---|
| 232 | }, 1000);
|
---|
| 233 | });
|
---|
| 234 | }
|
---|
| 235 | }
|
---|
| 236 | _emitChangeEvent() {
|
---|
| 237 | const event = new MatCheckboxChange();
|
---|
| 238 | event.source = this;
|
---|
| 239 | event.checked = this.checked;
|
---|
| 240 | this._controlValueAccessorChangeFn(this.checked);
|
---|
| 241 | this.change.emit(event);
|
---|
| 242 | // Assigning the value again here is redundant, but we have to do it in case it was
|
---|
| 243 | // changed inside the `change` listener which will cause the input to be out of sync.
|
---|
| 244 | if (this._inputElement) {
|
---|
| 245 | this._inputElement.nativeElement.checked = this.checked;
|
---|
| 246 | }
|
---|
| 247 | }
|
---|
| 248 | /** Toggles the `checked` state of the checkbox. */
|
---|
| 249 | toggle() {
|
---|
| 250 | this.checked = !this.checked;
|
---|
| 251 | }
|
---|
| 252 | /**
|
---|
| 253 | * Event handler for checkbox input element.
|
---|
| 254 | * Toggles checked state if element is not disabled.
|
---|
| 255 | * Do not toggle on (change) event since IE doesn't fire change event when
|
---|
| 256 | * indeterminate checkbox is clicked.
|
---|
| 257 | * @param event
|
---|
| 258 | */
|
---|
| 259 | _onInputClick(event) {
|
---|
| 260 | var _a;
|
---|
| 261 | const clickAction = (_a = this._options) === null || _a === void 0 ? void 0 : _a.clickAction;
|
---|
| 262 | // We have to stop propagation for click events on the visual hidden input element.
|
---|
| 263 | // By default, when a user clicks on a label element, a generated click event will be
|
---|
| 264 | // dispatched on the associated input element. Since we are using a label element as our
|
---|
| 265 | // root container, the click event on the `checkbox` will be executed twice.
|
---|
| 266 | // The real click event will bubble up, and the generated click event also tries to bubble up.
|
---|
| 267 | // This will lead to multiple click events.
|
---|
| 268 | // Preventing bubbling for the second event will solve that issue.
|
---|
| 269 | event.stopPropagation();
|
---|
| 270 | // If resetIndeterminate is false, and the current state is indeterminate, do nothing on click
|
---|
| 271 | if (!this.disabled && clickAction !== 'noop') {
|
---|
| 272 | // When user manually click on the checkbox, `indeterminate` is set to false.
|
---|
| 273 | if (this.indeterminate && clickAction !== 'check') {
|
---|
| 274 | Promise.resolve().then(() => {
|
---|
| 275 | this._indeterminate = false;
|
---|
| 276 | this.indeterminateChange.emit(this._indeterminate);
|
---|
| 277 | });
|
---|
| 278 | }
|
---|
| 279 | this.toggle();
|
---|
| 280 | this._transitionCheckState(this._checked ? 1 /* Checked */ : 2 /* Unchecked */);
|
---|
| 281 | // Emit our custom change event if the native input emitted one.
|
---|
| 282 | // It is important to only emit it, if the native input triggered one, because
|
---|
| 283 | // we don't want to trigger a change event, when the `checked` variable changes for example.
|
---|
| 284 | this._emitChangeEvent();
|
---|
| 285 | }
|
---|
| 286 | else if (!this.disabled && clickAction === 'noop') {
|
---|
| 287 | // Reset native input when clicked with noop. The native checkbox becomes checked after
|
---|
| 288 | // click, reset it to be align with `checked` value of `mat-checkbox`.
|
---|
| 289 | this._inputElement.nativeElement.checked = this.checked;
|
---|
| 290 | this._inputElement.nativeElement.indeterminate = this.indeterminate;
|
---|
| 291 | }
|
---|
| 292 | }
|
---|
| 293 | /** Focuses the checkbox. */
|
---|
| 294 | focus(origin, options) {
|
---|
| 295 | if (origin) {
|
---|
| 296 | this._focusMonitor.focusVia(this._inputElement, origin, options);
|
---|
| 297 | }
|
---|
| 298 | else {
|
---|
| 299 | this._inputElement.nativeElement.focus(options);
|
---|
| 300 | }
|
---|
| 301 | }
|
---|
| 302 | _onInteractionEvent(event) {
|
---|
| 303 | // We always have to stop propagation on the change event.
|
---|
| 304 | // Otherwise the change event, from the input element, will bubble up and
|
---|
| 305 | // emit its event object to the `change` output.
|
---|
| 306 | event.stopPropagation();
|
---|
| 307 | }
|
---|
| 308 | _getAnimationClassForCheckStateTransition(oldState, newState) {
|
---|
| 309 | // Don't transition if animations are disabled.
|
---|
| 310 | if (this._animationMode === 'NoopAnimations') {
|
---|
| 311 | return '';
|
---|
| 312 | }
|
---|
| 313 | let animSuffix = '';
|
---|
| 314 | switch (oldState) {
|
---|
| 315 | case 0 /* Init */:
|
---|
| 316 | // Handle edge case where user interacts with checkbox that does not have [(ngModel)] or
|
---|
| 317 | // [checked] bound to it.
|
---|
| 318 | if (newState === 1 /* Checked */) {
|
---|
| 319 | animSuffix = 'unchecked-checked';
|
---|
| 320 | }
|
---|
| 321 | else if (newState == 3 /* Indeterminate */) {
|
---|
| 322 | animSuffix = 'unchecked-indeterminate';
|
---|
| 323 | }
|
---|
| 324 | else {
|
---|
| 325 | return '';
|
---|
| 326 | }
|
---|
| 327 | break;
|
---|
| 328 | case 2 /* Unchecked */:
|
---|
| 329 | animSuffix = newState === 1 /* Checked */ ?
|
---|
| 330 | 'unchecked-checked' : 'unchecked-indeterminate';
|
---|
| 331 | break;
|
---|
| 332 | case 1 /* Checked */:
|
---|
| 333 | animSuffix = newState === 2 /* Unchecked */ ?
|
---|
| 334 | 'checked-unchecked' : 'checked-indeterminate';
|
---|
| 335 | break;
|
---|
| 336 | case 3 /* Indeterminate */:
|
---|
| 337 | animSuffix = newState === 1 /* Checked */ ?
|
---|
| 338 | 'indeterminate-checked' : 'indeterminate-unchecked';
|
---|
| 339 | break;
|
---|
| 340 | }
|
---|
| 341 | return `mat-checkbox-anim-${animSuffix}`;
|
---|
| 342 | }
|
---|
| 343 | /**
|
---|
| 344 | * Syncs the indeterminate value with the checkbox DOM node.
|
---|
| 345 | *
|
---|
| 346 | * We sync `indeterminate` directly on the DOM node, because in Ivy the check for whether a
|
---|
| 347 | * property is supported on an element boils down to `if (propName in element)`. Domino's
|
---|
| 348 | * HTMLInputElement doesn't have an `indeterminate` property so Ivy will warn during
|
---|
| 349 | * server-side rendering.
|
---|
| 350 | */
|
---|
| 351 | _syncIndeterminate(value) {
|
---|
| 352 | const nativeCheckbox = this._inputElement;
|
---|
| 353 | if (nativeCheckbox) {
|
---|
| 354 | nativeCheckbox.nativeElement.indeterminate = value;
|
---|
| 355 | }
|
---|
| 356 | }
|
---|
| 357 | }
|
---|
| 358 | MatCheckbox.decorators = [
|
---|
| 359 | { type: Component, args: [{
|
---|
| 360 | selector: 'mat-checkbox',
|
---|
| 361 | template: "<label [attr.for]=\"inputId\" class=\"mat-checkbox-layout\" #label>\n <span class=\"mat-checkbox-inner-container\"\n [class.mat-checkbox-inner-container-no-side-margin]=\"!checkboxLabel.textContent || !checkboxLabel.textContent.trim()\">\n <input #input\n class=\"mat-checkbox-input cdk-visually-hidden\" type=\"checkbox\"\n [id]=\"inputId\"\n [required]=\"required\"\n [checked]=\"checked\"\n [attr.value]=\"value\"\n [disabled]=\"disabled\"\n [attr.name]=\"name\"\n [tabIndex]=\"tabIndex\"\n [attr.aria-label]=\"ariaLabel || null\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n [attr.aria-checked]=\"_getAriaChecked()\"\n [attr.aria-describedby]=\"ariaDescribedby\"\n (change)=\"_onInteractionEvent($event)\"\n (click)=\"_onInputClick($event)\">\n <span matRipple class=\"mat-checkbox-ripple mat-focus-indicator\"\n [matRippleTrigger]=\"label\"\n [matRippleDisabled]=\"_isRippleDisabled()\"\n [matRippleRadius]=\"20\"\n [matRippleCentered]=\"true\"\n [matRippleAnimation]=\"{enterDuration: _animationMode === 'NoopAnimations' ? 0 : 150}\">\n <span class=\"mat-ripple-element mat-checkbox-persistent-ripple\"></span>\n </span>\n <span class=\"mat-checkbox-frame\"></span>\n <span class=\"mat-checkbox-background\">\n <svg version=\"1.1\"\n focusable=\"false\"\n class=\"mat-checkbox-checkmark\"\n viewBox=\"0 0 24 24\"\n xml:space=\"preserve\"\n aria-hidden=\"true\">\n <path class=\"mat-checkbox-checkmark-path\"\n fill=\"none\"\n stroke=\"white\"\n d=\"M4.1,12.7 9,17.6 20.3,6.3\"/>\n </svg>\n <!-- Element for rendering the indeterminate state checkbox. -->\n <span class=\"mat-checkbox-mixedmark\"></span>\n </span>\n </span>\n <span class=\"mat-checkbox-label\" #checkboxLabel (cdkObserveContent)=\"_onLabelTextChange()\">\n <!-- Add an invisible span so JAWS can read the label -->\n <span style=\"display:none\"> </span>\n <ng-content></ng-content>\n </span>\n</label>\n",
|
---|
| 362 | exportAs: 'matCheckbox',
|
---|
| 363 | host: {
|
---|
| 364 | 'class': 'mat-checkbox',
|
---|
| 365 | '[id]': 'id',
|
---|
| 366 | '[attr.tabindex]': 'null',
|
---|
| 367 | '[class.mat-checkbox-indeterminate]': 'indeterminate',
|
---|
| 368 | '[class.mat-checkbox-checked]': 'checked',
|
---|
| 369 | '[class.mat-checkbox-disabled]': 'disabled',
|
---|
| 370 | '[class.mat-checkbox-label-before]': 'labelPosition == "before"',
|
---|
| 371 | '[class._mat-animation-noopable]': `_animationMode === 'NoopAnimations'`,
|
---|
| 372 | },
|
---|
| 373 | providers: [MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR],
|
---|
| 374 | inputs: ['disableRipple', 'color', 'tabIndex'],
|
---|
| 375 | encapsulation: ViewEncapsulation.None,
|
---|
| 376 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
| 377 | styles: ["@keyframes mat-checkbox-fade-in-background{0%{opacity:0}50%{opacity:1}}@keyframes mat-checkbox-fade-out-background{0%,50%{opacity:1}100%{opacity:0}}@keyframes mat-checkbox-unchecked-checked-checkmark-path{0%,50%{stroke-dashoffset:22.910259}50%{animation-timing-function:cubic-bezier(0, 0, 0.2, 0.1)}100%{stroke-dashoffset:0}}@keyframes mat-checkbox-unchecked-indeterminate-mixedmark{0%,68.2%{transform:scaleX(0)}68.2%{animation-timing-function:cubic-bezier(0, 0, 0, 1)}100%{transform:scaleX(1)}}@keyframes mat-checkbox-checked-unchecked-checkmark-path{from{animation-timing-function:cubic-bezier(0.4, 0, 1, 1);stroke-dashoffset:0}to{stroke-dashoffset:-22.910259}}@keyframes mat-checkbox-checked-indeterminate-checkmark{from{animation-timing-function:cubic-bezier(0, 0, 0.2, 0.1);opacity:1;transform:rotate(0deg)}to{opacity:0;transform:rotate(45deg)}}@keyframes mat-checkbox-indeterminate-checked-checkmark{from{animation-timing-function:cubic-bezier(0.14, 0, 0, 1);opacity:0;transform:rotate(45deg)}to{opacity:1;transform:rotate(360deg)}}@keyframes mat-checkbox-checked-indeterminate-mixedmark{from{animation-timing-function:cubic-bezier(0, 0, 0.2, 0.1);opacity:0;transform:rotate(-45deg)}to{opacity:1;transform:rotate(0deg)}}@keyframes mat-checkbox-indeterminate-checked-mixedmark{from{animation-timing-function:cubic-bezier(0.14, 0, 0, 1);opacity:1;transform:rotate(0deg)}to{opacity:0;transform:rotate(315deg)}}@keyframes mat-checkbox-indeterminate-unchecked-mixedmark{0%{animation-timing-function:linear;opacity:1;transform:scaleX(1)}32.8%,100%{opacity:0;transform:scaleX(0)}}.mat-checkbox-background,.mat-checkbox-frame{top:0;left:0;right:0;bottom:0;position:absolute;border-radius:2px;box-sizing:border-box;pointer-events:none}.mat-checkbox{display:inline-block;transition:background 400ms cubic-bezier(0.25, 0.8, 0.25, 1),box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);cursor:pointer;-webkit-tap-highlight-color:transparent}._mat-animation-noopable.mat-checkbox{transition:none;animation:none}.mat-checkbox .mat-ripple-element:not(.mat-checkbox-persistent-ripple){opacity:.16}.mat-checkbox .mat-checkbox-ripple{position:absolute;left:calc(50% - 20px);top:calc(50% - 20px);height:40px;width:40px;z-index:1;pointer-events:none}.cdk-high-contrast-active .mat-checkbox.cdk-keyboard-focused .mat-checkbox-ripple{outline:solid 3px}.mat-checkbox-layout{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:inherit;align-items:baseline;vertical-align:middle;display:inline-flex;white-space:nowrap}.mat-checkbox-label{-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto}.mat-checkbox-inner-container{display:inline-block;height:16px;line-height:0;margin:auto;margin-right:8px;order:0;position:relative;vertical-align:middle;white-space:nowrap;width:16px;flex-shrink:0}[dir=rtl] .mat-checkbox-inner-container{margin-left:8px;margin-right:auto}.mat-checkbox-inner-container-no-side-margin{margin-left:0;margin-right:0}.mat-checkbox-frame{background-color:transparent;transition:border-color 90ms cubic-bezier(0, 0, 0.2, 0.1);border-width:2px;border-style:solid}._mat-animation-noopable .mat-checkbox-frame{transition:none}.mat-checkbox-background{align-items:center;display:inline-flex;justify-content:center;transition:background-color 90ms cubic-bezier(0, 0, 0.2, 0.1),opacity 90ms cubic-bezier(0, 0, 0.2, 0.1);-webkit-print-color-adjust:exact;color-adjust:exact}._mat-animation-noopable .mat-checkbox-background{transition:none}.cdk-high-contrast-active .mat-checkbox .mat-checkbox-background{background:none}.mat-checkbox-persistent-ripple{display:block;width:100%;height:100%;transform:none}.mat-checkbox-inner-container:hover .mat-checkbox-persistent-ripple{opacity:.04}.mat-checkbox.cdk-keyboard-focused .mat-checkbox-persistent-ripple{opacity:.12}.mat-checkbox-persistent-ripple,.mat-checkbox.mat-checkbox-disabled .mat-checkbox-inner-container:hover .mat-checkbox-persistent-ripple{opacity:0}@media(hover: none){.mat-checkbox-inner-container:hover .mat-checkbox-persistent-ripple{display:none}}.mat-checkbox-checkmark{top:0;left:0;right:0;bottom:0;position:absolute;width:100%}.mat-checkbox-checkmark-path{stroke-dashoffset:22.910259;stroke-dasharray:22.910259;stroke-width:2.1333333333px}.cdk-high-contrast-black-on-white .mat-checkbox-checkmark-path{stroke:#000 !important}.mat-checkbox-mixedmark{width:calc(100% - 6px);height:2px;opacity:0;transform:scaleX(0) rotate(0deg);border-radius:2px}.cdk-high-contrast-active .mat-checkbox-mixedmark{height:0;border-top:solid 2px;margin-top:2px}.mat-checkbox-label-before .mat-checkbox-inner-container{order:1;margin-left:8px;margin-right:auto}[dir=rtl] .mat-checkbox-label-before .mat-checkbox-inner-container{margin-left:auto;margin-right:8px}.mat-checkbox-checked .mat-checkbox-checkmark{opacity:1}.mat-checkbox-checked .mat-checkbox-checkmark-path{stroke-dashoffset:0}.mat-checkbox-checked .mat-checkbox-mixedmark{transform:scaleX(1) rotate(-45deg)}.mat-checkbox-indeterminate .mat-checkbox-checkmark{opacity:0;transform:rotate(45deg)}.mat-checkbox-indeterminate .mat-checkbox-checkmark-path{stroke-dashoffset:0}.mat-checkbox-indeterminate .mat-checkbox-mixedmark{opacity:1;transform:scaleX(1) rotate(0deg)}.mat-checkbox-unchecked .mat-checkbox-background{background-color:transparent}.mat-checkbox-disabled{cursor:default}.cdk-high-contrast-active .mat-checkbox-disabled{opacity:.5}.mat-checkbox-anim-unchecked-checked .mat-checkbox-background{animation:180ms linear 0ms mat-checkbox-fade-in-background}.mat-checkbox-anim-unchecked-checked .mat-checkbox-checkmark-path{animation:180ms linear 0ms mat-checkbox-unchecked-checked-checkmark-path}.mat-checkbox-anim-unchecked-indeterminate .mat-checkbox-background{animation:180ms linear 0ms mat-checkbox-fade-in-background}.mat-checkbox-anim-unchecked-indeterminate .mat-checkbox-mixedmark{animation:90ms linear 0ms mat-checkbox-unchecked-indeterminate-mixedmark}.mat-checkbox-anim-checked-unchecked .mat-checkbox-background{animation:180ms linear 0ms mat-checkbox-fade-out-background}.mat-checkbox-anim-checked-unchecked .mat-checkbox-checkmark-path{animation:90ms linear 0ms mat-checkbox-checked-unchecked-checkmark-path}.mat-checkbox-anim-checked-indeterminate .mat-checkbox-checkmark{animation:90ms linear 0ms mat-checkbox-checked-indeterminate-checkmark}.mat-checkbox-anim-checked-indeterminate .mat-checkbox-mixedmark{animation:90ms linear 0ms mat-checkbox-checked-indeterminate-mixedmark}.mat-checkbox-anim-indeterminate-checked .mat-checkbox-checkmark{animation:500ms linear 0ms mat-checkbox-indeterminate-checked-checkmark}.mat-checkbox-anim-indeterminate-checked .mat-checkbox-mixedmark{animation:500ms linear 0ms mat-checkbox-indeterminate-checked-mixedmark}.mat-checkbox-anim-indeterminate-unchecked .mat-checkbox-background{animation:180ms linear 0ms mat-checkbox-fade-out-background}.mat-checkbox-anim-indeterminate-unchecked .mat-checkbox-mixedmark{animation:300ms linear 0ms mat-checkbox-indeterminate-unchecked-mixedmark}.mat-checkbox-input{bottom:0;left:50%}\n"]
|
---|
| 378 | },] }
|
---|
| 379 | ];
|
---|
| 380 | MatCheckbox.ctorParameters = () => [
|
---|
| 381 | { type: ElementRef },
|
---|
| 382 | { type: ChangeDetectorRef },
|
---|
| 383 | { type: FocusMonitor },
|
---|
| 384 | { type: NgZone },
|
---|
| 385 | { type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] },
|
---|
| 386 | { type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] },
|
---|
| 387 | { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_CHECKBOX_DEFAULT_OPTIONS,] }] }
|
---|
| 388 | ];
|
---|
| 389 | MatCheckbox.propDecorators = {
|
---|
| 390 | ariaLabel: [{ type: Input, args: ['aria-label',] }],
|
---|
| 391 | ariaLabelledby: [{ type: Input, args: ['aria-labelledby',] }],
|
---|
| 392 | ariaDescribedby: [{ type: Input, args: ['aria-describedby',] }],
|
---|
| 393 | id: [{ type: Input }],
|
---|
| 394 | required: [{ type: Input }],
|
---|
| 395 | labelPosition: [{ type: Input }],
|
---|
| 396 | name: [{ type: Input }],
|
---|
| 397 | change: [{ type: Output }],
|
---|
| 398 | indeterminateChange: [{ type: Output }],
|
---|
| 399 | value: [{ type: Input }],
|
---|
| 400 | _inputElement: [{ type: ViewChild, args: ['input',] }],
|
---|
| 401 | ripple: [{ type: ViewChild, args: [MatRipple,] }],
|
---|
| 402 | checked: [{ type: Input }],
|
---|
| 403 | disabled: [{ type: Input }],
|
---|
| 404 | indeterminate: [{ type: Input }]
|
---|
| 405 | };
|
---|
| 406 |
|
---|
| 407 | /**
|
---|
| 408 | * @license
|
---|
| 409 | * Copyright Google LLC All Rights Reserved.
|
---|
| 410 | *
|
---|
| 411 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 412 | * found in the LICENSE file at https://angular.io/license
|
---|
| 413 | */
|
---|
| 414 | const MAT_CHECKBOX_REQUIRED_VALIDATOR = {
|
---|
| 415 | provide: NG_VALIDATORS,
|
---|
| 416 | useExisting: forwardRef(() => MatCheckboxRequiredValidator),
|
---|
| 417 | multi: true
|
---|
| 418 | };
|
---|
| 419 | /**
|
---|
| 420 | * Validator for Material checkbox's required attribute in template-driven checkbox.
|
---|
| 421 | * Current CheckboxRequiredValidator only work with `input type=checkbox` and does not
|
---|
| 422 | * work with `mat-checkbox`.
|
---|
| 423 | */
|
---|
| 424 | class MatCheckboxRequiredValidator extends CheckboxRequiredValidator {
|
---|
| 425 | }
|
---|
| 426 | MatCheckboxRequiredValidator.decorators = [
|
---|
| 427 | { type: Directive, args: [{
|
---|
| 428 | selector: `mat-checkbox[required][formControlName],
|
---|
| 429 | mat-checkbox[required][formControl], mat-checkbox[required][ngModel]`,
|
---|
| 430 | providers: [MAT_CHECKBOX_REQUIRED_VALIDATOR],
|
---|
| 431 | },] }
|
---|
| 432 | ];
|
---|
| 433 |
|
---|
| 434 | /**
|
---|
| 435 | * @license
|
---|
| 436 | * Copyright Google LLC All Rights Reserved.
|
---|
| 437 | *
|
---|
| 438 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 439 | * found in the LICENSE file at https://angular.io/license
|
---|
| 440 | */
|
---|
| 441 | /** This module is used by both original and MDC-based checkbox implementations. */
|
---|
| 442 | class _MatCheckboxRequiredValidatorModule {
|
---|
| 443 | }
|
---|
| 444 | _MatCheckboxRequiredValidatorModule.decorators = [
|
---|
| 445 | { type: NgModule, args: [{
|
---|
| 446 | exports: [MatCheckboxRequiredValidator],
|
---|
| 447 | declarations: [MatCheckboxRequiredValidator],
|
---|
| 448 | },] }
|
---|
| 449 | ];
|
---|
| 450 | class MatCheckboxModule {
|
---|
| 451 | }
|
---|
| 452 | MatCheckboxModule.decorators = [
|
---|
| 453 | { type: NgModule, args: [{
|
---|
| 454 | imports: [
|
---|
| 455 | MatRippleModule, MatCommonModule, ObserversModule,
|
---|
| 456 | _MatCheckboxRequiredValidatorModule
|
---|
| 457 | ],
|
---|
| 458 | exports: [MatCheckbox, MatCommonModule, _MatCheckboxRequiredValidatorModule],
|
---|
| 459 | declarations: [MatCheckbox],
|
---|
| 460 | },] }
|
---|
| 461 | ];
|
---|
| 462 |
|
---|
| 463 | /**
|
---|
| 464 | * @license
|
---|
| 465 | * Copyright Google LLC All Rights Reserved.
|
---|
| 466 | *
|
---|
| 467 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 468 | * found in the LICENSE file at https://angular.io/license
|
---|
| 469 | */
|
---|
| 470 |
|
---|
| 471 | /**
|
---|
| 472 | * Generated bundle index. Do not edit.
|
---|
| 473 | */
|
---|
| 474 |
|
---|
| 475 | export { MAT_CHECKBOX_CONTROL_VALUE_ACCESSOR, MAT_CHECKBOX_DEFAULT_OPTIONS, MAT_CHECKBOX_DEFAULT_OPTIONS_FACTORY, MAT_CHECKBOX_REQUIRED_VALIDATOR, MatCheckbox, MatCheckboxChange, MatCheckboxModule, MatCheckboxRequiredValidator, _MatCheckboxRequiredValidatorModule };
|
---|
| 476 | //# sourceMappingURL=checkbox.js.map
|
---|