jj 2.7.2 → 2.8.0
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/lib/bundle.cjs +24 -17
- package/lib/bundle.cjs.map +1 -1
- package/lib/bundle.d.cts +19 -18
- package/lib/bundle.d.ts +19 -18
- package/lib/bundle.global.js +24 -17
- package/lib/bundle.global.js.map +1 -1
- package/lib/bundle.js +24 -17
- package/lib/bundle.js.map +1 -1
- package/lib/bundle.min.cjs +1 -1
- package/lib/bundle.min.cjs.map +1 -1
- package/lib/bundle.min.d.cts +19 -18
- package/lib/bundle.min.d.ts +19 -18
- package/lib/bundle.min.global.js +1 -1
- package/lib/bundle.min.global.js.map +1 -1
- package/lib/bundle.min.js +1 -1
- package/lib/bundle.min.js.map +1 -1
- package/package.json +12 -6
package/lib/bundle.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var K=e=>{throw TypeError(e)};var tt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},et=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Y(t))!_.call(e,a)&&a!==r&&P(e,a,{get:()=>t[a],enumerable:!(o=X(t,a))||o.enumerable});return e};var rt=e=>et(P({},"__esModule",{value:!0}),e);var G=(e,t,r)=>t.has(e)||K("Cannot "+r);var c=(e,t,r)=>(G(e,t,"read from private field"),r?r.call(e):t.get(e)),m=(e,t,r)=>t.has(e)?K("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),A=(e,t,r,o)=>(G(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r),F=(e,t,r)=>(G(e,t,"access private method"),r);var xt={};tt(xt,{JJD:()=>T,JJDF:()=>h,JJE:()=>E,JJET:()=>L,JJHE:()=>f,JJN:()=>u,JJSE:()=>M,JJSR:()=>y,JJT:()=>b,ShadowMaster:()=>B,addLinkPre:()=>ht,attr2prop:()=>dt,createLinkPre:()=>Z,cssToStyle:()=>$,doc:()=>St,fetchCss:()=>Q,fetchHtml:()=>mt,fetchStyle:()=>lt,fetchText:()=>z,fileExt:()=>j,h:()=>pt,keb2cam:()=>U,keb2pas:()=>ut,nextAnimationFrame:()=>st,pas2keb:()=>at,registerComponent:()=>gt,sleep:()=>ot});module.exports=rt(xt);function C(e){return e!==void 0}function g(e){return typeof e=="function"}var{isNaN:nt,isFinite:$t,isInteger:Lt}=Number;function W(e){return typeof e=="number"&&!nt(e)}function O(e,t,r){if(!W(e))throw new TypeError(`inRange(): "x" must be a number. Got ${e} (${typeof e})`);if(C(t)){if(!W(t))throw new TypeError(`inRange(): "min" must be a number. Got ${t} (${typeof t})`);if(C(r)){if(!W(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return t>r?r<=e&&e<=t:t<=e&&e<=r}return e>=t}else if(C(r)){if(!W(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return e<=r}throw new TypeError(`inRange(): expected at least min or max to be defined. Got min=${t} and max=${r}`)}var{isArray:it}=Array;function k(e,t=0,r){return it(e)&&O(e.length,t,r)}var{hasOwnProperty:Nt}=Object;function p(e){return!!e&&typeof e=="object"}function s(e,t){if(!g(t))throw new TypeError(`Expected a constructor function. Got ${t} (${typeof t})`);return e instanceof t}function w(e,...t){if(!p(e))return!1;for(let r of t)if(!(r in e))return!1;return!0}function i(e){return typeof e=="string"}var{hasOwnProperty:Vt}=Object,{isArray:It}=Array;function S(e,t,r){return`Expected '${e}' to be ${t}. Got ${r} (${typeof r})`}function n(e,t,r){return new TypeError(S(e,t,r))}function j(e){if(!i(e))throw n("path","a string",e);let t=e.lastIndexOf(".");if(t===-1)return"";let r=e.slice(t+1);return r.indexOf("/")!==-1?"":r.toLowerCase().trim()}function st(){return new Promise(e=>requestAnimationFrame(e))}function ot(e=0){return new Promise(t=>setTimeout(t,e))}async function $(e){return await new CSSStyleSheet().replace(e)}function at(e){if(!i(e))throw n("str","a string",e);if(/[^a-zA-Z0-9_]/.test(e))throw new SyntaxError(S("str","alphanumeric characters and underscores",e));return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function ut(e){if(!i(e))throw n("str","a string",e);return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")||(e.length>0?e.charAt(0).toUpperCase()+e.slice(1):"")}function U(e){if(!i(e))throw n("str","a string",e);return e.replace(/^-+|-+$/g,"").replace(/-+([a-z])/g,(t,r)=>r.toUpperCase())}var D,R,v,V,I=class I{constructor(t){m(this,v);m(this,D);m(this,R,new WeakMap);if(!s(t,EventTarget))throw new TypeError(`JJET expects an EventTarget instance. Got ${t} (${typeof t}). `);A(this,D,t)}static from(t){return new I(t)}get ref(){return c(this,D)}on(t,r,o){let a=F(this,v,V).call(this,r);return this.ref.addEventListener(t,a,o),this}off(t,r,o){let a=F(this,v,V).call(this,r);return this.ref.removeEventListener(t,a,o),this}trigger(t){return this.ref.dispatchEvent(t),this}run(t,...r){return t.call(this,...r)}};D=new WeakMap,R=new WeakMap,v=new WeakSet,V=function(t){if(t===null)return null;let r=c(this,R).get(t);return r||(typeof t=="function"?r=t.bind(this):r={handleEvent:t.handleEvent.bind(this)},c(this,R).set(t,r)),r};var L=I;var u=class e extends L{static from(t){return new e(t)}static isWrapable(t){return i(t)||s(t,Node)||s(t,e)}static wrap(t){throw new ReferenceError("The mixin is supposed to override this method.")}static unwrap(t){if(i(t))return document.createTextNode(t);if(!p(t))throw new TypeError(`JJN.unwrap() expects a string, DOM Node, or JJ wrapper. Got ${t} (${typeof t}). `);if(s(t,Node))return t;if(s(t,e))return t.ref;throw new TypeError(`Could not unwrap ${t} (${typeof t}). Expected a string, Node, or JJ wrapper. Make sure you're passing a valid DOM element or JJ wrapper.`)}static wrapAll(t){return Array.from(t,e.wrap)}static unwrapAll(t){return Array.from(t,e.unwrap)}constructor(t){if(!s(t,Node))throw new TypeError(`JJN expects a Node instance. Got ${t} (${typeof t}). Use JJN.from(node) with a DOM Node, or check that you're passing a valid DOM element.`);super(t)}clone(t){return e.wrap(this.ref.cloneNode(t))}addText(t){return t&&this.ref.appendChild(document.createTextNode(t)),this}};var l=class extends u{find(t,r=!1){let o=this.ref.querySelector(t);if(o)return u.wrap(o);if(r)throw new TypeError(`No element matched query "${t}"`);return null}findAll(t){return u.wrapAll(this.ref.querySelectorAll(t))}addChild(...t){let r=u.unwrapAll(t.filter(u.isWrapable));return this.ref.append(...r),this}preChild(...t){let r=u.unwrapAll(t.filter(u.isWrapable));return this.ref.prepend(...r),this}addChildMap(t,r){return this.addChild(...t.map(r))}preChildMap(t,r){return this.preChild(...t.map(r))}setChildren(...t){let r=u.unwrapAll(t.filter(u.isWrapable));return this.ref.replaceChildren(...r),this}empty(){return this.setChildren(),this}};var h=class e extends l{static from(t){return new e(t)}static create(){return new e(document.createDocumentFragment())}constructor(t){if(!s(t,DocumentFragment))throw n("ref","a DocumentFragment",t);super(t)}};var y=class e extends h{static from(t){return new e(t)}constructor(t){if(!s(t,ShadowRoot))throw new TypeError(`JJSR expects a ShadowRoot instance. Got ${t} (${typeof t}). Access a shadow root using element.shadowRoot after calling element.attachShadow().`);super(t)}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}addStyleSheets(...t){return this.ref.adoptedStyleSheets.push(...t),this}};var E=class e extends l{static from(t){return new e(t)}constructor(t){if(!s(t,Element))throw new TypeError(`JJE expects an Element instance. Got ${t} (${typeof t}). Use JJE.from(element) with a DOM Element, or use the specific wrapper (JJHE for HTMLElement, JJSE for SVGElement).`);super(t)}getAttr(t){if(!i(t))throw n("name","a string",t);return this.ref.getAttribute(t)}hasAttr(t){if(!i(t))throw n("name","a string",t);return this.ref.hasAttribute(t)}setAttr(t,r){if(typeof t=="string")this.ref.setAttribute(t,r);else if(p(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(o,a);else throw n("nameOrObj","a string or object",t);return this}rmAttr(...t){for(let r of t){if(!i(r))throw n("name","a string",r);this.ref.removeAttribute(r)}return this}getAria(t){if(!i(t))throw n("name","a string",t);return this.ref.getAttribute(`aria-${t}`)}hasAria(t){if(!i(t))throw n("name","a string",t);return this.ref.hasAttribute(`aria-${t}`)}setAria(t,r){if(i(t))this.ref.setAttribute(`aria-${t}`,r);else if(p(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(`aria-${o}`,a);else throw n("nameOrObj","a string or object",t);return this}rmAria(...t){for(let r of t){if(!i(r))throw n("name","a string",r);this.ref.removeAttribute(`aria-${r}`)}return this}getClass(){return this.getAttr("class")}setClass(t){if(typeof t=="string")return this.setAttr("class",t);for(let[r,o]of Object.entries(t))o?this.ref.classList.add(r):this.ref.classList.remove(r);return this}addClass(...t){for(let r of t)if(!i(r))throw n("className","a string",r);return this.ref.classList.add(...t),this}rmClass(...t){for(let r of t)if(!i(r))throw n("className","a string",r);return this.ref.classList.remove(...t),this}hasClass(t){if(!i(t))throw n("className","a string",t);return this.ref.classList.contains(t)}toggleClass(t){if(!i(t))throw n("className","a string",t);return this.ref.classList.toggle(t),this}replaceClass(t,r){if(!i(t))throw n("oldClassName","a string",t);if(!i(r))throw n("newClassName","a string",r);return this.ref.classList.replace(t,r),this}closest(t){if(!i(t))throw n("selector","a string",t);let r=this.ref.closest(t);return r?u.wrap(r):null}hide(){return this.setAttr("hidden","").setAttr("aria-hidden","true")}show(){return this.rmAttr("hidden","aria-hidden")}disable(){return this.setAttr("disabled","").setAttr("aria-disabled","true")}enable(){return this.rmAttr("disabled","aria-disabled")}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}initShadow(t="open",r){let o=this.ref.shadowRoot??this.ref.attachShadow({mode:t});if(p(r)){let{template:a,styles:d}=r;a&&(i(a)?o.innerHTML=a:o.appendChild(a)),k(d)&&d.length&&o.adoptedStyleSheets.push(...d)}return this}get shadow(){return this.ref.shadowRoot?new y(this.ref.shadowRoot):null}};var x=class extends E{getData(t){if(!i(t))throw n("name","a string",t);return this.ref.dataset[t]}hasData(t){if(!i(t))throw n("name","a string",t);return w(this.ref.dataset,t)}setData(t,r){if(typeof t=="string")this.ref.dataset[t]=r;else if(p(t))for(let[o,a]of Object.entries(t))this.ref.dataset[o]=a;else throw n("nameOrObj","a string or object",t);return this}rmData(...t){for(let r of t){if(!i(r))throw n("name","a string",r);delete this.ref.dataset[r]}return this}};var f=class e extends x{static from(t){return new e(t)}static create(t,r){if(!i(t))throw n("tagName","a string like 'div' or 'button'",t);return new e(document.createElement(t,r))}constructor(t){if(!s(t,HTMLElement))throw n("ref","an HTMLElement",t);super(t)}getValue(){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value}setValue(t){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value=t,this}focus(){return this.ref.focus(),this}click(){return this.ref.click(),this}getText(){return this.ref.innerText}setText(t){return this.ref.innerText=t??"",this}};var b=class e extends u{static from(t){return new e(t)}static fromStr(t){return new e(document.createTextNode(t))}constructor(t){if(!s(t,Text))throw new TypeError(`JJT expects a Text node. Got ${t} (${typeof t}). Create a Text node with JJT.fromStr() or document.createTextNode('text').`);super(t)}getText(){return this.ref.textContent}setText(t){return this.ref.textContent=t??null,this}addText(t){return t!=null&&(this.ref.textContent+=t),this}empty(){return this.setText("")}};var T=class e extends l{static from(t){return new e(t)}constructor(t){if(!s(t,Document))throw new TypeError(`JJD expects a Document instance. Got ${t} (${typeof t}). `);super(t)}get head(){return f.from(this.ref.head)}get body(){return f.from(this.ref.body)}};var ft="http://www.w3.org/2000/svg",M=class e extends x{static from(t){return new e(t)}static create(t,r){if(!i(t))throw n("tagName",'a string like "circle" or "path"',t);let o=document.createElementNS(ft,t,r);return new e(o)}constructor(t){if(!s(t,SVGElement))throw n("ref","an SVGElement",t);super(t)}getText(){return this.ref.textContent??""}setText(t){return this.ref.textContent=t??"",this}setFill(t){return this.setAttr("fill",t)}setStroke(t){return this.setAttr("stroke",t)}setStrokeWidth(t){return this.setAttr("stroke-width",String(t))}setViewBox(t,r,o,a){if(typeof t=="number"&&r!==void 0&&o!==void 0&&a!==void 0)return this.setAttr("viewBox",`${t} ${r} ${o} ${a}`);let d=t;return this.setAttr("viewBox",Array.isArray(d)?d.join(" "):d)}setWidth(t){return this.setAttr("width",String(t))}setHeight(t){return this.setAttr("height",String(t))}setD(t){return this.setAttr("d",Array.isArray(t)?t.join(" "):t)}setTransform(t){return this.setAttr("transform",t)}};u.wrap=function(t){if(i(t))return b.fromStr(t);if(!p(t))throw n("raw","an object",t);if(s(t,u))return t;if(s(t,HTMLElement))return f.from(t);if(s(t,SVGElement))return M.from(t);if(s(t,Element))return E.from(t);if(s(t,ShadowRoot))return y.from(t);if(s(t,DocumentFragment))return h.from(t);if(s(t,Document))return T.from(t);if(s(t,Text))return b.from(t);if(s(t,Node))return u.from(t);throw n("raw","a Node",t)};function pt(e,t,...r){let o=f.create(e).addChild(...r);return t&&o.setAttr(t),o}function ct(e){switch(j(e)){case"html":case"htm":case"md":return"fetch";case"css":return"style";case"js":case"mjs":case"cjs":return"script";default:throw new Error(`No 'as' attribute was specified and we failed to guess it from the URL: ${e}`)}}function Z(e,t,r){if(!i(e)){if(!s(e,URL))throw n("href","a string or URL",e);e=e.toString()}if(!["prefetch","preload"].includes(t))throw new RangeError(S("rel","'prefetch' or 'preload'",t));if(!r&&(r=ct(e),!r))throw new Error(`Could not guess 'as' attribute from URL: ${e}`);if(!["fetch","style","script"].includes(r))throw new RangeError(S("as","'fetch', 'style', or 'script'",r));return f.create("link").setAttr({href:e,rel:t,as:r})}function ht(...e){let t=Z(...e);return document.head.append(t.ref),t}async function z(e,t="text/*"){if(!i(t))throw n("mime","a string",t);let r=await fetch(e,{headers:{Accept:t}});if(!r.ok)throw new Error(`GET ${e} failed: ${r.status} ${r.statusText}`);return r.text()}async function mt(e){return await z(e,"text/html")}async function Q(e){return await z(e,"text/css")}async function lt(e){return await $(await Q(e))}function dt(e,t,r,o){if(!s(e,HTMLElement))throw n("instance","an HTMLElement",e);if(r!==o){let a=U(t);if(w(e,a))return e[a]=o,!0}return!1}async function gt(e,t,r){if(!i(e))throw n("name","a string",e);if(!g(t))throw n("constructor","a function",t);customElements.get(e)||(customElements.define(e,t,r),await customElements.whenDefined(e))}async function wt(e){if(e!==void 0){if(g(e)&&(e=await e()),e=await e,i(e))return e;if(s(e,h))return e.ref.cloneNode(!0);if(s(e,DocumentFragment))return e.cloneNode(!0);if(s(e,f))return e.ref instanceof HTMLTemplateElement?e.ref.content.cloneNode(!0):e.ref.outerHTML;if(s(e,HTMLElement))return e instanceof HTMLTemplateElement?e.content.cloneNode(!0):e.outerHTML;throw n("template","a string, JJHE, JJDF, HTMLElement, or DocumentFragment",e)}}async function yt(e){if(g(e)&&(e=await e()),e=await e,s(e,CSSStyleSheet))return e;if(i(e))return await $(e);throw n("style","a CSS string or CSSStyleSheet",e)}function Et(e){return k(e)?e.map(yt):[]}async function Tt(e,t){let[r,...o]=await Promise.all([wt(e),...Et(t)]);return{template:r,styles:o}}var H,N,J,q=class q{constructor(){m(this,H);m(this,N,[]);m(this,J)}static create(){return new q}setTemplate(t){return A(this,H,t),this}addStyles(...t){return c(this,N).push(...t),this}async getResolved(){return c(this,J)||A(this,J,Tt(c(this,H),c(this,N))),await c(this,J)}};H=new WeakMap,N=new WeakMap,J=new WeakMap;var B=q;var St=T.from(document);0&&(module.exports={JJD,JJDF,JJE,JJET,JJHE,JJN,JJSE,JJSR,JJT,ShadowMaster,addLinkPre,attr2prop,createLinkPre,cssToStyle,doc,fetchCss,fetchHtml,fetchStyle,fetchText,fileExt,h,keb2cam,keb2pas,nextAnimationFrame,pas2keb,registerComponent,sleep});
|
|
1
|
+
"use strict";var P=Object.defineProperty;var X=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var K=e=>{throw TypeError(e)};var tt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},et=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Y(t))!_.call(e,a)&&a!==r&&P(e,a,{get:()=>t[a],enumerable:!(o=X(t,a))||o.enumerable});return e};var rt=e=>et(P({},"__esModule",{value:!0}),e);var G=(e,t,r)=>t.has(e)||K("Cannot "+r);var c=(e,t,r)=>(G(e,t,"read from private field"),r?r.call(e):t.get(e)),m=(e,t,r)=>t.has(e)?K("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),A=(e,t,r,o)=>(G(e,t,"write to private field"),o?o.call(e,r):t.set(e,r),r),F=(e,t,r)=>(G(e,t,"access private method"),r);var xt={};tt(xt,{JJD:()=>T,JJDF:()=>h,JJE:()=>y,JJET:()=>L,JJHE:()=>p,JJN:()=>u,JJSE:()=>v,JJSR:()=>E,JJT:()=>b,ShadowMaster:()=>B,addLinkPre:()=>ht,attr2prop:()=>dt,createLinkPre:()=>Z,cssToStyle:()=>$,doc:()=>St,fetchCss:()=>Q,fetchHtml:()=>mt,fetchStyle:()=>lt,fetchText:()=>z,fileExt:()=>j,h:()=>pt,keb2cam:()=>U,keb2pas:()=>ut,nextAnimationFrame:()=>st,pas2keb:()=>at,registerComponent:()=>gt,sleep:()=>ot});module.exports=rt(xt);function N(e){return e!==void 0}function g(e){return typeof e=="function"}var{isNaN:nt,isFinite:$t,isInteger:Lt}=Number;function C(e){return typeof e=="number"&&!nt(e)}function O(e,t,r){if(!C(e))throw new TypeError(`inRange(): "x" must be a number. Got ${e} (${typeof e})`);if(N(t)){if(!C(t))throw new TypeError(`inRange(): "min" must be a number. Got ${t} (${typeof t})`);if(N(r)){if(!C(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return t>r?r<=e&&e<=t:t<=e&&e<=r}return e>=t}else if(N(r)){if(!C(r))throw new TypeError(`inRange(): "max" must be a number. Got ${r} (${typeof r})`);return e<=r}throw new TypeError(`inRange(): expected at least min or max to be defined. Got min=${t} and max=${r}`)}var{isArray:it}=Array;function W(e,t=0,r){return it(e)&&O(e.length,t,r)}var{hasOwnProperty:Ht}=Object;function f(e){return!!e&&typeof e=="object"}function i(e,t){if(!g(t))throw new TypeError(`Expected a constructor function. Got ${t} (${typeof t})`);return e instanceof t}function w(e,...t){if(!f(e))return!1;for(let r of t)if(!(r in e))return!1;return!0}function s(e){return typeof e=="string"}var{hasOwnProperty:Vt}=Object,{isArray:It}=Array;function S(e,t,r){return`Expected '${e}' to be ${t}. Got ${r} (${typeof r})`}function n(e,t,r){return new TypeError(S(e,t,r))}function j(e){if(!s(e))throw n("path","a string",e);let t=e.lastIndexOf(".");if(t===-1)return"";let r=e.slice(t+1);return r.indexOf("/")!==-1?"":r.toLowerCase().trim()}function st(){return new Promise(e=>requestAnimationFrame(e))}function ot(e=0){return new Promise(t=>setTimeout(t,e))}async function $(e){return await new CSSStyleSheet().replace(e)}function at(e){if(!s(e))throw n("str","a string",e);if(/[^a-zA-Z0-9_]/.test(e))throw new SyntaxError(S("str","alphanumeric characters and underscores",e));return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}function ut(e){if(!s(e))throw n("str","a string",e);return e.split("-").filter(Boolean).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join("")||(e.length>0?e.charAt(0).toUpperCase()+e.slice(1):"")}function U(e){if(!s(e))throw n("str","a string",e);return e.replace(/^-+|-+$/g,"").replace(/-+([a-z])/g,(t,r)=>r.toUpperCase())}var k,D,R,V,I=class I{constructor(t){m(this,R);m(this,k);m(this,D,new WeakMap);if(!i(t,EventTarget))throw new TypeError(`JJET expects an EventTarget instance. Got ${t} (${typeof t}). `);A(this,k,t)}static from(t){return new I(t)}get ref(){return c(this,k)}on(t,r,o){let a=F(this,R,V).call(this,r);return this.ref.addEventListener(t,a,o),this}off(t,r,o){let a=F(this,R,V).call(this,r);return this.ref.removeEventListener(t,a,o),this}trigger(t){return this.ref.dispatchEvent(t),this}run(t,...r){return t.call(this,...r)}};k=new WeakMap,D=new WeakMap,R=new WeakSet,V=function(t){if(t===null)return null;let r=c(this,D).get(t);return r||(typeof t=="function"?r=t.bind(this):r={handleEvent:t.handleEvent.bind(this)},c(this,D).set(t,r)),r};var L=I;var u=class e extends L{static from(t){return new e(t)}static isWrappable(t){return s(t)||i(t,Node)||i(t,e)}static wrap(t){if(f(t)){if(i(t,e))return t;if(i(t,Node))return new e(t)}throw n("raw","a Node",t)}static unwrap(t){if(s(t))return document.createTextNode(t);if(!f(t))throw new TypeError(`JJN.unwrap() expects a string, DOM Node, or JJ wrapper. Got ${t} (${typeof t}). `);if(i(t,Node))return t;if(i(t,e))return t.ref;throw new TypeError(`Could not unwrap ${t} (${typeof t}). Expected a string, Node, or JJ wrapper. Make sure you're passing a valid DOM element or JJ wrapper.`)}static wrapAll(t){return Array.from(t,e.wrap)}static unwrapAll(t){return Array.from(t,e.unwrap)}constructor(t){if(!i(t,Node))throw new TypeError(`JJN expects a Node instance. Got ${t} (${typeof t}). Use JJN.from(node) with a DOM Node, or check that you're passing a valid DOM element.`);super(t)}clone(t){return e.wrap(this.ref.cloneNode(t))}addText(...t){return t&&this.ref.appendChild(document.createTextNode(t.join(""))),this}};var l=class extends u{find(t,r=!1){let o=this.ref.querySelector(t);if(o)return u.wrap(o);if(r)throw new TypeError(`No element matched query "${t}"`);return null}findAll(t){return u.wrapAll(this.ref.querySelectorAll(t))}addChild(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.append(...r),this}preChild(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.prepend(...r),this}addChildMap(t,r){return this.addChild(...t.map(r))}preChildMap(t,r){return this.preChild(...t.map(r))}setChildren(...t){let r=u.unwrapAll(t.filter(u.isWrappable));return this.ref.replaceChildren(...r),this}empty(){return this.setChildren(),this}};var h=class e extends l{static from(t){return new e(t)}static create(){return new e(document.createDocumentFragment())}constructor(t){if(!i(t,DocumentFragment))throw n("ref","a DocumentFragment",t);super(t)}};var E=class e extends h{static from(t){return new e(t)}constructor(t){if(!i(t,ShadowRoot))throw new TypeError(`JJSR expects a ShadowRoot instance. Got ${t} (${typeof t}). Access a shadow root using element.shadowRoot after calling element.attachShadow().`);super(t)}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}addStyleSheets(...t){return this.ref.adoptedStyleSheets.push(...t),this}};var y=class e extends l{static from(t){return new e(t)}constructor(t){if(!i(t,Element))throw new TypeError(`JJE expects an Element instance. Got ${t} (${typeof t}). Use JJE.from(element) with a DOM Element, or use the specific wrapper (JJHE for HTMLElement, JJSE for SVGElement).`);super(t)}getAttr(t){if(!s(t))throw n("name","a string",t);return this.ref.getAttribute(t)}hasAttr(t){if(!s(t))throw n("name","a string",t);return this.ref.hasAttribute(t)}setAttr(t,r){if(typeof t=="string")this.ref.setAttribute(t,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(o,a);else throw n("nameOrObj","a string or object",t);return this}rmAttr(...t){for(let r of t){if(!s(r))throw n("name","a string",r);this.ref.removeAttribute(r)}return this}getAria(t){if(!s(t))throw n("name","a string",t);return this.ref.getAttribute(`aria-${t}`)}hasAria(t){if(!s(t))throw n("name","a string",t);return this.ref.hasAttribute(`aria-${t}`)}setAria(t,r){if(s(t))this.ref.setAttribute(`aria-${t}`,r);else if(f(t))for(let[o,a]of Object.entries(t))this.ref.setAttribute(`aria-${o}`,a);else throw n("nameOrObj","a string or object",t);return this}rmAria(...t){for(let r of t){if(!s(r))throw n("name","a string",r);this.ref.removeAttribute(`aria-${r}`)}return this}getClass(){return this.getAttr("class")}setClass(t){if(typeof t=="string")return this.setAttr("class",t);for(let[r,o]of Object.entries(t))o?this.ref.classList.add(r):this.ref.classList.remove(r);return this}addClass(...t){for(let r of t)if(!s(r))throw n("className","a string",r);return this.ref.classList.add(...t),this}rmClass(...t){for(let r of t)if(!s(r))throw n("className","a string",r);return this.ref.classList.remove(...t),this}hasClass(t){if(!s(t))throw n("className","a string",t);return this.ref.classList.contains(t)}toggleClass(t){if(!s(t))throw n("className","a string",t);return this.ref.classList.toggle(t),this}replaceClass(t,r){if(!s(t))throw n("oldClassName","a string",t);if(!s(r))throw n("newClassName","a string",r);return this.ref.classList.replace(t,r),this}closest(t){if(!s(t))throw n("selector","a string",t);let r=this.ref.closest(t);return r?u.wrap(r):null}hide(){return this.setAttr("hidden","").setAttr("aria-hidden","true")}show(){return this.rmAttr("hidden","aria-hidden")}disable(){return this.setAttr("disabled","").setAttr("aria-disabled","true")}enable(){return this.rmAttr("disabled","aria-disabled")}getHTML(){return this.ref.innerHTML}setHTML(t,r){if(t&&r!==!0)throw new Error("Setting innerHTML is unsafe. Pass true as the second argument to confirm you know what you are doing.");return this.ref.innerHTML=t??"",this}initShadow(t="open",r){let o=this.ref.shadowRoot??this.ref.attachShadow({mode:t});if(f(r)){let{template:a,styles:d}=r;a&&(s(a)?o.innerHTML=a:o.appendChild(a)),W(d)&&d.length&&o.adoptedStyleSheets.push(...d)}return this}get shadow(){return this.ref.shadowRoot?new E(this.ref.shadowRoot):null}};var x=class extends y{getData(t){if(!s(t))throw n("name","a string",t);return this.ref.dataset[t]}hasData(t){if(!s(t))throw n("name","a string",t);return w(this.ref.dataset,t)}setData(t,r){if(typeof t=="string")this.ref.dataset[t]=r;else if(f(t))for(let[o,a]of Object.entries(t))this.ref.dataset[o]=a;else throw n("nameOrObj","a string or object",t);return this}rmData(...t){for(let r of t){if(!s(r))throw n("name","a string",r);delete this.ref.dataset[r]}return this}};var p=class e extends x{static from(t){return new e(t)}static create(t,r){if(!s(t))throw n("tagName","a string like 'div' or 'button'",t);return new e(document.createElement(t,r))}constructor(t){if(!i(t,HTMLElement))throw n("ref","an HTMLElement",t);super(t)}getValue(){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value}setValue(t){if(!w(this.ref,"value"))throw new ReferenceError(`${this.ref.tagName} has no value property.`);return this.ref.value=t,this}focus(){return this.ref.focus(),this}click(){return this.ref.click(),this}getText(){return this.ref.innerText}setText(t){return this.ref.innerText=t,this}};var b=class e extends u{static from(t){return new e(t)}static fromStr(t){return new e(document.createTextNode(t))}constructor(t){if(!i(t,Text))throw new TypeError(`JJT expects a Text node. Got ${t} (${typeof t}). Create a Text node with JJT.fromStr() or document.createTextNode('text').`);super(t)}getText(){return this.ref.textContent}setText(t){return this.ref.textContent=t,this}addText(...t){return this.setText(this.getText()+t.join("")),this}empty(){return this.setText("")}};var T=class e extends l{static from(t){return new e(t)}constructor(t){if(!i(t,Document))throw new TypeError(`JJD expects a Document instance. Got ${t} (${typeof t}). `);super(t)}get head(){return p.from(this.ref.head)}get body(){return p.from(this.ref.body)}};var ft="http://www.w3.org/2000/svg",v=class e extends x{static from(t){return new e(t)}static create(t,r){if(!s(t))throw n("tagName",'a string like "circle" or "path"',t);let o=document.createElementNS(ft,t,r);return new e(o)}constructor(t){if(!i(t,SVGElement))throw n("ref","an SVGElement",t);super(t)}getText(){return this.ref.textContent??""}setText(t){return this.ref.textContent=t,this}setFill(t){return this.setAttr("fill",t)}setStroke(t){return this.setAttr("stroke",t)}setStrokeWidth(t){return this.setAttr("stroke-width",String(t))}setViewBox(t,r,o,a){if(typeof t=="number"&&r!==void 0&&o!==void 0&&a!==void 0)return this.setAttr("viewBox",`${t} ${r} ${o} ${a}`);let d=t;return this.setAttr("viewBox",Array.isArray(d)?d.join(" "):d)}setWidth(t){return this.setAttr("width",String(t))}setHeight(t){return this.setAttr("height",String(t))}setD(t){return this.setAttr("d",Array.isArray(t)?t.join(" "):t)}setTransform(t){return this.setAttr("transform",t)}};u.wrap=function(t){if(s(t))return b.fromStr(t);if(!f(t))throw n("raw","an object",t);if(i(t,u))return t;if(i(t,HTMLElement))return p.from(t);if(i(t,SVGElement))return v.from(t);if(i(t,Element))return y.from(t);if(i(t,ShadowRoot))return E.from(t);if(i(t,DocumentFragment))return h.from(t);if(i(t,Document))return T.from(t);if(i(t,Text))return b.from(t);if(i(t,Node))return u.from(t);throw n("raw","a Node",t)};function pt(e,t,...r){let o=p.create(e).addChild(...r);return t&&o.setAttr(t),o}function ct(e){switch(j(e)){case"html":case"htm":case"md":return"fetch";case"css":return"style";case"js":case"mjs":case"cjs":return"script";default:throw new Error(`No 'as' attribute was specified and we failed to guess it from the URL: ${e}`)}}function Z(e,t,r){if(!s(e)){if(!i(e,URL))throw n("href","a string or URL",e);e=e.toString()}if(!["prefetch","preload"].includes(t))throw new RangeError(S("rel","'prefetch' or 'preload'",t));if(!r&&(r=ct(e),!r))throw new Error(`Could not guess 'as' attribute from URL: ${e}`);if(!["fetch","style","script"].includes(r))throw new RangeError(S("as","'fetch', 'style', or 'script'",r));return p.create("link").setAttr({href:e,rel:t,as:r})}function ht(...e){let t=Z(...e);return document.head.append(t.ref),t}async function z(e,t="text/*"){if(!s(t))throw n("mime","a string",t);let r=await fetch(e,{headers:{Accept:t}});if(!r.ok)throw new Error(`GET ${e} failed: ${r.status} ${r.statusText}`);return r.text()}async function mt(e){return await z(e,"text/html")}async function Q(e){return await z(e,"text/css")}async function lt(e){return await $(await Q(e))}function dt(e,t,r,o){if(!i(e,HTMLElement))throw n("instance","an HTMLElement",e);if(r!==o){let a=U(t);if(w(e,a))return e[a]=o,!0}return!1}async function gt(e,t,r){if(!s(e))throw n("name","a string",e);if(!g(t))throw n("constructor","a function",t);customElements.get(e)||(customElements.define(e,t,r),await customElements.whenDefined(e))}async function wt(e){if(e!==void 0){if(g(e)&&(e=await e()),e=await e,s(e))return e;if(i(e,h))return e.ref.cloneNode(!0);if(i(e,DocumentFragment))return e.cloneNode(!0);if(i(e,p))return e.ref instanceof HTMLTemplateElement?e.ref.content.cloneNode(!0):e.ref.outerHTML;if(i(e,HTMLElement))return e instanceof HTMLTemplateElement?e.content.cloneNode(!0):e.outerHTML;throw n("template","a string, JJHE, JJDF, HTMLElement, or DocumentFragment",e)}}async function Et(e){if(g(e)&&(e=await e()),e=await e,i(e,CSSStyleSheet))return e;if(s(e))return await $(e);throw n("style","a CSS string or CSSStyleSheet",e)}function yt(e){return W(e)?e.map(Et):[]}async function Tt(e,t){let[r,...o]=await Promise.all([wt(e),...yt(t)]);return{template:r,styles:o}}var M,H,J,q=class q{constructor(){m(this,M);m(this,H,[]);m(this,J)}static create(){return new q}setTemplate(t){return A(this,M,t),this}addStyles(...t){return c(this,H).push(...t),this}async getResolved(){return c(this,J)||A(this,J,Tt(c(this,M),c(this,H))),await c(this,J)}};M=new WeakMap,H=new WeakMap,J=new WeakMap;var B=q;var St=T.from(document);0&&(module.exports={JJD,JJDF,JJE,JJET,JJHE,JJN,JJSE,JJSR,JJT,ShadowMaster,addLinkPre,attr2prop,createLinkPre,cssToStyle,doc,fetchCss,fetchHtml,fetchStyle,fetchText,fileExt,h,keb2cam,keb2pas,nextAnimationFrame,pas2keb,registerComponent,sleep});
|
|
2
2
|
//# sourceMappingURL=bundle.min.cjs.map
|