UNPKG

preline

Version:

Preline UI is an open-source set of prebuilt UI components based on the utility-first Tailwind CSS framework.

1 lines 4.63 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(self,(()=>(()=>{"use strict";var e={961:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t,n){this.el=e,this.options=t,this.events=n,this.el=e,this.options=t,this.events={}}return e.prototype.createCollection=function(e,t){var n;e.push({id:(null===(n=null==t?void 0:t.el)||void 0===n?void 0:n.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=n},502:function(e,t,n){var o,r=this&&this.__extends||(o=function(e,t){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},o(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 n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},i.apply(this,arguments)},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var s=function(e){function t(t,n){var o=e.call(this,t,n)||this,r=t.getAttribute("data-hs-theme-switch"),a=r?JSON.parse(r):{},s=i(i({},a),n);return o.theme=(null==s?void 0:s.theme)||localStorage.getItem("hs_theme")||"default",o.themeSet=["light","dark","default"],o.init(),o}return r(t,e),t.prototype.init=function(){this.createCollection(window.$hsThemeSwitchCollection,this),"default"!==this.theme&&this.setAppearance()},t.prototype.setResetStyles=function(){var e=document.createElement("style");return e.innerText="*{transition: unset !important;}",e.setAttribute("data-hs-appearance-onload-styles",""),document.head.appendChild(e),e},t.prototype.addSystemThemeObserver=function(){var e=this;window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(function(t){t.matches?e.setAppearance("dark",!1):e.setAppearance("default",!1)}))},t.prototype.removeSystemThemeObserver=function(){window.matchMedia("(prefers-color-scheme: dark)").removeEventListener},t.prototype.setAppearance=function(e,t,n){void 0===e&&(e=this.theme),void 0===t&&(t=!0),void 0===n&&(n=!0);var o=document.querySelector("html"),r=this.setResetStyles();t&&localStorage.setItem("hs_theme",e),"auto"===e&&(e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"default"),o.classList.remove("light","dark","default","auto"),o.classList.add(e),setTimeout((function(){return r.remove()})),n&&window.dispatchEvent(new CustomEvent("on-hs-appearance-change",{detail:e}))},t.getInstance=function(e){var t=window.$hsThemeSwitchCollection.find((function(t){return t.element.el===("string"==typeof e?document.querySelector(e):e)}));return t?t.element:null},t.autoInit=function(){window.$hsThemeSwitchCollection||(window.$hsThemeSwitchCollection=[]);var e=function(e){"auto"===localStorage.getItem("hs_theme")?e.addSystemThemeObserver():e.removeSystemThemeObserver()};document.querySelectorAll("[data-hs-theme-switch]:not(.--prevent-on-load-init)").forEach((function(n){if(!window.$hsThemeSwitchCollection.find((function(e){var t;return(null===(t=null==e?void 0:e.element)||void 0===t?void 0:t.el)===n}))){var o=new t(n);o.el.checked="dark"===o.theme,e(o),o.el.addEventListener("change",(function(t){var n=t.target.checked?"dark":"default";o.setAppearance(n),e(o)}))}})),document.querySelectorAll("[data-hs-theme-click-value]:not(.--prevent-on-load-init)").forEach((function(n){var o=n.getAttribute("data-hs-theme-click-value"),r=new t(n);e(r),r.el.addEventListener("click",(function(){r.setAppearance(o),e(r)}))}))},t}(a(n(961)).default);window.addEventListener("load",(function(){s.autoInit()})),window.$hsThemeSwitchCollection&&window.addEventListener("on-hs-appearance-change",(function(e){window.$hsThemeSwitchCollection.forEach((function(t){t.element.el.checked="dark"===e.detail}))})),"undefined"!=typeof window&&(window.HSThemeSwitch=s),t.default=s}},t={};var n=function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o].call(i.exports,i,i.exports,n),i.exports}(502);return n})()));