UNPKG

flyonui

Version:

The easiest, free and open-source Tailwind CSS component library with semantic classes.

16 lines 7.43 kB
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var o=e();for(var s in o)("object"==typeof exports?exports:t)[s]=o[s]}}(self,()=>(()=>{"use strict";var t={234:function(t,e,o){ /* * HSTogglePassword * @version: 3.2.2 * @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 s=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0});const i=o(806),n=s(o(287));class l extends n.default{constructor(t,e){super(t,e);const o=t.getAttribute("data-toggle-password"),s=o?JSON.parse(o):{},n=Object.assign(Object.assign({},s),e),l=[];if((null==n?void 0:n.target)&&"string"==typeof(null==n?void 0:n.target)){(null==n?void 0:n.target.split(",")).forEach(t=>{l.push(document.querySelector(t))})}else(null==n?void 0:n.target)&&"object"==typeof(null==n?void 0:n.target)?n.target.forEach(t=>l.push(document.querySelector(t))):n.target.forEach(t=>l.push(t));this.target=l,this.isShown=!!this.el.hasAttribute("type")&&this.el.checked,this.eventType=(0,i.isFormElement)(this.el)?"change":"click",this.isMultiple=this.target.length>1&&!!this.el.closest("[data-toggle-password-group]"),this.target&&this.init()}elementAction(){this.isShown?this.hide():this.show(),this.fireEvent("toggle",this.target),(0,i.dispatch)("toggle.toggle-select",this.el,this.target)}init(){this.createCollection(window.$hsTogglePasswordCollection,this),this.isShown?this.show():this.hide(),this.onElementActionListener=()=>this.elementAction(),this.el.addEventListener(this.eventType,this.onElementActionListener)}getMultipleToggles(){const t=this.el.closest("[data-toggle-password-group]").querySelectorAll("[data-toggle-password]"),e=[];return t.forEach(t=>{e.push(l.getInstance(t))}),e}show(){if(this.isMultiple){this.getMultipleToggles().forEach(t=>!!t&&(t.isShown=!0)),this.el.closest("[data-toggle-password-group]").classList.add("active")}else this.isShown=!0,this.el.classList.add("active");this.target.forEach(t=>{t.type="text"})}hide(){if(this.isMultiple){this.getMultipleToggles().forEach(t=>!!t&&(t.isShown=!1)),this.el.closest("[data-toggle-password-group]").classList.remove("active")}else this.isShown=!1,this.el.classList.remove("active");this.target.forEach(t=>{t.type="password"})}destroy(){this.isMultiple?this.el.closest("[data-toggle-password-group]").classList.remove("active"):this.el.classList.remove("active"),this.target.forEach(t=>{t.type="password"}),this.el.removeEventListener(this.eventType,this.onElementActionListener),this.isShown=!1,window.$hsTogglePasswordCollection=window.$hsTogglePasswordCollection.filter(({element:t})=>t.el!==this.el)}static getInstance(t,e){const o=window.$hsTogglePasswordCollection.find(e=>e.element.el===("string"==typeof t?document.querySelector(t):t));return o?e?o:o.element:null}static autoInit(){window.$hsTogglePasswordCollection||(window.$hsTogglePasswordCollection=[]),window.$hsTogglePasswordCollection&&(window.$hsTogglePasswordCollection=window.$hsTogglePasswordCollection.filter(({element:t})=>document.contains(t.el))),document.querySelectorAll("[data-toggle-password]:not(.--prevent-on-load-init)").forEach(t=>{window.$hsTogglePasswordCollection.find(e=>{var o;return(null===(o=null==e?void 0:e.element)||void 0===o?void 0:o.el)===t})||new l(t)})}}window.addEventListener("load",()=>{l.autoInit()}),"undefined"!=typeof window&&(window.HSTogglePassword=l),e.default=l},287:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0});e.default=class{constructor(t,e,o){this.el=t,this.options=e,this.events=o,this.el=t,this.options=e,this.events={}}createCollection(t,e){var o;t.push({id:(null===(o=null==e?void 0:e.el)||void 0===o?void 0:o.id)||t.length+1,element:e})}fireEvent(t,e=null){if(this.events.hasOwnProperty(t))return this.events[t](e)}on(t,e){this.events[t]=e}}},806:function(t,e){ /* * @version: 3.2.2 * @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(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,o="")=>(window.getComputedStyle(t).getPropertyValue(e)||o).replace(" ","");e.getClassPropertyAlt=(t,e,o="")=>{let s="";return t.classList.forEach(t=>{t.includes(e)&&(s=t)}),s.match(/:(.*)]/)?s.match(/:(.*)]/)[1]:o};const o=t=>window.getComputedStyle(t).getPropertyValue("z-index");e.getZIndex=o;e.getHighestZIndex=t=>{let e=Number.NEGATIVE_INFINITY;return t.forEach(t=>{let s=o(t);"auto"!==s&&(s=parseInt(s,10),s>e&&(e=s))}),e};e.isDirectChild=(t,e)=>{const o=t.children;for(let t=0;t<o.length;t++)if(o[t]===e)return!0;return!1};e.isEnoughSpace=(t,e,o="auto",s=10,i=null)=>{const n=e.getBoundingClientRect(),l=i?i.getBoundingClientRect():null,r=window.innerHeight,a=l?n.top-l.top:n.top,c=(i?l.bottom:r)-n.bottom,d=t.clientHeight+s;return"bottom"===o?c>=d:"top"===o?a>=d:a>=d||c>=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],o=t.trim().slice(-1);if("{"===e&&"}"===o||"["===e&&"]"===o)try{return JSON.parse(t),!0}catch(t){return!1}return!1};const s=t=>{if(!t)return!1;return"none"===window.getComputedStyle(t).display||s(t.parentElement)};e.isParentOrElementHidden=s;e.isScrollable=t=>{const e=window.getComputedStyle(t),o=e.overflowY,s=e.overflowX,i=("scroll"===o||"auto"===o)&&t.scrollHeight>t.clientHeight,n=("scroll"===s||"auto"===s)&&t.scrollWidth>t.clientWidth;return i||n};e.debounce=(t,e=200)=>{let o;return(...s)=>{clearTimeout(o),o=setTimeout(()=>{t.apply(this,s)},e)}};e.dispatch=(t,e,o=null)=>{const s=new CustomEvent(t,{detail:{payload:o},bubbles:!0,cancelable:!0,composed:!1});e.dispatchEvent(s)};e.afterTransition=(t,e)=>{const o=()=>{e(),t.removeEventListener("transitionend",o,!0)},s=window.getComputedStyle(t),i=s.getPropertyValue("transition-duration");"none"!==s.getPropertyValue("transition-property")&&parseFloat(i)>0?t.addEventListener("transitionend",o,!0):e()};e.htmlToElement=t=>{const e=document.createElement("template");return t=t.trim(),e.innerHTML=t,e.content.firstChild};e.classToClassList=(t,e,o=" ",s="add")=>{t.split(o).forEach(t=>{t.trim()&&("add"===s?e.classList.add(t):e.classList.remove(t))})};const i={historyIndex:-1,addHistory(t){this.historyIndex=t},existsInHistory(t){return t>this.historyIndex},clearHistory(){this.historyIndex=-1}};e.menuSearchHistory=i}},e={};var o=function o(s){var i=e[s];if(void 0!==i)return i.exports;var n=e[s]={exports:{}};return t[s].call(n.exports,n,n.exports,o),n.exports}(234);return o})());