@stormid/modal
Advanced tools
Comparing version 1.0.0-alpha.6 to 1.0.0-alpha.7
@@ -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 a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},n=["click","keydown"],a=[32,13],o=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],i=function(e){return e.querySelector("[role=dialog]")||console.warn("No dialog 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(o.join(",")))},c=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),d()(e.getState())),e.getState().isOpen&&9===t.keyCode&&u(e.getState())(t)}},u=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.dialog.setAttribute("aria-hidden",!e.isOpen),e.node.classList.toggle(e.settings.onClassName)},d=function(e){return function(e){e.isOpen?function(e){document.addEventListener("keydown",e.keyListener),s(e);var t=function(){return e.focusableChildren.length>0&&e.focusableChildren[0].focus()};e.settings.delay?window.setTimeout(t,e.settings.delay):t()}(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 o=t.dialog,i=t.toggles;o&&i&&(o.setAttribute("aria-hidden",!0),o.getAttribute("aria-modal")||console.warn("The modal dialog should have an aria-modal attribute of 'true'."),o.getAttribute("aria-label")||o.getAttribute("aria-labelledby")&&document.querySelector("#"+o.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."),i.forEach(function(t){n.forEach(function(n){t.addEventListener(n,function(n){n.keyCode&&!~a.indexOf(n.keyCode)||n.which&&3===n.which||(n.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:t},[d()]))})})}))}};module.exports=function(n,a){var o=[].slice.call(document.querySelectorAll(n));return 0===o.length?console.warn("Modal not initialised, no elements found for selector '"+n+"'"):o.map(function(n){return Object.create(function(t){var n,a=t.node,o=t.settings,u=(n={},{dispatch:function(t,a){n=t?e({},n,t):n,a&&a.forEach(function(e){return e(n)})},getState:function(){return n}});return u.dispatch({settings:o,node:a,dialog:i(a),toggles:l(a,o),focusableChildren:r(a),keyListener:c(u),lastFocused:!1,isOpen:!1},[f(u)]),{getState:u.getState}}({settings:e({},t,n.dataset,a),node:n}))})}; | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e}).apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},n=["click","keydown"],a=[32,13],o=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],i=function(e){return e.querySelector("[role=dialog]")||console.warn("No dialog 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(o.join(",")))},c=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen},[d()])),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.dialog.setAttribute("aria-hidden",!e.isOpen),e.node.classList.toggle(e.settings.onClassName)},d=function(e){return function(e){e.isOpen?function(e){document.addEventListener("keydown",e.keyListener),u(e);var t=function(){return e.focusableChildren.length>0&&e.focusableChildren[0].focus()};e.settings.delay?window.setTimeout(t,e.settings.delay):t()}(e):function(e){document.removeEventListener("keydown",e.keyListener),u(e),e.lastFocused.focus()}(e),"function"==typeof e.settings.callback&&e.settings.callback.call(e)}},f=function(e){return function(t){var o=t.dialog,i=t.toggles;o&&i&&(o.setAttribute("aria-hidden",!0),o.getAttribute("aria-modal")||console.warn("The modal dialog should have an aria-modal attribute of 'true'."),o.getAttribute("aria-label")||o.getAttribute("aria-labelledby")&&document.querySelector("#"+o.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."),i.forEach(function(t){n.forEach(function(n){t.addEventListener(n,function(n){n.keyCode&&!~a.indexOf(n.keyCode)||n.which&&3===n.which||(n.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:t},[d()]))})})}))}};module.exports=function(n,a){var o=[].slice.call(document.querySelectorAll(n));return 0===o.length?console.warn("Modal not initialised, no elements found for selector '"+n+"'"):o.map(function(n){return Object.create(function(t){var n,a=t.node,o=t.settings,s=(n={},{dispatch:function(t,a){n=t?e({},n,t):n,a&&a.forEach(function(e){return e(n)})},getState:function(){return n}});return s.dispatch({settings:o,node:a,dialog:i(a),toggles:l(a,o),focusableChildren:r(a),keyListener:c(s),lastFocused:!1,isOpen:!1},[f(s)]),{getState:s.getState}}({settings:e({},t,n.dataset,a),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 l in a)Object.prototype.hasOwnProperty.call(a,l)&&(e[l]=a[l])}return e}).apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0};const a=["click","keydown"],l=[32,13],o=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],n=e=>e.querySelector("[role=dialog]")||console.warn("No dialog 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},s=e=>[].slice.call(e.querySelectorAll(o.join(","))),r=e=>t=>{e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),u()(e.getState())),e.getState().isOpen&&9===t.keyCode&&d(e.getState())(t)},d=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.dialog.setAttribute("aria-hidden",!e.isOpen),e.node.classList.toggle(e.settings.onClassName)},u=e=>e=>{e.isOpen?(e=>{document.addEventListener("keydown",e.keyListener),c(e);const t=()=>e.focusableChildren.length>0&&e.focusableChildren[0].focus();e.settings.delay?window.setTimeout(t,e.settings.delay):t()})(e):(e=>{document.removeEventListener("keydown",e.keyListener),c(e),e.lastFocused.focus()})(e),"function"==typeof e.settings.callback&&e.settings.callback.call(e)},g=e=>({dialog:t,toggles:o})=>{t&&o&&(t.setAttribute("aria-hidden",!0),t.getAttribute("aria-modal")||console.warn("The modal dialog should have an aria-modal attribute of 'true'."),t.getAttribute("aria-label")||t.getAttribute("aria-labelledby")&&document.querySelector(`#${t.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."),o.forEach(t=>{a.forEach(a=>{t.addEventListener(a,a=>{a.keyCode&&!~l.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()]))})})}))};export default(a,l)=>{const o=[].slice.call(document.querySelectorAll(a));return 0===o.length?console.warn(`Modal not initialised, no elements found for selector '${a}'`):o.map(a=>Object.create((({node:t,settings:a})=>{const l=(()=>{let t={};return{dispatch:(a,l)=>{t=a?e({},t,a):t,l&&l.forEach(e=>e(t))},getState:()=>t}})();return l.dispatch({settings:a,node:t,dialog:n(t),toggles:i(t,a),focusableChildren:s(t),keyListener:r(l),lastFocused:!1,isOpen:!1},[g(l)]),{getState:l.getState}})({settings:e({},t,a.dataset,l),node:a})))}; | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var a=arguments[t];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&(e[l]=a[l])}return e}).apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0};const a=["click","keydown"],l=[32,13],o=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],n=e=>e.querySelector("[role=dialog]")||console.warn("No dialog 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},s=e=>[].slice.call(e.querySelectorAll(o.join(","))),r=e=>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=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.dialog.setAttribute("aria-hidden",!e.isOpen),e.node.classList.toggle(e.settings.onClassName)},u=e=>e=>{e.isOpen?(e=>{document.addEventListener("keydown",e.keyListener),c(e);const t=()=>e.focusableChildren.length>0&&e.focusableChildren[0].focus();e.settings.delay?window.setTimeout(t,e.settings.delay):t()})(e):(e=>{document.removeEventListener("keydown",e.keyListener),c(e),e.lastFocused.focus()})(e),"function"==typeof e.settings.callback&&e.settings.callback.call(e)},g=e=>({dialog:t,toggles:o})=>{t&&o&&(t.setAttribute("aria-hidden",!0),t.getAttribute("aria-modal")||console.warn("The modal dialog should have an aria-modal attribute of 'true'."),t.getAttribute("aria-label")||t.getAttribute("aria-labelledby")&&document.querySelector(`#${t.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."),o.forEach(t=>{a.forEach(a=>{t.addEventListener(a,a=>{a.keyCode&&!~l.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()]))})})}))};export default(a,l)=>{const o=[].slice.call(document.querySelectorAll(a));return 0===o.length?console.warn(`Modal not initialised, no elements found for selector '${a}'`):o.map(a=>Object.create((({node:t,settings:a})=>{const l=(()=>{let t={};return{dispatch:(a,l)=>{t=a?e({},t,a):t,l&&l.forEach(e=>e(t))},getState:()=>t}})();return l.dispatch({settings:a,node:t,dialog:n(t),toggles:i(t,a),focusableChildren:s(t),keyListener:r(l),lastFocused:!1,isOpen:!1},[g(l)]),{getState:l.getState}})({settings:e({},t,a.dataset,l),node:a})))}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!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}).apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},n=["click","keydown"],o=[32,13],a=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],i=function(e){return e.querySelector("[role=dialog]")||console.warn("No dialog 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(a.join(",")))},u=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),d()(e.getState())),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.dialog.setAttribute("aria-hidden",!e.isOpen),e.node.classList.toggle(e.settings.onClassName)},d=function(e){return function(e){e.isOpen?function(e){document.addEventListener("keydown",e.keyListener),s(e);var t=function(){return e.focusableChildren.length>0&&e.focusableChildren[0].focus()};e.settings.delay?window.setTimeout(t,e.settings.delay):t()}(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 a=t.dialog,i=t.toggles;a&&i&&(a.setAttribute("aria-hidden",!0),a.getAttribute("aria-modal")||console.warn("The modal dialog should have an aria-modal attribute of 'true'."),a.getAttribute("aria-label")||a.getAttribute("aria-labelledby")&&document.querySelector("#"+a.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."),i.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},[d()]))})})}))}};return function(n,o){var a=[].slice.call(document.querySelectorAll(n));return 0===a.length?console.warn("Modal not initialised, no elements found for selector '"+n+"'"):a.map(function(n){return Object.create(function(t){var n,o=t.node,a=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:a,node:o,dialog:i(o),toggles:l(o,a),focusableChildren:r(o),keyListener:u(c),lastFocused:!1,isOpen:!1},[f(c)]),{getState:c.getState}}({settings:e({},t,n.dataset,o),node:n}))})}}); | ||
!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}).apply(this,arguments)}var t={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},n=["click","keydown"],o=[32,13],a=["a[href]","area[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","iframe","object","embed","[contenteditable]",'[tabindex]:not([tabindex="-1"])'],i=function(e){return e.querySelector("[role=dialog]")||console.warn("No dialog 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(a.join(",")))},s=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen},[d()])),e.getState().isOpen&&9===t.keyCode&&u(e.getState())(t)}},u=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())}},c=function(e){e.dialog.setAttribute("aria-hidden",!e.isOpen),e.node.classList.toggle(e.settings.onClassName)},d=function(e){return function(e){e.isOpen?function(e){document.addEventListener("keydown",e.keyListener),c(e);var t=function(){return e.focusableChildren.length>0&&e.focusableChildren[0].focus()};e.settings.delay?window.setTimeout(t,e.settings.delay):t()}(e):function(e){document.removeEventListener("keydown",e.keyListener),c(e),e.lastFocused.focus()}(e),"function"==typeof e.settings.callback&&e.settings.callback.call(e)}},f=function(e){return function(t){var a=t.dialog,i=t.toggles;a&&i&&(a.setAttribute("aria-hidden",!0),a.getAttribute("aria-modal")||console.warn("The modal dialog should have an aria-modal attribute of 'true'."),a.getAttribute("aria-label")||a.getAttribute("aria-labelledby")&&document.querySelector("#"+a.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."),i.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},[d()]))})})}))}};return function(n,o){var a=[].slice.call(document.querySelectorAll(n));return 0===a.length?console.warn("Modal not initialised, no elements found for selector '"+n+"'"):a.map(function(n){return Object.create(function(t){var n,o=t.node,a=t.settings,u=(n={},{dispatch:function(t,o){n=t?e({},n,t):n,o&&o.forEach(function(e){return e(n)})},getState:function(){return n}});return u.dispatch({settings:a,node:o,dialog:i(o),toggles:l(o,a),focusableChildren:r(o),keyListener:s(u),lastFocused:!1,isOpen:!1},[f(u)]),{getState:u.getState}}({settings:e({},t,n.dataset,o),node:n}))})}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@stormid/modal", | ||
"version": "1.0.0-alpha.6", | ||
"version": "1.0.0-alpha.7", | ||
"description": "Accessible modal dialog", | ||
@@ -31,3 +31,3 @@ "author": "stormid", | ||
}, | ||
"gitHead": "2a1c93f488c8560daffc514cc5d11fab68e7d649" | ||
"gitHead": "af37eef2eaa198200cca25a8858fcaeeb11b7a97" | ||
} |
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
69617
57