material-components-vue
Version:
Material Design components for Vue.js
2 lines • 16.4 kB
JavaScript
/*! For license information please see snackbar.min.js.LICENSE */
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(window,(function(){return n={},t.m=e={0:function(t,e,n){"use strict";n.d(e,"b",(function(){return o})),n.d(e,"a",(function(){return r})),n.d(e,"e",(function(){return a})),n.d(e,"c",(function(){return s})),n.d(e,"d",(function(){return c}));var i=function(t,e){return(i=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 o(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function a(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function s(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,o,r=n.call(t),a=[];try{for(;(void 0===e||0<e--)&&!(i=r.next()).done;)a.push(i.value)}catch(t){o={error:t}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function c(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t}},2:function(t,e,n){"use strict";var i={inheritAttrs:!1},o=["primary","secondary","background","surface","on-primary","on-secondary","on-surface","primary-bg","secondary-bg","text-primary-on-light","text-secondary-on-light","text-hint-on-light","text-disabled-on-light","text-icon-on-light","text-primary-on-dark","text-secondary-on-dark","text-hint-on-dark","text-disabled-on-dark","text-icon-on-dark"],r={props:{theming:{type:String,default:""}},mounted:function(){-1<o.indexOf(this.theming)&&this.$el.classList.add("mdc-theme--"+this.theming)}};n.d(e,"a",(function(){return i})),n.d(e,"b",(function(){return r}))},3:function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var i=(Object.defineProperty(o,"cssClasses",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(o,"strings",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(o,"numbers",{get:function(){return{}},enumerable:!0,configurable:!0}),Object.defineProperty(o,"defaultAdapter",{get:function(){return{}},enumerable:!0,configurable:!0}),o.prototype.init=function(){},o.prototype.destroy=function(){},o);function o(t){void 0===t&&(t={}),this.adapter_=t}},4:function(t,e,n){"use strict";function i(t,e,n,i,o,r,a,s){var c,u="function"==typeof t?t.options:t;if(e&&(u.render=e,u.staticRenderFns=n,u._compiled=!0),i&&(u.functional=!0),r&&(u._scopeId="data-v-"+r),a?(c=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},u._ssrRegister=c):o&&(c=s?function(){o.call(this,this.$root.$options.shadowRoot)}:o),c)if(u.functional){u._injectStyles=c;var l=u.render;u.render=function(t,e){return c.call(e),l(t,e)}}else{var f=u.beforeCreate;u.beforeCreate=f?[].concat(f,c):[c]}return{exports:t,options:u}}n.d(e,"a",(function(){return i}))},5:function(t,e,n){"use strict";n.d(e,"a",(function(){return r}));var i=n(0),o=n(3),r=(a.attachTo=function(t){return new a(t,new o.a({}))},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 i;void 0===n&&(n=!1),"function"==typeof CustomEvent?i=new CustomEvent(t,{bubbles:n,detail:e}):(i=document.createEvent("CustomEvent")).initCustomEvent(t,n,!1,e),this.root_.dispatchEvent(i)},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.d(n)),this.foundation_=void 0===e?this.getDefaultFoundation():e,this.foundation_.init(),this.initialSyncWithDOM()}},51:function(t,e,n){},7:function(t,e,n){"use strict";function i(t){"undefined"!=typeof window&&window.Vue&&window.Vue.use(t)}n.d(e,"a",(function(){return i}))},71:function(t,e,n){"use strict";n.r(e);var i,o=n(0),r=n(5),a=n(8),s={CLOSING:"mdc-snackbar--closing",OPEN:"mdc-snackbar--open",OPENING:"mdc-snackbar--opening"},c={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"},u={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},l=n(3),f=s.OPENING,d=s.OPEN,p=s.CLOSING,_=c.REASON_ACTION,m=c.REASON_DISMISS,h=(i=l.a,o.b(b,i),Object.defineProperty(b,"cssClasses",{get:function(){return s},enumerable:!0,configurable:!0}),Object.defineProperty(b,"strings",{get:function(){return c},enumerable:!0,configurable:!0}),Object.defineProperty(b,"numbers",{get:function(){return u},enumerable:!0,configurable:!0}),Object.defineProperty(b,"defaultAdapter",{get:function(){return{addClass:function(){},announce:function(){},notifyClosed:function(){},notifyClosing:function(){},notifyOpened:function(){},notifyOpening:function(){},removeClass:function(){}}},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this.clearAutoDismissTimer_(),cancelAnimationFrame(this.animationFrame_),this.animationFrame_=0,clearTimeout(this.animationTimer_),this.animationTimer_=0,this.adapter_.removeClass(f),this.adapter_.removeClass(d),this.adapter_.removeClass(p)},b.prototype.open=function(){var t=this;this.clearAutoDismissTimer_(),this.isOpen_=!0,this.adapter_.notifyOpening(),this.adapter_.removeClass(p),this.adapter_.addClass(f),this.adapter_.announce(),this.runNextAnimationFrame_((function(){t.adapter_.addClass(d),t.animationTimer_=setTimeout((function(){t.handleAnimationTimerEnd_(),t.adapter_.notifyOpened(),t.autoDismissTimer_=setTimeout((function(){t.close(m)}),t.getTimeoutMs())}),u.SNACKBAR_ANIMATION_OPEN_TIME_MS)}))},b.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(s.CLOSING),this.adapter_.removeClass(s.OPEN),this.adapter_.removeClass(s.OPENING),clearTimeout(this.animationTimer_),this.animationTimer_=setTimeout((function(){e.handleAnimationTimerEnd_(),e.adapter_.notifyClosed(t)}),u.SNACKBAR_ANIMATION_CLOSE_TIME_MS))},b.prototype.isOpen=function(){return this.isOpen_},b.prototype.getTimeoutMs=function(){return this.autoDismissTimeoutMs_},b.prototype.setTimeoutMs=function(t){var e=u.MIN_AUTO_DISMISS_TIMEOUT_MS,n=u.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},b.prototype.getCloseOnEscape=function(){return this.closeOnEscape_},b.prototype.setCloseOnEscape=function(t){this.closeOnEscape_=t},b.prototype.handleKeyDown=function(t){"Escape"!==t.key&&27!==t.keyCode||!this.getCloseOnEscape()||this.close(m)},b.prototype.handleActionButtonClick=function(t){this.close(_)},b.prototype.handleActionIconClick=function(t){this.close(m)},b.prototype.clearAutoDismissTimer_=function(){clearTimeout(this.autoDismissTimer_),this.autoDismissTimer_=0},b.prototype.handleAnimationTimerEnd_=function(){this.animationTimer_=0,this.adapter_.removeClass(s.OPENING),this.adapter_.removeClass(s.CLOSING)},b.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)}))},b);function b(t){var e=i.call(this,o.a({},b.defaultAdapter,t))||this;return e.isOpen_=!1,e.animationFrame_=0,e.animationTimer_=0,e.autoDismissTimer_=0,e.autoDismissTimeoutMs_=u.DEFAULT_AUTO_DISMISS_TIMEOUT_MS,e.closeOnEscape_=!0,e}var y=u.ARIA_LIVE_DELAY_MS,E=c.ARIA_LIVE_LABEL_TEXT_ATTR;function O(t,e){void 0===e&&(e=t);var n=t.getAttribute("aria-live"),i=e.textContent.trim();i&&n&&(t.setAttribute("aria-live","off"),e.textContent="",e.innerHTML='<span style="display: inline-block; width: 0; height: 1px;"> </span>',e.setAttribute(E,i),setTimeout((function(){t.setAttribute("aria-live",n),e.removeAttribute(E),e.textContent=i}),y))}var T,S=c.SURFACE_SELECTOR,C=c.LABEL_SELECTOR,g=c.ACTION_SELECTOR,v=c.DISMISS_SELECTOR,A=c.OPENING_EVENT,M=c.OPENED_EVENT,I=c.CLOSING_EVENT,k=c.CLOSED_EVENT,x=(T=r.a,o.b(N,T),N.attachTo=function(t){return new N(t)},N.prototype.initialize=function(t){void 0===t&&(t=function(){return O}),this.announce_=t()},N.prototype.initialSyncWithDOM=function(){var t=this;this.surfaceEl_=this.root_.querySelector(S),this.labelEl_=this.root_.querySelector(C),this.actionEl_=this.root_.querySelector(g),this.handleKeyDown_=function(e){return t.foundation_.handleKeyDown(e)},this.handleSurfaceClick_=function(e){var n=e.target;t.isActionButton_(n)?t.foundation_.handleActionButtonClick(e):t.isActionIcon_(n)&&t.foundation_.handleActionIconClick(e)},this.registerKeyDownHandler_(this.handleKeyDown_),this.registerSurfaceClickHandler_(this.handleSurfaceClick_)},N.prototype.destroy=function(){T.prototype.destroy.call(this),this.deregisterKeyDownHandler_(this.handleKeyDown_),this.deregisterSurfaceClickHandler_(this.handleSurfaceClick_)},N.prototype.open=function(){this.foundation_.open()},N.prototype.close=function(t){void 0===t&&(t=""),this.foundation_.close(t)},N.prototype.getDefaultFoundation=function(){var t=this;return new h({addClass:function(e){return t.root_.classList.add(e)},announce:function(){return t.announce_(t.labelEl_)},notifyClosed:function(e){return t.emit(k,e?{reason:e}:{})},notifyClosing:function(e){return t.emit(I,e?{reason:e}:{})},notifyOpened:function(){return t.emit(M,{})},notifyOpening:function(){return t.emit(A,{})},removeClass:function(e){return t.root_.classList.remove(e)}})},Object.defineProperty(N.prototype,"timeoutMs",{get:function(){return this.foundation_.getTimeoutMs()},set:function(t){this.foundation_.setTimeoutMs(t)},enumerable:!0,configurable:!0}),Object.defineProperty(N.prototype,"closeOnEscape",{get:function(){return this.foundation_.getCloseOnEscape()},set:function(t){this.foundation_.setCloseOnEscape(t)},enumerable:!0,configurable:!0}),Object.defineProperty(N.prototype,"isOpen",{get:function(){return this.foundation_.isOpen()},enumerable:!0,configurable:!0}),Object.defineProperty(N.prototype,"labelText",{get:function(){return this.labelEl_.textContent},set:function(t){this.labelEl_.textContent=t},enumerable:!0,configurable:!0}),Object.defineProperty(N.prototype,"actionButtonText",{get:function(){return this.actionEl_.textContent},set:function(t){this.actionEl_.textContent=t},enumerable:!0,configurable:!0}),N.prototype.registerKeyDownHandler_=function(t){this.listen("keydown",t)},N.prototype.deregisterKeyDownHandler_=function(t){this.unlisten("keydown",t)},N.prototype.registerSurfaceClickHandler_=function(t){this.surfaceEl_.addEventListener("click",t)},N.prototype.deregisterSurfaceClickHandler_=function(t){this.surfaceEl_.removeEventListener("click",t)},N.prototype.isActionButton_=function(t){return Boolean(Object(a.a)(t,g))},N.prototype.isActionIcon_=function(t){return Boolean(Object(a.a)(t,v))},N);function N(){return null!==T&&T.apply(this,arguments)||this}var D=n(2),L={mixins:[D.a,D.b],model:{prop:"open",event:"change"},props:{timeoutMs:{type:Number,default:5e3},closeOnEscape:{type:Boolean,default:!0},open:{type:Boolean,default:!1},labelText:{type:String,default:""},actionButtonText:{type:String,default:""},leading:{type:Boolean,default:!1},stacked:{type:Boolean,default:!1},hasDismiss:{type:Boolean,default:!1},dismissClass:{type:String,default:"material-icons"}},data:function(){return{mdcSnackbar:void 0}},computed:{classes:function(){return{"mdc-snackbar--leading":this.leading,"mdc-snackbar--stacked":this.stacked}},model:{get:function(){return this.open},set:function(t){this.$emit("change",t)}}},watch:{open:function(){this.open&&this.mdcSnackbar.open()},"mdcSnackbar.isOpen":function(){this.model=this.mdcSnackbar.isOpen},actionButtonText:function(){this.actionButtonText&&""!==this.actionButtonText&&(this.mdcSnackbar.actionButtonText=this.actionButtonText)},labelText:function(){this.labelText&&""!==this.labelText&&(this.mdcSnackbar.labelText=this.labelText)},closeOnEscape:function(){this.mdcSnackbar.closeOnEscape=this.closeOnEscape},timeoutMs:function(){this.mdcSnackbar.timeoutMs=this.timeoutMs}},mounted:function(){this.mdcSnackbar=x.attachTo(this.$el),this.mdcSnackbar.timeoutMs=this.timeoutMs,this.mdcSnackbar.closeOnEscape=this.closeOnEscape,this.labelText&&""!==this.labelText&&(this.mdcSnackbar.labelText=this.labelText),this.actionButtonText&&""!==this.actionButtonText&&(this.mdcSnackbar.actionButtonText=this.actionButtonText)},beforeDestroy:function(){this.mdcSnackbar.destroy()},methods:{onClosing:function(t){this.$emit("closing",t.detail)},onClosed:function(t){this.$emit("closed",t.detail)},onOpening:function(){this.$emit("opening")},onOpened:function(){this.$emit("opened")}}},w=n(4),P=Object(w.a)(L,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"mdc-snackbar",class:t.classes,on:{"MDCSnackbar:closed":t.onClosed,"MDCSnackbar:closing":t.onClosing,"MDCSnackbar:opened":t.onOpened,"MDCSnackbar:opening":t.onOpening}},[n("div",{staticClass:"mdc-snackbar__surface"},[n("div",{staticClass:"mdc-snackbar__label",attrs:{"aria-live":"polite",role:"status"}},[t._t("default")],2),t._v(" "),t.hasDismiss||""!==t.actionButtonText?n("div",{staticClass:"mdc-snackbar__actions"},[""!==t.actionButtonText?n("button",{staticClass:"mdc-button mdc-snackbar__action",attrs:{type:"button"}}):t._e(),t._v(" "),t.hasDismiss?n("button",{staticClass:"mdc-icon-button mdc-snackbar__dismiss",class:t.dismissClass,attrs:{title:"Dismiss"}},["material-icons"===t.dismissClass?t._t("dismiss",[t._v("\n close\n ")]):t._t("dismiss")],2):t._e()]):t._e()])])}),[],!1,null,null,null).exports,j=(n(51),n(7)),B={install:function(t){t.component("m-snackbar",P)}};e.default=B,Object(j.a)(B)},8:function(t,e,n){"use strict";function i(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}function o(t,e){return(t.matches||t.webkitMatchesSelector||t.msMatchesSelector).call(t,e)}n.d(e,"a",(function(){return i})),n.d(e,"b",(function(){return o}))}},t.c=n,t.d=function(e,n,i){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:i})},t.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(i,o,function(t){return e[t]}.bind(null,o));return i},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},t.p="",t(t.s=71);function t(i){if(n[i])return n[i].exports;var o=n[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var e,n}));