@dlightjs/components
Advanced tools
Comparing version 1.0.0-next.6 to 1.0.0-next.7
@@ -1,2 +0,2 @@ | ||
function g(){return location.hash.slice(2)}function m(){return location.pathname.slice(1)}function v(o,t){let e;if(o[0]==="/")e=o;else{o[0]!=="."&&(o="./"+o);let s=t==="history"?window.location.pathname:window.location.hash.replace(/^#/,""),r=o.split("/"),i=s.split("/").filter(a=>a),n=0;for(let a of r){if(![".",".."].includes(a))break;a===".."&&(i.length===0&&console.warn(`no ../ in ${o}`),i.pop()),n++}e="/"+[...i,...r.slice(n)].join("/")}return e}function y(o){return o.replace(/(^\/+)|(\/+$)/g,"")}function k(o,t){return!o&&!t?!0:!o||!t||Object.keys(o).length!==Object.keys(t).length?!1:Object.keys(o).every(e=>t[e]===o[e])}function N(o){return!!o.prototype?.Body}var l=class{mode;constructor(t="history"){this.mode=t}hashTo(t){window.location.href="#"+v(t,this.mode)}historyTo(t){window.history.pushState({},"",v(t,this.mode))}to(t){if(this.mode==="hash"){this.hashTo(t);return}this.historyTo(t)}};import{CondNode as z,ExpNode as T,EnvNode as K,PropView as J}from"@dlightjs/dlight";import{View as Q}from"@dlightjs/dlight";var L=history.pushState,p=[],_=class extends Q{constructor(){super(),this.homeUrl=this.homeUrl.bind(this),this.collectRoutes=this.collectRoutes.bind(this),this.updateRoute=this.updateRoute.bind(this),this.changePath=this.changePath.bind(this),this.historyChangeListen=this.historyChangeListen.bind(this),this.hashChangeListen=this.hashChangeListen.bind(this),this.willMount=this.willMount.bind(this),this.didMount=this.didMount.bind(this),this.willUnmount=this.willUnmount.bind(this)}$e$_dl_router_baseUrl;_dl_router_baseUrl="/";$$_dl_router_baseUrl=1;$p$mode;mode="history";$$mode=2;$s$mode=["currentPath"];$p$loading;loading;$p$guard;guard;$p$onPathUpdate;onPathUpdate;$p$afterEnter;afterEnter;$p$beforeLeave;beforeLeave;get routes(){return this._$children}routeMap={};hitPath="";$$hitPath=256;prevInfo={path:"/"};currentPath;$$currentPath=1024;get $f$currentPath(){return this._$cache("currentPath",[this.mode])?this.currentPath:this.mode==="hash"?g():m()}viewHolder={propView:!0};$$viewHolder=2048;homeUrl(t){return t.replace(/^~/,this._dl_router_baseUrl)}loaded=!1;collectRoutes(t,e){this.routeMap[t]=e,this.loaded&&this.updateRoute(this.prevInfo.path)}async updateRoute(t){this.loaded||(this.loaded=!0);let e="/"+t;t=y(e.replace(new RegExp(`^${this._dl_router_baseUrl}`),""));for(let[s,{comp:r,children:i,loading:n,redirect:a,info:d}]of Object.entries(this.routeMap)){let h=this.homeUrl(s.replace(/^(\.\/)+/,"")),q=h==="."&&t==="",I=t.startsWith(h+"/"),f=null,u;if(I||(f=t.match(new RegExp(`^${h}$`)),f&&(u=f.groups)),!(q||I||!!f))continue;if(s===this.hitPath&&k(u,this.viewHolder.params)&&(i||!N(r)||this.viewHolder.view===r))return;let w={...d,path:e};if(this.guard){let $=await this.guard(w,this.prevInfo,this._dl_router_baseUrl);if($===!1){this.navigator.to(this.prevInfo.path);return}if(typeof $=="string"){this.navigator.to(this.homeUrl($));return}}if(a){this.navigator.to(this.homeUrl(a));return}this.beforeLeave&&await this.beforeLeave(w,this.prevInfo,this._dl_router_baseUrl);let P=async()=>{this.afterEnter&&await this.afterEnter(w,this.prevInfo,this._dl_router_baseUrl)};if(i)this._$ud(this.viewHolder={view:i,propView:!0},"viewHolder"),P();else if(r)if(N(r))this._$ud(this.viewHolder={view:r,propView:!1,params:u},"viewHolder"),P();else{let $=n??this.loading;$&&this._$ud(this.viewHolder={view:$,propView:!!$.propViewFunc},"viewHolder"),r().then(W=>{this._$ud(this.viewHolder={view:W.default,propView:!1,params:u},"viewHolder"),P()})}this._$ud(this.hitPath=s,"hitPath"),this.prevInfo={path:e,...u};return}}navigator=new l;$$navigator=8192;changePath(t){t!==this.currentPath&&(this._$ud(this.currentPath=t,"currentPath"),this.onPathUpdate&&this.onPathUpdate(this.currentPath))}firstIn=!1;historyChangeListen(){let t=m();"/"+t!==this.prevInfo.path&&(this.changePath(t),this.updateRoute(t))}hashChangeListen(){let t=g();"/"+t!==this.prevInfo.path&&(this.changePath(t),this.updateRoute(t))}willMount(){this._$ud(this.navigator.mode=this.mode,"navigator"),Promise.resolve().then(()=>{this.mode==="hash"?this.hashChangeListen():this.historyChangeListen()})}didMount(){if(this.mode==="hash"){addEventListener("load",this.hashChangeListen),addEventListener("hashchange",this.hashChangeListen);return}addEventListener("load",this.historyChangeListen),addEventListener("popstate",this.historyChangeListen),p.push(this.historyChangeListen),history.pushState=new Proxy(L,{apply(t,e,s){let r=t.apply(e,s);return p.forEach(i=>i()),r}})}willUnmount(){if(this.mode==="hash"){removeEventListener("load",this.hashChangeListen),removeEventListener("hashchange",this.hashChangeListen);return}removeEventListener("load",this.historyChangeListen),removeEventListener("popstate",this.historyChangeListen),p=p.filter(t=>t!==this.historyChangeListen),p.length>0?history.pushState=new Proxy(L,{apply(t,e,s){let r=t.apply(e,s);return p.forEach(i=>i()),r}}):history.pushState=L}Body(){let t,e,s;return this._$update=r=>{r&257&&t&&t.updateEnv("_dl_router_baseUrl",()=>"/"+y(`${this._dl_router_baseUrl}/${this.hitPath}`),[this._dl_router_baseUrl,this.hitPath]),r&1026&&t&&t.updateEnv("path",()=>this.currentPath,[this.currentPath]),r&2048&&s&&s.updateCond(),r&8192&&t&&t.updateEnv("navigator",()=>this.navigator,[this.navigator]),s&&s.update(r)},t=new K({_dl_router_routesCollect:this.collectRoutes,_dl_router_baseUrl:"/"+y(`${this._dl_router_baseUrl}/${this.hitPath}`),path:this.currentPath,navigator:this.navigator},{_dl_router_routesCollect:[],_dl_router_baseUrl:[this._dl_router_baseUrl,this.hitPath],path:[this.currentPath],navigator:[this.navigator]}),e=new T(this.routes,[]),s=new z(2048,r=>{if(this.viewHolder.propView){if(r.cond===0)return r.didntChange=!0,[];r.cond=0;let i;return r.updateFunc=n=>{n&2048&&i&&i.update(()=>this.viewHolder.view,[this.viewHolder?.view])},i=new T(this.viewHolder.view,[this.viewHolder?.view]),r.cond===0?[i]:r.updateCond()}else{if(r.cond===1)return r.didntChange=!0,[];r.cond=1;let i,n;return r.updateFunc=a=>{a&2048&&n&&n.update(()=>i,[this.viewHolder?.view]),i&&i.update(a)},i=new J(a=>{let d;return a(h=>{h&2048&&d&&d._$setProps(()=>this.viewHolder.params,[this.viewHolder?.params])}),d=new this.viewHolder.view,d._$init(null,null,null,null),[d]}),n=new T(i,[this.viewHolder?.view]),r.cond===1?[n]:r.updateCond()}}),t.initNodes([e,s]),[t]}},X=_;import{View as Y,required as tt}from"@dlightjs/dlight";var E=class extends Y{constructor(){super(),this.collectRoutes=this.collectRoutes.bind(this)}$e$_dl_router_routesCollect;_dl_router_routesCollect=tt;$$_dl_router_routesCollect=1;$s$_dl_router_routesCollect=["collectRoutes"];$p$path;_$contentKey="path";path=".*";$$path=2;$s$path=["collectRoutes"];$p$comp;comp;$$comp=4;$s$comp=["collectRoutes"];get children(){return this._$children}$p$loading;loading;$$loading=8;$s$loading=["collectRoutes"];$p$redirect;redirect;$$redirect=16;$s$redirect=["collectRoutes"];$p$info;info;$$info=32;$s$info=["collectRoutes"];$w$collectRoutes;collectRoutes(){this._$cache("collectRoutes",[this._dl_router_routesCollect,this.path,this.comp,this.loading,this.redirect,this.info])||this._dl_router_routesCollect(this.path,{comp:this.comp,children:this.children,loading:this.loading,redirect:this.redirect,info:this.info})}},et=E;import{createElement as st,setStyle as D,delegateEvent as it,setHTMLProp as U,insertNode as rt,ExpNode as ot}from"@dlightjs/dlight";import{View as nt,required as x}from"@dlightjs/dlight";var H=class extends nt{constructor(){super(),this.handleClick=this.handleClick.bind(this)}$p$content;_$contentKey="content";content=x;$$content=1;$p$to;to=x;$p$mode;mode="history";$$mode=4;$s$mode=["nav"];$p$style;style={};$$style=8;$p$class;class="";$$class=16;get children(){return this._$children}$e$navigator;navigator=x;$$navigator=32;$s$navigator=["nav"];nav;get $f$nav(){return this._$cache("nav",[this.navigator,this.mode])?this.nav:this.navigator??new l(this.mode)}handleClick(t){if(t.preventDefault(),this.to.startsWith("http"))return window.open(this.to,"_blank");if(this.to.startsWith("?")){let e=this.nav.mode==="history"?m():g();return this.nav.to(e+this.to)}this.nav.to(this.to)}Body(){let t,e;return this._$update=s=>{s&1&&e&&e.update(()=>this.children??this.content,[this.content]),s&8&&t&&D(t,this.style),s&16&&t&&U(t,"className",()=>this.class,[this.class])},t=st("a"),D(t,this.style),U(t,"className",()=>this.class,[this.class]),it(t,"click",this.handleClick),e=new ot(this.children??this.content,[this.content]),rt(t,e,0),t._$nodes=[e],[t]}},at=H;import{CondNode as dt,ExpNode as ht,PropView as $t}from"@dlightjs/dlight";import{View as lt}from"@dlightjs/dlight";function Ye(o,t){class e extends lt{constructor(){super(),this.willMount=this.willMount.bind(this)}_$forwardProps;_$forwardPropsSet=new Set;_$forwardPropsId=[];ViewCls;$$ViewCls=8;willMount(){o().then(r=>{this._$ud(this.ViewCls=r.default,"ViewCls")})}Body(){let r;return this._$update=i=>{i&8&&r&&r.updateCond(),r&&r.update(i)},r=new dt(8,i=>{if(this.ViewCls){if(i.cond===0)return i.didntChange=!0,[];i.cond=0;let n,a;return i.updateFunc=d=>{d&8&&a&&a.update(()=>n,[this.ViewCls]),n&&n.update(d)},n=new $t(d=>{let h;return h=new this.ViewCls,h._$init(null,null,null,this),[h]}),a=new ht(n,[this.ViewCls]),i.cond===0?[a]:i.updateCond()}else if(t){if(i.cond===1)return i.didntChange=!0,[];i.cond=1;let n;return i.updateFunc=a=>{},n=new t,n._$init(null,null,null,null),i.cond===1?[n]:i.updateCond()}else return i.cond===2?(i.didntChange=!0,[]):(i.cond=2,i.updateFunc=n=>{},i.cond===2?[]:i.updateCond())}),[r]}}return e}import{createElement as ct,setStyle as F,setHTMLProp as G,insertNode as ut,ExpNode as gt}from"@dlightjs/dlight";import{View as M}from"@dlightjs/dlight";function pt(o,t){let e=[...o].reverse();for(;e.length>0;){let s=e.pop();t(s),"_$dlNodeType"in s?s._$nodes&&e.push(...[...s._$nodes].reverse()):s._$nodes?e.push(...[...s._$nodes].reverse()):e.push(...[...s.childNodes].reverse())}}function c(o,t){let e=s=>{pt(s,r=>{if(r.initNewNodes){let i=r.initNewNodes;r.initNewNodes=function(n){i.call(this,n),t(n),e(n)}}})};e(o)}var S=class extends M{constructor(){super(),this.setStyles=this.setStyles.bind(this),this.didMount=this.didMount.bind(this)}$p$spacing;spacing=0;$$spacing=1;$p$alignment;alignment="top";$$alignment=2;$s$alignment=["margin"];$p$width;width="100%";$$width=4;$p$height;height="max-content";$$height=8;$p$style;style={};$$style=16;$p$class;class;$$class=32;get children(){return this._$children}margin;get $f$margin(){return this._$cache("margin",[this.alignment])?this.margin:{top:"0 0 auto 0",bottom:"auto 0 0 0",center:"auto 0"}[this.alignment]??"0 0 auto 0"}nodes=[];setStyles(t){M.loopShallowEls(t,e=>{e.style.flexShrink="0",e.style.margin=this.margin})}didMount(){this.setStyles(this.nodes),c(this.nodes,this.setStyles)}Body(){let t,e;return this._$update=s=>{s&29&&t&&F(t,{...this.style,height:this.height,width:this.width,columnGap:`${this.spacing}px`,display:"flex",flexDirection:"row"}),s&32&&t&&G(t,"className",()=>this.class,[this.class])},t=ct("div"),G(t,"className",()=>this.class,[this.class]),F(t,{...this.style,height:this.height,width:this.width,columnGap:`${this.spacing}px`,display:"flex",flexDirection:"row"}),e=new gt(this.children,[]),M.addDidMount(e,s=>{this.nodes=s._$nodes}),ut(t,e,0),t._$nodes=[e],[t]}},mt=S;import{createElement as ft,setStyle as j,setHTMLProp as O,insertNode as yt,ExpNode as wt}from"@dlightjs/dlight";import{View as R}from"@dlightjs/dlight";var V=class extends R{constructor(){super(),this.setStyles=this.setStyles.bind(this),this.didMount=this.didMount.bind(this)}$p$spacing;spacing=0;$$spacing=1;$p$alignment;alignment="leading";$$alignment=2;$s$alignment=["margin"];$p$width;width="max-content";$$width=4;$p$height;height="100%";$$height=8;$p$style;style={};$$style=16;$p$class;class;$$class=32;get children(){return this._$children}margin;get $f$margin(){return this._$cache("margin",[this.alignment])?this.margin:{leading:"0 auto 0 0",tailing:"0 0 0 auto",center:"0 auto"}[this.alignment]??"0 auto 0 0"}nodes=[];setStyles(t){R.loopShallowEls(t,e=>{e.style.flexShrink="0",e.style.margin=this.margin})}didMount(){this.setStyles(this.nodes),c(this.nodes,this.setStyles)}Body(){let t,e;return this._$update=s=>{s&29&&t&&j(t,{...this.style,height:this.height,width:this.width,rowGap:`${this.spacing}px`,display:"flex",flexDirection:"column"}),s&32&&t&&O(t,"className",()=>this.class,[this.class])},t=ft("div"),O(t,"className",()=>this.class,[this.class]),j(t,{...this.style,height:this.height,width:this.width,rowGap:`${this.spacing}px`,display:"flex",flexDirection:"column"}),e=new wt(this.children,[]),R.addDidMount(e,s=>{this.nodes=s._$nodes}),yt(t,e,0),t._$nodes=[e],[t]}},Pt=V;import{createElement as vt,setStyle as B,setHTMLProp as Z,insertNode as Nt,ExpNode as Tt}from"@dlightjs/dlight";import{View as C}from"@dlightjs/dlight";var A=class extends C{constructor(){super(),this.setStyles=this.setStyles.bind(this),this.didMount=this.didMount.bind(this)}$p$hAlignment;hAlignment="center";$$hAlignment=1;$s$hAlignment=["justifyItems"];$p$vAlignment;vAlignment="center";$$vAlignment=2;$s$vAlignment=["alignItems"];$p$width;width="max-content";$$width=4;$p$height;height="max-content";$$height=8;$p$style;style={};$$style=16;$p$class;class;$$class=32;get children(){return this._$children}justifyItems;$$justifyItems=64;get $f$justifyItems(){return this._$cache("justifyItems",[this.hAlignment])?this.justifyItems:{leading:"flex-start",center:"center",tailing:"flex-end"}[this.hAlignment]??"center"}alignItems;$$alignItems=128;get $f$alignItems(){return this._$cache("alignItems",[this.vAlignment])?this.alignItems:{top:"flex-start",center:"center",bottom:"flex-end"}[this.vAlignment]??"center"}nodes=[];setStyles(t){C.loopShallowEls(t,e=>{e.style.position="absolute",e.style.gridArea="1 / 1/ 1 / 1"})}didMount(){this.setStyles(this.nodes),c(this.nodes,this.setStyles)}Body(){let t,e;return this._$update=s=>{s&32&&t&&Z(t,"className",()=>this.class,[this.class]),s&223&&t&&B(t,{...this.style,height:this.height,width:this.width,display:"grid",alignItems:this.alignItems,justifyItems:this.justifyItems})},t=vt("div"),Z(t,"className",()=>this.class,[this.class]),B(t,{...this.style,height:this.height,width:this.width,display:"grid",alignItems:this.alignItems,justifyItems:this.justifyItems}),e=new Tt(this.children,[]),C.addDidMount(e,s=>{this.nodes=s._$nodes}),Nt(t,e,0),t._$nodes=[e],[t]}},Lt=A;import{createElement as _t,setStyle as Et}from"@dlightjs/dlight";import{View as xt}from"@dlightjs/dlight";var b=class extends xt{isSpacer=!0;Body(){let t;return t=_t("div"),Et(t,{flexGrow:1}),[t]}},Ht=b;export{mt as HStack,at as Link,l as Navigator,et as Route,X as RouteGroup,Ht as Spacer,Pt as VStack,Lt as ZStack,Ye as lazy}; | ||
function g(){return location.hash.slice(2)}function m(){return location.pathname.slice(1)}function v(o,t){let e;if(o[0]==="/")e=o;else{o[0]!=="."&&(o="./"+o);let s=t==="history"?window.location.pathname:window.location.hash.replace(/^#/,""),r=o.split("/"),i=s.split("/").filter(a=>a),n=0;for(let a of r){if(![".",".."].includes(a))break;a===".."&&(i.length===0&&console.warn(`no ../ in ${o}`),i.pop()),n++}e="/"+[...i,...r.slice(n)].join("/")}return e}function y(o){return o.replace(/(^\/+)|(\/+$)/g,"")}function k(o,t){return!o&&!t?!0:!o||!t||Object.keys(o).length!==Object.keys(t).length?!1:Object.keys(o).every(e=>t[e]===o[e])}function N(o){return!!o.prototype?.Body}var l=class{mode;constructor(t="history"){this.mode=t}hashTo(t){window.location.href="#"+v(t,this.mode)}historyTo(t){window.history.pushState({},"",v(t,this.mode))}to(t){if(this.mode==="hash"){this.hashTo(t);return}this.historyTo(t)}};import{CondNode as z,ExpNode as T,EnvNode as K,PropView as J}from"@dlightjs/dlight";import{View as Q}from"@dlightjs/dlight";var L=history.pushState,p=[],_=class extends Q{constructor(){super(),this.homeUrl=this.homeUrl.bind(this),this.collectRoutes=this.collectRoutes.bind(this),this.updateRoute=this.updateRoute.bind(this),this.changePath=this.changePath.bind(this),this.historyChangeListen=this.historyChangeListen.bind(this),this.hashChangeListen=this.hashChangeListen.bind(this),this.willMount=this.willMount.bind(this),this.didMount=this.didMount.bind(this),this.willUnmount=this.willUnmount.bind(this)}$e$_dl_router_baseUrl;_dl_router_baseUrl="/";$$_dl_router_baseUrl=1;$p$mode;mode="history";$$mode=2;$s$mode=["currentPath"];$p$loading;loading;$p$guard;guard;$p$onPathUpdate;onPathUpdate;$p$afterEnter;afterEnter;$p$beforeLeave;beforeLeave;get routes(){return this._$children}routeMap={};hitPath="";$$hitPath=256;prevInfo={path:"/"};currentPath;$$currentPath=1024;get $f$currentPath(){return this._$cache("currentPath",[this.mode])?this.currentPath:this.mode==="hash"?g():m()}viewHolder={propView:!0};$$viewHolder=2048;homeUrl(t){return t.replace(/^~/,this._dl_router_baseUrl)}loaded=!1;collectRoutes(t,e){this.routeMap[t]=e,this.loaded&&this.updateRoute(this.prevInfo.path)}async updateRoute(t){this.loaded||(this.loaded=!0);let e="/"+t;t=y(e.replace(new RegExp(`^${this._dl_router_baseUrl}`),""));for(let[s,{comp:r,children:i,loading:n,redirect:a,info:d}]of Object.entries(this.routeMap)){let h=this.homeUrl(s.replace(/^(\.\/)+/,"")),q=h==="."&&t==="",I=t.startsWith(h+"/"),f=null,u;if(I||(f=t.match(new RegExp(`^${h}$`)),f&&(u=f.groups)),!(q||I||!!f))continue;if(s===this.hitPath&&k(u,this.viewHolder.params)&&(i||!N(r)||this.viewHolder.view===r))return;let w={...d,path:e};if(this.guard){let $=await this.guard(w,this.prevInfo,this._dl_router_baseUrl);if($===!1){this.navigator.to(this.prevInfo.path);return}if(typeof $=="string"){this.navigator.to(this.homeUrl($));return}}if(a){this.navigator.to(this.homeUrl(a));return}this.beforeLeave&&await this.beforeLeave(w,this.prevInfo,this._dl_router_baseUrl);let P=async()=>{this.afterEnter&&await this.afterEnter(w,this.prevInfo,this._dl_router_baseUrl)};if(i)this._$ud(this.viewHolder={view:i,propView:!0},"viewHolder"),P();else if(r)if(N(r))this._$ud(this.viewHolder={view:r,propView:!1,params:u},"viewHolder"),P();else{let $=n??this.loading;$&&this._$ud(this.viewHolder={view:$,propView:!!$.propViewFunc},"viewHolder"),r().then(W=>{this._$ud(this.viewHolder={view:W.default,propView:!1,params:u},"viewHolder"),P()})}this._$ud(this.hitPath=s,"hitPath"),this.prevInfo={path:e,...u};return}}navigator=new l;$$navigator=8192;changePath(t){t!==this.currentPath&&(this._$ud(this.currentPath=t,"currentPath"),this.onPathUpdate&&this.onPathUpdate(this.currentPath))}firstIn=!1;historyChangeListen(){let t=m();this.changePath(t),"/"+t!==this.prevInfo.path&&this.updateRoute(t)}hashChangeListen(){let t=g();this.changePath(t),"/"+t!==this.prevInfo.path&&this.updateRoute(t)}willMount(){this._$ud(this.navigator.mode=this.mode,"navigator"),Promise.resolve().then(()=>{this.mode==="hash"?this.hashChangeListen():this.historyChangeListen()})}didMount(){if(this.mode==="hash"){addEventListener("load",this.hashChangeListen),addEventListener("hashchange",this.hashChangeListen);return}addEventListener("load",this.historyChangeListen),addEventListener("popstate",this.historyChangeListen),p.push(this.historyChangeListen),history.pushState=new Proxy(L,{apply(t,e,s){let r=t.apply(e,s);return p.forEach(i=>i()),r}})}willUnmount(){if(this.mode==="hash"){removeEventListener("load",this.hashChangeListen),removeEventListener("hashchange",this.hashChangeListen);return}removeEventListener("load",this.historyChangeListen),removeEventListener("popstate",this.historyChangeListen),p=p.filter(t=>t!==this.historyChangeListen),p.length>0?history.pushState=new Proxy(L,{apply(t,e,s){let r=t.apply(e,s);return p.forEach(i=>i()),r}}):history.pushState=L}Body(){let t,e,s;return this._$update=r=>{r&257&&t&&t.updateEnv("_dl_router_baseUrl",()=>"/"+y(`${this._dl_router_baseUrl}/${this.hitPath}`),[this._dl_router_baseUrl,this.hitPath]),r&1026&&t&&t.updateEnv("path",()=>this.currentPath,[this.currentPath]),r&2048&&s&&s.updateCond(),r&8192&&t&&t.updateEnv("navigator",()=>this.navigator,[this.navigator]),s&&s.update(r)},t=new K({_dl_router_routesCollect:this.collectRoutes,_dl_router_baseUrl:"/"+y(`${this._dl_router_baseUrl}/${this.hitPath}`),path:this.currentPath,navigator:this.navigator},{_dl_router_routesCollect:[],_dl_router_baseUrl:[this._dl_router_baseUrl,this.hitPath],path:[this.currentPath],navigator:[this.navigator]}),e=new T(this.routes,[]),s=new z(2048,r=>{if(this.viewHolder.propView){if(r.cond===0)return r.didntChange=!0,[];r.cond=0;let i;return r.updateFunc=n=>{n&2048&&i&&i.update(()=>this.viewHolder.view,[this.viewHolder?.view])},i=new T(this.viewHolder.view,[this.viewHolder?.view]),r.cond===0?[i]:r.updateCond()}else{if(r.cond===1)return r.didntChange=!0,[];r.cond=1;let i,n;return r.updateFunc=a=>{a&2048&&n&&n.update(()=>i,[this.viewHolder?.view]),i&&i.update(a)},i=new J(a=>{let d;return a(h=>{h&2048&&d&&d._$setProps(()=>this.viewHolder.params,[this.viewHolder?.params])}),d=new this.viewHolder.view,d._$init(null,null,null,null),[d]}),n=new T(i,[this.viewHolder?.view]),r.cond===1?[n]:r.updateCond()}}),t.initNodes([e,s]),[t]}},X=_;import{View as Y,required as tt}from"@dlightjs/dlight";var E=class extends Y{constructor(){super(),this.collectRoutes=this.collectRoutes.bind(this)}$e$_dl_router_routesCollect;_dl_router_routesCollect=tt;$$_dl_router_routesCollect=1;$s$_dl_router_routesCollect=["collectRoutes"];$p$path;_$contentKey="path";path=".*";$$path=2;$s$path=["collectRoutes"];$p$comp;comp;$$comp=4;$s$comp=["collectRoutes"];get children(){return this._$children}$p$loading;loading;$$loading=8;$s$loading=["collectRoutes"];$p$redirect;redirect;$$redirect=16;$s$redirect=["collectRoutes"];$p$info;info;$$info=32;$s$info=["collectRoutes"];$w$collectRoutes;collectRoutes(){this._$cache("collectRoutes",[this._dl_router_routesCollect,this.path,this.comp,this.loading,this.redirect,this.info])||this._dl_router_routesCollect(this.path,{comp:this.comp,children:this.children,loading:this.loading,redirect:this.redirect,info:this.info})}},et=E;import{createElement as st,setStyle as D,delegateEvent as it,setHTMLProp as U,insertNode as rt,ExpNode as ot}from"@dlightjs/dlight";import{View as nt,required as x}from"@dlightjs/dlight";var H=class extends nt{constructor(){super(),this.handleClick=this.handleClick.bind(this)}$p$content;_$contentKey="content";content=x;$$content=1;$p$to;to=x;$p$mode;mode="history";$$mode=4;$s$mode=["nav"];$p$style;style={};$$style=8;$p$class;class="";$$class=16;get children(){return this._$children}$e$navigator;navigator=x;$$navigator=32;$s$navigator=["nav"];nav;get $f$nav(){return this._$cache("nav",[this.navigator,this.mode])?this.nav:this.navigator??new l(this.mode)}handleClick(t){if(t.preventDefault(),this.to.startsWith("http"))return window.open(this.to,"_blank");if(this.to.startsWith("?")){let e=this.nav.mode==="history"?m():g();return this.nav.to(e+this.to)}this.nav.to(this.to)}Body(){let t,e;return this._$update=s=>{s&1&&e&&e.update(()=>this.children??this.content,[this.content]),s&8&&t&&D(t,this.style),s&16&&t&&U(t,"className",()=>this.class,[this.class])},t=st("a"),D(t,this.style),U(t,"className",()=>this.class,[this.class]),it(t,"click",this.handleClick),e=new ot(this.children??this.content,[this.content]),rt(t,e,0),t._$nodes=[e],[t]}},at=H;import{CondNode as dt,ExpNode as ht,PropView as $t}from"@dlightjs/dlight";import{View as lt}from"@dlightjs/dlight";function Ye(o,t){class e extends lt{constructor(){super(),this.willMount=this.willMount.bind(this)}_$forwardProps;_$forwardPropsSet=new Set;_$forwardPropsId=[];ViewCls;$$ViewCls=8;willMount(){o().then(r=>{this._$ud(this.ViewCls=r.default,"ViewCls")})}Body(){let r;return this._$update=i=>{i&8&&r&&r.updateCond(),r&&r.update(i)},r=new dt(8,i=>{if(this.ViewCls){if(i.cond===0)return i.didntChange=!0,[];i.cond=0;let n,a;return i.updateFunc=d=>{d&8&&a&&a.update(()=>n,[this.ViewCls]),n&&n.update(d)},n=new $t(d=>{let h;return h=new this.ViewCls,h._$init(null,null,null,this),[h]}),a=new ht(n,[this.ViewCls]),i.cond===0?[a]:i.updateCond()}else if(t){if(i.cond===1)return i.didntChange=!0,[];i.cond=1;let n;return i.updateFunc=a=>{},n=new t,n._$init(null,null,null,null),i.cond===1?[n]:i.updateCond()}else return i.cond===2?(i.didntChange=!0,[]):(i.cond=2,i.updateFunc=n=>{},i.cond===2?[]:i.updateCond())}),[r]}}return e}import{createElement as ct,setStyle as F,setHTMLProp as G,insertNode as ut,ExpNode as gt}from"@dlightjs/dlight";import{View as M}from"@dlightjs/dlight";function pt(o,t){let e=[...o].reverse();for(;e.length>0;){let s=e.pop();t(s),"_$dlNodeType"in s?s._$nodes&&e.push(...[...s._$nodes].reverse()):s._$nodes?e.push(...[...s._$nodes].reverse()):e.push(...[...s.childNodes].reverse())}}function c(o,t){let e=s=>{pt(s,r=>{if(r.initNewNodes){let i=r.initNewNodes;r.initNewNodes=function(n){i.call(this,n),t(n),e(n)}}})};e(o)}var S=class extends M{constructor(){super(),this.setStyles=this.setStyles.bind(this),this.didMount=this.didMount.bind(this)}$p$spacing;spacing=0;$$spacing=1;$p$alignment;alignment="top";$$alignment=2;$s$alignment=["margin"];$p$width;width="100%";$$width=4;$p$height;height="max-content";$$height=8;$p$style;style={};$$style=16;$p$class;class;$$class=32;get children(){return this._$children}margin;get $f$margin(){return this._$cache("margin",[this.alignment])?this.margin:{top:"0 0 auto 0",bottom:"auto 0 0 0",center:"auto 0"}[this.alignment]??"0 0 auto 0"}nodes=[];setStyles(t){M.loopShallowEls(t,e=>{e.style.flexShrink="0",e.style.margin=this.margin})}didMount(){this.setStyles(this.nodes),c(this.nodes,this.setStyles)}Body(){let t,e;return this._$update=s=>{s&29&&t&&F(t,{...this.style,height:this.height,width:this.width,columnGap:`${this.spacing}px`,display:"flex",flexDirection:"row"}),s&32&&t&&G(t,"className",()=>this.class,[this.class])},t=ct("div"),G(t,"className",()=>this.class,[this.class]),F(t,{...this.style,height:this.height,width:this.width,columnGap:`${this.spacing}px`,display:"flex",flexDirection:"row"}),e=new gt(this.children,[]),M.addDidMount(e,s=>{this.nodes=s._$nodes}),ut(t,e,0),t._$nodes=[e],[t]}},mt=S;import{createElement as ft,setStyle as j,setHTMLProp as O,insertNode as yt,ExpNode as wt}from"@dlightjs/dlight";import{View as R}from"@dlightjs/dlight";var V=class extends R{constructor(){super(),this.setStyles=this.setStyles.bind(this),this.didMount=this.didMount.bind(this)}$p$spacing;spacing=0;$$spacing=1;$p$alignment;alignment="leading";$$alignment=2;$s$alignment=["margin"];$p$width;width="max-content";$$width=4;$p$height;height="100%";$$height=8;$p$style;style={};$$style=16;$p$class;class;$$class=32;get children(){return this._$children}margin;get $f$margin(){return this._$cache("margin",[this.alignment])?this.margin:{leading:"0 auto 0 0",tailing:"0 0 0 auto",center:"0 auto"}[this.alignment]??"0 auto 0 0"}nodes=[];setStyles(t){R.loopShallowEls(t,e=>{e.style.flexShrink="0",e.style.margin=this.margin})}didMount(){this.setStyles(this.nodes),c(this.nodes,this.setStyles)}Body(){let t,e;return this._$update=s=>{s&29&&t&&j(t,{...this.style,height:this.height,width:this.width,rowGap:`${this.spacing}px`,display:"flex",flexDirection:"column"}),s&32&&t&&O(t,"className",()=>this.class,[this.class])},t=ft("div"),O(t,"className",()=>this.class,[this.class]),j(t,{...this.style,height:this.height,width:this.width,rowGap:`${this.spacing}px`,display:"flex",flexDirection:"column"}),e=new wt(this.children,[]),R.addDidMount(e,s=>{this.nodes=s._$nodes}),yt(t,e,0),t._$nodes=[e],[t]}},Pt=V;import{createElement as vt,setStyle as B,setHTMLProp as Z,insertNode as Nt,ExpNode as Tt}from"@dlightjs/dlight";import{View as C}from"@dlightjs/dlight";var A=class extends C{constructor(){super(),this.setStyles=this.setStyles.bind(this),this.didMount=this.didMount.bind(this)}$p$hAlignment;hAlignment="center";$$hAlignment=1;$s$hAlignment=["justifyItems"];$p$vAlignment;vAlignment="center";$$vAlignment=2;$s$vAlignment=["alignItems"];$p$width;width="max-content";$$width=4;$p$height;height="max-content";$$height=8;$p$style;style={};$$style=16;$p$class;class;$$class=32;get children(){return this._$children}justifyItems;$$justifyItems=64;get $f$justifyItems(){return this._$cache("justifyItems",[this.hAlignment])?this.justifyItems:{leading:"flex-start",center:"center",tailing:"flex-end"}[this.hAlignment]??"center"}alignItems;$$alignItems=128;get $f$alignItems(){return this._$cache("alignItems",[this.vAlignment])?this.alignItems:{top:"flex-start",center:"center",bottom:"flex-end"}[this.vAlignment]??"center"}nodes=[];setStyles(t){C.loopShallowEls(t,e=>{e.style.position="absolute",e.style.gridArea="1 / 1/ 1 / 1"})}didMount(){this.setStyles(this.nodes),c(this.nodes,this.setStyles)}Body(){let t,e;return this._$update=s=>{s&32&&t&&Z(t,"className",()=>this.class,[this.class]),s&223&&t&&B(t,{...this.style,height:this.height,width:this.width,display:"grid",alignItems:this.alignItems,justifyItems:this.justifyItems})},t=vt("div"),Z(t,"className",()=>this.class,[this.class]),B(t,{...this.style,height:this.height,width:this.width,display:"grid",alignItems:this.alignItems,justifyItems:this.justifyItems}),e=new Tt(this.children,[]),C.addDidMount(e,s=>{this.nodes=s._$nodes}),Nt(t,e,0),t._$nodes=[e],[t]}},Lt=A;import{createElement as _t,setStyle as Et}from"@dlightjs/dlight";import{View as xt}from"@dlightjs/dlight";var b=class extends xt{isSpacer=!0;Body(){let t;return t=_t("div"),Et(t,{flexGrow:1}),[t]}},Ht=b;export{mt as HStack,at as Link,l as Navigator,et as Route,X as RouteGroup,Ht as Spacer,Pt as VStack,Lt as ZStack,Ye as lazy}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@dlightjs/components", | ||
"version": "1.0.0-next.6", | ||
"version": "1.0.0-next.7", | ||
"description": "DLight components library", | ||
@@ -5,0 +5,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
143582