jBase-2/dist/jbase.min.js

10 lines
33 KiB
JavaScript
Raw Normal View History

2026-05-17 12:39:25 +02:00
/**
* @k37z3r/jbase - Ditch the legacy bloat. jBase is a blazing-fast, SSR-ready micro-framework combining an elegant DOM chaining API with powerful, immutable data utilities. Fully typed, modular, and built for modern web & Node.js environments.
* @version 2.4.0
* @homepage https://github.com/k37z3r/jBase-2
* @author Sven Minio (https://github.com/k37z3r/jBase-2)
* @license GPL-3.0-or-later
* @copyright 2026 Sven Minio (https://github.com/k37z3r/jBase-2)
*/
"use strict";(()=>{var jt=Object.defineProperty;var c=(e,t)=>()=>(e&&(t=e(e=0)),t);var Bt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),h=(e,t)=>{for(var n in t)jt(e,n,{get:t[n],enumerable:!0})};function q(e,t){let n;return function(...s){let r=this;n||(e.apply(r,s),n=!0,setTimeout(()=>n=!1,t))}}function N(e,t){let n;return function(...s){clearTimeout(n),n=setTimeout(()=>e.apply(this,s),t)}}function m(){return typeof window<"u"&&typeof window.requestAnimationFrame<"u"}function l(e,t){if(Array.isArray(e)||e&&typeof e=="object"&&"length"in e&&typeof e.length=="number"){let s=e;for(let r=0,i=s.length;r<i&&t.call(s[r],r,s[r])!==!1;r++);}else{let s=e;for(let r in s)if(Object.prototype.hasOwnProperty.call(s,r)&&t.call(s[r],r,s[r])===!1)break}return e}function y(e){let t=e.replace(/on\w+\s*=\s*(['"])(?:(?!\1).)*\1/gi,"");return t=t.replace(/(href|action)\s*=\s*(['"])\s*javascript\s*:[\s\S]*?\2/gi,""),t}var d=c(()=>{"use strict";});var p,K=c(()=>{"use strict";d();p=class extends Array{selectorSource="";doc;constructor(t,n){if(super(),n instanceof Document?this.doc=n:n&&n.document?this.doc=n.document:this.doc=typeof document<"u"?document:null,!(typeof document>"u")&&(this.selectorSource=typeof t=="string"?t:"<DOM Object/Array>",!!t))if(t instanceof HTMLElement||t===document||t===window||t instanceof Element)this.push(t);else if(typeof t=="string"){let s=t.trim();if(s.startsWith("<")&&s.endsWith(">")){let r=this.doc.createElement("div");r.innerHTML=y(s),this.push(...Array.from(r.children))}else if(s.startsWith("#")&&!s.includes(" ")&&!s.includes(".")){let r=this.doc.getElementById(s.slice(1));r&&this.push(r)}else if(s.startsWith(".")&&!s.includes(" ")&&!/[:\[#]/.test(s)){let r=this.doc.getElementsByClassName(s.slice(1));for(let i=0;i<r.length;i++)this.push(r[i])}else if(/^[a-zA-Z0-9]+$/.test(s)){let r=this.doc.getElementsByTagName(s);for(let i=0;i<r.length;i++)this.push(r[i])}else try{this.push(...Array.from(this.doc.querySelectorAll(t)))}catch(r){console.warn(`jBase: Invalid selector "${t}"`,r)}}else(t instanceof NodeList||Array.isArray(t))&&this.push(...Array.from(t))}toJSON(){return{meta:"jBase Wrapper",query:this.selectorSource,count:this.length,preview:this.slice(0,10).map(t=>t instanceof Element?t.tagName.toLowerCase():typeof t)}}each(t){for(let n=0,s=this.length;n<s&&t.call(this[n],this[n],n)!==!1;n++);return this}}});var H={};h(H,{addClass:()=>vt,hasClass:()=>Et,removeClass:()=>Tt,toggleClass:()=>bt});function vt(...e){return this.each(function(t){t instanceof Element&&t.classList.add(...e)}),this}function Tt(...e){return this.each(function(t){t instanceof Element&&t.classList.remove(...e)}),this}function bt(e){return this.each(function(t){t instanceof Element&&t.classList.toggle(e)}),this}function Et(e){return this.some(t=>t instanceof Element&&t.classList.contains(e))}var ke=c(()=>{"use strict";});var R={};h(R,{css:()=>xt});function xt(e,t){if(typeof e=="object"&&e!==null)return this.each(function(n){if(n instanceof HTMLElement||n instanceof SVGElement)for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&(s.includes("-")?n.style.setProperty(s,String(e[s])):n.style[s]=e[s])}),this;if(typeof e=="string"){if(t===void 0){let n=this[0];if(n instanceof HTMLElement||n instanceof SVGElement){let s=n.ownerDocument,r=s?s.defaultView:null;return r?r.getComputedStyle(n).getPropertyValue(e)||r.getComputedStyle(n)[e]||"":n.style[e]||""}return""}this.each(function(n){(n instanceof HTMLElement||n instanceof SVGElement)&&(e.includes("-")?n.style.setProperty(e,String(t)):n.style[e]=t)})}return this}var Ce=c(()=>{"use strict";});var We,_e=c(()=>{"use strict";ke();Ce();We={...H,...R}});var J={};h(J,{off:()=>Mt,on:()=>wt,once:()=>St,trigger:()=>Lt});function wt(e,t,n,s){let r,i,o;if(typeof t=="string"?(r=t,typeof n=="function"?o=n:(i=n,o=s)):typeof t=="function"?o=t:(i=t,o=n),!o)return this;let a=e.split(" ");return this.each(function(f){if(!(f instanceof EventTarget))return;let u=f[F]||(f[F]=[]);l(a,function(j,x){let A=function(w){let k=f;if(r){let _=w.target instanceof Element?w.target:w.target?.parentElement,P=_ instanceof
//# sourceMappingURL=jbase.min.js.map