@material/checkbox
Advanced tools
Comparing version 0.3.7 to 0.4.0
@@ -17,6 +17,7 @@ /** | ||
/** @const {string} */ | ||
const ROOT = 'mdc-checkbox'; | ||
/** @enum {string} */ | ||
export const cssClasses = { | ||
ROOT: 'mdc-checkbox', | ||
UPGRADED: 'mdc-checkbox--upgraded', | ||
@@ -34,2 +35,3 @@ CHECKED: 'mdc-checkbox--checked', | ||
/** @enum {string} */ | ||
export const strings = { | ||
@@ -43,4 +45,5 @@ NATIVE_CONTROL_SELECTOR: `.${ROOT}__native-control`, | ||
/** @enum {number} */ | ||
export const numbers = { | ||
ANIM_END_LATCH_MS: 100, | ||
}; |
@@ -6,2 +6,2 @@ /*! | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.checkbox=e():(t.mdc=t.mdc||{},t.mdc.checkbox=e())}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/assets/",e(e.s=79)}({0:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),a=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t),this.adapter_=e}return r(t,null,[{key:"cssClasses",get:function(){return{}}},{key:"strings",get:function(){return{}}},{key:"numbers",get:function(){return{}}},{key:"defaultAdapter",get:function(){return{}}}]),r(t,[{key:"init",value:function(){}},{key:"destroy",value:function(){}}]),t}();e.a=a},1:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0);n.d(e,"MDCFoundation",function(){return i.a});var r=n(2);n.d(e,"MDCComponent",function(){return r.a})},2:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=n(0),a=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),o=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;i(this,t),this.root_=e;for(var r=arguments.length,a=Array(r>2?r-2:0),o=2;o<r;o++)a[o-2]=arguments[o];this.initialize.apply(this,a),this.foundation_=void 0===n?this.getDefaultFoundation():n,this.foundation_.init(),this.initialSyncWithDOM()}return a(t,null,[{key:"attachTo",value:function(e){return new t(e,new r.a)}}]),a(t,[{key:"initialize",value:function(){}},{key:"getDefaultFoundation",value:function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")}},{key:"initialSyncWithDOM",value:function(){}},{key:"destroy",value:function(){this.foundation_.destroy()}},{key:"listen",value:function(t,e){this.root_.addEventListener(t,e)}},{key:"unlisten",value:function(t,e){this.root_.removeEventListener(t,e)}},{key:"emit",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=void 0;"function"==typeof CustomEvent?i=new CustomEvent(t,{detail:e,bubbles:n}):(i=document.createEvent("CustomEvent"),i.initCustomEvent(t,n,!1,e)),this.root_.dispatchEvent(i)}}]),t}();e.a=o},22:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),n.d(e,"MDCCheckbox",function(){return p});var o=n(1),s=n(4),u=n(3),c=n(7),d=n(37);n.d(e,"MDCCheckboxFoundation",function(){return d.a});var l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},f=function t(e,n,i){null===e&&(e=Function.prototype);var r=Object.getOwnPropertyDescriptor(e,n);if(void 0===r){var a=Object.getPrototypeOf(e);return null===a?void 0:t(a,n,i)}if("value"in r)return r.value;var o=r.get;if(void 0!==o)return o.call(i)},_=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),p=function(t){function e(){var t;i(this,e);for(var n=arguments.length,a=Array(n),o=0;o<n;o++)a[o]=arguments[o];var s=r(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(a)));return s.ripple_=s.initRipple_(),s}return a(e,t),_(e,[{key:"nativeCb_",get:function(){var t=d.a.strings.NATIVE_CONTROL_SELECTOR;return this.root_.querySelector(t)}}],[{key:"attachTo",value:function(t){return new e(t)}}]),_(e,[{key:"initRipple_",value:function(){var t=this,e=n.i(u.getMatchesProperty)(HTMLElement.prototype),i=l(s.MDCRipple.createAdapter(this),{isUnbounded:function(){return!0},isSurfaceActive:function(){return t.nativeCb_[e](":active")},registerInteractionHandler:function(e,n){return t.nativeCb_.addEventListener(e,n)},deregisterInteractionHandler:function(e,n){return t.nativeCb_.removeEventListener(e,n)},computeBoundingRect:function(){var e=t.root_.getBoundingClientRect(),n=e.left,i=e.top;return{top:i,left:n,right:n+40,bottom:i+40,width:40,height:40}}}),r=new s.MDCRippleFoundation(i);return new s.MDCRipple(this.root_,r)}},{key:"getDefaultFoundation",value:function(){var t=this;return new d.a({addClass:function(e){return t.root_.classList.add(e)},removeClass:function(e){return t.root_.classList.remove(e)},registerAnimationEndHandler:function(e){return t.root_.addEventListener(n.i(c.getCorrectEventName)(window,"animationend"),e)},deregisterAnimationEndHandler:function(e){return t.root_.removeEventListener(n.i(c.getCorrectEventName)(window,"animationend"),e)},registerChangeHandler:function(e){return t.nativeCb_.addEventListener("change",e)},deregisterChangeHandler:function(e){return t.nativeCb_.removeEventListener("change",e)},getNativeControl:function(){return t.nativeCb_},forceLayout:function(){return t.root_.offsetWidth},isAttachedToDOM:function(){return Boolean(t.root_.parentNode)}})}},{key:"destroy",value:function(){this.ripple_.destroy(),f(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"destroy",this).call(this)}},{key:"ripple",get:function(){return this.ripple_}},{key:"checked",get:function(){return this.foundation_.isChecked()},set:function(t){this.foundation_.setChecked(t)}},{key:"indeterminate",get:function(){return this.foundation_.isIndeterminate()},set:function(t){this.foundation_.setIndeterminate(t)}},{key:"disabled",get:function(){return this.foundation_.isDisabled()},set:function(t){this.foundation_.setDisabled(t)}},{key:"value",get:function(){return this.foundation_.getValue()},set:function(t){this.foundation_.setValue(t)}}]),e}(o.MDCComponent)},3:function(t,e,n){"use strict";function i(t){if(t.CSS&&"function"==typeof t.CSS.supports){var e=t.CSS.supports("--css-vars","yes"),n=t.CSS.supports("(--css-vars: yes)")&&t.CSS.supports("color","#00000000");return e||n}}function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0===s||e){var n=!1;try{t.document.addEventListener("test",null,{get passive(){n=!0}})}catch(t){}s=n}return!!s&&{passive:!0}}function a(t){return["webkitMatchesSelector","msMatchesSelector","matches"].filter(function(e){return e in t}).pop()}function o(t,e,n){var i=e.x,r=e.y,a=i+n.left,o=r+n.top,s=void 0,u=void 0;return"touchstart"===t.type?(s=t.changedTouches[0].pageX-a,u=t.changedTouches[0].pageY-o):(s=t.pageX-a,u=t.pageY-o),{x:s,y:u}}Object.defineProperty(e,"__esModule",{value:!0}),e.supportsCssVariables=i,e.applyPassive=r,e.getMatchesProperty=a,e.getNormalizedEventCoords=o;var s=void 0},36:function(t,e,n){"use strict";n.d(e,"a",function(){return i}),n.d(e,"b",function(){return r}),n.d(e,"c",function(){return a});var i={ROOT:"mdc-checkbox",UPGRADED:"mdc-checkbox--upgraded",CHECKED:"mdc-checkbox--checked",INDETERMINATE:"mdc-checkbox--indeterminate",DISABLED:"mdc-checkbox--disabled",ANIM_UNCHECKED_CHECKED:"mdc-checkbox--anim-unchecked-checked",ANIM_UNCHECKED_INDETERMINATE:"mdc-checkbox--anim-unchecked-indeterminate",ANIM_CHECKED_UNCHECKED:"mdc-checkbox--anim-checked-unchecked",ANIM_CHECKED_INDETERMINATE:"mdc-checkbox--anim-checked-indeterminate",ANIM_INDETERMINATE_CHECKED:"mdc-checkbox--anim-indeterminate-checked",ANIM_INDETERMINATE_UNCHECKED:"mdc-checkbox--anim-indeterminate-unchecked"},r={NATIVE_CONTROL_SELECTOR:".mdc-checkbox__native-control",TRANSITION_STATE_INIT:"init",TRANSITION_STATE_CHECKED:"checked",TRANSITION_STATE_UNCHECKED:"unchecked",TRANSITION_STATE_INDETERMINATE:"indeterminate"},a={ANIM_END_LATCH_MS:100}},37:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function o(t){return t&&"function"==typeof t.set}var s=n(1),u=n(36),c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},d=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),l=["checked","indeterminate"],f=function(t){function e(t){i(this,e);var n=r(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,c(e.defaultAdapter,t)));return n.currentCheckState_=u.b.TRANSITION_STATE_INIT,n.currentAnimationClass_="",n.animEndLatchTimer_=0,n.animEndHandler_=function(){clearTimeout(n.animEndLatchTimer_),n.animEndLatchTimer_=setTimeout(function(){n.adapter_.removeClass(n.currentAnimationClass_),n.adapter_.deregisterAnimationEndHandler(n.animEndHandler_)},u.c.ANIM_END_LATCH_MS)},n.changeHandler_=function(){return n.transitionCheckState_()},n}return a(e,t),d(e,null,[{key:"cssClasses",get:function(){return u.a}},{key:"strings",get:function(){return u.b}},{key:"numbers",get:function(){return u.c}},{key:"defaultAdapter",get:function(){return{addClass:function(){},removeClass:function(){},registerAnimationEndHandler:function(){},deregisterAnimationEndHandler:function(){},registerChangeHandler:function(){},deregisterChangeHandler:function(){},getNativeControl:function(){},forceLayout:function(){},isAttachedToDOM:function(){}}}}]),d(e,[{key:"init",value:function(){this.adapter_.addClass(u.a.UPGRADED),this.adapter_.registerChangeHandler(this.changeHandler_),this.installPropertyChangeHooks_()}},{key:"destroy",value:function(){this.adapter_.deregisterChangeHandler(this.changeHandler_),this.uninstallPropertyChangeHooks_()}},{key:"isChecked",value:function(){return this.getNativeControl_().checked}},{key:"setChecked",value:function(t){this.getNativeControl_().checked=t}},{key:"isIndeterminate",value:function(){return this.getNativeControl_().indeterminate}},{key:"setIndeterminate",value:function(t){this.getNativeControl_().indeterminate=t}},{key:"isDisabled",value:function(){return this.getNativeControl_().disabled}},{key:"setDisabled",value:function(t){this.getNativeControl_().disabled=t,t?this.adapter_.addClass(u.a.DISABLED):this.adapter_.removeClass(u.a.DISABLED)}},{key:"getValue",value:function(){return this.getNativeControl_().value}},{key:"setValue",value:function(t){this.getNativeControl_().value=t}},{key:"installPropertyChangeHooks_",value:function(){var t=this,e=this.getNativeControl_(),n=Object.getPrototypeOf(e);l.forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);o(r)&&Object.defineProperty(e,i,{get:r.get,set:function(n){r.set.call(e,n),t.transitionCheckState_()},configurable:r.configurable,enumerable:r.enumerable})})}},{key:"uninstallPropertyChangeHooks_",value:function(){var t=this.getNativeControl_(),e=Object.getPrototypeOf(t);l.forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);o(i)&&Object.defineProperty(t,n,i)})}},{key:"transitionCheckState_",value:function(){var t=this.adapter_.getNativeControl();if(t){var e=this.currentCheckState_,n=this.determineCheckState_(t);e!==n&&(this.currentAnimationClass_.length>0&&(clearTimeout(this.animEndLatchTimer_),this.adapter_.forceLayout(),this.adapter_.removeClass(this.currentAnimationClass_)),this.currentAnimationClass_=this.getTransitionAnimationClass_(e,n),this.currentCheckState_=n,this.adapter_.isAttachedToDOM()&&this.currentAnimationClass_.length>0&&(this.adapter_.addClass(this.currentAnimationClass_),this.adapter_.registerAnimationEndHandler(this.animEndHandler_)))}}},{key:"determineCheckState_",value:function(t){var e=u.b.TRANSITION_STATE_INDETERMINATE,n=u.b.TRANSITION_STATE_CHECKED,i=u.b.TRANSITION_STATE_UNCHECKED;return t.indeterminate?e:t.checked?n:i}},{key:"getTransitionAnimationClass_",value:function(t,n){var i=u.b.TRANSITION_STATE_INIT,r=u.b.TRANSITION_STATE_CHECKED,a=u.b.TRANSITION_STATE_UNCHECKED,o=e.cssClasses,s=o.ANIM_UNCHECKED_CHECKED,c=o.ANIM_UNCHECKED_INDETERMINATE,d=o.ANIM_CHECKED_UNCHECKED,l=o.ANIM_CHECKED_INDETERMINATE,f=o.ANIM_INDETERMINATE_CHECKED,_=o.ANIM_INDETERMINATE_UNCHECKED;switch(t){case i:if(n===a)return"";case a:return n===r?s:c;case r:return n===a?d:l;default:return n===r?f:_}}},{key:"getNativeControl_",value:function(){return this.adapter_.getNativeControl()||{checked:!1,indeterminate:!1,disabled:!1,value:null}}}]),e}(s.MDCFoundation);e.a=f},4:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),n.d(e,"MDCRipple",function(){return d});var o=n(1),s=n(6),u=n(3);n.d(e,"MDCRippleFoundation",function(){return s.a}),n.d(e,"util",function(){return u});var c=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),d=function(t){function e(){return i(this,e),r(this,(e.__proto__||Object.getPrototypeOf(e)).apply(this,arguments))}return a(e,t),c(e,[{key:"activate",value:function(){this.foundation_.activate()}},{key:"deactivate",value:function(){this.foundation_.deactivate()}},{key:"layout",value:function(){this.foundation_.layout()}},{key:"getDefaultFoundation",value:function(){return new s.a(e.createAdapter(this))}},{key:"initialSyncWithDOM",value:function(){this.unbounded="mdcRippleIsUnbounded"in this.root_.dataset}},{key:"unbounded",get:function(){return this.unbounded_},set:function(t){var e=s.a.cssClasses.UNBOUNDED;this.unbounded_=Boolean(t),this.unbounded_?this.root_.classList.add(e):this.root_.classList.remove(e)}}],[{key:"attachTo",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.isUnbounded,r=void 0===i?void 0:i,a=new e(t);return void 0!==r&&(a.unbounded=r),a}},{key:"createAdapter",value:function(t){var e=u.getMatchesProperty(HTMLElement.prototype);return{browserSupportsCssVars:function(){return u.supportsCssVariables(window)},isUnbounded:function(){return t.unbounded},isSurfaceActive:function(){return t.root_[e](":active")},isSurfaceDisabled:function(){return t.disabled},addClass:function(e){return t.root_.classList.add(e)},removeClass:function(e){return t.root_.classList.remove(e)},registerInteractionHandler:function(e,n){return t.root_.addEventListener(e,n,u.applyPassive())},deregisterInteractionHandler:function(e,n){return t.root_.removeEventListener(e,n,u.applyPassive())},registerResizeHandler:function(t){return window.addEventListener("resize",t)},deregisterResizeHandler:function(t){return window.removeEventListener("resize",t)},updateCssVariable:function(e,n){return t.root_.style.setProperty(e,n)},computeBoundingRect:function(){return t.root_.getBoundingClientRect()},getWindowPageOffset:function(){return{x:window.pageXOffset,y:window.pageYOffset}}}}}]),e}(o.MDCComponent)},5:function(t,e,n){"use strict";n.d(e,"a",function(){return i}),n.d(e,"b",function(){return r}),n.d(e,"c",function(){return a});var i={ROOT:"mdc-ripple-upgraded",UNBOUNDED:"mdc-ripple-upgraded--unbounded",BG_FOCUSED:"mdc-ripple-upgraded--background-focused",BG_ACTIVE_FILL:"mdc-ripple-upgraded--background-active-fill",FG_ACTIVATION:"mdc-ripple-upgraded--foreground-activation",FG_DEACTIVATION:"mdc-ripple-upgraded--foreground-deactivation"},r={VAR_SURFACE_WIDTH:"--mdc-ripple-surface-width",VAR_SURFACE_HEIGHT:"--mdc-ripple-surface-height",VAR_FG_SIZE:"--mdc-ripple-fg-size",VAR_LEFT:"--mdc-ripple-left",VAR_TOP:"--mdc-ripple-top",VAR_FG_SCALE:"--mdc-ripple-fg-scale",VAR_FG_TRANSLATE_START:"--mdc-ripple-fg-translate-start",VAR_FG_TRANSLATE_END:"--mdc-ripple-fg-translate-end"},a={PADDING:10,INITIAL_ORIGIN_SCALE:.6,DEACTIVATION_TIMEOUT_MS:300,FG_DEACTIVATION_MS:83}},6:function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var o=n(1),s=n(5),u=n(3),c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},d=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),l={mouseup:"mousedown",pointerup:"pointerdown",touchend:"touchstart",keyup:"keydown",blur:"focus"},f=function(t){function e(t){i(this,e);var n=r(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,c(e.defaultAdapter,t)));return n.layoutFrame_=0,n.frame_={width:0,height:0},n.activationState_=n.defaultActivationState_(),n.xfDuration_=0,n.initialSize_=0,n.maxRadius_=0,n.listenerInfos_=[{activate:"touchstart",deactivate:"touchend"},{activate:"pointerdown",deactivate:"pointerup"},{activate:"mousedown",deactivate:"mouseup"},{activate:"keydown",deactivate:"keyup"},{focus:"focus",blur:"blur"}],n.listeners_={activate:function(t){return n.activate_(t)},deactivate:function(t){return n.deactivate_(t)},focus:function(){return requestAnimationFrame(function(){return n.adapter_.addClass(e.cssClasses.BG_FOCUSED)})},blur:function(){return requestAnimationFrame(function(){return n.adapter_.removeClass(e.cssClasses.BG_FOCUSED)})}},n.resizeHandler_=function(){return n.layout()},n.unboundedCoords_={left:0,top:0},n.fgScale_=0,n.activationTimer_=0,n.fgDeactivationRemovalTimer_=0,n.activationAnimationHasEnded_=!1,n.activationTimerCallback_=function(){n.activationAnimationHasEnded_=!0,n.runDeactivationUXLogicIfReady_()},n}return a(e,t),d(e,[{key:"isSupported_",get:function(){return this.adapter_.browserSupportsCssVars()}}],[{key:"cssClasses",get:function(){return s.a}},{key:"strings",get:function(){return s.b}},{key:"numbers",get:function(){return s.c}},{key:"defaultAdapter",get:function(){return{browserSupportsCssVars:function(){},isUnbounded:function(){},isSurfaceActive:function(){},isSurfaceDisabled:function(){},addClass:function(){},removeClass:function(){},registerInteractionHandler:function(){},deregisterInteractionHandler:function(){},registerResizeHandler:function(){},deregisterResizeHandler:function(){},updateCssVariable:function(){},computeBoundingRect:function(){},getWindowPageOffset:function(){}}}}]),d(e,[{key:"defaultActivationState_",value:function(){return{isActivated:!1,hasDeactivationUXRun:!1,wasActivatedByPointer:!1,wasElementMadeActive:!1,activationStartTime:0,activationEvent:null,isProgrammatic:!1}}},{key:"init",value:function(){var t=this;if(this.isSupported_){this.addEventListeners_();var n=e.cssClasses,i=n.ROOT,r=n.UNBOUNDED;requestAnimationFrame(function(){t.adapter_.addClass(i),t.adapter_.isUnbounded()&&t.adapter_.addClass(r),t.layoutInternal_()})}}},{key:"addEventListeners_",value:function(){var t=this;this.listenerInfos_.forEach(function(e){Object.keys(e).forEach(function(n){t.adapter_.registerInteractionHandler(e[n],t.listeners_[n])})}),this.adapter_.registerResizeHandler(this.resizeHandler_)}},{key:"activate_",value:function(t){var e=this;if(!this.adapter_.isSurfaceDisabled()){var n=this.activationState_;n.isActivated||(n.isActivated=!0,n.isProgrammatic=null===t,n.activationEvent=t,n.wasActivatedByPointer=!n.isProgrammatic&&("mousedown"===t.type||"touchstart"===t.type||"pointerdown"===t.type),n.activationStartTime=Date.now(),requestAnimationFrame(function(){n.wasElementMadeActive=!t||"keydown"!==t.type||e.adapter_.isSurfaceActive(),n.wasElementMadeActive?e.animateActivation_():e.activationState_=e.defaultActivationState_()}))}}},{key:"activate",value:function(){this.activate_(null)}},{key:"animateActivation_",value:function(){var t=this,n=e.strings,i=n.VAR_FG_TRANSLATE_START,r=n.VAR_FG_TRANSLATE_END,a=e.cssClasses,o=a.BG_ACTIVE_FILL,s=a.FG_DEACTIVATION,u=a.FG_ACTIVATION,c=e.numbers.DEACTIVATION_TIMEOUT_MS,d="",l="";if(!this.adapter_.isUnbounded()){var f=this.getFgTranslationCoordinates_(),_=f.startPoint,p=f.endPoint;d=_.x+"px, "+_.y+"px",l=p.x+"px, "+p.y+"px"}this.adapter_.updateCssVariable(i,d),this.adapter_.updateCssVariable(r,l),clearTimeout(this.activationTimer_),clearTimeout(this.fgDeactivationRemovalTimer_),this.rmBoundedActivationClasses_(),this.adapter_.removeClass(s),this.adapter_.computeBoundingRect(),this.adapter_.addClass(o),this.adapter_.addClass(u),this.activationTimer_=setTimeout(function(){return t.activationTimerCallback_()},c)}},{key:"getFgTranslationCoordinates_",value:function(){var t=this.activationState_,e=t.activationEvent,i=t.wasActivatedByPointer,r=void 0;return r=i?n.i(u.getNormalizedEventCoords)(e,this.adapter_.getWindowPageOffset(),this.adapter_.computeBoundingRect()):{x:this.frame_.width/2,y:this.frame_.height/2},r={x:r.x-this.initialSize_/2,y:r.y-this.initialSize_/2},{startPoint:r,endPoint:{x:this.frame_.width/2-this.initialSize_/2,y:this.frame_.height/2-this.initialSize_/2}}}},{key:"runDeactivationUXLogicIfReady_",value:function(){var t=this,n=e.cssClasses.FG_DEACTIVATION,i=this.activationState_,r=i.hasDeactivationUXRun,a=i.isActivated;(r||!a)&&this.activationAnimationHasEnded_&&(this.rmBoundedActivationClasses_(),this.adapter_.addClass(n),this.fgDeactivationRemovalTimer_=setTimeout(function(){t.adapter_.removeClass(n)},s.c.FG_DEACTIVATION_MS))}},{key:"rmBoundedActivationClasses_",value:function(){var t=e.cssClasses,n=t.BG_ACTIVE_FILL,i=t.FG_ACTIVATION;this.adapter_.removeClass(n),this.adapter_.removeClass(i),this.activationAnimationHasEnded_=!1,this.adapter_.computeBoundingRect()}},{key:"deactivate_",value:function(t){var e=this,n=this.activationState_;if(n.isActivated){if(n.isProgrammatic){return requestAnimationFrame(function(){return e.animateDeactivation_(null,c({},n))}),void(this.activationState_=this.defaultActivationState_())}var i=l[t.type],r=n.activationEvent.type,a=i===r,o=a;n.wasActivatedByPointer&&(o="mouseup"===t.type);var s=c({},n);requestAnimationFrame(function(){a&&(e.activationState_.hasDeactivationUXRun=!0,e.animateDeactivation_(t,s)),o&&(e.activationState_=e.defaultActivationState_())})}}},{key:"deactivate",value:function(){this.deactivate_(null)}},{key:"animateDeactivation_",value:function(t,n){var i=n.wasActivatedByPointer,r=n.wasElementMadeActive,a=e.cssClasses.BG_FOCUSED;(i||r)&&(this.adapter_.removeClass(a),this.runDeactivationUXLogicIfReady_())}},{key:"destroy",value:function(){var t=this;if(this.isSupported_){this.removeEventListeners_();var n=e.cssClasses,i=n.ROOT,r=n.UNBOUNDED;requestAnimationFrame(function(){t.adapter_.removeClass(i),t.adapter_.removeClass(r),t.removeCssVars_()})}}},{key:"removeEventListeners_",value:function(){var t=this;this.listenerInfos_.forEach(function(e){Object.keys(e).forEach(function(n){t.adapter_.deregisterInteractionHandler(e[n],t.listeners_[n])})}),this.adapter_.deregisterResizeHandler(this.resizeHandler_)}},{key:"removeCssVars_",value:function(){var t=this,n=e.strings;Object.keys(n).forEach(function(e){0===e.indexOf("VAR_")&&t.adapter_.updateCssVariable(n[e],null)})}},{key:"layout",value:function(){var t=this;this.layoutFrame_&&cancelAnimationFrame(this.layoutFrame_),this.layoutFrame_=requestAnimationFrame(function(){t.layoutInternal_(),t.layoutFrame_=0})}},{key:"layoutInternal_",value:function(){this.frame_=this.adapter_.computeBoundingRect();var t=Math.max(this.frame_.height,this.frame_.width),n=Math.sqrt(Math.pow(this.frame_.width,2)+Math.pow(this.frame_.height,2));this.initialSize_=t*e.numbers.INITIAL_ORIGIN_SCALE,this.maxRadius_=n+e.numbers.PADDING,this.fgScale_=this.maxRadius_/this.initialSize_,this.xfDuration_=1e3*Math.sqrt(this.maxRadius_/1024),this.updateLayoutCssVars_()}},{key:"updateLayoutCssVars_",value:function(){var t=e.strings,n=t.VAR_SURFACE_WIDTH,i=t.VAR_SURFACE_HEIGHT,r=t.VAR_FG_SIZE,a=t.VAR_LEFT,o=t.VAR_TOP,s=t.VAR_FG_SCALE;this.adapter_.updateCssVariable(n,this.frame_.width+"px"),this.adapter_.updateCssVariable(i,this.frame_.height+"px"),this.adapter_.updateCssVariable(r,this.initialSize_+"px"),this.adapter_.updateCssVariable(s,this.fgScale_),this.adapter_.isUnbounded()&&(this.unboundedCoords_={left:Math.round(this.frame_.width/2-this.initialSize_/2),top:Math.round(this.frame_.height/2-this.initialSize_/2)},this.adapter_.updateCssVariable(a,this.unboundedCoords_.left+"px"),this.adapter_.updateCssVariable(o,this.unboundedCoords_.top+"px"))}}]),e}(o.MDCFoundation);e.a=f},7:function(t,e,n){"use strict";function i(t){return void 0!==t.document&&"function"==typeof t.document.createElement}function r(t){return t in c||t in d}function a(t,e,n){return e[t].styleProperty in n.style?e[t].noPrefix:e[t].webkitPrefix}function o(t,e){if(!i(t)||!r(e))return e;var n=e in c?c:d,o=t.document.createElement("div");return n===c?a(e,n,o):n[e].noPrefix in o.style?n[e].noPrefix:n[e].webkitPrefix}function s(t,e){return o(t,e)}function u(t,e){return o(t,e)}Object.defineProperty(e,"__esModule",{value:!0}),n.d(e,"transformStyleProperties",function(){return l}),e.getCorrectEventName=s,e.getCorrectPropertyName=u;var c={animationstart:{noPrefix:"animationstart",webkitPrefix:"webkitAnimationStart",styleProperty:"animation"},animationend:{noPrefix:"animationend",webkitPrefix:"webkitAnimationEnd",styleProperty:"animation"},animationiteration:{noPrefix:"animationiteration",webkitPrefix:"webkitAnimationIteration",styleProperty:"animation"},transitionend:{noPrefix:"transitionend",webkitPrefix:"webkitTransitionEnd",styleProperty:"transition"}},d={animation:{noPrefix:"animation",webkitPrefix:"-webkit-animation"},transform:{noPrefix:"transform",webkitPrefix:"-webkit-transform"},transition:{noPrefix:"transition",webkitPrefix:"-webkit-transition"}},l=["transform","WebkitTransform","MozTransform","OTransform","MSTransform"]},79:function(t,e,n){t.exports=n(22)}})}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.checkbox=e():(t.mdc=t.mdc||{},t.mdc.checkbox=e())}(this,function(){return function(t){function e(i){if(n[i])return n[i].exports;var r=n[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,e),r.l=!0,r.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,i){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/assets/",e(e.s=27)}([function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),a=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i(this,t),this.adapter_=e}return r(t,null,[{key:"cssClasses",get:function(){return{}}},{key:"strings",get:function(){return{}}},{key:"numbers",get:function(){return{}}},{key:"defaultAdapter",get:function(){return{}}}]),r(t,[{key:"init",value:function(){}},{key:"destroy",value:function(){}}]),t}();e.a=a},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=n(0),a=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),o=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;i(this,t),this.root_=e;for(var r=arguments.length,a=Array(r>2?r-2:0),o=2;o<r;o++)a[o-2]=arguments[o];this.initialize.apply(this,a),this.foundation_=void 0===n?this.getDefaultFoundation():n,this.foundation_.init(),this.initialSyncWithDOM()}return a(t,null,[{key:"attachTo",value:function(e){return new t(e,new r.a)}}]),a(t,[{key:"initialize",value:function(){}},{key:"getDefaultFoundation",value:function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")}},{key:"initialSyncWithDOM",value:function(){}},{key:"destroy",value:function(){this.foundation_.destroy()}},{key:"listen",value:function(t,e){this.root_.addEventListener(t,e)}},{key:"unlisten",value:function(t,e){this.root_.removeEventListener(t,e)}},{key:"emit",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=void 0;"function"==typeof CustomEvent?i=new CustomEvent(t,{detail:e,bubbles:n}):(i=document.createEvent("CustomEvent"),i.initCustomEvent(t,n,!1,e)),this.root_.dispatchEvent(i)}}]),t}();e.a=o},,function(t,e,n){"use strict";function i(t){if(t.CSS&&"function"==typeof t.CSS.supports){var e=t.CSS.supports("--css-vars","yes"),n=t.CSS.supports("(--css-vars: yes)")&&t.CSS.supports("color","#00000000");return e||n}}function r(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window,e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(void 0===u||e){var n=!1;try{t.document.addEventListener("test",null,{get passive(){n=!0}})}catch(t){}u=n}return!!u&&{passive:!0}}function a(t){return["webkitMatchesSelector","msMatchesSelector","matches"].filter(function(e){return e in t}).pop()}function o(t,e,n){var i=e.x,r=e.y,a=i+n.left,o=r+n.top,u=void 0,s=void 0;return"touchstart"===t.type?(u=t.changedTouches[0].pageX-a,s=t.changedTouches[0].pageY-o):(u=t.pageX-a,s=t.pageY-o),{x:u,y:s}}Object.defineProperty(e,"__esModule",{value:!0}),e.supportsCssVariables=i,e.applyPassive=r,e.getMatchesProperty=a,e.getNormalizedEventCoords=o;var u=void 0},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}();!function(){function t(){i(this,t)}r(t,[{key:"browserSupportsCssVars",value:function(){}},{key:"isUnbounded",value:function(){}},{key:"isSurfaceActive",value:function(){}},{key:"isSurfaceDisabled",value:function(){}},{key:"addClass",value:function(t){}},{key:"removeClass",value:function(t){}},{key:"registerInteractionHandler",value:function(t,e){}},{key:"deregisterInteractionHandler",value:function(t,e){}},{key:"registerResizeHandler",value:function(t){}},{key:"deregisterResizeHandler",value:function(t){}},{key:"updateCssVariable",value:function(t,e){}},{key:"computeBoundingRect",value:function(){}},{key:"getWindowPageOffset",value:function(){}}])}()},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),n.d(e,"MDCRipple",function(){return d});var o=n(1),u=(n(4),n(6)),s=n(3);n.d(e,"MDCRippleFoundation",function(){return u.a}),n.d(e,"util",function(){return s});var c=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),d=function(t){function e(){var t;i(this,e);for(var n=arguments.length,a=Array(n),o=0;o<n;o++)a[o]=arguments[o];var u=r(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(a)));return u.disabled=!1,u.unbounded_,u}return a(e,t),c(e,[{key:"activate",value:function(){this.foundation_.activate()}},{key:"deactivate",value:function(){this.foundation_.deactivate()}},{key:"layout",value:function(){this.foundation_.layout()}},{key:"getDefaultFoundation",value:function(){return new u.a(e.createAdapter(this))}},{key:"initialSyncWithDOM",value:function(){this.unbounded="mdcRippleIsUnbounded"in this.root_.dataset}},{key:"unbounded",get:function(){return this.unbounded_},set:function(t){var e=u.a.cssClasses.UNBOUNDED;this.unbounded_=Boolean(t),this.unbounded_?this.root_.classList.add(e):this.root_.classList.remove(e)}}],[{key:"attachTo",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=n.isUnbounded,r=void 0===i?void 0:i,a=new e(t);return void 0!==r&&(a.unbounded=r),a}},{key:"createAdapter",value:function(t){var e=s.getMatchesProperty(HTMLElement.prototype);return{browserSupportsCssVars:function(){return s.supportsCssVariables(window)},isUnbounded:function(){return t.unbounded},isSurfaceActive:function(){return t.root_[e](":active")},isSurfaceDisabled:function(){return t.disabled},addClass:function(e){return t.root_.classList.add(e)},removeClass:function(e){return t.root_.classList.remove(e)},registerInteractionHandler:function(e,n){return t.root_.addEventListener(e,n,s.applyPassive())},deregisterInteractionHandler:function(e,n){return t.root_.removeEventListener(e,n,s.applyPassive())},registerResizeHandler:function(t){return window.addEventListener("resize",t)},deregisterResizeHandler:function(t){return window.removeEventListener("resize",t)},updateCssVariable:function(e,n){return t.root_.style.setProperty(e,n)},computeBoundingRect:function(){return t.root_.getBoundingClientRect()},getWindowPageOffset:function(){return{x:window.pageXOffset,y:window.pageYOffset}}}}}]),e}(o.a),l=function t(){i(this,t)};l.prototype.root_,l.prototype.unbounded,l.prototype.disabled},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}var o=n(0),u=(n(4),n(7)),s=n(3),c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},d=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),l={mouseup:"mousedown",pointerup:"pointerdown",touchend:"touchstart",keyup:"keydown",blur:"focus"},f=function(t){function e(t){i(this,e);var n=r(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,c(e.defaultAdapter,t)));return n.layoutFrame_=0,n.frame_={width:0,height:0},n.activationState_=n.defaultActivationState_(),n.xfDuration_=0,n.initialSize_=0,n.maxRadius_=0,n.listenerInfos_=[{activate:"touchstart",deactivate:"touchend"},{activate:"pointerdown",deactivate:"pointerup"},{activate:"mousedown",deactivate:"mouseup"},{activate:"keydown",deactivate:"keyup"},{focus:"focus",blur:"blur"}],n.listeners_={activate:function(t){return n.activate_(t)},deactivate:function(t){return n.deactivate_(t)},focus:function(){return requestAnimationFrame(function(){return n.adapter_.addClass(e.cssClasses.BG_FOCUSED)})},blur:function(){return requestAnimationFrame(function(){return n.adapter_.removeClass(e.cssClasses.BG_FOCUSED)})}},n.resizeHandler_=function(){return n.layout()},n.unboundedCoords_={left:0,top:0},n.fgScale_=0,n.activationTimer_=0,n.fgDeactivationRemovalTimer_=0,n.activationAnimationHasEnded_=!1,n.activationTimerCallback_=function(){n.activationAnimationHasEnded_=!0,n.runDeactivationUXLogicIfReady_()},n}return a(e,t),d(e,[{key:"isSupported_",get:function(){return this.adapter_.browserSupportsCssVars()}}],[{key:"cssClasses",get:function(){return u.a}},{key:"strings",get:function(){return u.c}},{key:"numbers",get:function(){return u.b}},{key:"defaultAdapter",get:function(){return{browserSupportsCssVars:function(){},isUnbounded:function(){},isSurfaceActive:function(){},isSurfaceDisabled:function(){},addClass:function(){},removeClass:function(){},registerInteractionHandler:function(){},deregisterInteractionHandler:function(){},registerResizeHandler:function(){},deregisterResizeHandler:function(){},updateCssVariable:function(){},computeBoundingRect:function(){},getWindowPageOffset:function(){}}}}]),d(e,[{key:"defaultActivationState_",value:function(){return{isActivated:!1,hasDeactivationUXRun:!1,wasActivatedByPointer:!1,wasElementMadeActive:!1,activationStartTime:0,activationEvent:null,isProgrammatic:!1}}},{key:"init",value:function(){var t=this;if(this.isSupported_){this.addEventListeners_();var n=e.cssClasses,i=n.ROOT,r=n.UNBOUNDED;requestAnimationFrame(function(){t.adapter_.addClass(i),t.adapter_.isUnbounded()&&t.adapter_.addClass(r),t.layoutInternal_()})}}},{key:"addEventListeners_",value:function(){var t=this;this.listenerInfos_.forEach(function(e){Object.keys(e).forEach(function(n){t.adapter_.registerInteractionHandler(e[n],t.listeners_[n])})}),this.adapter_.registerResizeHandler(this.resizeHandler_)}},{key:"activate_",value:function(t){var e=this;if(!this.adapter_.isSurfaceDisabled()){var n=this.activationState_;n.isActivated||(n.isActivated=!0,n.isProgrammatic=null===t,n.activationEvent=t,n.wasActivatedByPointer=!n.isProgrammatic&&("mousedown"===t.type||"touchstart"===t.type||"pointerdown"===t.type),n.activationStartTime=Date.now(),requestAnimationFrame(function(){n.wasElementMadeActive=!t||"keydown"!==t.type||e.adapter_.isSurfaceActive(),n.wasElementMadeActive?e.animateActivation_():e.activationState_=e.defaultActivationState_()}))}}},{key:"activate",value:function(){this.activate_(null)}},{key:"animateActivation_",value:function(){var t=this,n=e.strings,i=n.VAR_FG_TRANSLATE_START,r=n.VAR_FG_TRANSLATE_END,a=e.cssClasses,o=a.BG_ACTIVE_FILL,u=a.FG_DEACTIVATION,s=a.FG_ACTIVATION,c=e.numbers.DEACTIVATION_TIMEOUT_MS,d="",l="";if(!this.adapter_.isUnbounded()){var f=this.getFgTranslationCoordinates_(),_=f.startPoint,p=f.endPoint;d=_.x+"px, "+_.y+"px",l=p.x+"px, "+p.y+"px"}this.adapter_.updateCssVariable(i,d),this.adapter_.updateCssVariable(r,l),clearTimeout(this.activationTimer_),clearTimeout(this.fgDeactivationRemovalTimer_),this.rmBoundedActivationClasses_(),this.adapter_.removeClass(u),this.adapter_.computeBoundingRect(),this.adapter_.addClass(o),this.adapter_.addClass(s),this.activationTimer_=setTimeout(function(){return t.activationTimerCallback_()},c)}},{key:"getFgTranslationCoordinates_",value:function(){var t=this.activationState_,e=t.activationEvent,n=t.wasActivatedByPointer,i=void 0;return i=n?s.getNormalizedEventCoords(e,this.adapter_.getWindowPageOffset(),this.adapter_.computeBoundingRect()):{x:this.frame_.width/2,y:this.frame_.height/2},i={x:i.x-this.initialSize_/2,y:i.y-this.initialSize_/2},{startPoint:i,endPoint:{x:this.frame_.width/2-this.initialSize_/2,y:this.frame_.height/2-this.initialSize_/2}}}},{key:"runDeactivationUXLogicIfReady_",value:function(){var t=this,n=e.cssClasses.FG_DEACTIVATION,i=this.activationState_,r=i.hasDeactivationUXRun,a=i.isActivated;(r||!a)&&this.activationAnimationHasEnded_&&(this.rmBoundedActivationClasses_(),this.adapter_.addClass(n),this.fgDeactivationRemovalTimer_=setTimeout(function(){t.adapter_.removeClass(n)},u.b.FG_DEACTIVATION_MS))}},{key:"rmBoundedActivationClasses_",value:function(){var t=e.cssClasses,n=t.BG_ACTIVE_FILL,i=t.FG_ACTIVATION;this.adapter_.removeClass(n),this.adapter_.removeClass(i),this.activationAnimationHasEnded_=!1,this.adapter_.computeBoundingRect()}},{key:"deactivate_",value:function(t){var e=this,n=this.activationState_;if(n.isActivated){if(n.isProgrammatic){var i=c({},n);return requestAnimationFrame(function(){return e.animateDeactivation_(null,i)}),void(this.activationState_=this.defaultActivationState_())}var r=l[t.type],a=n.activationEvent.type,o=r===a,u=o;n.wasActivatedByPointer&&(u="mouseup"===t.type);var s=c({},n);requestAnimationFrame(function(){o&&(e.activationState_.hasDeactivationUXRun=!0,e.animateDeactivation_(t,s)),u&&(e.activationState_=e.defaultActivationState_())})}}},{key:"deactivate",value:function(){this.deactivate_(null)}},{key:"animateDeactivation_",value:function(t,n){var i=n.wasActivatedByPointer,r=n.wasElementMadeActive,a=e.cssClasses.BG_FOCUSED;(i||r)&&(this.adapter_.removeClass(a),this.runDeactivationUXLogicIfReady_())}},{key:"destroy",value:function(){var t=this;if(this.isSupported_){this.removeEventListeners_();var n=e.cssClasses,i=n.ROOT,r=n.UNBOUNDED;requestAnimationFrame(function(){t.adapter_.removeClass(i),t.adapter_.removeClass(r),t.removeCssVars_()})}}},{key:"removeEventListeners_",value:function(){var t=this;this.listenerInfos_.forEach(function(e){Object.keys(e).forEach(function(n){t.adapter_.deregisterInteractionHandler(e[n],t.listeners_[n])})}),this.adapter_.deregisterResizeHandler(this.resizeHandler_)}},{key:"removeCssVars_",value:function(){var t=this,n=e.strings;Object.keys(n).forEach(function(e){0===e.indexOf("VAR_")&&t.adapter_.updateCssVariable(n[e],null)})}},{key:"layout",value:function(){var t=this;this.layoutFrame_&&cancelAnimationFrame(this.layoutFrame_),this.layoutFrame_=requestAnimationFrame(function(){t.layoutInternal_(),t.layoutFrame_=0})}},{key:"layoutInternal_",value:function(){this.frame_=this.adapter_.computeBoundingRect();var t=Math.max(this.frame_.height,this.frame_.width),n=Math.sqrt(Math.pow(this.frame_.width,2)+Math.pow(this.frame_.height,2));this.initialSize_=t*e.numbers.INITIAL_ORIGIN_SCALE,this.maxRadius_=n+e.numbers.PADDING,this.fgScale_=this.maxRadius_/this.initialSize_,this.xfDuration_=1e3*Math.sqrt(this.maxRadius_/1024),this.updateLayoutCssVars_()}},{key:"updateLayoutCssVars_",value:function(){var t=e.strings,n=t.VAR_SURFACE_WIDTH,i=t.VAR_SURFACE_HEIGHT,r=t.VAR_FG_SIZE,a=t.VAR_LEFT,o=t.VAR_TOP,u=t.VAR_FG_SCALE;this.adapter_.updateCssVariable(n,this.frame_.width+"px"),this.adapter_.updateCssVariable(i,this.frame_.height+"px"),this.adapter_.updateCssVariable(r,this.initialSize_+"px"),this.adapter_.updateCssVariable(u,this.fgScale_),this.adapter_.isUnbounded()&&(this.unboundedCoords_={left:Math.round(this.frame_.width/2-this.initialSize_/2),top:Math.round(this.frame_.height/2-this.initialSize_/2)},this.adapter_.updateCssVariable(a,this.unboundedCoords_.left+"px"),this.adapter_.updateCssVariable(o,this.unboundedCoords_.top+"px"))}}]),e}(o.a);e.a=f},function(t,e,n){"use strict";n.d(e,"a",function(){return i}),n.d(e,"c",function(){return r}),n.d(e,"b",function(){return a});var i={ROOT:"mdc-ripple-upgraded",UNBOUNDED:"mdc-ripple-upgraded--unbounded",BG_FOCUSED:"mdc-ripple-upgraded--background-focused",BG_ACTIVE_FILL:"mdc-ripple-upgraded--background-active-fill",FG_ACTIVATION:"mdc-ripple-upgraded--foreground-activation",FG_DEACTIVATION:"mdc-ripple-upgraded--foreground-deactivation"},r={VAR_SURFACE_WIDTH:"--mdc-ripple-surface-width",VAR_SURFACE_HEIGHT:"--mdc-ripple-surface-height",VAR_FG_SIZE:"--mdc-ripple-fg-size",VAR_LEFT:"--mdc-ripple-left",VAR_TOP:"--mdc-ripple-top",VAR_FG_SCALE:"--mdc-ripple-fg-scale",VAR_FG_TRANSLATE_START:"--mdc-ripple-fg-translate-start",VAR_FG_TRANSLATE_END:"--mdc-ripple-fg-translate-end"},a={PADDING:10,INITIAL_ORIGIN_SCALE:.6,DEACTIVATION_TIMEOUT_MS:300,FG_DEACTIVATION_MS:83}},function(t,e,n){"use strict";function i(t){return void 0!==t.document&&"function"==typeof t.document.createElement}function r(t){return t in c||t in d}function a(t,e,n){return e[t].styleProperty in n.style?e[t].noPrefix:e[t].webkitPrefix}function o(t,e){if(!i(t)||!r(e))return e;var n=e in c?c:d,o=t.document.createElement("div");return n===c?a(e,n,o):n[e].noPrefix in o.style?n[e].noPrefix:n[e].webkitPrefix}function u(t,e){return o(t,e)}function s(t,e){return o(t,e)}Object.defineProperty(e,"__esModule",{value:!0}),n.d(e,"transformStyleProperties",function(){return l}),e.getCorrectEventName=u,e.getCorrectPropertyName=s;var c={animationstart:{noPrefix:"animationstart",webkitPrefix:"webkitAnimationStart",styleProperty:"animation"},animationend:{noPrefix:"animationend",webkitPrefix:"webkitAnimationEnd",styleProperty:"animation"},animationiteration:{noPrefix:"animationiteration",webkitPrefix:"webkitAnimationIteration",styleProperty:"animation"},transitionend:{noPrefix:"transitionend",webkitPrefix:"webkitTransitionEnd",styleProperty:"transition"}},d={animation:{noPrefix:"animation",webkitPrefix:"-webkit-animation"},transform:{noPrefix:"transform",webkitPrefix:"-webkit-transform"},transition:{noPrefix:"transition",webkitPrefix:"-webkit-transition"}},l=["transform","WebkitTransform","MozTransform","OTransform","MSTransform"]},,,,,,,,,function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}();!function(){function t(){i(this,t)}r(t,[{key:"addClass",value:function(t){}},{key:"removeClass",value:function(t){}},{key:"registerAnimationEndHandler",value:function(t){}},{key:"deregisterAnimationEndHandler",value:function(t){}},{key:"registerChangeHandler",value:function(t){}},{key:"deregisterChangeHandler",value:function(t){}},{key:"getNativeControl",value:function(){}},{key:"forceLayout",value:function(){}},{key:"isAttachedToDOM",value:function(){}}])}()},,,,,,,,,,function(t,e,n){t.exports=n(28)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),n.d(e,"MDCCheckbox",function(){return p});var o=n(8),u=n(1),s=(n(17),n(29)),c=n(5),d=n(3);n.d(e,"MDCCheckboxFoundation",function(){return s.a});var l=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},f=function t(e,n,i){null===e&&(e=Function.prototype);var r=Object.getOwnPropertyDescriptor(e,n);if(void 0===r){var a=Object.getPrototypeOf(e);return null===a?void 0:t(a,n,i)}if("value"in r)return r.value;var o=r.get;if(void 0!==o)return o.call(i)},_=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),p=function(t){function e(){var t;i(this,e);for(var n=arguments.length,a=Array(n),o=0;o<n;o++)a[o]=arguments[o];var u=r(this,(t=e.__proto__||Object.getPrototypeOf(e)).call.apply(t,[this].concat(a)));return u.ripple_=u.initRipple_(),u}return a(e,t),_(e,[{key:"nativeCb_",get:function(){var t=s.a.strings.NATIVE_CONTROL_SELECTOR;return this.root_.querySelector(t)}}],[{key:"attachTo",value:function(t){return new e(t)}}]),_(e,[{key:"initRipple_",value:function(){var t=this,e=d.getMatchesProperty(HTMLElement.prototype),n=l(c.MDCRipple.createAdapter(this),{isUnbounded:function(){return!0},isSurfaceActive:function(){return t.nativeCb_[e](":active")},registerInteractionHandler:function(e,n){return t.nativeCb_.addEventListener(e,n)},deregisterInteractionHandler:function(e,n){return t.nativeCb_.removeEventListener(e,n)},computeBoundingRect:function(){var e=t.root_.getBoundingClientRect(),n=e.left,i=e.top;return{top:i,left:n,right:n+40,bottom:i+40,width:40,height:40}}}),i=new c.MDCRippleFoundation(n);return new c.MDCRipple(this.root_,i)}},{key:"getDefaultFoundation",value:function(){var t=this;return new s.a({addClass:function(e){return t.root_.classList.add(e)},removeClass:function(e){return t.root_.classList.remove(e)},registerAnimationEndHandler:function(e){return t.root_.addEventListener(o.getCorrectEventName(window,"animationend"),e)},deregisterAnimationEndHandler:function(e){return t.root_.removeEventListener(o.getCorrectEventName(window,"animationend"),e)},registerChangeHandler:function(e){return t.nativeCb_.addEventListener("change",e)},deregisterChangeHandler:function(e){return t.nativeCb_.removeEventListener("change",e)},getNativeControl:function(){return t.nativeCb_},forceLayout:function(){return t.root_.offsetWidth},isAttachedToDOM:function(){return Boolean(t.root_.parentNode)}})}},{key:"destroy",value:function(){this.ripple_.destroy(),f(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"destroy",this).call(this)}},{key:"ripple",get:function(){return this.ripple_}},{key:"checked",get:function(){return this.foundation_.isChecked()},set:function(t){this.foundation_.setChecked(t)}},{key:"indeterminate",get:function(){return this.foundation_.isIndeterminate()},set:function(t){this.foundation_.setIndeterminate(t)}},{key:"disabled",get:function(){return this.foundation_.isDisabled()},set:function(t){this.foundation_.setDisabled(t)}},{key:"value",get:function(){return this.foundation_.getValue()},set:function(t){this.foundation_.setValue(t)}}]),e}(u.a)},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function o(t){return!!t&&"function"==typeof t.set}var u=n(0),s=(n(17),n(30)),c=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},d=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),l=["checked","indeterminate"],f=function(t){function e(t){i(this,e);var n=r(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,c(e.defaultAdapter,t)));return n.currentCheckState_=s.c.TRANSITION_STATE_INIT,n.currentAnimationClass_="",n.animEndLatchTimer_=0,n.animEndHandler_=function(){clearTimeout(n.animEndLatchTimer_),n.animEndLatchTimer_=setTimeout(function(){n.adapter_.removeClass(n.currentAnimationClass_),n.adapter_.deregisterAnimationEndHandler(n.animEndHandler_)},s.b.ANIM_END_LATCH_MS)},n.changeHandler_=function(){return n.transitionCheckState_()},n}return a(e,t),d(e,null,[{key:"cssClasses",get:function(){return s.a}},{key:"strings",get:function(){return s.c}},{key:"numbers",get:function(){return s.b}},{key:"defaultAdapter",get:function(){return{addClass:function(){},removeClass:function(){},registerAnimationEndHandler:function(){},deregisterAnimationEndHandler:function(){},registerChangeHandler:function(){},deregisterChangeHandler:function(){},getNativeControl:function(){},forceLayout:function(){},isAttachedToDOM:function(){}}}}]),d(e,[{key:"init",value:function(){this.adapter_.addClass(s.a.UPGRADED),this.adapter_.registerChangeHandler(this.changeHandler_),this.installPropertyChangeHooks_()}},{key:"destroy",value:function(){this.adapter_.deregisterChangeHandler(this.changeHandler_),this.uninstallPropertyChangeHooks_()}},{key:"isChecked",value:function(){return this.getNativeControl_().checked}},{key:"setChecked",value:function(t){this.getNativeControl_().checked=t}},{key:"isIndeterminate",value:function(){return this.getNativeControl_().indeterminate}},{key:"setIndeterminate",value:function(t){this.getNativeControl_().indeterminate=t}},{key:"isDisabled",value:function(){return this.getNativeControl_().disabled}},{key:"setDisabled",value:function(t){this.getNativeControl_().disabled=t,t?this.adapter_.addClass(s.a.DISABLED):this.adapter_.removeClass(s.a.DISABLED)}},{key:"getValue",value:function(){return this.getNativeControl_().value}},{key:"setValue",value:function(t){this.getNativeControl_().value=t}},{key:"installPropertyChangeHooks_",value:function(){var t=this,e=this.getNativeControl_(),n=Object.getPrototypeOf(e);l.forEach(function(i){var r=Object.getOwnPropertyDescriptor(n,i);if(o(r)){var a={get:r.get,set:function(n){r.set.call(e,n),t.transitionCheckState_()},configurable:r.configurable,enumerable:r.enumerable};Object.defineProperty(e,i,a)}})}},{key:"uninstallPropertyChangeHooks_",value:function(){var t=this.getNativeControl_(),e=Object.getPrototypeOf(t);l.forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);o(i)&&Object.defineProperty(t,n,i)})}},{key:"transitionCheckState_",value:function(){var t=this.adapter_.getNativeControl();if(t){var e=this.currentCheckState_,n=this.determineCheckState_(t);e!==n&&(this.currentAnimationClass_.length>0&&(clearTimeout(this.animEndLatchTimer_),this.adapter_.forceLayout(),this.adapter_.removeClass(this.currentAnimationClass_)),this.currentAnimationClass_=this.getTransitionAnimationClass_(e,n),this.currentCheckState_=n,this.adapter_.isAttachedToDOM()&&this.currentAnimationClass_.length>0&&(this.adapter_.addClass(this.currentAnimationClass_),this.adapter_.registerAnimationEndHandler(this.animEndHandler_)))}}},{key:"determineCheckState_",value:function(t){var e=s.c.TRANSITION_STATE_INDETERMINATE,n=s.c.TRANSITION_STATE_CHECKED,i=s.c.TRANSITION_STATE_UNCHECKED;return t.indeterminate?e:t.checked?n:i}},{key:"getTransitionAnimationClass_",value:function(t,n){var i=s.c.TRANSITION_STATE_INIT,r=s.c.TRANSITION_STATE_CHECKED,a=s.c.TRANSITION_STATE_UNCHECKED,o=e.cssClasses,u=o.ANIM_UNCHECKED_CHECKED,c=o.ANIM_UNCHECKED_INDETERMINATE,d=o.ANIM_CHECKED_UNCHECKED,l=o.ANIM_CHECKED_INDETERMINATE,f=o.ANIM_INDETERMINATE_CHECKED,_=o.ANIM_INDETERMINATE_UNCHECKED;switch(t){case i:if(n===a)return"";case a:return n===r?u:c;case r:return n===a?d:l;default:return n===r?f:_}}},{key:"getNativeControl_",value:function(){return this.adapter_.getNativeControl()||{checked:!1,indeterminate:!1,disabled:!1,value:null}}}]),e}(u.a);e.a=f},function(t,e,n){"use strict";n.d(e,"a",function(){return i}),n.d(e,"c",function(){return r}),n.d(e,"b",function(){return a});var i={UPGRADED:"mdc-checkbox--upgraded",CHECKED:"mdc-checkbox--checked",INDETERMINATE:"mdc-checkbox--indeterminate",DISABLED:"mdc-checkbox--disabled",ANIM_UNCHECKED_CHECKED:"mdc-checkbox--anim-unchecked-checked",ANIM_UNCHECKED_INDETERMINATE:"mdc-checkbox--anim-unchecked-indeterminate",ANIM_CHECKED_UNCHECKED:"mdc-checkbox--anim-checked-unchecked",ANIM_CHECKED_INDETERMINATE:"mdc-checkbox--anim-checked-indeterminate",ANIM_INDETERMINATE_CHECKED:"mdc-checkbox--anim-indeterminate-checked",ANIM_INDETERMINATE_UNCHECKED:"mdc-checkbox--anim-indeterminate-unchecked"},r={NATIVE_CONTROL_SELECTOR:".mdc-checkbox__native-control",TRANSITION_STATE_INIT:"init",TRANSITION_STATE_CHECKED:"checked",TRANSITION_STATE_UNCHECKED:"unchecked",TRANSITION_STATE_INDETERMINATE:"indeterminate"},a={ANIM_END_LATCH_MS:100}}])}); |
@@ -17,7 +17,14 @@ /** | ||
import {MDCFoundation} from '@material/base'; | ||
import MDCFoundation from '@material/base/foundation'; | ||
/* eslint-disable no-unused-vars */ | ||
import {MDCCheckboxAdapter, InputElementState} from './adapter'; | ||
/* eslint-enable no-unused-vars */ | ||
import {cssClasses, strings, numbers} from './constants'; | ||
/** @const {!Array<string>} */ | ||
const CB_PROTO_PROPS = ['checked', 'indeterminate']; | ||
/** | ||
* @extends {MDCFoundation<!MDCCheckboxAdapter>} | ||
*/ | ||
export default class MDCCheckboxFoundation extends MDCFoundation { | ||
@@ -44,3 +51,3 @@ static get cssClasses() { | ||
deregisterChangeHandler: (/* handler: EventListener */) => {}, | ||
getNativeControl: () => /* HTMLInputElement */ {}, | ||
getNativeControl: () => /* InputElementState */ {}, | ||
forceLayout: () => {}, | ||
@@ -54,6 +61,12 @@ isAttachedToDOM: () => /* boolean */ {}, | ||
/** @private {string} */ | ||
this.currentCheckState_ = strings.TRANSITION_STATE_INIT; | ||
/** @private {string} */ | ||
this.currentAnimationClass_ = ''; | ||
/** @private {number} */ | ||
this.animEndLatchTimer_ = 0; | ||
this.animEndHandler_ = () => { | ||
this.animEndHandler_ = /** @private {!EventListener} */ (() => { | ||
clearTimeout(this.animEndLatchTimer_); | ||
@@ -64,4 +77,6 @@ this.animEndLatchTimer_ = setTimeout(() => { | ||
}, numbers.ANIM_END_LATCH_MS); | ||
}; | ||
this.changeHandler_ = () => this.transitionCheckState_(); | ||
}); | ||
this.changeHandler_ = /** @private {!EventListener} */ ( | ||
() => this.transitionCheckState_()); | ||
} | ||
@@ -80,2 +95,3 @@ | ||
/** @return {boolean} */ | ||
isChecked() { | ||
@@ -85,2 +101,3 @@ return this.getNativeControl_().checked; | ||
/** @param {boolean} checked */ | ||
setChecked(checked) { | ||
@@ -90,2 +107,3 @@ this.getNativeControl_().checked = checked; | ||
/** @return {boolean} */ | ||
isIndeterminate() { | ||
@@ -95,2 +113,3 @@ return this.getNativeControl_().indeterminate; | ||
/** @param {boolean} indeterminate */ | ||
setIndeterminate(indeterminate) { | ||
@@ -100,2 +119,3 @@ this.getNativeControl_().indeterminate = indeterminate; | ||
/** @return {boolean} */ | ||
isDisabled() { | ||
@@ -105,2 +125,3 @@ return this.getNativeControl_().disabled; | ||
/** @param {boolean} disabled */ | ||
setDisabled(disabled) { | ||
@@ -115,2 +136,3 @@ this.getNativeControl_().disabled = disabled; | ||
/** @return {?string} */ | ||
getValue() { | ||
@@ -120,2 +142,3 @@ return this.getNativeControl_().value; | ||
/** @param {?string} value */ | ||
setValue(value) { | ||
@@ -125,2 +148,3 @@ this.getNativeControl_().value = value; | ||
/** @private */ | ||
installPropertyChangeHooks_() { | ||
@@ -135,3 +159,3 @@ const nativeCb = this.getNativeControl_(); | ||
if (validDescriptor(desc)) { | ||
Object.defineProperty(nativeCb, controlState, { | ||
const nativeCbDesc = /** @type {!ObjectPropertyDescriptor} */ ({ | ||
get: desc.get, | ||
@@ -145,2 +169,3 @@ set: (state) => { | ||
}); | ||
Object.defineProperty(nativeCb, controlState, nativeCbDesc); | ||
} | ||
@@ -150,2 +175,3 @@ }); | ||
/** @private */ | ||
uninstallPropertyChangeHooks_() { | ||
@@ -156,3 +182,4 @@ const nativeCb = this.getNativeControl_(); | ||
CB_PROTO_PROPS.forEach((controlState) => { | ||
const desc = Object.getOwnPropertyDescriptor(cbProto, controlState); | ||
const desc = /** @type {!ObjectPropertyDescriptor} */ ( | ||
Object.getOwnPropertyDescriptor(cbProto, controlState)); | ||
if (validDescriptor(desc)) { | ||
@@ -164,2 +191,3 @@ Object.defineProperty(nativeCb, controlState, desc); | ||
/** @private */ | ||
transitionCheckState_() { | ||
@@ -195,2 +223,7 @@ const nativeCb = this.adapter_.getNativeControl(); | ||
/** | ||
* @param {!InputElementState} nativeCb | ||
* @return {string} | ||
* @private | ||
*/ | ||
determineCheckState_(nativeCb) { | ||
@@ -209,2 +242,7 @@ const { | ||
/** | ||
* @param {string} oldState | ||
* @param {string} newState | ||
* @return {string} | ||
*/ | ||
getTransitionAnimationClass_(oldState, newState) { | ||
@@ -231,3 +269,3 @@ const { | ||
} | ||
// fallthrough | ||
// fallthrough | ||
case TRANSITION_STATE_UNCHECKED: | ||
@@ -237,9 +275,13 @@ return newState === TRANSITION_STATE_CHECKED ? ANIM_UNCHECKED_CHECKED : ANIM_UNCHECKED_INDETERMINATE; | ||
return newState === TRANSITION_STATE_UNCHECKED ? ANIM_CHECKED_UNCHECKED : ANIM_CHECKED_INDETERMINATE; | ||
// TRANSITION_STATE_INDETERMINATE | ||
// TRANSITION_STATE_INDETERMINATE | ||
default: | ||
return newState === TRANSITION_STATE_CHECKED ? | ||
ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED; | ||
ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED; | ||
} | ||
} | ||
/** | ||
* @return {!InputElementState} | ||
* @private | ||
*/ | ||
getNativeControl_() { | ||
@@ -255,4 +297,8 @@ return this.adapter_.getNativeControl() || { | ||
/** | ||
* @param {ObjectPropertyDescriptor|undefined} inputPropDesc | ||
* @return {boolean} | ||
*/ | ||
function validDescriptor(inputPropDesc) { | ||
return inputPropDesc && typeof inputPropDesc.set === 'function'; | ||
return !!inputPropDesc && typeof inputPropDesc.set === 'function'; | ||
} |
37
index.js
@@ -17,11 +17,16 @@ /** | ||
import {MDCComponent} from '@material/base'; | ||
import {getCorrectEventName} from '@material/animation'; | ||
import MDCComponent from '@material/base/component'; | ||
/* eslint-disable no-unused-vars */ | ||
import {InputElementState} from './adapter'; | ||
/* eslint-enable no-unused-vars */ | ||
import MDCCheckboxFoundation from './foundation'; | ||
import {MDCRipple, MDCRippleFoundation} from '@material/ripple'; | ||
import {getMatchesProperty} from '@material/ripple/util'; | ||
import {getCorrectEventName} from '@material/animation'; | ||
import MDCCheckboxFoundation from './foundation'; | ||
export {MDCCheckboxFoundation}; | ||
/** | ||
* @extends MDCComponent<!MDCCheckboxFoundation> | ||
*/ | ||
export class MDCCheckbox extends MDCComponent { | ||
@@ -32,5 +37,11 @@ static attachTo(root) { | ||
/** | ||
* @return {InputElementState|undefined} | ||
* @private | ||
*/ | ||
get nativeCb_() { | ||
const {NATIVE_CONTROL_SELECTOR} = MDCCheckboxFoundation.strings; | ||
return this.root_.querySelector(NATIVE_CONTROL_SELECTOR); | ||
const cbEl = /** @type {InputElementState|undefined} */ ( | ||
this.root_.querySelector(NATIVE_CONTROL_SELECTOR)); | ||
return cbEl; | ||
} | ||
@@ -40,5 +51,11 @@ | ||
super(...args); | ||
/** @private {!MDCRipple} */ | ||
this.ripple_ = this.initRipple_(); | ||
} | ||
/** | ||
* @return {!MDCRipple} | ||
* @private | ||
*/ | ||
initRipple_() { | ||
@@ -68,2 +85,3 @@ const MATCHES = getMatchesProperty(HTMLElement.prototype); | ||
/** @return {!MDCCheckboxFoundation} */ | ||
getDefaultFoundation() { | ||
@@ -85,2 +103,3 @@ return new MDCCheckboxFoundation({ | ||
/** @return {!MDCRipple} */ | ||
get ripple() { | ||
@@ -90,2 +109,3 @@ return this.ripple_; | ||
/** @return {boolean} */ | ||
get checked() { | ||
@@ -95,2 +115,3 @@ return this.foundation_.isChecked(); | ||
/** @param {boolean} checked */ | ||
set checked(checked) { | ||
@@ -100,2 +121,3 @@ this.foundation_.setChecked(checked); | ||
/** @return {boolean} */ | ||
get indeterminate() { | ||
@@ -105,2 +127,3 @@ return this.foundation_.isIndeterminate(); | ||
/** @param {boolean} indeterminate */ | ||
set indeterminate(indeterminate) { | ||
@@ -110,2 +133,3 @@ this.foundation_.setIndeterminate(indeterminate); | ||
/** @return {boolean} */ | ||
get disabled() { | ||
@@ -115,2 +139,3 @@ return this.foundation_.isDisabled(); | ||
/** @param {boolean} disabled */ | ||
set disabled(disabled) { | ||
@@ -120,2 +145,3 @@ this.foundation_.setDisabled(disabled); | ||
/** @return {?string} */ | ||
get value() { | ||
@@ -125,2 +151,3 @@ return this.foundation_.getValue(); | ||
/** @param {?string} value */ | ||
set value(value) { | ||
@@ -127,0 +154,0 @@ this.foundation_.setValue(value); |
{ | ||
"name": "@material/checkbox", | ||
"description": "The Material Components for the web checkbox component", | ||
"version": "0.3.7", | ||
"version": "0.4.0", | ||
"license": "Apache-2.0", | ||
@@ -18,4 +18,4 @@ "keywords": [ | ||
"@material/animation": "^0.2.3", | ||
"@material/base": "^0.2.1", | ||
"@material/ripple": "^0.7.0", | ||
"@material/base": "^0.2.2", | ||
"@material/ripple": "^0.8.0", | ||
"@material/rtl": "^0.1.6", | ||
@@ -22,0 +22,0 @@ "@material/theme": "^0.1.5" |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
220985
13
3505
1
+ Added@material/ripple@0.8.8(transitive)
+ Added@material/theme@0.4.0(transitive)
- Removed@material/ripple@0.7.0(transitive)
Updated@material/base@^0.2.2
Updated@material/ripple@^0.8.0