checkbox.es5.js 35 KB

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