@joystick.js/ui-canary 0.0.0-canary.94 → 0.0.0-canary.96
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 +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/_package.json
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,4 +18,4 @@ var Ar=Object.create;var ue=Object.defineProperty;var Dr=Object.getOwnPropertyDe
|
|
|
18
18
|
@media screen and (max-height: ${R}px) {
|
|
19
19
|
${typeof h=="function"?h(e):h}
|
|
20
20
|
}
|
|
21
|
-
`}}return r}return""}catch(r){i("component.css.compileCSS",r)}};var Jr=(t={},e=null)=>{try{let r=e(t);return r&&m(r)&&!q(r)?Object.assign({},r):{}}catch(r){i("component.state.compile.compileState",r)}},te=(t={},e={})=>{try{return u(e)?Jr(t,e):Object.assign({},e)}catch(r){i("component.state.compile",r)}};var pe={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var Ht=(t={},e={})=>{try{return e?Object.entries({...pe,...e||{}}).reduce((r={},[o,n])=>(r[o]=()=>n({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):pe}catch(r){i("component.lifecycle.compile",r)}};var re=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,n])=>(r[o]=(...s)=>(y(`ui.${t?.options?.test?.name||f()}.methods.${o}`,[...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}]),n(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}})),r),{})}catch{i("component.methods.compile")}};var fe=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>M(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){i("component.url.compile",e)}};var Qr=(t={},e=null)=>{try{let r=e(t);return r&&m(r)&&!q(r)?Object.assign({},r):{}}catch(r){i("component.props.compileDefaultProps.compile",r)}},Ut=(t={},e={})=>{try{return u(e)?Qr(t,e):Object.assign({},e)}catch(r){i("component.props.compileDefaultProps",r)}};var zt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=f(8),t.ssrId=e?._ssrId||null,t.css=ee(),t.data=X(e?.dataFromSSR,e?._componentId),t.defaultProps=Ut(t,e?.defaultProps),t.props=Nt(t?.defaultProps,e?.props),t.state=te(t,e?.state),t.events=e?.events||{},t.lifecycle=Ht(t,e?.lifecycle),t.methods=re(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=Vt,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=fe(e?.url)),r&&window.__joystick_url__&&(t.url=fe(window.__joystick_url__)),r&&window.__joystick_user__&&(t.user=window.__joystick_user__),r&&e?.websockets&&u(e?.websockets)){let o=e.websockets(t),n=m(o)&&Object.entries(o);for(let s=0;s<n?.length;s+=1){let[c,a]=n[s];Y({test:t?.test,url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(l={})=>{t.websockets={...t.websockets||{},[c]:l}})}}}catch(r){i("component.registerOptions",r)}};var Yr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("addToQueue.getQueue",e)}},W=(t="",e=null)=>{try{S()||(Yr(t)||{}).array.push({callback:e})}catch(r){i("addToQueue",r)}};var oe=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&u(o.options.data)){let n=await o.options.data(t,e,r,o);return Promise.resolve(n)}return Promise.resolve()}catch(n){i("component.data.fetch",n)}};var Bt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{y(`ui.${r?.options?.test?.name||f()}.data.refetch`,[o]);let n=await oe(G,e,o,r);return r.data=Bt(n,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=n),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){i("component.data.compile",o)}},Zt=Bt;var Gt=(t={})=>{try{if(!S()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return Zt(e,r,t)}return t?.data||{}}catch(e){i("component.loadDataFromWindow",e)}};var Qt=Hr(Wt());var Kt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(m(t)&&o){let n=Object.keys(t);for(let s=0;s<n.length;s+=1){let c=n[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let l=0;l<a.length;l+=1){let x=a[l],g=Kt(x,e,r);if(g!==null)return g}}}return null}catch(o){i("component.findComponentInTreeByField",o)}},D=Kt;var Jt=(t="",e={},r=null)=>{let o=D(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var Xr=(t={},e={},r=null)=>{try{let o=B(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){i("component.renderMethods.component.renderForClient",o)}},eo=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){i("component.renderMethods.component.renderToHTMLForSSR",e)}},to=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){i("component.renderMethods.component.collectDataFunctionsForSSR",e)}},ro=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};Jt(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){i("component.renderMethods.component.handleAddComponentToParent",e)}},oo=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&W("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e),y(`ui.${e?.options?.test?.name||f()}.lifecycle.onBeforeMount`,[e])}),!t.renderedComponent&&e.options.lifecycle.onMount&&W("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e),y(`ui.${e?.options?.test?.name||f()}.lifecycle.onMount`,[e])}))}catch(r){i("component.renderMethods.component.handleLifecycle",r)}},no=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Qt.diff)(e?.existingPropsMap,r)?.length>0&&W("lifecycle.onUpdateProps",()=>{let n=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(n||{},r,t),y(`ui.${t?.options?.test?.name||f()}.lifecycle.onBeforeMount`,[n||{},r,t])})}catch(o){i("component.renderMethods.component.handleOnChangeProps",o)}},io=function(){return function(e=null,r={},o={}){let n=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[n.id]||{},c=o.children[n.id]||[],a=s[c?.length];return n.state=a?.state||n.state,o.children[n.id]=[...o.children[n.id]||[],n],n.parent=o,no(n,o,r),W("lifecycle.onMount",()=>{n.setDOMNodeOnInstance()}),oo(this,n),n.parent&&ro(n),n.options.data&&n.parent.walkingTreeForSSR&&n.parent.ssrTree.dataFunctions?to(n):n.parent&&n.parent.ssrTree?eo(n):Xr(n,this,a?.children)}},so=function(e,r){try{let o=this;return new io().bind({})(e,r,o)}catch(o){i("component.renderMethods.component",o)}},he=so;var ao=function(e=[],r=null){try{return u(r)&&e&&Array.isArray(e)?e.map((o,n)=>r(o,n)).join(""):""}catch(o){i("component.renderMethods.each",o)}},we=ao;var co=(t="",e=[])=>{try{return e.reduce((r,[o,n])=>r.replace(`{{${o}}}`,n),t)}catch(r){i("component.renderMethods.i18n.replacePlaceholdersInString",r)}},ye=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),n=typeof t=="object"&&!o;if(r)return co(t,e);if(o)return t?.map(s=>ye(s,e));if(n)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=ye(a,e),s),{})}catch(r){i("component.renderMethods.i18n.handleTranslationReplacement",r)}},lo=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>r[o],e)}catch(r){i("component.renderMethods.i18n.getTranslationAtPath",r)}},uo=function(t="",e={}){try{let r=S()?this.translations:window.__joystick_i18n__,n=t?.includes(".")?lo(t,r):r[t];if(!r||!n)return"";let s=Object.entries(e);return ye(n,s)}catch(r){i("component.renderMethods.i18n",r)}},ge=uo;var mo=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){i("component.renderMethods.when",o)}},xe=mo;var Yt={c:he,component:he,e:we,each:we,i:ge,i18n:ge,w:xe,when:xe};var Xt=(t={},e={})=>{try{return Object.entries(Yt).reduce((r,[o,n])=>(r[o]=n.bind({...t,...e}),r),{})}catch(r){i("component.renderMethods.compile",r)}};var er=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((n={})=>({state:n?.state,children:er(n?.children)})),e),{})}catch(e){i("component.render.getExistingStateMap.buildMapForChildren",e)}},tr=(t={})=>{try{return er(t)}catch(e){i("component.render.getExistingStateMap",e)}};var rr=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),po=new RegExp(/\n/g);var fo=(t="")=>{try{return(t.match(rr)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){i("component.render.sanitizeHTML.removeCommentedCode",e)}},or=(t="")=>{try{let e=`${t}`;return e=fo(e),e}catch(e){i("component.render.sanitizeHTML",e)}};var nr=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:n=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${n}">${e}</div>`}catch(r){i("component.render.wrapHTML",r)}};var ir=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let n=0;n<o?.length;n+=1){let[s,c]=o[n];for(let a=0;a<c?.length;a+=1){let l=c[a];Object.entries(l?.timers)?.length>0&&r.push(...Object.values(l?.timers)),Object.entries(l?.children)?.length>0&&ir(l?.children,r)}}if(r?.length>0)for(let n=0;n<r?.length;n+=1)clearTimeout(r[n])}catch(r){i("component.render.clearTimersOnChildren",r)}},sr=ir;var ie=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=X(e.dataFromSSR,t.id)||{}),sr(t?.children);let r=tr(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Xt({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=re(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),n=or(o),s=nr(t,n);return{unwrapped:n,wrapped:s}}catch(r){i("component.render.toHTML",r)}};var ho=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){i("component.virtualDOM.build.parseAttributeMap",e)}},ar=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?ar(e):be(e)):be(t)}catch(e){i("component.virtualDOM.build.flattenWhenTags",e)}},be=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:ho(t.attributes),children:[].flatMap.call(t.childNodes,o=>ar(o))};return e==="text"&&(r=t.textContent),r}catch(e){i("component.virtualDOM.build",e)}},K=be;var wo=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){i("component.virtualDOM.build.convertHTMLToDOM",e)}},cr=(t="")=>{try{let e=wo(t);return K(e)}catch(e){i("component.virtualDOM.build",e)}};var dr=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var yo=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[n,s]=r[o];dr(n)&&e.setAttribute(n,s)}for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(n){let s=lr(n);e.appendChild(s)}}return e}catch(e){i("component.virtualDOM.renderTreeToDOM.renderElement",e)}},lr=(t=null)=>{try{return M(t)?document.createTextNode(t):yo(t)}catch(e){i("component.virtualDOM.renderTreeToDOM",e)}},Z=lr;var B=(t={},e={})=>{try{let r=ie(t,{existingChildren:e?.existingChildren}),o=cr(r.wrapped,t),n=e.includeActual&&o?Z(o):null;return{html:r,virtual:o,actual:n}}catch(r){i("component.render.getUpdatedDOM",r)}};var ur=(t={},e={})=>{try{let r=B(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){i("component.render.forMount",r)}};var go=(t={},e={})=>{let r=[];for(let[o,n]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,n),s));for(let o in t)o in e||r.push(n=>(n&&n.removeAttribute&&n.removeAttribute(o),n));return o=>{for(let n of r)n&&typeof n=="function"&&n(o)}},se=go;var xo=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let n=0;n<o;n+=1){let s=t[n],c=e[n];r.push([s,c])}return r},mr=xo;var bo=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},$o=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},ko=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(n=>{let s=c=>{let a=Z(n);return c.appendChild(a),c};r.push(s)}),r},Eo=(t=[],e=[])=>{let r=[];return t.forEach((o,n)=>{let s=ce(o,e[n]);r.push(s)}),r},Fo=(t=[],e=[])=>{let r=Eo(t,e),o=ko(t,e);return n=>{if(n){let s=mr(r,n.childNodes);$o(s),bo(o,n)}return n}},ae=Fo;var pr={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),se(t.attributes,e.attributes)(r),ae([],e.children)(r);let n=r.querySelector(`option[value="${o}"]`);if(n&&(r.value=o),!n){let s=r.querySelector("option");r.value=s?.value||""}return r}};var $e=(t,e)=>r=>{let o=t?Z(t):null;return r&&r.replaceWith(o),o},Mo=()=>t=>{t&&t.remove()},So=(t=void 0,e=void 0)=>t===void 0||e===void 0?Mo():typeof t=="string"||typeof e=="string"?$e(e,t):t.tagName!==e.tagName?$e(e):e.tagName==="select"?pr.select(t,e):["pre","code"].includes(e.tagName)?$e(e,t):n=>(se(t.attributes,e.attributes)(n),ae(t.children,e.children)(n),n),ce=So;var To=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("processQueue.getQueue",e)}},V=(t="",e=null)=>{try{S()||(To(t)||{}).process(e)}catch(r){i("processQueue",r)}};var fr=(t="",e=null)=>{let r=D(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var hr=(t="",e={},r=null)=>{let o=D(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var wr=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(m(n)&&n.attributes&&n.attributes["js-i"]&&n.attributes["js-i"]===e){t.children[o]=r;break}m(n)&&wr(n,e,r)}},yr=wr;var gr=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...n]=e.split(" ");return{type:o.toLowerCase(),selector:n.join(" "),handler:r}})}catch(e){i("component.events.serialize",e)}};var xr=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?gr(t?.events):[];for(let n=0;n<o?.length;n+=1){let s=o[n];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}}),y(`ui.${t?.options?.test?.name||f()}.events.${s.type}.selector_${s?.selector}`,[a,{...t||{},setState:t?.setState.bind(t),...e||{}}])}})}if(t?.children){let n=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<n?.length;s+=1){let c=n[s];xr(c,e,r)}}return r}catch(o){i("component.eve!nts.registerListenersFix.getListeners",o)}},_o=(t={},e={})=>{try{let o=xr(t,e,[])?.flatMap((n={})=>[].flatMap.call(n?.elements||[],s=>{let{elements:c=[],...a}=n||{};return{...a,element:s}}));for(let n=0;n<o?.length;n+=1){let{instance:s,element:c,elementSelector:a,type:l,handler:x}=o[n];c.addEventListener(l,x),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:l,handler:x}]}}catch(r){i("component.events.registerListenersFix",r)}},de=_o;var br=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((n=[],s=[])=>[...n,...s],[])).flatMap((n={})=>br(n));e=[...e,...o]}return e}catch(e){i("component.events.unregisterListenersFix.getListeners",e)}},Co=(t={})=>{try{let e=br(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:n,type:s,handler:c}=e[r];n.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){i("component.events.unregisterListenersFix",e)}},$r=Co;var kr=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},lt(e),zt(this,e),this.data=Gt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},n=this){let s=await oe(e,r,o,n);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=K(this.DOMNode);this.dom.virtual=r}let e=this.parent?D(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!S())return{instanceId:this.instanceId}}render(e={}){if(y(`ui.${this?.options?.test?.name||f()}.render`,[e]),e?.mounting)return ur(this,e);let r=this.onBeforeRender();$r(this),fr(this.instanceId);let o=B(this,{}),n=ce(this.dom.virtual,o.virtual);n&&u(n)&&V("lifecycle.onBeforeMount",()=>{let s=n(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,de(this,this.renderMethods),this.setDOMNodeOnInstance(),V("domNodes",()=>{V("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ie(this,e)}onAfterRender(e={},r={}){S()||(hr(e.instanceId,this),window.joystick._internal.css.update(),V("lifecycle.onUpdateProps"),r?.afterSetStateRender&&u(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&u(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){y(`ui.${this?.options?.test?.name||f()}.setState`,[e,r]),this.state=te(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&u(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[f()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[f()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=D(window.joystick._internal.tree,this.instanceId,"instanceId"),n=D(window.joystick._internal.tree,r,"instanceId");if(n?.instance?.DOMNode){let s=K(n?.instance?.DOMNode);yr(o?.instance?.dom?.virtual,n?.instanceId,s)}}},Er=kr;var Fr=(t={})=>{try{return(e={})=>new Er({...t,props:e?.props,url:e?.url,translations:e?.translations,api:e?.api,req:e?.req,parent:e?.parent})}catch(e){i("component",e)}};var Mr=(t={})=>{try{window.joystick._internal.tree={id:t?.id||null,instanceId:t?.instanceId||null,instance:t,children:[]}}catch(e){i("mount.initializeJoystickComponentTree",e)}};var Sr=(t={},e=null)=>{try{return t.innerHTML="",t.appendChild(e),e}catch(r){i("mount.appendToDOM",r)}};var Tr=(t=null,e={},r=null)=>{try{u(t)||i("mount","Component to mount must be a function."),m(e)||i("mount","props must be an object."),Re(r)||i("mount","target must be a DOM node.");let o=t({props:e});Mr(o);let n=o.render({mounting:!0,existingChildren:window.__joystick_childrenBeforeHMRUpdate__||null});return n&&(n.setAttribute("js-c",o.id),n.setAttribute("js-i",o.instanceId)),o.lifecycle.onBeforeMount(),V("lifecycle.onBeforeMount"),Sr(r,n),o.setDOMNodeOnInstance(),window.joystick._internal.css.update(),de(o,o.renderMethods),o.lifecycle.onMount(),V("lifecycle.onMount"),o}catch(o){i("mount",o)}};var _r=class{constructor(e=[]){this.array=[...e],this.array.push=function(){Array.prototype.push.apply(this,arguments)}}async process(e=null){if(this.array.length>0){let r=this.array.shift();r&&r.callback&&(await r.callback(),this.process(e))}else e&&e()}},N=_r;var vo=new RegExp(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g),Oo=new RegExp(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g),jo=(t,e)=>(e||"").replace(vo,()=>"").replace(Oo,r=>["@",": "].some(o=>r?.includes(o))?r:`[js-c="${t}"] ${r.trim()}`)?.trim(),Cr=(t={},e=[])=>{if(t.instance&&t.instance.options&&t.instance.options.css){let r=t.instance.id,o=t.instance.options.css,n=ee(o,t.instance),s=jo(r,n);e.push(s)}if(t.children&&t.children.length>0){let r=t?.children?.length||0;for(;r--;)Cr(t.children[r],e)}return e},vr=Cr;var Or=()=>{try{let t=document.head.querySelector("style[js-styles]"),r=vr(window.joystick?._internal?.tree).reverse().join("").trim();if(t?.innerText===r)return;if(t&&(t.innerHTML=r),!t){let o=document.createElement("style");o.setAttribute("js-styles",""),o.innerHTML=r,document.head.appendChild(o)}}catch(t){i("css.update",t)}};var jr=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var Ro=ve,Ao=Le,Do=G.get,Lo={get:Pe,track:me},Po=Ie,Io=qe,qo=G.set,su=Ne,au=me,Vo=ze,ke=()=>typeof window!="undefined"?window.__joystick_env__:typeof process!="undefined"?"production":null,le={_external:{},_internal:{last_interaction:null,css:{update:Or},queues:{domNodes:new N([]),eventListeners:new N([]),lifecycle:{onBeforeMount:new N([]),onMount:new N([]),onUpdateProps:new N([])},render:new N([])},tree:{},eventListeners:[]},accounts:Ro,cache:Ao,component:Fr,env:{development:ke()==="development",test:ke()==="test"},external:Lo,get:Do,html:Po,id:f,mount:Tr,renderComponentToHTML:Io,set:qo,upload:Vo,timers:{}};typeof window!="undefined"&&ke()!=="test"&&(document.body.addEventListener("mouseover",()=>{jr(()=>{le._internal.last_interaction=new Date().toISOString()},1e3)}),setInterval(()=>{let t=new Date;t.setMinutes(t.getMinutes()-1),le._internal.last_interaction<=t.toISOString()&&location.reload()},30*1e3));Be(le);var cu=le;export{Ro as accounts,Ao as cache,cu as default,Lo as external,Do as get,Po as html,Io as renderComponentToHTML,qo as set,su as test,au as trackExternal,Vo as upload};
|
|
21
|
+
`}}return r}return""}catch(r){i("component.css.compileCSS",r)}};var Jr=(t={},e=null)=>{try{let r=e(t);return r&&m(r)&&!q(r)?Object.assign({},r):{}}catch(r){i("component.state.compile.compileState",r)}},te=(t={},e={})=>{try{return u(e)?Jr(t,e):Object.assign({},e)}catch(r){i("component.state.compile",r)}};var pe={onBeforeMount:()=>null,onMount:()=>null,onBeforeUnmount:()=>null,onUpdateProps:()=>null,onRefetchData:()=>null};var Ht=(t={},e={})=>{try{return e?Object.entries({...pe,...e||{}}).reduce((r={},[o,n])=>(r[o]=()=>n({...t,setState:t.setState.bind(t),...t.renderMethods||{}}),r),{}):pe}catch(r){i("component.lifecycle.compile",r)}};var re=(t={},e={})=>{try{return Object.entries(e).reduce((r={},[o,n])=>(r[o]=(...s)=>(y(`ui.${t?.options?.test?.name||f()}.methods.${o}`,[...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}}]),n(...s,{...t,setState:t.setState.bind(t),...t.renderMethods||{}})),r),{})}catch{i("component.methods.compile")}};var fe=(t={})=>{try{return{...t,query:{...t?.query||{},set:(e="",r="")=>{if(typeof window!="undefined"){let o=new URL(window.location);o.searchParams.append(e,r),window.history.pushState({},"",o)}},unset:(e="")=>{if(typeof window!="undefined"){let r=new URL(window.location);r.searchParams.delete(e),window.history.pushState({},"",r)}}},isActive:(e="")=>M(e)&&t?.route!=="*"?e===(typeof location!="undefined"?location.pathname:t.path):!1}}catch(e){i("component.url.compile",e)}};var Qr=(t={},e=null)=>{try{let r=e(t);return r&&m(r)&&!q(r)?Object.assign({},r):{}}catch(r){i("component.props.compileDefaultProps.compile",r)}},Ut=(t={},e={})=>{try{return u(e)?Qr(t,e):Object.assign({},e)}catch(r){i("component.props.compileDefaultProps",r)}};var zt=(t={},e={})=>{try{t.options=e||{},t.id=e?._componentId||null,t.instanceId=f(8),t.ssrId=e?._ssrId||null,t.css=ee(),t.data=X(e?.dataFromSSR,e?._componentId),t.defaultProps=Ut(t,e?.defaultProps),t.props=Nt(t?.defaultProps,e?.props),t.state=te(t,e?.state),t.events=e?.events||{},t.lifecycle=Ht(t,e?.lifecycle),t.methods=re(t,e?.methods),t.wrapper=e?.wrapper||{},t.translations=e?.translations||{},t.validateForm=Vt,t.DOMNode=null,t.dom={},t.dom.virtual={},t.dom.actual={};let r=!S();if(r||(t.url=fe(e?.url)),r&&window.__joystick_url__&&(t.url=fe(window.__joystick_url__)),r&&window.__joystick_user__&&(t.user=window.__joystick_user__),r&&e?.websockets&&u(e?.websockets)){let o=e.websockets(t),n=m(o)&&Object.entries(o);for(let s=0;s<n?.length;s+=1){let[c,a]=n[s];Y({test:t?.test,url:`${window?.process?.env.NODE_ENV==="development"?"ws":"wss"}://${location.host}/api/_websockets/${c}`,options:a?.options||{},query:a?.query||{},events:a?.events||{}},(l={})=>{t.websockets={...t.websockets||{},[c]:l}})}}}catch(r){i("component.registerOptions",r)}};var Yr=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("addToQueue.getQueue",e)}},W=(t="",e=null)=>{try{S()||(Yr(t)||{}).array.push({callback:e})}catch(r){i("addToQueue",r)}};var oe=async(t={},e={},r={},o={})=>{try{if(o?.options?.data&&u(o.options.data)){let n=await o.options.data(t,e,r,o);return Promise.resolve(n)}return Promise.resolve()}catch(n){i("component.data.fetch",n)}};var Bt=(t={},e={},r={})=>{try{return{...t,refetch:async(o={})=>{y(`ui.${r?.options?.test?.name||f()}.data.refetch`,[o]);let n=await oe(G,e,o,r);return r.data=Bt(n,e,r),window.__joystick_data__[r?.id]&&(window.__joystick_data__[r?.id]=n),window?.__joystick_test__||r.render({afterRefetchDataRender:()=>{r?.lifecycle?.onRefetchData&&r?.lifecycle?.onRefetchData(r)}}),r.data}}}catch(o){i("component.data.compile",o)}},Zt=Bt;var Gt=(t={})=>{try{if(!S()){let e=window.__joystick_data__&&window.__joystick_data__[t?.id]||{},r=window.__joystick_req__||{};return Zt(e,r,t)}return t?.data||{}}catch(e){i("component.loadDataFromWindow",e)}};var Qt=Hr(Wt());var Kt=(t={},e="",r="id")=>{try{let o=t&&t.id;if(m(t)&&o){let n=Object.keys(t);for(let s=0;s<n.length;s+=1){let c=n[s],a=t[c];if(c===r&&a===e)return t;if(c==="children"&&Array.isArray(a))for(let l=0;l<a.length;l+=1){let x=a[l],g=Kt(x,e,r);if(g!==null)return g}}}return null}catch(o){i("component.findComponentInTreeByField",o)}},D=Kt;var Jt=(t="",e={},r=null)=>{let o=D(r||window.joystick._internal.tree,t,"instanceId");o&&(o.children=[...o.children||[],e])};var Xr=(t={},e={},r=null)=>{try{let o=B(t,{includeActual:!0,existingChildren:r});return t.dom=o,t.setDOMNodeOnInstance(),e.renderedComponent=t,o.html.wrapped}catch(o){i("component.renderMethods.component.renderForClient",o)}},eo=(t={})=>{try{return t.renderToHTML({ssrTree:t.parent.ssrTree,translations:t.parent.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t.parent?.dataFromSSR}).wrapped}catch(e){i("component.renderMethods.component.renderToHTMLForSSR",e)}},to=(t={})=>{try{return t.parent.ssrTree.dataFunctions.push(async()=>{try{let e=await t.options.data(t.parent.options.api,t.parent.options.req);return t.data=e||{},{componentId:t.id,ssrId:t.ssrId,data:e}}catch(e){return{componentId:t.id,ssrId:t.ssrId,data:null,error:e}}}),t.renderToHTML({ssrTree:t?.parent?.ssrTree,translations:t?.parent?.translations,walkingTreeForSSR:t?.parent?.walkingTreeForSSR,dataFromSSR:t?.parent?.dataFromSSR})}catch(e){i("component.renderMethods.component.collectDataFunctionsForSSR",e)}},ro=(t={})=>{try{let e={id:t.id,instanceId:t.instanceId,instance:t,children:[]};Jt(t.parent.instanceId,e,t.parent&&t.parent.ssrTree||null)}catch(e){i("component.renderMethods.component.handleAddComponentToParent",e)}},oo=(t={},e={})=>{try{!t.renderedComponent&&e.options&&e.options.lifecycle&&(e.options.lifecycle.onBeforeMount&&W("lifecycle.onBeforeMount",()=>{e.options.lifecycle.onBeforeMount(e),y(`ui.${e?.options?.test?.name||f()}.lifecycle.onBeforeMount`,[e])}),!t.renderedComponent&&e.options.lifecycle.onMount&&W("lifecycle.onMount",()=>{e.options.lifecycle.onMount(e),y(`ui.${e?.options?.test?.name||f()}.lifecycle.onMount`,[e])}))}catch(r){i("component.renderMethods.component.handleLifecycle",r)}},no=(t={},e={},r={})=>{try{!e.walkingTreeForSSR&&t?.options?.lifecycle?.onUpdateProps&&(0,Qt.diff)(e?.existingPropsMap,r)?.length>0&&W("lifecycle.onUpdateProps",()=>{let n=e?.existingPropsMap&&e?.existingPropsMap[t.id];t.options.lifecycle.onUpdateProps(n||{},r,t),y(`ui.${t?.options?.test?.name||f()}.lifecycle.onBeforeMount`,[n||{},r,t])})}catch(o){i("component.renderMethods.component.handleOnChangeProps",o)}},io=function(){return function(e=null,r={},o={}){let n=e({props:r,url:o.url,translations:o.translations,api:o.options.api,req:o.options.req,dataFromSSR:o?.dataFromSSR,parent:o}),s=o?.existingStateMap[n.id]||{},c=o.children[n.id]||[],a=s[c?.length];return n.state=a?.state||n.state,o.children[n.id]=[...o.children[n.id]||[],n],n.parent=o,no(n,o,r),W("lifecycle.onMount",()=>{n.setDOMNodeOnInstance()}),oo(this,n),n.parent&&ro(n),n.options.data&&n.parent.walkingTreeForSSR&&n.parent.ssrTree.dataFunctions?to(n):n.parent&&n.parent.ssrTree?eo(n):Xr(n,this,a?.children)}},so=function(e,r){try{let o=this;return new io().bind({})(e,r,o)}catch(o){i("component.renderMethods.component",o)}},he=so;var ao=function(e=[],r=null){try{return u(r)&&e&&Array.isArray(e)?e.map((o,n)=>r(o,n)).join(""):""}catch(o){i("component.renderMethods.each",o)}},we=ao;var co=(t="",e=[])=>{try{return e.reduce((r,[o,n])=>r.replace(`{{${o}}}`,n),t)}catch(r){i("component.renderMethods.i18n.replacePlaceholdersInString",r)}},ye=(t="",e=[])=>{try{let r=typeof t=="string",o=Array.isArray(t),n=typeof t=="object"&&!o;if(r)return co(t,e);if(o)return t?.map(s=>ye(s,e));if(n)return Object.entries(t)?.reduce((s={},[c,a])=>(s[c]=ye(a,e),s),{})}catch(r){i("component.renderMethods.i18n.handleTranslationReplacement",r)}},lo=(t="",e={})=>{try{return t?.split(".").reduce((r,o)=>r[o],e)}catch(r){i("component.renderMethods.i18n.getTranslationAtPath",r)}},uo=function(t="",e={}){try{let r=S()?this.translations:window.__joystick_i18n__,n=t?.includes(".")?lo(t,r):r[t];if(!r||!n)return"";let s=Object.entries(e);return ye(n,s)}catch(r){i("component.renderMethods.i18n",r)}},ge=uo;var mo=function(e=!1,r=""){try{return this?.renderingHTMLWithDataForSSR||e?`<when>${r.trim()}</when>`:"<when> </when>"}catch(o){i("component.renderMethods.when",o)}},xe=mo;var Yt={c:he,component:he,e:we,each:we,i:ge,i18n:ge,w:xe,when:xe};var Xt=(t={},e={})=>{try{return Object.entries(Yt).reduce((r,[o,n])=>(r[o]=n.bind({...t,...e}),r),{})}catch(r){i("component.renderMethods.compile",r)}};var er=(t={})=>{try{return Object.entries(t)?.reduce((e={},[r,o]={})=>(e[r]=o?.map((n={})=>({state:n?.state,children:er(n?.children)})),e),{})}catch(e){i("component.render.getExistingStateMap.buildMapForChildren",e)}},tr=(t={})=>{try{return er(t)}catch(e){i("component.render.getExistingStateMap",e)}};var rr=new RegExp(/\<\!\-\-(?:.|\n|\r)*?-->/g),po=new RegExp(/\n/g);var fo=(t="")=>{try{return(t.match(rr)||[]).forEach(r=>{t=t.replace(r,"")}),t}catch(e){i("component.render.sanitizeHTML.removeCommentedCode",e)}},or=(t="")=>{try{let e=`${t}`;return e=fo(e),e}catch(e){i("component.render.sanitizeHTML",e)}};var nr=(t={},e="")=>{try{let{wrapper:r=null,id:o=null,instanceId:n=null}=t;return`<div ${r?.id?`id="${r.id}" `:""}${r?.classList?`class="${r.classList?.join(" ")}" `:""} js-c="${o}" js-i="${n}">${e}</div>`}catch(r){i("component.render.wrapHTML",r)}};var ir=(t={},e=[])=>{try{let r=[...e],o=Object.entries(t);for(let n=0;n<o?.length;n+=1){let[s,c]=o[n];for(let a=0;a<c?.length;a+=1){let l=c[a];Object.entries(l?.timers)?.length>0&&r.push(...Object.values(l?.timers)),Object.entries(l?.children)?.length>0&&ir(l?.children,r)}}if(r?.length>0)for(let n=0;n<r?.length;n+=1)clearTimeout(r[n])}catch(r){i("component.render.clearTimersOnChildren",r)}},sr=ir;var ie=(t={},e={})=>{try{e?.dataFromSSR&&(t.data=X(e.dataFromSSR,t.id)||{}),sr(t?.children);let r=tr(e?.existingChildren||t?.children)||{};t.children={},t.renderMethods=Xt({...t,existingStateMap:r,translations:e?.translations||t.translations||{},ssrTree:e?.ssrTree,walkingTreeForSSR:e?.walkingTreeForSSR,renderingHTMLWithDataForSSR:e?.renderingHTMLWithDataForSSR,dataFromSSR:e?.dataFromSSR}),t.methods=re(t,t.options.methods);let o=t.options.render({...t||{},setState:t.setState.bind(t),...t.renderMethods||{}}),n=or(o),s=nr(t,n);return{unwrapped:n,wrapped:s}}catch(r){i("component.render.toHTML",r)}};var ho=(t={})=>{try{return Object.values(t).reduce((e={},r)=>(e[r.name]=r.value,e),{})}catch(e){i("component.virtualDOM.build.parseAttributeMap",e)}},ar=(t={})=>{try{return t.tagName==="WHEN"?[].flatMap.call(t?.childNodes,e=>e?.tagName==="WHEN"?ar(e):be(e)):be(t)}catch(e){i("component.virtualDOM.build.flattenWhenTags",e)}},be=(t={})=>{try{let e=t&&t.tagName&&t.tagName.toLowerCase()||"text",r={tagName:e,attributes:ho(t.attributes),children:[].flatMap.call(t.childNodes,o=>ar(o))};return e==="text"&&(r=t.textContent),r}catch(e){i("component.virtualDOM.build",e)}},K=be;var wo=(t="")=>{try{let e=document.createElement("div");return e.innerHTML=t,e?.childNodes[0]}catch(e){i("component.virtualDOM.build.convertHTMLToDOM",e)}},cr=(t="")=>{try{let e=wo(t);return K(e)}catch(e){i("component.virtualDOM.build",e)}};var dr=(t="")=>{try{return document.createElement("div").setAttribute(t,"Test"),!0}catch{return!1}};var yo=(t={})=>{try{let e=document.createElement(t.tagName),r=Object.entries(t.attributes);for(let o=0;o<r.length;o+=1){let[n,s]=r[o];dr(n)&&e.setAttribute(n,s)}for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(n){let s=lr(n);e.appendChild(s)}}return e}catch(e){i("component.virtualDOM.renderTreeToDOM.renderElement",e)}},lr=(t=null)=>{try{return M(t)?document.createTextNode(t):yo(t)}catch(e){i("component.virtualDOM.renderTreeToDOM",e)}},Z=lr;var B=(t={},e={})=>{try{let r=ie(t,{existingChildren:e?.existingChildren}),o=cr(r.wrapped,t),n=e.includeActual&&o?Z(o):null;return{html:r,virtual:o,actual:n}}catch(r){i("component.render.getUpdatedDOM",r)}};var ur=(t={},e={})=>{try{let r=B(t,{includeActual:!0,existingChildren:e?.existingChildren});return t.dom=r,r.actual}catch(r){i("component.render.forMount",r)}};var go=(t={},e={})=>{let r=[];for(let[o,n]of Object.entries(e))r.push(s=>(s&&s.setAttribute&&s.setAttribute(o,n),s));for(let o in t)o in e||r.push(n=>(n&&n.removeAttribute&&n.removeAttribute(o),n));return o=>{for(let n of r)n&&typeof n=="function"&&n(o)}},se=go;var xo=(t=[],e=[])=>{let r=[],o=Math.max(t.length,e.length);for(let n=0;n<o;n+=1){let s=t[n],c=e[n];r.push([s,c])}return r},mr=xo;var bo=(t=[],e)=>{t.forEach(r=>{r&&typeof r=="function"&&r(e)})},$o=(t=[])=>{t.forEach(([e,r])=>{e&&typeof e=="function"&&e(r)})},ko=(t=[],e=[])=>{let r=[];return e.slice(t.length).forEach(n=>{let s=c=>{let a=Z(n);return c.appendChild(a),c};r.push(s)}),r},Eo=(t=[],e=[])=>{let r=[];return t.forEach((o,n)=>{let s=ce(o,e[n]);r.push(s)}),r},Fo=(t=[],e=[])=>{let r=Eo(t,e),o=ko(t,e);return n=>{if(n){let s=mr(r,n.childNodes);$o(s),bo(o,n)}return n}},ae=Fo;var pr={select:(t,e)=>r=>{let o=r.value;r.replaceChildren(),se(t.attributes,e.attributes)(r),ae([],e.children)(r);let n=r.querySelector(`option[value="${o}"]`);if(n&&(r.value=o),!n){let s=r.querySelector("option");r.value=s?.value||""}return r}};var $e=(t,e)=>r=>{let o=t?Z(t):null;return r&&r.replaceWith(o),o},Mo=()=>t=>{t&&t.remove()},So=(t=void 0,e=void 0)=>t===void 0||e===void 0?Mo():typeof t=="string"||typeof e=="string"?$e(e,t):t.tagName!==e.tagName?$e(e):e.tagName==="select"?pr.select(t,e):["pre","code"].includes(e.tagName)?$e(e,t):n=>(se(t.attributes,e.attributes)(n),ae(t.children,e.children)(n),n),ce=So;var To=(t="")=>{try{let[e,r]=t?.split(".");return r?window?.joystick?._internal?.queues[e][r]:window?.joystick?._internal?.queues[e]}catch(e){i("processQueue.getQueue",e)}},V=(t="",e=null)=>{try{S()||(To(t)||{}).process(e)}catch(r){i("processQueue",r)}};var fr=(t="",e=null)=>{let r=D(e||window.joystick._internal.tree,t,"instanceId");r&&(r.children=[])};var hr=(t="",e={},r=null)=>{let o=D(r||window.joystick._internal.tree,t,"instanceId");o&&(o.instanceId=e?.instanceId,o.instance=e)};var wr=(t={},e="",r={})=>{for(let o=0;o<t?.children?.length;o+=1){let n=t?.children[o];if(m(n)&&n.attributes&&n.attributes["js-i"]&&n.attributes["js-i"]===e){t.children[o]=r;break}m(n)&&wr(n,e,r)}},yr=wr;var gr=(t={})=>{try{return Object.entries(t).map(([e,r])=>{let[o,...n]=e.split(" ");return{type:o.toLowerCase(),selector:n.join(" "),handler:r}})}catch(e){i("component.events.serialize",e)}};var xr=(t={},e={},r=[])=>{try{let o=Object.keys(t?.events||{})?.length>0?gr(t?.events):[];for(let n=0;n<o?.length;n+=1){let s=o[n];r.push({...s,instance:t,elements:document.querySelectorAll(`body [js-i="${t.instanceId}"] ${s?.selector}`),handler:function(a){s.handler(a,{...t||{},setState:t?.setState.bind(t),...e||{}}),y(`ui.${t?.options?.test?.name||f()}.events.${s.type}.selector_${s?.selector}`,[a,{...t||{},setState:t?.setState.bind(t),...e||{}}])}})}if(t?.children){let n=Object.entries(t?.children)?.flatMap(([s,c])=>c);for(let s=0;s<n?.length;s+=1){let c=n[s];xr(c,e,r)}}return r}catch(o){i("component.eve!nts.registerListenersFix.getListeners",o)}},_o=(t={},e={})=>{try{let o=xr(t,e,[])?.flatMap((n={})=>[].flatMap.call(n?.elements||[],s=>{let{elements:c=[],...a}=n||{};return{...a,element:s}}));for(let n=0;n<o?.length;n+=1){let{instance:s,element:c,elementSelector:a,type:l,handler:x}=o[n];c.addEventListener(l,x),s._eventListeners=[...s?._eventListeners||[],{instance:s,element:c,elementSelector:a,type:l,handler:x}]}}catch(r){i("component.events.registerListenersFix",r)}},de=_o;var br=(t={})=>{try{let e=t?._eventListeners||[];if(t?.children){let o=(Object.values(t?.children||{})?.reduce((n=[],s=[])=>[...n,...s],[])).flatMap((n={})=>br(n));e=[...e,...o]}return e}catch(e){i("component.events.unregisterListenersFix.getListeners",e)}},Co=(t={})=>{try{let e=br(t);for(let r=0;r<e?.length;r+=1){let{instance:o,element:n,type:s,handler:c}=e[r];n.removeEventListener(s,c),o._eventListeners=o._eventListeners?.splice(r,1)}}catch(e){i("component.events.unregisterListenersFix",e)}},$r=Co;var kr=class{constructor(e={}){this.parent=e?.parent||null,this.onUpdateChildComponent=this.handleUpdateChildComponentInVDOM,this.updateVirtualDOM=this.handleUpdateVirtualDOM,this.timers={},this.children={},lt(e),zt(this,e),this.data=Gt(this)}setDOMNodeOnInstance(){this.DOMNode=document.querySelector(`body [js-i="${this.instanceId}"]`)}async handleFetchData(e={},r={},o={},n=this){let s=await oe(e,r,o,n);return this.data=s,s}handleGetInstance(){return this}handleUpdateVirtualDOM(){if(this.DOMNode){let r=K(this.DOMNode);this.dom.virtual=r}let e=this.parent?D(window.joystick._internal.tree,this.parent?.instanceId,"instanceId"):null;e?.instance&&e.instance.updateVirtualDOM()}onBeforeRender(){if(!S())return{instanceId:this.instanceId}}render(e={}){if(y(`ui.${this?.options?.test?.name||f()}.render`,[e]),e?.mounting)return ur(this,e);let r=this.onBeforeRender();$r(this),fr(this.instanceId);let o=B(this,{}),n=ce(this.dom.virtual,o.virtual);n&&u(n)&&V("lifecycle.onBeforeMount",()=>{let s=n(this.DOMNode);this.dom.actual=s,this.dom.virtual=o.virtual,de(this,this.renderMethods),this.setDOMNodeOnInstance(),V("domNodes",()=>{V("lifecycle.onMount",()=>{this.onAfterRender(r,e)})})})}renderToHTML(e={}){return ie(this,e)}onAfterRender(e={},r={}){S()||(hr(e.instanceId,this),window.joystick._internal.css.update(),V("lifecycle.onUpdateProps"),r?.afterSetStateRender&&u(r.afterSetStateRender)&&r.afterSetStateRender(),r?.afterRefetchDataRender&&u(r.afterRefetchDataRender)&&r.afterRefetchDataRender(),this.parent&&this.parent.onUpdateChildComponent(this.id,this.instanceId))}setState(e={},r=null){y(`ui.${this?.options?.test?.name||f()}.setState`,[e,r]),this.state=te(this,{...this.state||{},...e}),this.render({afterSetStateRender:()=>{r&&u(r)&&r()}})}setTimeout(e=null,r=0){e&&(this.timers[f()]=window.setTimeout(e,r))}setInterval(e=null,r=0){e&&(this.timers[f()]=window.setInterval(e,r))}handleUpdateChildComponentInVDOM(e="",r=""){let o=D(window.joystick._internal.tree,this.instanceId,"instanceId"),n=D(window.joystick._internal.tree,r,"instanceId");if(n?.instance?.DOMNode){let s=K(n?.instance?.DOMNode);yr(o?.instance?.dom?.virtual,n?.instanceId,s)}}},Er=kr;var Fr=(t={})=>{try{return(e={})=>new Er({...t,props:e?.props,url:e?.url,translations:e?.translations,api:e?.api,req:e?.req,parent:e?.parent})}catch(e){i("component",e)}};var Mr=(t={})=>{try{window.joystick._internal.tree={id:t?.id||null,instanceId:t?.instanceId||null,instance:t,children:[]}}catch(e){i("mount.initializeJoystickComponentTree",e)}};var Sr=(t={},e=null)=>{try{return t.innerHTML="",t.appendChild(e),e}catch(r){i("mount.appendToDOM",r)}};var Tr=(t=null,e={},r=null)=>{try{u(t)||i("mount","Component to mount must be a function."),m(e)||i("mount","props must be an object."),Re(r)||i("mount","target must be a DOM node.");let o=t({props:e});Mr(o);let n=o.render({mounting:!0,existingChildren:window.__joystick_childrenBeforeHMRUpdate__||null});return n&&(n.setAttribute("js-c",o.id),n.setAttribute("js-i",o.instanceId)),o.lifecycle.onBeforeMount(),V("lifecycle.onBeforeMount"),Sr(r,n),o.setDOMNodeOnInstance(),window.joystick._internal.css.update(),de(o,o.renderMethods),o.lifecycle.onMount(),V("lifecycle.onMount"),o}catch(o){i("mount",o)}};var _r=class{constructor(e=[]){this.array=[...e],this.array.push=function(){Array.prototype.push.apply(this,arguments)}}async process(e=null){if(this.array.length>0){let r=this.array.shift();r&&r.callback&&(await r.callback(),this.process(e))}else e&&e()}},N=_r;var vo=new RegExp(/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g),Oo=new RegExp(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g),jo=(t,e)=>(e||"").replace(vo,()=>"").replace(Oo,r=>["@",": "].some(o=>r?.includes(o))?r:`[js-c="${t}"] ${r.trim()}`)?.trim(),Cr=(t={},e=[])=>{if(t.instance&&t.instance.options&&t.instance.options.css){let r=t.instance.id,o=t.instance.options.css,n=ee(o,t.instance),s=jo(r,n);e.push(s)}if(t.children&&t.children.length>0){let r=t?.children?.length||0;for(;r--;)Cr(t.children[r],e)}return e},vr=Cr;var Or=()=>{try{let t=document.head.querySelector("style[js-styles]"),r=vr(window.joystick?._internal?.tree).reverse().join("").trim();if(t?.innerText===r)return;if(t&&(t.innerHTML=r),!t){let o=document.createElement("style");o.setAttribute("js-styles",""),o.innerHTML=r,document.head.appendChild(o)}}catch(t){i("css.update",t)}};var jr=(()=>{let t=0;return(e,r)=>{clearTimeout(t),t=setTimeout(e,r)}})();var Ro=ve,Ao=Le,Do=G.get,Lo={get:Pe,track:me},Po=Ie,Io=qe,qo=G.set,su=Ne,au=me,Vo=ze,ke=()=>typeof window!="undefined"?window.__joystick_env__:typeof process!="undefined"?"production":null,le={_external:{},_internal:{last_interaction:null,css:{update:Or},queues:{domNodes:new N([]),eventListeners:new N([]),lifecycle:{onBeforeMount:new N([]),onMount:new N([]),onUpdateProps:new N([])},render:new N([])},tree:{},eventListeners:[]},accounts:Ro,cache:Ao,component:Fr,env:{development:ke()==="development",test:ke()==="test"},external:Lo,get:Do,html:Po,id:f,mount:Tr,renderComponentToHTML:Io,set:qo,upload:Vo,timers:{}};typeof window!="undefined"&&ke()!=="test"&&(document.body.addEventListener("mouseover",()=>{jr(()=>{le._internal.last_interaction=new Date().toISOString()},1e3)}),setInterval(()=>{let t=new Date;t.setMinutes(t.getMinutes()-30),le._internal.last_interaction<=t.toISOString()&&location.reload()},30*1e3));Be(le);var cu=le;export{Ro as accounts,Ao as cache,cu as default,Lo as external,Do as get,Po as html,Io as renderComponentToHTML,qo as set,su as test,au as trackExternal,Vo as upload};
|
package/package.json
CHANGED