@base-framework/atoms
Version:
This will add default atoms to the base framework.
3 lines (2 loc) • 7.8 kB
JavaScript
import{Atom as e}from"@base-framework/base";import{Builder as C,dataBinder as W}from"@base-framework/base";var y=t=>({tag:"comment",textContent:`${t.type} placeholder`,onCreated:t.onCreated,onDestroyed:t.onDestroyed});import{Data as Y}from"@base-framework/base";var x={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},B=t=>t>=x["2xl"]?"2xl":t>=x.xl?"xl":t>=x.lg?"lg":t>=x.md?"md":t>=x.sm?"sm":"xs",$=(t,o)=>{let s=x[t]||0,a=x[o]||0;return s>=a},l=new Y({size:null,width:0}),j=()=>{if(typeof window>"u")return;let t=window.innerWidth,o=B(t);l.size=o,l.width=t;let s=()=>{let a=window.innerWidth,r=B(a);(a!==l.width||r!==l.size)&&(l.width=a,l.size=r)};return window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s)}},G=null;typeof window<"u"&&(G=j());var u=t=>o=>{if(typeof o=="function")return m(l,"size",(s,a,r)=>$(s,t)?o(l.size,r):null)},D=u("xs"),k=u("sm"),L=u("md"),w=u("lg"),R=u("xl"),X=u("2xl");var g=t=>o=>{if(typeof o=="function")return m(l,"size",(s,a,r)=>s===t?o(s,r):null)},N=g("xs"),z=g("sm"),P=g("md"),_=g("lg"),H=g("xl"),M=g("2xl"),E=t=>o=>{if(typeof o=="function")return m(l,"size",(s,a,r)=>t.includes(s)?o(l.size,r):null)},I=E(["xs","sm"]),U=E(["md"]),F=E(["lg","xl","2xl"]);var c={PARENT:"parent",STATE:"state",ROUTE:"route"},q=(t,o)=>{switch(o){case c.PARENT:return J(t);case c.STATE:return t.state;case c.ROUTE:return t.route;default:return null}},v=(t,o,s=null)=>(a,r,p)=>a===o?t(a,r,p):s,S=(t,o=null)=>v(t,!0,o),O=(t,o=null,s=null)=>(...a)=>{let r=[...a],p=r.pop();if(typeof p=="function")return V({onCreated:(i,d)=>{if(r.length<(o?1:2)){let Q=q(d,t);r.unshift(Q)}let f=o||r[1],b=s?s(p,r):p,h=K(b,i,f,d);W.watch(i,r[0],f,h)}})},T=(t,o,s)=>(...a)=>{let r=[...a],p=typeof r[0]=="function"?r[0]:r[1];if(typeof p=="function")return V({onCreated:(i,d)=>{if(r.length<2||typeof r[0]=="function"){let h=q(d,t);r.unshift(h)}let f=s(p,r),b=K(f,i,o,d);W.watch(i,r[0],o,b)}})},K=(t,o,s,a)=>r=>{o._prevEle&&(C.removeNode(o._prevEle),o._prevEle=null);let p=t(r,o,a);if(p===void 0)return;let i=C.build(p,null,a);o._prevEle=i.childNodes[0],o.parentNode.insertBefore(i,o.nextSibling)},V=t=>y({type:"on",onCreated:t.onCreated,onDestroyed:o=>{o._prevEle&&(C.removeNode(o._prevEle),o._prevEle=null)}}),J=t=>t.data?t.data:t.context&&t.context.data?t.context.data:t.state?t.state:null,m=O(c.PARENT),Z=O(c.STATE),tt=O(c.ROUTE),ot=O(c.PARENT,null,(t,o)=>v(t,o[2])),et=O(c.STATE,null,(t,o)=>v(t,o[2])),nt=T(c.PARENT,"loaded",(t,o)=>{let s=o.length===3?o[2]:null;return S(t,s)}),rt=T(c.STATE,"loaded",(t,o)=>{let s=o.length===3?o[2]:null;return S(t,s)}),st=T(c.PARENT,"open",t=>S(t)),at=T(c.STATE,"open",t=>S(t));import{Builder as A}from"@base-framework/base";var ct=(t,o,s)=>{o._prevEle&&(A.removeNode(o._prevEle),o._prevEle=null);let a=t(s);if(a===void 0)return;let r=A.build(a,null,s);o._prevEle=r.childNodes[0],o.parentNode.insertBefore(r,o.nextSibling)},pt=t=>y({type:"use",onCreated:t.onCreated,onDestroyed:o=>{o._prevEle&&(A.removeNode(o._prevEle),o._prevEle=null)}}),lt=t=>pt({onCreated:(o,s)=>{ct(t,o,s)}});var n=(t,o)=>({...t,children:o}),At=t=>({...t,tag:"DOCTYPE"}),Bt=e((t,o)=>n({...t,tag:"html"},o)),Dt=e((t,o)=>n({...t,tag:"script"},o)),kt=e((t,o)=>n({...t,tag:"style"},o)),Lt=e((t,o)=>n({...t,tag:"head"},o)),wt=t=>({...t}),Rt=t=>({...t,tag:"meta"}),Xt=t=>({...t,tag:"link"}),Nt=e((t,o)=>n({...t,tag:"body"},o)),zt=e((t,o)=>n(t,o)),Pt=e((t,o)=>n({...t,tag:"dialog"},o)),_t=e((t,o)=>n({...t,tag:"span"},o)),Ht=e((t,o)=>n({...t,tag:"p"},o)),Mt=e((t,o)=>n({...t,tag:"a"},o)),it=e((t,o)=>n({...t,tag:"button"},o)),It=e((t,o)=>it({...t,type:"submit"},o)),Ut=e((t,o)=>n({...t,tag:"ul"},o)),Ft=e((t,o)=>n({...t,tag:"li"},o)),Wt=e(t=>n({...t,tag:"img"},null)),qt=e(t=>n({...t,tag:"br"},null)),Kt=e(t=>n({...t,tag:"hr"},null)),Vt=e((t,o)=>n({...t,tag:"text"},o)),Qt=e((t,o)=>n({...t,tag:"h1"},o)),Yt=e((t,o)=>n({...t,tag:"h2"},o)),$t=e((t,o)=>n({...t,tag:"h3"},o)),jt=e((t,o)=>n({...t,tag:"h4"},o)),Gt=e((t,o)=>n({...t,tag:"h5"},o)),Jt=e((t,o)=>n({...t,tag:"h6"},o)),xt=e(t=>n({...t,tag:"input"},null)),Zt=e((t,o)=>n({...t,tag:"label"},o)),to=e(t=>xt({...t,type:"checkbox"})),oo=e((t,o)=>n({...t,tag:"section"},o)),eo=e((t,o)=>n({...t,tag:"article"},o)),no=e((t,o)=>n({...t,tag:"header"},o)),ro=e((t,o)=>n({...t,tag:"footer"},o)),so=e((t,o)=>n({...t,tag:"nav"},o)),ao=e((t,o)=>n({...t,tag:"aside"},o)),co=e((t,o)=>n({...t,tag:"figure"},o)),po=e((t,o)=>n({...t,tag:"figcaption"},o)),lo=e((t,o)=>n({...t,tag:"main"},o)),io=e((t,o)=>n({...t,tag:"video"},o)),xo=e((t,o)=>n({...t,tag:"audio"},o)),uo=e((t,o)=>n({...t,tag:"table"},o)),go=e((t,o)=>n({...t,tag:"tr"},o)),mo=e((t,o)=>n({...t,tag:"th"},o)),Oo=e((t,o)=>n({...t,tag:"td"},o)),fo=e((t,o)=>n({...t,tag:"thead"},o)),yo=e((t,o)=>n({...t,tag:"tbody"},o)),So=e((t,o)=>n({...t,tag:"tfoot"},o)),To=e((t,o)=>n({...t,tag:"form"},o)),bo=e((t,o)=>n({...t,tag:"select"},o)),ho=e((t,o)=>n({...t,tag:"option"},o)),Eo=e((t,o)=>n({...t,tag:"textarea"},o)),Co=e((t,o)=>n({...t,tag:"canvas"},o)),vo=e((t,o)=>n({...t,tag:"progress"},o)),Ao=e((t,o)=>n({...t,tag:"blockquote"},o)),Bo=e((t,o)=>n({...t,tag:"pre"},o)),Do=e((t,o)=>n({...t,tag:"code"},o)),ko=e((t,o)=>n({...t,tag:"ol"},o)),Lo=e((t,o)=>n({...t,tag:"dl"},o)),wo=e((t,o)=>n({...t,tag:"dt"},o)),Ro=e((t,o)=>n({...t,tag:"dd"},o)),Xo=e((t,o)=>n({...t,tag:"fieldset"},o)),No=e((t,o)=>n({...t,tag:"legend"},o)),zo=e((t,o)=>n({...t,tag:"meter"},o)),Po=e((t,o)=>n({...t,tag:"iframe"},o)),_o=e((t,o)=>n({...t,tag:"details"},o)),Ho=e((t,o)=>n({...t,tag:"summary"},o)),Mo=e((t,o)=>n({...t,tag:"em"},o)),Io=e((t,o)=>n({...t,tag:"strong"},o)),Uo=e((t,o)=>n({...t,tag:"small"},o)),Fo=e((t,o)=>n({...t,tag:"s"},o)),Wo=e((t,o)=>n({...t,tag:"cite"},o)),qo=e((t,o)=>n({...t,tag:"q"},o)),Ko=e((t,o)=>n({...t,tag:"dfn"},o)),Vo=e((t,o)=>n({...t,tag:"abbr"},o)),Qo=e((t,o)=>n({...t,tag:"data"},o)),Yo=e((t,o)=>n({...t,tag:"time"},o)),$o=e((t,o)=>n({...t,tag:"var"},o)),jo=e((t,o)=>n({...t,tag:"samp"},o)),Go=e((t,o)=>n({...t,tag:"kbd"},o)),Jo=e((t,o)=>n({...t,tag:"sub"},o)),Zo=e((t,o)=>n({...t,tag:"sup"},o)),te=e((t,o)=>n({...t,tag:"i"},o)),oe=e((t,o)=>n({...t,tag:"b"},o)),ee=e((t,o)=>n({...t,tag:"u"},o)),ne=e((t,o)=>n({...t,tag:"mark"},o)),re=e((t,o)=>n({...t,tag:"ruby"},o)),se=e((t,o)=>n({...t,tag:"rt"},o)),ae=e((t,o)=>n({...t,tag:"rp"},o)),ce=e((t,o)=>n({...t,tag:"bdi"},o)),pe=e((t,o)=>n({...t,tag:"bdo"},o)),le=e(t=>n({...t,tag:"wbr"},null)),ie=e(t=>n({...t,tag:"comment"},null));export{Mt as A,Vo as Abbr,eo as Article,ao as Aside,xo as Audio,oe as B,ce as Bdi,pe as Bdo,Ao as Blockquote,Nt as Body,qt as Br,it as Button,Co as Canvas,to as Checkbox,Wo as Cite,Do as Code,ie as Comment,Qo as Data,Ro as Dd,_o as Details,Ko as Dfn,Pt as Dialog,zt as Div,Lo as Dl,At as Doctype,wo as Dt,Mo as Em,Xo as Fieldset,po as Figcaption,co as Figure,ro as Footer,To as Form,Qt as H1,Yt as H2,$t as H3,jt as H4,Gt as H5,Jt as H6,Lt as Head,no as Header,Kt as Hr,Bt as Html,te as I,ot as If,et as IfState,Po as Iframe,Wt as Img,xt as Input,Go as Kbd,Zt as Label,No as Legend,Ft as Li,Xt as Link,lo as Main,ne as Mark,Rt as Meta,zo as Meter,so as Nav,ko as Ol,m as On,X as On2Xl,M as On2XlOnly,F as OnDesktop,w as OnLg,_ as OnLgOnly,nt as OnLoad,L as OnMd,P as OnMdOnly,st as OnOpen,I as OnPhone,tt as OnRoute,k as OnSm,z as OnSmOnly,Z as OnState,rt as OnStateLoad,at as OnStateOpen,U as OnTablet,R as OnXl,H as OnXlOnly,D as OnXs,N as OnXsOnly,ho as Option,Ht as P,Bo as Pre,vo as Progress,qo as Q,ae as Rp,se as Rt,re as Ruby,Fo as S,jo as Samp,Dt as Script,oo as Section,bo as Select,Uo as Small,_t as Span,Io as Strong,kt as Style,Jo as Sub,It as SubmitButton,Ho as Summary,Zo as Sup,uo as Table,yo as Tbody,Oo as Td,Vt as Text,Eo as Textarea,So as Tfoot,mo as Th,fo as Thead,Yo as Time,wt as Title,go as Tr,ee as U,Ut as Ul,lt as UseParent,$o as Var,io as Video,le as Wbr};
//# sourceMappingURL=atoms.js.map