diff --git a/dist/vue-a11y-dialog.js b/dist/vue-a11y-dialog.js index d890263..58c3457 100644 --- a/dist/vue-a11y-dialog.js +++ b/dist/vue-a11y-dialog.js @@ -1 +1 @@ -(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],b):(a=a||self,b(a.VueA11yDialog={},a.vue))})(this,function(a,b){"use strict";function c(a,b){return b={exports:{}},a(b,b.exports),b.exports}b=b&&b.hasOwnProperty("default")?b["default"]:b;var d="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?{}:self:global:window,e=c(function(a){(function(){function b(a,b){this._show=this.show.bind(this),this._hide=this.hide.bind(this),this._maintainFocus=this._maintainFocus.bind(this),this._bindKeypress=this._bindKeypress.bind(this),this.container=a,this.dialog=a.querySelector("dialog, [role=\"dialog\"], [role=\"alertdialog\"]"),this.role=this.dialog.getAttribute("role")||"dialog",this.useDialog="show"in document.createElement("dialog")&&"DIALOG"===this.dialog.nodeName,this._listeners={},this.create(b)}function c(a){return Array.prototype.slice.call(a)}function d(a,b){return c((b||document).querySelectorAll(a))}function e(a){return NodeList.prototype.isPrototypeOf(a)?c(a):Element.prototype.isPrototypeOf(a)?[a]:"string"==typeof a?d(a):void 0}function f(a){var b=g(a),c=a.querySelector("[autofocus]")||b[0];c&&c.focus()}function g(a){return d(k.join(","),a).filter(function(a){return!!(a.offsetWidth||a.offsetHeight||a.getClientRects().length)})}function h(a,b){var c=g(a),d=c.indexOf(document.activeElement);b.shiftKey&&0===d?(c[c.length-1].focus(),b.preventDefault()):!b.shiftKey&&d===c.length-1&&(c[0].focus(),b.preventDefault())}function i(a){var b=c(a.parentNode.childNodes),d=b.filter(function(a){return 1===a.nodeType});return d.splice(d.indexOf(a),1),d}var j,k=["a[href]:not([tabindex^=\"-\"]):not([inert])","area[href]:not([tabindex^=\"-\"]):not([inert])","input:not([disabled]):not([inert])","select:not([disabled]):not([inert])","textarea:not([disabled]):not([inert])","button:not([disabled]):not([inert])","iframe:not([tabindex^=\"-\"]):not([inert])","audio:not([tabindex^=\"-\"]):not([inert])","video:not([tabindex^=\"-\"]):not([inert])","[contenteditable]:not([tabindex^=\"-\"]):not([inert])","[tabindex]:not([tabindex^=\"-\"]):not([inert])"];b.prototype.create=function(a){return this._targets=this._targets||e(a)||i(this.container),this.shown=this.dialog.hasAttribute("open"),this.dialog.setAttribute("role",this.role),this.useDialog?this.container.setAttribute("data-a11y-dialog-native",""):this.shown?this.container.removeAttribute("aria-hidden"):this.container.setAttribute("aria-hidden",!0),this._openers=d("[data-a11y-dialog-show=\""+this.container.id+"\"]"),this._openers.forEach(function(a){a.addEventListener("click",this._show)}.bind(this)),this._closers=d("[data-a11y-dialog-hide]",this.container).concat(d("[data-a11y-dialog-hide=\""+this.container.id+"\"]")),this._closers.forEach(function(a){a.addEventListener("click",this._hide)}.bind(this)),this._fire("create"),this},b.prototype.show=function(a){return this.shown?this:(this.shown=!0,j=document.activeElement,this.useDialog?this.dialog.showModal(a instanceof Event?void 0:a):(this.dialog.setAttribute("open",""),this.container.removeAttribute("aria-hidden"),this._targets.forEach(function(a){a.setAttribute("aria-hidden","true")})),f(this.dialog),document.body.addEventListener("focus",this._maintainFocus,!0),document.addEventListener("keydown",this._bindKeypress),this._fire("show",a),this)},b.prototype.hide=function(a){return this.shown?(this.shown=!1,this.useDialog?this.dialog.close(a instanceof Event?void 0:a):(this.dialog.removeAttribute("open"),this.container.setAttribute("aria-hidden","true"),this._targets.forEach(function(a){a.removeAttribute("aria-hidden")})),j&&j.focus(),document.body.removeEventListener("focus",this._maintainFocus,!0),document.removeEventListener("keydown",this._bindKeypress),this._fire("hide",a),this):this},b.prototype.destroy=function(){return this.hide(),this._openers.forEach(function(a){a.removeEventListener("click",this._show)}.bind(this)),this._closers.forEach(function(a){a.removeEventListener("click",this._hide)}.bind(this)),this._fire("destroy"),this._listeners={},this},b.prototype.on=function(a,b){return"undefined"==typeof this._listeners[a]&&(this._listeners[a]=[]),this._listeners[a].push(b),this},b.prototype.off=function(a,b){var c=this._listeners[a].indexOf(b);return-1=b.length&&this.slim?b[0]:a(c,[this.normalizeChildren(b)])):a(c,{class:"v-portal",style:"display: none",key:"v-portal-placeholder"})}};"undefined"!=typeof window&&window.Vue&&window.Vue.use({install:g});return{install:g,Portal:s,PortalTarget:p,Wormhole:m}})}),g=f.Portal,h={name:"VueA11yDialog",props:{id:{type:String,required:!0},appRoot:{type:[String,Array],required:!0},dialogRoot:{type:String,required:!0},classNames:{type:Object,default:()=>({})},titleId:{type:String},closeButtonLabel:{type:String,default:"Close this dialog window"},disableNative:{type:Boolean,default:!1},role:{type:String,default:"dialog"}},components:{Portal:g},computed:{fullTitleId(){return this.titleId||this.id+"-title"},dialogElement(){return this.disableNative?"div":"dialog"},roleAttribute(){return["dialog","alertdialog"].includes(this.role)?this.role:"dialog"},portalTarget(){return this.dialogRoot||this.appRoot}},data:()=>({dialog:null}),methods:{close(){this.dialog.hide()}},mounted(){this.$nextTick(()=>{this.dialog=new e(this.$refs.rootElement,this.appRoot),this.$emit("dialog-ref",this.dialog)})},destroyed(){this.dialog&&this.dialog.destroy(),this.$emit("dialog-ref")}};var i=function(a,b,c,d,e,f,g,h,i,j){"boolean"!=typeof g&&(i=h,h=g,g=!1);var k="function"==typeof c?c.options:c;a&&a.render&&(k.render=a.render,k.staticRenderFns=a.staticRenderFns,k._compiled=!0,e&&(k.functional=!0)),d&&(k._scopeId=d);var l;if(f?(l=function(a){a=a||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,a||"undefined"==typeof __VUE_SSR_CONTEXT__||(a=__VUE_SSR_CONTEXT__),b&&b.call(this,i(a)),a&&a._registeredComponents&&a._registeredComponents.add(f)},k._ssrRegister=l):b&&(l=g?function(){b.call(this,j(this.$root.$options.shadowRoot))}:function(a){b.call(this,h(a))}),l)if(k.functional){var m=k.render;k.render=function(a,b){return l.call(b),m(a,b)}}else{var n=k.beforeCreate;k.beforeCreate=n?[].concat(n,l):[l]}return c}({render:function(){var a=this,b=a.$createElement,c=a._self._c||b;return c("portal",{attrs:{"target-el":a.portalTarget}},[c("div",{ref:"rootElement",class:a.classNames.base,attrs:{id:a.id}},[c("div",{class:a.classNames.overlay,attrs:{"data-a11y-dialog-hide":"",tabIndex:"-1"},on:{click:function(){"alertdialog"===a.role?void 0:a.close}}}),a._v(" "),c(a.dialogElement,{tag:"component",class:a.classNames.element,attrs:{role:a.roleAttribute,"aria-labelledby":a.titleId}},[c("div",{class:a.classNames.document,attrs:{role:"document"}},[c("button",{class:a.classNames.closeButton,attrs:{"data-a11y-dialog-hide":"",type:"button","aria-label":a.closeButtonLabel},on:{click:a.close}},[a._t("closeButtonContent",[a._v("\n "+a._s("\xD7")+"\n ")])],2),a._v(" "),c("h1",{class:a.classNames.title,attrs:{id:a.fullTitleId}},[a._t("title")],2),a._v(" "),a._t("default")],2)])],1)])},staticRenderFns:[]},void 0,h,void 0,!1,void 0,void 0,void 0),j={install(a){a.component("a11y-dialog",i)}};a.A11yDialog=i,a.default=j,Object.defineProperty(a,"__esModule",{value:!0})}); +(function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):(e=e||self,t(e.VueA11yDialog={}))})(this,function(e){"use strict";var xo=Math.max;function t(e,t){return t={exports:{}},e(t,t.exports),t.exports}function n(e){return e===void 0||null===e}function o(e){return e!==void 0&&null!==e}function r(e){return!0===e}function i(e){return!1===e}function s(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}function d(e){return null!==e&&"object"==typeof e}function l(e){return Ao.call(e).slice(8,-1)}function c(e){return"[object Object]"===Ao.call(e)}function u(e){return"[object RegExp]"===Ao.call(e)}function m(e){var t=parseFloat(e+"");return 0<=t&&Math.floor(t)===t&&isFinite(e)}function y(e){return o(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function h(e){return null==e?"":Array.isArray(e)||c(e)&&e.toString===Ao?JSON.stringify(e,null,2):e+""}function g(e){var t=parseFloat(e);return isNaN(t)?e:t}function v(e,t){for(var n=Object.create(null),o=e.split(","),a=0;ad||scr&&rr[n].id>e.id;)n--;rr.splice(n+1,0,e)}if(!lr){if(lr=!0,"production"!==process.env.NODE_ENV&&!Ho.async)return void Tt();_e(Tt)}}}function jt(e,t,n){gr.get=function(){return this[t][n]},gr.set=function(e){this[t][n]=e},Object.defineProperty(e,n,gr)}function Rt(e){e._watchers=[];var t=e.$options;t.props&&Ft(e,t.props),t.methods&&Wt(e,t.methods),t.data?Ut(e):R(e._data={},!0),t.computed&&zt(e,t.computed),t.watch&&t.watch!==oa&&Yt(e,t.watch)}function Ft(e,t){var n=e.$options.propsData||{},o=e._props={},a=e.$options._propKeys=[],r=!e.$parent;r||P(!1);var i=function(i){a.push(i);var s=oe(i,t,n,e);if("production"!==process.env.NODE_ENV){var d=jo(i);(Io(d)||Ho.isReservedAttr(d))&&ca("\""+d+"\" is a reserved attribute and cannot be used as component prop.",e),F(o,i,s,function(){r||ar||ca("Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: \""+i+"\"",e)})}else F(o,i,s);i in e||jt(e,"_props",i)};for(var s in t)i(s);P(!0)}function Ut(e){var t=e.$options.data;t=e._data="function"==typeof t?Ht(t,e):t||{},c(t)||(t={},"production"!==process.env.NODE_ENV&&ca("data functions should return an object:\nhttps://vuejs.org/v2/guide/components.html#data-Must-Be-a-Function",e));for(var n=Object.keys(t),o=e.$options.props,a=e.$options.methods,r=n.length;r--;){var s=n[r];"production"!==process.env.NODE_ENV&&a&&_(a,s)&&ca("Method \""+s+"\" has already been defined as a data property.",e),o&&_(o,s)?"production"!==process.env.NODE_ENV&&ca("The data property \""+s+"\" is already declared as a prop. Use prop default value instead.",e):!O(s)&&jt(e,"_data",s)}R(t,!0)}function Ht(e,t){I();try{return e.call(t,t)}catch(n){return ye(n,t,"data()"),{}}finally{T()}}function zt(e,t){var n=e._computedWatchers=Object.create(null),o=da();for(var a in t){var r=t[a],i="function"==typeof r?r:r.get;"production"!==process.env.NODE_ENV&&null==i&&ca("Getter is missing for computed property \""+a+"\".",e),o||(n[a]=new hr(e,i||$,$,vr)),a in e?"production"!==process.env.NODE_ENV&&(a in e.$data?ca("The computed property \""+a+"\" is already defined in data.",e):e.$options.props&&a in e.$options.props&&ca("The computed property \""+a+"\" is already defined as a prop.",e)):Kt(e,a,r)}}function Kt(e,t,n){var o=!da();"function"==typeof n?(gr.get=o?Bt(t):qt(n),gr.set=$):(gr.get=n.get?o&&!1!==n.cache?Bt(t):qt(n.get):$,gr.set=n.set||$),"production"!==process.env.NODE_ENV&&gr.set===$&&(gr.set=function(){ca("Computed property \""+t+"\" was assigned to but it has no setter.",this)}),Object.defineProperty(e,t,gr)}function Bt(e){return function(){var t=this._computedWatchers&&this._computedWatchers[e];if(t)return t.dirty&&t.evaluate(),ba.target&&t.depend(),t.value}}function qt(e){return function(){return e.call(this,this)}}function Wt(e,t){var n=e.$options.props;for(var o in t)"production"!==process.env.NODE_ENV&&("function"!=typeof t[o]&&ca("Method \""+o+"\" has type \""+typeof t[o]+"\" in the component definition. Did you reference the function correctly?",e),n&&_(n,o)&&ca("Method \""+o+"\" has already been defined as a prop.",e),o in e&&O(o)&&ca("Method \""+o+"\" conflicts with an existing Vue instance method. Avoid defining component methods that start with _ or $.")),e[o]="function"==typeof t[o]?Ro(t[o],e):$}function Yt(e,t){for(var n in t){var o=t[n];if(Array.isArray(o))for(var a=0;ai[n].indexOf(r)&&i[n].push(r):i[n]=[r]:i[n]=r}}function En(e,t){return e.key===t.key&&(e.tag===t.tag&&e.isComment===t.isComment&&o(e.data)===o(t.data)&&kn(e,t)||r(e.isAsyncPlaceholder)&&e.asyncFactory===t.asyncFactory&&n(t.asyncFactory.error))}function kn(e,t){if("input"!==e.tag)return!0;var n,a=o(n=e.data)&&o(n=n.attrs)&&n.type,r=o(n=t.data)&&o(n=n.attrs)&&n.type;return a===r||Rr(a)&&Rr(r)}function Nn(e,t,n){var a,r,s={};for(a=t;a<=n;++a)r=e[a].key,o(r)&&(s[r]=a);return s}function $n(e,t){(e.data.directives||t.data.directives)&&Cn(e,t)}function Cn(e,t){var n,o,a,r=e===Ur,i=xn(e.data.directives,e.context),s=xn(t.data.directives,t.context),d=[],l=[];for(n in s)o=i[n],a=s[n],o?(a.oldValue=o.value,a.oldArg=o.arg,On(a,"update",t,e),a.def&&a.def.componentUpdated&&l.push(a)):(On(a,"bind",t,e),a.def&&a.def.inserted&&d.push(a));if(d.length){var p=function(){for(var n=0;n=a||0===t.timeStamp||t.target.ownerDocument!==document)return r.apply(this,arguments)}}kr.addEventListener(e,t,aa?{capture:n,passive:o}:n)}function Pn(e,t,n,o){(o||kr).removeEventListener(e,t._wrapper||t,n)}function Mn(e,t){if(!(n(e.data.on)&&n(t.data.on))){var o=t.data.on||{},a=e.data.on||{};kr=t.elm,Tn(o),Ne(o,a,Ln,Pn,Sn,t.context),kr=void 0}}function jn(e,t){if(!(n(e.data.domProps)&&n(t.data.domProps))){var a,r,i=t.elm,s=e.data.domProps||{},d=t.data.domProps||{};for(a in o(d.__ob__)&&(d=t.data.domProps=k({},d)),s)n(d[a])&&(i[a]="");for(a in d){if(r=d[a],"textContent"===a||"innerHTML"===a){if(t.children&&(t.children.length=0),r===s[a])continue;1===i.childNodes.length&&i.removeChild(i.childNodes[0])}if("value"===a||r!==s[a])if("value"===a){i._value=r;var l=n(r)?"":r+"";Rn(i,l)&&(i.value=l)}else if("innerHTML"===a&&Pr(i.tagName)&&n(i.innerHTML)){Nr=Nr||document.createElement("div"),Nr.innerHTML=""+r+"";for(var p=Nr.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;p.firstChild;)i.appendChild(p.firstChild)}else i[a]=r}}}function Rn(e,t){return!e.composing&&("OPTION"===e.tagName||Fn(e,t)||Un(e,t))}function Fn(e,t){var n=!0;try{n=document.activeElement!==e}catch(t){}return n&&e.value!==t}function Un(e,t){var n=e.value,a=e._vModifiers;if(o(a)){if(a.number)return g(n)!==g(t);if(a.trim)return n.trim()!==t.trim()}return n!==t}function Hn(e){var t=zn(e.style);return e.staticStyle?k(e.staticStyle,t):t}function zn(e){return Array.isArray(e)?N(e):"string"==typeof e?Br(e):e}function Kn(e,t){var n,o={};if(t)for(var a=e;a.componentInstance;)a=a.componentInstance._vnode,a&&a.data&&(n=Hn(a.data))&&k(o,n);(n=Hn(e.data))&&k(o,n);for(var r=e;r=r.parent;)r.data&&(n=Hn(r.data))&&k(o,n);return o}function Bn(e,t){var a=t.data,r=e.data;if(!(n(a.staticStyle)&&n(a.style)&&n(r.staticStyle)&&n(r.style))){var i,s,d=t.elm,l=r.staticStyle,p=r.normalizedStyle||r.style||{},c=l||p,u=zn(t.data.style)||{};t.data.normalizedStyle=o(u.__ob__)?k({},u):u;var m=Kn(t,!0);for(s in c)n(m[s])&&Yr(d,s,"");for(s in m)i=m[s],i!==c[s]&&Yr(d,s,null==i?"":i)}}function qn(e,t){if(t&&(t=t.trim()))if(e.classList)-1n.indexOf(" "+t+" ")&&e.setAttribute("class",(n+t).trim())}}function Wn(e,t){if(t&&(t=t.trim()))if(e.classList)-1n.indexOf(t)&&(n.push(t),qn(e,t))}function Xn(e,t){e._transitionClasses&&f(e._transitionClasses,t),Wn(e,t)}function Zn(t,e,n){var o=Qn(t,e),a=o.type,r=o.timeout,i=o.propCount;if(!a)return n();var s=a==="transition"?ti:oi,d=0,l=function(){t.removeEventListener(s,p),n()},p=function(n){n.target===t&&++d>=i&&l()};setTimeout(function(){dl?"transition":"animation":null,c=n?n==="transition"?r.length:d.length:0);var u=n==="transition"&&ri.test(o[ei+"Property"]);return{type:n,timeout:p,propCount:c,hasTransform:u}}function eo(e,t){for(;e.length explicit "+t+" duration is NaN - the duration expression might be incorrect.",n.context):ca(" explicit "+t+" duration is not a valid number - got "+JSON.stringify(e)+".",n.context)}function io(e){return"number"==typeof e&&!isNaN(e)}function so(e){if(n(e))return!1;var t=e.fns;return o(t)?so(Array.isArray(t)?t[0]:t):1<(e._length||e.length)}function lo(e,t){!0!==t.data.show&&oo(t)}function po(e,t,n){co(e,t,n),(Go||Xo)&&setTimeout(function(){co(e,t,n)},0)}function co(e,t,n){var o=t.value,a=e.multiple;if(a&&!Array.isArray(o))return void("production"!==process.env.NODE_ENV&&ca("