@preline/select 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var i in s)("object"==typeof exports?exports:t)[i]=s[i]}}(self,(()=>(()=>{"use strict";var t={223:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.BREAKPOINTS=e.COMBO_BOX_ACCESSIBILITY_KEY_SET=e.SELECT_ACCESSIBILITY_KEY_SET=e.TABS_ACCESSIBILITY_KEY_SET=e.OVERLAY_ACCESSIBILITY_KEY_SET=e.DROPDOWN_ACCESSIBILITY_KEY_SET=e.POSITIONS=void 0,e.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"},e.DROPDOWN_ACCESSIBILITY_KEY_SET=["Escape","ArrowUp","ArrowDown","ArrowRight","ArrowLeft","Home","End","Enter"],e.OVERLAY_ACCESSIBILITY_KEY_SET=["Escape","Tab"],e.TABS_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End"],e.SELECT_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter","Space","Tab"],e.COMBO_BOX_ACCESSIBILITY_KEY_SET=["ArrowUp","ArrowLeft","ArrowDown","ArrowRight","Home","End","Escape","Enter"],e.BREAKPOINTS={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536}},248:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(){this.components=[],this.currentlyOpenedComponents=[],this.activeComponent=null,this.initGlobalListeners()}initGlobalListeners(){document.addEventListener("keydown",(t=>this.handleGlobalKeydown(t))),document.addEventListener("focusin",(t=>this.handleGlobalFocusin(t)))}getActiveComponent(t){if(!t)return null;const e=this.components.filter((e=>e.wrapper.contains(t)||e.context&&e.context.contains(t)));if(0===e.length)return null;if(1===e.length)return e[0];let s=null,i=Number.MAX_SAFE_INTEGER;for(const o of e){let e=0,n=t;for(;n&&n!==o.wrapper&&n!==o.context;)e++,n=n.parentElement;e<i&&(i=e,s=o)}return s}handleGlobalFocusin(t){const e=t.target;this.activeComponent=this.getActiveComponent(e)}handleGlobalKeydown(t){const e=t.target;if(this.activeComponent=this.getActiveComponent(e),this.activeComponent)switch(t.key){case"Escape":if(this.activeComponent.isOpened)this.activeComponent.handlers.onEsc&&(this.activeComponent.handlers.onEsc(),t.preventDefault(),t.stopPropagation());else{const s=this.findClosestOpenParent(e);(null==s?void 0:s.handlers.onEsc)&&(s.handlers.onEsc(),t.preventDefault(),t.stopPropagation())}break;case"Enter":this.activeComponent.handlers.onEnter&&(this.activeComponent.handlers.onEnter(),t.preventDefault(),t.stopPropagation());break;case" ":case"Space":if("INPUT"===e.tagName||"TEXTAREA"===e.tagName)return;this.activeComponent.handlers.onSpace&&(this.activeComponent.handlers.onSpace(),t.preventDefault(),t.stopPropagation());break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":if(this.activeComponent.handlers.onArrow){if(t.metaKey||t.ctrlKey||t.altKey||t.shiftKey)return;this.activeComponent.handlers.onArrow(t),t.preventDefault(),t.stopPropagation()}break;case"Tab":if(!this.activeComponent.handlers.onTab)break;const s=t.shiftKey?this.activeComponent.handlers.onShiftTab:this.activeComponent.handlers.onTab;s&&s();break;case"Home":this.activeComponent.handlers.onHome&&(this.activeComponent.handlers.onHome(),t.preventDefault(),t.stopPropagation());break;case"End":this.activeComponent.handlers.onEnd&&(this.activeComponent.handlers.onEnd(),t.preventDefault(),t.stopPropagation());break;default:this.activeComponent.handlers.onFirstLetter&&1===t.key.length&&/^[a-zA-Z]$/.test(t.key)&&(this.activeComponent.handlers.onFirstLetter(t.key),t.preventDefault(),t.stopPropagation())}}findClosestOpenParent(t){let e=t.parentElement;for(;e;){const t=this.currentlyOpenedComponents.find((t=>t.wrapper===e&&t!==this.activeComponent));if(t)return t;e=e.parentElement}return null}registerComponent(t,e,s=!0,i="",o="",n){const l={wrapper:t,handlers:e,isOpened:s,name:i,selector:o,context:n,isRegistered:!0};return this.components.push(l),l}updateComponentState(t,e){t.isOpened=e,e?this.currentlyOpenedComponents.includes(t)||this.currentlyOpenedComponents.push(t):this.currentlyOpenedComponents=this.currentlyOpenedComponents.filter((e=>e!==t))}unregisterComponent(t){this.components=this.components.filter((e=>e!==t)),this.currentlyOpenedComponents=this.currentlyOpenedComponents.filter((e=>e!==t))}}},292:function(t,e){
|
|
2
2
|
/*
|
|
3
|
-
* @version: 3.2.
|
|
3
|
+
* @version: 3.2.1
|
|
4
4
|
* @author: Preline Labs Ltd.
|
|
5
5
|
* @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
|
|
6
6
|
* Copyright 2024 Preline Labs Ltd.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
Object.defineProperty(e,"__esModule",{value:!0}),e.stringToBoolean=e.menuSearchHistory=e.isScrollable=e.isParentOrElementHidden=e.isJson=e.isIpadOS=e.isIOS=e.isFormElement=e.isFocused=e.isEnoughSpace=e.isDirectChild=e.htmlToElement=e.getZIndex=e.getHighestZIndex=e.getClassPropertyAlt=e.getClassProperty=e.dispatch=e.debounce=e.classToClassList=e.afterTransition=void 0;e.stringToBoolean=t=>"true"===t;e.getClassProperty=(t,e,s="")=>(window.getComputedStyle(t).getPropertyValue(e)||s).replace(" ","");e.getClassPropertyAlt=(t,e,s="")=>{let i="";return t.classList.forEach((t=>{t.includes(e)&&(i=t)})),i.match(/:(.*)]/)?i.match(/:(.*)]/)[1]:s};const s=t=>window.getComputedStyle(t).getPropertyValue("z-index");e.getZIndex=s;e.getHighestZIndex=t=>{let e=Number.NEGATIVE_INFINITY;return t.forEach((t=>{let i=s(t);"auto"!==i&&(i=parseInt(i,10),i>e&&(e=i))})),e};e.isDirectChild=(t,e)=>{const s=t.children;for(let t=0;t<s.length;t++)if(s[t]===e)return!0;return!1};e.isEnoughSpace=(t,e,s="auto",i=10,o=null)=>{const n=e.getBoundingClientRect(),l=o?o.getBoundingClientRect():null,a=window.innerHeight,r=l?n.top-l.top:n.top,h=(o?l.bottom:a)-n.bottom,d=t.clientHeight+i;return"bottom"===s?h>=d:"top"===s?r>=d:r>=d||h>=d};e.isFocused=t=>document.activeElement===t;e.isFormElement=t=>t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement;e.isIOS=()=>!!/iPad|iPhone|iPod/.test(navigator.platform)||navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);e.isIpadOS=()=>navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&/MacIntel/.test(navigator.platform);e.isJson=t=>{if("string"!=typeof t)return!1;const e=t.trim()[0],s=t.trim().slice(-1);if("{"===e&&"}"===s||"["===e&&"]"===s)try{return JSON.parse(t),!0}catch(t){return!1}return!1};const i=t=>{if(!t)return!1;return"none"===window.getComputedStyle(t).display||i(t.parentElement)};e.isParentOrElementHidden=i;e.isScrollable=t=>{const e=window.getComputedStyle(t),s=e.overflowY,i=e.overflowX,o=("scroll"===s||"auto"===s)&&t.scrollHeight>t.clientHeight,n=("scroll"===i||"auto"===i)&&t.scrollWidth>t.clientWidth;return o||n};e.debounce=(t,e=200)=>{let s;return(...i)=>{clearTimeout(s),s=setTimeout((()=>{t.apply(this,i)}),e)}};e.dispatch=(t,e,s=null)=>{const i=new CustomEvent(t,{detail:{payload:s},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(i)};e.afterTransition=(t,e)=>{const s=()=>{e(),t.removeEventListener("transitionend",s,!0)},i=window.getComputedStyle(t),o=i.getPropertyValue("transition-duration");"none"!==i.getPropertyValue("transition-property")&&parseFloat(o)>0?t.addEventListener("transitionend",s,!0):e()};e.htmlToElement=t=>{const e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild};e.classToClassList=(t,e,s=" ",i="add")=>{t.split(s).forEach((t=>{t.trim()&&("add"===i?e.classList.add(t):e.classList.remove(t))}))};const o={historyIndex:-1,addHistory(t){this.historyIndex=t},existsInHistory(t){return t>this.historyIndex},clearHistory(){this.historyIndex=-1}};e.menuSearchHistory=o},442:function(t,e,s){
|
|
9
9
|
/*
|
|
10
10
|
* HSSelect
|
|
11
|
-
* @version: 3.2.
|
|
11
|
+
* @version: 3.2.1
|
|
12
12
|
* @author: Preline Labs Ltd.
|
|
13
13
|
* @license: Licensed under MIT and Preline UI Fair Use License (https://preline.co/docs/license.html)
|
|
14
14
|
* Copyright 2024 Preline Labs Ltd.
|
package/package.json
CHANGED