@preline/overlay
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -1,3 +0,1 @@ | ||
export interface IBasePlugin<O, E> { | ||
@@ -23,2 +21,3 @@ el: E; | ||
hiddenClass?: string | null; | ||
emulateScrollbarSpace?: boolean; | ||
isClosePrev?: boolean; | ||
@@ -35,5 +34,7 @@ backdropClasses?: string | null; | ||
private readonly hiddenClass; | ||
private readonly emulateScrollbarSpace; | ||
private readonly isClosePrev; | ||
private readonly backdropClasses; | ||
private readonly backdropExtraClasses; | ||
private readonly animationTarget; | ||
private openNextOverlay; | ||
@@ -57,2 +58,3 @@ private autoHide; | ||
private focusElement; | ||
private getScrollbarSize; | ||
open(): false | Promise<void>; | ||
@@ -59,0 +61,0 @@ close(forceClose?: boolean): Promise<unknown>; |
22
index.js
@@ -1,17 +0,17 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(self,(()=>(()=>{"use strict";var e={190:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BREAKPOINTS=t.COMBO_BOX_ACCESSIBILITY_KEY_SET=t.SELECT_ACCESSIBILITY_KEY_SET=t.TABS_ACCESSIBILITY_KEY_SET=t.OVERLAY_ACCESSIBILITY_KEY_SET=t.DROPDOWN_ACCESSIBILITY_KEY_SET=t.POSITIONS=void 0,t.POSITIONS={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-left":"top-start","top-right":"top-end",bottom:"bottom","bottom-left":"bottom-start","bottom-right":"bottom-end",right:"right","right-start":"right-start","right-end":"right-end",left:"left","left-start":"left-start","left-end":"left-end"},t.DROPDOWN_ACCESSIBILITY_KEY_SET=["Escape","ArrowUp","ArrowDown","Home","End","Enter"],t.OVERLAY_ACCESSIBILITY_KEY_SET=["Escape","Tab"],t.TABS_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End"],t.SELECT_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Tab"],t.COMBO_BOX_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter"],t.BREAKPOINTS={sm:640,md:768,lg:1024,xl:1280,"2xl":1536}},737:(e,t)=>{ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var o=t();for(var n in o)("object"==typeof exports?exports:e)[n]=o[n]}}(self,(()=>(()=>{"use strict";var e={223:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.BREAKPOINTS=t.COMBO_BOX_ACCESSIBILITY_KEY_SET=t.SELECT_ACCESSIBILITY_KEY_SET=t.TABS_ACCESSIBILITY_KEY_SET=t.OVERLAY_ACCESSIBILITY_KEY_SET=t.DROPDOWN_ACCESSIBILITY_KEY_SET=t.POSITIONS=void 0,t.POSITIONS={auto:"auto","auto-start":"auto-start","auto-end":"auto-end",top:"top","top-left":"top-start","top-right":"top-end",bottom:"bottom","bottom-left":"bottom-start","bottom-right":"bottom-end",right:"right","right-start":"right-start","right-end":"right-end",left:"left","left-start":"left-start","left-end":"left-end"},t.DROPDOWN_ACCESSIBILITY_KEY_SET=["Escape","ArrowUp","ArrowDown","Home","End","Enter"],t.OVERLAY_ACCESSIBILITY_KEY_SET=["Escape","Tab"],t.TABS_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End"],t.SELECT_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Tab"],t.COMBO_BOX_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter"],t.BREAKPOINTS={sm:640,md:768,lg:1024,xl:1280,"2xl":1536}},961:(e,t)=>{ | ||
/* | ||
* HSBasePlugin | ||
* @version: 2.1.0 | ||
* @author: HTMLStream | ||
* @license: Licensed under MIT (https://preline.co/docs/license.html) | ||
* Copyright 2023 HTMLStream | ||
* @version: 2.4.0 | ||
* @author: Preline Labs Ltd. | ||
* @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html) | ||
* Copyright 2024 Preline Labs Ltd. | ||
*/ | ||
Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t,o){this.el=e,this.options=t,this.events=o,this.el=e,this.options=t,this.events={}}return e.prototype.createCollection=function(e,t){var o;e.push({id:(null===(o=null==t?void 0:t.el)||void 0===o?void 0:o.id)||e.length+1,element:t})},e.prototype.fireEvent=function(e,t){if(void 0===t&&(t=null),this.events.hasOwnProperty(e))return this.events[e](t)},e.prototype.on=function(e,t){this.events[e]=t},e}();t.default=o},770:function(e,t,o){ | ||
Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t,o){this.el=e,this.options=t,this.events=o,this.el=e,this.options=t,this.events={}}return e.prototype.createCollection=function(e,t){var o;e.push({id:(null===(o=null==t?void 0:t.el)||void 0===o?void 0:o.id)||e.length+1,element:t})},e.prototype.fireEvent=function(e,t){if(void 0===t&&(t=null),this.events.hasOwnProperty(e))return this.events[e](t)},e.prototype.on=function(e,t){this.events[e]=t},e}();t.default=o},850:function(e,t,o){ | ||
/* | ||
* HSOverlay | ||
* @version: 2.1.0 | ||
* @author: HTMLStream | ||
* @license: Licensed under MIT (https://preline.co/docs/license.html) | ||
* Copyright 2023 HTMLStream | ||
* @version: 2.4.0 | ||
* @author: Preline Labs Ltd. | ||
* @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html) | ||
* Copyright 2024 Preline Labs Ltd. | ||
*/ | ||
var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)},l=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=o(969),s=o(190),c=function(e){function t(t,o,n){var r,l,c,u=e.call(this,t,o,n)||this,d=t.getAttribute("data-hs-overlay-options"),y=d?JSON.parse(d):{},f=i(i({},y),o);if(u.hiddenClass=(null==f?void 0:f.hiddenClass)||"hidden",u.isClosePrev=null===(r=null==f?void 0:f.isClosePrev)||void 0===r||r,u.backdropClasses=null!==(l=null==f?void 0:f.backdropClasses)&&void 0!==l?l:"hs-overlay-backdrop transition duration fixed inset-0 bg-gray-900 bg-opacity-50 dark:bg-opacity-80 dark:bg-neutral-900",u.backdropExtraClasses=null!==(c=null==f?void 0:f.backdropExtraClasses)&&void 0!==c?c:"",u.openNextOverlay=!1,u.autoHide=null,u.overlayId=u.el.getAttribute("data-hs-overlay"),u.overlay=document.querySelector(u.overlayId),u.overlay){u.isCloseWhenClickInside=(0,a.stringToBoolean)((0,a.getClassProperty)(u.overlay,"--close-when-click-inside","false")||"false"),u.isTabAccessibilityLimited=(0,a.stringToBoolean)((0,a.getClassProperty)(u.overlay,"--tab-accessibility-limited","true")||"true"),u.isLayoutAffect=(0,a.stringToBoolean)((0,a.getClassProperty)(u.overlay,"--is-layout-affect","false")||"false"),u.hasAutofocus=(0,a.stringToBoolean)((0,a.getClassProperty)(u.overlay,"--has-autofocus","true")||"true"),u.hasAbilityToCloseOnBackdropClick=(0,a.stringToBoolean)(u.overlay.getAttribute("data-hs-overlay-keyboard")||"true");var v=(0,a.getClassProperty)(u.overlay,"--auto-close");u.autoClose=!isNaN(+v)&&isFinite(+v)?+v:s.BREAKPOINTS[v]||null;var p=(0,a.getClassProperty)(u.overlay,"--opened");u.openedBreakpoint=(!isNaN(+p)&&isFinite(+p)?+p:s.BREAKPOINTS[p])||null}return u.overlay&&u.init(),u}return r(t,e),t.prototype.init=function(){var e=this;if(this.createCollection(window.$hsOverlayCollection,this),this.isLayoutAffect&&this.openedBreakpoint){var o=t.getInstance(this.el,!0);t.setOpened(this.openedBreakpoint,o)}this.el.addEventListener("click",(function(){e.overlay.classList.contains("opened")?e.close():e.open()})),this.overlay.addEventListener("click",(function(t){t.target.id&&"#".concat(t.target.id)===e.overlayId&&e.isCloseWhenClickInside&&e.hasAbilityToCloseOnBackdropClick&&e.close()}))},t.prototype.hideAuto=function(){var e=this,t=parseInt((0,a.getClassProperty)(this.overlay,"--auto-hide","0"));t&&(this.autoHide=setTimeout((function(){e.close()}),t))},t.prototype.checkTimer=function(){this.autoHide&&(clearTimeout(this.autoHide),this.autoHide=null)},t.prototype.buildBackdrop=function(){var e=this,t=this.overlay.classList.value.split(" "),o=parseInt(window.getComputedStyle(this.overlay).getPropertyValue("z-index")),n=this.overlay.getAttribute("data-hs-overlay-backdrop-container")||!1,r=document.createElement("div"),i="".concat(this.backdropClasses," ").concat(this.backdropExtraClasses),l="static"!==(0,a.getClassProperty)(this.overlay,"--overlay-backdrop","true"),s="false"===(0,a.getClassProperty)(this.overlay,"--overlay-backdrop","true");r.id="".concat(this.overlay.id,"-backdrop"),"style"in r&&(r.style.zIndex="".concat(o-1));for(var c=0,u=t;c<u.length;c++){var d=u[c];(d.startsWith("hs-overlay-backdrop-open:")||d.includes(":hs-overlay-backdrop-open:"))&&(i+=" ".concat(d))}s||(n&&((r=document.querySelector(n).cloneNode(!0)).classList.remove("hidden"),i="".concat(r.classList.toString()),r.classList.value=""),l&&r.addEventListener("click",(function(){return e.close()}),!0),r.setAttribute("data-hs-overlay-backdrop-template",""),document.body.appendChild(r),setTimeout((function(){r.classList.value=i})))},t.prototype.destroyBackdrop=function(){var e=document.querySelector("#".concat(this.overlay.id,"-backdrop"));e&&(this.openNextOverlay&&(e.style.transitionDuration="".concat(1.8*parseFloat(window.getComputedStyle(e).transitionDuration.replace(/[^\d.-]/g,"")),"s")),e.classList.add("opacity-0"),(0,a.afterTransition)(e,(function(){e.remove()})))},t.prototype.focusElement=function(){var e=this.overlay.querySelector("[autofocus]");if(!e)return!1;e.focus()},t.prototype.open=function(){var e=this;if(!this.overlay)return!1;var t=document.querySelectorAll(".hs-overlay.open"),o=window.$hsOverlayCollection.find((function(e){return Array.from(t).includes(e.element.overlay)&&!e.element.isLayoutAffect})),n="true"!==(0,a.getClassProperty)(this.overlay,"--body-scroll","false");if(this.isClosePrev&&o)return this.openNextOverlay=!0,o.element.close().then((function(){e.open(),e.openNextOverlay=!1}));n&&(document.body.style.overflow="hidden"),this.buildBackdrop(),this.checkTimer(),this.hideAuto(),this.overlay.classList.remove(this.hiddenClass),this.overlay.setAttribute("aria-overlay","true"),this.overlay.setAttribute("tabindex","-1"),setTimeout((function(){if(e.overlay.classList.contains("opened"))return!1;e.overlay.classList.add("open","opened"),e.isLayoutAffect&&document.body.classList.add("hs-overlay-body-open"),e.fireEvent("open",e.el),(0,a.dispatch)("open.hs.overlay",e.el,e.el),e.hasAutofocus&&e.focusElement()}),50)},t.prototype.close=function(e){var t=this;void 0===e&&(e=!1),this.isLayoutAffect&&document.body.classList.remove("hs-overlay-body-open");var o=function(e){if(t.overlay.classList.contains("open"))return!1;t.overlay.classList.add(t.hiddenClass),t.destroyBackdrop(),t.fireEvent("close",t.el),(0,a.dispatch)("close.hs.overlay",t.el,t.el),document.querySelector(".hs-overlay.opened")||(document.body.style.overflow=""),e(t.overlay)};return new Promise((function(n){if(!t.overlay)return!1;t.overlay.classList.remove("open","opened"),t.overlay.removeAttribute("aria-overlay"),t.overlay.removeAttribute("tabindex"),e?o(n):(0,a.afterTransition)(t.overlay,(function(){o(n)}))}))},t.getInstance=function(e,t){var o=window.$hsOverlayCollection.find((function(t){return t.element.el===("string"==typeof e?document.querySelector(e):e)||t.element.overlay===("string"==typeof e?document.querySelector(e):e)}));return o?t?o:o.element.el:null},t.autoInit=function(){window.$hsOverlayCollection||(window.$hsOverlayCollection=[]),document.querySelectorAll("[data-hs-overlay]:not(.--prevent-on-load-init)").forEach((function(e){window.$hsOverlayCollection.find((function(t){var o;return(null===(o=null==t?void 0:t.element)||void 0===o?void 0:o.el)===e}))||new t(e)})),window.$hsOverlayCollection&&document.addEventListener("keydown",(function(e){return t.accessibility(e)}))},t.open=function(e){var t=window.$hsOverlayCollection.find((function(t){return t.element.el===("string"==typeof e?document.querySelector(e):e)||t.element.overlay===("string"==typeof e?document.querySelector(e):e)}));t&&t.element.overlay.classList.contains(t.element.hiddenClass)&&t.element.open()},t.close=function(e){var t=window.$hsOverlayCollection.find((function(t){return t.element.el===("string"==typeof e?document.querySelector(e):e)||t.element.overlay===("string"==typeof e?document.querySelector(e):e)}));t&&!t.element.overlay.classList.contains(t.element.hiddenClass)&&t.element.close()},t.setOpened=function(e,t){document.body.clientWidth>=e?(document.body.classList.add("hs-overlay-body-open"),t.element.overlay.classList.add("opened")):t.element.close(!0)},t.accessibility=function(e){var t,o,n=window.$hsOverlayCollection.filter((function(e){return e.element.overlay.classList.contains("open")})),r=n[n.length-1],i=null===(o=null===(t=null==r?void 0:r.element)||void 0===t?void 0:t.overlay)||void 0===o?void 0:o.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),l=[];(null==i?void 0:i.length)&&i.forEach((function(e){(0,a.isParentOrElementHidden)(e)||l.push(e)}));var s=r&&!e.metaKey;if(s&&!r.element.isTabAccessibilityLimited&&"Tab"===e.code)return!1;s&&l.length&&"Tab"===e.code&&(e.preventDefault(),this.onTab(r,l)),s&&"Escape"===e.code&&(e.preventDefault(),this.onEscape(r))},t.onEscape=function(e){e&&e.element.hasAbilityToCloseOnBackdropClick&&e.element.close()},t.onTab=function(e,t){if(!t.length)return!1;var o=e.element.overlay.querySelector(":focus"),n=Array.from(t).indexOf(o);n>-1?t[(n+1)%t.length].focus():t[0].focus()},t.on=function(e,t,o){var n=window.$hsOverlayCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)||e.element.overlay===("string"==typeof t?document.querySelector(t):t)}));n&&(n.element.events[e]=o)},t}(l(o(737)).default);window.addEventListener("load",(function(){c.autoInit()})),window.addEventListener("resize",(function(){!function(){if(!window.$hsOverlayCollection.length||!window.$hsOverlayCollection.find((function(e){return e.element.autoClose})))return!1;window.$hsOverlayCollection.filter((function(e){return e.element.autoClose})).forEach((function(e){document.body.clientWidth>=e.element.autoClose&&e.element.close(!0)}))}(),function(){if(!window.$hsOverlayCollection.length||!window.$hsOverlayCollection.find((function(e){return e.element.openedBreakpoint})))return!1;window.$hsOverlayCollection.filter((function(e){return e.element.openedBreakpoint})).forEach((function(e){c.setOpened(e.element.openedBreakpoint,e)}))}()})),"undefined"!=typeof window&&(window.HSOverlay=c),t.default=c},969:function(e,t){var o=this;Object.defineProperty(t,"__esModule",{value:!0}),t.menuSearchHistory=t.classToClassList=t.htmlToElement=t.afterTransition=t.dispatch=t.debounce=t.isFormElement=t.isParentOrElementHidden=t.isEnoughSpace=t.isIpadOS=t.isIOS=t.getClassPropertyAlt=t.getClassProperty=t.stringToBoolean=void 0;t.stringToBoolean=function(e){return"true"===e};t.getClassProperty=function(e,t,o){return void 0===o&&(o=""),(window.getComputedStyle(e).getPropertyValue(t)||o).replace(" ","")};t.getClassPropertyAlt=function(e,t,o){void 0===o&&(o="");var n="";return e.classList.forEach((function(e){e.includes(t)&&(n=e)})),n.match(/:(.*)]/)?n.match(/:(.*)]/)[1]:o};t.isIOS=function(){return!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};t.isIpadOS=function(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};t.isEnoughSpace=function(e,t,o,n,r){void 0===o&&(o="auto"),void 0===n&&(n=10),void 0===r&&(r=null);var i=t.getBoundingClientRect(),l=r?r.getBoundingClientRect():null,a=window.innerHeight,s=l?i.top-l.top:i.top,c=(r?l.bottom:a)-i.bottom,u=e.clientHeight+n;return"bottom"===o?c>=u:"top"===o?s>=u:s>=u||c>=u};t.isFormElement=function(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement};var n=function(e){return!!e&&("none"===window.getComputedStyle(e).display||n(e.parentElement))};t.isParentOrElementHidden=n;t.debounce=function(e,t){var n;return void 0===t&&(t=200),function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];clearTimeout(n),n=setTimeout((function(){e.apply(o,r)}),t)}};t.dispatch=function(e,t,o){void 0===o&&(o=null);var n=new CustomEvent(e,{detail:{payload:o},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(n)};t.afterTransition=function(e,t){var o=function(){t(),e.removeEventListener("transitionend",o,!0)};window.getComputedStyle(e,null).getPropertyValue("transition")!==(navigator.userAgent.includes("Firefox")?"all":"all 0s ease 0s")?e.addEventListener("transitionend",o,!0):t()};t.htmlToElement=function(e){var t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild};t.classToClassList=function(e,t,o,n){void 0===o&&(o=" "),void 0===n&&(n="add"),e.split(o).forEach((function(e){return"add"===n?t.classList.add(e):t.classList.remove(e)}))};t.menuSearchHistory={historyIndex:-1,addHistory:function(e){this.historyIndex=e},existsInHistory:function(e){return e>this.historyIndex},clearHistory:function(){this.historyIndex=-1}}}},t={};var o=function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,o),i.exports}(770);return o})())); | ||
var n,r=this&&this.__extends||(n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])},n(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function o(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(o.prototype=t.prototype,new o)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)},l=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var a=o(292),s=o(223),c=function(e){function t(t,o,n){var r,l,c,d,u=e.call(this,t,o,n)||this,y=t.getAttribute("data-hs-overlay-options"),v=y?JSON.parse(y):{},p=i(i({},v),o);if(u.hiddenClass=(null==p?void 0:p.hiddenClass)||"hidden",u.emulateScrollbarSpace=(null==p?void 0:p.emulateScrollbarSpace)||!1,u.isClosePrev=null===(r=null==p?void 0:p.isClosePrev)||void 0===r||r,u.backdropClasses=null!==(l=null==p?void 0:p.backdropClasses)&&void 0!==l?l:"hs-overlay-backdrop transition duration fixed inset-0 bg-gray-900 bg-opacity-50 dark:bg-opacity-80 dark:bg-neutral-900",u.backdropExtraClasses=null!==(c=null==p?void 0:p.backdropExtraClasses)&&void 0!==c?c:"",u.openNextOverlay=!1,u.autoHide=null,u.overlayId=u.el.getAttribute("data-hs-overlay"),u.overlay=document.querySelector(u.overlayId),u.overlay){u.isCloseWhenClickInside=(0,a.stringToBoolean)((0,a.getClassProperty)(u.overlay,"--close-when-click-inside","false")||"false"),u.isTabAccessibilityLimited=(0,a.stringToBoolean)((0,a.getClassProperty)(u.overlay,"--tab-accessibility-limited","true")||"true"),u.isLayoutAffect=(0,a.stringToBoolean)((0,a.getClassProperty)(u.overlay,"--is-layout-affect","false")||"false"),u.hasAutofocus=(0,a.stringToBoolean)((0,a.getClassProperty)(u.overlay,"--has-autofocus","true")||"true"),u.hasAbilityToCloseOnBackdropClick=(0,a.stringToBoolean)(u.overlay.getAttribute("data-hs-overlay-keyboard")||"true");var f=(0,a.getClassProperty)(u.overlay,"--auto-close");u.autoClose=!isNaN(+f)&&isFinite(+f)?+f:s.BREAKPOINTS[f]||null;var h=(0,a.getClassProperty)(u.overlay,"--opened");u.openedBreakpoint=(!isNaN(+h)&&isFinite(+h)?+h:s.BREAKPOINTS[h])||null}return u.animationTarget=(null===(d=null==u?void 0:u.overlay)||void 0===d?void 0:d.querySelector(".hs-overlay-animation-target"))||u.overlay,u.overlay&&u.init(),u}return r(t,e),t.prototype.init=function(){var e,o=this;if(this.createCollection(window.$hsOverlayCollection,this),this.isLayoutAffect&&this.openedBreakpoint){var n=t.getInstance(this.el,!0);t.setOpened(this.openedBreakpoint,n)}(null===(e=null==this?void 0:this.el)||void 0===e?void 0:e.ariaExpanded)&&(this.overlay.classList.contains("opened")?this.el.ariaExpanded="true":this.el.ariaExpanded="false"),this.el.addEventListener("click",(function(){o.overlay.classList.contains("opened")?o.close():o.open()})),this.overlay.addEventListener("click",(function(e){e.target.id&&"#".concat(e.target.id)===o.overlayId&&o.isCloseWhenClickInside&&o.hasAbilityToCloseOnBackdropClick&&o.close()}))},t.prototype.hideAuto=function(){var e=this,t=parseInt((0,a.getClassProperty)(this.overlay,"--auto-hide","0"));t&&(this.autoHide=setTimeout((function(){e.close()}),t))},t.prototype.checkTimer=function(){this.autoHide&&(clearTimeout(this.autoHide),this.autoHide=null)},t.prototype.buildBackdrop=function(){var e=this,t=this.overlay.classList.value.split(" "),o=parseInt(window.getComputedStyle(this.overlay).getPropertyValue("z-index")),n=this.overlay.getAttribute("data-hs-overlay-backdrop-container")||!1,r=document.createElement("div"),i="".concat(this.backdropClasses," ").concat(this.backdropExtraClasses),l="static"!==(0,a.getClassProperty)(this.overlay,"--overlay-backdrop","true"),s="false"===(0,a.getClassProperty)(this.overlay,"--overlay-backdrop","true");r.id="".concat(this.overlay.id,"-backdrop"),"style"in r&&(r.style.zIndex="".concat(o-1));for(var c=0,d=t;c<d.length;c++){var u=d[c];(u.startsWith("hs-overlay-backdrop-open:")||u.includes(":hs-overlay-backdrop-open:"))&&(i+=" ".concat(u))}s||(n&&((r=document.querySelector(n).cloneNode(!0)).classList.remove("hidden"),i="".concat(r.classList.toString()),r.classList.value=""),l&&r.addEventListener("click",(function(){return e.close()}),!0),r.setAttribute("data-hs-overlay-backdrop-template",""),document.body.appendChild(r),setTimeout((function(){r.classList.value=i})))},t.prototype.destroyBackdrop=function(){var e=document.querySelector("#".concat(this.overlay.id,"-backdrop"));e&&(this.openNextOverlay&&(e.style.transitionDuration="".concat(1.8*parseFloat(window.getComputedStyle(e).transitionDuration.replace(/[^\d.-]/g,"")),"s")),e.classList.add("opacity-0"),(0,a.afterTransition)(e,(function(){e.remove()})))},t.prototype.focusElement=function(){var e=this.overlay.querySelector("[autofocus]");if(!e)return!1;e.focus()},t.prototype.getScrollbarSize=function(){var e=document.createElement("div");e.style.overflow="scroll",e.style.width="100px",e.style.height="100px",document.body.appendChild(e);var t=e.offsetWidth-e.clientWidth;return document.body.removeChild(e),t},t.prototype.open=function(){var e=this;if(!this.overlay)return!1;var t=document.querySelectorAll(".hs-overlay.open"),o=window.$hsOverlayCollection.find((function(e){return Array.from(t).includes(e.element.overlay)&&!e.element.isLayoutAffect})),n=document.querySelectorAll('[data-hs-overlay="#'.concat(this.overlay.id,'"]')),r="true"!==(0,a.getClassProperty)(this.overlay,"--body-scroll","false");if(this.isClosePrev&&o)return this.openNextOverlay=!0,o.element.close().then((function(){e.open(),e.openNextOverlay=!1}));r&&(document.body.style.overflow="hidden",this.emulateScrollbarSpace&&(document.body.style.paddingRight="".concat(this.getScrollbarSize(),"px"))),this.buildBackdrop(),this.checkTimer(),this.hideAuto(),n.forEach((function(e){e.ariaExpanded&&(e.ariaExpanded="true")})),this.overlay.classList.remove(this.hiddenClass),this.overlay.setAttribute("aria-overlay","true"),this.overlay.setAttribute("tabindex","-1"),setTimeout((function(){if(e.overlay.classList.contains("opened"))return!1;e.overlay.classList.add("open","opened"),e.isLayoutAffect&&document.body.classList.add("hs-overlay-body-open"),e.fireEvent("open",e.el),(0,a.dispatch)("open.hs.overlay",e.el,e.el),e.hasAutofocus&&e.focusElement()}),50)},t.prototype.close=function(e){var t=this;void 0===e&&(e=!1),this.isLayoutAffect&&document.body.classList.remove("hs-overlay-body-open");var o=function(e){if(t.overlay.classList.contains("open"))return!1;document.querySelectorAll('[data-hs-overlay="#'.concat(t.overlay.id,'"]')).forEach((function(e){e.ariaExpanded&&(e.ariaExpanded="false")})),t.overlay.classList.add(t.hiddenClass),t.destroyBackdrop(),t.fireEvent("close",t.el),(0,a.dispatch)("close.hs.overlay",t.el,t.el),document.querySelector(".hs-overlay.opened")||(document.body.style.overflow="",t.emulateScrollbarSpace&&(document.body.style.paddingRight="")),e(t.overlay)};return new Promise((function(n){if(!t.overlay)return!1;t.overlay.classList.remove("open","opened"),t.overlay.removeAttribute("aria-overlay"),t.overlay.removeAttribute("tabindex"),e?o(n):(0,a.afterTransition)(t.animationTarget,(function(){return o(n)}))}))},t.getInstance=function(e,t){var o=window.$hsOverlayCollection.find((function(t){return t.element.el===("string"==typeof e?document.querySelector(e):e)||t.element.overlay===("string"==typeof e?document.querySelector(e):e)}));return o?t?o:o.element.el:null},t.autoInit=function(){window.$hsOverlayCollection||(window.$hsOverlayCollection=[]),document.querySelectorAll("[data-hs-overlay]:not(.--prevent-on-load-init)").forEach((function(e){window.$hsOverlayCollection.find((function(t){var o;return(null===(o=null==t?void 0:t.element)||void 0===o?void 0:o.el)===e}))||new t(e)})),window.$hsOverlayCollection&&document.addEventListener("keydown",(function(e){return t.accessibility(e)}))},t.open=function(e){var t=window.$hsOverlayCollection.find((function(t){return t.element.el===("string"==typeof e?document.querySelector(e):e)||t.element.overlay===("string"==typeof e?document.querySelector(e):e)}));t&&t.element.overlay.classList.contains(t.element.hiddenClass)&&t.element.open()},t.close=function(e){var t=window.$hsOverlayCollection.find((function(t){return t.element.el===("string"==typeof e?document.querySelector(e):e)||t.element.overlay===("string"==typeof e?document.querySelector(e):e)}));t&&!t.element.overlay.classList.contains(t.element.hiddenClass)&&t.element.close()},t.setOpened=function(e,t){document.body.clientWidth>=e?(document.body.classList.add("hs-overlay-body-open"),t.element.overlay.classList.add("opened")):t.element.close(!0)},t.accessibility=function(e){var t,o,n=window.$hsOverlayCollection.filter((function(e){return e.element.overlay.classList.contains("open")})),r=n[n.length-1],i=null===(o=null===(t=null==r?void 0:r.element)||void 0===t?void 0:t.overlay)||void 0===o?void 0:o.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),l=[];(null==i?void 0:i.length)&&i.forEach((function(e){(0,a.isParentOrElementHidden)(e)||l.push(e)}));var s=r&&!e.metaKey;if(s&&!r.element.isTabAccessibilityLimited&&"Tab"===e.code)return!1;s&&l.length&&"Tab"===e.code&&(e.preventDefault(),this.onTab(r,l)),s&&"Escape"===e.code&&(e.preventDefault(),this.onEscape(r))},t.onEscape=function(e){e&&e.element.hasAbilityToCloseOnBackdropClick&&e.element.close()},t.onTab=function(e,t){if(!t.length)return!1;var o=e.element.overlay.querySelector(":focus"),n=Array.from(t).indexOf(o);n>-1?t[(n+1)%t.length].focus():t[0].focus()},t.on=function(e,t,o){var n=window.$hsOverlayCollection.find((function(e){return e.element.el===("string"==typeof t?document.querySelector(t):t)||e.element.overlay===("string"==typeof t?document.querySelector(t):t)}));n&&(n.element.events[e]=o)},t}(l(o(961)).default);window.addEventListener("load",(function(){c.autoInit()})),window.addEventListener("resize",(function(){!function(){if(!window.$hsOverlayCollection.length||!window.$hsOverlayCollection.find((function(e){return e.element.autoClose})))return!1;window.$hsOverlayCollection.filter((function(e){return e.element.autoClose})).forEach((function(e){document.body.clientWidth>=e.element.autoClose&&e.element.close(!0)}))}(),function(){if(!window.$hsOverlayCollection.length||!window.$hsOverlayCollection.find((function(e){return e.element.autoClose})))return!1;window.$hsOverlayCollection.filter((function(e){return e.element.autoClose})).forEach((function(e){document.body.clientWidth>=e.element.autoClose&&e.element.close(!0)}))}(),function(){if(!window.$hsOverlayCollection.length||!window.$hsOverlayCollection.find((function(e){return e.element.overlay.classList.contains("opened")})))return!1;window.$hsOverlayCollection.filter((function(e){return e.element.overlay.classList.contains("opened")})).forEach((function(e){var t=parseInt(window.getComputedStyle(e.element.overlay).getPropertyValue("z-index")),o=document.querySelector("#".concat(e.element.overlay.id,"-backdrop"));if(t===parseInt(window.getComputedStyle(o).getPropertyValue("z-index"))+1)return!1;"style"in o&&(o.style.zIndex="".concat(t-1)),document.body.classList.add("hs-overlay-body-open")}))}()})),"undefined"!=typeof window&&(window.HSOverlay=c),t.default=c},292:function(e,t){var o=this;Object.defineProperty(t,"__esModule",{value:!0}),t.menuSearchHistory=t.classToClassList=t.htmlToElement=t.afterTransition=t.dispatch=t.debounce=t.isFormElement=t.isParentOrElementHidden=t.isEnoughSpace=t.isIpadOS=t.isIOS=t.getZIndex=t.getClassPropertyAlt=t.getClassProperty=t.stringToBoolean=void 0,t.getHighestZIndex=function(e){var t=Number.NEGATIVE_INFINITY;return e.forEach((function(e){var o=n(e);"auto"!==o&&(o=parseInt(o,10))>t&&(t=o)})),t};t.stringToBoolean=function(e){return"true"===e};t.getClassProperty=function(e,t,o){return void 0===o&&(o=""),(window.getComputedStyle(e).getPropertyValue(t)||o).replace(" ","")};t.getClassPropertyAlt=function(e,t,o){void 0===o&&(o="");var n="";return e.classList.forEach((function(e){e.includes(t)&&(n=e)})),n.match(/:(.*)]/)?n.match(/:(.*)]/)[1]:o};var n=function(e){return window.getComputedStyle(e).getPropertyValue("z-index")};t.getZIndex=n;t.isIOS=function(){return!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};t.isIpadOS=function(){return navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform)};t.isEnoughSpace=function(e,t,o,n,r){void 0===o&&(o="auto"),void 0===n&&(n=10),void 0===r&&(r=null);var i=t.getBoundingClientRect(),l=r?r.getBoundingClientRect():null,a=window.innerHeight,s=l?i.top-l.top:i.top,c=(r?l.bottom:a)-i.bottom,d=e.clientHeight+n;return"bottom"===o?c>=d:"top"===o?s>=d:s>=d||c>=d};t.isFormElement=function(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement};var r=function(e){return!!e&&("none"===window.getComputedStyle(e).display||r(e.parentElement))};t.isParentOrElementHidden=r;t.debounce=function(e,t){var n;return void 0===t&&(t=200),function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];clearTimeout(n),n=setTimeout((function(){e.apply(o,r)}),t)}};t.dispatch=function(e,t,o){void 0===o&&(o=null);var n=new CustomEvent(e,{detail:{payload:o},bubbles:!0,cancelable:!0,composed:!1});t.dispatchEvent(n)};t.afterTransition=function(e,t){var o=function(){t(),e.removeEventListener("transitionend",o,!0)};window.getComputedStyle(e,null).getPropertyValue("transition")!==(navigator.userAgent.includes("Firefox")?"all":"all 0s ease 0s")?e.addEventListener("transitionend",o,!0):t()};t.htmlToElement=function(e){var t=document.createElement("template");return e=e.trim(),t.innerHTML=e,t.content.firstChild};t.classToClassList=function(e,t,o,n){void 0===o&&(o=" "),void 0===n&&(n="add"),e.split(o).forEach((function(e){return"add"===n?t.classList.add(e):t.classList.remove(e)}))};t.menuSearchHistory={historyIndex:-1,addHistory:function(e){this.historyIndex=e},existsInHistory:function(e){return e>this.historyIndex},clearHistory:function(){this.historyIndex=-1}}}},t={};var o=function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n].call(i.exports,i,i.exports,o),i.exports}(850);return o})())); |
{ | ||
"name": "@preline/overlay", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"description": "Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
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
23284
94
1
80
1