@instincthub/react-ui 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -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
|
|
@@ -88,8 +88,8 @@ export type SearchParamsType = {
|
|
|
88
88
|
[key: string]: string;
|
|
89
89
|
};
|
|
90
90
|
export interface SearchParamsPageProps {
|
|
91
|
-
params: SearchParamsType
|
|
92
|
-
searchParams: SearchParamsType
|
|
91
|
+
params: Promise<SearchParamsType>;
|
|
92
|
+
searchParams: Promise<SearchParamsType>;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Response interface for S3 uploads
|