@base-framework/organisms
Version:
This will add default organisms to the base framework.
3 lines (2 loc) • 1.06 kB
JavaScript
import{Component as u,router as d}from"@base-framework/base";var r=(s,t)=>({attr:s,value:t}),f=s=>String(s).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),g=(s,t)=>new RegExp("^"+f(s)+"($|#|/|\\.).*").test(t),i=class extends u{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,c=this.setupWatchers(t,e);return{tag:"a",class:this.class||this.className||null,onState:["selected",{[this.selectedClass]:!0}],href:this.getString(t),text:this.getString(e),nest:this.nest||this.children,dataSet:this.dataSet,watch:c}}getLinkPath(){return this?.panel?.pathname||null}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let c=this.exact===!0,p=d.data,a=[];return t&&typeof t=="object"&&a.push(r("href",t)),e&&typeof e=="object"&&a.push(r("text",e)),a.push({value:["[[path]]",p],callBack:(n,h)=>{let l=h.pathname+h.hash,o=c?n===l:g(h.pathname,n);this.update(o)}}),a}setupStates(){return{selected:!1}}update(t){this.state.selected=t}};export{i as a};
//# sourceMappingURL=chunk-L4FOVYKJ.js.map