@instincthub/react-ui 0.3.0 → 0.3.1
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/src/assets/css/navbar/sidenav.css +293 -0
- package/dist/src/components/forms/uploads/FileUploader.cjs +1 -1
- package/dist/src/components/forms/uploads/FileUploader.js +1 -1
- package/dist/src/components/forms/uploads/IhubFileUploader.cjs +1 -1
- package/dist/src/components/forms/uploads/IhubFileUploader.js +1 -1
- package/dist/src/components/forms/uploads/uploadedFileUrl.cjs +2 -0
- package/dist/src/components/forms/uploads/uploadedFileUrl.cjs.map +1 -0
- package/dist/src/components/forms/uploads/uploadedFileUrl.js +2 -0
- package/dist/src/components/forms/uploads/uploadedFileUrl.js.map +1 -0
- package/dist/src/components/navbar/SideNavSearch.cjs +2 -0
- package/dist/src/components/navbar/SideNavSearch.cjs.map +1 -0
- package/dist/src/components/navbar/SideNavSearch.js +2 -0
- package/dist/src/components/navbar/SideNavSearch.js.map +1 -0
- package/dist/src/components/navbar/SideNavbar.cjs +1 -1
- package/dist/src/components/navbar/SideNavbar.js +1 -1
- package/dist/src/components/navbar/sideNavMatch.cjs +2 -0
- package/dist/src/components/navbar/sideNavMatch.cjs.map +1 -0
- package/dist/src/components/navbar/sideNavMatch.js +2 -0
- package/dist/src/components/navbar/sideNavMatch.js.map +1 -0
- package/dist/src/types/components/forms/uploads/uploadedFileUrl.d.ts +17 -0
- package/dist/src/types/components/navbar/SideNavSearch.d.ts +27 -0
- package/dist/src/types/components/navbar/SideNavbar.d.ts +1 -1
- package/dist/src/types/components/navbar/sideNavMatch.d.ts +65 -0
- package/dist/src/types/types/navbar.d.ts +44 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),i=require("react/jsx-runtime"),n=require("react"),s=require("next/link"),a=require("next/image"),r=require("@mui/icons-material/ChevronLeft"),t=require("@mui/icons-material/ChevronRight"),c=require("../auth/ClientOnly.cjs");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../lib/helpFunction.cjs"),require("@mui/icons-material/Visibility"),require("@mui/icons-material/VisibilityOff"),require("../../../node_modules/.pnpm/next-auth@5.0.0-beta.30_next@15.5.26_@babel_core@7.28.5_react-dom@19.3.0_react@19.3.0__react@19.3.0__react@19.3.0/node_modules/next-auth/react.cjs"),require("next/navigation"),require("../lib/utils.cjs"),require("../lib/phoneUtils.cjs"),require("../ui/OrDivider.cjs"),require("../forms/SubmitButton.cjs"),require("react-redux"),require("../lib/redux/store.cjs"),require("../lib/redux/slices/courseSlice/courseFilterSubject.cjs"),require("../lib/redux/slices/courseSlice/courseFilterLevel.cjs"),require("../lib/redux/slices/courseSlice/courseFilterDuration.cjs"),require("../lib/redux/slices/courseSlice/courseSearch.cjs"),require("../lib/redux/slices/courseSlice/stepQuestions.cjs"),require("../lib/redux/slices/courseSlice/stepContent.cjs"),require("../lib/redux/slices/courseSlice/courseDetails.cjs"),require("../lib/redux/slices/courseSlice/videoTimestamp.cjs"),require("../lib/redux/slices/courseSlice/videoEndCountdown.cjs"),require("../lib/redux/slices/courseSlice/videoTimestampObject.cjs"),require("../lib/redux/slices/courseSlice/courseModules.cjs"),require("../lib/redux/slices/courseSlice/courseOverview.cjs"),require("../lib/redux/slices/courseSlice/selectedCourses.cjs"),require("../lib/redux/slices/navigationSlice/appToggle.cjs"),require("../lib/redux/slices/navigationSlice/toggleCreateCourse.cjs"),require("../lib/redux/slices/navigationSlice/toggleCreateCohort.cjs"),require("../lib/redux/slices/navigationSlice/confirmDelete.cjs"),require("../lib/redux/slices/navigationSlice/IPAdress.cjs"),require("../lib/redux/slices/navigationSlice/settingsToggle.cjs"),require("../lib/redux/slices/navigationSlice/userLocation.cjs"),require("../lib/redux/slices/navigationSlice/searchValue.cjs"),require("../lib/redux/slices/navigationSlice/currentPromo.cjs"),require("../lib/redux/slices/navigationSlice/courseNextStep.cjs"),require("../lib/redux/slices/channelSlice/activeChannel.cjs"),require("../lib/redux/slices/channelSlice/channelDetails.cjs"),require("../lib/redux/slices/channelSlice/instructorChannelList.cjs"),require("../lib/redux/slices/channelSlice/channelHandle.cjs"),require("../lib/redux/slices/generics/objectSlice.cjs"),require("../lib/redux/slices/generics/arraySlice.cjs"),require("../lib/redux/slices/messageSlice/feedbackToggle.cjs"),require("../lib/redux/slices/messageSlice/statusMessageState.cjs"),require("../lib/redux/slices/utilsSlice/screenSize.cjs"),require("../lib/redux/slices/authSlice/channelCallbackUrl.cjs"),require("../lib/redux/slices/authSlice/unsplashObject.cjs"),require("@mui/icons-material/DoneOutlined"),require("@mui/icons-material/ContentCopyOutlined"),require("../status/MultiPurposeModal.cjs");var u=l(n),d=l(s),o=l(a),h=l(r),v=l(t);exports.default=function(s){var a,r=s.items,t=s.defaultExpanded,l=void 0===t||t,b=s.isExpanded,f=s.onExpandedChange,m=s.position,x=void 0===m?"left":m,j=s.variant,p=void 0===j?"default":j,g=s.expandedWidth,S=void 0===g?240:g,q=s.collapsedWidth,N=void 0===q?64:q,w=s.animation,y=void 0===w?"slide":w,C=s.logo,k=s.footer,E=s.className,D=void 0===E?"":E,A=s.darkMode,_=void 0!==A&&A,T=s.positioning,L=s.resizable,M=void 0!==L&&L,z=s.maxWidth,O=void 0===z?400:z,F=s.minWidth,I=void 0===F?180:F,U=s.onNavigate,W=s.autoCollapseOnMobile,B=void 0===W||W,P=s.showBackdrop,K=void 0===P||P,R=s.onBackdropClick,X=s.enableTouchGestures,H=void 0===X||X,V=s.persistState,G=void 0===V||V,Q=s.persistStateKey,J=void 0===Q?"ihub-sidenav-expanded":Q,Y=s.lazyRender,Z=void 0!==Y&&Y,$=s.renderItem,ee=s.tooltip,ie=s.toggleShortcut,ne=s.contentContainerClassName,se=void 0===ne?"":ne,ae=s.children,re=void 0!==b,te=n.useState(l),ce=e.slicedToArray(te,2),le=ce[0],ue=ce[1];n.useEffect(function(){if(re)ue(b);else if(G&&"undefined"!=typeof window){var e=localStorage.getItem(J);null!==e&&ue("true"===e)}},[re,b,G,J]),n.useEffect(function(){re&&ue(b)},[re,b]);var de=function(){return re?b:le},oe=function(e){re||(ue(e),G&&"undefined"!=typeof window&&localStorage.setItem(J,String(e))),null==f||f(e)},he=function(){return oe(!de())},ve=n.useState(null),be=e.slicedToArray(ve,2),fe=be[0],me=be[1],xe=n.useState(new Set),je=e.slicedToArray(xe,2),pe=je[0],ge=je[1];n.useEffect(function(){var e=new Set,i=function(n){var s=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n.forEach(function(n){if("group"===n.type){var a=n;(a.defaultExpanded||s||a.children.some(function(e){return"isActive"in e&&e.isActive||"group"===e.type&&e.defaultExpanded}))&&(e.add(n.id),i(a.children,!0))}})};i(r),ge(e)},[r]),n.useEffect(function(){var i=function(n){var s,a=e.createForOfIteratorHelper(n);try{var r,t=function(){var n=s.value;if("isActive"in n&&n.isActive)return{v:n.id};if("group"===n.type){var a=i(n.children);if(a)return ge(function(i){return new Set([].concat(e.toConsumableArray(i),[n.id]))}),{v:a}}};for(a.s();!(s=a.n()).done;)if(r=t())return r.v}catch(e){a.e(e)}finally{a.f()}return null},n=i(r);n&&me(n)},[r]);var Se=n.useCallback(function(e,i){"button"===e.type&&e.onClick(i),me(e.id),null==U||U(e,i),B&&window.innerWidth<=768&&oe(!1)},[U,B,oe]),qe=n.useState(!1),Ne=e.slicedToArray(qe,2),we=Ne[0],ye=Ne[1];n.useEffect(function(){var e=function(){ye(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[]),n.useEffect(function(){if(ie){var e=function(e){var i=ie.toLowerCase().split("+"),n=i.filter(function(e){return["ctrl","alt","shift","meta"].includes(e)}),s=i.find(function(e){return!["ctrl","alt","shift","meta"].includes(e)});s&&(e.key||"").toLowerCase()===s&&n.every(function(i){switch(i){case"ctrl":return e.ctrlKey;case"alt":return e.altKey;case"shift":return e.shiftKey;case"meta":return e.metaKey;default:return!1}})&&(e.preventDefault(),he())};return document.addEventListener("keydown",e),function(){return document.removeEventListener("keydown",e)}}},[ie,he]);var Ce=n.useState(de()?S:N),ke=e.slicedToArray(Ce,2),Ee=ke[0],De=ke[1],Ae=n.useRef(!1),_e=n.useRef(null);n.useEffect(function(){De(de()?S:N)},[de,S,N]);var Te=n.useRef(null),Le=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if($)return $(e,i);switch(e.type){case"link":return Me(e,i);case"group":return ze(e,i);case"button":return Oe(e,i);case"divider":return Fe(e);default:return null}},Me=function(e,n){if(e.hasAccess&&!e.hasAccess())return null;var s=e.id===fe,a=n>0?"ihub-sidenav-indent-".concat(n):"",r=i.jsxs(i.Fragment,{children:[e.icon&&i.jsx("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?i.jsx(o.default,{src:e.icon,alt:"",width:24,height:24}):e.icon}),i.jsx("span",{className:"ihub-sidenav-text ".concat(de()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&i.jsx("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content})]});return e.isExternal?i.jsx("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:"ihub-sidenav-item ihub-sidenav-link ".concat(a," ").concat(s?"ihub-sidenav-active":""," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),onClick:function(i){return!e.isDisabled&&Se(e,i)},"data-tooltip":!de()&&null!=ee&&ee.enabled?e.title:void 0,"aria-disabled":e.isDisabled,children:r}):i.jsx(d.default,{href:e.href,className:"ihub-sidenav-item ihub-sidenav-link ".concat(a," ").concat(e.isActive&&0===n?"ihub-sidenav-active":e.isActive?"ihub-sidenav-child-active":""," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),onClick:function(i){return!e.isDisabled&&Se(e,i)},"data-tooltip":!de()&&null!=ee&&ee.enabled?e.title:void 0,"aria-disabled":e.isDisabled,children:r})},ze=function(e,n){var s=pe.has(e.id),a=e.children.some(function(e){return e.id===fe||"group"===e.type&&e.children.some(function(e){return e.id===fe})}),r=n>0?"ihub-sidenav-indent-".concat(n):"";return e.hideGroupTitle?i.jsx("div",{className:"ihub-sidenav-group ".concat(e.className||""),children:e.children.map(function(e,s){return i.jsx(u.default.Fragment,{children:Le(e,n)},e.id||"group-child-".concat(s))})}):i.jsxs("div",{className:"ihub-sidenav-group ".concat(e.className||""," ").concat(a?"ihub-sidenav-group-active":""),children:[i.jsxs("div",{className:"ihub-sidenav-item ihub-sidenav-group-header ".concat(e.isActive?"ihub-sidenav-active":""," ").concat(r," ").concat(e.isDisabled?"ihub-sidenav-disabled":""),onClick:function(){return!e.isDisabled&&(i=e.id,void ge(function(e){var n=new Set(e);return n.has(i)?n.delete(i):n.add(i),n}));var i},"data-tooltip":!de()&&null!=ee&&ee.enabled?e.title:void 0,"aria-disabled":e.isDisabled,"aria-expanded":s,children:[e.icon&&i.jsx("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?i.jsx(o.default,{src:e.icon,alt:"",width:24,height:24}):e.icon}),i.jsx("span",{className:"ihub-sidenav-text ".concat(de()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&i.jsx("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content}),i.jsx("span",{className:"ihub-sidenav-arrow ".concat(s?"ihub-sidenav-arrow-expanded":""," ").concat(de()?"":"ihub-sidenav-arrow-hidden")})]}),(s||!de())&&i.jsx("div",{className:"ihub-sidenav-group-items ".concat(s?"ihub-sidenav-group-expanded":""," ").concat(de()?"":"ihub-sidenav-group-collapsed"),children:(!Z||s||!de())&&e.children.map(function(e,s){return i.jsx(u.default.Fragment,{children:Le(e,n+1)},e.id||"group-child-".concat(s))})})]})},Oe=function(e,n){var s=n>0?"ihub-sidenav-indent-".concat(n):"";return i.jsxs("button",{className:"ihub-sidenav-item ihub-sidenav-button ".concat(s," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),onClick:function(i){return!e.isDisabled&&Se(e,i)},"data-tooltip":!de()&&null!=ee&&ee.enabled?e.title:void 0,disabled:e.isDisabled,children:[e.icon&&i.jsx("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?i.jsx(o.default,{src:e.icon,alt:"",width:24,height:24}):e.icon}),i.jsx("span",{className:"ihub-sidenav-text ".concat(de()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&i.jsx("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content})]})},Fe=function(e,n){return i.jsx("div",{className:"ihub-sidenav-divider",children:e.title&&de()&&i.jsx("span",{className:"ihub-sidenav-divider-text",children:e.title})})},Ie=["ihub-sidenav","ihub-sidenav-".concat(x),"ihub-sidenav-".concat(p),de()?"ihub-sidenav-expanded":"ihub-sidenav-collapsed",_?"ihub-sidenav-dark":"",M&&de()?"ihub-sidenav-resizable":"",we?"ihub-sidenav-mobile":"","none"!==y?"ihub-sidenav-".concat(y):"",D].filter(Boolean).join(" "),Ue=e.objectSpread2(e.objectSpread2(e.objectSpread2({width:"number"==typeof Ee?"".concat(Ee,"px"):Ee},null!=T&&T.fixed?{position:"fixed"}:{}),void 0!==(null==T?void 0:T.top)?{top:T.top}:{}),void 0!==(null==T?void 0:T.zIndex)?{zIndex:T.zIndex}:{}),We=["ihub-sidenav-container","ihub-sidenav-container-".concat(x),de()?"ihub-sidenav-container-expanded":"ihub-sidenav-container-collapsed",se].filter(Boolean).join(" "),Be={"--ihub-sidenav-width":"number"==typeof Ee?"".concat(Ee,"px"):Ee};return i.jsxs("div",{className:We,style:Be,children:[we&&de()&&K&&i.jsx("div",{className:"ihub-sidenav-backdrop",onClick:function(){oe(!1),null==R||R()}}),i.jsxs("div",{ref:_e,className:Ie,style:Ue,onTouchStart:function(e){H&&we&&(Te.current=e.touches[0].clientX)},onTouchMove:function(e){if(H&&we&&null!==Te.current){var i=e.touches[0].clientX-Te.current;Math.abs(i)>=50&&(oe("left"===x&&i>0||"right"===x&&i<0),Te.current=null)}},onTouchEnd:function(){Te.current=null},children:[i.jsx("button",{className:"ihub-sidenav-toggle",onClick:he,"aria-expanded":de(),"aria-label":de()?"Collapse sidebar":"Expand sidebar",children:"left"===x?de()?i.jsx(h.default,{}):i.jsx(v.default,{className:"ihub-ml-2"}):de()?i.jsx(v.default,{}):i.jsx(h.default,{className:"ihub-mr-2"})}),(null==C?void 0:C.href)&&i.jsx("div",{className:"ihub-sidenav-logo",children:i.jsx(d.default,{href:C.href||"",children:de()||!C.src?i.jsx(o.default,{src:C.src,alt:C.alt,width:C.width||120,height:C.height||40}):C.miniSrc&&i.jsx(o.default,{src:C.miniSrc,alt:C.alt,width:C.height||40,height:C.height||40})})}),M&&de()&&i.jsx("div",{className:"ihub-sidenav-resize-handle ihub-sidenav-resize-handle-".concat(x),onMouseDown:function(e){if(M&&de()){e.preventDefault(),Ae.current=!0;var i=function(e){var i;Ae.current&&(i="left"===x?e.clientX:window.innerWidth-e.clientX,i=Math.max(Number(I),Math.min(Number(O),i)),De(i))},n=function(){Ae.current=!1,document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",n)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",n)}}}),i.jsx("div",{className:"ihub-sidenav-content ihub-scrollbar-thin-light ".concat(null!=C&&C.href?"":"ihub-mt-2"),children:i.jsx("nav",{className:"ihub-sidenav-nav",children:r.map(function(e,n){return i.jsx(u.default.Fragment,{children:Le(e)},e.id||"nav-item-".concat(n))})})}),k&&i.jsxs("div",{className:"ihub-sidenav-footer",children:[i.jsx(c.default,{fallback:i.jsxs("div",{className:"ihub-sidenav-user",children:[i.jsx("div",{className:"ihub-sidenav-user-initials",children:"U"}),i.jsx("div",{className:"ihub-sidenav-user-info",children:i.jsx("div",{className:"ihub-sidenav-user-name",children:"User"})})]}),children:k.showUserProfile&&k.user&&de()&&i.jsxs("div",{className:"ihub-sidenav-user",children:[k.user.avatar?i.jsx(o.default,{src:"".concat(k.user.avatar),alt:k.user.name||"User",width:40,height:40,className:"ihub-sidenav-user-avatar"}):i.jsx("div",{className:"ihub-sidenav-user-initials",children:(null===(a=k.user.name)||void 0===a?void 0:a.charAt(0))||"U"}),i.jsxs("div",{className:"ihub-sidenav-user-info",children:[k.user.name&&i.jsx("div",{className:"ihub-sidenav-user-name",children:k.user.name}),k.user.role&&i.jsx("div",{className:"ihub-sidenav-user-role",children:k.user.role})]})]})}),k.actions&&i.jsx("div",{className:"ihub-sidenav-footer-actions",children:k.actions.map(function(e,n){return i.jsx(u.default.Fragment,{children:Oe(e,0)},e.id||"footer-action-".concat(n))})}),k.content&&i.jsx("div",{className:"ihub-sidenav-footer-content",children:de()?k.content:null})]})]}),i.jsx("div",{className:"ihub-sidenav-main",children:ae})]})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),i=require("react/jsx-runtime"),n=require("react"),t=require("next/link"),a=require("next/image"),s=require("@mui/icons-material/ChevronLeft"),r=require("@mui/icons-material/ChevronRight"),c=require("@mui/icons-material/ExpandMore"),l=require("../auth/ClientOnly.cjs");require("../lib/helpFunction.cjs"),require("@mui/icons-material/Visibility"),require("@mui/icons-material/VisibilityOff"),require("../../../node_modules/.pnpm/next-auth@5.0.0-beta.30_next@15.5.26_@babel_core@7.28.5_react-dom@19.3.0_react@19.3.0__react@19.3.0__react@19.3.0/node_modules/next-auth/react.cjs"),require("next/navigation"),require("../lib/utils.cjs"),require("../lib/phoneUtils.cjs"),require("../ui/OrDivider.cjs"),require("../forms/SubmitButton.cjs"),require("react-redux"),require("../lib/redux/store.cjs"),require("../lib/redux/slices/courseSlice/courseFilterSubject.cjs"),require("../lib/redux/slices/courseSlice/courseFilterLevel.cjs"),require("../lib/redux/slices/courseSlice/courseFilterDuration.cjs"),require("../lib/redux/slices/courseSlice/courseSearch.cjs"),require("../lib/redux/slices/courseSlice/stepQuestions.cjs"),require("../lib/redux/slices/courseSlice/stepContent.cjs"),require("../lib/redux/slices/courseSlice/courseDetails.cjs"),require("../lib/redux/slices/courseSlice/videoTimestamp.cjs"),require("../lib/redux/slices/courseSlice/videoEndCountdown.cjs"),require("../lib/redux/slices/courseSlice/videoTimestampObject.cjs"),require("../lib/redux/slices/courseSlice/courseModules.cjs"),require("../lib/redux/slices/courseSlice/courseOverview.cjs"),require("../lib/redux/slices/courseSlice/selectedCourses.cjs"),require("../lib/redux/slices/navigationSlice/appToggle.cjs"),require("../lib/redux/slices/navigationSlice/toggleCreateCourse.cjs"),require("../lib/redux/slices/navigationSlice/toggleCreateCohort.cjs"),require("../lib/redux/slices/navigationSlice/confirmDelete.cjs"),require("../lib/redux/slices/navigationSlice/IPAdress.cjs"),require("../lib/redux/slices/navigationSlice/settingsToggle.cjs"),require("../lib/redux/slices/navigationSlice/userLocation.cjs"),require("../lib/redux/slices/navigationSlice/searchValue.cjs"),require("../lib/redux/slices/navigationSlice/currentPromo.cjs"),require("../lib/redux/slices/navigationSlice/courseNextStep.cjs"),require("../lib/redux/slices/channelSlice/activeChannel.cjs"),require("../lib/redux/slices/channelSlice/channelDetails.cjs"),require("../lib/redux/slices/channelSlice/instructorChannelList.cjs"),require("../lib/redux/slices/channelSlice/channelHandle.cjs"),require("../lib/redux/slices/generics/objectSlice.cjs"),require("../lib/redux/slices/generics/arraySlice.cjs"),require("../lib/redux/slices/messageSlice/feedbackToggle.cjs"),require("../lib/redux/slices/messageSlice/statusMessageState.cjs"),require("../lib/redux/slices/utilsSlice/screenSize.cjs"),require("../lib/redux/slices/authSlice/channelCallbackUrl.cjs"),require("../lib/redux/slices/authSlice/unsplashObject.cjs"),require("@mui/icons-material/DoneOutlined"),require("@mui/icons-material/ContentCopyOutlined"),require("../status/MultiPurposeModal.cjs");var d=require("./SideNavSearch.cjs"),u=require("./sideNavMatch.cjs");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=o(n),v=o(t),b=o(a),f=o(s),m=o(r),x=o(c);exports.default=function(t){var a,s=t.items,r=t.defaultExpanded,c=void 0===r||r,o=t.isExpanded,p=t.onExpandedChange,j=t.position,g=void 0===j?"left":j,S=t.variant,N=void 0===S?"default":S,q=t.expandedWidth,y=void 0===q?240:q,w=t.collapsedWidth,C=void 0===w?64:w,E=t.animation,k=void 0===E?"slide":E,A=t.logo,I=t.footer,D=t.className,M=void 0===D?"":D,T=t.darkMode,_=void 0!==T&&T,L=t.positioning,F=t.resizable,O=void 0!==F&&F,z=t.maxWidth,R=void 0===z?400:z,B=t.minWidth,P=void 0===B?180:B,U=t.onNavigate,W=t.autoCollapseOnMobile,K=void 0===W||W,V=t.showBackdrop,X=void 0===V||V,G=t.onBackdropClick,H=t.enableTouchGestures,J=void 0===H||H,Q=t.persistState,Y=void 0===Q||Q,Z=t.persistStateKey,$=void 0===Z?"ihub-sidenav-expanded":Z,ee=t.lazyRender,ie=void 0!==ee&&ee,ne=t.renderItem,te=t.tooltip,ae=t.toggleShortcut,se=t.contentContainerClassName,re=void 0===se?"":se,ce=t.activePath,le=t.search,de=t.children,ue="ihub-sidenav-".concat(n.useId().replace(/:/g,"")),oe=void 0!==o,he=n.useState(c),ve=e.slicedToArray(he,2),be=ve[0],fe=ve[1];n.useEffect(function(){if(oe)fe(o);else if(Y&&"undefined"!=typeof window){var e=localStorage.getItem($);null!==e&&fe("true"===e)}},[oe,o,Y,$]),n.useEffect(function(){oe&&fe(o)},[oe,o]);var me=function(){return oe?o:be},xe=function(e){oe||(fe(e),Y&&"undefined"!=typeof window&&localStorage.setItem($,String(e))),null==p||p(e)},pe=function(){return xe(!me())},je=n.useMemo(function(){return void 0!==ce?u.resolveSideNavActive(s,ce):u.findFlaggedActive(s)},[s,ce]),ge=je.ancestorIds.join("|"),Se=n.useState(je.id),Ne=e.slicedToArray(Se,2),qe=Ne[0],ye=Ne[1],we=n.useState(function(){return new Set(je.ancestorIds)}),Ce=e.slicedToArray(we,2),Ee=Ce[0],ke=Ce[1],Ae="".concat($,"-sections"),Ie=n.useState(function(){var e=new Set;return s.forEach(function(i){"section"===i.type&&i.defaultCollapsed&&e.add(i.id)}),je.ancestorIds.forEach(function(i){return e.delete(i)}),e}),De=e.slicedToArray(Ie,2),Me=De[0],Te=De[1];n.useEffect(function(){je.id&&ye(je.id)},[je.id]),n.useEffect(function(){if(Y&&"undefined"!=typeof window)try{var i=JSON.parse(localStorage.getItem(Ae)||"null");i&&"object"===e.typeof(i)&&Te(function(n){var t=new Set(n);return Object.entries(i).forEach(function(i){var n=e.slicedToArray(i,2),a=n[0];n[1]&&!je.ancestorIds.includes(a)?t.add(a):t.delete(a)}),t})}catch(e){}},[Y,Ae]),n.useEffect(function(){var i=[],n=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];e.forEach(function(e){"section"===e.type?n(e.children,t):"group"===e.type&&(e.defaultExpanded||t?(i.push(e.id),n(e.children,!0)):n(e.children,!1))})};n(s),i.length&&ke(function(n){return i.every(function(e){return n.has(e)})?n:new Set([].concat(e.toConsumableArray(n),i))})},[s]),n.useEffect(function(){je.ancestorIds.length&&(ke(function(i){return je.ancestorIds.every(function(e){return i.has(e)})?i:new Set([].concat(e.toConsumableArray(i),e.toConsumableArray(je.ancestorIds)))}),Te(function(i){return je.ancestorIds.some(function(e){return i.has(e)})?new Set(e.toConsumableArray(i).filter(function(e){return!je.ancestorIds.includes(e)})):i}))},[ge]);var _e=n.useCallback(function(e,i){"button"===e.type&&e.onClick(i),"link"===e.type&&ye(e.id),null==U||U(e,i),K&&window.innerWidth<=768&&xe(!1)},[U,K,xe]),Le=n.useState(!1),Fe=e.slicedToArray(Le,2),Oe=Fe[0],ze=Fe[1];n.useEffect(function(){var e=function(){ze(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[]),n.useEffect(function(){if(ae){var e=function(e){var i=ae.toLowerCase().split("+"),n=i.filter(function(e){return["ctrl","alt","shift","meta"].includes(e)}),t=i.find(function(e){return!["ctrl","alt","shift","meta"].includes(e)});t&&(e.key||"").toLowerCase()===t&&n.every(function(i){switch(i){case"ctrl":return e.ctrlKey;case"alt":return e.altKey;case"shift":return e.shiftKey;case"meta":return e.metaKey;default:return!1}})&&(e.preventDefault(),pe())};return document.addEventListener("keydown",e),function(){return document.removeEventListener("keydown",e)}}},[ae,pe]);var Re=n.useState(me()?y:C),Be=e.slicedToArray(Re,2),Pe=Be[0],Ue=Be[1],We=n.useRef(!1),Ke=n.useRef(null),Ve=n.useRef(null);n.useEffect(function(){var e=window.requestAnimationFrame(function(){var e,i=null===(e=Ve.current)||void 0===e?void 0:e.querySelector('[aria-current="page"]'),n=Ve.current;if(i&&n){var t=i.getBoundingClientRect(),a=n.getBoundingClientRect();(t.top<a.top||t.bottom>a.bottom)&&i.scrollIntoView({block:"center"})}});return function(){return window.cancelAnimationFrame(e)}},[qe,Ee,Me]),n.useEffect(function(){Ue(me()?y:C)},[me,y,C]);var Xe=n.useRef(null),Ge=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(ne)return ne(e,i);switch(e.type){case"link":return He(e,i);case"group":return Je(e,i);case"button":return Qe(e,i);case"divider":return Ze(e);case"section":return Ye(e);default:return null}},He=function(e,n){if(e.hasAccess&&!e.hasAccess())return null;var t=e.id===qe||void 0===ce&&!!e.isActive,a=n>0?"ihub-sidenav-indent-".concat(n):"",s=i.jsxs(i.Fragment,{children:[e.icon&&i.jsx("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?i.jsx(b.default,{src:e.icon,alt:"",width:24,height:24}):e.icon}),i.jsx("span",{className:"ihub-sidenav-text ".concat(me()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&i.jsx("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content})]});return e.isExternal?i.jsx("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:"ihub-sidenav-item ihub-sidenav-link ".concat(a," ").concat(t?"ihub-sidenav-active":""," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),onClick:function(i){return!e.isDisabled&&_e(e,i)},"data-tooltip":!me()&&null!=te&&te.enabled?e.title:void 0,"aria-disabled":e.isDisabled,children:s}):i.jsx(v.default,{href:e.href,className:"ihub-sidenav-item ihub-sidenav-link ".concat(a," ").concat(t&&0===n?"ihub-sidenav-active":t?"ihub-sidenav-child-active":""," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),"aria-current":t?"page":void 0,onClick:function(i){return!e.isDisabled&&_e(e,i)},"data-tooltip":!me()&&null!=te&&te.enabled?e.title:void 0,"aria-disabled":e.isDisabled,children:s})},Je=function(e,n){var t=Ee.has(e.id),a=u.containsNavId(e,qe),s=n>0?"ihub-sidenav-indent-".concat(n):"";return e.hideGroupTitle?i.jsx("div",{className:"ihub-sidenav-group ".concat(e.className||""),children:e.children.map(function(e,t){return i.jsx(h.default.Fragment,{children:Ge(e,n)},e.id||"group-child-".concat(t))})}):i.jsxs("div",{className:"ihub-sidenav-group ".concat(e.className||""," ").concat(a?"ihub-sidenav-group-active":""),children:[i.jsxs("div",{className:"ihub-sidenav-item ihub-sidenav-group-header ".concat(e.isActive?"ihub-sidenav-active":""," ").concat(s," ").concat(e.isDisabled?"ihub-sidenav-disabled":""),onClick:function(){return!e.isDisabled&&(i=e.id,void ke(function(e){var n=new Set(e);return n.has(i)?n.delete(i):n.add(i),n}));var i},"data-tooltip":!me()&&null!=te&&te.enabled?e.title:void 0,"aria-disabled":e.isDisabled,"aria-expanded":t,children:[e.icon&&i.jsx("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?i.jsx(b.default,{src:e.icon,alt:"",width:24,height:24}):e.icon}),i.jsx("span",{className:"ihub-sidenav-text ".concat(me()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&i.jsx("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content}),i.jsx("span",{className:"ihub-sidenav-arrow ".concat(t?"ihub-sidenav-arrow-expanded":""," ").concat(me()?"":"ihub-sidenav-arrow-hidden")})]}),(t||!me())&&i.jsx("div",{className:"ihub-sidenav-group-items ".concat(t?"ihub-sidenav-group-expanded":""," ").concat(me()?"":"ihub-sidenav-group-collapsed"),children:(!ie||t||!me())&&e.children.map(function(e,t){return i.jsx(h.default.Fragment,{children:Ge(e,n+1)},e.id||"group-child-".concat(t))})})]})},Qe=function(e,n){var t=n>0?"ihub-sidenav-indent-".concat(n):"";return i.jsxs("button",{className:"ihub-sidenav-item ihub-sidenav-button ".concat(t," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),onClick:function(i){return!e.isDisabled&&_e(e,i)},"data-tooltip":!me()&&null!=te&&te.enabled?e.title:void 0,disabled:e.isDisabled,children:[e.icon&&i.jsx("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?i.jsx(b.default,{src:e.icon,alt:"",width:24,height:24}):e.icon}),i.jsx("span",{className:"ihub-sidenav-text ".concat(me()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&i.jsx("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content})]})},Ye=function(e){var n=me(),t=!1!==e.collapsible,a=n&&t&&Me.has(e.id),r="".concat(ue,"-section-").concat(e.id),c=u.containsNavId(e,qe);return i.jsxs("div",{className:"ihub-sidenav-section ".concat(e.className||""," ").concat(c?"ihub-sidenav-section-active":""),children:[n&&(t?i.jsxs("button",{type:"button",className:"ihub-sidenav-section-head","aria-expanded":!a,"aria-controls":r,onClick:function(){return i=e.id,void Te(function(e){var n=new Set(e);if(n.has(i)?n.delete(i):n.add(i),Y&&"undefined"!=typeof window)try{var t={};s.forEach(function(e){"section"===e.type&&(t[e.id]=n.has(e.id))}),localStorage.setItem(Ae,JSON.stringify(t))}catch(e){}return n});var i},children:[i.jsx("span",{className:"ihub-sidenav-section-title",children:e.title}),a&&c&&i.jsx("span",{className:"ihub-sidenav-section-dot","aria-label":"Current page is here"}),a&&i.jsx("span",{className:"ihub-sidenav-section-count",children:e.children.filter(function(e){return"divider"!==e.type}).length}),i.jsx("span",{className:"ihub-sidenav-section-chevron","aria-hidden":"true",children:i.jsx(x.default,{})})]}):i.jsx("div",{className:"ihub-sidenav-section-head ihub-sidenav-section-head-static",children:i.jsx("span",{className:"ihub-sidenav-section-title",children:e.title})})),!a&&i.jsx("div",{id:r,className:"ihub-sidenav-section-items",children:e.children.map(function(e,n){return i.jsx(h.default.Fragment,{children:Ge(e,0)},e.id||"section-child-".concat(n))})})]})},Ze=function(e,n){return i.jsx("div",{className:"ihub-sidenav-divider",children:e.title&&me()&&i.jsx("span",{className:"ihub-sidenav-divider-text",children:e.title})})},$e=!0===le?{}:le||null,ei=function(e){return i.jsx("div",{ref:Ve,className:"ihub-sidenav-content ihub-scrollbar-thin-light ".concat(null!=A&&A.href||$e?"":"ihub-mt-2"),children:null!=e?e:i.jsx("nav",{className:"ihub-sidenav-nav",children:s.map(function(e,n){return i.jsx(h.default.Fragment,{children:Ge(e)},e.id||"nav-item-".concat(n))})})})},ii=["ihub-sidenav","ihub-sidenav-".concat(g),"ihub-sidenav-".concat(N),me()?"ihub-sidenav-expanded":"ihub-sidenav-collapsed",_?"ihub-sidenav-dark":"",O&&me()?"ihub-sidenav-resizable":"",Oe?"ihub-sidenav-mobile":"","none"!==k?"ihub-sidenav-".concat(k):"",M].filter(Boolean).join(" "),ni=e.objectSpread2(e.objectSpread2(e.objectSpread2({width:"number"==typeof Pe?"".concat(Pe,"px"):Pe},null!=L&&L.fixed?{position:"fixed"}:{}),void 0!==(null==L?void 0:L.top)?{top:L.top}:{}),void 0!==(null==L?void 0:L.zIndex)?{zIndex:L.zIndex}:{}),ti=["ihub-sidenav-container","ihub-sidenav-container-".concat(g),me()?"ihub-sidenav-container-expanded":"ihub-sidenav-container-collapsed",re].filter(Boolean).join(" "),ai={"--ihub-sidenav-width":"number"==typeof Pe?"".concat(Pe,"px"):Pe};return i.jsxs("div",{className:ti,style:ai,children:[Oe&&me()&&X&&i.jsx("div",{className:"ihub-sidenav-backdrop",onClick:function(){xe(!1),null==G||G()}}),i.jsxs("div",{ref:Ke,className:ii,style:ni,onTouchStart:function(e){J&&Oe&&(Xe.current=e.touches[0].clientX)},onTouchMove:function(e){if(J&&Oe&&null!==Xe.current){var i=e.touches[0].clientX-Xe.current;Math.abs(i)>=50&&(xe("left"===g&&i>0||"right"===g&&i<0),Xe.current=null)}},onTouchEnd:function(){Xe.current=null},children:[i.jsx("button",{className:"ihub-sidenav-toggle",onClick:pe,"aria-expanded":me(),"aria-label":me()?"Collapse sidebar":"Expand sidebar",children:"left"===g?me()?i.jsx(f.default,{}):i.jsx(m.default,{className:"ihub-ml-2"}):me()?i.jsx(m.default,{}):i.jsx(f.default,{className:"ihub-mr-2"})}),(null==A?void 0:A.href)&&i.jsx("div",{className:"ihub-sidenav-logo",children:i.jsx(v.default,{href:A.href||"",children:me()||!A.src?i.jsx(b.default,{src:A.src,alt:A.alt,width:A.width||120,height:A.height||40}):A.miniSrc&&i.jsx(b.default,{src:A.miniSrc,alt:A.alt,width:A.height||40,height:A.height||40})})}),O&&me()&&i.jsx("div",{className:"ihub-sidenav-resize-handle ihub-sidenav-resize-handle-".concat(g),onMouseDown:function(e){if(O&&me()){e.preventDefault(),We.current=!0;var i=function(e){var i;We.current&&(i="left"===g?e.clientX:window.innerWidth-e.clientX,i=Math.max(Number(P),Math.min(Number(R),i)),Ue(i))},n=function(){We.current=!1,document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",n)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",n)}}}),$e&&me()?i.jsx(d.default,{items:s,config:$e,idPrefix:ue,shortcutEnabled:!Oe||me(),renderResult:function(n,t){var a=n.item,s=t.id,r=t.selected,c=t.label,l=t.onMouseEnter,d=t.onActivated,u=a.icon&&i.jsx("span",{className:"ihub-sidenav-icon","aria-hidden":"true",children:"string"==typeof a.icon?i.jsx(b.default,{src:a.icon,alt:"",width:24,height:24}):a.icon}),o={id:s,role:"option","aria-selected":r,className:"ihub-sidenav-item ihub-sidenav-result",onMouseEnter:l};if("button"===a.type)return i.jsxs("button",e.objectSpread2(e.objectSpread2({type:"button"},o),{},{onClick:function(e){_e(a,e),d()},children:[u,c]}));var h=function(e){_e(a,e),d()};return a.isExternal?i.jsxs("a",e.objectSpread2(e.objectSpread2({href:a.href,target:"_blank",rel:"noopener noreferrer"},o),{},{onClick:h,children:[u,c]})):i.jsxs(v.default,e.objectSpread2(e.objectSpread2({href:a.href},o),{},{onClick:h,children:[u,c]}))},children:function(e){return ei(e)}}):ei(null),I&&i.jsxs("div",{className:"ihub-sidenav-footer",children:[i.jsx(l.default,{fallback:i.jsxs("div",{className:"ihub-sidenav-user",children:[i.jsx("div",{className:"ihub-sidenav-user-initials",children:"U"}),i.jsx("div",{className:"ihub-sidenav-user-info",children:i.jsx("div",{className:"ihub-sidenav-user-name",children:"User"})})]}),children:I.showUserProfile&&I.user&&me()&&i.jsxs("div",{className:"ihub-sidenav-user",children:[I.user.avatar?i.jsx(b.default,{src:"".concat(I.user.avatar),alt:I.user.name||"User",width:40,height:40,className:"ihub-sidenav-user-avatar"}):i.jsx("div",{className:"ihub-sidenav-user-initials",children:(null===(a=I.user.name)||void 0===a?void 0:a.charAt(0))||"U"}),i.jsxs("div",{className:"ihub-sidenav-user-info",children:[I.user.name&&i.jsx("div",{className:"ihub-sidenav-user-name",children:I.user.name}),I.user.role&&i.jsx("div",{className:"ihub-sidenav-user-role",children:I.user.role})]})]})}),I.actions&&i.jsx("div",{className:"ihub-sidenav-footer-actions",children:I.actions.map(function(e,n){return i.jsx(h.default.Fragment,{children:Qe(e,0)},e.id||"footer-action-".concat(n))})}),I.content&&i.jsx("div",{className:"ihub-sidenav-footer-content",children:me()?I.content:null})]})]}),i.jsx("div",{className:"ihub-sidenav-main",children:de})]})};
|
|
2
2
|
//# sourceMappingURL=SideNavbar.cjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e,objectSpread2 as i,createForOfIteratorHelper as n,toConsumableArray as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as a,jsx as s,Fragment as r}from"react/jsx-runtime";import c,{useState as o,useEffect as l,useCallback as d,useRef as u}from"react";import h from"next/link";import v from"next/image";import m from"@mui/icons-material/ChevronLeft";import b from"@mui/icons-material/ChevronRight";import p from"../auth/ClientOnly.js";import"../lib/helpFunction.js";import"@mui/icons-material/Visibility";import"@mui/icons-material/VisibilityOff";import"../../../node_modules/.pnpm/next-auth@5.0.0-beta.30_next@15.5.26_@babel_core@7.28.5_react-dom@19.3.0_react@19.3.0__react@19.3.0__react@19.3.0/node_modules/next-auth/react.js";import"next/navigation";import"../lib/utils.js";import"../lib/phoneUtils.js";import"../ui/OrDivider.js";import"../forms/SubmitButton.js";import"react-redux";import"../lib/redux/store.js";import"../lib/redux/slices/courseSlice/courseFilterSubject.js";import"../lib/redux/slices/courseSlice/courseFilterLevel.js";import"../lib/redux/slices/courseSlice/courseFilterDuration.js";import"../lib/redux/slices/courseSlice/courseSearch.js";import"../lib/redux/slices/courseSlice/stepQuestions.js";import"../lib/redux/slices/courseSlice/stepContent.js";import"../lib/redux/slices/courseSlice/courseDetails.js";import"../lib/redux/slices/courseSlice/videoTimestamp.js";import"../lib/redux/slices/courseSlice/videoEndCountdown.js";import"../lib/redux/slices/courseSlice/videoTimestampObject.js";import"../lib/redux/slices/courseSlice/courseModules.js";import"../lib/redux/slices/courseSlice/courseOverview.js";import"../lib/redux/slices/courseSlice/selectedCourses.js";import"../lib/redux/slices/navigationSlice/appToggle.js";import"../lib/redux/slices/navigationSlice/toggleCreateCourse.js";import"../lib/redux/slices/navigationSlice/toggleCreateCohort.js";import"../lib/redux/slices/navigationSlice/confirmDelete.js";import"../lib/redux/slices/navigationSlice/IPAdress.js";import"../lib/redux/slices/navigationSlice/settingsToggle.js";import"../lib/redux/slices/navigationSlice/userLocation.js";import"../lib/redux/slices/navigationSlice/searchValue.js";import"../lib/redux/slices/navigationSlice/currentPromo.js";import"../lib/redux/slices/navigationSlice/courseNextStep.js";import"../lib/redux/slices/channelSlice/activeChannel.js";import"../lib/redux/slices/channelSlice/channelDetails.js";import"../lib/redux/slices/channelSlice/instructorChannelList.js";import"../lib/redux/slices/channelSlice/channelHandle.js";import"../lib/redux/slices/generics/objectSlice.js";import"../lib/redux/slices/generics/arraySlice.js";import"../lib/redux/slices/messageSlice/feedbackToggle.js";import"../lib/redux/slices/messageSlice/statusMessageState.js";import"../lib/redux/slices/utilsSlice/screenSize.js";import"../lib/redux/slices/authSlice/channelCallbackUrl.js";import"../lib/redux/slices/authSlice/unsplashObject.js";import"@mui/icons-material/DoneOutlined";import"@mui/icons-material/ContentCopyOutlined";import"../status/MultiPurposeModal.js";var f=function(f){var g,x=f.items,N=f.defaultExpanded,S=void 0===N||N,j=f.isExpanded,w=f.onExpandedChange,y=f.position,C=void 0===y?"left":y,k=f.variant,D=void 0===k?"default":k,E=f.expandedWidth,L=void 0===E?240:E,_=f.collapsedWidth,A=void 0===_?64:_,z=f.animation,M=void 0===z?"slide":z,T=f.logo,O=f.footer,F=f.className,I=void 0===F?"":F,U=f.darkMode,W=void 0!==U&&U,B=f.positioning,K=f.resizable,P=void 0!==K&&K,X=f.maxWidth,H=void 0===X?400:X,V=f.minWidth,G=void 0===V?180:V,R=f.onNavigate,Q=f.autoCollapseOnMobile,q=void 0===Q||Q,J=f.showBackdrop,Y=void 0===J||J,Z=f.onBackdropClick,$=f.enableTouchGestures,ee=void 0===$||$,ie=f.persistState,ne=void 0===ie||ie,te=f.persistStateKey,ae=void 0===te?"ihub-sidenav-expanded":te,se=f.lazyRender,re=void 0!==se&&se,ce=f.renderItem,oe=f.tooltip,le=f.toggleShortcut,de=f.contentContainerClassName,ue=void 0===de?"":de,he=f.children,ve=void 0!==j,me=o(S),be=e(me,2),pe=be[0],fe=be[1];l(function(){if(ve)fe(j);else if(ne&&"undefined"!=typeof window){var e=localStorage.getItem(ae);null!==e&&fe("true"===e)}},[ve,j,ne,ae]),l(function(){ve&&fe(j)},[ve,j]);var ge=function(){return ve?j:pe},xe=function(e){ve||(fe(e),ne&&"undefined"!=typeof window&&localStorage.setItem(ae,String(e))),null==w||w(e)},Ne=function(){return xe(!ge())},Se=o(null),je=e(Se,2),we=je[0],ye=je[1],Ce=o(new Set),ke=e(Ce,2),De=ke[0],Ee=ke[1];l(function(){var e=new Set,i=function(n){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n.forEach(function(n){if("group"===n.type){var a=n;(a.defaultExpanded||t||a.children.some(function(e){return"isActive"in e&&e.isActive||"group"===e.type&&e.defaultExpanded}))&&(e.add(n.id),i(a.children,!0))}})};i(x),Ee(e)},[x]),l(function(){var e=function(i){var a,s=n(i);try{var r,c=function(){var i=a.value;if("isActive"in i&&i.isActive)return{v:i.id};if("group"===i.type){var n=e(i.children);if(n)return Ee(function(e){return new Set([].concat(t(e),[i.id]))}),{v:n}}};for(s.s();!(a=s.n()).done;)if(r=c())return r.v}catch(e){s.e(e)}finally{s.f()}return null},i=e(x);i&&ye(i)},[x]);var Le=d(function(e,i){"button"===e.type&&e.onClick(i),ye(e.id),null==R||R(e,i),q&&window.innerWidth<=768&&xe(!1)},[R,q,xe]),_e=o(!1),Ae=e(_e,2),ze=Ae[0],Me=Ae[1];l(function(){var e=function(){Me(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[]),l(function(){if(le){var e=function(e){var i=le.toLowerCase().split("+"),n=i.filter(function(e){return["ctrl","alt","shift","meta"].includes(e)}),t=i.find(function(e){return!["ctrl","alt","shift","meta"].includes(e)});t&&(e.key||"").toLowerCase()===t&&n.every(function(i){switch(i){case"ctrl":return e.ctrlKey;case"alt":return e.altKey;case"shift":return e.shiftKey;case"meta":return e.metaKey;default:return!1}})&&(e.preventDefault(),Ne())};return document.addEventListener("keydown",e),function(){return document.removeEventListener("keydown",e)}}},[le,Ne]);var Te=o(ge()?L:A),Oe=e(Te,2),Fe=Oe[0],Ie=Oe[1],Ue=u(!1),We=u(null);l(function(){Ie(ge()?L:A)},[ge,L,A]);var Be=u(null),Ke=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(ce)return ce(e,i);switch(e.type){case"link":return Pe(e,i);case"group":return Xe(e,i);case"button":return He(e,i);case"divider":return Ve(e);default:return null}},Pe=function(e,i){if(e.hasAccess&&!e.hasAccess())return null;var n=e.id===we,t=i>0?"ihub-sidenav-indent-".concat(i):"",c=a(r,{children:[e.icon&&s("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?s(v,{src:e.icon,alt:"",width:24,height:24}):e.icon}),s("span",{className:"ihub-sidenav-text ".concat(ge()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&s("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content})]});return e.isExternal?s("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:"ihub-sidenav-item ihub-sidenav-link ".concat(t," ").concat(n?"ihub-sidenav-active":""," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),onClick:function(i){return!e.isDisabled&&Le(e,i)},"data-tooltip":!ge()&&null!=oe&&oe.enabled?e.title:void 0,"aria-disabled":e.isDisabled,children:c}):s(h,{href:e.href,className:"ihub-sidenav-item ihub-sidenav-link ".concat(t," ").concat(e.isActive&&0===i?"ihub-sidenav-active":e.isActive?"ihub-sidenav-child-active":""," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),onClick:function(i){return!e.isDisabled&&Le(e,i)},"data-tooltip":!ge()&&null!=oe&&oe.enabled?e.title:void 0,"aria-disabled":e.isDisabled,children:c})},Xe=function(e,i){var n=De.has(e.id),t=e.children.some(function(e){return e.id===we||"group"===e.type&&e.children.some(function(e){return e.id===we})}),r=i>0?"ihub-sidenav-indent-".concat(i):"";return e.hideGroupTitle?s("div",{className:"ihub-sidenav-group ".concat(e.className||""),children:e.children.map(function(e,n){return s(c.Fragment,{children:Ke(e,i)},e.id||"group-child-".concat(n))})}):a("div",{className:"ihub-sidenav-group ".concat(e.className||""," ").concat(t?"ihub-sidenav-group-active":""),children:[a("div",{className:"ihub-sidenav-item ihub-sidenav-group-header ".concat(e.isActive?"ihub-sidenav-active":""," ").concat(r," ").concat(e.isDisabled?"ihub-sidenav-disabled":""),onClick:function(){return!e.isDisabled&&(i=e.id,void Ee(function(e){var n=new Set(e);return n.has(i)?n.delete(i):n.add(i),n}));var i},"data-tooltip":!ge()&&null!=oe&&oe.enabled?e.title:void 0,"aria-disabled":e.isDisabled,"aria-expanded":n,children:[e.icon&&s("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?s(v,{src:e.icon,alt:"",width:24,height:24}):e.icon}),s("span",{className:"ihub-sidenav-text ".concat(ge()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&s("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content}),s("span",{className:"ihub-sidenav-arrow ".concat(n?"ihub-sidenav-arrow-expanded":""," ").concat(ge()?"":"ihub-sidenav-arrow-hidden")})]}),(n||!ge())&&s("div",{className:"ihub-sidenav-group-items ".concat(n?"ihub-sidenav-group-expanded":""," ").concat(ge()?"":"ihub-sidenav-group-collapsed"),children:(!re||n||!ge())&&e.children.map(function(e,n){return s(c.Fragment,{children:Ke(e,i+1)},e.id||"group-child-".concat(n))})})]})},He=function(e,i){var n=i>0?"ihub-sidenav-indent-".concat(i):"";return a("button",{className:"ihub-sidenav-item ihub-sidenav-button ".concat(n," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),onClick:function(i){return!e.isDisabled&&Le(e,i)},"data-tooltip":!ge()&&null!=oe&&oe.enabled?e.title:void 0,disabled:e.isDisabled,children:[e.icon&&s("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?s(v,{src:e.icon,alt:"",width:24,height:24}):e.icon}),s("span",{className:"ihub-sidenav-text ".concat(ge()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&s("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content})]})},Ve=function(e,i){return s("div",{className:"ihub-sidenav-divider",children:e.title&&ge()&&s("span",{className:"ihub-sidenav-divider-text",children:e.title})})},Ge=["ihub-sidenav","ihub-sidenav-".concat(C),"ihub-sidenav-".concat(D),ge()?"ihub-sidenav-expanded":"ihub-sidenav-collapsed",W?"ihub-sidenav-dark":"",P&&ge()?"ihub-sidenav-resizable":"",ze?"ihub-sidenav-mobile":"","none"!==M?"ihub-sidenav-".concat(M):"",I].filter(Boolean).join(" "),Re=i(i(i({width:"number"==typeof Fe?"".concat(Fe,"px"):Fe},null!=B&&B.fixed?{position:"fixed"}:{}),void 0!==(null==B?void 0:B.top)?{top:B.top}:{}),void 0!==(null==B?void 0:B.zIndex)?{zIndex:B.zIndex}:{}),Qe=["ihub-sidenav-container","ihub-sidenav-container-".concat(C),ge()?"ihub-sidenav-container-expanded":"ihub-sidenav-container-collapsed",ue].filter(Boolean).join(" "),qe={"--ihub-sidenav-width":"number"==typeof Fe?"".concat(Fe,"px"):Fe};return a("div",{className:Qe,style:qe,children:[ze&&ge()&&Y&&s("div",{className:"ihub-sidenav-backdrop",onClick:function(){xe(!1),null==Z||Z()}}),a("div",{ref:We,className:Ge,style:Re,onTouchStart:function(e){ee&&ze&&(Be.current=e.touches[0].clientX)},onTouchMove:function(e){if(ee&&ze&&null!==Be.current){var i=e.touches[0].clientX-Be.current;Math.abs(i)>=50&&(xe("left"===C&&i>0||"right"===C&&i<0),Be.current=null)}},onTouchEnd:function(){Be.current=null},children:[s("button",{className:"ihub-sidenav-toggle",onClick:Ne,"aria-expanded":ge(),"aria-label":ge()?"Collapse sidebar":"Expand sidebar",children:"left"===C?ge()?s(m,{}):s(b,{className:"ihub-ml-2"}):ge()?s(b,{}):s(m,{className:"ihub-mr-2"})}),(null==T?void 0:T.href)&&s("div",{className:"ihub-sidenav-logo",children:s(h,{href:T.href||"",children:ge()||!T.src?s(v,{src:T.src,alt:T.alt,width:T.width||120,height:T.height||40}):T.miniSrc&&s(v,{src:T.miniSrc,alt:T.alt,width:T.height||40,height:T.height||40})})}),P&&ge()&&s("div",{className:"ihub-sidenav-resize-handle ihub-sidenav-resize-handle-".concat(C),onMouseDown:function(e){if(P&&ge()){e.preventDefault(),Ue.current=!0;var i=function(e){var i;Ue.current&&(i="left"===C?e.clientX:window.innerWidth-e.clientX,i=Math.max(Number(G),Math.min(Number(H),i)),Ie(i))},n=function(){Ue.current=!1,document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",n)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",n)}}}),s("div",{className:"ihub-sidenav-content ihub-scrollbar-thin-light ".concat(null!=T&&T.href?"":"ihub-mt-2"),children:s("nav",{className:"ihub-sidenav-nav",children:x.map(function(e,i){return s(c.Fragment,{children:Ke(e)},e.id||"nav-item-".concat(i))})})}),O&&a("div",{className:"ihub-sidenav-footer",children:[s(p,{fallback:a("div",{className:"ihub-sidenav-user",children:[s("div",{className:"ihub-sidenav-user-initials",children:"U"}),s("div",{className:"ihub-sidenav-user-info",children:s("div",{className:"ihub-sidenav-user-name",children:"User"})})]}),children:O.showUserProfile&&O.user&&ge()&&a("div",{className:"ihub-sidenav-user",children:[O.user.avatar?s(v,{src:"".concat(O.user.avatar),alt:O.user.name||"User",width:40,height:40,className:"ihub-sidenav-user-avatar"}):s("div",{className:"ihub-sidenav-user-initials",children:(null===(g=O.user.name)||void 0===g?void 0:g.charAt(0))||"U"}),a("div",{className:"ihub-sidenav-user-info",children:[O.user.name&&s("div",{className:"ihub-sidenav-user-name",children:O.user.name}),O.user.role&&s("div",{className:"ihub-sidenav-user-role",children:O.user.role})]})]})}),O.actions&&s("div",{className:"ihub-sidenav-footer-actions",children:O.actions.map(function(e,i){return s(c.Fragment,{children:He(e,0)},e.id||"footer-action-".concat(i))})}),O.content&&s("div",{className:"ihub-sidenav-footer-content",children:ge()?O.content:null})]})]}),s("div",{className:"ihub-sidenav-main",children:he})]})};export{f as default};
|
|
1
|
+
import{slicedToArray as e,typeof as i,toConsumableArray as n,objectSpread2 as t}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as a,jsx as r,Fragment as s}from"react/jsx-runtime";import c,{useId as o,useState as l,useEffect as d,useMemo as u,useCallback as h,useRef as v}from"react";import m from"next/link";import b from"next/image";import p from"@mui/icons-material/ChevronLeft";import f from"@mui/icons-material/ChevronRight";import g from"@mui/icons-material/ExpandMore";import x from"../auth/ClientOnly.js";import"../lib/helpFunction.js";import"@mui/icons-material/Visibility";import"@mui/icons-material/VisibilityOff";import"../../../node_modules/.pnpm/next-auth@5.0.0-beta.30_next@15.5.26_@babel_core@7.28.5_react-dom@19.3.0_react@19.3.0__react@19.3.0__react@19.3.0/node_modules/next-auth/react.js";import"next/navigation";import"../lib/utils.js";import"../lib/phoneUtils.js";import"../ui/OrDivider.js";import"../forms/SubmitButton.js";import"react-redux";import"../lib/redux/store.js";import"../lib/redux/slices/courseSlice/courseFilterSubject.js";import"../lib/redux/slices/courseSlice/courseFilterLevel.js";import"../lib/redux/slices/courseSlice/courseFilterDuration.js";import"../lib/redux/slices/courseSlice/courseSearch.js";import"../lib/redux/slices/courseSlice/stepQuestions.js";import"../lib/redux/slices/courseSlice/stepContent.js";import"../lib/redux/slices/courseSlice/courseDetails.js";import"../lib/redux/slices/courseSlice/videoTimestamp.js";import"../lib/redux/slices/courseSlice/videoEndCountdown.js";import"../lib/redux/slices/courseSlice/videoTimestampObject.js";import"../lib/redux/slices/courseSlice/courseModules.js";import"../lib/redux/slices/courseSlice/courseOverview.js";import"../lib/redux/slices/courseSlice/selectedCourses.js";import"../lib/redux/slices/navigationSlice/appToggle.js";import"../lib/redux/slices/navigationSlice/toggleCreateCourse.js";import"../lib/redux/slices/navigationSlice/toggleCreateCohort.js";import"../lib/redux/slices/navigationSlice/confirmDelete.js";import"../lib/redux/slices/navigationSlice/IPAdress.js";import"../lib/redux/slices/navigationSlice/settingsToggle.js";import"../lib/redux/slices/navigationSlice/userLocation.js";import"../lib/redux/slices/navigationSlice/searchValue.js";import"../lib/redux/slices/navigationSlice/currentPromo.js";import"../lib/redux/slices/navigationSlice/courseNextStep.js";import"../lib/redux/slices/channelSlice/activeChannel.js";import"../lib/redux/slices/channelSlice/channelDetails.js";import"../lib/redux/slices/channelSlice/instructorChannelList.js";import"../lib/redux/slices/channelSlice/channelHandle.js";import"../lib/redux/slices/generics/objectSlice.js";import"../lib/redux/slices/generics/arraySlice.js";import"../lib/redux/slices/messageSlice/feedbackToggle.js";import"../lib/redux/slices/messageSlice/statusMessageState.js";import"../lib/redux/slices/utilsSlice/screenSize.js";import"../lib/redux/slices/authSlice/channelCallbackUrl.js";import"../lib/redux/slices/authSlice/unsplashObject.js";import"@mui/icons-material/DoneOutlined";import"@mui/icons-material/ContentCopyOutlined";import"../status/MultiPurposeModal.js";import N from"./SideNavSearch.js";import{resolveSideNavActive as S,findFlaggedActive as j,containsNavId as w}from"./sideNavMatch.js";var y=function(y){var C,k=y.items,E=y.defaultExpanded,D=void 0===E||E,I=y.isExpanded,M=y.onExpandedChange,_=y.position,L=void 0===_?"left":_,O=y.variant,z=void 0===O?"default":O,A=y.expandedWidth,F=void 0===A?240:A,T=y.collapsedWidth,B=void 0===T?64:T,P=y.animation,U=void 0===P?"slide":P,W=y.logo,K=y.footer,R=y.className,V=void 0===R?"":R,X=y.darkMode,q=void 0!==X&&X,G=y.positioning,H=y.resizable,J=void 0!==H&&H,Q=y.maxWidth,Y=void 0===Q?400:Q,Z=y.minWidth,$=void 0===Z?180:Z,ee=y.onNavigate,ie=y.autoCollapseOnMobile,ne=void 0===ie||ie,te=y.showBackdrop,ae=void 0===te||te,re=y.onBackdropClick,se=y.enableTouchGestures,ce=void 0===se||se,oe=y.persistState,le=void 0===oe||oe,de=y.persistStateKey,ue=void 0===de?"ihub-sidenav-expanded":de,he=y.lazyRender,ve=void 0!==he&&he,me=y.renderItem,be=y.tooltip,pe=y.toggleShortcut,fe=y.contentContainerClassName,ge=void 0===fe?"":fe,xe=y.activePath,Ne=y.search,Se=y.children,je="ihub-sidenav-".concat(o().replace(/:/g,"")),we=void 0!==I,ye=l(D),Ce=e(ye,2),ke=Ce[0],Ee=Ce[1];d(function(){if(we)Ee(I);else if(le&&"undefined"!=typeof window){var e=localStorage.getItem(ue);null!==e&&Ee("true"===e)}},[we,I,le,ue]),d(function(){we&&Ee(I)},[we,I]);var De=function(){return we?I:ke},Ie=function(e){we||(Ee(e),le&&"undefined"!=typeof window&&localStorage.setItem(ue,String(e))),null==M||M(e)},Me=function(){return Ie(!De())},_e=u(function(){return void 0!==xe?S(k,xe):j(k)},[k,xe]),Le=_e.ancestorIds.join("|"),Oe=l(_e.id),ze=e(Oe,2),Ae=ze[0],Fe=ze[1],Te=l(function(){return new Set(_e.ancestorIds)}),Be=e(Te,2),Pe=Be[0],Ue=Be[1],We="".concat(ue,"-sections"),Ke=l(function(){var e=new Set;return k.forEach(function(i){"section"===i.type&&i.defaultCollapsed&&e.add(i.id)}),_e.ancestorIds.forEach(function(i){return e.delete(i)}),e}),Re=e(Ke,2),Ve=Re[0],Xe=Re[1];d(function(){_e.id&&Fe(_e.id)},[_e.id]),d(function(){if(le&&"undefined"!=typeof window)try{var n=JSON.parse(localStorage.getItem(We)||"null");n&&"object"===i(n)&&Xe(function(i){var t=new Set(i);return Object.entries(n).forEach(function(i){var n=e(i,2),a=n[0];n[1]&&!_e.ancestorIds.includes(a)?t.add(a):t.delete(a)}),t})}catch(e){}},[le,We]),d(function(){var e=[],i=function(n){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];n.forEach(function(n){"section"===n.type?i(n.children,t):"group"===n.type&&(n.defaultExpanded||t?(e.push(n.id),i(n.children,!0)):i(n.children,!1))})};i(k),e.length&&Ue(function(i){return e.every(function(e){return i.has(e)})?i:new Set([].concat(n(i),e))})},[k]),d(function(){_e.ancestorIds.length&&(Ue(function(e){return _e.ancestorIds.every(function(i){return e.has(i)})?e:new Set([].concat(n(e),n(_e.ancestorIds)))}),Xe(function(e){return _e.ancestorIds.some(function(i){return e.has(i)})?new Set(n(e).filter(function(e){return!_e.ancestorIds.includes(e)})):e}))},[Le]);var qe=h(function(e,i){"button"===e.type&&e.onClick(i),"link"===e.type&&Fe(e.id),null==ee||ee(e,i),ne&&window.innerWidth<=768&&Ie(!1)},[ee,ne,Ie]),Ge=l(!1),He=e(Ge,2),Je=He[0],Qe=He[1];d(function(){var e=function(){Qe(window.innerWidth<=768)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}},[]),d(function(){if(pe){var e=function(e){var i=pe.toLowerCase().split("+"),n=i.filter(function(e){return["ctrl","alt","shift","meta"].includes(e)}),t=i.find(function(e){return!["ctrl","alt","shift","meta"].includes(e)});t&&(e.key||"").toLowerCase()===t&&n.every(function(i){switch(i){case"ctrl":return e.ctrlKey;case"alt":return e.altKey;case"shift":return e.shiftKey;case"meta":return e.metaKey;default:return!1}})&&(e.preventDefault(),Me())};return document.addEventListener("keydown",e),function(){return document.removeEventListener("keydown",e)}}},[pe,Me]);var Ye=l(De()?F:B),Ze=e(Ye,2),$e=Ze[0],ei=Ze[1],ii=v(!1),ni=v(null),ti=v(null);d(function(){var e=window.requestAnimationFrame(function(){var e,i=null===(e=ti.current)||void 0===e?void 0:e.querySelector('[aria-current="page"]'),n=ti.current;if(i&&n){var t=i.getBoundingClientRect(),a=n.getBoundingClientRect();(t.top<a.top||t.bottom>a.bottom)&&i.scrollIntoView({block:"center"})}});return function(){return window.cancelAnimationFrame(e)}},[Ae,Pe,Ve]),d(function(){ei(De()?F:B)},[De,F,B]);var ai=v(null),ri=function(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(me)return me(e,i);switch(e.type){case"link":return si(e,i);case"group":return ci(e,i);case"button":return oi(e,i);case"divider":return di(e);case"section":return li(e);default:return null}},si=function(e,i){if(e.hasAccess&&!e.hasAccess())return null;var n=e.id===Ae||void 0===xe&&!!e.isActive,t=i>0?"ihub-sidenav-indent-".concat(i):"",c=a(s,{children:[e.icon&&r("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?r(b,{src:e.icon,alt:"",width:24,height:24}):e.icon}),r("span",{className:"ihub-sidenav-text ".concat(De()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&r("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content})]});return e.isExternal?r("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:"ihub-sidenav-item ihub-sidenav-link ".concat(t," ").concat(n?"ihub-sidenav-active":""," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),onClick:function(i){return!e.isDisabled&&qe(e,i)},"data-tooltip":!De()&&null!=be&&be.enabled?e.title:void 0,"aria-disabled":e.isDisabled,children:c}):r(m,{href:e.href,className:"ihub-sidenav-item ihub-sidenav-link ".concat(t," ").concat(n&&0===i?"ihub-sidenav-active":n?"ihub-sidenav-child-active":""," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),"aria-current":n?"page":void 0,onClick:function(i){return!e.isDisabled&&qe(e,i)},"data-tooltip":!De()&&null!=be&&be.enabled?e.title:void 0,"aria-disabled":e.isDisabled,children:c})},ci=function(e,i){var n=Pe.has(e.id),t=w(e,Ae),s=i>0?"ihub-sidenav-indent-".concat(i):"";return e.hideGroupTitle?r("div",{className:"ihub-sidenav-group ".concat(e.className||""),children:e.children.map(function(e,n){return r(c.Fragment,{children:ri(e,i)},e.id||"group-child-".concat(n))})}):a("div",{className:"ihub-sidenav-group ".concat(e.className||""," ").concat(t?"ihub-sidenav-group-active":""),children:[a("div",{className:"ihub-sidenav-item ihub-sidenav-group-header ".concat(e.isActive?"ihub-sidenav-active":""," ").concat(s," ").concat(e.isDisabled?"ihub-sidenav-disabled":""),onClick:function(){return!e.isDisabled&&(i=e.id,void Ue(function(e){var n=new Set(e);return n.has(i)?n.delete(i):n.add(i),n}));var i},"data-tooltip":!De()&&null!=be&&be.enabled?e.title:void 0,"aria-disabled":e.isDisabled,"aria-expanded":n,children:[e.icon&&r("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?r(b,{src:e.icon,alt:"",width:24,height:24}):e.icon}),r("span",{className:"ihub-sidenav-text ".concat(De()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&r("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content}),r("span",{className:"ihub-sidenav-arrow ".concat(n?"ihub-sidenav-arrow-expanded":""," ").concat(De()?"":"ihub-sidenav-arrow-hidden")})]}),(n||!De())&&r("div",{className:"ihub-sidenav-group-items ".concat(n?"ihub-sidenav-group-expanded":""," ").concat(De()?"":"ihub-sidenav-group-collapsed"),children:(!ve||n||!De())&&e.children.map(function(e,n){return r(c.Fragment,{children:ri(e,i+1)},e.id||"group-child-".concat(n))})})]})},oi=function(e,i){var n=i>0?"ihub-sidenav-indent-".concat(i):"";return a("button",{className:"ihub-sidenav-item ihub-sidenav-button ".concat(n," ").concat(e.isDisabled?"ihub-sidenav-disabled":""," ").concat(e.className||""),onClick:function(i){return!e.isDisabled&&qe(e,i)},"data-tooltip":!De()&&null!=be&&be.enabled?e.title:void 0,disabled:e.isDisabled,children:[e.icon&&r("span",{className:"ihub-sidenav-icon",children:"string"==typeof e.icon?r(b,{src:e.icon,alt:"",width:24,height:24}):e.icon}),r("span",{className:"ihub-sidenav-text ".concat(De()?"":"ihub-sidenav-text-hidden"),children:e.title}),e.badge&&r("span",{className:"ihub-sidenav-badge ihub-sidenav-badge-".concat(e.badge.variant||"default"),children:e.badge.content})]})},li=function(e){var i=De(),n=!1!==e.collapsible,t=i&&n&&Ve.has(e.id),s="".concat(je,"-section-").concat(e.id),o=w(e,Ae);return a("div",{className:"ihub-sidenav-section ".concat(e.className||""," ").concat(o?"ihub-sidenav-section-active":""),children:[i&&(n?a("button",{type:"button",className:"ihub-sidenav-section-head","aria-expanded":!t,"aria-controls":s,onClick:function(){return i=e.id,void Xe(function(e){var n=new Set(e);if(n.has(i)?n.delete(i):n.add(i),le&&"undefined"!=typeof window)try{var t={};k.forEach(function(e){"section"===e.type&&(t[e.id]=n.has(e.id))}),localStorage.setItem(We,JSON.stringify(t))}catch(e){}return n});var i},children:[r("span",{className:"ihub-sidenav-section-title",children:e.title}),t&&o&&r("span",{className:"ihub-sidenav-section-dot","aria-label":"Current page is here"}),t&&r("span",{className:"ihub-sidenav-section-count",children:e.children.filter(function(e){return"divider"!==e.type}).length}),r("span",{className:"ihub-sidenav-section-chevron","aria-hidden":"true",children:r(g,{})})]}):r("div",{className:"ihub-sidenav-section-head ihub-sidenav-section-head-static",children:r("span",{className:"ihub-sidenav-section-title",children:e.title})})),!t&&r("div",{id:s,className:"ihub-sidenav-section-items",children:e.children.map(function(e,i){return r(c.Fragment,{children:ri(e,0)},e.id||"section-child-".concat(i))})})]})},di=function(e,i){return r("div",{className:"ihub-sidenav-divider",children:e.title&&De()&&r("span",{className:"ihub-sidenav-divider-text",children:e.title})})},ui=!0===Ne?{}:Ne||null,hi=function(e){return r("div",{ref:ti,className:"ihub-sidenav-content ihub-scrollbar-thin-light ".concat(null!=W&&W.href||ui?"":"ihub-mt-2"),children:null!=e?e:r("nav",{className:"ihub-sidenav-nav",children:k.map(function(e,i){return r(c.Fragment,{children:ri(e)},e.id||"nav-item-".concat(i))})})})},vi=["ihub-sidenav","ihub-sidenav-".concat(L),"ihub-sidenav-".concat(z),De()?"ihub-sidenav-expanded":"ihub-sidenav-collapsed",q?"ihub-sidenav-dark":"",J&&De()?"ihub-sidenav-resizable":"",Je?"ihub-sidenav-mobile":"","none"!==U?"ihub-sidenav-".concat(U):"",V].filter(Boolean).join(" "),mi=t(t(t({width:"number"==typeof $e?"".concat($e,"px"):$e},null!=G&&G.fixed?{position:"fixed"}:{}),void 0!==(null==G?void 0:G.top)?{top:G.top}:{}),void 0!==(null==G?void 0:G.zIndex)?{zIndex:G.zIndex}:{}),bi=["ihub-sidenav-container","ihub-sidenav-container-".concat(L),De()?"ihub-sidenav-container-expanded":"ihub-sidenav-container-collapsed",ge].filter(Boolean).join(" "),pi={"--ihub-sidenav-width":"number"==typeof $e?"".concat($e,"px"):$e};return a("div",{className:bi,style:pi,children:[Je&&De()&&ae&&r("div",{className:"ihub-sidenav-backdrop",onClick:function(){Ie(!1),null==re||re()}}),a("div",{ref:ni,className:vi,style:mi,onTouchStart:function(e){ce&&Je&&(ai.current=e.touches[0].clientX)},onTouchMove:function(e){if(ce&&Je&&null!==ai.current){var i=e.touches[0].clientX-ai.current;Math.abs(i)>=50&&(Ie("left"===L&&i>0||"right"===L&&i<0),ai.current=null)}},onTouchEnd:function(){ai.current=null},children:[r("button",{className:"ihub-sidenav-toggle",onClick:Me,"aria-expanded":De(),"aria-label":De()?"Collapse sidebar":"Expand sidebar",children:"left"===L?De()?r(p,{}):r(f,{className:"ihub-ml-2"}):De()?r(f,{}):r(p,{className:"ihub-mr-2"})}),(null==W?void 0:W.href)&&r("div",{className:"ihub-sidenav-logo",children:r(m,{href:W.href||"",children:De()||!W.src?r(b,{src:W.src,alt:W.alt,width:W.width||120,height:W.height||40}):W.miniSrc&&r(b,{src:W.miniSrc,alt:W.alt,width:W.height||40,height:W.height||40})})}),J&&De()&&r("div",{className:"ihub-sidenav-resize-handle ihub-sidenav-resize-handle-".concat(L),onMouseDown:function(e){if(J&&De()){e.preventDefault(),ii.current=!0;var i=function(e){var i;ii.current&&(i="left"===L?e.clientX:window.innerWidth-e.clientX,i=Math.max(Number($),Math.min(Number(Y),i)),ei(i))},n=function(){ii.current=!1,document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",n)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",n)}}}),ui&&De()?r(N,{items:k,config:ui,idPrefix:je,shortcutEnabled:!Je||De(),renderResult:function(e,i){var n=e.item,s=i.id,c=i.selected,o=i.label,l=i.onMouseEnter,d=i.onActivated,u=n.icon&&r("span",{className:"ihub-sidenav-icon","aria-hidden":"true",children:"string"==typeof n.icon?r(b,{src:n.icon,alt:"",width:24,height:24}):n.icon}),h={id:s,role:"option","aria-selected":c,className:"ihub-sidenav-item ihub-sidenav-result",onMouseEnter:l};if("button"===n.type)return a("button",t(t({type:"button"},h),{},{onClick:function(e){qe(n,e),d()},children:[u,o]}));var v=function(e){qe(n,e),d()};return n.isExternal?a("a",t(t({href:n.href,target:"_blank",rel:"noopener noreferrer"},h),{},{onClick:v,children:[u,o]})):a(m,t(t({href:n.href},h),{},{onClick:v,children:[u,o]}))},children:function(e){return hi(e)}}):hi(null),K&&a("div",{className:"ihub-sidenav-footer",children:[r(x,{fallback:a("div",{className:"ihub-sidenav-user",children:[r("div",{className:"ihub-sidenav-user-initials",children:"U"}),r("div",{className:"ihub-sidenav-user-info",children:r("div",{className:"ihub-sidenav-user-name",children:"User"})})]}),children:K.showUserProfile&&K.user&&De()&&a("div",{className:"ihub-sidenav-user",children:[K.user.avatar?r(b,{src:"".concat(K.user.avatar),alt:K.user.name||"User",width:40,height:40,className:"ihub-sidenav-user-avatar"}):r("div",{className:"ihub-sidenav-user-initials",children:(null===(C=K.user.name)||void 0===C?void 0:C.charAt(0))||"U"}),a("div",{className:"ihub-sidenav-user-info",children:[K.user.name&&r("div",{className:"ihub-sidenav-user-name",children:K.user.name}),K.user.role&&r("div",{className:"ihub-sidenav-user-role",children:K.user.role})]})]})}),K.actions&&r("div",{className:"ihub-sidenav-footer-actions",children:K.actions.map(function(e,i){return r(c.Fragment,{children:oi(e,0)},e.id||"footer-action-".concat(i))})}),K.content&&r("div",{className:"ihub-sidenav-footer-content",children:De()?K.content:null})]})]}),r("div",{className:"ihub-sidenav-main",children:Se})]})};export{y as default};
|
|
2
2
|
//# sourceMappingURL=SideNavbar.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("../../../_virtual/_rollupPluginBabelHelpers.cjs"),e=function(r){return"group"===r.type||"section"===r.type};function t(r,e){if(!e)return!1;var t=e.split(/[?#]/)[0],n=t.split("/").filter(Boolean).length;return r===t||n>1&&r.startsWith(t+"/")}var n=function(r){return r.toLowerCase().replace(/&/g,"and").replace(/\s+/g," ").trim()};exports.containsNavId=function r(t,n){return!(!n||!e(t))&&t.children.some(function(e){return e.id===n||r(e,n)})},exports.findFlaggedActive=function(t){var n,i=function(t,n){var o,a=r.createForOfIteratorHelper(t);try{for(a.s();!(o=a.n()).done;){var l=o.value;if("section"!==l.type&&"divider"!==l.type&&l.isActive&&!e(l))return{id:l.id,ancestorIds:n};if(e(l)){var c=i(l.children,[].concat(r.toConsumableArray(n),[l.id]));if(c)return c}}}catch(r){a.e(r)}finally{a.f()}return null};return null!==(n=i(t,[]))&&void 0!==n?n:{id:null,ancestorIds:[]}},exports.navPathMatches=t,exports.resolveSideNavActive=function(n,i){var o={id:null,ancestorIds:[],length:-1};if(!i)return{id:null,ancestorIds:[]};var a=function(n,l){n.forEach(function(n){var c;if("link"===n.type&&!n.isExternal&&t(i,n.href)){var s=n.href.length;s>o.length&&(o={id:n.id,ancestorIds:l,length:s})}(e(n)||"link"===n.type&&null!==(c=n.children)&&void 0!==c&&c.length)&&a(n.children,[].concat(r.toConsumableArray(l),[n.id]))})};return a(n,[]),{id:o.id,ancestorIds:o.ancestorIds}},exports.searchSideNav=function(t,i){var o=n(i);if(!o)return[];var a=o.split(" "),l=function(r){var e=n(r.join(" "));return a.every(function(r){return e.includes(r)})},c=[],s=function(t,i,a){t.forEach(function(t){var u,d;if("divider"!==t.type)if(e(t)){var f,v="group"===t.type&&null!==(f=t.keywords)&&void 0!==f?f:[];s(t.children,[].concat(r.toConsumableArray(i),[t.title]),[].concat(r.toConsumableArray(a),r.toConsumableArray(v)))}else if(!t.isDisabled&&("link"!==t.type||!t.hasAccess||t.hasAccess())){var h,p,y=[t.title].concat(r.toConsumableArray(i),r.toConsumableArray(null!==(u=t.keywords)&&void 0!==u?u:[])),m=n(t.title);if((h=l(y)?m.startsWith(o)?0:m.includes(o)?1:2:a.length&&l([].concat(r.toConsumableArray(y),r.toConsumableArray(a)))?3:-1)>=0&&c.push({item:t,trail:i,rank:h,order:c.length}),"link"===t.type&&null!==(d=t.children)&&void 0!==d&&d.length)s(t.children,[].concat(r.toConsumableArray(i),[t.title]),[].concat(r.toConsumableArray(a),r.toConsumableArray(null!==(p=t.keywords)&&void 0!==p?p:[])))}})};s(t,[],[]);var u=c.some(function(r){return r.rank<3}),d=new Set;return c.filter(function(r){return!u||r.rank<3}).sort(function(r,e){return r.rank-e.rank||r.order-e.order}).filter(function(r){var e="link"===r.item.type?r.item.href:"button:".concat(r.item.id);return!d.has(e)&&(d.add(e),!0)}).map(function(r){return{item:r.item,trail:r.trail}})},exports.splitNavMatch=function(r,e){var t=e.trim().toLowerCase(),n=t?r.toLowerCase().indexOf(t):-1;return n<0?[r,"",""]:[r.slice(0,n),r.slice(n,n+t.length),r.slice(n+t.length)]};
|
|
2
|
+
//# sourceMappingURL=sideNavMatch.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sideNavMatch.cjs","sources":["../../../../src/components/navbar/sideNavMatch.ts"],"sourcesContent":["import {\n NavButtonItem,\n NavGroupItem,\n NavItemType,\n NavLinkItem,\n NavSectionItem,\n} from \"../../types/navbar\";\n\n/** Where the current route sits in the menu. */\nexport interface SideNavActive {\n /** Id of the item with the most specific matching href */\n id: string | null;\n /** Ids of the groups and section above it, outermost first */\n ancestorIds: string[];\n}\n\n/** One search hit: always something you can open, never a group. */\nexport interface SideNavSearchResult {\n item: NavLinkItem | NavButtonItem;\n /** Titles of the section and groups above it */\n trail: string[];\n}\n\ntype Container = NavGroupItem | NavSectionItem;\n\nconst isContainer = (item: NavItemType): item is Container =>\n item.type === \"group\" || item.type === \"section\";\n\n/**\n * Whether a menu href covers a route.\n * Single-segment hrefs (\"/\", \"/acme\") match exactly only, otherwise the home\n * link would claim every page.\n * @param pathname Current route\n * @param href Menu destination\n * @returns True when the route is the href or sits beneath it\n */\nexport function navPathMatches(pathname: string, href?: string): boolean {\n if (!href) return false;\n const clean = href.split(/[?#]/)[0];\n const depth = clean.split(\"/\").filter(Boolean).length;\n return pathname === clean || (depth > 1 && pathname.startsWith(clean + \"/\"));\n}\n\n/**\n * Find the item a route belongs to: the internal link with the longest\n * matching href, so /deals/import lights \"Import\" and not \"Deals\" too.\n * @param items Menu items\n * @param pathname Current route\n * @returns Active id and the ids of everything above it\n */\nexport function resolveSideNavActive(\n items: NavItemType[],\n pathname?: string\n): SideNavActive {\n let best: SideNavActive & { length: number } = { id: null, ancestorIds: [], length: -1 };\n if (!pathname) return { id: null, ancestorIds: [] };\n\n const walk = (list: NavItemType[], ancestors: string[]) => {\n list.forEach((item) => {\n if (item.type === \"link\" && !item.isExternal && navPathMatches(pathname, item.href)) {\n const length = item.href.length;\n if (length > best.length) best = { id: item.id, ancestorIds: ancestors, length };\n }\n if (isContainer(item)) walk(item.children, [...ancestors, item.id]);\n else if (item.type === \"link\" && item.children?.length) walk(item.children, [...ancestors, item.id]);\n });\n };\n walk(items, []);\n return { id: best.id, ancestorIds: best.ancestorIds };\n}\n\n/**\n * Find the item flagged `isActive`, at any depth, for menus that do not pass\n * `activePath`.\n * @param items Menu items\n * @returns Active id and the ids of everything above it\n */\nexport function findFlaggedActive(items: NavItemType[]): SideNavActive {\n const walk = (list: NavItemType[], ancestors: string[]): SideNavActive | null => {\n for (const item of list) {\n if (item.type !== \"section\" && item.type !== \"divider\" && item.isActive && !isContainer(item)) {\n return { id: item.id, ancestorIds: ancestors };\n }\n if (isContainer(item)) {\n const found = walk(item.children, [...ancestors, item.id]);\n if (found) return found;\n }\n }\n return null;\n };\n return walk(items, []) ?? { id: null, ancestorIds: [] };\n}\n\n/**\n * Whether `id` is somewhere inside `item`.\n * @param item A group or section\n * @param id Item id to look for\n */\nexport function containsNavId(item: NavItemType, id: string | null): boolean {\n if (!id || !isContainer(item)) return false;\n return item.children.some((child) => child.id === id || containsNavId(child, id));\n}\n\n/** Rank of a hit that matched only through a parent's keywords. */\nconst INHERITED_RANK = 3;\n\nconst normalise = (value: string): string =>\n value.toLowerCase().replace(/&/g, \"and\").replace(/\\s+/g, \" \").trim();\n\n/**\n * Search every link and button in the menu, nested ones included.\n *\n * Every word must appear in the item's title, keywords, or the titles of the\n * groups and section above it. Title prefixes rank first, then title matches,\n * then context matches. A parent's keywords help a child match, but an item\n * matching only through them is dropped when anything matches directly.\n * Hidden (`hasAccess` false) and disabled items are skipped; an href listed\n * twice is returned once.\n * @param items Menu items\n * @param query What the user typed\n * @returns Ranked hits, empty for a blank query\n */\nexport function searchSideNav(items: NavItemType[], query: string): SideNavSearchResult[] {\n const needle = normalise(query);\n if (!needle) return [];\n const words = needle.split(\" \");\n const matchesAll = (parts: string[]) => {\n const haystack = normalise(parts.join(\" \"));\n return words.every((word) => haystack.includes(word));\n };\n\n type Hit = SideNavSearchResult & { rank: number; order: number };\n const hits: Hit[] = [];\n\n const walk = (list: NavItemType[], trail: string[], inherited: string[]) => {\n list.forEach((item) => {\n if (item.type === \"divider\") return;\n if (isContainer(item)) {\n const keywords = item.type === \"group\" ? item.keywords ?? [] : [];\n walk(item.children, [...trail, item.title], [...inherited, ...keywords]);\n return;\n }\n if (item.isDisabled) return;\n if (item.type === \"link\" && item.hasAccess && !item.hasAccess()) return;\n\n const own = [item.title, ...trail, ...(item.keywords ?? [])];\n const title = normalise(item.title);\n let rank: number;\n if (matchesAll(own)) {\n rank = title.startsWith(needle) ? 0 : title.includes(needle) ? 1 : 2;\n } else if (inherited.length && matchesAll([...own, ...inherited])) {\n rank = INHERITED_RANK;\n } else {\n rank = -1;\n }\n if (rank >= 0) hits.push({ item, trail, rank, order: hits.length });\n\n if (item.type === \"link\" && item.children?.length) {\n walk(item.children, [...trail, item.title], [...inherited, ...(item.keywords ?? [])]);\n }\n });\n };\n walk(items, [], []);\n\n const hasDirectHit = hits.some((hit) => hit.rank < INHERITED_RANK);\n const seen = new Set<string>();\n return hits\n .filter((hit) => !hasDirectHit || hit.rank < INHERITED_RANK)\n .sort((a, b) => a.rank - b.rank || a.order - b.order)\n .filter((hit) => {\n const key = hit.item.type === \"link\" ? hit.item.href : `button:${hit.item.id}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n })\n .map(({ item, trail }) => ({ item, trail }));\n}\n\n/**\n * Split a title around the query so the match can be marked.\n * @param title Item title\n * @param query What the user typed\n * @returns [before, match, after]; match is empty when there is no hit\n */\nexport function splitNavMatch(title: string, query: string): [string, string, string] {\n const needle = query.trim().toLowerCase();\n const at = needle ? title.toLowerCase().indexOf(needle) : -1;\n if (at < 0) return [title, \"\", \"\"];\n return [title.slice(0, at), title.slice(at, at + needle.length), title.slice(at + needle.length)];\n}\n"],"names":["isContainer","item","type","navPathMatches","pathname","href","clean","split","depth","filter","Boolean","length","startsWith","normalise","value","toLowerCase","replace","trim","containsNavId","id","children","some","child","items","_walk3","walk","list","ancestors","_step","_iterator","_createForOfIteratorHelper","createForOfIteratorHelper","s","n","done","isActive","ancestorIds","found","concat","_toConsumableArray","toConsumableArray","err","e","f","best","forEach","_item$children","isExternal","query","needle","words","matchesAll","parts","haystack","join","every","word","includes","hits","trail","inherited","_item$keywords2","_item$children2","_item$keywords","keywords","title","isDisabled","hasAccess","rank","_item$keywords3","own","push","order","hasDirectHit","hit","seen","Set","sort","a","b","key","has","add","map","_ref","at","indexOf","slice"],"mappings":"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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{toConsumableArray as n,createForOfIteratorHelper as r}from"../../../_virtual/_rollupPluginBabelHelpers.js";var t=function(n){return"group"===n.type||"section"===n.type};function e(n,r){if(!r)return!1;var t=r.split(/[?#]/)[0],e=t.split("/").filter(Boolean).length;return n===t||e>1&&n.startsWith(t+"/")}function i(r,i){var l={id:null,ancestorIds:[],length:-1};if(!i)return{id:null,ancestorIds:[]};var o=function(r,a){r.forEach(function(r){var c;if("link"===r.type&&!r.isExternal&&e(i,r.href)){var u=r.href.length;u>l.length&&(l={id:r.id,ancestorIds:a,length:u})}(t(r)||"link"===r.type&&null!==(c=r.children)&&void 0!==c&&c.length)&&o(r.children,[].concat(n(a),[r.id]))})};return o(r,[]),{id:l.id,ancestorIds:l.ancestorIds}}function l(e){var i,l=function(e,i){var o,a=r(e);try{for(a.s();!(o=a.n()).done;){var c=o.value;if("section"!==c.type&&"divider"!==c.type&&c.isActive&&!t(c))return{id:c.id,ancestorIds:i};if(t(c)){var u=l(c.children,[].concat(n(i),[c.id]));if(u)return u}}}catch(n){a.e(n)}finally{a.f()}return null};return null!==(i=l(e,[]))&&void 0!==i?i:{id:null,ancestorIds:[]}}function o(n,r){return!(!r||!t(n))&&n.children.some(function(n){return n.id===r||o(n,r)})}var a=function(n){return n.toLowerCase().replace(/&/g,"and").replace(/\s+/g," ").trim()};function c(r,e){var i=a(e);if(!i)return[];var l=i.split(" "),o=function(n){var r=a(n.join(" "));return l.every(function(n){return r.includes(n)})},c=[],u=function(r,e,l){r.forEach(function(r){var s,d;if("divider"!==r.type)if(t(r)){var f,v="group"===r.type&&null!==(f=r.keywords)&&void 0!==f?f:[];u(r.children,[].concat(n(e),[r.title]),[].concat(n(l),n(v)))}else if(!r.isDisabled&&("link"!==r.type||!r.hasAccess||r.hasAccess())){var h,p,y=[r.title].concat(n(e),n(null!==(s=r.keywords)&&void 0!==s?s:[])),g=a(r.title);if((h=o(y)?g.startsWith(i)?0:g.includes(i)?1:2:l.length&&o([].concat(n(y),n(l)))?3:-1)>=0&&c.push({item:r,trail:e,rank:h,order:c.length}),"link"===r.type&&null!==(d=r.children)&&void 0!==d&&d.length)u(r.children,[].concat(n(e),[r.title]),[].concat(n(l),n(null!==(p=r.keywords)&&void 0!==p?p:[])))}})};u(r,[],[]);var s=c.some(function(n){return n.rank<3}),d=new Set;return c.filter(function(n){return!s||n.rank<3}).sort(function(n,r){return n.rank-r.rank||n.order-r.order}).filter(function(n){var r="link"===n.item.type?n.item.href:"button:".concat(n.item.id);return!d.has(r)&&(d.add(r),!0)}).map(function(n){return{item:n.item,trail:n.trail}})}function u(n,r){var t=r.trim().toLowerCase(),e=t?n.toLowerCase().indexOf(t):-1;return e<0?[n,"",""]:[n.slice(0,e),n.slice(e,e+t.length),n.slice(e+t.length)]}export{o as containsNavId,l as findFlaggedActive,e as navPathMatches,i as resolveSideNavActive,c as searchSideNav,u as splitNavMatch};
|
|
2
|
+
//# sourceMappingURL=sideNavMatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sideNavMatch.js","sources":["../../../../src/components/navbar/sideNavMatch.ts"],"sourcesContent":["import {\n NavButtonItem,\n NavGroupItem,\n NavItemType,\n NavLinkItem,\n NavSectionItem,\n} from \"../../types/navbar\";\n\n/** Where the current route sits in the menu. */\nexport interface SideNavActive {\n /** Id of the item with the most specific matching href */\n id: string | null;\n /** Ids of the groups and section above it, outermost first */\n ancestorIds: string[];\n}\n\n/** One search hit: always something you can open, never a group. */\nexport interface SideNavSearchResult {\n item: NavLinkItem | NavButtonItem;\n /** Titles of the section and groups above it */\n trail: string[];\n}\n\ntype Container = NavGroupItem | NavSectionItem;\n\nconst isContainer = (item: NavItemType): item is Container =>\n item.type === \"group\" || item.type === \"section\";\n\n/**\n * Whether a menu href covers a route.\n * Single-segment hrefs (\"/\", \"/acme\") match exactly only, otherwise the home\n * link would claim every page.\n * @param pathname Current route\n * @param href Menu destination\n * @returns True when the route is the href or sits beneath it\n */\nexport function navPathMatches(pathname: string, href?: string): boolean {\n if (!href) return false;\n const clean = href.split(/[?#]/)[0];\n const depth = clean.split(\"/\").filter(Boolean).length;\n return pathname === clean || (depth > 1 && pathname.startsWith(clean + \"/\"));\n}\n\n/**\n * Find the item a route belongs to: the internal link with the longest\n * matching href, so /deals/import lights \"Import\" and not \"Deals\" too.\n * @param items Menu items\n * @param pathname Current route\n * @returns Active id and the ids of everything above it\n */\nexport function resolveSideNavActive(\n items: NavItemType[],\n pathname?: string\n): SideNavActive {\n let best: SideNavActive & { length: number } = { id: null, ancestorIds: [], length: -1 };\n if (!pathname) return { id: null, ancestorIds: [] };\n\n const walk = (list: NavItemType[], ancestors: string[]) => {\n list.forEach((item) => {\n if (item.type === \"link\" && !item.isExternal && navPathMatches(pathname, item.href)) {\n const length = item.href.length;\n if (length > best.length) best = { id: item.id, ancestorIds: ancestors, length };\n }\n if (isContainer(item)) walk(item.children, [...ancestors, item.id]);\n else if (item.type === \"link\" && item.children?.length) walk(item.children, [...ancestors, item.id]);\n });\n };\n walk(items, []);\n return { id: best.id, ancestorIds: best.ancestorIds };\n}\n\n/**\n * Find the item flagged `isActive`, at any depth, for menus that do not pass\n * `activePath`.\n * @param items Menu items\n * @returns Active id and the ids of everything above it\n */\nexport function findFlaggedActive(items: NavItemType[]): SideNavActive {\n const walk = (list: NavItemType[], ancestors: string[]): SideNavActive | null => {\n for (const item of list) {\n if (item.type !== \"section\" && item.type !== \"divider\" && item.isActive && !isContainer(item)) {\n return { id: item.id, ancestorIds: ancestors };\n }\n if (isContainer(item)) {\n const found = walk(item.children, [...ancestors, item.id]);\n if (found) return found;\n }\n }\n return null;\n };\n return walk(items, []) ?? { id: null, ancestorIds: [] };\n}\n\n/**\n * Whether `id` is somewhere inside `item`.\n * @param item A group or section\n * @param id Item id to look for\n */\nexport function containsNavId(item: NavItemType, id: string | null): boolean {\n if (!id || !isContainer(item)) return false;\n return item.children.some((child) => child.id === id || containsNavId(child, id));\n}\n\n/** Rank of a hit that matched only through a parent's keywords. */\nconst INHERITED_RANK = 3;\n\nconst normalise = (value: string): string =>\n value.toLowerCase().replace(/&/g, \"and\").replace(/\\s+/g, \" \").trim();\n\n/**\n * Search every link and button in the menu, nested ones included.\n *\n * Every word must appear in the item's title, keywords, or the titles of the\n * groups and section above it. Title prefixes rank first, then title matches,\n * then context matches. A parent's keywords help a child match, but an item\n * matching only through them is dropped when anything matches directly.\n * Hidden (`hasAccess` false) and disabled items are skipped; an href listed\n * twice is returned once.\n * @param items Menu items\n * @param query What the user typed\n * @returns Ranked hits, empty for a blank query\n */\nexport function searchSideNav(items: NavItemType[], query: string): SideNavSearchResult[] {\n const needle = normalise(query);\n if (!needle) return [];\n const words = needle.split(\" \");\n const matchesAll = (parts: string[]) => {\n const haystack = normalise(parts.join(\" \"));\n return words.every((word) => haystack.includes(word));\n };\n\n type Hit = SideNavSearchResult & { rank: number; order: number };\n const hits: Hit[] = [];\n\n const walk = (list: NavItemType[], trail: string[], inherited: string[]) => {\n list.forEach((item) => {\n if (item.type === \"divider\") return;\n if (isContainer(item)) {\n const keywords = item.type === \"group\" ? item.keywords ?? [] : [];\n walk(item.children, [...trail, item.title], [...inherited, ...keywords]);\n return;\n }\n if (item.isDisabled) return;\n if (item.type === \"link\" && item.hasAccess && !item.hasAccess()) return;\n\n const own = [item.title, ...trail, ...(item.keywords ?? [])];\n const title = normalise(item.title);\n let rank: number;\n if (matchesAll(own)) {\n rank = title.startsWith(needle) ? 0 : title.includes(needle) ? 1 : 2;\n } else if (inherited.length && matchesAll([...own, ...inherited])) {\n rank = INHERITED_RANK;\n } else {\n rank = -1;\n }\n if (rank >= 0) hits.push({ item, trail, rank, order: hits.length });\n\n if (item.type === \"link\" && item.children?.length) {\n walk(item.children, [...trail, item.title], [...inherited, ...(item.keywords ?? [])]);\n }\n });\n };\n walk(items, [], []);\n\n const hasDirectHit = hits.some((hit) => hit.rank < INHERITED_RANK);\n const seen = new Set<string>();\n return hits\n .filter((hit) => !hasDirectHit || hit.rank < INHERITED_RANK)\n .sort((a, b) => a.rank - b.rank || a.order - b.order)\n .filter((hit) => {\n const key = hit.item.type === \"link\" ? hit.item.href : `button:${hit.item.id}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n })\n .map(({ item, trail }) => ({ item, trail }));\n}\n\n/**\n * Split a title around the query so the match can be marked.\n * @param title Item title\n * @param query What the user typed\n * @returns [before, match, after]; match is empty when there is no hit\n */\nexport function splitNavMatch(title: string, query: string): [string, string, string] {\n const needle = query.trim().toLowerCase();\n const at = needle ? title.toLowerCase().indexOf(needle) : -1;\n if (at < 0) return [title, \"\", \"\"];\n return [title.slice(0, at), title.slice(at, at + needle.length), title.slice(at + needle.length)];\n}\n"],"names":["isContainer","item","type","navPathMatches","pathname","href","clean","split","depth","filter","Boolean","length","startsWith","resolveSideNavActive","items","best","id","ancestorIds","walk","list","ancestors","forEach","_item$children","isExternal","children","concat","_toConsumableArray","findFlaggedActive","_walk3","_step","_iterator","_createForOfIteratorHelper","s","n","done","value","isActive","found","err","e","f","containsNavId","some","child","normalise","toLowerCase","replace","trim","searchSideNav","query","needle","words","matchesAll","parts","haystack","join","every","word","includes","hits","trail","inherited","_item$keywords2","_item$children2","_item$keywords","keywords","title","isDisabled","hasAccess","rank","_item$keywords3","own","push","order","hasDirectHit","hit","seen","Set","sort","a","b","key","has","add","map","_ref","splitNavMatch","at","indexOf","slice"],"mappings":"kHAyBA,IAAMA,EAAc,SAACC,GAAiB,MACtB,UAAdA,EAAKC,MAAkC,YAAdD,EAAKC,IAAkB,EAUlC,SAAAC,EAAeC,EAAkBC,GAC/C,IAAKA,EAAM,OAAO,EAClB,IAAMC,EAAQD,EAAKE,MAAM,QAAQ,GAC3BC,EAAQF,EAAMC,MAAM,KAAKE,OAAOC,SAASC,OAC/C,OAAOP,IAAaE,GAAUE,EAAQ,GAAKJ,EAASQ,WAAWN,EAAQ,IACzE,CASgB,SAAAO,EACdC,EACAV,GAEA,IAAIW,EAA2C,CAAEC,GAAI,KAAMC,YAAa,GAAIN,QAAS,GACrF,IAAKP,EAAU,MAAO,CAAEY,GAAI,KAAMC,YAAa,IAE/C,IAAMC,EAAO,SAACC,EAAqBC,GACjCD,EAAKE,QAAQ,SAACpB,GAAQ,IAAAqB,EACpB,GAAkB,SAAdrB,EAAKC,OAAoBD,EAAKsB,YAAcpB,EAAeC,EAAUH,EAAKI,MAAO,CACnF,IAAMM,EAASV,EAAKI,KAAKM,OACrBA,EAASI,EAAKJ,SAAQI,EAAO,CAAEC,GAAIf,EAAKe,GAAIC,YAAaG,EAAWT,OAAAA,GACzE,EACGX,EAAYC,IACO,SAAdA,EAAKC,MAAgC,QAAjBoB,EAAIrB,EAAKuB,gBAAQ,IAAAF,GAAbA,EAAeX,SADzBO,EAAKjB,EAAKuB,SAAQ,GAAAC,OAAAC,EAAMN,GAAS,CAAEnB,EAAKe,KAEjE,IAGF,OADAE,EAAKJ,EAAO,IACL,CAAEE,GAAID,EAAKC,GAAIC,YAAaF,EAAKE,YAC1C,CAQM,SAAUU,EAAkBb,GAAoB,IAAAc,EAC9CV,EAAO,SAACC,EAAqBC,GAA6C,IACvDS,EADuDC,EAAAC,EAC3DZ,GAAI,IAAvB,IAAAW,EAAAE,MAAAH,EAAAC,EAAAG,KAAAC,MAAyB,CAAA,IAAdjC,EAAI4B,EAAAM,MACb,GAAkB,YAAdlC,EAAKC,MAAoC,YAAdD,EAAKC,MAAsBD,EAAKmC,WAAapC,EAAYC,GACtF,MAAO,CAAEe,GAAIf,EAAKe,GAAIC,YAAaG,GAErC,GAAIpB,EAAYC,GAAO,CACrB,IAAMoC,EAAQnB,EAAKjB,EAAKuB,SAAQC,GAAAA,OAAAC,EAAMN,GAAS,CAAEnB,EAAKe,MACtD,GAAIqB,EAAO,OAAOA,CACnB,CACF,CAAA,CAAA,MAAAC,GAAAR,EAAAS,EAAAD,EAAA,CAAA,QAAAR,EAAAU,GAAA,CACD,OAAO,MAET,OAAsBZ,QAAtBA,EAAOV,EAAKJ,EAAO,WAAGc,IAAAA,EAAAA,EAAI,CAAEZ,GAAI,KAAMC,YAAa,GACrD,CAOgB,SAAAwB,EAAcxC,EAAmBe,GAC/C,SAAKA,IAAOhB,EAAYC,KACjBA,EAAKuB,SAASkB,KAAK,SAACC,GAAK,OAAKA,EAAM3B,KAAOA,GAAMyB,EAAcE,EAAO3B,IAC/E,CAGA,IAEM4B,EAAY,SAACT,GAAa,OAC9BA,EAAMU,cAAcC,QAAQ,KAAM,OAAOA,QAAQ,OAAQ,KAAKC,MAAM,EAetD,SAAAC,EAAclC,EAAsBmC,GAClD,IAAMC,EAASN,EAAUK,GACzB,IAAKC,EAAQ,MAAO,GACpB,IAAMC,EAAQD,EAAO3C,MAAM,KACrB6C,EAAa,SAACC,GAClB,IAAMC,EAAWV,EAAUS,EAAME,KAAK,MACtC,OAAOJ,EAAMK,MAAM,SAACC,GAAI,OAAKH,EAASI,SAASD,MAI3CE,EAAc,GAEdzC,EAAO,SAACC,EAAqByC,EAAiBC,GAClD1C,EAAKE,QAAQ,SAACpB,GAAQ,IAAA6D,EAAAC,EACpB,GAAkB,YAAd9D,EAAKC,KACT,GAAIF,EAAYC,GAAhB,CAAuB,IAAA+D,EACfC,EAAyB,UAAdhE,EAAKC,cAAgB8D,EAAG/D,EAAKgE,gBAAQ,IAAAD,EAAAA,EAAS,GAC/D9C,EAAKjB,EAAKuB,SAAQ,GAAAC,OAAAC,EAAMkC,GAAO3D,CAAAA,EAAKiE,QAAK,GAAAzC,OAAAC,EAAOmC,GAASnC,EAAKuC,IAE/D,MACD,IAAIhE,EAAKkE,aACS,SAAdlE,EAAKC,OAAmBD,EAAKmE,WAAcnE,EAAKmE,aAApD,CAEA,IAEIC,EAU+CC,EAZ7CC,EAAOtE,CAAAA,EAAKiE,OAAKzC,OAAAC,EAAKkC,GAAKlC,EAAmBoC,QAAnBA,EAAM7D,EAAKgE,gBAAQH,IAAAA,EAAAA,EAAI,KAClDI,EAAQtB,EAAU3C,EAAKiE,OAW7B,IAREG,EADEjB,EAAWmB,GACNL,EAAMtD,WAAWsC,GAAU,EAAIgB,EAAMR,SAASR,GAAU,EAAI,EAC1DW,EAAUlD,QAAUyC,EAAU3B,GAAAA,OAAAC,EAAK6C,GAAG7C,EAAKmC,KA9CrC,GAiDP,IAEE,GAAGF,EAAKa,KAAK,CAAEvE,KAAAA,EAAM2D,MAAAA,EAAOS,KAAAA,EAAMI,MAAOd,EAAKhD,SAExC,SAAdV,EAAKC,MAAgC6D,QAAjBA,EAAI9D,EAAKuB,oBAAQuC,GAAbA,EAAepD,OACzCO,EAAKjB,EAAKuB,YAAQC,OAAAC,EAAMkC,GAAO3D,CAAAA,EAAKiE,WAAKzC,OAAAC,EAAOmC,GAASnC,EAAmB,QAAnB4C,EAAMrE,EAAKgE,gBAAQK,IAAAA,EAAAA,EAAI,KAfjB,CAiBnE,IAEFpD,EAAKJ,EAAO,GAAI,IAEhB,IAAM4D,EAAef,EAAKjB,KAAK,SAACiC,GAAG,OAAKA,EAAIN,KA5DvB,IA6DfO,EAAO,IAAIC,IACjB,OAAOlB,EACJlD,OAAO,SAACkE,GAAG,OAAMD,GAAgBC,EAAIN,KA/DnB,CA+DwC,GAC1DS,KAAK,SAACC,EAAGC,GAAC,OAAKD,EAAEV,KAAOW,EAAEX,MAAQU,EAAEN,MAAQO,EAAEP,KAAK,GACnDhE,OAAO,SAACkE,GACP,IAAMM,EAAwB,SAAlBN,EAAI1E,KAAKC,KAAkByE,EAAI1E,KAAKI,KAAI,UAAAoB,OAAakD,EAAI1E,KAAKe,IAC1E,OAAI4D,EAAKM,IAAID,KACbL,EAAKO,IAAIF,IACF,EACT,GACCG,IAAI,SAAAC,GAAc,MAAQ,CAAEpF,KAAjBoF,EAAJpF,KAA2B2D,MAAhByB,EAALzB,MAA4B,EAC9C,CAQgB,SAAA0B,EAAcpB,EAAejB,GAC3C,IAAMC,EAASD,EAAMF,OAAOF,cACtB0C,EAAKrC,EAASgB,EAAMrB,cAAc2C,QAAQtC,IAAW,EAC3D,OAAIqC,EAAK,EAAU,CAACrB,EAAO,GAAI,IACxB,CAACA,EAAMuB,MAAM,EAAGF,GAAKrB,EAAMuB,MAAMF,EAAIA,EAAKrC,EAAOvC,QAASuD,EAAMuB,MAAMF,EAAKrC,EAAOvC,QAC3F"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public URL of an object the uploaders wrote to S3 / Spaces.
|
|
3
|
+
*
|
|
4
|
+
* The uploaders write to `${keyLocation}/${key}` where keyLocation is either
|
|
5
|
+
* NEXT_PUBLIC_AWS_LOCATION (videos) or NEXT_PUBLIC_AWS_LOCATION_FILES. They
|
|
6
|
+
* used to report `${FILE_URL}creators/${key}`, which is only right for the
|
|
7
|
+
* files location, so every video upload returned a URL that 403s.
|
|
8
|
+
*
|
|
9
|
+
* NEXT_PUBLIC_FILE_URL is the CDN origin plus the start of the files
|
|
10
|
+
* location (e.g. `https://cdn.example.com/prod_env/social-files/` for
|
|
11
|
+
* `prod_env/social-files/creators`). The CDN base is FILE_URL with that
|
|
12
|
+
* shared tail removed, and the URL is that base plus the key actually written.
|
|
13
|
+
*/
|
|
14
|
+
/** CDN base (ending in "/") that object keys are appended to. */
|
|
15
|
+
export declare const cdnBaseUrl: (fileUrl: string, filesLocation?: string) => string;
|
|
16
|
+
/** Public URL for `fullKey`, the exact key passed to S3 as `Key`. */
|
|
17
|
+
export declare const uploadedFileUrl: (fullKey: string, fileUrl: string, filesLocation?: string) => string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { NavItemType, SideNavSearchConfig } from "../../types/navbar";
|
|
3
|
+
import { SideNavSearchResult } from "./sideNavMatch";
|
|
4
|
+
interface SideNavSearchProps {
|
|
5
|
+
items: NavItemType[];
|
|
6
|
+
config: SideNavSearchConfig;
|
|
7
|
+
/** Unique prefix for ids (several sidebars can share a page) */
|
|
8
|
+
idPrefix: string;
|
|
9
|
+
/** Renders one hit; must return the clickable element for that item */
|
|
10
|
+
renderResult: (result: SideNavSearchResult, props: {
|
|
11
|
+
id: string;
|
|
12
|
+
selected: boolean;
|
|
13
|
+
label: React.ReactNode;
|
|
14
|
+
onMouseEnter: () => void;
|
|
15
|
+
onActivated: () => void;
|
|
16
|
+
}) => React.ReactNode;
|
|
17
|
+
/** Whether the "/" shortcut listens (the menu is on screen) */
|
|
18
|
+
shortcutEnabled: boolean;
|
|
19
|
+
/** Renders the area below the field: the result list, or null for "show the menu" */
|
|
20
|
+
children: (results: React.ReactNode | null) => React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Search field and result list for SideNavbar. The shortcut key focuses it,
|
|
24
|
+
* arrows move through the hits, Enter opens one, Escape clears.
|
|
25
|
+
*/
|
|
26
|
+
declare const SideNavSearch: ({ items, config, idPrefix, renderResult, shortcutEnabled, children, }: SideNavSearchProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export default SideNavSearch;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { SideNavbarProps } from "../../types/navbar";
|
|
2
|
-
declare const SideNavbar: ({ items, defaultExpanded, isExpanded: controlledExpanded, onExpandedChange, position, variant, expandedWidth, collapsedWidth, animation, logo, footer, className, darkMode, positioning, resizable, maxWidth, minWidth, onNavigate, autoCollapseOnMobile, showBackdrop, onBackdropClick, enableTouchGestures, persistState, persistStateKey, lazyRender, renderItem, tooltip, toggleShortcut, contentContainerClassName, children, }: SideNavbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
declare const SideNavbar: ({ items, defaultExpanded, isExpanded: controlledExpanded, onExpandedChange, position, variant, expandedWidth, collapsedWidth, animation, logo, footer, className, darkMode, positioning, resizable, maxWidth, minWidth, onNavigate, autoCollapseOnMobile, showBackdrop, onBackdropClick, enableTouchGestures, persistState, persistStateKey, lazyRender, renderItem, tooltip, toggleShortcut, contentContainerClassName, activePath, search, children, }: SideNavbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default SideNavbar;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { NavButtonItem, NavItemType, NavLinkItem } from "../../types/navbar";
|
|
2
|
+
/** Where the current route sits in the menu. */
|
|
3
|
+
export interface SideNavActive {
|
|
4
|
+
/** Id of the item with the most specific matching href */
|
|
5
|
+
id: string | null;
|
|
6
|
+
/** Ids of the groups and section above it, outermost first */
|
|
7
|
+
ancestorIds: string[];
|
|
8
|
+
}
|
|
9
|
+
/** One search hit: always something you can open, never a group. */
|
|
10
|
+
export interface SideNavSearchResult {
|
|
11
|
+
item: NavLinkItem | NavButtonItem;
|
|
12
|
+
/** Titles of the section and groups above it */
|
|
13
|
+
trail: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Whether a menu href covers a route.
|
|
17
|
+
* Single-segment hrefs ("/", "/acme") match exactly only, otherwise the home
|
|
18
|
+
* link would claim every page.
|
|
19
|
+
* @param pathname Current route
|
|
20
|
+
* @param href Menu destination
|
|
21
|
+
* @returns True when the route is the href or sits beneath it
|
|
22
|
+
*/
|
|
23
|
+
export declare function navPathMatches(pathname: string, href?: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Find the item a route belongs to: the internal link with the longest
|
|
26
|
+
* matching href, so /deals/import lights "Import" and not "Deals" too.
|
|
27
|
+
* @param items Menu items
|
|
28
|
+
* @param pathname Current route
|
|
29
|
+
* @returns Active id and the ids of everything above it
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveSideNavActive(items: NavItemType[], pathname?: string): SideNavActive;
|
|
32
|
+
/**
|
|
33
|
+
* Find the item flagged `isActive`, at any depth, for menus that do not pass
|
|
34
|
+
* `activePath`.
|
|
35
|
+
* @param items Menu items
|
|
36
|
+
* @returns Active id and the ids of everything above it
|
|
37
|
+
*/
|
|
38
|
+
export declare function findFlaggedActive(items: NavItemType[]): SideNavActive;
|
|
39
|
+
/**
|
|
40
|
+
* Whether `id` is somewhere inside `item`.
|
|
41
|
+
* @param item A group or section
|
|
42
|
+
* @param id Item id to look for
|
|
43
|
+
*/
|
|
44
|
+
export declare function containsNavId(item: NavItemType, id: string | null): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Search every link and button in the menu, nested ones included.
|
|
47
|
+
*
|
|
48
|
+
* Every word must appear in the item's title, keywords, or the titles of the
|
|
49
|
+
* groups and section above it. Title prefixes rank first, then title matches,
|
|
50
|
+
* then context matches. A parent's keywords help a child match, but an item
|
|
51
|
+
* matching only through them is dropped when anything matches directly.
|
|
52
|
+
* Hidden (`hasAccess` false) and disabled items are skipped; an href listed
|
|
53
|
+
* twice is returned once.
|
|
54
|
+
* @param items Menu items
|
|
55
|
+
* @param query What the user typed
|
|
56
|
+
* @returns Ranked hits, empty for a blank query
|
|
57
|
+
*/
|
|
58
|
+
export declare function searchSideNav(items: NavItemType[], query: string): SideNavSearchResult[];
|
|
59
|
+
/**
|
|
60
|
+
* Split a title around the query so the match can be marked.
|
|
61
|
+
* @param title Item title
|
|
62
|
+
* @param query What the user typed
|
|
63
|
+
* @returns [before, match, after]; match is empty when there is no hit
|
|
64
|
+
*/
|
|
65
|
+
export declare function splitNavMatch(title: string, query: string): [string, string, string];
|
|
@@ -26,6 +26,8 @@ export interface NavItemBase {
|
|
|
26
26
|
};
|
|
27
27
|
/** Additional metadata for custom rendering */
|
|
28
28
|
meta?: Record<string, any>;
|
|
29
|
+
/** Extra words the menu search matches ("pipeline" for a Deals item) */
|
|
30
|
+
keywords?: string[];
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
33
|
* Navigation link item
|
|
@@ -74,10 +76,43 @@ export interface NavDividerItem {
|
|
|
74
76
|
/** Optional title for the divider */
|
|
75
77
|
title?: string;
|
|
76
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* A labelled block of items ("Main", "Money", "More tools") with an optional
|
|
81
|
+
* collapsible heading. Sections sit at the top level; they do not nest.
|
|
82
|
+
*/
|
|
83
|
+
export interface NavSectionItem {
|
|
84
|
+
/** Type of navigation item */
|
|
85
|
+
type: 'section';
|
|
86
|
+
/** Unique identifier */
|
|
87
|
+
id: string;
|
|
88
|
+
/** Heading shown above the items */
|
|
89
|
+
title: string;
|
|
90
|
+
/** Items in the section */
|
|
91
|
+
children: (NavLinkItem | NavGroupItem | NavButtonItem | NavDividerItem)[];
|
|
92
|
+
/** Whether the heading collapses the section (default true) */
|
|
93
|
+
collapsible?: boolean;
|
|
94
|
+
/** Start collapsed until opened, or until the active page is inside it */
|
|
95
|
+
defaultCollapsed?: boolean;
|
|
96
|
+
/** Additional CSS class names */
|
|
97
|
+
className?: string;
|
|
98
|
+
}
|
|
77
99
|
/**
|
|
78
100
|
* Union of all navigation item types
|
|
79
101
|
*/
|
|
80
|
-
export type NavItemType = NavLinkItem | NavGroupItem | NavButtonItem | NavDividerItem;
|
|
102
|
+
export type NavItemType = NavLinkItem | NavGroupItem | NavButtonItem | NavDividerItem | NavSectionItem;
|
|
103
|
+
/**
|
|
104
|
+
* Menu search configuration
|
|
105
|
+
*/
|
|
106
|
+
export interface SideNavSearchConfig {
|
|
107
|
+
/** Input placeholder (default "Search menu") */
|
|
108
|
+
placeholder?: string;
|
|
109
|
+
/** Key that focuses the search from anywhere on the page (default "/"); false to disable */
|
|
110
|
+
shortcut?: string | false;
|
|
111
|
+
/** Shown when nothing matches; receives the query */
|
|
112
|
+
emptyMessage?: (query: string) => React.ReactNode;
|
|
113
|
+
/** Called whenever the query changes */
|
|
114
|
+
onSearch?: (query: string) => void;
|
|
115
|
+
}
|
|
81
116
|
/**
|
|
82
117
|
* Logo configuration
|
|
83
118
|
*/
|
|
@@ -203,6 +238,14 @@ export interface SideNavbarProps {
|
|
|
203
238
|
toggleShortcut?: string;
|
|
204
239
|
/** Container class name for the main content area */
|
|
205
240
|
contentContainerClassName?: string;
|
|
241
|
+
/**
|
|
242
|
+
* Current route (e.g. `usePathname()`). When set, the item with the most
|
|
243
|
+
* specific matching `href` is active and every group and section above it
|
|
244
|
+
* opens, including on a hard reload. Overrides per-item `isActive`.
|
|
245
|
+
*/
|
|
246
|
+
activePath?: string;
|
|
247
|
+
/** Show a search field above the menu that filters every link, nested ones included */
|
|
248
|
+
search?: boolean | SideNavSearchConfig;
|
|
206
249
|
/** Children content to render in main area */
|
|
207
250
|
children?: React.ReactNode;
|
|
208
251
|
}
|