react-headless-pagination
Advanced tools
Comparing version 1.1.5 to 1.1.6
@@ -5,3 +5,3 @@ import React from "react"; | ||
export declare const NextButton: ({ className, children, dataTestId, as, ...buttonProps }: ButtonProps) => JSX.Element; | ||
export declare const PageButton: ({ as, className, dataTestIdActive, dataTestIdInactive, activeClassName, inactiveClassName, }: PageButtonProps) => JSX.Element; | ||
export declare const PageButton: ({ as, className, dataTestIdActive, dataTestIdInactive, activeClassName, inactiveClassName, renderExtraProps, }: PageButtonProps) => JSX.Element; | ||
export declare const Pagination: { | ||
@@ -24,3 +24,3 @@ ({ dataTestId, ...paginationProps }: { | ||
NextButton: ({ className, children, dataTestId, as, ...buttonProps }: ButtonProps) => JSX.Element; | ||
PageButton: ({ as, className, dataTestIdActive, dataTestIdInactive, activeClassName, inactiveClassName, }: PageButtonProps) => JSX.Element; | ||
PageButton: ({ as, className, dataTestIdActive, dataTestIdInactive, activeClassName, inactiveClassName, renderExtraProps, }: PageButtonProps) => JSX.Element; | ||
}; |
@@ -201,3 +201,4 @@ 'use strict'; | ||
activeClassName = _ref4.activeClassName, | ||
inactiveClassName = _ref4.inactiveClassName; | ||
inactiveClassName = _ref4.inactiveClassName, | ||
renderExtraProps = _ref4.renderExtraProps; | ||
var pagination = React.useContext(PaginationContext); | ||
@@ -222,3 +223,3 @@ | ||
className: clsx(className, pagination.currentPage + 1 === page ? activeClassName : inactiveClassName) | ||
}, as.props), page)); | ||
}, as.props, renderExtraProps ? renderExtraProps(page) : {}), page)); | ||
}; | ||
@@ -225,0 +226,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),n=e(require("clsx"));function a(e,t){if(null==e)return{};var n,a,r={},s=Object.keys(e);for(a=0;a<s.length;a++)t.indexOf(n=s[a])>=0||(r[n]=e[n]);return r}var r=function(e){var r,s=e.className,u=e.children,l=e.dataTestId,i=e.as,o=void 0===i?t.createElement("button",null):i,d=a(e,["className","children","dataTestId","as"]),g=t.useContext(c),P=function(){g.currentPage+1>1&&g.setCurrentPage(g.currentPage-1)},m=0===g.currentPage;return t.createElement(o.type,Object.assign({},d,o.props,{className:n(s,o.props.className),onClick:function(){return P()},tabIndex:m?"-1":0,disabled:m,"data-testid":l,onKeyPress:function(e){e.preventDefault(),"Enter"!==e.key||m||P()}}),null!=(r=o.props.children)?r:u)},s=function(e){var r,s=e.className,u=e.children,l=e.dataTestId,i=e.as,o=void 0===i?t.createElement("button",null):i,d=a(e,["className","children","dataTestId","as"]),g=t.useContext(c),P=function(){g.currentPage+1<g.pages.length&&g.setCurrentPage(g.currentPage+1)},m=g.currentPage===g.pages.length-1;return t.createElement(o.type,Object.assign({},d,o.props,{className:n(s,o.props.className),onClick:function(){return P()},tabIndex:m?"-1":0,disabled:m,"data-testid":l,onKeyPress:function(e){e.preventDefault(),"Enter"!==e.key||m||P()}}),null!=(r=o.props.children)?r:u)},u=function(e){var n=e.prev,a=t.useContext(c);return a.isPreviousTruncable&&!0===n||a.isNextTruncable&&!n?t.createElement("li",{className:a.truncableClassName||void 0},a.truncableText):null},l=function(e){var a=e.as,r=void 0===a?t.createElement("a",null):a,s=e.className,l=e.dataTestIdActive,i=e.dataTestIdInactive,o=e.activeClassName,d=e.inactiveClassName,g=t.useContext(c),P=function(e){var a;return t.createElement("li",{key:e},t.createElement(r.type,Object.assign({"data-testid":n((a={},a[""+l]=l&&g.currentPage+1===e,a[i+"-"+e]=l&&g.currentPage+1!==e,a))||void 0,tabIndex:0,onKeyPress:function(t){"Enter"===t.key&&g.setCurrentPage(e-1)},onClick:function(){return g.setCurrentPage(e-1)},className:n(s,g.currentPage+1===e?o:d)},r.props),e))};return t.createElement(t.Fragment,null,g.previousPages.map(P),t.createElement(u,{prev:!0}),g.middlePages.map(P),t.createElement(u,null),g.nextPages.map(P))},c=t.createContext({currentPage:0,setCurrentPage:function(){},truncableText:"...",truncableClassName:"",pages:[],hasPreviousPage:!1,hasNextPage:!1,previousPages:[],isPreviousTruncable:!1,middlePages:[],isNextTruncable:!1,nextPages:[]}),i=function(e){var n,r,s,u,l,i,o,d,g,P,m,p,v,f,x,b,N,C,h,T,E,y=e.dataTestId,I=a(e,["dataTestId"]),k=(r=(n=I).currentPage,s=n.setCurrentPage,l=void 0===(u=n.truncableText)?"...":u,o=void 0===(i=n.truncableClassName)?"":i,d=n.totalPages,g=n.edgePageCount,P=n.middlePagesSiblingCount,m=Array(d).fill(0).map((function(e,t){return t+1})),p=r>1,v=r<d,f=r<=P,x=r+P>=d,b=t.useMemo((function(){var e=2*P+1;return f?m.slice(0,e):x?m.slice(-e):m.slice(r-P,r+P+1)}),[r,m]),N=t.useMemo((function(){return f||m.slice(0,b[0]-1).length<1?[]:m.slice(0,g).filter((function(e){return!b.includes(e)}))}),[r,m]),C=t.useMemo((function(){return m.slice(b[b.length-1],m[m.length])}),[m,b]),h=t.useMemo((function(){return x||C.length<1?[]:m.slice(m.length-g,m.length).filter((function(e){return!b.includes(e)}))}),[b,m]),T=t.useMemo((function(){return b[0]>N[N.length-1]+1}),[N,b]),E=t.useMemo((function(){return b[b.length-1]+1<h[0]}),[h,b]),{currentPage:r,setCurrentPage:s,truncableText:l,truncableClassName:o,pages:m,hasPreviousPage:p,hasNextPage:v,previousPages:N,isPreviousTruncable:T,middlePages:b,isNextTruncable:E,nextPages:h});return t.createElement(c.Provider,{value:k},t.createElement("div",{className:I.className,"data-testid":y},I.children))};i.PrevButton=r,i.NextButton=s,i.PageButton=l,exports.NextButton=s,exports.PageButton=l,exports.Pagination=i,exports.PrevButton=r; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),n=e(require("clsx"));function a(e,t){if(null==e)return{};var n,a,r={},s=Object.keys(e);for(a=0;a<s.length;a++)t.indexOf(n=s[a])>=0||(r[n]=e[n]);return r}var r=function(e){var r,s=e.className,u=e.children,l=e.dataTestId,i=e.as,o=void 0===i?t.createElement("button",null):i,d=a(e,["className","children","dataTestId","as"]),g=t.useContext(c),P=function(){g.currentPage+1>1&&g.setCurrentPage(g.currentPage-1)},m=0===g.currentPage;return t.createElement(o.type,Object.assign({},d,o.props,{className:n(s,o.props.className),onClick:function(){return P()},tabIndex:m?"-1":0,disabled:m,"data-testid":l,onKeyPress:function(e){e.preventDefault(),"Enter"!==e.key||m||P()}}),null!=(r=o.props.children)?r:u)},s=function(e){var r,s=e.className,u=e.children,l=e.dataTestId,i=e.as,o=void 0===i?t.createElement("button",null):i,d=a(e,["className","children","dataTestId","as"]),g=t.useContext(c),P=function(){g.currentPage+1<g.pages.length&&g.setCurrentPage(g.currentPage+1)},m=g.currentPage===g.pages.length-1;return t.createElement(o.type,Object.assign({},d,o.props,{className:n(s,o.props.className),onClick:function(){return P()},tabIndex:m?"-1":0,disabled:m,"data-testid":l,onKeyPress:function(e){e.preventDefault(),"Enter"!==e.key||m||P()}}),null!=(r=o.props.children)?r:u)},u=function(e){var n=e.prev,a=t.useContext(c);return a.isPreviousTruncable&&!0===n||a.isNextTruncable&&!n?t.createElement("li",{className:a.truncableClassName||void 0},a.truncableText):null},l=function(e){var a=e.as,r=void 0===a?t.createElement("a",null):a,s=e.className,l=e.dataTestIdActive,i=e.dataTestIdInactive,o=e.activeClassName,d=e.inactiveClassName,g=e.renderExtraProps,P=t.useContext(c),m=function(e){var a;return t.createElement("li",{key:e},t.createElement(r.type,Object.assign({"data-testid":n((a={},a[""+l]=l&&P.currentPage+1===e,a[i+"-"+e]=l&&P.currentPage+1!==e,a))||void 0,tabIndex:0,onKeyPress:function(t){"Enter"===t.key&&P.setCurrentPage(e-1)},onClick:function(){return P.setCurrentPage(e-1)},className:n(s,P.currentPage+1===e?o:d)},r.props,g?g(e):{}),e))};return t.createElement(t.Fragment,null,P.previousPages.map(m),t.createElement(u,{prev:!0}),P.middlePages.map(m),t.createElement(u,null),P.nextPages.map(m))},c=t.createContext({currentPage:0,setCurrentPage:function(){},truncableText:"...",truncableClassName:"",pages:[],hasPreviousPage:!1,hasNextPage:!1,previousPages:[],isPreviousTruncable:!1,middlePages:[],isNextTruncable:!1,nextPages:[]}),i=function(e){var n,r,s,u,l,i,o,d,g,P,m,p,v,f,x,b,N,C,h,T,E,y=e.dataTestId,I=a(e,["dataTestId"]),k=(r=(n=I).currentPage,s=n.setCurrentPage,l=void 0===(u=n.truncableText)?"...":u,o=void 0===(i=n.truncableClassName)?"":i,d=n.totalPages,g=n.edgePageCount,P=n.middlePagesSiblingCount,m=Array(d).fill(0).map((function(e,t){return t+1})),p=r>1,v=r<d,f=r<=P,x=r+P>=d,b=t.useMemo((function(){var e=2*P+1;return f?m.slice(0,e):x?m.slice(-e):m.slice(r-P,r+P+1)}),[r,m]),N=t.useMemo((function(){return f||m.slice(0,b[0]-1).length<1?[]:m.slice(0,g).filter((function(e){return!b.includes(e)}))}),[r,m]),C=t.useMemo((function(){return m.slice(b[b.length-1],m[m.length])}),[m,b]),h=t.useMemo((function(){return x||C.length<1?[]:m.slice(m.length-g,m.length).filter((function(e){return!b.includes(e)}))}),[b,m]),T=t.useMemo((function(){return b[0]>N[N.length-1]+1}),[N,b]),E=t.useMemo((function(){return b[b.length-1]+1<h[0]}),[h,b]),{currentPage:r,setCurrentPage:s,truncableText:l,truncableClassName:o,pages:m,hasPreviousPage:p,hasNextPage:v,previousPages:N,isPreviousTruncable:T,middlePages:b,isNextTruncable:E,nextPages:h});return t.createElement(c.Provider,{value:k},t.createElement("div",{className:I.className,"data-testid":y},I.children))};i.PrevButton=r,i.NextButton=s,i.PageButton=l,exports.NextButton=s,exports.PageButton=l,exports.Pagination=i,exports.PrevButton=r; | ||
//# sourceMappingURL=react-headless-pagination.cjs.production.min.js.map |
@@ -195,3 +195,4 @@ import React from 'react'; | ||
activeClassName = _ref4.activeClassName, | ||
inactiveClassName = _ref4.inactiveClassName; | ||
inactiveClassName = _ref4.inactiveClassName, | ||
renderExtraProps = _ref4.renderExtraProps; | ||
var pagination = React.useContext(PaginationContext); | ||
@@ -216,3 +217,3 @@ | ||
className: clsx(className, pagination.currentPage + 1 === page ? activeClassName : inactiveClassName) | ||
}, as.props), page)); | ||
}, as.props, renderExtraProps ? renderExtraProps(page) : {}), page)); | ||
}; | ||
@@ -219,0 +220,0 @@ |
@@ -43,3 +43,4 @@ import { ButtonHTMLAttributes } from "react"; | ||
dataTestIdInactive?: string; | ||
renderExtraProps?: (pageNum: number) => {}; | ||
}; | ||
export { IPaginationProps, IUsePagination, IPagination, ButtonProps, PageButtonProps, }; |
{ | ||
"name": "react-headless-pagination", | ||
"author": "Thijs Smudde", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78452
553