Socket
Socket
Sign inDemoInstall

@stormid/modal

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stormid/modal - npm Package Compare versions

Comparing version 1.0.0-alpha.4 to 1.0.0-alpha.5

2

dist/index.js

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

var e={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},t=window.PointerEvent?["pointerup","keydown"]:["ontouchend"in window?"ontouchend":"click","keydown"],n=[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"])'],a=function(e){return e.querySelector("[role=dialog]")||console.warn("No dialog found in modal node")},i=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(o.join(",")))},r=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),s(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)},u=function(e){return function(o){var a=o.dialog,i=o.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(o){t.forEach(function(t){o.addEventListener(t,function(t){t.keyCode&&!~n.indexOf(t.keyCode)||t.which&&3===t.which||(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:o},[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)}]))})})}))}};module.exports=function(t,n){var o=[].slice.call(document.querySelectorAll(t));return 0===o.length?console.warn("Modal not initialised, no elements found for selector '"+t+"'"):o.map(function(t){return Object.create(function(e){var t,n=e.node,o=e.settings,c=(t={},{dispatch:function(e,n){t=e?Object.assign({},t,e):t,n&&n.forEach(function(e){return e(t)})},getState:function(){return t}});return c.dispatch({settings:o,node:n,dialog:a(n),toggles:i(n,o),focusableChildren:l(n),keyListener:r(c),lastFocused:!1,isOpen:!1},[u(c)]),{getState:c.getState}}({settings:Object.assign({},e,t.dataset,n),node:t}))})};
var e={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},t=["click","keydown"],n=[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"])'],o=function(e){return e.querySelector("[role=dialog]")||console.warn("No dialog found in modal node")},i=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(a.join(",")))},r=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),c(e.getState())),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())}},c=function(e){e.dialog.setAttribute("aria-hidden",!e.isOpen),e.node.classList.toggle(e.settings.onClassName)},u=function(e){return function(a){var o=a.dialog,i=a.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(a){t.forEach(function(t){a.addEventListener(t,function(t){t.keyCode&&!~n.indexOf(t.keyCode)||t.which&&3===t.which||(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:a},[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)}]))})})}))}};module.exports=function(t,n){var a=[].slice.call(document.querySelectorAll(t));return 0===a.length?console.warn("Modal not initialised, no elements found for selector '"+t+"'"):a.map(function(t){return Object.create(function(e){var t,n=e.node,a=e.settings,s=(t={},{dispatch:function(e,n){t=e?Object.assign({},t,e):t,n&&n.forEach(function(e){return e(t)})},getState:function(){return t}});return s.dispatch({settings:a,node:n,dialog:o(n),toggles:i(n,a),focusableChildren:l(n),keyListener:r(s),lastFocused:!1,isOpen:!1},[u(s)]),{getState:s.getState}}({settings:Object.assign({},e,t.dataset,n),node:t}))})};
//# sourceMappingURL=index.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.Modal=t()}(this,function(){var e={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},t=window.PointerEvent?["pointerup","keydown"]:["ontouchend"in window?"ontouchend":"click","keydown"],n=[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"])'],a=function(e){return e.querySelector("[role=dialog]")||console.warn("No dialog found in modal node")},i=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(o.join(",")))},r=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),c(e.getState())),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())}},c=function(e){e.dialog.setAttribute("aria-hidden",!e.isOpen),e.node.classList.toggle(e.settings.onClassName)},u=function(e){return function(o){var a=o.dialog,i=o.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(o){t.forEach(function(t){o.addEventListener(t,function(t){t.keyCode&&!~n.indexOf(t.keyCode)||t.which&&3===t.which||(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:o},[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)}]))})})}))}};return function(t,n){var o=[].slice.call(document.querySelectorAll(t));return 0===o.length?console.warn("Modal not initialised, no elements found for selector '"+t+"'"):o.map(function(t){return Object.create(function(e){var t,n=e.node,o=e.settings,d=(t={},{dispatch:function(e,n){t=e?Object.assign({},t,e):t,n&&n.forEach(function(e){return e(t)})},getState:function(){return t}});return d.dispatch({settings:o,node:n,dialog:a(n),toggles:i(n,o),focusableChildren:l(n),keyListener:r(d),lastFocused:!1,isOpen:!1},[u(d)]),{getState:d.getState}}({settings:Object.assign({},e,t.dataset,n),node:t}))})}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Modal=t()}(this,function(){var e={onClassName:"is--active",toggleSelectorAttribute:"data-modal-toggle",callback:!1,delay:0},t=["click","keydown"],n=[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"])'],a=function(e){return e.querySelector("[role=dialog]")||console.warn("No dialog found in modal node")},i=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(o.join(",")))},r=function(e){return function(t){e.getState().isOpen&&27===t.keyCode&&(t.preventDefault(),s(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)},u=function(e){return function(o){var a=o.dialog,i=o.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(o){t.forEach(function(t){o.addEventListener(t,function(t){t.keyCode&&!~n.indexOf(t.keyCode)||t.which&&3===t.which||(t.preventDefault(),e.dispatch({isOpen:!e.getState().isOpen,lastFocused:e.getState().isOpen?e.getState().lastFocused:o},[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)}]))})})}))}};return function(t,n){var o=[].slice.call(document.querySelectorAll(t));return 0===o.length?console.warn("Modal not initialised, no elements found for selector '"+t+"'"):o.map(function(t){return Object.create(function(e){var t,n=e.node,o=e.settings,c=(t={},{dispatch:function(e,n){t=e?Object.assign({},t,e):t,n&&n.forEach(function(e){return e(t)})},getState:function(){return t}});return c.dispatch({settings:o,node:n,dialog:a(n),toggles:i(n,o),focusableChildren:l(n),keyListener:r(c),lastFocused:!1,isOpen:!1},[u(c)]),{getState:c.getState}}({settings:Object.assign({},e,t.dataset,n),node:t}))})}});
//# sourceMappingURL=index.umd.js.map
{
"name": "@stormid/modal",
"version": "1.0.0-alpha.4",
"version": "1.0.0-alpha.5",
"description": "Accessible modal dialog",

@@ -31,3 +31,3 @@ "author": "stormid",

},
"gitHead": "21baf6c4e6b44d324308f2b97a1654537839e455"
"gitHead": "8daca30ea97c9798b5bb85115b03a0f494282b26"
}

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