@instincthub/react-ui 0.0.9 → 0.1.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/forms/input-fields.css +0 -1
- package/dist/src/assets/css/navbar/responsive-navbar.css +1 -0
- package/dist/src/assets/css/tag-only-selectors.css +0 -1
- package/dist/src/components/navbar/ResponsiveNavbar.js +1 -1
- package/dist/src/components/ui/pagination/Pagination.js +1 -1
- package/dist/src/types/components/navbar/ResponsiveNavbar.d.ts +27 -1
- package/dist/src/types/types/index.d.ts +4 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{
|
|
1
|
+
import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as n,jsx as i,Fragment as r}from"react/jsx-runtime";import{useState as a,useEffect as t}from"react";import o from"next/link";import l from"next/image";import u from"@mui/icons-material/LightMode";import c from"@mui/icons-material/DarkMode";var s=function(s){var h,d,m=s.session,b=s.logoSrc,v=s.logoAlt,p=void 0===v?"Company Logo":v,f=s.navLinks,g=s.userAreaLinks,N=void 0===g?[]:g,w=s.theme,k=void 0===w?"LightMode":w,L=s.containerClass,E=void 0===L?"ihub-container":L,M=s.topBanner,x=s.bottomBanner,_=s.hideTopBanner,D=void 0!==_&&_,B=s.hideBottomBanner,C=void 0!==B&&B,S=a(!1),A=e(S,2),y=A[0],j=A[1],z=a(!1),I=e(z,2),P=I[0],T=I[1],U=a(!1),H=e(U,2),W=H[0],Y=H[1],q=a(null),F=e(q,2),G=F[0],J=F[1],K=a(null),O=e(K,2),Q=O[0],R=O[1],V=a(k),X=e(V,2),Z=X[0],$=X[1],ee=null==m||null===(h=m.user)||void 0===h?void 0:h.name;t((function(){var e=function(){window.scrollY>50?T(!0):T(!1)};return window.addEventListener("scroll",e),function(){return window.removeEventListener("scroll",e)}}),[]),t((function(){var e=localStorage.getItem("theme");e&&($(e),document.documentElement.classList.remove("LightMode","DarkMode"),document.documentElement.classList.add(e))}),[]),t((function(){var e=function(e){var n=e.target;!y||n.closest(".ihub-navbar-elements")||n.closest(".ihub-hamburger")||j(!1),W&&!n.closest(".ihub-user-dropdown")&&(Y(!1),R(null)),null===G||n.closest(".ihub-nav-submenu-".concat(G))||J(null)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}}),[y,W,G,Q]),t((function(){var e=function(){window.innerWidth>768&&y&&j(!1)};return window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[y]);return n("header",{className:"ihub-navbar ".concat(P?"ihub-navbar-scrolled":""," ").concat("DarkMode"===Z?"ihub-navbar-dark":""),children:[M&&!D&&i("div",{className:"ihub-navbar-top-banner",children:M}),i("div",{className:E,children:n("nav",{className:"ihub-navbar-container",children:[i("div",{className:"ihub-navbar-logo",children:i(o,{href:"/",children:i(l,{src:b,alt:p,width:120,height:40,className:"ihub-logo-image"})})}),n("div",{className:"ihub-hamburger",onClick:function(){j(!y),J(null)},children:[i("div",{className:"ihub-hamburger-line ".concat(y?"ihub-active":"")}),i("div",{className:"ihub-hamburger-line ".concat(y?"ihub-active":"")}),i("div",{className:"ihub-hamburger-line ".concat(y?"ihub-active":"")})]}),n("div",{className:"ihub-navbar-elements ".concat(y?"ihub-active":""),children:[n("ul",{className:"ihub-nav-links",children:[f.map((function(e,a){return i("li",{className:"ihub-nav-item ihub-nav-submenu-".concat(a," ").concat(e.submenu?"ihub-has-submenu":""," ").concat(G===a?"ihub-submenu-active":""),children:e.submenu?n(r,{children:[n("a",{href:"#",onClick:function(e){return function(e,n){n.preventDefault(),J(G===e?null:e)}(a,e)},className:"ihub-submenu-toggle ".concat(e.highlight?"ihub-nav-highlight":""),children:[e.title,i("span",{className:"ihub-dropdown-arrow"})]}),G===a&&i("ul",{className:"ihub-submenu",children:e.submenu.map((function(e,r){return i("li",{className:"ihub-submenu-item",children:e.isExternal?n("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",children:[e.icon&&i("span",{className:"ihub-submenu-icon",children:e.icon}),e.title]}):n(o,{href:e.href,children:[e.icon&&i("span",{className:"ihub-submenu-icon",children:e.icon}),e.title]})},r)}))})]}):i(r,{children:e.isExternal?i("a",{href:e.href,target:"_blank",rel:"noopener noreferrer",className:e.highlight?"ihub-nav-highlight":"",children:e.title}):i(o,{href:e.href,className:e.highlight?"ihub-nav-highlight":"",children:e.title})})},a)})),i("li",{className:"ihub-nav-item",children:i("button",{onClick:function(){var e="LightMode"===Z?"DarkMode":"LightMode";document.documentElement.classList.remove("LightMode","DarkMode"),document.documentElement.classList.add(e),$(e),localStorage.setItem("theme",e)},className:"ihub-theme-toggle","aria-label":"Switch to ".concat("LightMode"===Z?"DarkMode":"LightMode"," mode"),children:i("LightMode"===Z?c:u,{})})})]}),i("div",{className:"ihub-navbar-user-area",children:m?n("div",{className:"ihub-user-dropdown",children:[n("div",{className:"ihub-user-profile",onClick:function(){Y(!W),R(null)},children:[null!=ee&&ee.picture?i(l,{src:ee.picture,alt:"User",width:40,height:40,className:"ihub-user-avatar"}):i("div",{className:"ihub-user-initials",children:(null==ee||null===(d=ee.full_name)||void 0===d?void 0:d.charAt(0))||"U"}),n("span",{className:"ihub-user-name ihub-hide-sm",children:[null==ee?void 0:ee.full_name,i("span",{className:"ihub-dropdown-arrow"})]})]}),W&&n("div",{className:"ihub-dropdown ihub-user-menu-dropdown",children:[N.map((function(e,r){return i("div",{className:"ihub-dropdown-item-wrapper",children:e.submenu?n("div",{className:"ihub-dropdown-with-submenu",children:[n("a",{href:"#",className:"ihub-dropdown-item ihub-dropdown-parent",onClick:function(e){return function(e,n){n.preventDefault(),n.stopPropagation(),R(Q===e?null:e)}(r,e)},target:e.isExternal?"_blank":void 0,rel:e.isExternal?"noopener noreferrer":void 0,children:[e.icon&&i("span",{className:"ihub-dropdown-icon",children:e.icon}),e.title,i("span",{className:"ihub-submenu-caret ".concat(Q===r?"ihub-active":"")})]}),Q===r&&i("div",{className:"ihub-user-submenu",children:e.submenu.map((function(e,r){return n(o,{href:e.href,className:"ihub-dropdown-subitem",target:e.isExternal?"_blank":void 0,rel:e.isExternal?"noopener noreferrer":void 0,children:[e.icon&&i("span",{className:"ihub-dropdown-icon",children:e.icon}),e.title]},r)}))})]}):n(o,{href:e.href,className:"ihub-dropdown-item",children:[e.icon&&i("span",{className:"ihub-dropdown-icon",children:e.icon}),e.title]})},r)})),n(o,{href:"/api/auth/signout",className:"ihub-dropdown-item ihub-signout",children:[i("span",{className:"ihub-dropdown-icon",children:"⤴"}),"Sign out"]})]})]}):i("div",{className:"ihub-auth-buttons",children:N.map((function(e,n){return e.isButton?i(o,{href:e.href,className:"".concat("outline"===e.buttonStyle?"ihub-outlined-btn":"ihub-important-btn"),target:e.isExternal?"_blank":void 0,rel:e.isExternal?"noopener noreferrer":void 0,children:e.title},n):i(o,{href:e.href,className:"ihub-auth-link",children:e.title},n)}))})})]})]})}),x&&!C&&i("div",{className:"ihub-navbar-bottom-banner",children:x})]})};export{s as default};
|
|
2
2
|
//# sourceMappingURL=ResponsiveNavbar.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{slicedToArray as a,asyncToGenerator as n,regeneratorRuntime as i}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as t,jsx as e}from"react/jsx-runtime";import{useState as o,useEffect as
|
|
1
|
+
import{slicedToArray as a,asyncToGenerator as n,regeneratorRuntime as i}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import{jsxs as t,jsx as e}from"react/jsx-runtime";import{useState as o,useRef as r,useEffect as l}from"react";import c from"next/link";import{reqOptions as s,fetchAPI as u}from"../../lib/helpFunction.js";import"../../lib/utils.js";import{useSearchParams as h}from"next/navigation";var d=function(a){if(!a)return null;try{return new URL(a).searchParams.get("offset")}catch(a){return null}},p=function(p){var g=p.data,f=p.limit,m=p.urlPath,b=p.setData,v=p.token,w=void 0===v?null:v,x=p.tabsValues,N=void 0===x?"":x,L=p.searchValues,k=void 0===L?"":L,y=p.rangeLimit,P=void 0===y?5:y,G=p.className,I=void 0===G?"":G,M=p.showFirstLast,R=void 0===M||M,j=h(),C=j.get("offset")||"0",S=j.get("search")||"",U=o([]),B=a(U,2),F=B[0],T=B[1],A=o(0),V=a(A,2),Z=V[0],_=V[1],D=o(P||5),E=a(D,2),H=E[0],q=E[1],z=o(!1),J=a(z,2),K=J[0],O=J[1],Q=r(!0),W=Number(C),X=Math.floor(W/f),Y=d((null==g?void 0:g.next)||""),$=d((null==g?void 0:g.previous)||""),aa=function(){var a=n(i().mark((function a(n){var t,e,o,r,l;return i().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return O(!0),a.prev=1,t=s("GET",null,w),e=void 0!==n?"&offset=".concat(n):"",o=k||S?"&search=".concat(encodeURIComponent(k||S)):"",r=N?"&cat=".concat(encodeURIComponent(N)):"",l="".concat(m,"?limit=").concat(f).concat(e).concat(o).concat(r),a.next=9,u(b,l,t,!0);case 9:a.next=14;break;case 11:a.prev=11,a.t0=a.catch(1),console.error("Pagination fetch error:",a.t0);case 14:return a.prev=14,na(),O(!1),a.finish(14);case 18:case"end":return a.stop()}}),a,null,[[1,11,14,18]])})));return function(n){return a.apply(this,arguments)}}(),na=function(){console.log("updatePageRange called with currentPageIndex:",X,P),X+1>=P?(_(X-2),q(X+3)):(_(0),q(P))};if(l((function(){if(W>0||N||k||S?aa(W):aa(),null!=g&&g.count){var a=Math.ceil(g.count/f);T(Array.from({length:a},(function(a,n){return n})))}}),[C,null==g?void 0:g.count,N,f]),l((function(){if(Q.current)Q.current=!1;else if("undefined"!=typeof window){var a=new URLSearchParams(window.location.search);a.set("offset","0"),window.history.replaceState({},"","".concat(window.location.pathname,"?").concat(a.toString()))}}),[k,S]),!F.length&&!K)return null;var ia=F.length,ta=0===X,ea=X===ia-1,oa=F.slice(Z,H);return t("div",{className:"ihub-pagination-container ".concat(I),role:"navigation","aria-label":"Pagination",children:[K&&t("div",{className:"ihub-pagination-loading",children:[e("div",{className:"ihub-loading-spinner"}),e("span",{children:"Loading..."})]}),t("ul",{className:"ihub-pagination-list",children:[t("div",{className:"ihub-pagination-nav-group",children:[R&&e("li",{className:"ihub-pagination-item ".concat(ta?"ihub-pagination-disabled":""),children:e(c,{href:"?offset=0",className:"ihub-pagination-link ihub-pagination-first","aria-label":"Go to first page",tabIndex:ta?-1:0,children:"First"})}),e("li",{className:"ihub-pagination-item ".concat(ta||null==g||!g.previous?"ihub-pagination-disabled":""),children:e(c,{href:"?offset=".concat($||0),className:"ihub-pagination-link ihub-pagination-previous","aria-label":"Go to previous page",tabIndex:ta||null==g||!g.previous?-1:0,children:e("svg",{width:"8",height:"13",viewBox:"0 0 8 13",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M7.66927 1.83333L3.08594 6.41667L7.66927 11L6.7526 12.8333L0.335938 6.41667L6.7526 0L7.66927 1.83333Z",fill:"currentColor"})})})})]}),e("div",{className:"ihub-pagination-pages",children:oa.map((function(a){var n=X===a,i=a+1;return e("li",{className:"ihub-pagination-item ".concat(n?"ihub-pagination-active":""),"data-page":i,children:e(c,{href:"?offset=".concat(a*f),className:"ihub-pagination-link ihub-pagination-number","aria-label":"Go to page ".concat(i),"aria-current":n?"page":void 0,children:i})},a)}))}),t("div",{className:"ihub-pagination-nav-group ".concat(null!=g&&g.next?"":"ihub-pagination-disabled"),children:[e("li",{className:"ihub-pagination-item ".concat(ea||null==g||!g.next?"ihub-pagination-disabled":""),children:e(c,{href:"?offset=".concat(Y||W),className:"ihub-pagination-link ihub-pagination-next","aria-label":"Go to next page",tabIndex:ea||null==g||!g.next?-1:0,children:e("svg",{width:"8",height:"13",viewBox:"0 0 8 13",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:e("path",{d:"M0.330731 1.83333L4.91406 6.41667L0.330731 11L1.2474 12.8333L7.66406 6.41667L1.2474 0L0.330731 1.83333Z",fill:"currentColor"})})})}),R&&e("li",{className:"ihub-pagination-item ".concat(ea?"ihub-pagination-disabled":""),children:e(c,{href:"?offset=".concat((ia-1)*f),className:"ihub-pagination-link ihub-pagination-last","aria-label":"Go to last page",tabIndex:ea?-1:0,children:"Last"})})]})]}),e("div",{className:"ihub-pagination-info",children:t("span",{className:"ihub-pagination-summary",children:["Showing ",Math.min(W+1,(null==g?void 0:g.count)||0)," to"," ",Math.min(W+f,(null==g?void 0:g.count)||0)," of"," ",(null==g?void 0:g.count)||0," results"]})})]})};export{p as default};
|
|
2
2
|
//# sourceMappingURL=Pagination.js.map
|
|
@@ -1,3 +1,29 @@
|
|
|
1
1
|
import { NavbarPropsType } from "../../types";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* ```tsx
|
|
5
|
+
* <ResponsiveNavbar
|
|
6
|
+
* session={session}
|
|
7
|
+
* logoSrc="https://example.com/logo.png"
|
|
8
|
+
* logoAlt="Company Logo"
|
|
9
|
+
* navLinks={navLinks}
|
|
10
|
+
* userAreaLinks={userAreaLinks}
|
|
11
|
+
* theme="LightMode"
|
|
12
|
+
* containerClass="ihub-container"
|
|
13
|
+
* topBanner={<div>Top Banner</div>}
|
|
14
|
+
* />
|
|
15
|
+
* ```
|
|
16
|
+
* @param {SessionType} session - The session object
|
|
17
|
+
* @param {string} logoSrc - The source of the logo
|
|
18
|
+
* @param {string} logoAlt - The alt text of the logo
|
|
19
|
+
* @param {NavLinkType[]} navLinks - The navigation links
|
|
20
|
+
* @param {UserAreaLinkType[]} userAreaLinks - The user area links
|
|
21
|
+
* @param {string} theme - The theme of the navbar
|
|
22
|
+
* @param {string} containerClass - The class of the container
|
|
23
|
+
* @param {React.ReactNode | JSX.Element | null} topBanner - The top banner
|
|
24
|
+
* @param {React.ReactNode | JSX.Element | null} bottomBanner - The bottom banner
|
|
25
|
+
* @param {boolean} hideTopBanner - Whether to hide the top banner
|
|
26
|
+
* @param {boolean} hideBottomBanner - Whether to hide the bottom banner
|
|
27
|
+
* */
|
|
28
|
+
declare const ResponsiveNavbar: ({ session, logoSrc, logoAlt, navLinks, userAreaLinks, theme: initialTheme, containerClass, topBanner, bottomBanner, hideTopBanner, hideBottomBanner, }: NavbarPropsType) => import("react/jsx-runtime").JSX.Element;
|
|
3
29
|
export default ResponsiveNavbar;
|
|
@@ -240,6 +240,10 @@ export interface NavbarPropsType {
|
|
|
240
240
|
userAreaLinks?: UserAreaLinkType[];
|
|
241
241
|
theme?: "LightMode" | "DarkMode";
|
|
242
242
|
containerClass?: string;
|
|
243
|
+
topBanner?: React.ReactNode | JSX.Element | null;
|
|
244
|
+
hideTopBanner?: boolean;
|
|
245
|
+
bottomBanner?: React.ReactNode | JSX.Element | null;
|
|
246
|
+
hideBottomBanner?: boolean;
|
|
243
247
|
}
|
|
244
248
|
export interface LoginFormPropsType {
|
|
245
249
|
params?: SearchParamsType;
|