Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@material/snackbar

Package Overview
Dependencies
Maintainers
17
Versions
1684
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@material/snackbar - npm Package Compare versions

Comparing version 4.0.0-canary.1 to 4.0.0-canary.735147131.0

178

CHANGELOG.md

@@ -6,2 +6,180 @@ # Change Log

# [4.0.0-canary.735147131.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.735147131.0) (2019-10-16)
### Features
* **icon-button:** Add density mixin to icon button ([#5122](https://github.com/material-components/material-components-web/issues/5122)) ([37d6458](https://github.com/material-components/material-components-web/commit/37d6458))
* **snackbar:** Add option for indefinite timeout ([#4998](https://github.com/material-components/material-components-web/issues/4998)) ([4f11851](https://github.com/material-components/material-components-web/commit/4f11851))
# [4.0.0-canary.5dc45b82a.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.5dc45b82a.0) (2019-10-16)
### Features
* **icon-button:** Add density mixin to icon button ([#5122](https://github.com/material-components/material-components-web/issues/5122)) ([37d6458](https://github.com/material-components/material-components-web/commit/37d6458))
* **snackbar:** Add option for indefinite timeout ([#4998](https://github.com/material-components/material-components-web/issues/4998)) ([4f11851](https://github.com/material-components/material-components-web/commit/4f11851))
# [4.0.0-canary.22d7ad2fb.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.22d7ad2fb.0) (2019-10-15)
### Features
* **icon-button:** Add density mixin to icon button ([#5122](https://github.com/material-components/material-components-web/issues/5122)) ([37d6458](https://github.com/material-components/material-components-web/commit/37d6458))
* **snackbar:** Add option for indefinite timeout ([#4998](https://github.com/material-components/material-components-web/issues/4998)) ([4f11851](https://github.com/material-components/material-components-web/commit/4f11851))
# [4.0.0-canary.199534d61.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.199534d61.0) (2019-09-27)
### Features
* **snackbar:** Add option for indefinite timeout ([#4998](https://github.com/material-components/material-components-web/issues/4998)) ([4f11851](https://github.com/material-components/material-components-web/commit/4f11851))
# [4.0.0-canary.905884690.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.905884690.0) (2019-09-16)
### Features
* **snackbar:** Add option for indefinite timeout ([#4998](https://github.com/material-components/material-components-web/issues/4998)) ([4f11851](https://github.com/material-components/material-components-web/commit/4f11851))
# [4.0.0-canary.e851d4f40.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.e851d4f40.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.e09c3b770.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.e09c3b770.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.b58076d4b.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.b58076d4b.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.22916a234.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.22916a234.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.c7e991001.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.c7e991001.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [5.0.0-canary.b8513889d.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v5.0.0-canary.b8513889d.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.0c808fb33.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.0c808fb33.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.e3497b3e6.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.e3497b3e6.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.79d881baf.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.79d881baf.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.79d881baf.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.79d881baf.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.79d881baf.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.79d881baf.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.eab7903af.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.eab7903af.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.eab7903af.0](https://github.com/material-components/material-components-web/compare/v3.2.0...v4.0.0-canary.eab7903af.0) (2019-09-13)
**Note:** Version bump only for package @material/snackbar
# [3.2.0](https://github.com/material-components/material-components-web/compare/v3.1.1...v3.2.0) (2019-09-12)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-edc72a4d7.0](https://github.com/material-components/material-components-web/compare/v3.1.1...v4.0.0-edc72a4d7.0) (2019-09-09)
**Note:** Version bump only for package @material/snackbar
# [4.0.0-canary.1](https://github.com/material-components/material-components-web/compare/v3.1.1...v4.0.0-canary.1) (2019-09-09)

@@ -8,0 +186,0 @@

1

constants.d.ts

@@ -43,2 +43,3 @@ /**

DEFAULT_AUTO_DISMISS_TIMEOUT_MS: number;
INDETERMINATE: number;
MAX_AUTO_DISMISS_TIMEOUT_MS: number;

@@ -45,0 +46,0 @@ MIN_AUTO_DISMISS_TIMEOUT_MS: number;

@@ -43,2 +43,3 @@ /**

DEFAULT_AUTO_DISMISS_TIMEOUT_MS: 5000,
INDETERMINATE: -1,
MAX_AUTO_DISMISS_TIMEOUT_MS: 10000,

@@ -45,0 +46,0 @@ MIN_AUTO_DISMISS_TIMEOUT_MS: 4000,

@@ -174,2 +174,3 @@ // Generated by dts-bundle v0.7.3

DEFAULT_AUTO_DISMISS_TIMEOUT_MS: number;
INDETERMINATE: number;
MAX_AUTO_DISMISS_TIMEOUT_MS: number;

@@ -235,2 +236,3 @@ MIN_AUTO_DISMISS_TIMEOUT_MS: number;

DEFAULT_AUTO_DISMISS_TIMEOUT_MS: number;
INDETERMINATE: number;
MAX_AUTO_DISMISS_TIMEOUT_MS: number;

@@ -237,0 +239,0 @@ MIN_AUTO_DISMISS_TIMEOUT_MS: number;

15

dist/mdc.snackbar.js

@@ -681,2 +681,3 @@ /**

DEFAULT_AUTO_DISMISS_TIMEOUT_MS: 5000,
INDETERMINATE: -1,
MAX_AUTO_DISMISS_TIMEOUT_MS: 10000,

@@ -853,7 +854,10 @@ MIN_AUTO_DISMISS_TIMEOUT_MS: 4000,

_this.animationTimer_ = setTimeout(function () {
var timeoutMs = _this.getTimeoutMs();
_this.handleAnimationTimerEnd_();
_this.adapter_.notifyOpened();
_this.autoDismissTimer_ = setTimeout(function () {
_this.close(REASON_DISMISS);
}, _this.getTimeoutMs());
if (timeoutMs !== constants_1.numbers.INDETERMINATE) {
_this.autoDismissTimer_ = setTimeout(function () {
_this.close(REASON_DISMISS);
}, timeoutMs);
}
}, constants_1.numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS);

@@ -900,6 +904,7 @@ });

var maxValue = constants_1.numbers.MAX_AUTO_DISMISS_TIMEOUT_MS;
if (timeoutMs <= maxValue && timeoutMs >= minValue) {
var indeterminateValue = constants_1.numbers.INDETERMINATE;
if (timeoutMs === constants_1.numbers.INDETERMINATE || timeoutMs <= maxValue && timeoutMs >= minValue) {
this.autoDismissTimeoutMs_ = timeoutMs;
} else {
throw new Error("timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + ", but got '" + timeoutMs + "'");
throw new Error("\n timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + "\n (or " + indeterminateValue + " to disable), but got '" + timeoutMs + "'");
}

@@ -906,0 +911,0 @@ };

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.snackbar=e():(t.mdc=t.mdc||{},t.mdc.snackbar=e())}(this,function(){return o={},i.m=n={0:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=(Object.defineProperty(i,"cssClasses",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(i,"strings",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(i,"numbers",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(i,"defaultAdapter",{get:function(){return{}},enumerable:!0,configurable:!0}),i.prototype.init=function(){},i.prototype.destroy=function(){},i);function i(t){void 0===t&&(t={}),this.adapter_=t}e.MDCFoundation=o,e.default=o},1:function(t,e,n){"use strict";var o=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,i,r=n.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(o=r.next()).done;)s.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s},i=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(o(arguments[e]));return t};Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),s=(a.attachTo=function(t){return new a(t,new r.MDCFoundation({}))},a.prototype.initialize=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]},a.prototype.getDefaultFoundation=function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")},a.prototype.initialSyncWithDOM=function(){},a.prototype.destroy=function(){this.foundation_.destroy()},a.prototype.listen=function(t,e,n){this.root_.addEventListener(t,e,n)},a.prototype.unlisten=function(t,e,n){this.root_.removeEventListener(t,e,n)},a.prototype.emit=function(t,e,n){var o;void 0===n&&(n=!1),"function"==typeof CustomEvent?o=new CustomEvent(t,{bubbles:n,detail:e}):(o=document.createEvent("CustomEvent")).initCustomEvent(t,n,!1,e),this.root_.dispatchEvent(o)},a);function a(t,e){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];this.root_=t,this.initialize.apply(this,i(n)),this.foundation_=void 0===e?this.getDefaultFoundation():e,this.foundation_.init(),this.initialSyncWithDOM()}e.MDCComponent=s,e.default=s},149:function(t,n,e){"use strict";function o(t){for(var e in t)n.hasOwnProperty(e)||(n[e]=t[e])}var i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(n,"__esModule",{value:!0});var r=i(e(89));n.util=r,o(e(150)),o(e(39)),o(e(90))},150:function(t,e,n){"use strict";var o,i=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var s,a=n(1),u=n(2),c=n(39),l=n(90),f=r(n(89)),_=c.strings.SURFACE_SELECTOR,p=c.strings.LABEL_SELECTOR,d=c.strings.ACTION_SELECTOR,m=c.strings.DISMISS_SELECTOR,h=c.strings.OPENING_EVENT,y=c.strings.OPENED_EVENT,O=c.strings.CLOSING_EVENT,b=c.strings.CLOSED_EVENT,E=(s=a.MDCComponent,i(C,s),C.attachTo=function(t){return new C(t)},C.prototype.initialize=function(t){void 0===t&&(t=function(){return f.announce}),this.announce_=t()},C.prototype.initialSyncWithDOM=function(){var n=this;this.surfaceEl_=this.root_.querySelector(_),this.labelEl_=this.root_.querySelector(p),this.actionEl_=this.root_.querySelector(d),this.handleKeyDown_=function(t){return n.foundation_.handleKeyDown(t)},this.handleSurfaceClick_=function(t){var e=t.target;n.isActionButton_(e)?n.foundation_.handleActionButtonClick(t):n.isActionIcon_(e)&&n.foundation_.handleActionIconClick(t)},this.registerKeyDownHandler_(this.handleKeyDown_),this.registerSurfaceClickHandler_(this.handleSurfaceClick_)},C.prototype.destroy=function(){s.prototype.destroy.call(this),this.deregisterKeyDownHandler_(this.handleKeyDown_),this.deregisterSurfaceClickHandler_(this.handleSurfaceClick_)},C.prototype.open=function(){this.foundation_.open()},C.prototype.close=function(t){void 0===t&&(t=""),this.foundation_.close(t)},C.prototype.getDefaultFoundation=function(){var e=this,t={addClass:function(t){return e.root_.classList.add(t)},announce:function(){return e.announce_(e.labelEl_)},notifyClosed:function(t){return e.emit(b,t?{reason:t}:{})},notifyClosing:function(t){return e.emit(O,t?{reason:t}:{})},notifyOpened:function(){return e.emit(y,{})},notifyOpening:function(){return e.emit(h,{})},removeClass:function(t){return e.root_.classList.remove(t)}};return new l.MDCSnackbarFoundation(t)},Object.defineProperty(C.prototype,"timeoutMs",{get:function(){return this.foundation_.getTimeoutMs()},set:function(t){this.foundation_.setTimeoutMs(t)},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"closeOnEscape",{get:function(){return this.foundation_.getCloseOnEscape()},set:function(t){this.foundation_.setCloseOnEscape(t)},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"isOpen",{get:function(){return this.foundation_.isOpen()},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"labelText",{get:function(){return this.labelEl_.textContent},set:function(t){this.labelEl_.textContent=t},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"actionButtonText",{get:function(){return this.actionEl_.textContent},set:function(t){this.actionEl_.textContent=t},enumerable:!0,configurable:!0}),C.prototype.registerKeyDownHandler_=function(t){this.listen("keydown",t)},C.prototype.deregisterKeyDownHandler_=function(t){this.unlisten("keydown",t)},C.prototype.registerSurfaceClickHandler_=function(t){this.surfaceEl_.addEventListener("click",t)},C.prototype.deregisterSurfaceClickHandler_=function(t){this.surfaceEl_.removeEventListener("click",t)},C.prototype.isActionButton_=function(t){return Boolean(u.closest(t,d))},C.prototype.isActionIcon_=function(t){return Boolean(u.closest(t,m))},C);function C(){return null!==s&&s.apply(this,arguments)||this}e.MDCSnackbar=E},2:function(t,e,n){"use strict";function o(t,e){return(t.matches||t.webkitMatchesSelector||t.msMatchesSelector).call(t,e)}Object.defineProperty(e,"__esModule",{value:!0}),e.closest=function(t,e){if(t.closest)return t.closest(e);for(var n=t;n;){if(o(n,e))return n;n=n.parentElement}return null},e.matches=o},39:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.cssClasses={CLOSING:"mdc-snackbar--closing",OPEN:"mdc-snackbar--open",OPENING:"mdc-snackbar--opening"};e.strings={ACTION_SELECTOR:".mdc-snackbar__action",ARIA_LIVE_LABEL_TEXT_ATTR:"data-mdc-snackbar-label-text",CLOSED_EVENT:"MDCSnackbar:closed",CLOSING_EVENT:"MDCSnackbar:closing",DISMISS_SELECTOR:".mdc-snackbar__dismiss",LABEL_SELECTOR:".mdc-snackbar__label",OPENED_EVENT:"MDCSnackbar:opened",OPENING_EVENT:"MDCSnackbar:opening",REASON_ACTION:"action",REASON_DISMISS:"dismiss",SURFACE_SELECTOR:".mdc-snackbar__surface"};e.numbers={DEFAULT_AUTO_DISMISS_TIMEOUT_MS:5e3,MAX_AUTO_DISMISS_TIMEOUT_MS:1e4,MIN_AUTO_DISMISS_TIMEOUT_MS:4e3,SNACKBAR_ANIMATION_CLOSE_TIME_MS:75,SNACKBAR_ANIMATION_OPEN_TIME_MS:150,ARIA_LIVE_DELAY_MS:1e3}},89:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(39),i=o.numbers.ARIA_LIVE_DELAY_MS,r=o.strings.ARIA_LIVE_LABEL_TEXT_ATTR;e.announce=function(t,e){void 0===e&&(e=t);var n=t.getAttribute("aria-live"),o=e.textContent.trim();o&&n&&(t.setAttribute("aria-live","off"),e.textContent="",e.innerHTML='<span style="display: inline-block; width: 0; height: 1px;">&nbsp;</span>',e.setAttribute(r,o),setTimeout(function(){t.setAttribute("aria-live",n),e.removeAttribute(r),e.textContent=o},i))}},90:function(t,e,n){"use strict";var o,i=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var s,a=n(0),u=n(39),c=u.cssClasses.OPENING,l=u.cssClasses.OPEN,f=u.cssClasses.CLOSING,_=u.strings.REASON_ACTION,p=u.strings.REASON_DISMISS,d=(s=a.MDCFoundation,i(m,s),Object.defineProperty(m,"cssClasses",{get:function(){return u.cssClasses},enumerable:!0,configurable:!0}),Object.defineProperty(m,"strings",{get:function(){return u.strings},enumerable:!0,configurable:!0}),Object.defineProperty(m,"numbers",{get:function(){return u.numbers},enumerable:!0,configurable:!0}),Object.defineProperty(m,"defaultAdapter",{get:function(){return{addClass:function(){},announce:function(){},notifyClosed:function(){},notifyClosing:function(){},notifyOpened:function(){},notifyOpening:function(){},removeClass:function(){}}},enumerable:!0,configurable:!0}),m.prototype.destroy=function(){this.clearAutoDismissTimer_(),cancelAnimationFrame(this.animationFrame_),this.animationFrame_=0,clearTimeout(this.animationTimer_),this.animationTimer_=0,this.adapter_.removeClass(c),this.adapter_.removeClass(l),this.adapter_.removeClass(f)},m.prototype.open=function(){var t=this;this.clearAutoDismissTimer_(),this.isOpen_=!0,this.adapter_.notifyOpening(),this.adapter_.removeClass(f),this.adapter_.addClass(c),this.adapter_.announce(),this.runNextAnimationFrame_(function(){t.adapter_.addClass(l),t.animationTimer_=setTimeout(function(){t.handleAnimationTimerEnd_(),t.adapter_.notifyOpened(),t.autoDismissTimer_=setTimeout(function(){t.close(p)},t.getTimeoutMs())},u.numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS)})},m.prototype.close=function(t){var e=this;void 0===t&&(t=""),this.isOpen_&&(cancelAnimationFrame(this.animationFrame_),this.animationFrame_=0,this.clearAutoDismissTimer_(),this.isOpen_=!1,this.adapter_.notifyClosing(t),this.adapter_.addClass(u.cssClasses.CLOSING),this.adapter_.removeClass(u.cssClasses.OPEN),this.adapter_.removeClass(u.cssClasses.OPENING),clearTimeout(this.animationTimer_),this.animationTimer_=setTimeout(function(){e.handleAnimationTimerEnd_(),e.adapter_.notifyClosed(t)},u.numbers.SNACKBAR_ANIMATION_CLOSE_TIME_MS))},m.prototype.isOpen=function(){return this.isOpen_},m.prototype.getTimeoutMs=function(){return this.autoDismissTimeoutMs_},m.prototype.setTimeoutMs=function(t){var e=u.numbers.MIN_AUTO_DISMISS_TIMEOUT_MS,n=u.numbers.MAX_AUTO_DISMISS_TIMEOUT_MS;if(!(t<=n&&e<=t))throw new Error("timeoutMs must be an integer in the range "+e+"–"+n+", but got '"+t+"'");this.autoDismissTimeoutMs_=t},m.prototype.getCloseOnEscape=function(){return this.closeOnEscape_},m.prototype.setCloseOnEscape=function(t){this.closeOnEscape_=t},m.prototype.handleKeyDown=function(t){"Escape"!==t.key&&27!==t.keyCode||!this.getCloseOnEscape()||this.close(p)},m.prototype.handleActionButtonClick=function(t){this.close(_)},m.prototype.handleActionIconClick=function(t){this.close(p)},m.prototype.clearAutoDismissTimer_=function(){clearTimeout(this.autoDismissTimer_),this.autoDismissTimer_=0},m.prototype.handleAnimationTimerEnd_=function(){this.animationTimer_=0,this.adapter_.removeClass(u.cssClasses.OPENING),this.adapter_.removeClass(u.cssClasses.CLOSING)},m.prototype.runNextAnimationFrame_=function(t){var e=this;cancelAnimationFrame(this.animationFrame_),this.animationFrame_=requestAnimationFrame(function(){e.animationFrame_=0,clearTimeout(e.animationTimer_),e.animationTimer_=setTimeout(t,0)})},m);function m(t){var e=s.call(this,r({},m.defaultAdapter,t))||this;return e.isOpen_=!1,e.animationFrame_=0,e.animationTimer_=0,e.autoDismissTimer_=0,e.autoDismissTimeoutMs_=u.numbers.DEFAULT_AUTO_DISMISS_TIMEOUT_MS,e.closeOnEscape_=!0,e}e.MDCSnackbarFoundation=d,e.default=d}},i.c=o,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=149);function i(t){if(o[t])return o[t].exports;var e=o[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,i),e.l=!0,e.exports}var n,o});
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.snackbar=e():(t.mdc=t.mdc||{},t.mdc.snackbar=e())}(this,function(){return o={},i.m=n={0:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=(Object.defineProperty(i,"cssClasses",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(i,"strings",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(i,"numbers",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(i,"defaultAdapter",{get:function(){return{}},enumerable:!0,configurable:!0}),i.prototype.init=function(){},i.prototype.destroy=function(){},i);function i(t){void 0===t&&(t={}),this.adapter_=t}e.MDCFoundation=o,e.default=o},1:function(t,e,n){"use strict";var o=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,i,r=n.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(o=r.next()).done;)s.push(o.value)}catch(t){i={error:t}}finally{try{o&&!o.done&&(n=r.return)&&n.call(r)}finally{if(i)throw i.error}}return s},i=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(o(arguments[e]));return t};Object.defineProperty(e,"__esModule",{value:!0});var r=n(0),s=(a.attachTo=function(t){return new a(t,new r.MDCFoundation({}))},a.prototype.initialize=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e]},a.prototype.getDefaultFoundation=function(){throw new Error("Subclasses must override getDefaultFoundation to return a properly configured foundation class")},a.prototype.initialSyncWithDOM=function(){},a.prototype.destroy=function(){this.foundation_.destroy()},a.prototype.listen=function(t,e,n){this.root_.addEventListener(t,e,n)},a.prototype.unlisten=function(t,e,n){this.root_.removeEventListener(t,e,n)},a.prototype.emit=function(t,e,n){var o;void 0===n&&(n=!1),"function"==typeof CustomEvent?o=new CustomEvent(t,{bubbles:n,detail:e}):(o=document.createEvent("CustomEvent")).initCustomEvent(t,n,!1,e),this.root_.dispatchEvent(o)},a);function a(t,e){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];this.root_=t,this.initialize.apply(this,i(n)),this.foundation_=void 0===e?this.getDefaultFoundation():e,this.foundation_.init(),this.initialSyncWithDOM()}e.MDCComponent=s,e.default=s},149:function(t,n,e){"use strict";function o(t){for(var e in t)n.hasOwnProperty(e)||(n[e]=t[e])}var i=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(n,"__esModule",{value:!0});var r=i(e(89));n.util=r,o(e(150)),o(e(39)),o(e(90))},150:function(t,e,n){"use strict";var o,i=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),r=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e};Object.defineProperty(e,"__esModule",{value:!0});var s,a=n(1),u=n(2),c=n(39),l=n(90),f=r(n(89)),_=c.strings.SURFACE_SELECTOR,p=c.strings.LABEL_SELECTOR,d=c.strings.ACTION_SELECTOR,m=c.strings.DISMISS_SELECTOR,h=c.strings.OPENING_EVENT,y=c.strings.OPENED_EVENT,E=c.strings.CLOSING_EVENT,b=c.strings.CLOSED_EVENT,O=(s=a.MDCComponent,i(T,s),T.attachTo=function(t){return new T(t)},T.prototype.initialize=function(t){void 0===t&&(t=function(){return f.announce}),this.announce_=t()},T.prototype.initialSyncWithDOM=function(){var n=this;this.surfaceEl_=this.root_.querySelector(_),this.labelEl_=this.root_.querySelector(p),this.actionEl_=this.root_.querySelector(d),this.handleKeyDown_=function(t){return n.foundation_.handleKeyDown(t)},this.handleSurfaceClick_=function(t){var e=t.target;n.isActionButton_(e)?n.foundation_.handleActionButtonClick(t):n.isActionIcon_(e)&&n.foundation_.handleActionIconClick(t)},this.registerKeyDownHandler_(this.handleKeyDown_),this.registerSurfaceClickHandler_(this.handleSurfaceClick_)},T.prototype.destroy=function(){s.prototype.destroy.call(this),this.deregisterKeyDownHandler_(this.handleKeyDown_),this.deregisterSurfaceClickHandler_(this.handleSurfaceClick_)},T.prototype.open=function(){this.foundation_.open()},T.prototype.close=function(t){void 0===t&&(t=""),this.foundation_.close(t)},T.prototype.getDefaultFoundation=function(){var e=this,t={addClass:function(t){return e.root_.classList.add(t)},announce:function(){return e.announce_(e.labelEl_)},notifyClosed:function(t){return e.emit(b,t?{reason:t}:{})},notifyClosing:function(t){return e.emit(E,t?{reason:t}:{})},notifyOpened:function(){return e.emit(y,{})},notifyOpening:function(){return e.emit(h,{})},removeClass:function(t){return e.root_.classList.remove(t)}};return new l.MDCSnackbarFoundation(t)},Object.defineProperty(T.prototype,"timeoutMs",{get:function(){return this.foundation_.getTimeoutMs()},set:function(t){this.foundation_.setTimeoutMs(t)},enumerable:!0,configurable:!0}),Object.defineProperty(T.prototype,"closeOnEscape",{get:function(){return this.foundation_.getCloseOnEscape()},set:function(t){this.foundation_.setCloseOnEscape(t)},enumerable:!0,configurable:!0}),Object.defineProperty(T.prototype,"isOpen",{get:function(){return this.foundation_.isOpen()},enumerable:!0,configurable:!0}),Object.defineProperty(T.prototype,"labelText",{get:function(){return this.labelEl_.textContent},set:function(t){this.labelEl_.textContent=t},enumerable:!0,configurable:!0}),Object.defineProperty(T.prototype,"actionButtonText",{get:function(){return this.actionEl_.textContent},set:function(t){this.actionEl_.textContent=t},enumerable:!0,configurable:!0}),T.prototype.registerKeyDownHandler_=function(t){this.listen("keydown",t)},T.prototype.deregisterKeyDownHandler_=function(t){this.unlisten("keydown",t)},T.prototype.registerSurfaceClickHandler_=function(t){this.surfaceEl_.addEventListener("click",t)},T.prototype.deregisterSurfaceClickHandler_=function(t){this.surfaceEl_.removeEventListener("click",t)},T.prototype.isActionButton_=function(t){return Boolean(u.closest(t,d))},T.prototype.isActionIcon_=function(t){return Boolean(u.closest(t,m))},T);function T(){return null!==s&&s.apply(this,arguments)||this}e.MDCSnackbar=O},2:function(t,e,n){"use strict";function o(t,e){return(t.matches||t.webkitMatchesSelector||t.msMatchesSelector).call(t,e)}Object.defineProperty(e,"__esModule",{value:!0}),e.closest=function(t,e){if(t.closest)return t.closest(e);for(var n=t;n;){if(o(n,e))return n;n=n.parentElement}return null},e.matches=o},39:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.cssClasses={CLOSING:"mdc-snackbar--closing",OPEN:"mdc-snackbar--open",OPENING:"mdc-snackbar--opening"};e.strings={ACTION_SELECTOR:".mdc-snackbar__action",ARIA_LIVE_LABEL_TEXT_ATTR:"data-mdc-snackbar-label-text",CLOSED_EVENT:"MDCSnackbar:closed",CLOSING_EVENT:"MDCSnackbar:closing",DISMISS_SELECTOR:".mdc-snackbar__dismiss",LABEL_SELECTOR:".mdc-snackbar__label",OPENED_EVENT:"MDCSnackbar:opened",OPENING_EVENT:"MDCSnackbar:opening",REASON_ACTION:"action",REASON_DISMISS:"dismiss",SURFACE_SELECTOR:".mdc-snackbar__surface"};e.numbers={DEFAULT_AUTO_DISMISS_TIMEOUT_MS:5e3,INDETERMINATE:-1,MAX_AUTO_DISMISS_TIMEOUT_MS:1e4,MIN_AUTO_DISMISS_TIMEOUT_MS:4e3,SNACKBAR_ANIMATION_CLOSE_TIME_MS:75,SNACKBAR_ANIMATION_OPEN_TIME_MS:150,ARIA_LIVE_DELAY_MS:1e3}},89:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=n(39),i=o.numbers.ARIA_LIVE_DELAY_MS,r=o.strings.ARIA_LIVE_LABEL_TEXT_ATTR;e.announce=function(t,e){void 0===e&&(e=t);var n=t.getAttribute("aria-live"),o=e.textContent.trim();o&&n&&(t.setAttribute("aria-live","off"),e.textContent="",e.innerHTML='<span style="display: inline-block; width: 0; height: 1px;">&nbsp;</span>',e.setAttribute(r,o),setTimeout(function(){t.setAttribute("aria-live",n),e.removeAttribute(r),e.textContent=o},i))}},90:function(t,e,n){"use strict";var o,i=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};Object.defineProperty(e,"__esModule",{value:!0});var s,a=n(0),u=n(39),c=u.cssClasses.OPENING,l=u.cssClasses.OPEN,f=u.cssClasses.CLOSING,_=u.strings.REASON_ACTION,p=u.strings.REASON_DISMISS,d=(s=a.MDCFoundation,i(m,s),Object.defineProperty(m,"cssClasses",{get:function(){return u.cssClasses},enumerable:!0,configurable:!0}),Object.defineProperty(m,"strings",{get:function(){return u.strings},enumerable:!0,configurable:!0}),Object.defineProperty(m,"numbers",{get:function(){return u.numbers},enumerable:!0,configurable:!0}),Object.defineProperty(m,"defaultAdapter",{get:function(){return{addClass:function(){},announce:function(){},notifyClosed:function(){},notifyClosing:function(){},notifyOpened:function(){},notifyOpening:function(){},removeClass:function(){}}},enumerable:!0,configurable:!0}),m.prototype.destroy=function(){this.clearAutoDismissTimer_(),cancelAnimationFrame(this.animationFrame_),this.animationFrame_=0,clearTimeout(this.animationTimer_),this.animationTimer_=0,this.adapter_.removeClass(c),this.adapter_.removeClass(l),this.adapter_.removeClass(f)},m.prototype.open=function(){var e=this;this.clearAutoDismissTimer_(),this.isOpen_=!0,this.adapter_.notifyOpening(),this.adapter_.removeClass(f),this.adapter_.addClass(c),this.adapter_.announce(),this.runNextAnimationFrame_(function(){e.adapter_.addClass(l),e.animationTimer_=setTimeout(function(){var t=e.getTimeoutMs();e.handleAnimationTimerEnd_(),e.adapter_.notifyOpened(),t!==u.numbers.INDETERMINATE&&(e.autoDismissTimer_=setTimeout(function(){e.close(p)},t))},u.numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS)})},m.prototype.close=function(t){var e=this;void 0===t&&(t=""),this.isOpen_&&(cancelAnimationFrame(this.animationFrame_),this.animationFrame_=0,this.clearAutoDismissTimer_(),this.isOpen_=!1,this.adapter_.notifyClosing(t),this.adapter_.addClass(u.cssClasses.CLOSING),this.adapter_.removeClass(u.cssClasses.OPEN),this.adapter_.removeClass(u.cssClasses.OPENING),clearTimeout(this.animationTimer_),this.animationTimer_=setTimeout(function(){e.handleAnimationTimerEnd_(),e.adapter_.notifyClosed(t)},u.numbers.SNACKBAR_ANIMATION_CLOSE_TIME_MS))},m.prototype.isOpen=function(){return this.isOpen_},m.prototype.getTimeoutMs=function(){return this.autoDismissTimeoutMs_},m.prototype.setTimeoutMs=function(t){var e=u.numbers.MIN_AUTO_DISMISS_TIMEOUT_MS,n=u.numbers.MAX_AUTO_DISMISS_TIMEOUT_MS,o=u.numbers.INDETERMINATE;if(!(t===u.numbers.INDETERMINATE||t<=n&&e<=t))throw new Error("\n timeoutMs must be an integer in the range "+e+"–"+n+"\n (or "+o+" to disable), but got '"+t+"'");this.autoDismissTimeoutMs_=t},m.prototype.getCloseOnEscape=function(){return this.closeOnEscape_},m.prototype.setCloseOnEscape=function(t){this.closeOnEscape_=t},m.prototype.handleKeyDown=function(t){"Escape"!==t.key&&27!==t.keyCode||!this.getCloseOnEscape()||this.close(p)},m.prototype.handleActionButtonClick=function(t){this.close(_)},m.prototype.handleActionIconClick=function(t){this.close(p)},m.prototype.clearAutoDismissTimer_=function(){clearTimeout(this.autoDismissTimer_),this.autoDismissTimer_=0},m.prototype.handleAnimationTimerEnd_=function(){this.animationTimer_=0,this.adapter_.removeClass(u.cssClasses.OPENING),this.adapter_.removeClass(u.cssClasses.CLOSING)},m.prototype.runNextAnimationFrame_=function(t){var e=this;cancelAnimationFrame(this.animationFrame_),this.animationFrame_=requestAnimationFrame(function(){e.animationFrame_=0,clearTimeout(e.animationTimer_),e.animationTimer_=setTimeout(t,0)})},m);function m(t){var e=s.call(this,r({},m.defaultAdapter,t))||this;return e.isOpen_=!1,e.animationFrame_=0,e.animationTimer_=0,e.autoDismissTimer_=0,e.autoDismissTimeoutMs_=u.numbers.DEFAULT_AUTO_DISMISS_TIMEOUT_MS,e.closeOnEscape_=!0,e}e.MDCSnackbarFoundation=d,e.default=d}},i.c=o,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)i.d(n,o,function(t){return e[t]}.bind(null,o));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=149);function i(t){if(o[t])return o[t].exports;var e=o[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,i),e.l=!0,e.exports}var n,o});

@@ -46,2 +46,3 @@ /**

DEFAULT_AUTO_DISMISS_TIMEOUT_MS: number;
INDETERMINATE: number;
MAX_AUTO_DISMISS_TIMEOUT_MS: number;

@@ -48,0 +49,0 @@ MIN_AUTO_DISMISS_TIMEOUT_MS: number;

@@ -98,7 +98,10 @@ /**

_this.animationTimer_ = setTimeout(function () {
var timeoutMs = _this.getTimeoutMs();
_this.handleAnimationTimerEnd_();
_this.adapter_.notifyOpened();
_this.autoDismissTimer_ = setTimeout(function () {
_this.close(REASON_DISMISS);
}, _this.getTimeoutMs());
if (timeoutMs !== numbers.INDETERMINATE) {
_this.autoDismissTimer_ = setTimeout(function () {
_this.close(REASON_DISMISS);
}, timeoutMs);
}
}, numbers.SNACKBAR_ANIMATION_OPEN_TIME_MS);

@@ -143,7 +146,8 @@ });

var maxValue = numbers.MAX_AUTO_DISMISS_TIMEOUT_MS;
if (timeoutMs <= maxValue && timeoutMs >= minValue) {
var indeterminateValue = numbers.INDETERMINATE;
if (timeoutMs === numbers.INDETERMINATE || (timeoutMs <= maxValue && timeoutMs >= minValue)) {
this.autoDismissTimeoutMs_ = timeoutMs;
}
else {
throw new Error("timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + ", but got '" + timeoutMs + "'");
throw new Error("\n timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + "\n (or " + indeterminateValue + " to disable), but got '" + timeoutMs + "'");
}

@@ -150,0 +154,0 @@ };

{
"name": "@material/snackbar",
"description": "The Material Components for the web snackbar component",
"version": "4.0.0-canary.1",
"version": "4.0.0-canary.735147131.0",
"license": "MIT",

@@ -21,16 +21,16 @@ "keywords": [

"dependencies": {
"@material/animation": "^4.0.0-canary.1",
"@material/base": "^4.0.0-canary.1",
"@material/button": "^4.0.0-canary.1",
"@material/dom": "^4.0.0-canary.1",
"@material/feature-targeting": "^4.0.0-canary.1",
"@material/icon-button": "^4.0.0-canary.1",
"@material/ripple": "^4.0.0-canary.1",
"@material/rtl": "^4.0.0-canary.1",
"@material/shape": "^4.0.0-canary.1",
"@material/theme": "^4.0.0-canary.1",
"@material/typography": "^4.0.0-canary.1",
"@material/animation": "4.0.0-canary.735147131.0",
"@material/base": "4.0.0-canary.735147131.0",
"@material/button": "4.0.0-canary.735147131.0",
"@material/dom": "4.0.0-canary.735147131.0",
"@material/feature-targeting": "4.0.0-canary.735147131.0",
"@material/icon-button": "4.0.0-canary.735147131.0",
"@material/ripple": "4.0.0-canary.735147131.0",
"@material/rtl": "4.0.0-canary.735147131.0",
"@material/shape": "4.0.0-canary.735147131.0",
"@material/theme": "4.0.0-canary.735147131.0",
"@material/typography": "4.0.0-canary.735147131.0",
"tslib": "^1.9.3"
},
"gitHead": "edc72a4d7d6a61d61620fd05a80e2491e518bccf"
"gitHead": "d7bebbe119e39bd973d398066f5601862aface5d"
}

@@ -169,3 +169,3 @@ <!--docs:

`isOpen` | `boolean` (read-only) | Gets whether the snackbar is currently open.
`timeoutMs` | `number` | Gets/sets the automatic dismiss timeout in milliseconds. Value must be between `4000` and `10000` or an error will be thrown. Defaults to `5000` (5 seconds).
`timeoutMs` | `number` | Gets/sets the automatic dismiss timeout in milliseconds. Value must be between `4000` and `10000` (or `-1` to disable the timeout completely) or an error will be thrown. Defaults to `5000` (5 seconds).
`closeOnEscape` | `boolean` | Gets/sets whether the snackbar closes when it is focused and the user presses the <kbd>ESC</kbd> key. Defaults to `true`.

@@ -172,0 +172,0 @@ `labelText` | `string` | Gets/sets the `textContent` of the label element.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc