@reactive-web-components/rwc 2.61.10 → 2.63.7
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/README.md +52 -1
- package/package.json +5 -5
- package/{reactive-web-component.f_B19_fm.js → reactive-web-component.BmjLtNib.js} +391 -396
- package/reactive-web-component.Bx_Hbzlr.umd.cjs +2 -0
- package/shared/types/element.d.ts +1 -0
- package/shared/utils/signal/signal.d.ts +1 -1
- package/shared/utils/signal/utils.d.ts +6 -0
- package/reactive-web-component.rx6nheib.umd.cjs +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(i,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(i=typeof globalThis<"u"?globalThis:i||self,A(i.ReactiveComponent={}))})(this,function(i){"use strict";var fn=Object.defineProperty;var hn=(i,A,_)=>A in i?fn(i,A,{enumerable:!0,configurable:!0,writable:!0,value:_}):i[A]=_;var u=(i,A,_)=>hn(i,typeof A!="symbol"?A+"":A,_);const A=n=>n&&typeof n=="object"&&("classList"in n||"attributes"in n||"customAttributes"in n||"reactiveClassList"in n||"listeners"in n||"customListeners"in n||"children"in n||"effects"in n||"ref"in n||"style"in n||Object.keys(n).some(t=>t.startsWith(".")||t.startsWith("@")||t.startsWith("$")))&&!("hostElement"in n),_=n=>n&&typeof n=="object"&&"hostElement"in n&&"append"in n&&"set"in n&&"addStyle"in n&&"setAttribute"in n&&"addClass"in n&&"addEffect"in n&&"addReactiveContent"in n&&"setReactiveContent"in n&&"clear"in n,D=(n,t,...e)=>{t&&t.apply(n,e)};let G=!0;const C=(...n)=>{G&&console.debug(["[rwc]",...n].join(" | "),...Array.from(n.join("").matchAll(/%c/gm)).map((t,e)=>e%2===0?"color:red":"color:inherit"))},B=n=>n.replace(/([A-Z])/gm,t=>`-${t.toLowerCase()}`),ot=n=>n.replace(/-(\w)/gm,(t,e)=>e.toUpperCase()),F=(n,...t)=>{if(!G)return;const e={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=n.match(/@[rgbpycow]/g)||[],o=s.map(c=>{const a=c.slice(1);return e[a]||"color: inherit"});let r=n;s.forEach(c=>{const a=new RegExp(`\\${c}([^\\s,]+)`,"g");r=r.replace(a,"%c$1")}),console.log(r,...o,...t)},Tt=()=>{G=!0},rt=()=>{G=!1};rt();const jt=(n,t)=>{n.every(Boolean)&&t(n)},V=new Set;let Q=!1;const Ot=n=>{n.status==="active"&&V.add(n),Q||(Q=!0,queueMicrotask(()=>{Q=!1,C("pendingEffects.size",V.size);const t=Array.from(V);V.clear(),t.forEach(e=>{if(e.status==="active"){K(e),O.push(e);try{e()}catch(s){console.error("Error in effect:",s)}finally{O.pop()}}}),C("after ------ pendingEffects.size",V.size)}))},O=[],K=n=>{var t,e,s,o;(t=n.children)==null||t.forEach(r=>{var c;return(c=r.destroy)==null?void 0:c.call(r)}),(e=n.children)==null||e.clear(),(s=n.cleanupSet)==null||s.forEach(r=>r()),(o=n.cleanupSet)==null||o.clear()};function T(n,t){let e=(t==null?void 0:t.signalCompareFn)||(()=>!0);const s=new Set;function o(){var c;const r=O[O.length-1];return r&&!r.fake&&!s.has(r)&&r.status==="active"&&(s.add(r),(c=r.cleanupSet)==null||c.add(()=>s.delete(r))),!(t!=null&&t.name)&&(r!=null&&r.effectId)&&o.setName(r.effectId),n}return o.signalId=`${(t==null?void 0:t.name)||""}_${Math.random().toString(36).substring(2,15)}`,o.setName=function(r){return o.signalId=`${r}_${Math.random().toString(36).substring(2,15)}`,o},o.setCompareFn=function(r){return e=r,o},o.clearSubscribers=function(){s.clear()},o.getSubscribers=function(){return s},o.peek=function(){return Object.freeze(n)},o.initValue=Object.freeze(n),o.forceSet=function(r){n=r,s.forEach(c=>Ot(c))},o.set=function(r,c=e){n!==r&&c(n,r)&&o.forceSet(r)},o.update=function(r){o.set(r(n))},o.pipe=(r,c)=>{c!=null&&c.name&&o.setName(c.name);const a=T(null);return v(()=>{const d=o();v(()=>{const h=r(d);h instanceof Promise?h.then(E=>a.set(E)):R(h)?v(()=>a.set(h()),{name:"pipe_effect_inner"}):a.set(h)},{name:"pipe_effect"})},{name:(c==null?void 0:c.name)||`pipe_${o.signalId}`}),a},o}function v(n,t){var r;const e=`${(t==null?void 0:t.name)||""}_${Math.random().toString(36).substring(2,15)}`;C("current effect",`%c${e}%c`);const s=n;s.status="active",s.children=new Set,s.effectId=e;const o=O[O.length-1];return o&&((r=o.children)==null||r.add(s),s.parent=new WeakRef(o),s.destroy=()=>{var c;K(s),(c=o.children)==null||c.delete(s),s.destroy=void 0,s.status="inactive"}),s.cleanupSet=new Set,O.push(s),s(),O.pop(),s}const R=n=>!!n&&["object","function"].includes(typeof n)&&"set"in n&&"update"in n&&"forceSet"in n&&"signalId"in n;function Mt(n,...t){const e=T("");return v(()=>{const s=t.map(r=>R(r)?String(r()):String(r)),o=[n[0]];s.forEach((r,c)=>{o.push(r,n[c+1])}),e.set(o.join(""))}),e}function $t(n,t){const e=T(t??null),s=o=>e.set(o);return n instanceof Promise?n.then(s):typeof n=="function"&&v(()=>{const o=n();o instanceof Promise?o.then(s):R(o)?v(()=>s(o())):s(o)}),e}function _t(n,t){let e=n(),s=t();v(()=>{const o=n(),r=t();o!==r&&(o!==e?t.set(o):r!==s&&n.set(r)),e=o,s=r})}function Ht(...n){let t=n.map(s=>s());const e=T(t);return n.forEach((s,o)=>{v(()=>{const r=()=>t.filter(c=>c!==void 0).length;r()===n.length&&(t=Array.from(t).fill(void 0)),t[o]=s(),r()===n.length&&e.set([...t])})}),e}const kt=(...n)=>{const t=T([]);return v(()=>{t.set(n.map(e=>e()))}),t},Wt=(n,t)=>{let e=!0;const s=v(()=>{var o;e&&(e=!1,t(n()),(o=s.destroy)==null||o.call(s))})},U="eventProps",Y="EVENT_CONFIG",J="observedAttributes",Pt=()=>(n,t)=>{Reflect.get(n,J)||Reflect.defineProperty(n,J,{value:[]}),Reflect.get(n,J).push(B(t))},Bt=n=>(t,e)=>{Reflect.get(t,U)||Reflect.defineProperty(t,U,{value:[]}),Reflect.get(t,Y)||Reflect.defineProperty(t,Y,{value:{}}),Reflect.get(t,Y)[e]={bubbles:(n==null?void 0:n.bubbles)??!1,composed:(n==null?void 0:n.composed)??!1},Reflect.get(t,U).push(e)},x=(n,t=!1)=>e=>{C(n,"start register static attr",e.prototype[J]);const s=[];if(e.styles){const r=e.styles,c=[];Array.isArray(r)?c.push(...r):c.push(r),c.forEach(a=>{const d=new CSSStyleSheet;d.replaceSync(a),s.push(d);const S=new CSSStyleSheet;S.replaceSync(a.slice(a.indexOf("@property"))),document.adoptedStyleSheets.push(S)})}class o extends e{constructor(...c){C("constructor",`%c${n}%c`),super(t,...c),s.length>0&&this.shadow.adoptedStyleSheets.push(...s)}render(){return C("rwc: render from new class"),e.prototype.render.call(this)}attributeChangedCallback(c,a,d){C("%cAttribute has changed.%c",`%c${c}%c`,`oldValue: ${a}, newValue: ${d}`,`%c${n}%c`);try{d=JSON.parse(d)}catch{}const S=ot(c);if(S in this&&R(this[S])){const h=this[S];h.setName(c),d===null?(h.set(h.initValue),this.removeAttribute(c)):h.set(d)}D(this,e.prototype.attributeChangedCallback,c,a,d)}connectedCallback(){const c=()=>{var d,S;C("rwc: connectedCallback"),C("connectedCallback",`%c${n}%c`,this),(d=this.init)==null||d.call(this),this.providers&&Object.keys(this.providers).length>0&&(C("WRAPPER for providers",n),Object.entries(this.providers).forEach(([h,f])=>{C("register provider",h,f()),this.addEventListener(h,E=>{var m;C("send provider",h,f());const p=E;((m=p.detail)==null?void 0:m.context)===h&&(p.stopPropagation(),p.detail.callback(f))})})),this.checkInjects(),(S=e.prototype[U])==null||S.forEach(h=>{this[h]=f=>{const E=e.prototype[Y][h],{bubbles:p,composed:m}=E;R(f)?v(()=>{F("@oemit reactive value",f()),this.dispatchEvent(new CustomEvent(h,{detail:f(),bubbles:p,composed:m}))}):(F("@oemit value",f),this.dispatchEvent(new CustomEvent(h,{detail:f,bubbles:p,composed:m})))}}),C("start render",`%c${n}%c`,n);const a=()=>{C("rwc: insertRenderTemplate");const f=this.render().hostElement;f&&this.shadow.appendChild(f),D(this,e.prototype.connectedCallback),this.appendSlotContent()};if(this.rootStyle&&!e.styles){const h=p=>p instanceof Promise||Array.isArray(p)&&p.every(m=>m instanceof Promise),f=this.rootStyle,E=p=>{const m=new CSSStyleSheet;m.replaceSync(p),this.shadow.adoptedStyleSheets.push(m);const w=new CSSStyleSheet;w.replaceSync(p.slice(p.indexOf("@property"))),document.adoptedStyleSheets.push(w)};if(h(f)){const p=[];Array.isArray(f)?p.push(...f):p.push(f),Promise.all(p).then(m=>m.forEach(w=>E(w.default))).then(()=>a())}else{const p=[];Array.isArray(f)?p.push(...f):p.push(f),p.forEach(m=>E(m)),a()}}else a();this.slotContext&&Object.keys(this.slotContext).length>0&&this.shadow.querySelectorAll("slot").forEach(h=>{C(this.slotContext,this.slotContext&&this.slotContext[h.name]),F("@bslot element",h,`name:${h.name};`,h.assignedElements()),h.assignedElements().forEach(f=>{const E=this.slotContext[h.name];this.slotContext&&R(E)&&(F("@oslot element",h,`name:${h.name};`,h.assignedElements()),v(()=>{f.dispatchEvent(new CustomEvent("handleSlotContext",{detail:E()}))}))})})};c.fake=!0,c.component=new WeakRef(this),this.effectSet.add(new WeakRef(c)),v(c,{name:"FAKE_wrapperEffect"})}disconnectedCallback(){this.allSlotContent=[],this.slotContent={},this.htmlSlotContent={},this.effectSet.forEach(c=>{var a,d;return(d=(a=c.deref())==null?void 0:a.destroy)==null?void 0:d.call(a)}),this.effectSet.clear(),this.shadow.replaceChildren(),this.replaceChildren(),D(this,e.prototype.disconnectedCallback)}}return u(o,"observedAttributes",e.prototype[J]??[]),u(o,"renderTagName",n),o.toString=()=>n,customElements.get(n)?console.error(`название тега ${n} повторяется, компонент ${e.name} не зарегистрирован`):customElements.define(n,o),e.renderTagName=n,e};class H extends HTMLElement{constructor(e=!1){super();u(this,"init");u(this,"isSlotLazyLoading",!1);u(this,"slotTemplate");u(this,"slotContext");u(this,"rootStyle");u(this,"modelValue");u(this,"providers");u(this,"effectSet",new Set);u(this,"appendAllSlotContent");u(this,"allSlotContent",[]);u(this,"slotContent",{});u(this,"htmlSlotContent",{});u(this,"shadow");u(this,"injects",{});this.shadow=this.attachShadow({mode:e?"closed":"open"})}appendChild(e,s=!0){var o;if(this.isSlotLazyLoading&&s){if(e instanceof HTMLElement){const r=e.slot||"default";this.htmlSlotContent[r]||(this.htmlSlotContent[r]=[]),(o=this.htmlSlotContent[r])==null||o.push(e)}}else return super.appendChild(e)}appendSlotContent(){var e;(e=this.appendAllSlotContent)==null||e.call(this)}inject(e){return C("%cinject%c",e),this.injects[e]||(this.injects[e]=T(null)),this.injects[e]}checkInjects(){Object.entries(this.injects).forEach(([e,s])=>{C("%cinject%c",`%c${e}%c`,"from BaseElement (dispatch event)"),this.shadow.dispatchEvent(new CustomEvent(e,{detail:{context:e,callback:o=>v(()=>{s.set(o())},{name:e})},bubbles:!0,composed:!0}))})}setReactiveValue(e){this.modelValue=e}}u(H,"observedAttributes",[]),u(H,"renderTagName",""),u(H,"styles");const Ft=n=>"render"in n&&"setReactiveValue"in n,Vt="handleSlotContext",it="onConnected",ct=n=>typeof n=="string"?n:JSON.stringify(n),Jt=n=>{const t=document.createElement("span");return t.textContent=ct(n),t},lt=(n,t)=>(n.appendChild(Jt(t)),n),Nt=(n,t)=>(n.replaceChildren(),lt(n,t)),at=n=>{const t=document.createElement("span");return v(()=>{const e=n();t.textContent=ct(e)}),t};class dt{constructor(t){u(this,"wrapper");u(this,"keyedEffects",new Map);u(this,"append",(...t)=>(t.forEach(e=>{var o;const s=e.hostElement;s&&((o=this.hostElement)==null||o.appendChild(s),it in s&&setTimeout(()=>{var r;(r=s.onConnected)==null||r.call(s,e,s)}))}),this));u(this,"set",(...t)=>{var s;this.clear();const e=document.createDocumentFragment();return t.forEach(o=>{const r=o.hostElement;r&&e.appendChild(r)}),(s=this.hostElement)==null||s.appendChild(e),this});u(this,"removeChild",(...t)=>(t.forEach(e=>{var s,o;if(Array.from(((s=this.hostElement)==null?void 0:s.childNodes.values())||[]).some(r=>r===e.hostElement)){const r=e.hostElement;r&&((o=this.hostElement)==null||o.removeChild(r))}}),this));u(this,"addHtmlContent",t=>{const e=this.hostElement;return e?(lt(e,t),this):this});u(this,"setHtmlContent",t=>{const e=this.hostElement;return e?(Nt(e,t),this):this});u(this,"setAttribute",(t,e)=>{var r;C("setAttribute",t,e);const s=this.hostElement;if(!s)return this;let o;if((typeof e=="boolean"||e===null)&&!(s instanceof H))if(e)o="";else{this.removeAttribute(t);const c=t.toLowerCase();return c in s&&(s[c]=null),this}else typeof e!="string"?o=JSON.stringify(e):o=e;if((r=this.hostElement)==null||r.setAttribute(B(t),o),!(s instanceof H)){const c=t.toLowerCase();c in s&&(s[c]=e)}return this});u(this,"setCustomAttribute",(t,e)=>{var o;let s;return typeof e!="string"?s=JSON.stringify(e):s=e,(o=this.hostElement)==null||o.setAttribute(B(t),s),this});u(this,"setReactiveAttribute",(t,e)=>(this.addEffect(s=>{C("setReactiveAttribute effect",t,e),s.setAttribute(t,e())},t),this));u(this,"setReactiveCustomAttribute",(t,e)=>(this.addEffect(s=>{s.setCustomAttribute(t,e())}),this));u(this,"removeAttribute",t=>{var e;return(e=this.hostElement)==null||e.removeAttribute(B(t)),this});u(this,"addStyle",t=>{const e=this.hostElement;return e?(Object.entries(t).forEach(([s,o])=>{const r=s.startsWith("--");typeof o=="function"?this.addEffect(()=>{if(r){const c=String(o()||"");e.style.setProperty(s,c)}else e.style[s]=o()}):typeof o=="string"&&(r?e.style.setProperty(s,o):e.style[s]=o)}),this):this});u(this,"onConnected",t=>this.hostElement?(Reflect.defineProperty(this.hostElement,it,{get(){return t}}),this):this);u(this,"addClass",(...t)=>(t.forEach(e=>{var s;typeof e=="string"?(s=this.hostElement)==null||s.classList.add(...e.split(" ").flatMap(o=>o.split(`
|
|
2
|
+
`)).map(o=>o.trim()).filter(Boolean)):(()=>{let o=null;this.addEffect(()=>{const r=e();r.length>0&&(o?this.replaceClass(o,r):this.addClass(r),o=r)})})()}),this));u(this,"setClass",(...t)=>{var e,s,o;return(s=this.hostElement)==null||s.classList.remove(...((e=this.hostElement)==null?void 0:e.classList)||[]),(o=this.hostElement)==null||o.classList.add(...t),this});u(this,"addReactiveClass",t=>(Object.keys(t).forEach(e=>{this.addEffect(s=>{t[e]()?s.addClass(e):s.removeClass(e)})}),this));u(this,"removeClass",(...t)=>{var e;return(e=this.hostElement)==null||e.classList.remove(...t),this});u(this,"replaceClass",(t,e)=>{var s;return(s=this.hostElement)==null||s.classList.replace(t,e),this});u(this,"addEffect",(t,e)=>{var r,c;const s=this.hostElement;if(!s)return this;const o=()=>t(this,s);if(e){const a=(r=this.keyedEffects.get(e))==null?void 0:r.deref();a&&K(a)}return(c=s.effectSet)==null||c.add(new WeakRef(o)),o.component=this.wrapper,v(o,{name:(e==null?void 0:e.toString())||s.tagName}),this});u(this,"addReactiveContent",t=>{var e;return(e=this.hostElement)==null||e.appendChild(at(t)),this});u(this,"setReactiveContent",t=>{var e;return this.clear(),(e=this.hostElement)==null||e.appendChild(at(t)),this});u(this,"clear",()=>{var t;return(t=this.hostElement)==null||t.replaceChildren(),this});this.wrapper=t;const e=t.deref();e&&(e.effectSet=new Set)}get hostElement(){return this.wrapper.deref()}addEventlistener(t,e,s=!1){var o;return(o=this.hostElement)==null||o.addEventListener(t,r=>e(r,this,this.hostElement),s),this}}class qt extends dt{constructor(){super(...arguments);u(this,"setReactiveValue",e=>(this.hostElement instanceof H&&this.hostElement.setReactiveValue(e),this));u(this,"setSlotTemplate",e=>{var o;const s=(o=this.hostElement)==null?void 0:o.slotTemplate;return s&&Object.entries(e).forEach(([r,c])=>{s[r]=c}),this})}}const zt=()=>()=>{},ft=n=>new qt(new WeakRef(n)),ht=n=>new dt(new WeakRef(n)),ut=(n,...t)=>({classList:[...n.map(e=>e.trim()).filter(Boolean),...t]}),Dt=(n,...t)=>ut(n,...t),tt=(n,t)=>{var o;if(!t||!n.deref())return;const e=Object.keys(t||{}).filter(r=>r.startsWith(".")||r.startsWith("@")||r.startsWith("$"));e.filter(r=>r.startsWith(".")).forEach(r=>{t!=null&&t.attributes||(t.attributes={}),t.attributes[r.slice(1)]=t[r]}),e.filter(r=>r.startsWith("@")).forEach(r=>{t!=null&&t.listeners||(t.listeners={});const c=r.slice(1);t.listeners[c]=t[r]}),e.filter(r=>r.startsWith("$")).forEach(r=>{t!=null&&t.effects||(t.effects=[]),t.effects.push(t[r])});const s=n.deref();if(s)return Ct(s,t.classList),St(s,t.style),yt(s,t.attributes),bt(s,t.reactiveClassList),Et(s,t.customAttributes),pt(s,t.children),mt(s,t.effects),et(s,t.listeners),et(s,t.customListeners),(o=t.ref)==null||o.set(s),s},et=(n,t)=>{t&&Object.entries(t).forEach(([e,s])=>{typeof s=="function"&&n.addEventlistener(e,s)})},mt=(n,t)=>t==null?void 0:t.forEach(e=>n.addEffect(e)),pt=(n,t)=>N(new WeakRef(n),...t||[])??n,Et=(n,t)=>{const e=t;e&&Object.keys(e).forEach(s=>{R(e[s])?n.setReactiveCustomAttribute(s,e[s]):typeof e[s]=="function"?n.addEffect(()=>{n.setCustomAttribute(s,e[s]())}):n.setCustomAttribute(s,e[s])})},Ct=(n,t)=>n.addClass(...t||[]),bt=(n,t)=>n.addReactiveClass(t||{}),St=(n,t)=>n.addStyle(t||{}),yt=(n,t)=>{const e=t,s=(o,r)=>{r!==void 0&&(C("addAttribute",o,r),R(r)?n.setReactiveAttribute(o,r):typeof r=="function"?n.addEffect(()=>{n.setAttribute(o,r())}):n.setAttribute(o,r))};e&&Object.keys(e).forEach(o=>{s(o,e[o])})},N=(n,...t)=>{const e=n.deref();if(e)return t.forEach(s=>{typeof s=="string"?s.trim().length>0&&e.addHtmlContent(s):R(s)?e.addReactiveContent(s):e.append(s)}),e},k=(n,t)=>{const e=document.createElement(n),s=ht(e);return tt(new WeakRef(s),t)??s},Z=(n,t)=>{const[e,...s]=n.split(" ").map(r=>r.trim()),o=k(e,t);return s.length>0&&o.addClass(...s),(...r)=>N(new WeakRef(o),...r.filter(Boolean).flat().flatMap(c=>typeof c=="function"&&!R(c)?j(()=>c(o)):c))??o},j=n=>{const t=`getSignalContent_${Math.random().toString(36).substring(2,15)}`;return k("div").addStyle({display:"contents"}).addEffect(e=>{e.clear(),N(new WeakRef(e),...[n()].flat())},t)},Gt=(n,t,e)=>{const s=k("div").addStyle({display:"contents"}),o=new Map,r=new Map,c=new Map,a=new Map;let d=[];const S=new Set;let h=n.peek();const f=m=>{S.delete(m),o.delete(m),r.delete(m),c.delete(m),a.delete(m)},E=m=>{if(!a.has(m)){const w=d.indexOf(m);return a.set(m,w),w}return a.get(m)},p=(m,w,q)=>Array.from(q.children).indexOf(m)!==w;return v(()=>{const m=n(),w=m.map(t).map(b=>typeof b=="string"?b:b.toString()),q=new Set(w);a.clear(),w.forEach((b,y)=>{a.set(b,y)}),d=w;const M=s.hostElement;if(!M)return;C("containerChildren",Array.from(M.children),d);const z=[];Array.from(M.children).forEach(b=>{const y=b.dataset.key;y&&!q.has(y)&&z.push(b)}),z.forEach(b=>{const y=b.dataset.key;C("remove element",y,b),b.remove(),f(y)}),w.forEach((b,y)=>{var g;const L=m[y],P=h[y];if(!o.has(b))C("create new element",b,L),o.set(b,T(Math.random().toString(36).substring(2,15))),r.set(b,()=>e(L,y,m).setCustomAttribute("data-key",b));else if(P&&JSON.stringify(L)!==JSON.stringify(P)){const I=c.get(b);(g=o.get(b))==null||g.set(Math.random().toString(36).substring(2,15)),r.set(b,()=>e(L,y,m).setCustomAttribute("data-key",b)),I&&I.parentNode&&C("mark element for update",b)}}),h=[...m.map(b=>({...b}))];const X=()=>{o.forEach((b,y)=>{C("key from setTimeout foreach currItemSignalMap",y),S.has(y)||(S.add(y),v(()=>{var It;b();const L=E(y),P=(It=r.get(y))==null?void 0:It();if(!P||!P.hostElement)return;const g=s.hostElement,I=P.hostElement;if(!g)return;C("call effect from setTimeout",y,I);const $=c.get(y);if($&&$.parentNode===g){if(p($,L,g)){const W=g.children[L];W&&W!==$?g.insertBefore($,W):W||g.appendChild($)}I!==$&&($.replaceWith(I),c.set(y,I))}else if(c.set(y,I),L<g.children.length){const W=g.children[L];W?g.insertBefore(I,W):g.appendChild(I)}else g.appendChild(I)}))})};Promise.resolve().then(()=>X())}),s},Kt=n=>{let t=[k("div")],e=!1;return v(()=>{var r,c;const s=n();e=Array.isArray(s);const o=[];o.push(...[s].flat()),o.length===0&&o.push(k("div").addStyle({display:"none"}).setAttribute("id","empty_template"));try{C("newReactiveComponent.map",o.map(a=>{var d;return C("newReactiveComponent hostElement",a.hostElement),(d=a.hostElement)==null?void 0:d.id})),C("currComponent[0].hostElement?.id",(r=t[0].hostElement)==null?void 0:r.id,t),(c=t[0].hostElement)==null||c.replaceWith(...o.map(a=>a.hostElement).filter(Boolean)),t.slice(1).forEach(a=>{var d;return(d=a.hostElement)==null?void 0:d.remove()}),t=o}catch(a){console.error(a)}}),e?t:t[0]},Ut=n=>Vt in n,Yt=n=>{const t=Z("div")().addStyle({display:"contents"}),e=s=>{const o=t.hostElement;return o&&(o.innerHTML=s),t};return typeof n=="string"?e(n):t.addEffect(()=>{e(n())}),t},nt=(n,t,e)=>n?j(t):e?j(e):Z("div")().setAttribute("id","empty_div_renderIf").addStyle({display:"none"}),vt=(n,t,e)=>j(()=>nt(!!n(),t,e)),Zt=(n,t,e)=>typeof n=="boolean"?nt(n,t,e):vt(n,t,e),st=(n,t)=>j(t).addEffect((e,s)=>{if(typeof n=="boolean")s.style.display=n?"block":"none";else{const o=n()?"block":"none";s.style.display=o}}),Xt=(n,t,e)=>{const s=[st(n,t)].flat();return e&&s.push(...[st(()=>typeof n=="boolean"?!n:!n(),e)].flat()),j(()=>s)},wt=(n,t)=>{C("createCustomElement",n);const e=document.createElement(n),s=ft(e);return e.init=()=>{tt(new WeakRef(s),t)},s},At=(n,t)=>{const e=n.split(" ").slice(1).map(o=>o.trim()),s=wt(n.split(" ")[0],t);return Array.isArray(e)&&e.length>0&&s.addClass(...e),(...o)=>{const r=o.filter(Boolean).flat().flatMap(a=>typeof a=="function"&&!R(a)?j(()=>a(s)):a),c=s.hostElement;return c&&(c.allSlotContent=r,c.slotContent=r.filter(_).reduce((a,d)=>{var h;const S=((h=d.hostElement)==null?void 0:h.getAttribute("slot"))||"default";return a[S]||(a[S]=[]),a[S].push(d),a},{}),c.appendAllSlotContent=()=>{N(new WeakRef(s),...r)}),s}},gt=(n,t,e)=>At(`${n.renderTagName}${t&&typeof t=="string"?" "+t:""}`,A(t)?t:t&&typeof t=="string"?e:void 0),Qt=()=>{const n=()=>{};return n.oldValue=null,n},xt=()=>({}),Rt=(n,t,e)=>{const s=t?x(t,e)(n):n;return(o,...r)=>{const c=[...r];return o&&!A(o)&&c.unshift(o),gt(s,A(o)?o:{})(...c)}},te=n=>[Rt(n),(t,e)=>{x(t,e)(n)}],l={};["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(n=>{l[n]=(t,...e)=>{let s=[...e];return t&&!A(t)&&(s=[t].concat(s)),Z(n,A(t)?t:{})(...s)}});const Lt=l.div,ee=l.span,ne=l.section,se=l.input,oe=l.button,re=l.table,ie=l.tr,ce=l.td,le=l.th,ae=l.ul,de=l.li,fe=l.ol,he=l.form,ue=l.label,me=l.select,pe=l.option,Ee=l.textarea,Ce=l.img,be=l.a,Se=l.p,ye=l.h1,ve=l.h2,we=l.h3,Ae=l.h4,ge=l.h5,Re=l.h6,Le=l.br,Ie=l.hr,Te=l.pre,je=l.code,Oe=l.nav,Me=l.header,$e=l.footer,_e=l.main,He=l.aside,ke=l.article,We=l.figure,Pe=l.figcaption,Be=l.blockquote,Fe=l.cite,Ve=l.small,Je=l.strong,Ne=l.em,qe=l.b,ze=l.i,De=l.u,Ge=l.s,Ke=l.sub,Ue=l.sup,Ye=l.mark,Ze=l.del,Xe=l.ins,Qe=l.details,xe=l.summary,tn=l.progress,en=l.meter,nn=l.audio,sn=l.video,on=l.canvas,rn=l.slot,cn=n=>t=>n(t).addClass(...t.classList??[]).addReactiveClass(t.reactiveClassList??{});function ln(n,t){let e=0;return(...s)=>{const o=Date.now();o-e>=t&&(n(...s),e=o)}}const an=(n,t)=>j(()=>{const e=n();let s=null;return e.map((o,r)=>Lt({"@dragstart":(c,a,d)=>{s=d},"@dragend":(c,a,d)=>{d.style.transform="",d.removeAttribute("draggable")},"@mousedown":(c,a,d)=>{d.style.transform="translateZ(0)",d.setAttribute("draggable","true")},"@dragover":c=>{c.preventDefault()},"@dragenter":ln((c,a,d)=>{var S,h,f;if(c.preventDefault(),s){let E=s,p=d;const m=((S=s.getClientRects().item(0))==null?void 0:S.y)??0,w=((h=d.getClientRects().item(0))==null?void 0:h.y)??0;m<w&&([E,p]=[d,s]),(f=d.parentElement)==null||f.insertBefore(E,p)}},200)},t(o,r,[...n.peek()])))}),dn=(n,t,e)=>{let s=[],o=[];const r=k("div").addStyle({display:"contents"}),c=new Map,a=new Map;return v(()=>{const d=n(),S=d.map(t);o.filter(f=>!S.includes(f)).forEach(f=>{var E,p;c.delete(f),(p=(E=r.hostElement)==null?void 0:E.querySelector(`[data-key="${f}"]`))==null||p.remove()}),S.forEach((f,E)=>{o.includes(f)||c.set(f,()=>e(d[E],E,d).setCustomAttribute("data-key",f))}),S.forEach((f,E)=>{var p;if(o.includes(f)){JSON.stringify(s[o.indexOf(f)])!==JSON.stringify(d[E])&&((p=a.get(f))==null||p.set({templateFunc:()=>e(d[E],E,d),items:d,itemsKey:S,index:E}));return}a.set(f,T({templateFunc:()=>e(d[E],E,d),items:d,itemsKey:S,index:E})),queueMicrotask(()=>{v(()=>{var z,X,b;const{templateFunc:m,index:w}=((z=a.get(f))==null?void 0:z())??{},q=(X=r.hostElement)==null?void 0:X.querySelector(`[data-key="${f}"]`),M=(m==null?void 0:m().setCustomAttribute("data-key",f).hostElement)??document.createElement("div");q?(b=r.hostElement)==null||b.childNodes.forEach((y,L)=>{y instanceof HTMLElement&&y.getAttribute("data-key")===f&&(w===L?(h(w??0,r.hostElement,M),y.remove()):h(w??0,r.hostElement,M))}):h(w??0,r.hostElement,M)})})});const h=(f,E,p)=>{p&&E&&(f<E.children.length?E.insertBefore(p,E.children[f]):E.appendChild(p))};o=S,s=[...d]}),r};i.BaseElement=H,i.a=be,i.addAttributeList=yt,i.addClassList=Ct,i.addCustomAttributes=Et,i.addReactiveClassList=bt,i.addStyleList=St,i.appendContentItem=N,i.article=ke,i.aside=He,i.audio=nn,i.b=qe,i.bindReactiveSignals=_t,i.blockquote=Be,i.br=Le,i.button=oe,i.camelToKebab=B,i.canvas=on,i.checkCall=D,i.checkRef=jt,i.cite=Fe,i.classList=ut,i.cls=Dt,i.code=je,i.colorLog=F,i.combineLatest=kt,i.component=x,i.configCustomComponent=te,i.createComponent=cn,i.createCustom=gt,i.createCustomEl=At,i.createCustomElement=wt,i.createEl=Z,i.createElement=k,i.createSignal=$t,i.customElementHelpers=ft,i.ddList=an,i.defineSlotTemplate=xt,i.del=Ze,i.details=Qe,i.disableLogs=rt,i.div=Lt,i.effect=v,i.elementHelpers=ht,i.em=Ne,i.enableLogs=Tt,i.event=Bt,i.eventEmitter=zt,i.figcaption=Pe,i.figure=We,i.firstUpdate=Wt,i.footer=$e,i.forkJoin=Ht,i.form=he,i.getList=dn,i.getSignalContent=j,i.h1=ye,i.h2=ve,i.h3=we,i.h4=Ae,i.h5=ge,i.h6=Re,i.header=Me,i.hr=Ie,i.i=ze,i.img=Ce,i.initComponent=tt,i.input=se,i.ins=Xe,i.isBaseElement=Ft,i.isComponentConfig=_,i.isComponentInitConfig=A,i.isReactiveSignal=R,i.isSlotTemplate=Ut,i.kebabToCamel=ot,i.label=ue,i.li=de,i.main=_e,i.mark=Ye,i.meter=en,i.nav=Oe,i.newEventEmitter=Qt,i.ol=fe,i.oldGetList=Gt,i.option=pe,i.p=Se,i.pre=Te,i.progress=tn,i.projectLog=C,i.property=Pt,i.removeEffect=K,i.renderIf=nt,i.rs=Mt,i.rxRenderIf=vt,i.s=Ge,i.section=ne,i.select=me,i.setChildren=pt,i.setEffects=mt,i.setListeners=et,i.show=Xt,i.showIf=st,i.signal=T,i.signalComponent=Kt,i.slot=rn,i.small=Ve,i.span=ee,i.strong=Je,i.sub=Ke,i.summary=xe,i.sup=Ue,i.table=re,i.td=ce,i.textarea=Ee,i.th=le,i.tr=ie,i.u=De,i.ul=ae,i.unsafeHtml=Yt,i.useCustomComponent=Rt,i.video=sn,i.when=Zt,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -165,6 +165,7 @@ export type ConfigStyle = Partial<{
|
|
|
165
165
|
}>;
|
|
166
166
|
export type ComponentInitConfig<T extends ExtraHTMLElement> = Partial<{
|
|
167
167
|
classList: ConfigClassList;
|
|
168
|
+
ref: ReactiveSignal<ComponentConfig<T>>;
|
|
168
169
|
style: ConfigStyle;
|
|
169
170
|
attributes: ConfigAttribute<T>;
|
|
170
171
|
customAttributes: ConfigCustomAttribute;
|
|
@@ -17,7 +17,7 @@ export declare function signal<T = unknown>(initValue: T, signalConfig?: {
|
|
|
17
17
|
}): ReactiveSignal<T>;
|
|
18
18
|
export declare function effect(cb: () => void, config?: {
|
|
19
19
|
name?: string;
|
|
20
|
-
}):
|
|
20
|
+
}): EffectCb;
|
|
21
21
|
export declare const isReactiveSignal: <R extends ReactiveSignal<any>>(v: R | any) => v is R;
|
|
22
22
|
/**
|
|
23
23
|
* Reactive String (rs). Создаёт зависимый string сигнал от источника.
|
|
@@ -9,3 +9,9 @@ export declare function forkJoin<T extends readonly ReactiveSignal<unknown>[]>(.
|
|
|
9
9
|
[K in keyof T]: UnwrapSignal<T[K]>;
|
|
10
10
|
}>;
|
|
11
11
|
export declare const combineLatest: <T extends readonly ReactiveSignal<any>[]>(...signals: T) => ReactiveSignal<{ [K in keyof T]: UnwrapSignal<T[K]>; }>;
|
|
12
|
+
/**
|
|
13
|
+
* Обработка первого обновления сигнала
|
|
14
|
+
* @param sgn сигнал
|
|
15
|
+
* @param cb функция обратного вызова после первого обновления сигнала
|
|
16
|
+
*/
|
|
17
|
+
export declare const firstUpdate: <T extends ReactiveSignal<any>>(sgn: T, cb: (value: UnwrapSignal<T>) => void) => void;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(function(r,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(r=typeof globalThis<"u"?globalThis:r||self,A(r.ReactiveComponent={}))})(this,function(r){"use strict";var mn=Object.defineProperty;var pn=(r,A,_)=>A in r?mn(r,A,{enumerable:!0,configurable:!0,writable:!0,value:_}):r[A]=_;var u=(r,A,_)=>pn(r,typeof A!="symbol"?A+"":A,_);const A=n=>n&&typeof n=="object"&&("classList"in n||"attributes"in n||"customAttributes"in n||"reactiveClassList"in n||"listeners"in n||"customListeners"in n||"children"in n||"effects"in n||"style"in n||Object.keys(n).some(t=>t.startsWith(".")||t.startsWith("@")||t.startsWith("$")))&&!("hostElement"in n),_=n=>n&&typeof n=="object"&&"hostElement"in n&&"append"in n&&"set"in n&&"addStyle"in n&&"setAttribute"in n&&"addClass"in n&&"addEffect"in n&&"addReactiveContent"in n&&"setReactiveContent"in n&&"clear"in n,D=(n,t,...e)=>{t&&t.apply(n,e)};let G=!0;const S=(...n)=>{G&&console.debug(["[rwc]",...n].join(" | "),...Array.from(n.join("").matchAll(/%c/gm)).map((t,e)=>e%2===0?"color:red":"color:inherit"))},F=n=>n.replace(/([A-Z])/gm,t=>`-${t.toLowerCase()}`),rt=n=>n.replace(/-(\w)/gm,(t,e)=>e.toUpperCase()),B=(n,...t)=>{if(!G)return;const e={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=n.match(/@[rgbpycow]/g)||[],o=s.map(c=>{const a=c.slice(1);return e[a]||"color: inherit"});let i=n;s.forEach(c=>{const a=new RegExp(`\\${c}([^\\s,]+)`,"g");i=i.replace(a,"%c$1")}),console.log(i,...o,...t)},Ot=()=>{G=!0},it=()=>{G=!1};it();const Mt=(n,t)=>{n.every(Boolean)&&t(n)},N=new Set;let Q=!1,x=!1;const $t=()=>{if(!x){x=!0;try{if(Q=!1,N.size===0)return;const n=Array.from(N);N.clear(),n.forEach(t=>{if(t.status==="active"){K(t),O.push(t);try{t()}catch(e){console.error("Error in effect:",e)}finally{O.pop()}}}),N.size>0&&ct()}finally{x=!1}}};function _t(){queueMicrotask($t)}const ct=()=>{Q||(Q=!0,_t())},Ht=n=>{N.add(n),ct()},O=[],K=n=>{var t,e,s,o;(t=n.children)==null||t.forEach(i=>{var c;return(c=i.destroy)==null?void 0:c.call(i)}),(e=n.children)==null||e.clear(),(s=n.cleanupSet)==null||s.forEach(i=>i()),(o=n.cleanupSet)==null||o.clear()};function T(n,t){let e=(t==null?void 0:t.signalCompareFn)||(()=>!0);const s=new Set;function o(){var c;const i=O[O.length-1];return i&&!i.fake&&!s.has(i)&&i.status==="active"&&(s.add(i),(c=i.cleanupSet)==null||c.add(()=>s.delete(i))),!(t!=null&&t.name)&&(i!=null&&i.effectId)&&o.setName(i.effectId),n}return o.signalId=`${(t==null?void 0:t.name)||""}_${Math.random().toString(36).substring(2,15)}`,o.setName=function(i){return o.signalId=`${i}_${Math.random().toString(36).substring(2,15)}`,o},o.setCompareFn=function(i){return e=i,o},o.clearSubscribers=function(){s.clear()},o.getSubscribers=function(){return s},o.peek=function(){return Object.freeze(n)},o.initValue=Object.freeze(n),o.forceSet=function(i){n=i,s.forEach(c=>{Ht(c)})},o.set=function(i,c=e){n!==i&&c(n,i)&&o.forceSet(i)},o.update=function(i){o.set(i(n))},o.pipe=(i,c)=>{c!=null&&c.name&&o.setName(c.name);const a=T(null);return v(()=>{const d=o();v(()=>{const h=i(d);h instanceof Promise?h.then(E=>a.set(E)):R(h)?v(()=>a.set(h()),{name:"pipe_effect_inner"}):a.set(h)},{name:"pipe_effect"})},{name:(c==null?void 0:c.name)||`pipe_${o.signalId}`}),a},o}function v(n,t){var i;const e=`${(t==null?void 0:t.name)||""}_${Math.random().toString(36).substring(2,15)}`;S("current effect",`%c${e}%c`);const s=n;s.status="active",s.children=new Set,s.effectId=e;const o=O[O.length-1];o&&((i=o.children)==null||i.add(s),s.parent=new WeakRef(o),s.destroy=()=>{var c;K(s),(c=o.children)==null||c.delete(s),s.destroy=void 0,s.status="inactive"}),s.cleanupSet=new Set,O.push(s),s(),O.pop()}const R=n=>!!n&&["object","function"].includes(typeof n)&&"set"in n&&"update"in n&&"forceSet"in n&&"signalId"in n;function kt(n,...t){const e=T("");return v(()=>{const s=t.map(i=>R(i)?String(i()):String(i)),o=[n[0]];s.forEach((i,c)=>{o.push(i,n[c+1])}),e.set(o.join(""))}),e}function Wt(n,t){const e=T(t??null),s=o=>e.set(o);return n instanceof Promise?n.then(s):typeof n=="function"&&v(()=>{const o=n();o instanceof Promise?o.then(s):R(o)?v(()=>s(o())):s(o)}),e}function Pt(n,t){let e=n(),s=t();v(()=>{const o=n(),i=t();o!==i&&(o!==e?t.set(o):i!==s&&n.set(i)),e=o,s=i})}function Ft(...n){let t=n.map(s=>s());const e=T(t);return n.forEach((s,o)=>{v(()=>{const i=()=>t.filter(c=>c!==void 0).length;i()===n.length&&(t=Array.from(t).fill(void 0)),t[o]=s(),i()===n.length&&e.set([...t])})}),e}const Bt=(...n)=>{const t=T([]);return v(()=>{t.set(n.map(e=>e()))}),t},Y="eventProps",Z="EVENT_CONFIG",V="observedAttributes",Nt=()=>(n,t)=>{Reflect.get(n,V)||Reflect.defineProperty(n,V,{value:[]}),Reflect.get(n,V).push(F(t))},Vt=n=>(t,e)=>{Reflect.get(t,Y)||Reflect.defineProperty(t,Y,{value:[]}),Reflect.get(t,Z)||Reflect.defineProperty(t,Z,{value:{}}),Reflect.get(t,Z)[e]={bubbles:(n==null?void 0:n.bubbles)??!1,composed:(n==null?void 0:n.composed)??!1},Reflect.get(t,Y).push(e)},tt=(n,t=!1)=>e=>{S(n,"start register static attr",e.prototype[V]);const s=[];if(e.styles){const i=e.styles,c=[];Array.isArray(i)?c.push(...i):c.push(i),c.forEach(a=>{const d=new CSSStyleSheet;d.replaceSync(a),s.push(d);const b=new CSSStyleSheet;b.replaceSync(a.slice(a.indexOf("@property"))),document.adoptedStyleSheets.push(b)})}class o extends e{constructor(...c){S("constructor",`%c${n}%c`),super(t,...c),s.length>0&&this.shadow.adoptedStyleSheets.push(...s)}render(){return S("rwc: render from new class"),e.prototype.render.call(this)}attributeChangedCallback(c,a,d){S("%cAttribute has changed.%c",`%c${c}%c`,`oldValue: ${a}, newValue: ${d}`,`%c${n}%c`);try{d=JSON.parse(d)}catch{}const b=rt(c);if(b in this&&R(this[b])){const h=this[b];h.setName(c),d===null?(h.set(h.initValue),this.removeAttribute(c)):h.set(d)}D(this,e.prototype.attributeChangedCallback,c,a,d)}connectedCallback(){const c=()=>{var d,b;S("rwc: connectedCallback"),S("connectedCallback",`%c${n}%c`,this),(d=this.init)==null||d.call(this),this.providers&&Object.keys(this.providers).length>0&&(S("WRAPPER for providers",n),Object.entries(this.providers).forEach(([h,f])=>{S("register provider",h,f()),this.addEventListener(h,E=>{var m;S("send provider",h,f());const p=E;((m=p.detail)==null?void 0:m.context)===h&&(p.stopPropagation(),p.detail.callback(f))})})),this.checkInjects(),(b=e.prototype[Y])==null||b.forEach(h=>{this[h]=f=>{const E=e.prototype[Z][h],{bubbles:p,composed:m}=E;R(f)?v(()=>{B("@oemit reactive value",f()),this.dispatchEvent(new CustomEvent(h,{detail:f(),bubbles:p,composed:m}))}):(B("@oemit value",f),this.dispatchEvent(new CustomEvent(h,{detail:f,bubbles:p,composed:m})))}}),S("start render",`%c${n}%c`,n);const a=()=>{S("rwc: insertRenderTemplate");const f=this.render().hostElement;f&&this.shadow.appendChild(f),D(this,e.prototype.connectedCallback),this.appendSlotContent()};if(this.rootStyle&&!e.styles){const h=p=>p instanceof Promise||Array.isArray(p)&&p.every(m=>m instanceof Promise),f=this.rootStyle,E=p=>{const m=new CSSStyleSheet;m.replaceSync(p),this.shadow.adoptedStyleSheets.push(m);const w=new CSSStyleSheet;w.replaceSync(p.slice(p.indexOf("@property"))),document.adoptedStyleSheets.push(w)};if(h(f)){const p=[];Array.isArray(f)?p.push(...f):p.push(f),Promise.all(p).then(m=>m.forEach(w=>E(w.default))).then(()=>a())}else{const p=[];Array.isArray(f)?p.push(...f):p.push(f),p.forEach(m=>E(m)),a()}}else a();this.slotContext&&Object.keys(this.slotContext).length>0&&this.shadow.querySelectorAll("slot").forEach(h=>{S(this.slotContext,this.slotContext&&this.slotContext[h.name]),B("@bslot element",h,`name:${h.name};`,h.assignedElements()),h.assignedElements().forEach(f=>{const E=this.slotContext[h.name];this.slotContext&&R(E)&&(B("@oslot element",h,`name:${h.name};`,h.assignedElements()),v(()=>{f.dispatchEvent(new CustomEvent("handleSlotContext",{detail:E()}))}))})})};c.fake=!0,c.component=new WeakRef(this),this.effectSet.add(new WeakRef(c)),v(c,{name:"FAKE_wrapperEffect"})}disconnectedCallback(){this.allSlotContent=[],this.slotContent={},this.htmlSlotContent={},this.effectSet.forEach(c=>{var a,d;return(d=(a=c.deref())==null?void 0:a.destroy)==null?void 0:d.call(a)}),this.effectSet.clear(),this.shadow.replaceChildren(),this.replaceChildren(),D(this,e.prototype.disconnectedCallback)}}return u(o,"observedAttributes",e.prototype[V]??[]),u(o,"renderTagName",n),o.toString=()=>n,customElements.get(n)?console.error(`название тега ${n} повторяется, компонент ${e.name} не зарегистрирован`):customElements.define(n,o),e.renderTagName=n,e};class H extends HTMLElement{constructor(e=!1){super();u(this,"init");u(this,"isSlotLazyLoading",!1);u(this,"slotTemplate");u(this,"slotContext");u(this,"rootStyle");u(this,"modelValue");u(this,"providers");u(this,"effectSet",new Set);u(this,"appendAllSlotContent");u(this,"allSlotContent",[]);u(this,"slotContent",{});u(this,"htmlSlotContent",{});u(this,"shadow");u(this,"injects",{});this.shadow=this.attachShadow({mode:e?"closed":"open"})}appendChild(e,s=!0){var o;if(this.isSlotLazyLoading&&s){if(e instanceof HTMLElement){const i=e.slot||"default";this.htmlSlotContent[i]||(this.htmlSlotContent[i]=[]),(o=this.htmlSlotContent[i])==null||o.push(e)}}else return super.appendChild(e)}appendSlotContent(){var e;(e=this.appendAllSlotContent)==null||e.call(this)}inject(e){return S("%cinject%c",e),this.injects[e]||(this.injects[e]=T(null)),this.injects[e]}checkInjects(){Object.entries(this.injects).forEach(([e,s])=>{S("%cinject%c",`%c${e}%c`,"from BaseElement (dispatch event)"),this.shadow.dispatchEvent(new CustomEvent(e,{detail:{context:e,callback:o=>v(()=>{s.set(o())},{name:e})},bubbles:!0,composed:!0}))})}setReactiveValue(e){this.modelValue=e}}u(H,"observedAttributes",[]),u(H,"renderTagName",""),u(H,"styles");const Jt=n=>"render"in n&&"setReactiveValue"in n,qt="handleSlotContext",lt="onConnected",at=n=>typeof n=="string"?n:JSON.stringify(n),zt=n=>{const t=document.createElement("span");return t.textContent=at(n),t},dt=(n,t)=>(n.appendChild(zt(t)),n),Dt=(n,t)=>(n.replaceChildren(),dt(n,t)),ft=n=>{const t=document.createElement("span");return v(()=>{const e=n();t.textContent=at(e)}),t};class ht{constructor(t){u(this,"wrapper");u(this,"keyedEffects",new Map);u(this,"append",(...t)=>(t.forEach(e=>{var o;const s=e.hostElement;s&&((o=this.hostElement)==null||o.appendChild(s),lt in s&&setTimeout(()=>{var i;(i=s.onConnected)==null||i.call(s,e,s)}))}),this));u(this,"set",(...t)=>{var s;this.clear();const e=document.createDocumentFragment();return t.forEach(o=>{const i=o.hostElement;i&&e.appendChild(i)}),(s=this.hostElement)==null||s.appendChild(e),this});u(this,"removeChild",(...t)=>(t.forEach(e=>{var s,o;if(Array.from(((s=this.hostElement)==null?void 0:s.childNodes.values())||[]).some(i=>i===e.hostElement)){const i=e.hostElement;i&&((o=this.hostElement)==null||o.removeChild(i))}}),this));u(this,"addHtmlContent",t=>{const e=this.hostElement;return e?(dt(e,t),this):this});u(this,"setHtmlContent",t=>{const e=this.hostElement;return e?(Dt(e,t),this):this});u(this,"setAttribute",(t,e)=>{var i;const s=this.hostElement;if(!s)return this;let o;if((typeof e=="boolean"||e===null)&&!(s instanceof H))if(e)o="";else{this.removeAttribute(t);const c=t.toLowerCase();return c in s&&(s[c]=null),this}else typeof e!="string"?o=JSON.stringify(e):o=e;if((i=this.hostElement)==null||i.setAttribute(F(t),o),!(s instanceof H)){const c=t.toLowerCase();c in s&&(s[c]=e)}return this});u(this,"setCustomAttribute",(t,e)=>{var o;let s;return typeof e!="string"?s=JSON.stringify(e):s=e,(o=this.hostElement)==null||o.setAttribute(F(t),s),this});u(this,"setReactiveAttribute",(t,e)=>(this.addEffect(s=>{s.setAttribute(t,e())},t),this));u(this,"setReactiveCustomAttribute",(t,e)=>(this.addEffect(s=>{s.setCustomAttribute(t,e())}),this));u(this,"removeAttribute",t=>{var e;return(e=this.hostElement)==null||e.removeAttribute(F(t)),this});u(this,"addStyle",t=>{const e=this.hostElement;return e?(Object.entries(t).forEach(([s,o])=>{const i=s.startsWith("--");typeof o=="function"?this.addEffect(()=>{if(i){const c=String(o()||"");e.style.setProperty(s,c)}else e.style[s]=o()}):typeof o=="string"&&(i?e.style.setProperty(s,o):e.style[s]=o)}),this):this});u(this,"onConnected",t=>this.hostElement?(Reflect.defineProperty(this.hostElement,lt,{get(){return t}}),this):this);u(this,"addClass",(...t)=>(t.forEach(e=>{var s;typeof e=="string"?(s=this.hostElement)==null||s.classList.add(...e.split(" ").flatMap(o=>o.split(`
|
|
2
|
-
`)).map(o=>o.trim()).filter(Boolean)):(()=>{let o=null;this.addEffect(()=>{const i=e();i.length>0&&(o?this.replaceClass(o,i):this.addClass(i),o=i)})})()}),this));u(this,"setClass",(...t)=>{var e,s,o;return(s=this.hostElement)==null||s.classList.remove(...((e=this.hostElement)==null?void 0:e.classList)||[]),(o=this.hostElement)==null||o.classList.add(...t),this});u(this,"addReactiveClass",t=>(Object.keys(t).forEach(e=>{this.addEffect(s=>{t[e]()?s.addClass(e):s.removeClass(e)})}),this));u(this,"removeClass",(...t)=>{var e;return(e=this.hostElement)==null||e.classList.remove(...t),this});u(this,"replaceClass",(t,e)=>{var s;return(s=this.hostElement)==null||s.classList.replace(t,e),this});u(this,"addEffect",(t,e)=>{var i,c;const s=this.hostElement;if(!s)return this;const o=()=>t(this,s);if(e){const a=(i=this.keyedEffects.get(e))==null?void 0:i.deref();a&&K(a)}return(c=s.effectSet)==null||c.add(new WeakRef(o)),o.component=this.wrapper,v(o,{name:(e==null?void 0:e.toString())||s.tagName}),this});u(this,"addReactiveContent",t=>{var e;return(e=this.hostElement)==null||e.appendChild(ft(t)),this});u(this,"setReactiveContent",t=>{var e;return this.clear(),(e=this.hostElement)==null||e.appendChild(ft(t)),this});u(this,"clear",()=>{var t;return(t=this.hostElement)==null||t.replaceChildren(),this});this.wrapper=t;const e=t.deref();e&&(e.effectSet=new Set)}get hostElement(){return this.wrapper.deref()}addEventlistener(t,e,s=!1){var o;return(o=this.hostElement)==null||o.addEventListener(t,i=>e(i,this,this.hostElement),s),this}}class Gt extends ht{constructor(){super(...arguments);u(this,"setReactiveValue",e=>(this.hostElement instanceof H&&this.hostElement.setReactiveValue(e),this));u(this,"setSlotTemplate",e=>{var o;const s=(o=this.hostElement)==null?void 0:o.slotTemplate;return s&&Object.entries(e).forEach(([i,c])=>{s[i]=c}),this})}}const Kt=()=>()=>{},ut=n=>new Gt(new WeakRef(n)),mt=n=>new ht(new WeakRef(n)),pt=(n,...t)=>({classList:[...n.map(e=>e.trim()).filter(Boolean),...t]}),Yt=(n,...t)=>pt(n,...t),et=(n,t)=>{if(!t||!n.deref())return;const e=Object.keys(t||{}).filter(o=>o.startsWith(".")||o.startsWith("@")||o.startsWith("$"));e.filter(o=>o.startsWith(".")).forEach(o=>{t!=null&&t.attributes||(t.attributes={}),t.attributes[o.slice(1)]=t[o]}),e.filter(o=>o.startsWith("@")).forEach(o=>{t!=null&&t.listeners||(t.listeners={});const i=o.slice(1);t.listeners[i]=t[o]}),e.filter(o=>o.startsWith("$")).forEach(o=>{t!=null&&t.effects||(t.effects=[]),t.effects.push(t[o])});const s=n.deref();if(s)return St(s,t.classList),vt(s,t.style),wt(s,t.attributes),yt(s,t.reactiveClassList),bt(s,t.customAttributes),Ct(s,t.children),Et(s,t.effects),nt(s,t.listeners),nt(s,t.customListeners),s},nt=(n,t)=>{t&&Object.entries(t).forEach(([e,s])=>{typeof s=="function"&&n.addEventlistener(e,s)})},Et=(n,t)=>t==null?void 0:t.forEach(e=>n.addEffect(e)),Ct=(n,t)=>J(new WeakRef(n),...t||[])??n,bt=(n,t)=>{const e=t;e&&Object.keys(e).forEach(s=>{R(e[s])?n.setReactiveCustomAttribute(s,e[s]):typeof e[s]=="function"?n.addEffect(()=>{n.setCustomAttribute(s,e[s]())}):n.setCustomAttribute(s,e[s])})},St=(n,t)=>n.addClass(...t||[]),yt=(n,t)=>n.addReactiveClass(t||{}),vt=(n,t)=>n.addStyle(t||{}),wt=(n,t)=>{const e=t,s=(o,i)=>{i!==void 0&&(R(i)?n.setReactiveAttribute(o,i):typeof i=="function"?n.addEffect(()=>{n.setAttribute(o,i())}):n.setAttribute(o,i))};e&&Object.keys(e).forEach(o=>{s(o,e[o])})},J=(n,...t)=>{const e=n.deref();if(e)return t.forEach(s=>{typeof s=="string"?s.trim().length>0&&e.addHtmlContent(s):R(s)?e.addReactiveContent(s):e.append(s)}),e},k=(n,t)=>{const e=document.createElement(n),s=mt(e);return et(new WeakRef(s),t)??s},U=(n,t)=>{const[e,...s]=n.split(" ").map(i=>i.trim()),o=k(e,t);return s.length>0&&o.addClass(...s),(...i)=>J(new WeakRef(o),...i.filter(Boolean).flat().flatMap(c=>typeof c=="function"&&!R(c)?j(()=>c(o)):c))??o},j=n=>{const t=`getSignalContent_${Math.random().toString(36).substring(2,15)}`;return k("div").addStyle({display:"contents"}).addEffect(e=>{e.clear(),J(new WeakRef(e),...[n()].flat())},t)},Zt=(n,t,e)=>{const s=k("div").addStyle({display:"contents"}),o=new Map,i=new Map,c=new Map,a=new Map;let d=[];const b=new Set;let h=n.peek();const f=m=>{b.delete(m),o.delete(m),i.delete(m),c.delete(m),a.delete(m)},E=m=>{if(!a.has(m)){const w=d.indexOf(m);return a.set(m,w),w}return a.get(m)},p=(m,w,q)=>Array.from(q.children).indexOf(m)!==w;return v(()=>{const m=n(),w=m.map(t).map(C=>typeof C=="string"?C:C.toString()),q=new Set(w);a.clear(),w.forEach((C,y)=>{a.set(C,y)}),d=w;const M=s.hostElement;if(!M)return;S("containerChildren",Array.from(M.children),d);const z=[];Array.from(M.children).forEach(C=>{const y=C.dataset.key;y&&!q.has(y)&&z.push(C)}),z.forEach(C=>{const y=C.dataset.key;S("remove element",y,C),C.remove(),f(y)}),w.forEach((C,y)=>{var g;const L=m[y],P=h[y];if(!o.has(C))S("create new element",C,L),o.set(C,T(Math.random().toString(36).substring(2,15))),i.set(C,()=>e(L,y,m).setCustomAttribute("data-key",C));else if(P&&JSON.stringify(L)!==JSON.stringify(P)){const I=c.get(C);(g=o.get(C))==null||g.set(Math.random().toString(36).substring(2,15)),i.set(C,()=>e(L,y,m).setCustomAttribute("data-key",C)),I&&I.parentNode&&S("mark element for update",C)}}),h=[...m.map(C=>({...C}))];const X=()=>{o.forEach((C,y)=>{S("key from setTimeout foreach currItemSignalMap",y),b.has(y)||(b.add(y),v(()=>{var jt;C();const L=E(y),P=(jt=i.get(y))==null?void 0:jt();if(!P||!P.hostElement)return;const g=s.hostElement,I=P.hostElement;if(!g)return;S("call effect from setTimeout",y,I);const $=c.get(y);if($&&$.parentNode===g){if(p($,L,g)){const W=g.children[L];W&&W!==$?g.insertBefore($,W):W||g.appendChild($)}I!==$&&($.replaceWith(I),c.set(y,I))}else if(c.set(y,I),L<g.children.length){const W=g.children[L];W?g.insertBefore(I,W):g.appendChild(I)}else g.appendChild(I)}))})};Promise.resolve().then(()=>X())}),s},Ut=n=>{let t=[k("div")],e=!1;return v(()=>{var i,c;const s=n();e=Array.isArray(s);const o=[];o.push(...[s].flat()),o.length===0&&o.push(k("div").addStyle({display:"none"}).setAttribute("id","empty_template"));try{S("newReactiveComponent.map",o.map(a=>{var d;return S("newReactiveComponent hostElement",a.hostElement),(d=a.hostElement)==null?void 0:d.id})),S("currComponent[0].hostElement?.id",(i=t[0].hostElement)==null?void 0:i.id,t),(c=t[0].hostElement)==null||c.replaceWith(...o.map(a=>a.hostElement).filter(Boolean)),t.slice(1).forEach(a=>{var d;return(d=a.hostElement)==null?void 0:d.remove()}),t=o}catch(a){console.error(a)}}),e?t:t[0]},Xt=n=>qt in n,Qt=n=>{const t=U("div")().addStyle({display:"contents"}),e=s=>{const o=t.hostElement;return o&&(o.innerHTML=s),t};return typeof n=="string"?e(n):t.addEffect(()=>{e(n())}),t},st=(n,t,e)=>n?j(t):e?j(e):U("div")().setAttribute("id","empty_div_renderIf").addStyle({display:"none"}),At=(n,t,e)=>j(()=>st(!!n(),t,e)),xt=(n,t,e)=>typeof n=="boolean"?st(n,t,e):At(n,t,e),ot=(n,t)=>j(t).addEffect((e,s)=>{if(typeof n=="boolean")s.style.display=n?"block":"none";else{const o=n()?"block":"none";s.style.display=o}}),te=(n,t,e)=>{const s=[ot(n,t)].flat();return e&&s.push(...[ot(()=>typeof n=="boolean"?!n:!n(),e)].flat()),j(()=>s)},gt=(n,t)=>{S("createCustomElement",n);const e=document.createElement(n),s=ut(e);return e.init=()=>{et(new WeakRef(s),t)},s},Rt=(n,t)=>{const e=n.split(" ").slice(1).map(o=>o.trim()),s=gt(n.split(" ")[0],t);return Array.isArray(e)&&e.length>0&&s.addClass(...e),(...o)=>{const i=o.filter(Boolean).flat().flatMap(a=>typeof a=="function"&&!R(a)?j(()=>a(s)):a),c=s.hostElement;return c&&(c.allSlotContent=i,c.slotContent=i.filter(_).reduce((a,d)=>{var h;const b=((h=d.hostElement)==null?void 0:h.getAttribute("slot"))||"default";return a[b]||(a[b]=[]),a[b].push(d),a},{}),c.appendAllSlotContent=()=>{J(new WeakRef(s),...i)}),s}},Lt=(n,t,e)=>Rt(`${n.renderTagName}${t&&typeof t=="string"?" "+t:""}`,A(t)?t:t&&typeof t=="string"?e:void 0),ee=()=>{const n=()=>{};return n.oldValue=null,n},ne=()=>({}),It=(n,t,e)=>{const s=t?tt(t,e)(n):n;return(o,...i)=>{const c=[...i];return o&&!A(o)&&c.unshift(o),Lt(s,A(o)?o:{})(...c)}},se=n=>[It(n),(t,e)=>{tt(t,e)(n)}],l={};["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(n=>{l[n]=(t,...e)=>{let s=[...e];return t&&!A(t)&&(s=[t].concat(s)),U(n,A(t)?t:{})(...s)}});const Tt=l.div,oe=l.span,re=l.section,ie=l.input,ce=l.button,le=l.table,ae=l.tr,de=l.td,fe=l.th,he=l.ul,ue=l.li,me=l.ol,pe=l.form,Ee=l.label,Ce=l.select,be=l.option,Se=l.textarea,ye=l.img,ve=l.a,we=l.p,Ae=l.h1,ge=l.h2,Re=l.h3,Le=l.h4,Ie=l.h5,Te=l.h6,je=l.br,Oe=l.hr,Me=l.pre,$e=l.code,_e=l.nav,He=l.header,ke=l.footer,We=l.main,Pe=l.aside,Fe=l.article,Be=l.figure,Ne=l.figcaption,Ve=l.blockquote,Je=l.cite,qe=l.small,ze=l.strong,De=l.em,Ge=l.b,Ke=l.i,Ye=l.u,Ze=l.s,Ue=l.sub,Xe=l.sup,Qe=l.mark,xe=l.del,tn=l.ins,en=l.details,nn=l.summary,sn=l.progress,on=l.meter,rn=l.audio,cn=l.video,ln=l.canvas,an=l.slot,dn=n=>t=>n(t).addClass(...t.classList??[]).addReactiveClass(t.reactiveClassList??{});function fn(n,t){let e=0;return(...s)=>{const o=Date.now();o-e>=t&&(n(...s),e=o)}}const hn=(n,t)=>j(()=>{const e=n();let s=null;return e.map((o,i)=>Tt({"@dragstart":(c,a,d)=>{s=d},"@dragend":(c,a,d)=>{d.style.transform="",d.removeAttribute("draggable")},"@mousedown":(c,a,d)=>{d.style.transform="translateZ(0)",d.setAttribute("draggable","true")},"@dragover":c=>{c.preventDefault()},"@dragenter":fn((c,a,d)=>{var b,h,f;if(c.preventDefault(),s){let E=s,p=d;const m=((b=s.getClientRects().item(0))==null?void 0:b.y)??0,w=((h=d.getClientRects().item(0))==null?void 0:h.y)??0;m<w&&([E,p]=[d,s]),(f=d.parentElement)==null||f.insertBefore(E,p)}},200)},t(o,i,[...n.peek()])))}),un=(n,t,e)=>{let s=[],o=[];const i=k("div").addStyle({display:"contents"}),c=new Map,a=new Map;return v(()=>{const d=n(),b=d.map(t);o.filter(f=>!b.includes(f)).forEach(f=>{var E,p;c.delete(f),(p=(E=i.hostElement)==null?void 0:E.querySelector(`[data-key="${f}"]`))==null||p.remove()}),b.forEach((f,E)=>{o.includes(f)||c.set(f,()=>e(d[E],E,d).setCustomAttribute("data-key",f))}),b.forEach((f,E)=>{var p;if(o.includes(f)){JSON.stringify(s[o.indexOf(f)])!==JSON.stringify(d[E])&&((p=a.get(f))==null||p.set({templateFunc:()=>e(d[E],E,d),items:d,itemsKey:b,index:E}));return}a.set(f,T({templateFunc:()=>e(d[E],E,d),items:d,itemsKey:b,index:E})),queueMicrotask(()=>{v(()=>{var z,X,C;const{templateFunc:m,index:w}=((z=a.get(f))==null?void 0:z())??{},q=(X=i.hostElement)==null?void 0:X.querySelector(`[data-key="${f}"]`),M=(m==null?void 0:m().setCustomAttribute("data-key",f).hostElement)??document.createElement("div");q?(C=i.hostElement)==null||C.childNodes.forEach((y,L)=>{y instanceof HTMLElement&&y.getAttribute("data-key")===f&&(w===L?(h(w??0,i.hostElement,M),y.remove()):h(w??0,i.hostElement,M))}):h(w??0,i.hostElement,M)})})});const h=(f,E,p)=>{p&&E&&(f<E.children.length?E.insertBefore(p,E.children[f]):E.appendChild(p))};o=b,s=[...d]}),i};r.BaseElement=H,r.a=ve,r.addAttributeList=wt,r.addClassList=St,r.addCustomAttributes=bt,r.addReactiveClassList=yt,r.addStyleList=vt,r.appendContentItem=J,r.article=Fe,r.aside=Pe,r.audio=rn,r.b=Ge,r.bindReactiveSignals=Pt,r.blockquote=Ve,r.br=je,r.button=ce,r.camelToKebab=F,r.canvas=ln,r.checkCall=D,r.checkRef=Mt,r.cite=Je,r.classList=pt,r.cls=Yt,r.code=$e,r.colorLog=B,r.combineLatest=Bt,r.component=tt,r.configCustomComponent=se,r.createComponent=dn,r.createCustom=Lt,r.createCustomEl=Rt,r.createCustomElement=gt,r.createEl=U,r.createElement=k,r.createSignal=Wt,r.customElementHelpers=ut,r.ddList=hn,r.defineSlotTemplate=ne,r.del=xe,r.details=en,r.disableLogs=it,r.div=Tt,r.effect=v,r.elementHelpers=mt,r.em=De,r.enableLogs=Ot,r.event=Vt,r.eventEmitter=Kt,r.figcaption=Ne,r.figure=Be,r.footer=ke,r.forkJoin=Ft,r.form=pe,r.getList=un,r.getSignalContent=j,r.h1=Ae,r.h2=ge,r.h3=Re,r.h4=Le,r.h5=Ie,r.h6=Te,r.header=He,r.hr=Oe,r.i=Ke,r.img=ye,r.initComponent=et,r.input=ie,r.ins=tn,r.isBaseElement=Jt,r.isComponentConfig=_,r.isComponentInitConfig=A,r.isReactiveSignal=R,r.isSlotTemplate=Xt,r.kebabToCamel=rt,r.label=Ee,r.li=ue,r.main=We,r.mark=Qe,r.meter=on,r.nav=_e,r.newEventEmitter=ee,r.ol=me,r.oldGetList=Zt,r.option=be,r.p=we,r.pre=Me,r.progress=sn,r.projectLog=S,r.property=Nt,r.removeEffect=K,r.renderIf=st,r.rs=kt,r.rxRenderIf=At,r.s=Ze,r.section=re,r.select=Ce,r.setChildren=Ct,r.setEffects=Et,r.setListeners=nt,r.show=te,r.showIf=ot,r.signal=T,r.signalComponent=Ut,r.slot=an,r.small=qe,r.span=oe,r.strong=ze,r.sub=Ue,r.summary=nn,r.sup=Xe,r.table=le,r.td=de,r.textarea=Se,r.th=fe,r.tr=ae,r.u=Ye,r.ul=he,r.unsafeHtml=Qt,r.useCustomComponent=It,r.video=cn,r.when=xt,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|