@reactive-web-components/rwc 2.54.2 → 2.55.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/package.json +5 -5
- package/reactive-web-component.DGlwUwL8.js +873 -0
- package/reactive-web-component.DftPSBwc.umd.cjs +2 -0
- package/shared/utils/clean/component-stack.d.ts +1 -0
- package/shared/utils/clean/index.d.ts +1 -0
- package/shared/utils/html-elements/create-component-config.d.ts +39 -0
- package/shared/utils/html-elements/element-helper.d.ts +1 -6
- package/shared/utils/html-elements/element.d.ts +0 -4
- package/shared/utils/signal/signal.d.ts +1 -1
- package/reactive-web-component.FnhsCVIl.umd.cjs +0 -2
- package/reactive-web-component.o8AlN8rR.js +0 -892
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(o,y){typeof exports=="object"&&typeof module<"u"?y(exports):typeof define=="function"&&define.amd?define(["exports"],y):(o=typeof globalThis<"u"?globalThis:o||self,y(o.ReactiveComponent={}))})(this,function(o){"use strict";var Ze=Object.defineProperty;var Qe=(o,y,A)=>y in o?Ze(o,y,{enumerable:!0,configurable:!0,writable:!0,value:A}):o[y]=A;var d=(o,y,A)=>Qe(o,typeof y!="symbol"?y+"":y,A);const y=t=>t&&typeof t=="object"&&("classList"in t||"attributes"in t||"customAttributes"in t||"reactiveClassList"in t||"listeners"in t||"customListeners"in t||"children"in t||"effects"in t||"style"in t||Object.keys(t).some(e=>e.startsWith(".")||e.startsWith("@")||e.startsWith("$")))&&!("hostElement"in t),A=t=>t&&typeof t=="object"&&"hostElement"in t&&"append"in t&&"set"in t&&"addStyle"in t&&"setAttribute"in t&&"addClass"in t&&"addEffect"in t&&"addReactiveContent"in t&&"setReactiveContent"in t&&"clear"in t,F=(t,e,...s)=>{e&&e.apply(t,s)};let W=!0;const m=(...t)=>{W&&console.debug(["[rwc]",...t].join(" | "),...Array.from(t.join("").matchAll(/%c/gm)).map((e,s)=>s%2===0?"color:red":"color:inherit"))},M=t=>t.replace(/([A-Z])/gm,e=>`-${e.toLowerCase()}`),X=t=>t.replace(/-(\w)/gm,(e,s)=>s.toUpperCase()),L=(t,...e)=>{if(!W)return;const s={r:"color: #ff0000",g:"color: #00ff00",b:"color: #0000ff",y:"color: #ffff00",p:"color: #800080",c:"color: #00ffff",o:"color: #ffa500",w:"color: #808080"},n=t.match(/@[rgbpycow]/g)||[],r=n.map(l=>{const c=l.slice(1);return s[c]||"color: inherit"});let i=t;n.forEach(l=>{const c=new RegExp(`\\${l}([^\\s,]+)`,"g");i=i.replace(c,"%c$1")}),console.log(i,...r,...e)},Et=()=>{W=!0},Z=()=>{W=!1};Z();const j=[];let q=!1;const yt=t=>{q=t},D=new Map,O=new WeakMap,_=[],k=[];function v(t,e){const s=new Set;let n=(e==null?void 0:e.signalCompareFn)||(()=>!0);function r(){var l;const i=_[_.length-1];if(i&&!("fake"in i&&i.fake)){const c=O.get(i),u=c==null?void 0:c.parent;if(u){const h=O.get(u);h==null||h.cleanupFns.add(()=>{s.delete(i)})}"selfCleanup"in i||(i.selfCleanup=[]),i.selfCleanup.push(()=>{s.delete(i)}),s.add(i),q&&((l=D.get(i.effectId))==null||l.signals.push(r))}return t}return r.signalId=`${(e==null?void 0:e.name)||""}_${Math.random().toString(36).substring(2,15)}`,r.getSubscribers=()=>[...s],r.setCompareFn=function(i){return n=i,r},r.clearSubscribers=function(){s.clear()},r.peek=function(){return Object.freeze(t)},r.initValue=Object.freeze(t),r.oldValue=Object.freeze(t),r.forceSet=function(i){r.oldValue=Object.freeze(t),t=i,s.forEach(l=>{setTimeout(()=>{const c=l,u=O.get(c);u&&u.cleanupFns.size>0&&(u.cleanupFns.forEach(h=>h()),u.cleanupFns.clear()),k.push(c),c(),k.pop()})})},r.set=function(i,l=n){t!==i&&l(t,i)&&r.forceSet(i)},r.update=function(i){r.set(i(t))},r.pipe=(i,l)=>{const c=v(null);return b(()=>{const u=r();b(()=>{const h=i(u);h instanceof Promise?h.then(p=>c.set(p)):w(h)?b(()=>c.set(h())):c.set(h)},l)}),c},r}function b(t,e){var l;const s=`${(e==null?void 0:e.name)||""}_${Math.random().toString(36).substring(2,15)}`;m("current effect",`%c${s}%c`);const n=t;t=()=>(m("current effect callback",`%c${s}%c`),n()),"fake"in n&&n.fake&&(t.fake=!0),t.effectId=s;const r=k[k.length-1];q&&D.set(s,{signals:[],parent:(r==null?void 0:r.effectId)||null}),O.has(t)||O.set(t,{cleanupFns:new Set});const i=O.get(t);r?i.parent=r:delete i.parent,k.push(t),_.push(t),t(),(l=j[j.length-1])==null||l.call(j,t),_.pop(),k.pop()}const w=t=>!!t&&["object","function"].includes(typeof t)&&"set"in t&&"oldValue"in t&&"update"in t&&"forceSet"in t;function St(t,...e){const s=v("");return b(()=>{const n=e.map(i=>w(i)?String(i()):String(i)),r=[t[0]];n.forEach((i,l)=>{r.push(i,t[l+1])}),s.set(r.join(""))}),s}function wt(t,e){const s=v(e??null),n=r=>s.set(r);return t instanceof Promise?t.then(n):typeof t=="function"&&b(()=>{const r=t();r instanceof Promise?r.then(n):w(r)?b(()=>n(r())):n(r)}),s}function vt(t,e){let s=t(),n=e();b(()=>{const r=t(),i=e();r!==i&&(r!==s?e.set(r):i!==n&&t.set(i)),s=r,n=i})}function gt(...t){let e=t.map(n=>n());const s=v(e);return t.forEach((n,r)=>{b(()=>{const i=()=>e.filter(l=>l!==void 0).length;i()===t.length&&(e=Array.from(e).fill(void 0)),e[r]=n(),i()===t.length&&s.set([...e])})}),s}const At=(...t)=>{const e=v([]);return b(()=>{e.set(t.map(s=>s()))}),e};class R extends HTMLElement{constructor(s=!1){super();d(this,"isSlotLazyLoading",!1);d(this,"slotTemplate");d(this,"slotContext");d(this,"rootStyle");d(this,"modelValue");d(this,"providers");d(this,"appendAllSlotContent");d(this,"allSlotContent",[]);d(this,"slotContent",{});d(this,"htmlSlotContent",{});d(this,"shadow");d(this,"injects",{});this.shadow=this.attachShadow({mode:s?"closed":"open"})}appendChild(s,n=!0){var r;if(this.isSlotLazyLoading&&n){if(s instanceof HTMLElement){const i=s.slot||"default";this.htmlSlotContent[i]||(this.htmlSlotContent[i]=[]),(r=this.htmlSlotContent[i])==null||r.push(s)}}else return super.appendChild(s)}appendSlotContent(){var s;(s=this.appendAllSlotContent)==null||s.call(this)}inject(s){return m("%cinject%c",s),this.injects[s]||(this.injects[s]=v(null)),this.injects[s]}checkInjects(){Object.entries(this.injects).forEach(([s,n])=>{m("%cinject%c",`%c${s}%c`,"from BaseElement (dispatch event)"),this.shadow.dispatchEvent(new CustomEvent(s,{detail:{context:s,callback:r=>b(()=>{n.set(r())})},bubbles:!0,composed:!0}))})}setReactiveValue(s){this.modelValue=s}}d(R,"observedAttributes",[]),d(R,"renderTagName",""),d(R,"styles");const Lt=t=>"render"in t&&"setReactiveValue"in t,Rt="handleSlotContext",Q="onConnected",Y=t=>typeof t=="string"?t:JSON.stringify(t),Tt=t=>{const e=document.createElement("span");return e.textContent=Y(t),e},K=(t,e)=>(t.appendChild(Tt(e)),t),jt=(t,e)=>(t.innerHTML="",K(t,e)),x=t=>{const e=document.createElement("span");return b(()=>{const s=t();e.textContent=Y(s)}),e};class tt{constructor(e){d(this,"wrapper");d(this,"hostElement");d(this,"append",(...e)=>(e.forEach(s=>{this.wrapper.appendChild(s.hostElement),Q in s.hostElement&&setTimeout(()=>{var n,r;(r=(n=s.hostElement).onConnected)==null||r.call(n,s,s.hostElement)})}),this));d(this,"set",(...e)=>{this.clear();const s=document.createDocumentFragment();return e.forEach(n=>{s.appendChild(n.hostElement)}),this.wrapper.appendChild(s),this});d(this,"removeChild",(...e)=>(e.forEach(s=>{Array.from(this.wrapper.childNodes.values()).some(n=>n===s.hostElement)&&this.wrapper.removeChild(s.hostElement)}),this));d(this,"addHtmlContent",e=>(K(this.wrapper,e),this));d(this,"setHtmlContent",e=>(jt(this.wrapper,e),this));d(this,"setAttribute",(e,s)=>{let n;if(typeof s=="boolean"&&!(this.wrapper instanceof R))if(s)n="";else{this.removeAttribute(e);const r=e.toLowerCase();return r in this.wrapper&&(this.wrapper[r]=null),this}else typeof s!="string"?n=JSON.stringify(s):n=s;if(this.wrapper.setAttribute(M(e),n),!(this.wrapper instanceof R)){const r=e.toLowerCase();r in this.wrapper&&(this.wrapper[r]=s)}return this});d(this,"setCustomAttribute",(e,s)=>{let n;return typeof s!="string"?n=JSON.stringify(s):n=s,this.wrapper.setAttribute(M(e),n),this});d(this,"setReactiveAttribute",(e,s)=>(b(()=>this.setAttribute(e,s())),this));d(this,"setReactiveCustomAttribute",(e,s)=>(b(()=>this.setCustomAttribute(e,s())),this));d(this,"removeAttribute",e=>(this.wrapper.removeAttribute(M(e)),this));d(this,"addStyle",e=>(Object.entries(e).forEach(([s,n])=>{const r=s.startsWith("--");typeof n=="function"?this.addEffect(()=>{if(r){const i=String(n()||"");this.wrapper.style.setProperty(s,i)}else this.wrapper.style[s]=n()}):typeof n=="string"&&(r?this.wrapper.style.setProperty(s,n):this.wrapper.style[s]=n)}),this));d(this,"onConnected",e=>(Reflect.defineProperty(this.wrapper,Q,{get(){return e}}),this));d(this,"addClass",(...e)=>(e.forEach(s=>{typeof s=="string"?this.wrapper.classList.add(...s.split(" ").flatMap(n=>n.split(`
|
|
2
|
+
`)).map(n=>n.trim()).filter(Boolean)):(()=>{let n=null;this.addEffect(()=>{const r=s();r.length>0&&(n?this.replaceClass(n,r):this.addClass(r),n=r)})})()}),this));d(this,"setClass",(...e)=>(this.wrapper.classList.remove(...this.wrapper.classList),this.wrapper.classList.add(...e),this));d(this,"addReactiveClass",e=>(Object.keys(e).forEach(s=>{b(()=>{e[s]()?this.addClass(s):this.removeClass(s)})}),this));d(this,"removeClass",(...e)=>(this.wrapper.classList.remove(...e),this));d(this,"replaceClass",(e,s)=>(this.wrapper.classList.replace(e,s),this));d(this,"addEffect",e=>(b(()=>e(this,this.hostElement)),this));d(this,"addReactiveContent",e=>(this.wrapper.appendChild(x(e)),this));d(this,"setReactiveContent",e=>(this.clear(),this.wrapper.appendChild(x(e)),this));d(this,"clear",()=>(this.wrapper.innerHTML="",this));this.wrapper=e,this.hostElement=e}test(){console.log("test")}addEventlistener(e,s,n=!1){return this.wrapper.addEventListener(e,r=>s(r,this,this.wrapper),n),this}}class Ot extends tt{constructor(){super(...arguments);d(this,"setReactiveValue",s=>(this.wrapper instanceof R&&this.wrapper.setReactiveValue(s),this));d(this,"setSlotTemplate",s=>{const n=this.wrapper.slotTemplate;return n&&Object.entries(s).forEach(([r,i])=>{n[r]=i}),this})}}const kt=()=>()=>{},et=t=>new Ot(t),st=t=>new tt(t),nt=(t,...e)=>({classList:[...t.map(s=>s.trim()).filter(Boolean),...e]}),It=(t,...e)=>nt(t,...e),G=(t,e)=>{if(!e)return t;const s=Object.keys(e||{}).filter(n=>n.startsWith(".")||n.startsWith("@")||n.startsWith("$"));return s.filter(n=>n.startsWith(".")).forEach(n=>{e!=null&&e.attributes||(e.attributes={}),e.attributes[n.slice(1)]=e[n]}),s.filter(n=>n.startsWith("@")).forEach(n=>{e!=null&&e.listeners||(e.listeners={});const r=n.slice(1);e.listeners[r]=e[n]}),s.filter(n=>n.startsWith("$")).forEach(n=>{e!=null&&e.effects||(e.effects=[]),e.effects.push(e[n])}),at(t,e.classList),ct(t,e.style),ht(t,e.attributes),lt(t,e.reactiveClassList),it(t,e.customAttributes),rt(t,e.children),ot(t,e.effects),N(t,e.listeners),N(t,e.customListeners),t},N=(t,e)=>{e&&Object.entries(e).forEach(([s,n])=>{typeof n=="function"&&t.addEventlistener(s,n)})},ot=(t,e)=>e==null?void 0:e.forEach(s=>t.addEffect(s)),rt=(t,e)=>$(t,...e||[]),it=(t,e)=>{const s=e;s&&Object.keys(s).forEach(n=>{w(s[n])?t.setReactiveCustomAttribute(n,s[n]):typeof s[n]=="function"?t.addEffect(()=>{t.setCustomAttribute(n,s[n]())}):t.setCustomAttribute(n,s[n])})},at=(t,e)=>t.addClass(...e||[]),lt=(t,e)=>t.addReactiveClass(e||{}),ct=(t,e)=>t.addStyle(e||{}),ht=(t,e)=>{const s=e,n=(r,i)=>{i&&(w(i)?t.setReactiveAttribute(r,i):typeof i=="function"?t.addEffect(()=>{t.setAttribute(r,i())}):t.setAttribute(r,i))};s&&Object.keys(s).forEach(r=>{n(r,s[r])})},$=(t,...e)=>(e.forEach(s=>{typeof s=="string"?s.trim().length>0&&t.addHtmlContent(s):w(s)?t.addReactiveContent(s):t.append(s)}),t),I=(t,e)=>{const s=document.createElement(t),n=st(s);return G(n,e)},B=(t,e)=>{const[s,...n]=t.split(" ").map(i=>i.trim()),r=I(s,e);return n.length>0&&r.addClass(...n),(...i)=>$(r,...i.filter(Boolean).flat().flatMap(l=>typeof l=="function"&&!w(l)?g(()=>l(r)):l))},g=t=>I("div").addStyle({display:"contents"}).addEffect(e=>{const s=t(),n=[];Array.isArray(s)?n.push(...s):n.push(s),e.clear(),$(e,...n)}),Mt=(t,e,s)=>{const n=I("div").addStyle({display:"contents"}),r=new Map,i=new Map;let l=[];const c=new Set;let u=t.peek();const h=p=>{c.delete(p),r.delete(p),i.delete(p)};return b(()=>{const p=t();l=p.map(e).map(f=>typeof f=="string"?f:f.toString());const S=Array.from(n.hostElement.children);m("containerChildren",S,l),S.forEach(f=>{const E=f.dataset.key;l.includes(E)||(m("remove element",E,f),f.remove(),h(E))}),l.forEach(f=>{var P,T;const E=p[l.indexOf(f)];r.has(f)?JSON.stringify(E)!==JSON.stringify(u[l.indexOf(f)])&&((P=n.hostElement.querySelector(`[data-key="${f}"]`))==null||P.remove(),(T=r.get(f))==null||T.set(Math.random().toString(36).substring(2,15)),i.set(f,()=>s(E,l.indexOf(f),p).setCustomAttribute("data-key",f))):(m("create new element",f,E),r.set(f,v(Math.random().toString(36).substring(2,15))),i.set(f,()=>s(E,l.indexOf(f),p).setCustomAttribute("data-key",f)))}),u=[...p.map(f=>({...f}))];const C=()=>{r.forEach((f,E)=>{m("key from setTimeout foreach currItemSignalMap",E),c.has(E)||(c.add(E),b(()=>{var bt;f();const P=l.indexOf(E),T=(bt=i.get(E))==null?void 0:bt();T&&(m("call effect from setTimeout",E,T.hostElement),P<=n.hostElement.children.length-1?n.hostElement.insertBefore(T.hostElement,n.hostElement.children[P]):n.hostElement.append(T.hostElement))}))})};Promise.resolve().then(()=>C())}),n},$t=t=>{let e=[I("div")],s=!1;return b(()=>{var i,l;const n=t();s=Array.isArray(n);const r=[];r.push(...[n].flat()),r.length===0&&r.push(I("div").addStyle({display:"none"}).setAttribute("id","empty_template"));try{m("newReactiveComponent.map",r.map(c=>{var u;return m("newReactiveComponent hostElement",c.hostElement),(u=c.hostElement)==null?void 0:u.id})),m("currComponent[0].hostElement?.id",(i=e[0].hostElement)==null?void 0:i.id,e),(l=e[0].hostElement)==null||l.replaceWith(...r.map(c=>c.hostElement)),e.slice(1).forEach(c=>{var u;return(u=c.hostElement)==null?void 0:u.remove()}),e=r}catch(c){console.error(c)}}),s?e:e[0]},Ht=t=>Rt in t,Pt=t=>{const e=B("div")().addStyle({display:"contents"}),s=n=>(e.hostElement.innerHTML=n,e);return typeof t=="string"?s(t):e.addEffect(()=>{s(t())}),e},V=(t,e,s)=>t?g(e):s?g(s):B("div")().setAttribute("id","empty_div_renderIf").addStyle({display:"none"}),dt=(t,e,s)=>g(()=>V(!!t(),e,s)),Ft=(t,e,s)=>typeof t=="boolean"?V(t,e,s):dt(t,e,s),U=(t,e)=>{const s=g(e);return typeof t=="boolean"?[s].flat().forEach(n=>n.hostElement.style.display=t?"block":"none"):b(()=>{const n=t()?"block":"none";[s].flat().forEach(r=>r.hostElement.style.display=n)}),s},Wt=(t,e,s)=>{const n=[U(t,e)].flat();return s&&n.push(...[U(()=>typeof t=="boolean"?!t:!t(),s)].flat()),g(()=>n)},ft=(t,e)=>{m("createCustomElement",t);const s=document.createElement(t),n=et(s);return G(n,e)},ut=(t,e)=>{const s=t.split(" ").slice(1).map(r=>r.trim()),n=ft(t.split(" ")[0],e);return Array.isArray(s)&&s.length>0&&n.addClass(...s),(...r)=>{L("@rcreateCustomEl content",t,r);const i=r.filter(Boolean).flat().flatMap(l=>typeof l=="function"&&!w(l)?g(()=>l(n)):l);return n.hostElement.allSlotContent=i,n.hostElement.slotContent=i.filter(A).reduce((l,c)=>{const u=c.hostElement.getAttribute("slot")||"default";return l[u]||(l[u]=[]),l[u].push(c),l},{}),n.hostElement.appendAllSlotContent=()=>$(n,...i),n}},pt=(t,e,s)=>ut(`${t.renderTagName}${e&&typeof e=="string"?" "+e:""}`,y(e)?e:e&&typeof e=="string"?s:void 0),_t=()=>{const t=()=>{};return t.oldValue=null,t},Bt=()=>({}),Jt=(t,e,s)=>{const n=e?Ct(e,s)(t):t;return(r,...i)=>{const l=[...i];return r&&!y(r)&&l.unshift(r),pt(n,y(r)?r:{})(...l)}},a={};["div","span","section","input","button","table","tr","td","th","ul","li","ol","form","label","select","option","textarea","img","a","p","h1","h2","h3","h4","h5","h6","br","hr","pre","code","nav","header","footer","main","aside","article","figure","figcaption","blockquote","cite","small","strong","em","b","i","u","s","sub","sup","mark","del","ins","details","summary","progress","meter","audio","video","canvas","slot"].forEach(t=>{a[t]=(e,...s)=>{let n=[...s];return e&&!y(e)&&(n=[e].concat(n)),B(t,y(e)?e:{})(...n)}});const mt=a.div,zt=a.span,qt=a.section,Dt=a.input,Gt=a.button,Nt=a.table,Vt=a.tr,Ut=a.td,Xt=a.th,Zt=a.ul,Qt=a.li,Yt=a.ol,Kt=a.form,xt=a.label,te=a.select,ee=a.option,se=a.textarea,ne=a.img,oe=a.a,re=a.p,ie=a.h1,ae=a.h2,le=a.h3,ce=a.h4,he=a.h5,de=a.h6,fe=a.br,ue=a.hr,pe=a.pre,me=a.code,Ce=a.nav,be=a.header,Ee=a.footer,ye=a.main,Se=a.aside,we=a.article,ve=a.figure,ge=a.figcaption,Ae=a.blockquote,Le=a.cite,Re=a.small,Te=a.strong,je=a.em,Oe=a.b,ke=a.i,Ie=a.u,Me=a.s,$e=a.sub,He=a.sup,Pe=a.mark,Fe=a.del,We=a.ins,_e=a.details,Be=a.summary,Je=a.progress,ze=a.meter,qe=a.audio,De=a.video,Ge=a.canvas,Ne=a.slot,Ve=t=>e=>t(e).addClass(...e.classList??[]).addReactiveClass(e.reactiveClassList??{}),J="eventProps",z="EVENT_CONFIG",H="observedAttributes",Ue=()=>(t,e)=>{Reflect.get(t,H)||Reflect.defineProperty(t,H,{value:[]}),Reflect.get(t,H).push(M(e))},Xe=t=>(e,s)=>{Reflect.get(e,J)||Reflect.defineProperty(e,J,{value:[]}),Reflect.get(e,z)||Reflect.defineProperty(e,z,{value:{}}),Reflect.get(e,z)[s]={bubbles:(t==null?void 0:t.bubbles)??!1,composed:(t==null?void 0:t.composed)??!1},Reflect.get(e,J).push(s)},Ct=(t,e=!1)=>s=>{m(t,"start register static attr",s.prototype[H]);const n=[];if(s.styles){const i=s.styles,l=[];Array.isArray(i)?l.push(...i):l.push(i),l.forEach(c=>{const u=new CSSStyleSheet;u.replaceSync(c),n.push(u);const h=new CSSStyleSheet;h.replaceSync(c.slice(c.indexOf("@property"))),document.adoptedStyleSheets.push(h)})}class r extends s{constructor(...c){m("constructor",`%c${t}%c`);super(e,...c);d(this,"effectCleanupHandleEvent",c=>{this.effects.push(c)});d(this,"effects",[]);L("@osheet",n),n.length>0&&this.shadow.adoptedStyleSheets.push(...n)}render(){m("rwc: render from new class");let c=mt();const u=()=>{m("wrapperEffectCallback"),c=s.prototype.render.call(this)};return u.fake=!0,b(u),c}attributeChangedCallback(c,u,h){m("%cAttribute has changed.%c",`%c${c}%c`,`oldValue: ${u}, newValue: ${h}`,`%c${t}%c`);try{h=JSON.parse(h)}catch{}const p=X(c);if(p in this&&w(this[p])){const S=this[p];h===null?(S.set(S.initValue),this.removeAttribute(c)):S.set(h)}F(this,s.prototype.attributeChangedCallback,c,u,h)}connectedCallback(){var u;m("rwc: connectedCallback"),m("connectedCallback",`%c${t}%c`,this),this.providers&&Object.keys(this.providers).length>0&&(m("WRAPPER for providers",t),Object.entries(this.providers).forEach(([h,p])=>{m("register provider",h,p()),this.addEventListener(h,S=>{var f;m("send provider",h,p());const C=S;((f=C.detail)==null?void 0:f.context)===h&&(C.stopPropagation(),C.detail.callback(p))})})),this.checkInjects(),(u=s.prototype[J])==null||u.forEach(h=>{this[h]=p=>{const S=s.prototype[z][h],{bubbles:C,composed:f}=S;w(p)?b(()=>{L("@oemit reactive value",p()),this.dispatchEvent(new CustomEvent(h,{detail:p(),bubbles:C,composed:f}))}):(L("@oemit value",p),this.dispatchEvent(new CustomEvent(h,{detail:p,bubbles:C,composed:f})))}}),m("start render",`%c${t}%c`,t);const c=()=>{m("rwc: insertRenderTemplate"),j.push(this.effectCleanupHandleEvent);const h=this.render();this.shadow.appendChild(h.hostElement),F(this,s.prototype.connectedCallback),this.appendSlotContent(),j.pop()};if(this.rootStyle&&!s.styles){const h=C=>C instanceof Promise||Array.isArray(C)&&C.every(f=>f instanceof Promise),p=this.rootStyle,S=C=>{const f=new CSSStyleSheet;f.replaceSync(C),this.shadow.adoptedStyleSheets.push(f);const E=new CSSStyleSheet;E.replaceSync(C.slice(C.indexOf("@property"))),document.adoptedStyleSheets.push(E)};if(h(p)){const C=[];Array.isArray(p)?C.push(...p):C.push(p),Promise.all(C).then(f=>f.forEach(E=>S(E.default))).then(()=>c())}else{const C=[];Array.isArray(p)?C.push(...p):C.push(p),C.forEach(f=>S(f)),c()}}else c();this.slotContext&&Object.keys(this.slotContext).length>0&&this.shadow.querySelectorAll("slot").forEach(h=>{m(this.slotContext,this.slotContext&&this.slotContext[h.name]),L("@bslot element",h,`name:${h.name};`,h.assignedElements()),h.assignedElements().forEach(p=>{const S=this.slotContext[h.name];this.slotContext&&w(S)&&(L("@oslot element",h,`name:${h.name};`,h.assignedElements()),b(()=>{p.dispatchEvent(new CustomEvent("handleSlotContext",{detail:S()}))}))})})}disconnectedCallback(){this.shadow.replaceChildren(),this.replaceChildren(),F(this,s.prototype.disconnectedCallback),this.effects.forEach(c=>{var u;(u=c.selfCleanup)==null||u.forEach(h=>h())}),this.effects=[]}}return d(r,"observedAttributes",s.prototype[H]??[]),d(r,"renderTagName",t),r.toString=()=>t,customElements.get(t)?console.error(`название тега ${t} повторяется, компонент ${s.name} не зарегистрирован`):customElements.define(t,r),s.renderTagName=t,s};o.BaseElement=R,o.a=oe,o.addAttributeList=ht,o.addClassList=at,o.addCustomAttributes=it,o.addReactiveClassList=lt,o.addStyleList=ct,o.appendContentItem=$,o.article=we,o.aside=Se,o.audio=qe,o.b=Oe,o.bindReactiveSignals=vt,o.blockquote=Ae,o.br=fe,o.button=Gt,o.camelToKebab=M,o.canvas=Ge,o.checkCall=F,o.cite=Le,o.classList=nt,o.cls=It,o.code=me,o.colorLog=L,o.combineLatest=At,o.component=Ct,o.createComponent=Ve,o.createCustom=pt,o.createCustomEl=ut,o.createCustomElement=ft,o.createEl=B,o.createElement=I,o.createSignal=wt,o.customElementHelpers=et,o.defineSlotTemplate=Bt,o.del=Fe,o.details=_e,o.disableLogs=Z,o.div=mt,o.effect=b,o.effectMap=D,o.elementHelpers=st,o.em=je,o.enableLogs=Et,o.event=Xe,o.eventEmitter=kt,o.figcaption=ge,o.figure=ve,o.footer=Ee,o.forkJoin=gt,o.form=Kt,o.getList=Mt,o.getSignalContent=g,o.h1=ie,o.h2=ae,o.h3=le,o.h4=ce,o.h5=he,o.h6=de,o.header=be,o.hr=ue,o.i=ke,o.img=ne,o.initComponent=G,o.input=Dt,o.ins=We,o.isBaseElement=Lt,o.isComponentConfig=A,o.isComponentInitConfig=y,o.isReactiveSignal=w,o.isSlotTemplate=Ht,o.kebabToCamel=X,o.label=xt,o.li=Qt,o.main=ye,o.mark=Pe,o.meter=ze,o.nav=Ce,o.newEventEmitter=_t,o.ol=Yt,o.option=ee,o.p=re,o.pre=pe,o.progress=Je,o.projectLog=m,o.property=Ue,o.renderIf=V,o.rs=St,o.rxRenderIf=dt,o.s=Me,o.section=qt,o.select=te,o.setChildren=rt,o.setEffectDebugEnabled=yt,o.setEffects=ot,o.setListeners=N,o.show=Wt,o.showIf=U,o.signal=v,o.signalComponent=$t,o.slot=Ne,o.small=Re,o.span=zt,o.strong=Te,o.sub=$e,o.summary=Be,o.sup=He,o.table=Nt,o.td=Ut,o.textarea=se,o.th=Xt,o.tr=Vt,o.u=Ie,o.ul=Zt,o.unsafeHtml=Pt,o.useCustomComponent=Jt,o.video=De,o.when=Ft,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const componentStackFunc: ((e: () => void) => void)[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './component-stack';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ComponentConfig, CustomComponentConfig, ExtraHTMLElement } from '../../types/element';
|
|
2
|
+
import { ReactiveSignal } from '../signal';
|
|
3
|
+
export declare const getTextContent: (content: string | unknown) => string;
|
|
4
|
+
export declare const textContentWrapper: (content: string | unknown) => HTMLSpanElement;
|
|
5
|
+
export declare const addHtmlContent: <T extends HTMLElement = HTMLElement>(htmlElement: T, content: string | unknown) => T;
|
|
6
|
+
export declare const setHtmlContent: <T extends HTMLElement = HTMLElement>(htmlElement: T, content: string | unknown) => T;
|
|
7
|
+
export declare const htmlEffectWrapper: (content: ReactiveSignal<unknown>) => HTMLSpanElement;
|
|
8
|
+
export declare class HtmlComponentConfig<T extends ExtraHTMLElement> implements ComponentConfig<T> {
|
|
9
|
+
protected wrapper: T;
|
|
10
|
+
hostElement: T;
|
|
11
|
+
constructor(wrapper: T);
|
|
12
|
+
append: ComponentConfig<T>["append"];
|
|
13
|
+
set: ComponentConfig<T>["set"];
|
|
14
|
+
removeChild: ComponentConfig<T>["removeChild"];
|
|
15
|
+
addHtmlContent: ComponentConfig<T>["addHtmlContent"];
|
|
16
|
+
setHtmlContent: ComponentConfig<T>["setHtmlContent"];
|
|
17
|
+
test(): void;
|
|
18
|
+
addEventlistener(eventName: string, cb: any, options?: boolean | AddEventListenerOptions): this;
|
|
19
|
+
setAttribute: ComponentConfig<T>["setAttribute"];
|
|
20
|
+
setCustomAttribute: ComponentConfig<T>["setCustomAttribute"];
|
|
21
|
+
setReactiveAttribute: ComponentConfig<T>["setReactiveAttribute"];
|
|
22
|
+
setReactiveCustomAttribute: ComponentConfig<T>["setReactiveCustomAttribute"];
|
|
23
|
+
removeAttribute: ComponentConfig<T>["removeAttribute"];
|
|
24
|
+
addStyle: ComponentConfig<T>["addStyle"];
|
|
25
|
+
onConnected: ComponentConfig<T>["onConnected"];
|
|
26
|
+
addClass: ComponentConfig<T>["addClass"];
|
|
27
|
+
setClass: ComponentConfig<T>["setClass"];
|
|
28
|
+
addReactiveClass: ComponentConfig<T>["addReactiveClass"];
|
|
29
|
+
removeClass: ComponentConfig<T>["removeClass"];
|
|
30
|
+
replaceClass: ComponentConfig<T>["replaceClass"];
|
|
31
|
+
addEffect: ComponentConfig<T>["addEffect"];
|
|
32
|
+
addReactiveContent: ComponentConfig<T>["addReactiveContent"];
|
|
33
|
+
setReactiveContent: ComponentConfig<T>["setReactiveContent"];
|
|
34
|
+
clear: ComponentConfig<T>["clear"];
|
|
35
|
+
}
|
|
36
|
+
export declare class CustomHtmlComponentConfig<T extends ExtraHTMLElement> extends HtmlComponentConfig<T> implements CustomComponentConfig<T> {
|
|
37
|
+
setReactiveValue: CustomComponentConfig<T>["setReactiveValue"];
|
|
38
|
+
setSlotTemplate: CustomComponentConfig<T>["setSlotTemplate"];
|
|
39
|
+
}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { ComponentConfig, ComponentContent, ComponentInitConfig, ConfigAttribute, ConfigChildren, ConfigClassList, ConfigCustomAttribute, ConfigEffect, ConfigListeners, ConfigReactiveClassList, ConfigStyle, CustomComponentConfig, ExtraHTMLElement } from '../../types/element';
|
|
2
|
-
import { ReactiveSignal } from '../signal';
|
|
3
2
|
export declare const eventEmitter: () => () => void;
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const textContentWrapper: (content: string | unknown) => HTMLSpanElement;
|
|
6
|
-
export declare const addHtmlContent: <T extends HTMLElement = HTMLElement>(htmlElement: T, content: string | unknown) => T;
|
|
7
|
-
export declare const setHtmlContent: <T extends HTMLElement = HTMLElement>(htmlElement: T, content: string | unknown) => T;
|
|
8
|
-
export declare const htmlEffectWrapper: (content: ReactiveSignal<unknown>) => HTMLSpanElement;
|
|
3
|
+
export declare const customElementHelpers: <T extends ExtraHTMLElement>(wrapper: T) => CustomComponentConfig<T>;
|
|
9
4
|
export declare const elementHelpers: <T extends ExtraHTMLElement>(wrapper: T) => ComponentConfig<T>;
|
|
10
5
|
export declare const classList: (strings: TemplateStringsArray, ...args: (string | (() => string))[]) => {
|
|
11
6
|
classList: (string | (() => string))[];
|
|
@@ -3,10 +3,6 @@ import { ReactiveSignal } from '../signal';
|
|
|
3
3
|
export declare const createElement: <K extends HtmlTagName>(tagName: K, config?: ComponentInitConfig<HTMLElementTagNameMap[K]>) => ComponentConfig<HTMLElementTagNameMap[K]>;
|
|
4
4
|
export declare const createEl: <K extends HtmlTagName>(tagName: `${K} ${string}` | K, config?: ComponentInitConfig<HTMLElementTagNameMap[K]>) => (...content: ChildrenContent<HTMLElementTagNameMap[K]>[]) => ComponentConfig<HTMLElementTagNameMap[K]>;
|
|
5
5
|
export declare const getSignalContent: (cb: CompFuncContent) => ComponentConfig<HTMLDivElement>;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated
|
|
8
|
-
*/
|
|
9
|
-
export declare const getReactiveTemplate: <Cb extends CompFuncContent>(cb: Cb) => ReturnType<typeof cb>;
|
|
10
6
|
/**
|
|
11
7
|
* Создает реактивный список элементов, который автоматически обновляется при изменении массива данных.
|
|
12
8
|
* Поддерживает эффективное обновление DOM с минимальными перерисовками.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IsPromise, IsPromiseFunction, UnwrapPromise } from './helpers.types';
|
|
2
2
|
import { CompareFn, ReactiveSignal, UnwrapSignal } from './signal.type';
|
|
3
|
-
export declare
|
|
3
|
+
export declare const setEffectDebugEnabled: (enabled: boolean) => void;
|
|
4
4
|
export declare const effectMap: Map<string, {
|
|
5
5
|
signals: Array<ReactiveSignal<any>>;
|
|
6
6
|
parent: string | null;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(o,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(o=typeof globalThis<"u"?globalThis:o||self,p(o.ReactiveComponent={}))})(this,function(o){"use strict";var Ne=Object.defineProperty;var Ve=(o,p,L)=>p in o?Ne(o,p,{enumerable:!0,configurable:!0,writable:!0,value:L}):o[p]=L;var E=(o,p,L)=>Ve(o,typeof p!="symbol"?p+"":p,L);const p=t=>t&&typeof t=="object"&&("classList"in t||"attributes"in t||"customAttributes"in t||"reactiveClassList"in t||"listeners"in t||"customListeners"in t||"children"in t||"effects"in t||"style"in t||Object.keys(t).some(e=>e.startsWith(".")||e.startsWith("@")||e.startsWith("$")))&&!("hostElement"in t),L=t=>t&&typeof t=="object"&&"hostElement"in t&&"append"in t&&"set"in t&&"addStyle"in t&&"setAttribute"in t&&"addClass"in t&&"addEffect"in t&&"addReactiveContent"in t&&"setReactiveContent"in t&&"clear"in t,W=(t,e,...n)=>{e&&e.apply(t,n)};let _=!0;const f=(...t)=>{_&&console.debug(["[rwc]",...t].join(" | "),...Array.from(t.join("").matchAll(/%c/gm)).map((e,n)=>n%2===0?"color:red":"color:inherit"))},M=t=>t.replace(/([A-Z])/gm,e=>`-${e.toLowerCase()}`),Q=t=>t.replace(/-(\w)/gm,(e,n)=>n.toUpperCase()),R=(t,...e)=>{if(!_)return;const n={r:"color: #ff0000",g:"color: #00ff00",b:"color: #0000ff",y:"color: #ffff00",p:"color: #800080",c:"color: #00ffff",o:"color: #ffa500",w:"color: #808080"},s=t.match(/@[rgbpycow]/g)||[],i=s.map(c=>{const d=c.slice(1);return n[d]||"color: inherit"});let l=t;s.forEach(c=>{const d=new RegExp(`\\${c}([^\\s,]+)`,"g");l=l.replace(d,"%c$1")}),console.log(l,...i,...e)},bt=()=>{_=!0},Y=()=>{_=!1};Y();let pt=!1;const Et=new Map,O=new WeakMap,B=[],w=[];function A(t,e){const n=new Set;let s=(e==null?void 0:e.signalCompareFn)||(()=>!0);function i(){const l=B[B.length-1];if(l&&!("fake"in l&&l.fake)){const c=O.get(l),d=c==null?void 0:c.parent;if(d){const r=O.get(d);r==null||r.cleanupFns.add(()=>{n.delete(l)})}n.add(l)}return t}return i.signalId=`${(e==null?void 0:e.name)||""}_${Math.random().toString(36).substring(2,15)}`,i.getSubscribers=()=>[...n],i.setCompareFn=function(l){return s=l,i},i.clearSubscribers=function(){n.clear()},i.peek=function(){return Object.freeze(t)},i.initValue=Object.freeze(t),i.oldValue=Object.freeze(t),i.forceSet=function(l){i.oldValue=Object.freeze(t),t=l,n.forEach(c=>Promise.resolve(c).then(d=>{const r=O.get(d);r&&r.cleanupFns.size>0&&(r.cleanupFns.forEach(h=>h()),r.cleanupFns.clear()),w.push(d),d(),w.pop()}))},i.set=function(l,c=s){t!==l&&c(t,l)&&i.forceSet(l)},i.update=function(l){i.set(l(t))},i.pipe=(l,c)=>{const d=A(null);return b(()=>{const r=i();b(()=>{const h=l(r);h instanceof Promise?h.then(m=>d.set(m)):v(h)?b(()=>d.set(h())):d.set(h)},c)}),d},i}function b(t,e){const n=`${(e==null?void 0:e.name)||""}_${Math.random().toString(36).substring(2,15)}`;f("current effect",`%c${n}%c`);const s=t;t=()=>(f("current effect callback",`%c${n}%c`),s()),"fake"in s&&s.fake&&(t.fake=!0),t.effectId=n;const i=w[w.length-1];O.has(t)||O.set(t,{cleanupFns:new Set});const l=O.get(t);i?l.parent=i:delete l.parent,w.push(t),B.push(t),t(),B.pop(),w.pop()}const v=t=>!!t&&["object","function"].includes(typeof t)&&"set"in t&&"oldValue"in t&&"update"in t&&"forceSet"in t;function yt(t,...e){const n=A("");return b(()=>{const s=e.map(l=>v(l)?String(l()):String(l)),i=[t[0]];s.forEach((l,c)=>{i.push(l,t[c+1])}),n.set(i.join(""))}),n}function St(t,e){const n=A(e??null),s=i=>n.set(i);return t instanceof Promise?t.then(s):typeof t=="function"&&b(()=>{const i=t();i instanceof Promise?i.then(s):v(i)?b(()=>s(i())):s(i)}),n}function vt(t,e){let n=t(),s=e();b(()=>{const i=t(),l=e();i!==l&&(i!==n?e.set(i):l!==s&&t.set(l)),n=i,s=l})}function At(...t){let e=t.map(s=>s());const n=A(e);return t.forEach((s,i)=>{b(()=>{const l=()=>e.filter(c=>c!==void 0).length;l()===t.length&&(e=Array.from(e).fill(void 0)),e[i]=s(),l()===t.length&&n.set([...e])})}),n}const gt=(...t)=>{const e=A([]);return b(()=>{e.set(t.map(n=>n()))}),e};class T extends HTMLElement{constructor(n=!1){super();E(this,"isSlotLazyLoading",!1);E(this,"slotTemplate");E(this,"slotContext");E(this,"rootStyle");E(this,"modelValue");E(this,"providers");E(this,"appendAllSlotContent");E(this,"allSlotContent",[]);E(this,"slotContent",{});E(this,"htmlSlotContent",{});E(this,"shadow");E(this,"injects",{});this.shadow=this.attachShadow({mode:n?"closed":"open"})}appendChild(n,s=!0){var i;if(this.isSlotLazyLoading&&s){if(n instanceof HTMLElement){const l=n.slot||"default";this.htmlSlotContent[l]||(this.htmlSlotContent[l]=[]),(i=this.htmlSlotContent[l])==null||i.push(n)}}else return super.appendChild(n)}appendSlotContent(){var n;(n=this.appendAllSlotContent)==null||n.call(this)}inject(n){return f("%cinject%c",n),this.injects[n]||(this.injects[n]=A(null)),this.injects[n]}checkInjects(){Object.entries(this.injects).forEach(([n,s])=>{f("%cinject%c",`%c${n}%c`,"from BaseElement (dispatch event)"),this.shadow.dispatchEvent(new CustomEvent(n,{detail:{context:n,callback:i=>b(()=>{s.set(i())})},bubbles:!0,composed:!0}))})}setReactiveValue(n){this.modelValue=n}}E(T,"observedAttributes",[]),E(T,"renderTagName",""),E(T,"styles");const Lt=t=>"render"in t&&"setReactiveValue"in t,Rt="handleSlotContext",K="onConnected",Tt=()=>()=>{},D=t=>typeof t=="string"?t:JSON.stringify(t),G=t=>{const e=document.createElement("span");return e.textContent=D(t),e},N=(t,e)=>(t.appendChild(G(e)),t),x=(t,e)=>(t.innerHTML="",N(t,e)),J=t=>{const e=document.createElement("span");return b(()=>{const n=t();e.textContent=D(n)}),e},$=t=>({append(...e){return e.forEach(n=>{t.appendChild(n.hostElement),K in n.hostElement&&setTimeout(()=>{var s,i;(i=(s=n.hostElement).onConnected)==null||i.call(s,n,n.hostElement)})}),this},set(...e){this.clear();const n=document.createDocumentFragment();return e.forEach(s=>{n.appendChild(s.hostElement)}),t.appendChild(n),this},removeChild(...e){return e.forEach(n=>{Array.from(t.childNodes.values()).some(s=>s===n.hostElement)&&t.removeChild(n.hostElement)}),this},addHtmlContent(e){return N(t,e),this},setHtmlContent(e){return x(t,e),this},addEventlistener(e,n,s=!1){return t.addEventListener(e,i=>n(i,this,t),s),this},setAttribute(e,n){let s;if(typeof n=="boolean"&&!(t instanceof T))if(n)s="";else{this.removeAttribute(e);const i=e.toLowerCase();return i in t&&(t[i]=null),this}else typeof n!="string"?s=JSON.stringify(n):s=n;if(t.setAttribute(M(e),s),!(t instanceof T)){const i=e.toLowerCase();i in t&&(t[i]=n)}return this},setCustomAttribute(e,n){let s;return typeof n!="string"?s=JSON.stringify(n):s=n,t.setAttribute(M(e),s),this},setReactiveAttribute(e,n){return b(()=>this.setAttribute(e,n())),this},setReactiveCustomAttribute(e,n){return b(()=>this.setCustomAttribute(e,n())),this},removeAttribute(e){return t.removeAttribute(M(e)),this},addStyle(e){return Object.entries(e).forEach(([n,s])=>{const i=n.startsWith("--");typeof s=="function"?this.addEffect(()=>{if(i){const l=String(s()||"");t.style.setProperty(n,l)}else t.style[n]=s()}):typeof s=="string"&&(i?t.style.setProperty(n,s):t.style[n]=s)}),this},onConnected(e){return Reflect.defineProperty(t,K,{get(){return e}}),this},addClass(...e){return e.forEach(n=>{typeof n=="string"?t.classList.add(...n.split(" ").flatMap(s=>s.split(`
|
|
2
|
-
`)).map(s=>s.trim()).filter(Boolean)):(()=>{let s=null;this.addEffect(()=>{const i=n();i.length>0&&(s?this.replaceClass(s,i):this.addClass(i),s=i)})})()}),this},setClass(...e){return t.classList.remove(...t.classList),t.classList.add(...e),this},addReactiveClass(e){return Object.keys(e).forEach(n=>{b(()=>{e[n]()?this.addClass(n):this.removeClass(n)})}),this},removeClass(...e){return t.classList.remove(...e),this},replaceClass(e,n){return t.classList.replace(e,n),this},addEffect(e){return b(()=>e(this,this.hostElement)),this},addReactiveContent(e){return t.appendChild(J(e)),this},setReactiveContent(e){return this.clear(),t.appendChild(J(e)),this},clear(){return t.innerHTML="",this},hostElement:t}),tt=(t,...e)=>({classList:[...t.map(n=>n.trim()).filter(Boolean),...e]}),jt=(t,...e)=>tt(t,...e),V=(t,e)=>{if(!e)return t;const n=Object.keys(e||{}).filter(s=>s.startsWith(".")||s.startsWith("@")||s.startsWith("$"));return n.filter(s=>s.startsWith(".")).forEach(s=>{e!=null&&e.attributes||(e.attributes={}),e.attributes[s.slice(1)]=e[s]}),n.filter(s=>s.startsWith("@")).forEach(s=>{e!=null&&e.listeners||(e.listeners={});const i=s.slice(1);e.listeners[i]=e[s]}),n.filter(s=>s.startsWith("$")).forEach(s=>{e!=null&&e.effects||(e.effects=[]),e.effects.push(e[s])}),ot(t,e.classList),lt(t,e.style),ct(t,e.attributes),it(t,e.reactiveClassList),st(t,e.customAttributes),nt(t,e.children),et(t,e.effects),U(t,e.listeners),U(t,e.customListeners),t},U=(t,e)=>{e&&Object.entries(e).forEach(([n,s])=>{typeof s=="function"&&t.addEventlistener(n,s)})},et=(t,e)=>e==null?void 0:e.forEach(n=>t.addEffect(n)),nt=(t,e)=>I(t,...e||[]),st=(t,e)=>{const n=e;n&&Object.keys(n).forEach(s=>{v(n[s])?t.setReactiveCustomAttribute(s,n[s]):typeof n[s]=="function"?t.addEffect(()=>{t.setCustomAttribute(s,n[s]())}):t.setCustomAttribute(s,n[s])})},ot=(t,e)=>t.addClass(...e||[]),it=(t,e)=>t.addReactiveClass(e||{}),lt=(t,e)=>t.addStyle(e||{}),ct=(t,e)=>{const n=e,s=(i,l)=>{l&&(v(l)?t.setReactiveAttribute(i,l):typeof l=="function"?t.addEffect(()=>{t.setAttribute(i,l())}):t.setAttribute(i,l))};n&&Object.keys(n).forEach(i=>{s(i,n[i])})},I=(t,...e)=>(e.forEach(n=>{typeof n=="string"?n.trim().length>0&&t.addHtmlContent(n):v(n)?t.addReactiveContent(n):t.append(n)}),t),k=(t,e)=>{const n=document.createElement(t),s={...$(n)};return V(s,e)},P=(t,e)=>{const[n,...s]=t.split(" ").map(l=>l.trim()),i=k(n,e);return s.length>0&&i.addClass(...s),(...l)=>I(i,...l.filter(Boolean).flat().flatMap(c=>typeof c=="function"&&!v(c)?g(()=>c(i)):c))},g=t=>k("div").addStyle({display:"contents"}).addEffect(e=>{const n=t(),s=[];Array.isArray(n)?s.push(...n):s.push(n),e.clear(),I(e,...s)}),Ot=t=>{const e=s=>typeof s=="string"?s.trim().length>0?$(G(s)):P("div")():v(s)?$(J(s)):s;return at(()=>{const s=t();return s instanceof Array&&Array.isArray(s)?s.map(e):e(s)})},wt=(t,e,n)=>{const s=k("div").addStyle({display:"contents"}),i=new Map,l=new Map;let c=[];const d=new Set;let r=t.peek();const h=m=>{d.delete(m),i.delete(m),l.delete(m)};return b(()=>{const m=t();c=m.map(e).map(u=>typeof u=="string"?u:u.toString());const C=Array.from(s.hostElement.children);f("containerChildren",C,c),C.forEach(u=>{const S=u.dataset.key;c.includes(S)||(f("remove element",S,u),u.remove(),h(S))}),c.forEach(u=>{var H,j;const S=m[c.indexOf(u)];i.has(u)?JSON.stringify(S)!==JSON.stringify(r[c.indexOf(u)])&&((H=s.hostElement.querySelector(`[data-key="${u}"]`))==null||H.remove(),(j=i.get(u))==null||j.set(Math.random().toString(36).substring(2,15)),l.set(u,()=>n(S,c.indexOf(u),m).setCustomAttribute("data-key",u))):(f("create new element",u,S),i.set(u,A(Math.random().toString(36).substring(2,15))),l.set(u,()=>n(S,c.indexOf(u),m).setCustomAttribute("data-key",u)))}),r=[...m.map(u=>({...u}))];const y=()=>{i.forEach((u,S)=>{f("key from setTimeout foreach currItemSignalMap",S),d.has(S)||(d.add(S),b(()=>{var Ct;u();const H=c.indexOf(S),j=(Ct=l.get(S))==null?void 0:Ct();j&&(f("call effect from setTimeout",S,j.hostElement),H<=s.hostElement.children.length-1?s.hostElement.insertBefore(j.hostElement,s.hostElement.children[H]):s.hostElement.append(j.hostElement))}))})};Promise.resolve().then(()=>y())}),s},at=t=>{let e=[k("div")],n=!1;return b(()=>{var l,c;const s=t();n=Array.isArray(s);const i=[];i.push(...[s].flat()),i.length===0&&i.push(k("div").addStyle({display:"none"}).setAttribute("id","empty_template"));try{f("newReactiveComponent.map",i.map(d=>{var r;return f("newReactiveComponent hostElement",d.hostElement),(r=d.hostElement)==null?void 0:r.id})),f("currComponent[0].hostElement?.id",(l=e[0].hostElement)==null?void 0:l.id,e),(c=e[0].hostElement)==null||c.replaceWith(...i.map(d=>d.hostElement)),e.slice(1).forEach(d=>{var r;return(r=d.hostElement)==null?void 0:r.remove()}),e=i}catch(d){console.error(d)}}),n?e:e[0]},kt=t=>Rt in t,Mt=t=>{const e=P("div")().addStyle({display:"contents"}),n=s=>(e.hostElement.innerHTML=s,e);return typeof t=="string"?n(t):e.addEffect(()=>{n(t())}),e},X=(t,e,n)=>t?g(e):n?g(n):P("div")().setAttribute("id","empty_div_renderIf").addStyle({display:"none"}),rt=(t,e,n)=>g(()=>X(!!t(),e,n)),$t=(t,e,n)=>typeof t=="boolean"?X(t,e,n):rt(t,e,n),Z=(t,e)=>{const n=g(e);return typeof t=="boolean"?[n].flat().forEach(s=>s.hostElement.style.display=t?"block":"none"):b(()=>{const s=t()?"block":"none";[n].flat().forEach(i=>i.hostElement.style.display=s)}),n},It=(t,e,n)=>{const s=[Z(t,e)].flat();return n&&s.push(...[Z(()=>typeof t=="boolean"?!t:!t(),n)].flat()),g(()=>s)},dt=(t,e)=>{f("createCustomElement",t);const n=document.createElement(t),s={...$(n),setReactiveValue(i){return n instanceof T&&n.setReactiveValue(i),this},setSlotTemplate(i){const l=n.slotTemplate;return l&&Object.entries(i).forEach(([c,d])=>{l[c]=d}),this}};return V(s,e)},ht=(t,e)=>{const n=t.split(" ").slice(1).map(i=>i.trim()),s=dt(t.split(" ")[0],e);return Array.isArray(n)&&n.length>0&&s.addClass(...n),(...i)=>{R("@rcreateCustomEl content",t,i);const l=i.filter(Boolean).flat().flatMap(c=>typeof c=="function"&&!v(c)?g(()=>c(s)):c);return s.hostElement.allSlotContent=l,s.hostElement.slotContent=l.filter(L).reduce((c,d)=>{const r=d.hostElement.getAttribute("slot")||"default";return c[r]||(c[r]=[]),c[r].push(d),c},{}),s.hostElement.appendAllSlotContent=()=>I(s,...l),s}},ut=(t,e,n)=>ht(`${t.renderTagName}${e&&typeof e=="string"?" "+e:""}`,p(e)?e:e&&typeof e=="string"?n:void 0),Pt=()=>{const t=()=>{};return t.oldValue=null,t},Ft=()=>({}),Ht=(t,e,n)=>{const s=e?mt(e,n)(t):t;return(i,...l)=>{const c=[...l];return i&&!p(i)&&c.unshift(i),ut(s,p(i)?i:{})(...c)}},a={};["div","span","section","input","button","table","tr","td","th","ul","li","ol","form","label","select","option","textarea","img","a","p","h1","h2","h3","h4","h5","h6","br","hr","pre","code","nav","header","footer","main","aside","article","figure","figcaption","blockquote","cite","small","strong","em","b","i","u","s","sub","sup","mark","del","ins","details","summary","progress","meter","audio","video","canvas","slot"].forEach(t=>{a[t]=(e,...n)=>{let s=[...n];return e&&!p(e)&&(s=[e].concat(s)),P(t,p(e)?e:{})(...s)}});const ft=a.div,Wt=a.span,_t=a.section,Bt=a.input,Jt=a.button,zt=a.table,qt=a.tr,Dt=a.td,Gt=a.th,Nt=a.ul,Vt=a.li,Ut=a.ol,Xt=a.form,Zt=a.label,Qt=a.select,Yt=a.option,Kt=a.textarea,xt=a.img,te=a.a,ee=a.p,ne=a.h1,se=a.h2,oe=a.h3,ie=a.h4,le=a.h5,ce=a.h6,ae=a.br,re=a.hr,de=a.pre,he=a.code,ue=a.nav,fe=a.header,me=a.footer,Ce=a.main,be=a.aside,pe=a.article,Ee=a.figure,ye=a.figcaption,Se=a.blockquote,ve=a.cite,Ae=a.small,ge=a.strong,Le=a.em,Re=a.b,Te=a.i,je=a.u,Oe=a.s,we=a.sub,ke=a.sup,Me=a.mark,$e=a.del,Ie=a.ins,Pe=a.details,Fe=a.summary,He=a.progress,We=a.meter,_e=a.audio,Be=a.video,Je=a.canvas,ze=a.slot,qe=t=>e=>t(e).addClass(...e.classList??[]).addReactiveClass(e.reactiveClassList??{}),z="eventProps",q="EVENT_CONFIG",F="observedAttributes",De=()=>(t,e)=>{Reflect.get(t,F)||Reflect.defineProperty(t,F,{value:[]}),Reflect.get(t,F).push(M(e))},Ge=t=>(e,n)=>{Reflect.get(e,z)||Reflect.defineProperty(e,z,{value:[]}),Reflect.get(e,q)||Reflect.defineProperty(e,q,{value:{}}),Reflect.get(e,q)[n]={bubbles:(t==null?void 0:t.bubbles)??!1,composed:(t==null?void 0:t.composed)??!1},Reflect.get(e,z).push(n)},mt=(t,e=!1)=>n=>{f(t,"start register static attr",n.prototype[F]);const s=[];if(n.styles){const l=n.styles,c=[];Array.isArray(l)?c.push(...l):c.push(l),c.forEach(d=>{const r=new CSSStyleSheet;r.replaceSync(d),s.push(r);const h=new CSSStyleSheet;h.replaceSync(d.slice(d.indexOf("@property"))),document.adoptedStyleSheets.push(h)})}class i extends n{constructor(...c){f("constructor",`%c${t}%c`),super(e,...c),R("@osheet",s),s.length>0&&this.shadow.adoptedStyleSheets.push(...s)}render(){f("rwc: render from new class");let c=ft();const d=()=>{f("wrapperEffectCallback"),c=n.prototype.render.call(this)};return d.fake=!0,b(d),c}attributeChangedCallback(c,d,r){f("%cAttribute has changed.%c",`%c${c}%c`,`oldValue: ${d}, newValue: ${r}`,`%c${t}%c`);try{r=JSON.parse(r)}catch{}const h=Q(c);if(h in this&&v(this[h])){const m=this[h];r===null?(m.set(m.initValue),this.removeAttribute(c)):m.set(r)}W(this,n.prototype.attributeChangedCallback,c,d,r)}connectedCallback(){var d;f("rwc: connectedCallback"),f("connectedCallback",`%c${t}%c`,this),this.providers&&Object.keys(this.providers).length>0&&(f("WRAPPER for providers",t),Object.entries(this.providers).forEach(([r,h])=>{f("register provider",r,h()),this.addEventListener(r,m=>{var y;f("send provider",r,h());const C=m;((y=C.detail)==null?void 0:y.context)===r&&(C.stopPropagation(),C.detail.callback(h))})})),this.checkInjects(),(d=n.prototype[z])==null||d.forEach(r=>{this[r]=h=>{const m=n.prototype[q][r],{bubbles:C,composed:y}=m;v(h)?b(()=>{R("@oemit reactive value",h()),this.dispatchEvent(new CustomEvent(r,{detail:h(),bubbles:C,composed:y}))}):(R("@oemit value",h),this.dispatchEvent(new CustomEvent(r,{detail:h,bubbles:C,composed:y})))}}),f("start render",`%c${t}%c`,t);const c=()=>{f("rwc: insertRenderTemplate");const r=this.render();this.shadow.appendChild(r.hostElement),W(this,n.prototype.connectedCallback),this.appendSlotContent()};if(this.rootStyle&&!n.styles){const r=C=>C instanceof Promise||Array.isArray(C)&&C.every(y=>y instanceof Promise),h=this.rootStyle,m=C=>{const y=new CSSStyleSheet;y.replaceSync(C),this.shadow.adoptedStyleSheets.push(y);const u=new CSSStyleSheet;u.replaceSync(C.slice(C.indexOf("@property"))),document.adoptedStyleSheets.push(u)};if(r(h)){const C=[];Array.isArray(h)?C.push(...h):C.push(h),Promise.all(C).then(y=>y.forEach(u=>m(u.default))).then(()=>c())}else{const C=[];Array.isArray(h)?C.push(...h):C.push(h),C.forEach(y=>m(y)),c()}}else c();this.slotContext&&Object.keys(this.slotContext).length>0&&this.shadow.querySelectorAll("slot").forEach(r=>{f(this.slotContext,this.slotContext&&this.slotContext[r.name]),R("@bslot element",r,`name:${r.name};`,r.assignedElements()),r.assignedElements().forEach(h=>{const m=this.slotContext[r.name];this.slotContext&&v(m)&&(R("@oslot element",r,`name:${r.name};`,r.assignedElements()),b(()=>{h.dispatchEvent(new CustomEvent("handleSlotContext",{detail:m()}))}))})})}disconnectedCallback(){this.shadow.replaceChildren(),this.replaceChildren(),W(this,n.prototype.disconnectedCallback)}}return E(i,"observedAttributes",n.prototype[F]??[]),E(i,"renderTagName",t),i.toString=()=>t,customElements.get(t)?console.error(`название тега ${t} повторяется, компонент ${n.name} не зарегистрирован`):customElements.define(t,i),n.renderTagName=t,n};o.BaseElement=T,o.a=te,o.addAttributeList=ct,o.addClassList=ot,o.addCustomAttributes=st,o.addHtmlContent=N,o.addReactiveClassList=it,o.addStyleList=lt,o.appendContentItem=I,o.article=pe,o.aside=be,o.audio=_e,o.b=Re,o.bindReactiveSignals=vt,o.blockquote=Se,o.br=ae,o.button=Jt,o.camelToKebab=M,o.canvas=Je,o.checkCall=W,o.cite=ve,o.classList=tt,o.cls=jt,o.code=he,o.colorLog=R,o.combineLatest=gt,o.component=mt,o.createComponent=qe,o.createCustom=ut,o.createCustomEl=ht,o.createCustomElement=dt,o.createEl=P,o.createElement=k,o.createSignal=St,o.defineSlotTemplate=Ft,o.del=$e,o.details=Pe,o.disableLogs=Y,o.div=ft,o.effect=b,o.effectMap=Et,o.elementHelpers=$,o.em=Le,o.enableLogs=bt,o.event=Ge,o.eventEmitter=Tt,o.figcaption=ye,o.figure=Ee,o.footer=me,o.forkJoin=At,o.form=Xt,o.getList=wt,o.getReactiveTemplate=Ot,o.getSignalContent=g,o.getTextContent=D,o.h1=ne,o.h2=se,o.h3=oe,o.h4=ie,o.h5=le,o.h6=ce,o.header=fe,o.hr=re,o.htmlEffectWrapper=J,o.i=Te,o.img=xt,o.initComponent=V,o.input=Bt,o.ins=Ie,o.isBaseElement=Lt,o.isComponentConfig=L,o.isComponentInitConfig=p,o.isEffectDebugEnabled=pt,o.isReactiveSignal=v,o.isSlotTemplate=kt,o.kebabToCamel=Q,o.label=Zt,o.li=Vt,o.main=Ce,o.mark=Me,o.meter=We,o.nav=ue,o.newEventEmitter=Pt,o.ol=Ut,o.option=Yt,o.p=ee,o.pre=de,o.progress=He,o.projectLog=f,o.property=De,o.renderIf=X,o.rs=yt,o.rxRenderIf=rt,o.s=Oe,o.section=_t,o.select=Qt,o.setChildren=nt,o.setEffects=et,o.setHtmlContent=x,o.setListeners=U,o.show=It,o.showIf=Z,o.signal=A,o.signalComponent=at,o.slot=ze,o.small=Ae,o.span=Wt,o.strong=ge,o.sub=we,o.summary=Fe,o.sup=ke,o.table=zt,o.td=Dt,o.textContentWrapper=G,o.textarea=Kt,o.th=Gt,o.tr=qt,o.u=je,o.ul=Nt,o.unsafeHtml=Mt,o.useCustomComponent=Ht,o.video=Be,o.when=$t,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|