checkbox.js 30 KB

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