@anjuna/docs
Version:
Anjuna Documentation Web Components
1 lines • 6.01 kB
JavaScript
const t=window.AnjunaDocs.h;class e{static get is(){return"ad-api-name"}static get style(){return"ad-api-name:after{color:var(--anj-secondary-dark);content:\":\";margin-right:.5rem}"}}class s{render(){return[t("ad-api-name",null,this.arg.name),t("ad-type-def",null,this.arg.type)]}static get is(){return"ad-arg-def"}static get properties(){return{arg:{type:"Any",attr:"arg"}}}static get style(){return"ad-arg-def:after{color:var(--anj-secondary-dark);content:\",\";margin-right:.5rem}ad-arg-def:last-child:after{content:none;margin-right:0}"}}class a{static get is(){return"ad-decorator"}static get style(){return"ad-decorator{color:var(--anj-secondary-dark)}.api.ng ad-method-def ad-decorator,.api.ng ad-prop-def ad-decorator{display:none}"}}class r{render(){return[t("h4",null,t("ad-decorator",null,"@Event")," ",t("ad-api-name",null,this.event.event)),t("p",null,this.event.docs)]}static get is(){return"ad-event-def"}static get properties(){return{event:{type:"Any",attr:"event"}}}static get style(){return"ad-event-def,ad-input-def,ad-method-def,ad-output-def,ad-prop-def{display:block;margin-bottom:1.5rem}ad-event-def h4,ad-input-def h4,ad-method-def h4,ad-output-def h4,ad-prop-def h4{color:var(--anj-dark);font-size:1rem;font-weight:400;margin:0 0 .5rem;padding:0}"}}class n{render(){return[t("h4",null,t("ad-decorator",null,"@Input "),t("ad-api-name",null,this.input.name),t("ad-type-def",null,this.input.type)),t("p",null,this.input.docs)]}static get is(){return"ad-input-def"}static get properties(){return{input:{type:"Any",attr:"input"}}}static get style(){return"ad-event-def,ad-input-def,ad-method-def,ad-output-def,ad-prop-def{display:block;margin-bottom:1.5rem}ad-event-def h4,ad-input-def h4,ad-method-def h4,ad-output-def h4,ad-prop-def h4{color:var(--anj-dark);font-size:1rem;font-weight:400;margin:0 0 .5rem;padding:0}"}}class i{nameless(t){return`(${t.split("(")[1]}`}render(){return[t("h4",null,t("ad-decorator",null,"@Method "),t("ad-api-name",null,this.method.name),t("ad-type-def",null,this.nameless(this.method.signature))),t("p",null,this.method.docs)]}static get is(){return"ad-method-def"}static get properties(){return{method:{type:"Any",attr:"method"}}}static get style(){return"ad-event-def,ad-input-def,ad-method-def,ad-output-def,ad-prop-def{display:block;margin-bottom:1.5rem}ad-event-def h4,ad-input-def h4,ad-method-def h4,ad-output-def h4,ad-prop-def h4{color:var(--anj-dark);font-size:1rem;font-weight:400;margin:0 0 .5rem;padding:0}"}}class l{render(){return[t("h4",null,t("ad-decorator",null,"@Output "),t("ad-api-name",null,this.output.name),t("ad-type-def",null,this.output.type)),t("p",null,this.output.docs)]}static get is(){return"ad-output-def"}static get properties(){return{output:{type:"Any",attr:"output"}}}static get style(){return"ad-event-def,ad-input-def,ad-method-def,ad-output-def,ad-prop-def{display:block;margin-bottom:1.5rem}ad-event-def h4,ad-input-def h4,ad-method-def h4,ad-output-def h4,ad-prop-def h4{color:var(--anj-dark);font-size:1rem;font-weight:400;margin:0 0 .5rem;padding:0}"}}class o{render(){return[t("h4",null,t("ad-decorator",null,"@Prop "),t("ad-api-name",null,this.prop.name),t("ad-type-def",null,this.prop.type)),t("p",null,this.prop.docs)]}static get is(){return"ad-prop-def"}static get properties(){return{prop:{type:"Any",attr:"prop"}}}static get style(){return"ad-event-def,ad-input-def,ad-method-def,ad-output-def,ad-prop-def{display:block;margin-bottom:1.5rem}ad-event-def h4,ad-input-def h4,ad-method-def h4,ad-output-def h4,ad-prop-def h4{color:var(--anj-dark);font-size:1rem;font-weight:400;margin:0 0 .5rem;padding:0}"}}class d{static get is(){return"ad-real-time"}static get style(){return"ad-real-time{border:1px dashed var(--anj-border);border-radius:.25rem;display:block;margin-top:1.5rem;overflow-x:auto;padding:1rem;width:100%}"}}class c{constructor(){this.activeId="#overview",this.docs={}}onDemosChange(){this.sectionIds=["#overview"].concat(this.demos.map(t=>`#${t.usage}`)).concat("#api")}componentDidLoad(){this.navigate=p(this.navigate.bind(this),50),this.onScroll=p(this.onScroll.bind(this),10),this.onDemosChange(),window.location.hash&&this.navigate()}onScroll(){const t=this.sectionIds.map(t=>document.querySelector(t));let e=t[0];t.slice(1).forEach(t=>{t&&Math.abs(window.scrollY-t.offsetTop)<Math.abs(window.scrollY-e.offsetTop)&&(e=t)}),this.activeId=`#${e.getAttribute("id")}`}parseTitle(t){const e=t.replace("#",""),s=this.docs[e];return s?s.split(/##(.*?)\n/).find(t=>""!==t).trim():e}anchorClass(t){return t===this.activeId?"anj-active":""}navigate(){return new Promise(t=>{window.setTimeout(()=>{this.activeId=window.location.hash;const e=document.querySelector(this.activeId);window.scrollTo(0,e.offsetTop),t()},500)})}render(){if(!this.sectionIds)return;const e=window.location.pathname;return t("div",{class:"anj-toc"},this.sectionIds.map(s=>t("a",{href:`${e}${s}`,onClick:()=>this.activeId=s,class:this.anchorClass(s)},this.parseTitle(s))))}static get is(){return"ad-toc"}static get properties(){return{activeId:{state:!0},demos:{type:"Any",attr:"demos",watchCallbacks:["onDemosChange"]},docs:{type:"Any",attr:"docs"},sectionIds:{state:!0}}}static get listeners(){return[{name:"window:scroll",method:"onScroll",passive:!0}]}static get style(){return"ad-toc{display:block;position:relative}ad-toc .anj-toc{padding:1rem 0;position:fixed;top:3rem;z-index:1030}ad-toc a{display:block;font-size:.75rem;margin-bottom:.5rem;text-transform:capitalize;-webkit-transition:color .2s ease;transition:color .2s ease}ad-toc a.anj-active,ad-toc a.anj-active:hover{color:var(--anj-primary);text-decoration:none}"}}const p=(t,e=0)=>{let s;return(...a)=>{clearTimeout(s),s=setTimeout(t,e,...a)}};class u{static get is(){return"ad-type-def"}static get style(){return"ad-type-def{color:var(--anj-neutral);font-size:.75rem}"}}export{e as AdApiName,s as AdArgDef,a as AdDecorator,r as AdEventDef,n as AdInputDef,i as AdMethodDef,l as AdOutputDef,o as AdPropDef,d as AdRealTime,c as AdToc,u as AdTypeDef};