@nrk/core-dialog
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -1,3 +0,3 @@ | ||
/*! @nrk/core-dialog v2.0.1 - Copyright (c) 2017-2019 NRK */ | ||
/*! @nrk/core-dialog v2.0.2 - Copyright (c) 2017-2019 NRK */ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).coreDialog=e()}(this,function(){"use strict";function r(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t,e,n){return(o=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,n){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return n&&a(o,n.prototype),o}).apply(null,arguments)}function c(t){var i="function"==typeof Map?new Map:void 0;return(c=function(t){if(null===t||(e=t,-1===Function.toString.call(e).indexOf("[native code]")))return t;var e;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,n)}function n(){return o(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,t)})(t)}function s(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function l(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var t="undefined"!=typeof window;t&&/(android)/i.test(navigator.userAgent),t&&/iPad|iPhone|iPod/.test(String(navigator.platform));t&&!window.Element.prototype.toggleAttribute&&(window.Element.prototype.toggleAttribute=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:!this.hasAttribute(t);return!e===this.hasAttribute(t)&&this[e?"setAttribute":"removeAttribute"](t,""),e});var e,n,d=(e="undefined"==typeof window?{}:window.Element.prototype,n=e.matches||e.msMatchesSelector||e.webkitMatchesSelector,e.closest?function(t,e){return t.closest(e)}:function(t,e){for(;t;t=t.parentElement)if(n.call(t,e))return t;return null});function f(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document;if(t){if(t.nodeType)return[t];if("string"==typeof t)return[].slice.call(e.querySelectorAll(t));if(t.length)return[].slice.call(t)}return[]}var h="[tabindex],a,button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled])";function p(t){return t.clientWidth&&t.clientHeight&&"hidden"!==window.getComputedStyle(t).getPropertyValue("visibility")}function y(t){for(var e=t,n=1;e;e=e.offsetParent)n+=Number(window.getComputedStyle(e).getPropertyValue("z-index"))||0;return n}function b(e){if(!e.contains(document.activeElement)&&p(e)){var t=f("[autofocus]",e).concat(f(h,e)).filter(p)[0];try{t.focus()}catch(t){console.warn(e,'is initialized without focusable elements. Please add [tabindex="-1"] the main element (for instance a <h1>)')}}}return function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),s(this,u(e).apply(this,arguments))}var n,i,o;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&a(t,e)}(e,c(HTMLElement)),n=e,o=[{key:"observedAttributes",get:function(){return["hidden"]}}],(i=[{key:"connectedCallback",value:function(){this._open=!this.hidden,this._opener="data-dialog-".concat(Date.now().toString(36)+Math.random().toString(36).slice(2,5)),this.setAttribute("role","dialog"),this.setAttribute("aria-modal",this.modal),this.addEventListener("transitionend",this),document.addEventListener("keydown",this),document.addEventListener("click",this)}},{key:"disconnectedCallback",value:function(){this.removeEventListener("transitionend",this),document.removeEventListener("keydown",this),document.removeEventListener("click",this)}},{key:"attributeChangedCallback",value:function(t){if(this._open===this.hidden){var e=document.querySelector("[".concat(this._opener,"]")),n=e||document.activeElement||document.body,i=Math.min(Math.max.apply(Math,l(f("body *").map(y))),2e9);this.className=this.className,this.backdrop.hidden=!this.modal||this.hidden,this._open=!this.hidden,this.hidden?e&&(e.focus(),e.removeAttribute(this._opener),setTimeout(function(){return e.focus()})):(this.style.zIndex=i+2,this.backdrop.style.zIndex=i+1,n.setAttribute(this._opener,""),b(this)),function(t,e){var n,i=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},o="prevent_recursive_dispatch_maximum_callstack".concat(e);if(t[o])return;t[o]=!0,"function"==typeof window.CustomEvent?n=new window.CustomEvent(e,{bubbles:!0,cancelable:!0,detail:i}):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i);var r=t.dispatchEvent(n);t[o]=null}(this,"dialog.toggle")}}},{key:"handleEvent",value:function(t){var e,n,i,o;if(!t.defaultPrevented)if("transitionend"!==t.type||t.target!==this||this.hidden){if("click"===t.type){if(t.target===this.backdrop&&!this.strict)return this.close();var r=d(t.target,"button[for]"),u=r&&r.getAttribute("for"),a="close"===u?d(t.target,this.nodeName)===this:u===this.id;u===this.id&&r.setAttribute(this._opener,""),a&&(this.hidden="close"===u)}else if("keydown"===t.type&&(9===t.keyCode||27===t.keyCode)&&!this.hidden){if(f("".concat(this.nodeName,":not([hidden])")).sort(function(t,e){return y(t)-y(e)}).pop()!==this)return;9===t.keyCode&&(n=t,i=f(h,e=this).filter(p),o=i[n.shiftKey?0:i.length-1],n.target!==o&&e.contains(n.target)||(n.preventDefault(),i[n.shiftKey?i.length-1:0].focus())),27!==t.keyCode||this.strict||(t.preventDefault(),this.close())}}else b(this)}},{key:"close",value:function(){this.hidden=!0}},{key:"show",value:function(){this.modal=this.hidden=!1}},{key:"showModal",value:function(){this.modal=!0,this.hidden=!1}},{key:"open",get:function(){return!this.hidden},set:function(t){this.hidden=!t}},{key:"modal",get:function(){return"false"!==this.getAttribute("aria-modal")},set:function(t){this.setAttribute("aria-modal",Boolean(t))}},{key:"strict",get:function(){return this.hasAttribute("strict")},set:function(t){this.toggleAttribute("strict",t)}},{key:"hidden",get:function(){return this.hasAttribute("hidden")},set:function(t){this.toggleAttribute("hidden",t)}},{key:"backdrop",get:function(){var t=this.nextElementSibling;if(t&&"BACKDROP"===t.nodeName)return t;var e=document.createElement("backdrop");return e.hidden=!0,this.insertAdjacentElement("afterend",e)}}])&&r(n.prototype,i),o&&r(n,o),e}()}),window.customElements.define("core-dialog",coreDialog); | ||
//# sourceMappingURL=core-dialog.min.js.map |
@@ -5,3 +5,3 @@ { | ||
"author": "NRK <opensource@nrk.no> (https://www.nrk.no/)", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"license": "MIT", | ||
@@ -8,0 +8,0 @@ "main": "core-dialog.cjs.js", |
@@ -212,3 +212,3 @@ # Core Dialog | ||
Your dialog must contain `<input>`, `<button>`, `<select>`, `<textarea>`, `<a>` | ||
or element with `tabindex="-1"` to ensure the user is navigated into the `@nrk/nrk-dialog`. | ||
or element with `tabindex="-1"` to ensure the user is navigated into the `<core-dialog>`. | ||
As a best practice; if your dialog contains a form element, use `autofocus`. | ||
@@ -215,0 +215,0 @@ If you dialog is without form elements, start your dialog |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1
124360
12