@preline/overlay
Advanced tools
Comparing version 2.0.2 to 2.1.0
export interface IOverlayOptions { | ||
hiddenClass?: string | null; | ||
isClosePrev?: boolean; | ||
backdropClasses?: string | null; | ||
} | ||
export interface IOverlay { | ||
options?: IOverlayOptions; | ||
open(): void; | ||
close(): void; | ||
} | ||
export interface ICollectionItem<T> { | ||
id: string | number; | ||
element: T; | ||
} | ||
export interface IBasePlugin<O, E> { | ||
@@ -30,2 +17,16 @@ el: E; | ||
} | ||
export interface ICollectionItem<T> { | ||
id: string | number; | ||
element: T; | ||
} | ||
export interface IOverlayOptions { | ||
hiddenClass?: string | null; | ||
isClosePrev?: boolean; | ||
backdropClasses?: string | null; | ||
} | ||
export interface IOverlay { | ||
options?: IOverlayOptions; | ||
open(): void; | ||
close(): void; | ||
} | ||
declare class HSOverlay extends HSBasePlugin<{}> implements IOverlay { | ||
@@ -39,6 +40,9 @@ private readonly hiddenClass; | ||
overlay: HTMLElement | null; | ||
isCloseWhenClickInside: string; | ||
isTabAccessibilityLimited: string; | ||
hasAutofocus: string; | ||
hasAbilityToCloseOnBackdropClick: string; | ||
isCloseWhenClickInside: boolean; | ||
isTabAccessibilityLimited: boolean; | ||
isLayoutAffect: boolean; | ||
hasAutofocus: boolean; | ||
hasAbilityToCloseOnBackdropClick: boolean; | ||
openedBreakpoint: number | null; | ||
autoClose: number | null; | ||
constructor(el: HTMLElement, options?: IOverlayOptions, events?: {}); | ||
@@ -52,3 +56,3 @@ private init; | ||
open(): false | Promise<void>; | ||
close(): Promise<unknown>; | ||
close(forceClose?: boolean): Promise<unknown>; | ||
static getInstance(target: HTMLElement, isInstance?: boolean): HTMLElement | ICollectionItem<HSOverlay>; | ||
@@ -58,2 +62,3 @@ static autoInit(): void; | ||
static close(target: HTMLElement): void; | ||
static setOpened(breakpoint: number, el: ICollectionItem<HSOverlay>): void; | ||
static accessibility(evt: KeyboardEvent): boolean; | ||
@@ -60,0 +65,0 @@ static onEscape(target: ICollectionItem<HSOverlay>): void; |
@@ -1,5 +0,5 @@ | ||
!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={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={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)=>{ | ||
/* | ||
* HSBasePlugin | ||
* @version: 2.0.3 | ||
* @version: 2.1.0 | ||
* @author: HTMLStream | ||
@@ -12,3 +12,3 @@ * @license: Licensed under MIT (https://preline.co/docs/license.html) | ||
* HSOverlay | ||
* @version: 2.0.3 | ||
* @version: 2.1.0 | ||
* @author: HTMLStream | ||
@@ -18,2 +18,2 @@ * @license: Licensed under MIT (https://preline.co/docs/license.html) | ||
*/ | ||
var n,i=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)}),r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},r.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0});var l=o(969),s=function(e){function t(t,o,n){var i,s,a=e.call(this,t,o,n)||this,c=t.getAttribute("data-hs-overlay-options"),u=c?JSON.parse(c):{},d=r(r({},u),o);return a.hiddenClass=(null==d?void 0:d.hiddenClass)||"hidden",a.isClosePrev=null===(i=null==d?void 0:d.isClosePrev)||void 0===i||i,a.backdropClasses=null!==(s=null==d?void 0:d.backdropClasses)&&void 0!==s?s:"transition duration fixed inset-0 bg-gray-900 bg-opacity-50 dark:bg-opacity-80 hs-overlay-backdrop",a.openNextOverlay=!1,a.autoHide=null,a.overlayId=a.el.getAttribute("data-hs-overlay"),a.overlay=document.querySelector(a.overlayId),a.overlay&&(a.isCloseWhenClickInside=(0,l.getClassProperty)(a.overlay,"--close-when-click-inside","false")||"false",a.isTabAccessibilityLimited=(0,l.getClassProperty)(a.overlay,"--tab-accessibility-limited","true")||"true",a.hasAutofocus=(0,l.getClassProperty)(a.overlay,"--has-autofocus","true")||"true",a.hasAbilityToCloseOnBackdropClick=a.overlay.getAttribute("data-hs-overlay-keyboard")||"true"),a.overlay&&a.init(),a}return i(t,e),t.prototype.init=function(){var e=this;this.createCollection(window.$hsOverlayCollection,this),this.el.addEventListener("click",(function(){e.overlay.classList.contains(e.hiddenClass)?e.open():e.close()})),this.overlay.addEventListener("click",(function(t){t.target.id&&"#".concat(t.target.id)===e.overlayId&&"true"===e.isCloseWhenClickInside&&"true"===e.hasAbilityToCloseOnBackdropClick&&e.close()}))},t.prototype.hideAuto=function(){var e=this,t=parseInt((0,l.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,i=document.createElement("div"),r=this.backdropClasses,s="static"!==(0,l.getClassProperty)(this.overlay,"--overlay-backdrop","true"),a="false"===(0,l.getClassProperty)(this.overlay,"--overlay-backdrop","true");i.id="".concat(this.overlay.id,"-backdrop"),"style"in i&&(i.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:"))&&(r+=" ".concat(d))}a||(n&&((i=document.querySelector(n).cloneNode(!0)).classList.remove("hidden"),r="".concat(i.classList.toString()),i.classList.value=""),s&&i.addEventListener("click",(function(){return e.close()}),!0),i.setAttribute("data-hs-overlay-backdrop-template",""),document.body.appendChild(i),setTimeout((function(){i.classList.value=r})))},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,l.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=window.$hsOverlayCollection.find((function(e){return e.element.overlay===document.querySelector(".hs-overlay.open")})),o="true"!==(0,l.getClassProperty)(this.overlay,"--body-scroll","false");if(this.isClosePrev&&t)return this.openNextOverlay=!0,t.element.close().then((function(){e.open(),e.openNextOverlay=!1}));o&&(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(e.hiddenClass))return!1;e.overlay.classList.add("open"),e.fireEvent("open",e.el),(0,l.dispatch)("open.hs.overlay",e.el,e.el),"true"===e.hasAutofocus&&e.focusElement()}),50)},t.prototype.close=function(){var e=this;return new Promise((function(t){if(!e.overlay)return!1;e.overlay.classList.remove("open"),e.overlay.removeAttribute("aria-overlay"),e.overlay.removeAttribute("tabindex"),(0,l.afterTransition)(e.overlay,(function(){if(e.overlay.classList.contains("open"))return!1;e.overlay.classList.add(e.hiddenClass),e.destroyBackdrop(),e.fireEvent("close",e.el),(0,l.dispatch)("close.hs.overlay",e.el,e.el),document.body.style.overflow="",t(e.overlay)}))}))},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.accessibility=function(e){var t,o,n=window.$hsOverlayCollection.filter((function(e){return e.element.overlay.classList.contains("open")})),i=n[n.length-1],r=null===(o=null===(t=null==i?void 0:i.element)||void 0===t?void 0:t.overlay)||void 0===o?void 0:o.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),s=[];(null==r?void 0:r.length)&&r.forEach((function(e){(0,l.isParentOrElementHidden)(e)||s.push(e)}));var a=i&&!e.metaKey;if(a&&"false"===i.element.isTabAccessibilityLimited&&"Tab"===e.code)return!1;a&&s.length&&"Tab"===e.code&&(e.preventDefault(),this.onTab(i,s)),a&&"Escape"===e.code&&(e.preventDefault(),this.onEscape(i))},t.onEscape=function(e){e&&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}(o(737).default);window.addEventListener("load",(function(){s.autoInit()})),"undefined"!=typeof window&&(window.HSOverlay=s),t.default=s},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=void 0;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,i){void 0===o&&(o="auto"),void 0===n&&(n=10),void 0===i&&(i=null);var r=t.getBoundingClientRect(),l=i?i.getBoundingClientRect():null,s=window.innerHeight,a=l?r.top-l.top:r.top,c=(i?l.bottom:s)-r.bottom,u=e.clientHeight+n;return"bottom"===o?c>=u:"top"===o?a>=u:a>=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 i=[],r=0;r<arguments.length;r++)i[r]=arguments[r];clearTimeout(n),n=setTimeout((function(){e.apply(o,i)}),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)};"all 0s ease 0s"!==window.getComputedStyle(e,null).getPropertyValue("transition")?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){void 0===o&&(o=" "),e.split(o).forEach((function(e){return t.classList.add(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 i=t[n];if(void 0!==i)return i.exports;var r=t[n]={exports:{}};return e[n].call(r.exports,r,r.exports,o),r.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)};Object.defineProperty(t,"__esModule",{value:!0});var l=o(969),a=o(190),s=function(e){function t(t,o,n){var r,s,c=e.call(this,t,o,n)||this,u=t.getAttribute("data-hs-overlay-options"),d=u?JSON.parse(u):{},y=i(i({},d),o);if(c.hiddenClass=(null==y?void 0:y.hiddenClass)||"hidden",c.isClosePrev=null===(r=null==y?void 0:y.isClosePrev)||void 0===r||r,c.backdropClasses=null!==(s=null==y?void 0:y.backdropClasses)&&void 0!==s?s:"transition duration fixed inset-0 bg-gray-900 bg-opacity-50 dark:bg-opacity-80 hs-overlay-backdrop",c.openNextOverlay=!1,c.autoHide=null,c.overlayId=c.el.getAttribute("data-hs-overlay"),c.overlay=document.querySelector(c.overlayId),c.overlay){c.isCloseWhenClickInside=(0,l.stringToBoolean)((0,l.getClassProperty)(c.overlay,"--close-when-click-inside","false")||"false"),c.isTabAccessibilityLimited=(0,l.stringToBoolean)((0,l.getClassProperty)(c.overlay,"--tab-accessibility-limited","true")||"true"),c.isLayoutAffect=(0,l.stringToBoolean)((0,l.getClassProperty)(c.overlay,"--is-layout-affect","false")||"false"),c.hasAutofocus=(0,l.stringToBoolean)((0,l.getClassProperty)(c.overlay,"--has-autofocus","true")||"true"),c.hasAbilityToCloseOnBackdropClick=(0,l.stringToBoolean)(c.overlay.getAttribute("data-hs-overlay-keyboard")||"true");var v=(0,l.getClassProperty)(c.overlay,"--auto-close");c.autoClose=!isNaN(+v)&&isFinite(+v)?+v:a.BREAKPOINTS[v]||null;var f=(0,l.getClassProperty)(c.overlay,"--opened");c.openedBreakpoint=(!isNaN(+f)&&isFinite(+f)?+f:a.BREAKPOINTS[f])||null}return c.overlay&&c.init(),c}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,l.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=this.backdropClasses,a="static"!==(0,l.getClassProperty)(this.overlay,"--overlay-backdrop","true"),s="false"===(0,l.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=""),a&&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,l.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=window.$hsOverlayCollection.find((function(e){return e.element.overlay===document.querySelector(".hs-overlay.open")&&!e.element.isLayoutAffect})),o="true"!==(0,l.getClassProperty)(this.overlay,"--body-scroll","false");if(this.isClosePrev&&t)return this.openNextOverlay=!0,t.element.close().then((function(){e.open(),e.openNextOverlay=!1}));o&&(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,l.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,l.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,l.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"])'),a=[];(null==i?void 0:i.length)&&i.forEach((function(e){(0,l.isParentOrElementHidden)(e)||a.push(e)}));var s=r&&!e.metaKey;if(s&&!r.element.isTabAccessibilityLimited&&"Tab"===e.code)return!1;s&&a.length&&"Tab"===e.code&&(e.preventDefault(),this.onTab(r,a)),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}(o(737).default);window.addEventListener("load",(function(){s.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){s.setOpened(e.element.openedBreakpoint,e)}))}()})),"undefined"!=typeof window&&(window.HSOverlay=s),t.default=s},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})())); |
{ | ||
"name": "@preline/overlay", | ||
"version": "2.0.2", | ||
"version": "2.1.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", |
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
18451
88
0