tiny-essentials 1.23.0 → 1.23.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.
@@ -1 +1 @@
1
- (()=>{"use strict";var e={d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{TinyLoadingScreen:()=>s});const s=class{#e=null;get overlay(){return this.#e}#t=null;get messageElement(){return this.#t}#s;get container(){return this.#s}#n={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#n}}set options(e){if("object"!=typeof e||null===e)throw new TypeError("options must be an object");if(void 0!==e.fadeIn&&null!==e.fadeIn&&("number"!=typeof e.fadeIn||e.fadeIn<0))throw new TypeError("fadeIn must be a non-negative number or null");if(void 0!==e.fadeOut&&null!==e.fadeOut&&("number"!=typeof e.fadeOut||e.fadeOut<0))throw new TypeError("fadeOut must be a non-negative number or null");if(void 0!==e.zIndex&&("number"!=typeof e.zIndex||!Number.isInteger(e.zIndex)))throw new TypeError("zIndex must be an integer number");this.#n={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#a="none";get status(){return this.#a}#i="";get defaultMessage(){return this.#i}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#i=e}#o=null;get message(){return this.#o}#r=!1;get allowHtmlText(){return this.#r}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#r=e}#l=null;get fadeInTimeout(){return null!==this.#l}#u=null;get fadeOutTimeout(){return null!==this.#u}get visible(){return!!this.#e}#m=null;get onChange(){return this.#m}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#m=e}_emitChange(){"function"==typeof this.#m&&this.#m(this.#a)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#s=e}_updateMessage(e=this.#i){if(!this.#t)throw new Error("messageElement is not initialized");if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(this.#o=e,"string"==typeof e)this.#r?this.#t.innerHTML=e:this.#t.textContent=e;else{if(!this.#r)throw new Error("HTMLElement messages require allowHtmlText = true");this.#t.textContent="",this.#t.appendChild(e)}}_removeOldClasses(){this.#e?.classList.remove("active"),this.#e?.classList.remove("fadeIn"),this.#e?.classList.remove("fadeOut")}start(e=this.#i){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(!this.#e){this.#e=document.createElement("div"),this.#e.classList.add("loading-overlay"),this.#e.style.zIndex=String(this.#n.zIndex);const t=document.createElement("div");t.classList.add("loading-content");const s=document.createElement("div");s.classList.add("loading-spinner"),this.#t=document.createElement("div"),this.#t.classList.add("loading-message"),t.appendChild(s),t.appendChild(this.#t),this.#e.appendChild(t),this.#s.appendChild(this.#e),this._removeOldClasses(),this.#a="fadeIn",this.#e.classList.add("fadeIn"),this._emitChange();const n=()=>{this._removeOldClasses(),this.#l=null,this.#a="active",this.#e?.classList.add("active"),this._emitChange()};return"number"==typeof this.#n.fadeIn?(this.#l&&clearTimeout(this.#l),this.#l=setTimeout(n,this.#n.fadeIn)):n(),this._updateMessage(e),!0}return this.#t&&this._updateMessage(e),!1}update(e=this.#i){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#t&&(this._updateMessage(e),!0)}stop(){if(this.#e){this._removeOldClasses(),this.#a="fadeOut",this.#e.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#u=null,this.#a="none",this.#e?.remove(),this.#e=null,this.#t=null,this.#o=null,this._emitChange()};return"number"==typeof this.#n.fadeOut?(this.#u&&clearTimeout(this.#u),this.#u=setTimeout(e,this.#n.fadeOut)):e(),!0}return!1}};window.TinyLoadingScreen=t.TinyLoadingScreen})();
1
+ (()=>{"use strict";var e={d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{TinyLoadingScreen:()=>s});const s=class{#e=null;get overlay(){return this.#e}#t=null;get messageElement(){return this.#t}#s;get container(){return this.#s}#n={fadeIn:null,fadeOut:null,zIndex:9999};get options(){return{...this.#n}}set options(e){if("object"!=typeof e||null===e)throw new TypeError("options must be an object");if(void 0!==e.fadeIn&&null!==e.fadeIn&&("number"!=typeof e.fadeIn||e.fadeIn<0))throw new TypeError("fadeIn must be a non-negative number or null");if(void 0!==e.fadeOut&&null!==e.fadeOut&&("number"!=typeof e.fadeOut||e.fadeOut<0))throw new TypeError("fadeOut must be a non-negative number or null");if(void 0!==e.zIndex&&("number"!=typeof e.zIndex||!Number.isInteger(e.zIndex)))throw new TypeError("zIndex must be an integer number");this.#n={fadeIn:e.fadeIn??null,fadeOut:e.fadeOut??null,zIndex:e.zIndex??9999}}#a="none";get status(){return this.#a}#i="";get defaultMessage(){return this.#i}set defaultMessage(e){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("defaultMessage must be a string or an HTMLElement");this.#i=e}#o=null;get message(){return this.#o}#l=!1;get allowHtmlText(){return this.#l}set allowHtmlText(e){if("boolean"!=typeof e)throw new TypeError("allowHtmlText must be a boolean");this.#l=e}#r=null;get fadeInTimeout(){return null!==this.#r}#u=null;get fadeOutTimeout(){return null!==this.#u}get visible(){return!!this.#e}#d=null;get onChange(){return this.#d}set onChange(e){if(null!==e&&"function"!=typeof e)throw new TypeError("onChange must be a function or null");this.#d=e}_emitChange(){"function"==typeof this.#d&&this.#d(this.#a)}constructor(e=document.body){if(!(e instanceof HTMLElement))throw new TypeError("container must be an HTMLElement");this.#s=e}_updateMessage(e=this.#i){if(!this.#t)throw new Error("messageElement is not initialized");if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(this.#o=e,"string"==typeof e)this.#l?this.#t.innerHTML=e:this.#t.textContent=e;else{if(!this.#l)throw new Error("HTMLElement messages require allowHtmlText = true");this.#t.textContent="",this.#t.appendChild(e)}}_removeOldClasses(){this.#e?.classList.remove("active"),this.#e?.classList.remove("fadeIn"),this.#e?.classList.remove("fadeOut")}start(e=this.#i){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");if(!this.#e){this.#e=document.createElement("div"),this.#e.classList.add("loading-overlay"),this.#e.style.zIndex=String(this.#n.zIndex);const t=document.createElement("div");t.classList.add("loading-container");const s=document.createElement("div");s.classList.add("loading-content");const n=document.createElement("div");n.classList.add("loading-spinner"),this.#t=document.createElement("div"),this.#t.classList.add("loading-message"),s.appendChild(n),s.appendChild(this.#t),t.appendChild(s),this.#e.appendChild(t),this.#s.appendChild(this.#e),this._removeOldClasses(),this.#a="fadeIn",this.#e.classList.add("fadeIn"),this._emitChange();const a=()=>{this._removeOldClasses(),this.#r=null,this.#a="active",this.#e?.classList.add("active"),this._emitChange()};return"number"==typeof this.#n.fadeIn?(this.#r&&clearTimeout(this.#r),this.#r=setTimeout(a,this.#n.fadeIn)):a(),this._updateMessage(e),!0}return this.#t&&this._updateMessage(e),!1}update(e=this.#i){if("string"!=typeof e&&!(e instanceof HTMLElement))throw new TypeError("message must be a string or an HTMLElement");return!!this.#t&&(this._updateMessage(e),!0)}stop(){if(this.#e){this._removeOldClasses(),this.#a="fadeOut",this.#e.classList.add("fadeOut"),this._emitChange();const e=()=>{this._removeOldClasses(),this.#u=null,this.#a="none",this.#e?.remove(),this.#e=null,this.#t=null,this.#o=null,this._emitChange()};return"number"==typeof this.#n.fadeOut?(this.#u&&clearTimeout(this.#u),this.#u=setTimeout(e,this.#n.fadeOut)):e(),!0}return!1}};window.TinyLoadingScreen=t.TinyLoadingScreen})();
@@ -1 +1 @@
1
- .loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.6);display:flex;justify-content:center;align-items:center;z-index:9999}.loading-overlay .loading-content{text-align:center;color:#fff;font-family:Arial,sans-serif}.loading-overlay .loading-spinner{border:4px solid hsla(0,0%,100%,.3);border-top:4px solid #fff;border-radius:50%;width:50px;height:50px;margin:0 auto 15px;animation:spin 1s linear infinite}.loading-overlay .loading-message{font-size:1.2em}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}
1
+ .loading-overlay{position:absolute;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.6);display:absolute;justify-content:center;align-items:center;z-index:9999}.loading-overlay .loading-container{height:100%;width:100%;display:flex;align-items:center}.loading-overlay .loading-content{text-align:center;color:#fff;font-family:Arial,sans-serif;margin:auto}.loading-overlay .loading-spinner{position:relative;border:4px solid hsla(0,0%,100%,.3);border-top:4px solid #fff;border-radius:50%;width:50px;height:50px;margin:0 auto 15px;animation:spin 1s linear infinite}.loading-overlay .loading-spinner::after{content:"";position:absolute;top:50%;left:50%;width:20px;height:20px;transform:translate(-50%, -50%);border-radius:50%;background:rgba(0,0,0,0);pointer-events:none}.loading-overlay .loading-message{font-size:1.2em}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}
@@ -267,6 +267,9 @@ class TinyLoadingScreen {
267
267
  this.#overlay.classList.add('loading-overlay');
268
268
  this.#overlay.style.zIndex = String(this.#options.zIndex);
269
269
 
270
+ const contentBase = document.createElement('div');
271
+ contentBase.classList.add('loading-container');
272
+
270
273
  const content = document.createElement('div');
271
274
  content.classList.add('loading-content');
272
275
 
@@ -278,7 +281,8 @@ class TinyLoadingScreen {
278
281
 
279
282
  content.appendChild(spinner);
280
283
  content.appendChild(this.#messageElement);
281
- this.#overlay.appendChild(content);
284
+ contentBase.appendChild(content);
285
+ this.#overlay.appendChild(contentBase);
282
286
  this.#container.appendChild(this.#overlay);
283
287
 
284
288
  // trigger fade in
@@ -227,6 +227,8 @@ class TinyLoadingScreen {
227
227
  this.#overlay = document.createElement('div');
228
228
  this.#overlay.classList.add('loading-overlay');
229
229
  this.#overlay.style.zIndex = String(this.#options.zIndex);
230
+ const contentBase = document.createElement('div');
231
+ contentBase.classList.add('loading-container');
230
232
  const content = document.createElement('div');
231
233
  content.classList.add('loading-content');
232
234
  const spinner = document.createElement('div');
@@ -235,7 +237,8 @@ class TinyLoadingScreen {
235
237
  this.#messageElement.classList.add('loading-message');
236
238
  content.appendChild(spinner);
237
239
  content.appendChild(this.#messageElement);
238
- this.#overlay.appendChild(content);
240
+ contentBase.appendChild(content);
241
+ this.#overlay.appendChild(contentBase);
239
242
  this.#container.appendChild(this.#overlay);
240
243
  // trigger fade in
241
244
  this._removeOldClasses();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tiny-essentials",
3
- "version": "1.23.0",
3
+ "version": "1.23.1",
4
4
  "description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
5
5
  "scripts": {
6
6
  "test": "npm run test:mjs && npm run test:cjs && npm run test:js",