@stormid/modal
Advanced tools
Comparing version 1.0.0-alpha.12 to 1.0.0-alpha.13
@@ -1,2 +0,2 @@ | ||
function e(){return e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},e.apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},n=["click","keydown"],o=[32,13],i=["a[href]","area[href]","input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],a=function(e){return e.querySelector("[role=dialog]")||e.querySelector("[role=alertdialog]")||console.warn("No dialog or alertdialog found in modal node")},r=function(e,t){var n=e.getAttribute(t.toggleSelectorAttribute)&&[].slice.call(document.querySelectorAll("."+e.getAttribute(t.toggleSelectorAttribute)));return n||console.warn("Modal cannot be initialised, no modal toggle elements found. Does the modal have a "+t.toggleSelectorAttribute+" attribute that identifies toggle buttons?"),n},l=function(e){return[].slice.call(e.querySelectorAll(i.join(",")))},c=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen},[u()])),e.getState().isOpen&&9===t.keyCode&&d(e.getState())(t)}},d=function(e){return function(t){var n=e.focusableChildren.indexOf(document.activeElement);t.shiftKey&&0===n?(t.preventDefault(),e.focusableChildren[e.focusableChildren.length-1].focus()):t.shiftKey||n!==e.focusableChildren.length-1||(t.preventDefault(),e.focusableChildren[0].focus())}},s=function(e){e.node[e.isOpen?"removeAttribute":"setAttribute"]("hidden","hidden"),[].slice.call(document.querySelectorAll("body > *")).forEach(function(t){return t!==e.node&&t[e.isOpen?"setAttribute":"removeAttribute"]("aria-hidden","true")}),e.node.classList.toggle(e.settings.onClassName),document.documentElement.classList.toggle("is--modal")},u=function(e){return function(e){e.isOpen?function(e){e.dialog.hasAttribute("aria-hidden")&&e.dialog.removeAttribute("aria-hidden");var t=document.body.firstElementChild||null;t!==e.node&&document.body.insertBefore(e.node,t),document.addEventListener("keydown",e.keyListener),s(e);var n=function(){return e.focusableChildren.length>0&&e.focusableChildren[0].focus()};e.settings.delay?window.setTimeout(n,e.settings.delay):n()}(e):function(e){document.removeEventListener("keydown",e.keyListener),s(e),e.lastFocused.focus()}(e),"function"==typeof e.settings.callback&&e.settings.callback.call(e)}},f=function(e){return function(t){var i=t.dialog,a=t.toggles;i&&a&&(t.node.setAttribute("hidden","hidden"),i.getAttribute("aria-label")||i.getAttribute("aria-labelledby")&&document.querySelector("#"+i.getAttribute("aria-labelledby"))||console.warn("The modal dialog should have an aria-labelledby attribute that matches the id of an element that contains text, or an aria-label attribute."),"alertdialog"!==i.getAttribute("role")||i.getAttribute("aria-describedby")&&document.querySelector("#"+i.getAttribute("aria-describedby"))||console.warn("The alertdialog should have an aria-describedby attribute that matches the id of an element that contains text"),a.forEach(function(t){n.forEach(function(n){t.addEventListener(n,function(n){n.keyCode&&!~o.indexOf(n.keyCode)||n.which&&3===n.which||(n.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:t},[u()]))})})}))}},b=function(e){return"string"==typeof e?[].slice.call(document.querySelectorAll(e)):e instanceof Array?e:Object.prototype.isPrototypeOf.call(NodeList.prototype,e)?[].slice.call(e):e instanceof HTMLElement?[e]:[]};exports.default=function(n,o){var i=b(n);return 0===i.length?console.warn("Modal not initialised, no elements found for selector '"+n+"'"):i.map(function(n){return Object.create(function(t){var n,o=t.node,i=t.settings,d=(n={},{dispatch:function(t,o){n=t?e({},n,t):n,o&&o.forEach(function(e){return e(n)})},getState:function(){return n}});return d.dispatch({settings:i,node:o,dialog:a(o),toggles:r(o,i),focusableChildren:l(o),keyListener:c(d),lastFocused:!1,isOpen:!1},[f(d)]),{getState:d.getState}}({settings:e({},t,n.dataset,o),node:n}))})},exports.getSelection=b; | ||
function e(){return e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},e.apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},n=["click","keydown"],o=[32,13],i=["a[href]","area[href]","input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],a=function(e){return e.querySelector("[role=dialog]")||e.querySelector("[role=alertdialog]")||console.warn("No dialog or alertdialog found in modal node")},r=function(e,t){var n=e.getAttribute(t.toggleSelectorAttribute)&&[].slice.call(document.querySelectorAll("."+e.getAttribute(t.toggleSelectorAttribute)));return n||console.warn("Modal cannot be initialised, no modal toggle elements found. Does the modal have a "+t.toggleSelectorAttribute+" attribute that identifies toggle buttons?"),n},l=function(e){return[].slice.call(e.querySelectorAll(i.join(",")))},d=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen},[u()])),e.getState().isOpen&&9===t.keyCode&&c(e.getState())(t)}},c=function(e){return function(t){var n=e.focusableChildren.indexOf(document.activeElement);t.shiftKey&&0===n?(t.preventDefault(),e.focusableChildren[e.focusableChildren.length-1].focus()):t.shiftKey||n!==e.focusableChildren.length-1||(t.preventDefault(),e.focusableChildren[0].focus())}},s=function(e){e.node[e.isOpen?"removeAttribute":"setAttribute"]("hidden","hidden"),[].slice.call(document.querySelectorAll("body > *")).forEach(function(t){return t!==e.node&&t[e.isOpen?"setAttribute":"removeAttribute"]("aria-hidden","true")}),e.node.classList.toggle(e.settings.onClassName),document.documentElement.classList.toggle("is--modal")},u=function(e){return function(e){e.isOpen?function(e){e.dialog.hasAttribute("aria-hidden")&&e.dialog.removeAttribute("aria-hidden");var t=document.body.firstElementChild||null;t!==e.node&&document.body.insertBefore(e.node,t),document.addEventListener("keydown",e.keyListener),s(e);var n=function(){return e.focusableChildren.length>0&&e.focusableChildren[0].focus()};e.settings.delay?window.setTimeout(n,e.settings.delay):n()}(e):function(e){document.removeEventListener("keydown",e.keyListener),s(e),e.lastFocused.focus()}(e),"function"==typeof e.settings.callback&&e.settings.callback.call(e)}},f=function(e){return function(t){var i=t.dialog,a=t.toggles;i&&a&&(t.node.setAttribute("hidden","hidden"),i.getAttribute("aria-label")||i.getAttribute("aria-labelledby")&&document.querySelector("#"+i.getAttribute("aria-labelledby"))||console.warn("The modal dialog should have an aria-labelledby attribute that matches the id of an element that contains text, or an aria-label attribute."),"alertdialog"!==i.getAttribute("role")||i.getAttribute("aria-describedby")&&document.querySelector("#"+i.getAttribute("aria-describedby"))||console.warn("The alertdialog should have an aria-describedby attribute that matches the id of an element that contains text"),a.forEach(function(t){n.forEach(function(n){t.addEventListener(n,function(n){n.keyCode&&!~o.indexOf(n.keyCode)||n.which&&3===n.which||(n.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:t},[u()]))})})}))}};module.exports=function(n,o){var i=function(e){return"string"==typeof e?[].slice.call(document.querySelectorAll(e)):e instanceof Array?e:Object.prototype.isPrototypeOf.call(NodeList.prototype,e)?[].slice.call(e):e instanceof HTMLElement?[e]:[]}(n);return 0===i.length?console.warn("Modal not initialised, no elements found for selector '"+n+"'"):i.map(function(n){return Object.create(function(t){var n,o=t.node,i=t.settings,c=(n={},{dispatch:function(t,o){n=t?e({},n,t):n,o&&o.forEach(function(e){return e(n)})},getState:function(){return n}});return c.dispatch({settings:i,node:o,dialog:a(o),toggles:r(o,i),focusableChildren:l(o),keyListener:d(c),lastFocused:!1,isOpen:!1},[f(c)]),{getState:c.getState}}({settings:e({},t,n.dataset,o),node:n}))})}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
function e(){return e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o])}return e},e.apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0};const a=["click","keydown"],o=[32,13],l=["a[href]","area[href]","input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],n=e=>e.querySelector("[role=dialog]")||e.querySelector("[role=alertdialog]")||console.warn("No dialog or alertdialog found in modal node"),i=(e,t)=>{const a=e.getAttribute(t.toggleSelectorAttribute)&&[].slice.call(document.querySelectorAll("."+e.getAttribute(t.toggleSelectorAttribute)));return a||console.warn(`Modal cannot be initialised, no modal toggle elements found. Does the modal have a ${t.toggleSelectorAttribute} attribute that identifies toggle buttons?`),a},r=e=>[].slice.call(e.querySelectorAll(l.join(","))),d=e=>t=>{e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen},[u()])),e.getState().isOpen&&9===t.keyCode&&s(e.getState())(t)},s=e=>t=>{const a=e.focusableChildren.indexOf(document.activeElement);t.shiftKey&&0===a?(t.preventDefault(),e.focusableChildren[e.focusableChildren.length-1].focus()):t.shiftKey||a!==e.focusableChildren.length-1||(t.preventDefault(),e.focusableChildren[0].focus())},c=e=>{e.node[e.isOpen?"removeAttribute":"setAttribute"]("hidden","hidden"),[].slice.call(document.querySelectorAll("body > *")).forEach(t=>t!==e.node&&t[e.isOpen?"setAttribute":"removeAttribute"]("aria-hidden","true")),e.node.classList.toggle(e.settings.onClassName),document.documentElement.classList.toggle("is--modal")},u=e=>e=>{e.isOpen?(e=>{e.dialog.hasAttribute("aria-hidden")&&e.dialog.removeAttribute("aria-hidden");const t=document.body.firstElementChild||null;t!==e.node&&document.body.insertBefore(e.node,t),document.addEventListener("keydown",e.keyListener),c(e);const a=()=>e.focusableChildren.length>0&&e.focusableChildren[0].focus();e.settings.delay?window.setTimeout(a,e.settings.delay):a()})(e):(e=>{document.removeEventListener("keydown",e.keyListener),c(e),e.lastFocused.focus()})(e),"function"==typeof e.settings.callback&&e.settings.callback.call(e)},b=e=>({node:t,dialog:l,toggles:n})=>{l&&n&&(t.setAttribute("hidden","hidden"),l.getAttribute("aria-label")||l.getAttribute("aria-labelledby")&&document.querySelector(`#${l.getAttribute("aria-labelledby")}`)||console.warn("The modal dialog should have an aria-labelledby attribute that matches the id of an element that contains text, or an aria-label attribute."),"alertdialog"!==l.getAttribute("role")||l.getAttribute("aria-describedby")&&document.querySelector(`#${l.getAttribute("aria-describedby")}`)||console.warn("The alertdialog should have an aria-describedby attribute that matches the id of an element that contains text"),n.forEach(t=>{a.forEach(a=>{t.addEventListener(a,a=>{a.keyCode&&!~o.indexOf(a.keyCode)||a.which&&3===a.which||(a.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:t},[u()]))})})}))},g=e=>"string"==typeof e?[].slice.call(document.querySelectorAll(e)):e instanceof Array?e:Object.prototype.isPrototypeOf.call(NodeList.prototype,e)?[].slice.call(e):e instanceof HTMLElement?[e]:[];var h=(a,o)=>{let l=g(a);return 0===l.length?console.warn(`Modal not initialised, no elements found for selector '${a}'`):l.map(a=>Object.create((({node:t,settings:a})=>{const o=(()=>{let t={};return{dispatch:(a,o)=>{t=a?e({},t,a):t,o&&o.forEach(e=>e(t))},getState:()=>t}})();return o.dispatch({settings:a,node:t,dialog:n(t),toggles:i(t,a),focusableChildren:r(t),keyListener:d(o),lastFocused:!1,isOpen:!1},[b(o)]),{getState:o.getState}})({settings:e({},t,a.dataset,o),node:a})))};export{h as default,g as getSelection}; | ||
function e(){return e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o])}return e},e.apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0};const a=["click","keydown"],o=[32,13],l=["a[href]","area[href]","input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],n=e=>e.querySelector("[role=dialog]")||e.querySelector("[role=alertdialog]")||console.warn("No dialog or alertdialog found in modal node"),i=(e,t)=>{const a=e.getAttribute(t.toggleSelectorAttribute)&&[].slice.call(document.querySelectorAll("."+e.getAttribute(t.toggleSelectorAttribute)));return a||console.warn(`Modal cannot be initialised, no modal toggle elements found. Does the modal have a ${t.toggleSelectorAttribute} attribute that identifies toggle buttons?`),a},r=e=>[].slice.call(e.querySelectorAll(l.join(","))),d=e=>t=>{e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen},[u()])),e.getState().isOpen&&9===t.keyCode&&s(e.getState())(t)},s=e=>t=>{const a=e.focusableChildren.indexOf(document.activeElement);t.shiftKey&&0===a?(t.preventDefault(),e.focusableChildren[e.focusableChildren.length-1].focus()):t.shiftKey||a!==e.focusableChildren.length-1||(t.preventDefault(),e.focusableChildren[0].focus())},c=e=>{e.node[e.isOpen?"removeAttribute":"setAttribute"]("hidden","hidden"),[].slice.call(document.querySelectorAll("body > *")).forEach(t=>t!==e.node&&t[e.isOpen?"setAttribute":"removeAttribute"]("aria-hidden","true")),e.node.classList.toggle(e.settings.onClassName),document.documentElement.classList.toggle("is--modal")},u=e=>e=>{e.isOpen?(e=>{e.dialog.hasAttribute("aria-hidden")&&e.dialog.removeAttribute("aria-hidden");const t=document.body.firstElementChild||null;t!==e.node&&document.body.insertBefore(e.node,t),document.addEventListener("keydown",e.keyListener),c(e);const a=()=>e.focusableChildren.length>0&&e.focusableChildren[0].focus();e.settings.delay?window.setTimeout(a,e.settings.delay):a()})(e):(e=>{document.removeEventListener("keydown",e.keyListener),c(e),e.lastFocused.focus()})(e),"function"==typeof e.settings.callback&&e.settings.callback.call(e)},b=e=>({node:t,dialog:l,toggles:n})=>{l&&n&&(t.setAttribute("hidden","hidden"),l.getAttribute("aria-label")||l.getAttribute("aria-labelledby")&&document.querySelector(`#${l.getAttribute("aria-labelledby")}`)||console.warn("The modal dialog should have an aria-labelledby attribute that matches the id of an element that contains text, or an aria-label attribute."),"alertdialog"!==l.getAttribute("role")||l.getAttribute("aria-describedby")&&document.querySelector(`#${l.getAttribute("aria-describedby")}`)||console.warn("The alertdialog should have an aria-describedby attribute that matches the id of an element that contains text"),n.forEach(t=>{a.forEach(a=>{t.addEventListener(a,a=>{a.keyCode&&!~o.indexOf(a.keyCode)||a.which&&3===a.which||(a.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:t},[u()]))})})}))};var g=(a,o)=>{let l=(e=>"string"==typeof e?[].slice.call(document.querySelectorAll(e)):e instanceof Array?e:Object.prototype.isPrototypeOf.call(NodeList.prototype,e)?[].slice.call(e):e instanceof HTMLElement?[e]:[])(a);return 0===l.length?console.warn(`Modal not initialised, no elements found for selector '${a}'`):l.map(a=>Object.create((({node:t,settings:a})=>{const o=(()=>{let t={};return{dispatch:(a,o)=>{t=a?e({},t,a):t,o&&o.forEach(e=>e(t))},getState:()=>t}})();return o.dispatch({settings:a,node:t,dialog:n(t),toggles:i(t,a),focusableChildren:r(t),keyListener:d(o),lastFocused:!1,isOpen:!1},[b(o)]),{getState:o.getState}})({settings:e({},t,a.dataset,o),node:a})))};export{g as default}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).Modal={})}(this,function(e){function t(){return t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},t.apply(this,arguments)}var n={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},o=["click","keydown"],i=[32,13],a=["a[href]","area[href]","input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],l=function(e){return e.querySelector("[role=dialog]")||e.querySelector("[role=alertdialog]")||console.warn("No dialog or alertdialog found in modal node")},r=function(e,t){var n=e.getAttribute(t.toggleSelectorAttribute)&&[].slice.call(document.querySelectorAll("."+e.getAttribute(t.toggleSelectorAttribute)));return n||console.warn("Modal cannot be initialised, no modal toggle elements found. Does the modal have a "+t.toggleSelectorAttribute+" attribute that identifies toggle buttons?"),n},d=function(e){return[].slice.call(e.querySelectorAll(a.join(",")))},c=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen},[f()])),e.getState().isOpen&&9===t.keyCode&&s(e.getState())(t)}},s=function(e){return function(t){var n=e.focusableChildren.indexOf(document.activeElement);t.shiftKey&&0===n?(t.preventDefault(),e.focusableChildren[e.focusableChildren.length-1].focus()):t.shiftKey||n!==e.focusableChildren.length-1||(t.preventDefault(),e.focusableChildren[0].focus())}},u=function(e){e.node[e.isOpen?"removeAttribute":"setAttribute"]("hidden","hidden"),[].slice.call(document.querySelectorAll("body > *")).forEach(function(t){return t!==e.node&&t[e.isOpen?"setAttribute":"removeAttribute"]("aria-hidden","true")}),e.node.classList.toggle(e.settings.onClassName),document.documentElement.classList.toggle("is--modal")},f=function(e){return function(e){e.isOpen?function(e){e.dialog.hasAttribute("aria-hidden")&&e.dialog.removeAttribute("aria-hidden");var t=document.body.firstElementChild||null;t!==e.node&&document.body.insertBefore(e.node,t),document.addEventListener("keydown",e.keyListener),u(e);var n=function(){return e.focusableChildren.length>0&&e.focusableChildren[0].focus()};e.settings.delay?window.setTimeout(n,e.settings.delay):n()}(e):function(e){document.removeEventListener("keydown",e.keyListener),u(e),e.lastFocused.focus()}(e),"function"==typeof e.settings.callback&&e.settings.callback.call(e)}},b=function(e){return function(t){var n=t.dialog,a=t.toggles;n&&a&&(t.node.setAttribute("hidden","hidden"),n.getAttribute("aria-label")||n.getAttribute("aria-labelledby")&&document.querySelector("#"+n.getAttribute("aria-labelledby"))||console.warn("The modal dialog should have an aria-labelledby attribute that matches the id of an element that contains text, or an aria-label attribute."),"alertdialog"!==n.getAttribute("role")||n.getAttribute("aria-describedby")&&document.querySelector("#"+n.getAttribute("aria-describedby"))||console.warn("The alertdialog should have an aria-describedby attribute that matches the id of an element that contains text"),a.forEach(function(t){o.forEach(function(n){t.addEventListener(n,function(n){n.keyCode&&!~i.indexOf(n.keyCode)||n.which&&3===n.which||(n.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:t},[f()]))})})}))}},g=function(e){return"string"==typeof e?[].slice.call(document.querySelectorAll(e)):e instanceof Array?e:Object.prototype.isPrototypeOf.call(NodeList.prototype,e)?[].slice.call(e):e instanceof HTMLElement?[e]:[]};e.default=function(e,o){var i=g(e);return 0===i.length?console.warn("Modal not initialised, no elements found for selector '"+e+"'"):i.map(function(e){return Object.create(function(e){var n,o=e.node,i=e.settings,a=(n={},{dispatch:function(e,o){n=e?t({},n,e):n,o&&o.forEach(function(e){return e(n)})},getState:function(){return n}});return a.dispatch({settings:i,node:o,dialog:l(o),toggles:r(o,i),focusableChildren:d(o),keyListener:c(a),lastFocused:!1,isOpen:!1},[b(a)]),{getState:a.getState}}({settings:t({},n,e.dataset,o),node:e}))})},e.getSelection=g}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).Modal=t()}(this,function(){function e(){return e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},e.apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},n=["click","keydown"],o=[32,13],i=["a[href]","area[href]","input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],a=function(e){return e.querySelector("[role=dialog]")||e.querySelector("[role=alertdialog]")||console.warn("No dialog or alertdialog found in modal node")},l=function(e,t){var n=e.getAttribute(t.toggleSelectorAttribute)&&[].slice.call(document.querySelectorAll("."+e.getAttribute(t.toggleSelectorAttribute)));return n||console.warn("Modal cannot be initialised, no modal toggle elements found. Does the modal have a "+t.toggleSelectorAttribute+" attribute that identifies toggle buttons?"),n},r=function(e){return[].slice.call(e.querySelectorAll(i.join(",")))},d=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen},[u()])),e.getState().isOpen&&9===t.keyCode&&c(e.getState())(t)}},c=function(e){return function(t){var n=e.focusableChildren.indexOf(document.activeElement);t.shiftKey&&0===n?(t.preventDefault(),e.focusableChildren[e.focusableChildren.length-1].focus()):t.shiftKey||n!==e.focusableChildren.length-1||(t.preventDefault(),e.focusableChildren[0].focus())}},s=function(e){e.node[e.isOpen?"removeAttribute":"setAttribute"]("hidden","hidden"),[].slice.call(document.querySelectorAll("body > *")).forEach(function(t){return t!==e.node&&t[e.isOpen?"setAttribute":"removeAttribute"]("aria-hidden","true")}),e.node.classList.toggle(e.settings.onClassName),document.documentElement.classList.toggle("is--modal")},u=function(e){return function(e){e.isOpen?function(e){e.dialog.hasAttribute("aria-hidden")&&e.dialog.removeAttribute("aria-hidden");var t=document.body.firstElementChild||null;t!==e.node&&document.body.insertBefore(e.node,t),document.addEventListener("keydown",e.keyListener),s(e);var n=function(){return e.focusableChildren.length>0&&e.focusableChildren[0].focus()};e.settings.delay?window.setTimeout(n,e.settings.delay):n()}(e):function(e){document.removeEventListener("keydown",e.keyListener),s(e),e.lastFocused.focus()}(e),"function"==typeof e.settings.callback&&e.settings.callback.call(e)}},f=function(e){return function(t){var i=t.dialog,a=t.toggles;i&&a&&(t.node.setAttribute("hidden","hidden"),i.getAttribute("aria-label")||i.getAttribute("aria-labelledby")&&document.querySelector("#"+i.getAttribute("aria-labelledby"))||console.warn("The modal dialog should have an aria-labelledby attribute that matches the id of an element that contains text, or an aria-label attribute."),"alertdialog"!==i.getAttribute("role")||i.getAttribute("aria-describedby")&&document.querySelector("#"+i.getAttribute("aria-describedby"))||console.warn("The alertdialog should have an aria-describedby attribute that matches the id of an element that contains text"),a.forEach(function(t){n.forEach(function(n){t.addEventListener(n,function(n){n.keyCode&&!~o.indexOf(n.keyCode)||n.which&&3===n.which||(n.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:t},[u()]))})})}))}};return function(n,o){var i=function(e){return"string"==typeof e?[].slice.call(document.querySelectorAll(e)):e instanceof Array?e:Object.prototype.isPrototypeOf.call(NodeList.prototype,e)?[].slice.call(e):e instanceof HTMLElement?[e]:[]}(n);return 0===i.length?console.warn("Modal not initialised, no elements found for selector '"+n+"'"):i.map(function(n){return Object.create(function(t){var n,o=t.node,i=t.settings,c=(n={},{dispatch:function(t,o){n=t?e({},n,t):n,o&&o.forEach(function(e){return e(n)})},getState:function(){return n}});return c.dispatch({settings:i,node:o,dialog:a(o),toggles:l(o,i),focusableChildren:r(o),keyListener:d(c),lastFocused:!1,isOpen:!1},[f(c)]),{getState:c.getState}}({settings:e({},t,n.dataset,o),node:n}))})}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@stormid/modal", | ||
"version": "1.0.0-alpha.12", | ||
"version": "1.0.0-alpha.13", | ||
"description": "Accessible modal dialog", | ||
@@ -31,3 +31,3 @@ "author": "stormid", | ||
}, | ||
"gitHead": "5a78d93bb9f509d1af5dcf4d3b3f30bb2cd1583f" | ||
"gitHead": "4051edd5bb4b814992e426711b1fac24a676fa7f" | ||
} |
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
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
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
81433