@hari_digitus/sms-ui-library 7.0.5 → 9.0.0
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/Readme.md +78 -0
- package/dist/SideNavBar.cjs.js +10 -10
- package/dist/SideNavBar.es.js +315 -312
- package/dist/types/icons/icon.d.ts +6 -0
- package/package.json +2 -2
package/Readme.md
CHANGED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { fetchUserRole } from "../../service/RDRService";
|
|
3
|
+
import { Amphenol, RdrContainer, ReportIcon, SupplierIcon } from "../../icons";
|
|
4
|
+
import { Role } from "../../constants/Enum";
|
|
5
|
+
import { SideNavbar, SidebarProvider } from "@hari_digitus/sms-ui-library";
|
|
6
|
+
|
|
7
|
+
function App() {
|
|
8
|
+
const [userData, setUserData] = useState({
|
|
9
|
+
email: "",
|
|
10
|
+
role: 0,
|
|
11
|
+
roleName: "",
|
|
12
|
+
} as any);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const getRole = async () => {
|
|
16
|
+
const data = await fetchUserRole();
|
|
17
|
+
setUserData({
|
|
18
|
+
role: data.role,
|
|
19
|
+
email: data.user.emailAddress,
|
|
20
|
+
roleName: data.roleName,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
getRole();
|
|
25
|
+
}, []);
|
|
26
|
+
|
|
27
|
+
const sidebarConfig = {
|
|
28
|
+
brandName: "Amphenol",
|
|
29
|
+
brandSubtitle: "COMMUNICATION SOLUTIONS",
|
|
30
|
+
logo: <Amphenol />,
|
|
31
|
+
|
|
32
|
+
user: userData,
|
|
33
|
+
|
|
34
|
+
createButtonLabel: "Create RDR",
|
|
35
|
+
createButtonPath: "/rdr-details",
|
|
36
|
+
|
|
37
|
+
navItems: [
|
|
38
|
+
{
|
|
39
|
+
name: "RDR Management",
|
|
40
|
+
path: "/rdr-management-list",
|
|
41
|
+
section: "OPERATIONS",
|
|
42
|
+
roles: [Role.RDRBUYER, Role.WAREHOUSETEAM],
|
|
43
|
+
icon: <RdrContainer />,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "Reports",
|
|
47
|
+
path: "/rdr-reports",
|
|
48
|
+
section: "REPORTS",
|
|
49
|
+
roles: [Role.RDRBUYER, Role.WAREHOUSETEAM],
|
|
50
|
+
icon: <ReportIcon />,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "Suppliers & FF",
|
|
54
|
+
path: "/rdr-supplier-ff-list",
|
|
55
|
+
section: "ADMIN",
|
|
56
|
+
roles: [Role.WAREHOUSETEAM],
|
|
57
|
+
icon: <SupplierIcon />,
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
|
|
61
|
+
onNavigate: (path: string) => {
|
|
62
|
+
window.history.pushState({}, "", path);
|
|
63
|
+
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
onSignOut: () => {
|
|
67
|
+
window.location.href = "/c/portal/logout";
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<SidebarProvider>
|
|
73
|
+
<SideNavbar config={sidebarConfig} />
|
|
74
|
+
</SidebarProvider>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default App;
|
package/dist/SideNavBar.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("react");var ce={exports:{}},Q={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var Fe;function pr(){if(Fe)return Q;Fe=1;var S
|
|
9
|
+
*/var Fe;function pr(){if(Fe)return Q;Fe=1;var w=S,P=Symbol.for("react.element"),h=Symbol.for("react.fragment"),_=Object.prototype.hasOwnProperty,k=w.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,N={key:!0,ref:!0,__self:!0,__source:!0};function I(m,d,D){var g,j={},O=null,Y=null;D!==void 0&&(O=""+D),d.key!==void 0&&(O=""+d.key),d.ref!==void 0&&(Y=d.ref);for(g in d)_.call(d,g)&&!N.hasOwnProperty(g)&&(j[g]=d[g]);if(m&&m.defaultProps)for(g in d=m.defaultProps,d)j[g]===void 0&&(j[g]=d[g]);return{$$typeof:P,type:m,key:O,ref:Y,props:j,_owner:k.current}}return Q.Fragment=h,Q.jsx=I,Q.jsxs=I,Q}var ee={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var Me;function vr(){return Me||(Me=1,process.env.NODE_ENV!=="production"&&(function(){var S
|
|
18
|
-
`+he+e}}var me=!1,se;{var Be=typeof WeakMap=="function"?WeakMap:Map;se=new Be}function
|
|
19
|
-
`),
|
|
20
|
-
`),c=i.length-1,f=
|
|
21
|
-
`+i[c].replace(" at new "," at ");return e.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",e.displayName)),typeof e=="function"&&se.set(e,R),R}while(c>=1&&f>=0);break}}}finally{me=!1,X.current=u,ve(),Error.prepareStackTrace=s}var V=e?e.displayName||e.name:"",W=V?oe(V):"";return typeof e=="function"&&se.set(e,W),W}function Ue(e,r,
|
|
17
|
+
*/var Me;function vr(){return Me||(Me=1,process.env.NODE_ENV!=="production"&&(function(){var w=S,P=Symbol.for("react.element"),h=Symbol.for("react.portal"),_=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),I=Symbol.for("react.provider"),m=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),Y=Symbol.for("react.offscreen"),b=Symbol.iterator,re="@@iterator";function B(e){if(e===null||typeof e!="object")return null;var r=b&&e[b]||e[re];return typeof r=="function"?r:null}var F=w.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),a=1;a<r;a++)n[a-1]=arguments[a];fe("error",e,n)}}function fe(e,r,n){{var a=F.ReactDebugCurrentFrame,s=a.getStackAddendum();s!==""&&(r+="%s",n=n.concat([s]));var u=n.map(function(o){return String(o)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var de=!1,ne=!1,pe=!1,te=!1,ae=!1,M;M=Symbol.for("react.module.reference");function q(e){return!!(typeof e=="string"||typeof e=="function"||e===_||e===N||ae||e===k||e===D||e===g||te||e===Y||de||ne||pe||typeof e=="object"&&e!==null&&(e.$$typeof===O||e.$$typeof===j||e.$$typeof===I||e.$$typeof===m||e.$$typeof===d||e.$$typeof===M||e.getModuleId!==void 0))}function ie(e,r,n){var a=e.displayName;if(a)return a;var s=r.displayName||r.name||"";return s!==""?n+"("+s+")":n}function J(e){return e.displayName||"Context"}function T(e){if(e==null)return null;if(typeof e.tag=="number"&&p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case _:return"Fragment";case h:return"Portal";case N:return"Profiler";case k:return"StrictMode";case D:return"Suspense";case g:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case m:var r=e;return J(r)+".Consumer";case I:var n=e;return J(n._context)+".Provider";case d:return ie(e,e.render,"ForwardRef");case j:var a=e.displayName||null;return a!==null?a:T(e.type)||"Memo";case O:{var s=e,u=s._payload,o=s._init;try{return T(o(u))}catch{return null}}}return null}var A=Object.assign,$=0,v,C,L,l,H,K,G;function z(){}z.__reactDisabledLog=!0;function x(){{if($===0){v=console.log,C=console.info,L=console.warn,l=console.error,H=console.group,K=console.groupCollapsed,G=console.groupEnd;var e={configurable:!0,enumerable:!0,value:z,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}$++}}function ve(){{if($--,$===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},e,{value:v}),info:A({},e,{value:C}),warn:A({},e,{value:L}),error:A({},e,{value:l}),group:A({},e,{value:H}),groupCollapsed:A({},e,{value:K}),groupEnd:A({},e,{value:G})})}$<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var X=F.ReactCurrentDispatcher,he;function oe(e,r,n){{if(he===void 0)try{throw Error()}catch(s){var a=s.stack.trim().match(/\n( *(at )?)/);he=a&&a[1]||""}return`
|
|
18
|
+
`+he+e}}var me=!1,se;{var Be=typeof WeakMap=="function"?WeakMap:Map;se=new Be}function je(e,r){if(!e||me)return"";{var n=se.get(e);if(n!==void 0)return n}var a;me=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=X.current,X.current=null,x();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(E){a=E}Reflect.construct(e,[],o)}else{try{o.call()}catch(E){a=E}e.call(o.prototype)}}else{try{throw Error()}catch(E){a=E}e()}}catch(E){if(E&&a&&typeof E.stack=="string"){for(var i=E.stack.split(`
|
|
19
|
+
`),y=a.stack.split(`
|
|
20
|
+
`),c=i.length-1,f=y.length-1;c>=1&&f>=0&&i[c]!==y[f];)f--;for(;c>=1&&f>=0;c--,f--)if(i[c]!==y[f]){if(c!==1||f!==1)do if(c--,f--,f<0||i[c]!==y[f]){var R=`
|
|
21
|
+
`+i[c].replace(" at new "," at ");return e.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",e.displayName)),typeof e=="function"&&se.set(e,R),R}while(c>=1&&f>=0);break}}}finally{me=!1,X.current=u,ve(),Error.prepareStackTrace=s}var V=e?e.displayName||e.name:"",W=V?oe(V):"";return typeof e=="function"&&se.set(e,W),W}function Ue(e,r,n){return je(e,!1)}function Ve(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function le(e,r,n){if(e==null)return"";if(typeof e=="function")return je(e,Ve(e));if(typeof e=="string")return oe(e);switch(e){case D:return oe("Suspense");case g:return oe("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return Ue(e.render);case j:return le(e.type,r,n);case O:{var a=e,s=a._payload,u=a._init;try{return le(u(s),r,n)}catch{}}}return""}var Z=Object.prototype.hasOwnProperty,Re={},_e=F.ReactDebugCurrentFrame;function ue(e){if(e){var r=e._owner,n=le(e.type,e._source,r?r.type:null);_e.setExtraStackFrame(n)}else _e.setExtraStackFrame(null)}function qe(e,r,n,a,s){{var u=Function.call.bind(Z);for(var o in e)if(u(e,o)){var i=void 0;try{if(typeof e[o]!="function"){var y=Error((a||"React class")+": "+n+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw y.name="Invariant Violation",y}i=e[o](r,o,a,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(c){i=c}i&&!(i instanceof Error)&&(ue(s),p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",a||"React class",n,o,typeof i),ue(null)),i instanceof Error&&!(i.message in Re)&&(Re[i.message]=!0,ue(s),p("Failed %s type: %s",n,i.message),ue(null))}}}var Je=Array.isArray;function ge(e){return Je(e)}function He(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function Ke(e){try{return Ce(e),!1}catch{return!0}}function Ce(e){return""+e}function Se(e){if(Ke(e))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",He(e)),Ce(e)}var we=F.ReactCurrentOwner,Ge={key:!0,ref:!0,__self:!0,__source:!0},Oe,Te;function ze(e){if(Z.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Xe(e){if(Z.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Ze(e,r){typeof e.ref=="string"&&we.current}function Qe(e,r){{var n=function(){Oe||(Oe=!0,p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function er(e,r){{var n=function(){Te||(Te=!0,p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var rr=function(e,r,n,a,s,u,o){var i={$$typeof:P,type:e,key:r,ref:n,props:o,_owner:u};return i._store={},Object.defineProperty(i._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(i,"_self",{configurable:!1,enumerable:!1,writable:!1,value:a}),Object.defineProperty(i,"_source",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i};function nr(e,r,n,a,s){{var u,o={},i=null,y=null;n!==void 0&&(Se(n),i=""+n),Xe(r)&&(Se(r.key),i=""+r.key),ze(r)&&(y=r.ref,Ze(r,s));for(u in r)Z.call(r,u)&&!Ge.hasOwnProperty(u)&&(o[u]=r[u]);if(e&&e.defaultProps){var c=e.defaultProps;for(u in c)o[u]===void 0&&(o[u]=c[u])}if(i||y){var f=typeof e=="function"?e.displayName||e.name||"Unknown":e;i&&Qe(o,f),y&&er(o,f)}return rr(e,i,y,s,a,we.current,o)}}var be=F.ReactCurrentOwner,Pe=F.ReactDebugCurrentFrame;function U(e){if(e){var r=e._owner,n=le(e.type,e._source,r?r.type:null);Pe.setExtraStackFrame(n)}else Pe.setExtraStackFrame(null)}var xe;xe=!1;function ye(e){return typeof e=="object"&&e!==null&&e.$$typeof===P}function ke(){{if(be.current){var e=T(be.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function tr(e){return""}var Ne={};function ar(e){{var r=ke();if(!r){var
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function tr(e){return""}var Ne={};function ar(e){{var r=ke();if(!r){var n=typeof e=="string"?e:e.displayName||e.name;n&&(r=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+
|
|
25
|
+
Check the top-level render call using <`+n+">.")}return r}}function Ie(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=ar(r);if(Ne[n])return;Ne[n]=!0;var a="";e&&e._owner&&e._owner!==be.current&&(a=" It was passed a child from "+T(e._owner.type)+"."),U(e),p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,a),U(null)}}function De(e,r){{if(typeof e!="object")return;if(ge(e))for(var n=0;n<e.length;n++){var a=e[n];ye(a)&&Ie(a,r)}else if(ye(e))e._store&&(e._store.validated=!0);else if(e){var s=B(e);if(typeof s=="function"&&s!==e.entries)for(var u=s.call(e),o;!(o=u.next()).done;)ye(o.value)&&Ie(o.value,r)}}}function ir(e){{var r=e.type;if(r==null||typeof r=="string")return;var n;if(typeof r=="function")n=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===d||r.$$typeof===j))n=r.propTypes;else return;if(n){var a=T(r);qe(n,e.props,"prop",a,e)}else if(r.PropTypes!==void 0&&!xe){xe=!0;var s=T(r);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",s||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function or(e){{for(var r=Object.keys(e.props),n=0;n<r.length;n++){var a=r[n];if(a!=="children"&&a!=="key"){U(e),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",a),U(null);break}}e.ref!==null&&(U(e),p("Invalid attribute `ref` supplied to `React.Fragment`."),U(null))}}var Ae={};function Le(e,r,n,a,s,u){{var o=q(e);if(!o){var i="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(i+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var y=tr();y?i+=y:i+=ke();var c;e===null?c="null":ge(e)?c="array":e!==void 0&&e.$$typeof===P?(c="<"+(T(e.type)||"Unknown")+" />",i=" Did you accidentally export a JSX literal instead of a component?"):c=typeof e,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",c,i)}var f=nr(e,r,n,s,u);if(f==null)return f;if(o){var R=r.children;if(R!==void 0)if(a)if(ge(R)){for(var V=0;V<R.length;V++)De(R[V],e);Object.freeze&&Object.freeze(R)}else p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else De(R,e)}if(Z.call(r,"key")){var W=T(e),E=Object.keys(r).filter(function(dr){return dr!=="key"}),Ee=E.length>0?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}";if(!Ae[W+Ee]){var fr=E.length>0?"{"+E.join(": ..., ")+": ...}":"{}";p(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,
|
|
30
|
+
<%s key={someKey} {...props} />`,Ee,W,fr,W),Ae[W+Ee]=!0}}return e===_?or(f):ir(f),f}}function sr(e,r,n){return Le(e,r,n,!0)}function lr(e,r,n){return Le(e,r,n,!1)}var ur=lr,cr=sr;ee.Fragment=_,ee.jsx=ur,ee.jsxs=cr})()),ee}var $e;function hr(){return $e||($e=1,process.env.NODE_ENV==="production"?ce.exports=pr():ce.exports=vr()),ce.exports}var t=hr();const We=S.createContext(null),mr=({children:w})=>{const[P,h]=S.useState(!0),[_,k]=S.useState(null),N=()=>{h(m=>!m),k(null)},I=m=>{k(d=>d===m?null:m)};return t.jsx(We.Provider,{value:{isExpanded:P,toggleSidebar:N,openSubmenu:_,toggleSubmenu:I},children:w})},Ye=()=>{const w=S.useContext(We);if(!w)throw new Error("useSidebar must be used inside <SidebarProvider>");return w},gr="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M20.3334%207C20.3334%207.55228%2020.0072%208%2019.6048%208L4.06194%208C3.65957%208%203.33337%207.55228%203.33337%207C3.33337%206.44772%203.65957%206%204.06194%206L19.6048%206C20.0072%206%2020.3334%206.44772%2020.3334%207Z'%20fill='white'%20/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M20.3334%2012C20.3334%2012.5523%2020.0072%2013%2019.6048%2013L4.06194%2013C3.65957%2013%203.33337%2012.5523%203.33337%2012C3.33337%2011.4477%203.65957%2011%204.06194%2011L19.6048%2011C20.0072%2011%2020.3334%2011.4477%2020.3334%2012Z'%20fill='white'%20/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M20.3334%2017C20.3334%2017.5523%2020.0072%2018%2019.6048%2018L4.06194%2018C3.65957%2018%203.33337%2017.5523%203.33337%2017C3.33337%2016.4477%203.65957%2016%204.06194%2016L19.6048%2016C20.0072%2016%2020.3334%2016.4477%2020.3334%2017Z'%20fill='white'%20/%3e%3c/svg%3e",br="data:image/svg+xml,%3csvg%20width='18'%20height='18'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20strokeWidth='2'%20strokeLinecap='round'%20strokeLinejoin='round'%20%3e%3ccircle%20cx='12'%20cy='12'%20r='10'%20/%3e%3cpath%20d='M9.09%209a3%203%200%200%201%205.83%201c0%202-3%203-3%203'%20/%3e%3cline%20x1='12'%20y1='17'%20x2='12.01'%20y2='17'%20/%3e%3c/svg%3e",xr="data:image/svg+xml,",yr="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20strokeWidth='2.5'%20strokeLinecap='round'%20strokeLinejoin='round'%20%3e%3cline%20x1='12'%20y1='5'%20x2='12'%20y2='19'%20/%3e%3cline%20x1='5'%20y1='12'%20x2='19'%20y2='12'%20/%3e%3c/svg%3e",Er="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20strokeWidth='2'%20strokeLinecap='round'%20strokeLinejoin='round'%20%3e%3cpath%20d='M9%2021H5a2%202%200%200%201-2-2V5a2%202%200%200%201%202-2h4'%20/%3e%3cpolyline%20points='16%2017%2021%2012%2016%207'%20/%3e%3cline%20x1='21'%20y1='12'%20x2='9'%20y2='12'%20/%3e%3c/svg%3e",jr=({config:w})=>{const{navItems:P,user:h,createButtonRoles:_,createButtonLabel:k="Create",createButtonPath:N,brandName:I="Amphenol",brandSubtitle:m="COMMUNICATION SOLUTIONS",logo:d,helpLabel:D="Help Center",helpIcon:g,onSignOut:j,onNavigate:O,className:Y=""}=w,{isExpanded:b,toggleSidebar:re,openSubmenu:B,toggleSubmenu:F}=Ye(),[p,fe]=S.useState(window.location.pathname),[de,ne]=S.useState(!1),[pe,te]=S.useState(!1),[ae,M]=S.useState(null);S.useEffect(()=>{const v=()=>fe(window.location.pathname);return window.addEventListener("popstate",v),()=>window.removeEventListener("popstate",v)},[]);const q=(v,C)=>{v.preventDefault(),C&&(O?O(C):(window.history.pushState({},"",C),window.dispatchEvent(new PopStateEvent("popstate"))))},ie=()=>h.email?h.email.split("@")[0]:"User",J=()=>h.email?h.email.charAt(0).toUpperCase():"U",T=()=>{j?j():window.location.href="/c/portal/logout"},A=!_||_.includes(h.role),$=P.reduce((v,C)=>{const L=C.section||"GENERAL";return v[L]||(v[L]=[]),v[L].push(C),v},{});return t.jsxs("aside",{style:{backgroundColor:"#0f172a"},className:`rdr-sidebar ${b?"expanded":"collapsed"} ${Y}`,children:[t.jsxs("div",{className:"sidebar-header ",style:{paddingTop:"10px"},children:[t.jsxs("div",{className:"logo-section",onClick:re,children:[t.jsx("span",{className:"logo-icon ",style:{color:"var(--sidebar-accent)",marginTop:"15px"},children:d??t.jsx(xr,{})}),b&&t.jsxs("div",{className:"brand-text",children:[t.jsx("h2",{children:I}),m&&t.jsx("span",{children:m})]})]}),b&&t.jsx("button",{className:"menu-toggle",onClick:re,"aria-label":"Collapse sidebar",children:t.jsx(gr,{})})]}),A&&N&&t.jsx("div",{className:"sidebar-actions",children:t.jsxs("button",{className:"sidebar-create-btn",style:{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",width:b?"100%":"44px",height:"44px",padding:b?"0 16px":"0",borderRadius:"10px",border:"none",outline:"none",boxShadow:"none",cursor:"pointer",fontSize:"14px",fontWeight:600,color:"#fff",background:pe?"#149B6E":"#18B885",transition:"background-color 0.2s ease"},onMouseEnter:()=>te(!0),onMouseLeave:()=>te(!1),onClick:v=>q(v,N),children:[t.jsx(yr,{}),b&&t.jsx("span",{children:k})]})}),t.jsx("div",{className:"sidebar-nav",children:Object.entries($).map(([v,C])=>{const L=C.filter(l=>!l.roles||l.roles.includes(h.role));return L.length?t.jsxs("div",{className:"nav-section",style:{listStyleType:"none"},children:[b&&t.jsx("h4",{className:"section-title",children:v}),t.jsx("ul",{className:"nav-items",children:L.map(l=>{var G,z;const H=(G=l.subItems)==null?void 0:G.some(x=>x.path&&p.includes(x.path)),K=l.path?p===l.path:!1;return t.jsx("li",{children:(z=l.subItems)!=null&&z.length?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`nav-item ${B===l.name||H?"active":""}`,"data-label":l.name,onClick:()=>F(l.name),onMouseEnter:()=>M(l.name),onMouseLeave:()=>M(null),style:B===l.name||H||ae===l.name?{backgroundColor:"#10B981",border:"1px solid #10B981",borderRadius:"8px"}:{},children:[t.jsx("span",{className:"nav-icon",children:l.icon}),b&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"nav-text",children:l.name}),t.jsx("span",{className:"submenu-arrow",children:B===l.name?"−":"+"})]})]}),b&&B===l.name&&t.jsx("ul",{className:"submenu",children:l.subItems.map(x=>{const ve=x.path?p===x.path:!1;return t.jsx("li",{children:t.jsxs("a",{href:x.path||"/",onClick:X=>q(X,x.path),className:`submenu-item ${ve?"active-sub":""}`,children:[x.icon&&t.jsx("span",{className:"submenu-icon",children:x.icon}),t.jsx("span",{children:x.name})]})},x.name)})})]}):t.jsxs("a",{href:l.path||"/","data-label":l.name,onClick:x=>q(x,l.path),style:K||ae===l.name?{backgroundColor:"#10B981",border:"none",borderRadius:"8px",outline:"1px solid #10B981",outlineOffset:"0px"}:{border:"none"},onMouseEnter:()=>M(l.name),onMouseLeave:()=>M(null),className:`nav-item ${K?"active":""}`,children:[t.jsx("span",{className:"nav-icon",children:l.icon}),b&&t.jsx("span",{className:"nav-text",children:l.name})]})},l.name)})})]},v):null})}),t.jsxs("div",{className:"sidebar-footer",children:[t.jsxs("div",{className:"footer-link","data-label":D,children:[t.jsx("span",{children:g??t.jsx(br,{})}),b&&t.jsx("span",{children:D})]}),t.jsxs("div",{className:"user-profile-wrapper",children:[t.jsxs("div",{className:"user-profile",onClick:()=>ne(v=>!v),children:[t.jsx("div",{className:"avatar",children:J()}),b&&t.jsxs("div",{className:"user-info",children:[t.jsx("div",{className:"user-name",children:ie()}),t.jsx("div",{className:"user-role",children:h.roleName})]})]}),de&&t.jsxs("div",{className:"profile-popup",children:[t.jsx("button",{className:"popup-close",onClick:()=>ne(!1),"aria-label":"Close",children:"✕"}),t.jsxs("div",{className:"popup-header",children:[t.jsx("div",{className:"popup-avatar",children:J()}),t.jsxs("div",{className:"popup-user-details",children:[t.jsx("div",{className:"popup-name",children:ie()}),t.jsx("div",{className:"popup-role",children:h.roleName}),t.jsx("div",{className:"popup-email",children:h.email})]})]}),t.jsx("div",{className:"popup-divider"}),t.jsxs("button",{className:"signout-btn",onClick:T,children:[t.jsx(Er,{}),t.jsx("span",{children:"Sign Out"})]})]})]})]})]})};exports.SideNavbar=jr;exports.SidebarProvider=mr;exports.useSidebar=Ye;
|