@ukpc-lib/react 0.3.41 → 0.3.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.js +2 -2
- package/dist/{index.module-edaf6f24.cjs → index.module-06bf4d76.cjs} +1 -1
- package/dist/{index.module-b7d2d67a.js → index.module-0f5e9fad.js} +2234 -2231
- package/dist/share/index.cjs +1 -1
- package/dist/share/index.js +1 -1
- package/package.json +1 -1
- package/web-components-bundle/global-menu/index.cjs +1 -1
- package/web-components-bundle/global-menu/index.js +1 -1
- package/web-components-bundle/global-topbar/index.cjs +1 -1
- package/web-components-bundle/global-topbar/index.js +2 -2
- package/web-components-bundle/has-permission/index.cjs +1 -1
- package/web-components-bundle/has-permission/index.js +2 -2
- package/web-components-bundle/{index-6c2bc04a.cjs → index-60a9bd54.cjs} +1 -1
- package/web-components-bundle/{index-bc5f0a32.js → index-981f4a42.js} +5948 -5951
- package/web-components-bundle/{index-abae7804.cjs → index-a3fc049e.cjs} +79 -79
- package/web-components-bundle/{index-f9a0dd02.js → index-db308fb2.js} +4 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),j=require("react"),m=require("../index.module-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),j=require("react"),m=require("../index.module-06bf4d76.cjs"),K=require("moment"),Gt=require("axios");require("@r2wc/react-to-web-component");const an=require("react-router-dom"),N=require("@mui/material");function Jn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const L=Jn(j),Qn=e=>{var n,o;const{tabs:t}=e,r=i=>{e.setCurrentTab(i.target.id)};return console.log("🚀 ~ brandColors:",e.currentTab),s.jsxs(s.Fragment,{children:[s.jsx("style",{children:`
|
|
2
2
|
.tab-title {
|
|
3
3
|
min-width: 90px;
|
|
4
4
|
padding: 5px 16px;
|
package/dist/components/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as N, Fragment as $e, jsx as c } from "react/jsx-runtime";
|
|
2
2
|
import * as L from "react";
|
|
3
3
|
import Co, { useState as G, useContext as xe, useEffect as Q, useRef as be, useCallback as bt, forwardRef as Oo, createElement as tr, PureComponent as No } from "react";
|
|
4
|
-
import { c as Ne, Q as $n, g as To, C as Te, p as Pt, S as ko, a as $o, L as Io, b as Pr, u as Mo, d as mt, e as Ao, s as pt, _ as z, f as _e, P as k, h as he, i as Po, o as Ro, j as Do, k as zo, l as Rr, m as In, n as xt, q as Dr, I as Fo, r as Lo, t as zr, D as jo, v as Mn, w as An, x as Vo, y as Ho, z as Oe, A as Bo, B as gt } from "../index.module-
|
|
5
|
-
import { G as Tc, E as kc, F as $c } from "../index.module-
|
|
4
|
+
import { c as Ne, Q as $n, g as To, C as Te, p as Pt, S as ko, a as $o, L as Io, b as Pr, u as Mo, d as mt, e as Ao, s as pt, _ as z, f as _e, P as k, h as he, i as Po, o as Ro, j as Do, k as zo, l as Rr, m as In, n as xt, q as Dr, I as Fo, r as Lo, t as zr, D as jo, v as Mn, w as An, x as Vo, y as Ho, z as Oe, A as Bo, B as gt } from "../index.module-0f5e9fad.js";
|
|
5
|
+
import { G as Tc, E as kc, F as $c } from "../index.module-0f5e9fad.js";
|
|
6
6
|
import Z from "moment";
|
|
7
7
|
import hr from "axios";
|
|
8
8
|
import "@r2wc/react-to-web-component";
|
|
@@ -132,7 +132,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
132
132
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
133
133
|
* MIT Licensed
|
|
134
134
|
*/var ly=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,pD=/\\([\u000b\u0020-\u00ff])/g,gD=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,mD=vD;function vD(t){if(!t)throw new TypeError("argument string is required");var e=typeof t=="object"?yD(t):t;if(typeof e!="string")throw new TypeError("argument string is required to be a string");var n=e.indexOf(";"),r=n!==-1?e.slice(0,n).trim():e.trim();if(!gD.test(r))throw new TypeError("invalid media type");var i=new bD(r.toLowerCase());if(n!==-1){var s,u,g;for(ly.lastIndex=n;u=ly.exec(e);){if(u.index!==n)throw new TypeError("invalid parameter format");n+=u[0].length,s=u[1].toLowerCase(),g=u[2],g.charCodeAt(0)===34&&(g=g.slice(1,-1),g.indexOf("\\")!==-1&&(g=g.replace(pD,"$1"))),i.parameters[s]=g}if(n!==e.length)throw new TypeError("invalid parameter format")}return i}function yD(t){var e;if(typeof t.getHeader=="function"?e=t.getHeader("content-type"):typeof t.headers=="object"&&(e=t.headers&&t.headers["content-type"]),typeof e!="string")throw new TypeError("content-type header is missing from object");return e}function bD(t){this.parameters=Object.create(null),this.type=t}var vc=new Map,tw=function(e){return e.cloneNode(!0)},uy=function(){return window.location.protocol==="file:"},nw=function(e,n,r){var i=new XMLHttpRequest;i.onreadystatechange=function(){try{if(!/\.svg/i.test(e)&&i.readyState===2){var s=i.getResponseHeader("Content-Type");if(!s)throw new Error("Content type not found");var u=mD(s).type;if(!(u==="image/svg+xml"||u==="text/plain"))throw new Error("Invalid content type: ".concat(u))}if(i.readyState===4){if(i.status===404||i.responseXML===null)throw new Error(uy()?"Note: SVG injection ajax calls do not work locally without adjusting security settings in your browser. Or consider using a local webserver.":"Unable to load SVG file: "+e);if(i.status===200||uy()&&i.status===0)r(null,i);else throw new Error("There was a problem injecting the SVG: "+i.status+" "+i.statusText)}}catch(g){if(i.abort(),g instanceof Error)r(g,i);else throw g}},i.open("GET",e),i.withCredentials=n,i.overrideMimeType&&i.overrideMimeType("text/xml"),i.send()},jl={},cy=function(e,n){jl[e]=jl[e]||[],jl[e].push(n)},wD=function(e){for(var n=function(u,g){setTimeout(function(){if(Array.isArray(jl[e])){var p=vc.get(e),y=jl[e][u];p instanceof SVGSVGElement&&y(null,tw(p)),p instanceof Error&&y(p),u===jl[e].length-1&&delete jl[e]}},0)},r=0,i=jl[e].length;r<i;r++)n(r)},xD=function(e,n,r){if(vc.has(e)){var i=vc.get(e);if(i===void 0){cy(e,r);return}if(i instanceof SVGSVGElement){r(null,tw(i));return}}vc.set(e,void 0),cy(e,r),nw(e,n,function(s,u){var g;s?vc.set(e,s):((g=u.responseXML)===null||g===void 0?void 0:g.documentElement)instanceof SVGSVGElement&&vc.set(e,u.responseXML.documentElement),wD(e)})},SD=function(e,n,r){nw(e,n,function(i,s){var u;i?r(i):((u=s.responseXML)===null||u===void 0?void 0:u.documentElement)instanceof SVGSVGElement&&r(null,s.responseXML.documentElement)})},CD=0,TD=function(){return++CD},us=[],fy={},ED="http://www.w3.org/2000/svg",Eh="http://www.w3.org/1999/xlink",dy=function(e,n,r,i,s,u,g){var p=e.getAttribute("data-src")||e.getAttribute("src");if(!p){g(new Error("Invalid data-src or src attribute"));return}if(us.indexOf(e)!==-1){us.splice(us.indexOf(e),1),e=null;return}us.push(e),e.setAttribute("src","");var y=i?xD:SD;y(p,s,function(T,x){if(!x){us.splice(us.indexOf(e),1),e=null,g(T);return}var O=e.getAttribute("id");O&&x.setAttribute("id",O);var j=e.getAttribute("title");j&&x.setAttribute("title",j);var Y=e.getAttribute("width");Y&&x.setAttribute("width",Y);var z=e.getAttribute("height");z&&x.setAttribute("height",z);var $=Array.from(new Set(Th(Th(Th([],(x.getAttribute("class")||"").split(" "),!0),["injected-svg"],!1),(e.getAttribute("class")||"").split(" "),!0))).join(" ").trim();x.setAttribute("class",$);var L=e.getAttribute("style");L&&x.setAttribute("style",L),x.setAttribute("data-src",p);var te=[].filter.call(e.attributes,function(Ye){return/^data-\w[\w-]*$/.test(Ye.name)});if(Array.prototype.forEach.call(te,function(Ye){Ye.name&&Ye.value&&x.setAttribute(Ye.name,Ye.value)}),r){var ne={clipPath:["clip-path"],"color-profile":["color-profile"],cursor:["cursor"],filter:["filter"],linearGradient:["fill","stroke"],marker:["marker","marker-start","marker-mid","marker-end"],mask:["mask"],path:[],pattern:["fill","stroke"],radialGradient:["fill","stroke"]},he,ie,xe,b,Se;Object.keys(ne).forEach(function(Ye){he=Ye,xe=ne[Ye],ie=x.querySelectorAll(he+"[id]");for(var rt=function(Ze,Qe){b=ie[Ze].id,Se=b+"-"+TD();var Je;Array.prototype.forEach.call(xe,function(Bt){Je=x.querySelectorAll("["+Bt+'*="'+b+'"]');for(var Ht=0,zn=Je.length;Ht<zn;Ht++){var hr=Je[Ht].getAttribute(Bt);hr&&!hr.match(new RegExp('url\\("?#'+b+'"?\\)'))||Je[Ht].setAttribute(Bt,"url(#"+Se+")")}});for(var Ke=x.querySelectorAll("[*|href]"),ht=[],wt=0,xt=Ke.length;wt<xt;wt++){var pt=Ke[wt].getAttributeNS(Eh,"href");pt&&pt.toString()==="#"+ie[Ze].id&&ht.push(Ke[wt])}for(var Tt=0,Xe=ht.length;Tt<Xe;Tt++)ht[Tt].setAttributeNS(Eh,"href","#"+Se);ie[Ze].id=Se},_e=0,Ae=ie.length;_e<Ae;_e++)rt(_e)})}x.removeAttribute("xmlns:a");for(var me=x.querySelectorAll("script"),tt=[],vt,nt,et=0,ft=me.length;et<ft;et++)nt=me[et].getAttribute("type"),(!nt||nt==="application/ecmascript"||nt==="application/javascript"||nt==="text/javascript")&&(vt=me[et].innerText||me[et].textContent,vt&&tt.push(vt),x.removeChild(me[et]));if(tt.length>0&&(n==="always"||n==="once"&&!fy[p])){for(var ve=0,Me=tt.length;ve<Me;ve++)new Function(tt[ve])(window);fy[p]=!0}var Ve=x.querySelectorAll("style");if(Array.prototype.forEach.call(Ve,function(Ye){Ye.textContent+=""}),x.setAttribute("xmlns",ED),x.setAttribute("xmlns:xlink",Eh),u(x),!e.parentNode){us.splice(us.indexOf(e),1),e=null,g(new Error("Parent node is null"));return}e.parentNode.replaceChild(x,e),us.splice(us.indexOf(e),1),e=null,g(null,x)})},kD=function(e,n){var r=n===void 0?{}:n,i=r.afterAll,s=i===void 0?function(){}:i,u=r.afterEach,g=u===void 0?function(){}:u,p=r.beforeEach,y=p===void 0?function(){}:p,T=r.cacheRequests,x=T===void 0?!0:T,O=r.evalScripts,j=O===void 0?"never":O,Y=r.httpRequestWithCredentials,z=Y===void 0?!1:Y,$=r.renumerateIRIElements,L=$===void 0?!0:$;if(e&&"length"in e)for(var te=0,ne=0,he=e.length;ne<he;ne++)dy(e[ne],j,L,x,z,y,function(ie,xe){g(ie,xe),e&&"length"in e&&e.length===++te&&s(te)});else e?dy(e,j,L,x,z,y,function(ie,xe){g(ie,xe),s(1),e=null}):s(0)},_D=function(e){var n=(e==null?void 0:e.ownerDocument)||document;return n.defaultView||window},PD=function(e,n){for(var r in e)if(!(r in n))return!0;for(var i in n)if(e[i]!==n[i])return!0;return!1},RD=["afterInjection","beforeInjection","desc","evalScripts","fallback","httpRequestWithCredentials","loading","renumerateIRIElements","src","title","useRequestCache","wrapper"],Hf="http://www.w3.org/2000/svg",hy="http://www.w3.org/1999/xlink",Wp=function(t){ew(e,t);function e(){for(var r,i=arguments.length,s=new Array(i),u=0;u<i;u++)s[u]=arguments[u];return r=t.call.apply(t,[this].concat(s))||this,r.initialState={hasError:!1,isLoading:!0},r.state=r.initialState,r._isMounted=!1,r.reactWrapper=void 0,r.nonReactWrapper=void 0,r.refCallback=function(g){r.reactWrapper=g},r}var n=e.prototype;return n.renderSVG=function(){var i=this;if(this.reactWrapper instanceof _D(this.reactWrapper).Node){var s=this.props,u=s.desc,g=s.evalScripts,p=s.httpRequestWithCredentials,y=s.renumerateIRIElements,T=s.src,x=s.title,O=s.useRequestCache,j=this.props.onError,Y=this.props.beforeInjection,z=this.props.afterInjection,$=this.props.wrapper,L,te;$==="svg"?(L=document.createElementNS(Hf,$),L.setAttribute("xmlns",Hf),L.setAttribute("xmlns:xlink",hy),te=document.createElementNS(Hf,$)):(L=document.createElement($),te=document.createElement($)),L.appendChild(te),te.dataset.src=T,this.nonReactWrapper=this.reactWrapper.appendChild(L);var ne=function(b){if(i.removeSVG(),!i._isMounted){j(b);return}i.setState(function(){return{hasError:!0,isLoading:!1}},function(){j(b)})},he=function(b,Se){if(b){ne(b);return}i._isMounted&&i.setState(function(){return{isLoading:!1}},function(){try{z(Se)}catch(me){ne(me)}})},ie=function(b){if(b.setAttribute("role","img"),u){var Se=b.querySelector(":scope > desc");Se&&b.removeChild(Se);var me=document.createElement("desc");me.innerHTML=u,b.prepend(me)}if(x){var tt=b.querySelector(":scope > title");tt&&b.removeChild(tt);var vt=document.createElement("title");vt.innerHTML=x,b.prepend(vt)}try{Y(b)}catch(nt){ne(nt)}};kD(te,{afterEach:he,beforeEach:ie,cacheRequests:O,evalScripts:g,httpRequestWithCredentials:p,renumerateIRIElements:y})}},n.removeSVG=function(){var i;(i=this.nonReactWrapper)!=null&&i.parentNode&&(this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper),this.nonReactWrapper=null)},n.componentDidMount=function(){this._isMounted=!0,this.renderSVG()},n.componentDidUpdate=function(i){var s=this;PD(kc({},i),this.props)&&this.setState(function(){return s.initialState},function(){s.removeSVG(),s.renderSVG()})},n.componentWillUnmount=function(){this._isMounted=!1,this.removeSVG()},n.render=function(){var i=this.props;i.afterInjection,i.beforeInjection,i.desc,i.evalScripts;var s=i.fallback;i.httpRequestWithCredentials;var u=i.loading;i.renumerateIRIElements,i.src,i.title,i.useRequestCache;var g=i.wrapper,p=vp(i,RD),y=g;return kn.createElement(y,kc({},p,{ref:this.refCallback},g==="svg"?{xmlns:Hf,xmlnsXlink:hy}:{}),this.state.isLoading&&u&&kn.createElement(u,null),this.state.hasError&&s&&kn.createElement(s,null))},e}(kn.Component);Wp.defaultProps={afterInjection:function(){},beforeInjection:function(){},desc:"",evalScripts:"never",fallback:null,httpRequestWithCredentials:!1,loading:null,onError:function(){},renumerateIRIElements:!0,title:"",useRequestCache:!0,wrapper:"div"};Wp.propTypes={afterInjection:xr.func,beforeInjection:xr.func,desc:xr.string,evalScripts:xr.oneOf(["always","once","never"]),fallback:xr.oneOfType([xr.func,xr.object,xr.string]),httpRequestWithCredentials:xr.bool,loading:xr.oneOfType([xr.func,xr.object,xr.string]),onError:xr.func,renumerateIRIElements:xr.bool,src:xr.string.isRequired,title:xr.string,useRequestCache:xr.bool,wrapper:xr.oneOf(["div","span","svg"])};function AD(t){return ut.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16",...t,children:ut.jsx("path",{fill:"currenColor",d:"M4.427 7.427l3.396 3.396a.25.25 0 00.354 0l3.396-3.396A.25.25 0 0011.396 7H4.604a.25.25 0 00-.177.427z"})})}function OD(t){const{renderChildren:e,parentRef:n,onlyChild:r}=t,[i,s]=Pe.useState({top:0,left:0}),u=Pe.useRef(null),[g,p]=Pe.useState("auto");return Pe.useLayoutEffect(()=>{if(n.current&&u.current){const y=n.current.getBoundingClientRect(),T=u.current.getBoundingClientRect();let x=y.top;const O=y.left+y.width,j=T.height+(window.innerHeight-y.top)>window.innerHeight;j&&(console.log("overtop"),p(window.innerHeight-y.top-50)),y.top+T.height>window.innerHeight&&!j&&(x=y.top-T.height+y.height),s({top:x,left:O})}},[n,u]),r?e({maxHeight:g}):Ly.createPortal(ut.jsx("div",{ref:u,style:{position:"fixed",top:i.top,left:i.left,zIndex:1200},children:e({maxHeight:g})}),n.current)}function DD(t){const{children:e,title:n,hasTooltip:r}=t,i=Pe.useRef(),[s,u]=Pe.useState(!1),[g,p]=Pe.useState({top:0,left:0});return ut.jsxs("div",{className:"tooltip-item__wrapper",onMouseOver:()=>{if(u(!0),i.current){const y=i.current.getBoundingClientRect();p({top:y.top-20,left:y.left})}},onMouseLeave:()=>u(!1),ref:i,children:[ut.jsx("div",{children:e}),s&&r&&ut.jsx("div",{className:"tooltip-item__content",style:{position:"fixed",background:"#85858A",borderRadius:"4px",color:"#fff",padding:"4px 8px",top:g.top,left:g.left,zIndex:1400,fontSize:"10px",transition:"all 0.2s ease-in-out",animation:"fadeIn 0.2s ease-in-out",pointerEvents:"none"},children:n})]})}function rw(t,e){return e?t:void 0}function iw({item:t,level:e=0,...n}){var et,ft,ve,Me,Ve;const{isActive:r,isCollapsed:i,expanded:s,toggleExpand:u}=n,g=`level-${e}`,p=i?"collapsed":"expanded",y=r(t.id)?"active":"",T=(Ye,rt=g)=>`${Ye} ${rt} ${p} ${y}`,x=!!((et=t.children)!=null&&et.length),[O,j]=Pe.useState(!1),Y=Pe.useRef(),z=Pe.useRef(),$=(z==null?void 0:z.current)&&((ft=z==null?void 0:z.current)==null?void 0:ft.scrollWidth)>((ve=z==null?void 0:z.current)==null?void 0:ve.clientWidth),L=window.location.origin,te=t.path&&t.path.includes("http")?new URL(t.path):{origin:"",pathname:""},ne=window.location.pathname.split("/")[1],he=te.pathname.split("/")[1],ie=n.ssr||!L.includes("local")&&L!==te.origin||he!==ne,xe=x||e===0?"div":ie?"a":My.Link,b=t.path||"#",Se=e+1,me=x&&!(i&&Se>=2&&!O),tt=i||e===0?void 0:`${e}rem`,vt=()=>{j(!0)},nt=()=>{j(!1)};return ut.jsxs("div",{ref:Y,className:T("menu-item__wrapper"),onMouseOver:vt,onMouseOut:nt,children:[ut.jsx(DD,{hasTooltip:$||i&&e===1,children:ut.jsxs(xe,{to:b,href:b,className:T("menu-item__link"),style:{paddingLeft:tt,transition:"all 0.3s",color:r(t.id)?((Me=n.brandColors)==null?void 0:Me.primary400)||vo.primary400:void 0,backgroundColor:r(t.id)&&e===1?(Ve=n.brandColors)==null?void 0:Ve.primary200:void 0},onClick:Ye=>{x&&(Ye.preventDefault(),i||u(t.id))},children:[e!==0&&ut.jsx(ID,{cls:T,item:t}),ut.jsx("span",{className:T("menu-item__label"),ref:z,children:t.name}),x&&ut.jsx("div",{className:T("menu-item__icon-arrow__wrapper"),children:ut.jsx(AD,{className:T(`menu-item__icon-arrow__icon ${s(t.id)?"open":"close"}`)})})]}),title:t.name}),me&&ut.jsx(OD,{parentRef:Y,onlyChild:!i||i&&Se<2,renderChildren:({maxHeight:Ye})=>{var rt;return ut.jsx(dD.div,{className:T(`menu-item__dropdown ${s(t.id)?"menu-item__dropdown--open":"menu-item__dropdown--close"}`,`level-${Se}`),initial:{height:i||s(t.id)?"auto":0},animate:{height:i||s(t.id)?"auto":0},transition:{duration:.25},style:rw({maxHeight:Ye,overflowY:"auto",paddingRight:3},Ye!=="auto"&&!!Se),children:(rt=t.children)==null?void 0:rt.map(_e=>Pe.createElement(iw,{...n,key:_e.id,item:_e,level:Se}))})}})]})}function ID({item:t,cls:e}){var u,g;const[n,r]=Pe.useState(!t.icon),i=()=>{r(!0)},s=(u=t.icon)==null?void 0:u.endsWith(".svg");return ut.jsx("div",{className:e("menu-item__icon"),children:n?ut.jsx("div",{style:{width:24,height:24,backgroundColor:"#dadada",borderRadius:"5px",display:"flex",justifyContent:"center",alignItems:"center"},children:(g=t.name.trim().at(0))==null?void 0:g.toUpperCase()}):s?ut.jsx(Wp,{src:t.icon,beforeInjection:p=>{p.setAttribute("style","margin: 0 auto;"),p.querySelectorAll("path").forEach(T=>{T.hasAttribute("fill")&&T.setAttribute("fill","currentColor"),T.hasAttribute("stroke")&&T.setAttribute("stroke","currentColor")})}}):ut.jsx("img",{src:t.icon||"/",alt:" ",style:{height:24,maxHeight:24},onError:i})})}function MD(){return ut.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",fill:"currentColor",stroke:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",children:ut.jsx("path",{d:"M21 18v2H3v-2h18zM6.596 3.903L8.01 5.318 4.828 8.5 8.01 11.68l-1.414 1.415L2 8.5l4.596-4.597zM21 11v2h-9v-2h9zm0-7v2h-9V4h9z"})})}function LD(){return ut.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",fill:"currentColor",stroke:"currentColor",strokeWidth:"0",viewBox:"0 0 24 24",children:ut.jsx("path",{d:"M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"})})}function FD(t){return ut.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"20",fill:"none",viewBox:"0 0 18 20",...t,children:ut.jsx("path",{fill:"#E01B00",fillRule:"evenodd",d:"M.179 2.875A2.375 2.375 0 012.554.5h3.393a1.018 1.018 0 010 2.036H2.554a.34.34 0 00-.34.339v14.25c0 .187.152.34.34.34h3.393a1.018 1.018 0 110 2.035H2.554a2.375 2.375 0 01-2.375-2.375V2.875zm14.167 6.107h-7.72a1.018 1.018 0 000 2.036h7.72l-2.673 2.673a1.018 1.018 0 101.44 1.44l4.41-4.411a1.018 1.018 0 000-1.44l-4.41-4.41a1.018 1.018 0 10-1.44 1.439l2.673 2.673z",clipRule:"evenodd"})})}const jD=`.wrap-section{padding:0 8px;transition:all .3s}.wrap-section.collapsed{padding:0 4px}.side-bar{display:flex;flex-direction:column;max-width:18rem;height:calc(100vh - 64px);border-right:1px solid #ddd;background-color:#fafafa;transition:all .3s}.side-bar.expanded{width:17rem}.side-bar.collapsed{width:64px}.side-bar__wrap-btn-logout,.side-bar__btn-logout{margin:40px 0}.side-bar__logout-btn__text{margin-left:12px;font-size:.875rem;opacity:1}.side-bar__logout-btn__text.collapsed{opacity:0;transition:ease-in-out .2s;transition-delay:.15s}.side-bar__wrapper-toggle-btn{display:flex;flex-direction:row;justify-content:flex-end;transition:all .3s;margin-right:-8px;margin-top:40px}.side-bar__wrapper-toggle-btn.collapsed{justify-content:center;width:100%}.side-bar__toggle-btn{margin-top:-6px;color:#85858a}.side-bar__logout-btn{width:100%;text-align:left;display:flex;flex-direction:row;align-items:center;padding:8px 16px 8px 18.6665px;min-height:48px;border-radius:.375rem;overflow:hidden;transition:all .3s ease-in-out}.side-bar__logout-btn:hover{background-color:#919eab14}.side-bar__icon-logout{flex-shrink:0}.menu-item__wrapper{display:flex;flex-direction:column;position:relative;width:100%}.menu-item__link{display:flex;flex-direction:row;border-radius:.375rem;align-items:center;padding:.5rem;position:relative;height:48px;cursor:pointer;color:#85858a}.menu-item__link:hover{background-color:#919eab14}.menu-item__link.collapsed.level-1{padding-left:calc(.5rem + 7.665px)!important}.menu-item__link.active{background-color:#009d4f1a;color:inherit}.menu-item__link.active.level-2,.menu-item__link.active.level-3,.menu-item__link.active.level-4,.menu-item__link.active.level-5,.menu-item__link.active.level-6,.menu-item__link.active.level-7,.menu-item__link.active.level-8,.menu-item__link.active.level-9,.menu-item__link.active.level-10{background-color:inherit;color:inherit}.menu-item__link.active.level-2:hover,.menu-item__link.active.level-3:hover,.menu-item__link.active.level-4:hover,.menu-item__link.active.level-5:hover,.menu-item__link.active.level-6:hover,.menu-item__link.active.level-7:hover,.menu-item__link.active.level-8:hover,.menu-item__link.active.level-9:hover,.menu-item__link.active.level-10:hover{background-color:#919eab14}.menu-item__link.level-0{height:37px}.menu-item__link.menu-item__link.collapsed.level-0{padding:0;height:0;transition:all .15s}.menu-item__icon{width:1.5rem;height:1.5rem;flex-shrink:0;display:grid;place-items:center}.menu-item__icon.collapsed.level-1>*{margin:0 auto}.menu-item__label{font-size:.875rem;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;width:100%;flex-shrink:1;margin-left:12px;padding-right:12px;color:#292929;opacity:1}.menu-item__label.level-1.collapsed{text-overflow:unset}.menu-item__label.active{color:inherit}.menu-item__label.collapsed{margin-left:8px;font-size:.75rem;line-height:1rem}.menu-item__label.collapsed.level-0,.menu-item__label.collapsed.level-1{font-size:.875rem;opacity:0;transition-delay:.15s}.menu-item__label.level-0{color:#85858a;margin-left:0}.menu-item__icon-arrow__wrapper{display:grid;place-items:center;position:absolute;top:50%;transform:translateY(-50%);right:0}.menu-item__icon-arrow__wrapper.expanded{right:4px}.menu-item__icon-arrow__wrapper.level-0.collapsed{display:none}.menu-item__icon-arrow__icon{transition:all .3s!important;transform:rotate(-90deg)!important}.menu-item__icon-arrow__icon.active{color:inherit}.menu-item__icon-arrow__icon.expanded.open{transform:rotate(0)!important}.menu-item__dropdown.collapsed{background-color:#fafafa;border:1px solid #ddd;box-shadow:#0000001a 0 10px 15px -3px,#0000000d 0 4px 6px -2px;border-radius:4px;width:180px;max-width:180px;padding:4px;z-index:1200}.menu-item__dropdown::-webkit-scrollbar{width:4px}.menu-item__dropdown::-webkit-scrollbar-thumb{background-color:#9b9b9b99;border-radius:2px}.menu-item__dropdown,.menu-item__dropdown>*{margin-top:4px}.menu-item__dropdown.expanded.menu-item__dropdown--close{margin-top:0;transition:margin-top .3s}.menu-item__dropdown:first-of-type{margin-top:0}.menu-item__dropdown>*:first-child{margin-top:0}.menu-item__dropdown.collapsed .menu-item__link{height:40px}.menu-item__dropdown.collapsed .menu-item__link.level-1{height:48px}.menu-item__dropdown.collapsed.level-1{width:auto;max-width:unset;box-shadow:none;border:none;padding:0;background-color:unset}.menu-item__dropdown.expanded{overflow:hidden}.icon-btn{display:inline-flex;align-items:center;justify-content:center;padding:8px;border-radius:50%;background-color:transparent;transition:background-color .3s ease;border:none}.icon-btn:hover{background-color:var(--btn-bg-hover)}.simplebar-scrollbar:before{background-color:#0000002d}.side-bar__menu.collapsed .simplebar-track.simplebar-vertical{display:none}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}
|
|
135
|
-
`,py=localStorage.getItem("isCollapsed");function BD(t){const{baseUrl:e,menuPath:n}=t,r=My.useLocation(),[i,s]=Pe.useState([]),[u,g]=Pe.useState(py===null?!0:py==="true"),[p,y]=Pe.useState({}),T=Up(i),[x,O]=Pe.useState(window.location.href);Pe.useEffect(()=>{O(window.location.href)},[r]);const j=ow(T,x).filter(ie=>ie.parentKey!==0);console.log("matchPaths:",x,r,j);const Y=ie=>{y({...p,[ie]:!p[ie]})},z=()=>{g(!u),localStorage.setItem("isCollapsed",JSON.stringify(!u))};Pe.useLayoutEffect(()=>{(async()=>{var xe,b;try{const me=e+(n||"/global-menu-config/api/v1/menu-items/user"),{data:tt}=await Iy.get(me,{withCredentials:!0});let vt=tt.map(et=>({...et,parentKey:0}));vt=sw(vt),t.replacePath&&(vt=aw(vt,t.replacePath));const nt=HD(vt);y(nt),s(vt)}catch(Se){console.log(Se),gp(((b=(xe=Se.response)==null?void 0:xe.data)==null?void 0:b.errorMessage)||"Have error when get menu items")}})()},[e,n,t.replacePath]);const[$,L]=Pe.useState(!1),te=u?"collapsed":"expanded",ne=ie=>`${ie} ${te}`,he=Pe.useRef(null);return ut.jsxs("div",{className:ne("side-bar"),children:[ut.jsx("div",{className:ne("wrap-section side-bar__wrapper-toggle-btn"),children:ut.jsx("button",{className:"icon-btn side-bar__toggle-btn",onClick:z,children:u?ut.jsx(LD,{}):ut.jsx(MD,{})})}),ut.jsx(Db,{ref:he,className:ne("wrap-section side-bar__menu"),style:{marginTop:24,flex:1,overflow:"auto",height:"100%",overflowX:"hidden"},children:i.map(ie=>{const xe=b=>j.some(Se=>Se.id===b);return ut.jsx(iw,{item:ie,isActive:xe,isCollapsed:u,expanded:b=>p[b],toggleExpand:Y,replacePath:t.replacePath,ssr:t.ssr,brandColors:t.brandColors},ie.id)})}),ut.jsxs("div",{className:ne("wrap-section side-bar__wrap-btn-logout"),children:[ut.jsxs("button",{className:ne("side-bar__logout-btn"),onClick:()=>L(!0),children:[ut.jsx(FD,{className:ne("side-bar__icon-logout")}),ut.jsx("span",{className:ne("side-bar__logout-btn__text"),children:"Logout"})]}),ut.jsx(Fy,{isOpen:$,onClose:()=>L(!1),onConfirm:()=>t.logout?t.logout():qT(t.baseUrl)})]})]})}function Up(t){let e=[];for(const n of t)e.push(n),n.children&&(e=e.concat(Up(n.children)));return e}function ND(t,e){const n=new URL(t).searchParams,r=new URL(e).searchParams;return Array.from(r).filter(([i,s])=>s===n.get(i)).length}function ow(t,e){var p;const n=new URL(e);let r=t.filter(y=>y.path&&y.path.includes("http")).map(y=>({item:y,itemUrl:new URL(y.path),matchingParamsCount:ND(e,y.path)})).sort((y,T)=>{const x=new URL(y.itemUrl).searchParams,O=new URL(T.itemUrl).searchParams;return Array.from(x).length-Array.from(O).length}).filter(({itemUrl:y})=>n.origin===y.origin);const i=r.filter(({itemUrl:y})=>n.pathname===y.pathname),s=r.filter(({itemUrl:y})=>n.pathname.includes(y.pathname));r=i.length>0?i:s,r=r.sort((y,T)=>T.matchingParamsCount-y.matchingParamsCount);let u=r.length>0?(p=r.find(y=>y.item.parentKey))==null?void 0:p.item:null;console.log("matchingItems:",r);let g=[];for(;u;)g=[u,...g],u=t.find(y=>y.id===(u==null?void 0:u.parentKey))||null;return console.log("parents:",g),g}function aw(t,e){return t.map(n=>(n.
|
|
135
|
+
`,py=localStorage.getItem("isCollapsed");function BD(t){const{baseUrl:e,menuPath:n}=t,r=My.useLocation(),[i,s]=Pe.useState([]),[u,g]=Pe.useState(py===null?!0:py==="true"),[p,y]=Pe.useState({}),T=Up(i),[x,O]=Pe.useState(window.location.href);Pe.useEffect(()=>{O(window.location.href)},[r]);const j=ow(T,x).filter(ie=>ie.parentKey!==0);console.log("matchPaths:",x,r,j);const Y=ie=>{y({...p,[ie]:!p[ie]})},z=()=>{g(!u),localStorage.setItem("isCollapsed",JSON.stringify(!u))};Pe.useLayoutEffect(()=>{(async()=>{var xe,b;try{const me=e+(n||"/global-menu-config/api/v1/menu-items/user"),{data:tt}=await Iy.get(me,{withCredentials:!0});let vt=tt.map(et=>({...et,parentKey:0}));vt=sw(vt),t.replacePath&&(vt=aw(vt,t.replacePath));const nt=HD(vt);y(nt),s(vt)}catch(Se){console.log(Se),gp(((b=(xe=Se.response)==null?void 0:xe.data)==null?void 0:b.errorMessage)||"Have error when get menu items")}})()},[e,n,t.replacePath]);const[$,L]=Pe.useState(!1),te=u?"collapsed":"expanded",ne=ie=>`${ie} ${te}`,he=Pe.useRef(null);return ut.jsxs("div",{className:ne("side-bar"),children:[ut.jsx("div",{className:ne("wrap-section side-bar__wrapper-toggle-btn"),children:ut.jsx("button",{className:"icon-btn side-bar__toggle-btn",onClick:z,children:u?ut.jsx(LD,{}):ut.jsx(MD,{})})}),ut.jsx(Db,{ref:he,className:ne("wrap-section side-bar__menu"),style:{marginTop:24,flex:1,overflow:"auto",height:"100%",overflowX:"hidden"},children:i.map(ie=>{const xe=b=>j.some(Se=>Se.id===b);return ut.jsx(iw,{item:ie,isActive:xe,isCollapsed:u,expanded:b=>p[b],toggleExpand:Y,replacePath:t.replacePath,ssr:t.ssr,brandColors:t.brandColors},ie.id)})}),ut.jsxs("div",{className:ne("wrap-section side-bar__wrap-btn-logout"),children:[ut.jsxs("button",{className:ne("side-bar__logout-btn"),onClick:()=>L(!0),children:[ut.jsx(FD,{className:ne("side-bar__icon-logout")}),ut.jsx("span",{className:ne("side-bar__logout-btn__text"),children:"Logout"})]}),ut.jsx(Fy,{isOpen:$,onClose:()=>L(!1),onConfirm:()=>t.logout?t.logout():qT(t.baseUrl)})]})]})}function Up(t){let e=[];for(const n of t)e.push(n),n.children&&(e=e.concat(Up(n.children)));return e}function ND(t,e){const n=new URL(t).searchParams,r=new URL(e).searchParams;return Array.from(r).filter(([i,s])=>s===n.get(i)).length}function ow(t,e){var p;const n=new URL(e);let r=t.filter(y=>y.path&&y.path.includes("http")).map(y=>({item:y,itemUrl:new URL(y.path),matchingParamsCount:ND(e,y.path)})).sort((y,T)=>{const x=new URL(y.itemUrl).searchParams,O=new URL(T.itemUrl).searchParams;return Array.from(x).length-Array.from(O).length}).filter(({itemUrl:y})=>n.origin===y.origin);const i=r.filter(({itemUrl:y})=>n.pathname===y.pathname),s=r.filter(({itemUrl:y})=>n.pathname.includes(y.pathname));r=i.length>0?i:s,r=r.sort((y,T)=>T.matchingParamsCount-y.matchingParamsCount);let u=r.length>0?(p=r.find(y=>y.item.parentKey))==null?void 0:p.item:null;console.log("matchingItems:",r);let g=[];for(;u;)g=[u,...g],u=t.find(y=>y.id===(u==null?void 0:u.parentKey))||null;return console.log("parents:",g),g}function aw(t,e){return t.map(n=>{var r;return(r=n.children)!=null&&r.length?(n.path="",n.children=aw(n.children,e)):n.path=e(n.path),n})}function sw(t){return t.map(n=>n.path&&!n.path.includes("http")&&n.path.includes("/")?{...n,path:window.location.origin+n.path}:(n.children&&(n.children=sw(n.children)),n))}function HD(t){const e=Up(t),n=ow(e,window.location.href),r={};return n.forEach(i=>r[i.id]=!0),e.forEach(i=>{i.parentKey||(r[i.id]=!0)}),r}function WD(t){return ut.jsx(Sb,{styles:[tP,jD],style:{position:"sticky",zIndex:20},children:ut.jsx(BD,{...t})})}const UD={"page-container":"_page-container_1pwo1_1","page-main-content":"_page-main-content_1pwo1_8","page-title":"_page-title_1pwo1_19","text-base":"_text-base_1pwo1_26","mt-4":"_mt-4_1pwo1_33"};var ud={exports:{}};/**
|
|
136
136
|
* @license
|
|
137
137
|
* Lodash <https://lodash.com/>
|
|
138
138
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|