UNPKG

@codeperate/cdp-ui-library

Version:

Codeperate UI Library

1 lines 5.49 kB
import{r as e,h as r,H as t,a as n}from"./p-21e532ba.js";import{d as i}from"./p-c571c098.js";function o(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function a(e){return e&&e.sensitive?"":"i"}function s(e,r,t){return function(e,r,t){void 0===t&&(t={});for(var n=t.strict,i=void 0!==n&&n,s=t.start,c=void 0===s||s,u=t.end,f=void 0===u||u,p=t.encode,d=void 0===p?function(e){return e}:p,l="["+o(t.endsWith||"")+"]|$",v="["+o(t.delimiter||"/#?")+"]",m=c?"^":"",g=0,x=e;g<x.length;g++){var h=x[g];if("string"==typeof h)m+=o(d(h));else{var E=o(d(h.prefix)),y=o(d(h.suffix));h.pattern?(r&&r.push(h),m+=E||y?"+"===h.modifier||"*"===h.modifier?"(?:"+E+"((?:"+h.pattern+")(?:"+y+E+"(?:"+h.pattern+"))*)"+y+")"+("*"===h.modifier?"?":""):"(?:"+E+"("+h.pattern+")"+y+")"+h.modifier:"("+h.pattern+")"+h.modifier):m+="(?:"+E+y+")"+h.modifier}}if(f)i||(m+=v+"?"),m+=t.endsWith?"(?="+l+")":"$";else{var b=e[e.length-1],A="string"==typeof b?v.indexOf(b[b.length-1])>-1:void 0===b;i||(m+="(?:"+v+"(?="+l+"))?"),A||(m+="(?="+v+"|"+l+")")}return new RegExp(m,a(t))}(function(e,r){void 0===r&&(r={});for(var t=function(e){for(var r=[],t=0;t<e.length;){var n=e[t];if("*"!==n&&"+"!==n&&"?"!==n)if("\\"!==n)if("{"!==n)if("}"!==n)if(":"!==n)if("("!==n)r.push({type:"CHAR",index:t,value:e[t++]});else{var i=1,o="";if("?"===e[s=t+1])throw new TypeError('Pattern cannot start with "?" at '+s);for(;s<e.length;)if("\\"!==e[s]){if(")"===e[s]){if(0==--i){s++;break}}else if("("===e[s]&&(i++,"?"!==e[s+1]))throw new TypeError("Capturing groups are not allowed at "+s);o+=e[s++]}else o+=e[s++]+e[s++];if(i)throw new TypeError("Unbalanced pattern at "+t);if(!o)throw new TypeError("Missing pattern at "+t);r.push({type:"PATTERN",index:t,value:o}),t=s}else{for(var a="",s=t+1;s<e.length;){var c=e.charCodeAt(s);if(!(c>=48&&c<=57||c>=65&&c<=90||c>=97&&c<=122||95===c))break;a+=e[s++]}if(!a)throw new TypeError("Missing parameter name at "+t);r.push({type:"NAME",index:t,value:a}),t=s}else r.push({type:"CLOSE",index:t,value:e[t++]});else r.push({type:"OPEN",index:t,value:e[t++]});else r.push({type:"ESCAPED_CHAR",index:t++,value:e[t++]});else r.push({type:"MODIFIER",index:t,value:e[t++]})}return r.push({type:"END",index:t,value:""}),r}(e),n=r.prefixes,i=void 0===n?"./":n,a="[^"+o(r.delimiter||"/#?")+"]+?",s=[],c=0,u=0,f="",p=function(e){if(u<t.length&&t[u].type===e)return t[u++].value},d=function(e){var r=p(e);if(void 0!==r)return r;var n=t[u];throw new TypeError("Unexpected "+n.type+" at "+n.index+", expected "+e)},l=function(){for(var e,r="";e=p("CHAR")||p("ESCAPED_CHAR");)r+=e;return r};u<t.length;){var v=p("CHAR"),m=p("NAME"),g=p("PATTERN");if(m||g)-1===i.indexOf(h=v||"")&&(f+=h,h=""),f&&(s.push(f),f=""),s.push({name:m||c++,prefix:h,suffix:"",pattern:g||a,modifier:p("MODIFIER")||""});else{var x=v||p("ESCAPED_CHAR");if(x)f+=x;else if(f&&(s.push(f),f=""),p("OPEN")){var h=l(),E=p("NAME")||"",y=p("PATTERN")||"",b=l();d("CLOSE"),s.push({name:E||(y?c++:""),pattern:E&&!y?a:y,prefix:h,suffix:b,modifier:p("MODIFIER")||""})}else d("END")}}return s}(e,t),r,t)}function c(e,r,t){return e instanceof RegExp?function(e,r){if(!r)return e;for(var t=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,i=t.exec(e.source);i;)r.push({name:i[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),i=t.exec(e.source);return e}(e,r):Array.isArray(e)?function(e,r,t){var n=e.map((function(e){return c(e,r,t).source}));return new RegExp("(?:"+n.join("|")+")",a(t))}(e,r,t):s(e,r,t)}const u=class{constructor(r){e(this,r),this.defaultConfig={menuItems:[],anchorPropsFn:null,classList:{host:"grid grid-cols-1 gap-y-2 auto-rows-min",menuItem:"py-2 px-4 hover:bg-light-blue-600 hover:text-white rounded-md grid grid-cols-[max-content,1fr,max-content] items-center gap-4 cursor-pointer",menuItemActive:"py-2 px-4 bg-light-blue-600 text-white rounded-md grid grid-cols-[max-content,1fr,max-content] items-center gap-4 cursor-pointer",subMenuItem:"py-1 px-4 hover:bg-light-blue-600 hover:text-white rounded-md grid grid-cols-[max-content,1fr,max-content] items-center gap-4",subMenuItemActive:"py-1 px-4 bg-light-blue-600 text-white rounded-md grid grid-cols-[max-content,1fr,max-content] items-center gap-4",subMenuWrapper:"grid grid-cols-1 gap-y-1 mt-2 pl-4"}}}componentWillLoad(){this._config=i(this.config,this.defaultConfig)}isActive(e,r){const t=c(e);return!!r.match(t)}render(){const{classList:e,anchorPropsFn:n,menuItems:i}=this._config,o=this.props.activePath;return r(t,{class:e.host},i.map((t=>{var{name:i,isActive:a,icon:s,indicator:c}=t,u=function(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]])}return t}(t,["name","isActive","icon","indicator"]);let f=u.href,p=u.expand,d=a?a(o):this.isActive(f,o);return u.nested?r("cdp-accordion",{props:{display:p||d},config:{toggle:!f}},r("a",Object.assign({slot:"accordion",class:d?e.menuItemActive:e.menuItem},f?n(f):{}),s?s(d):"",i,c?c(d):""),r("div",{class:e.subMenuWrapper},u.nested.map((({name:t,href:i,indicator:a,icon:s,isActive:c})=>{let u=c?c(o):this.isActive(i,o);return r("a",Object.assign({},n(i),{class:u?e.subMenuItemActive:e.subMenuItem}),s?s(u):"",t,a?a(u):"")})))):r("a",Object.assign({},n(f),{class:d?e.menuItemActive:e.menuItem}),s?s(d):"",i,c?c(d):"")})))}get rootEl(){return n(this)}};export{u as cdp_menu_list}