Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-headless-pagination

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-headless-pagination - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

28

dist/react-headless-pagination.cjs.development.js

@@ -127,2 +127,3 @@ 'use strict';

var disabled = pagination.currentPage === 0;
return React.createElement(as.type, Object.assign({}, buttonProps, as.props, {

@@ -133,5 +134,12 @@ className: classNames(className, as.props.className),

},
tabIndex: pagination.currentPage === 0 ? -1 : 0,
disabled: pagination.currentPage === 0,
"data-testid": dataTestId
tabIndex: disabled ? "-1" : 0,
disabled: disabled,
"data-testid": dataTestId,
onKeyPress: function onKeyPress(event) {
event.preventDefault();
if (event.key === "Enter" && !disabled) {
previous();
}
}
}), (_as$props$children = as.props.children) != null ? _as$props$children : children);

@@ -157,2 +165,3 @@ };

var disabled = pagination.currentPage === pagination.pages.length - 1;
return React.createElement(as.type, Object.assign({}, buttonProps, as.props, {

@@ -163,5 +172,12 @@ className: classNames(className, as.props.className),

},
tabIndex: pagination.currentPage === pagination.pages.length - 1 ? -1 : 0,
disabled: pagination.currentPage === pagination.pages.length - 1,
"data-testid": dataTestId
tabIndex: disabled ? "-1" : 0,
disabled: disabled,
"data-testid": dataTestId,
onKeyPress: function onKeyPress(event) {
event.preventDefault();
if (event.key === "Enter" && !disabled) {
next();
}
}
}), (_as$props$children2 = as.props.children) != null ? _as$props$children2 : children);

@@ -168,0 +184,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")),a=e(require("classnames"));function n(e,t){if(null==e)return{};var a,n,r={},s=Object.keys(e);for(n=0;n<s.length;n++)t.indexOf(a=s[n])>=0||(r[a]=e[a]);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=n(e,["className","children","dataTestId","as"]),g=t.useContext(c);return t.createElement(o.type,Object.assign({},d,o.props,{className:a(s,o.props.className),onClick:function(){g.currentPage+1>1&&g.setCurrentPage(g.currentPage-1)},tabIndex:0===g.currentPage?-1:0,disabled:0===g.currentPage,"data-testid":l}),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=n(e,["className","children","dataTestId","as"]),g=t.useContext(c);return t.createElement(o.type,Object.assign({},d,o.props,{className:a(s,o.props.className),onClick:function(){g.currentPage+1<g.pages.length&&g.setCurrentPage(g.currentPage+1)},tabIndex:g.currentPage===g.pages.length-1?-1:0,disabled:g.currentPage===g.pages.length-1,"data-testid":l}),null!=(r=o.props.children)?r:u)},u=function(e){var a=e.prev,n=t.useContext(c);return n.isPreviousTruncable&&!0===a||n.isNextTruncable&&!a?t.createElement("li",{className:n.truncableClassName||void 0},n.truncableText):null},l=function(e){var n=e.as,r=void 0===n?t.createElement("a",null):n,s=e.className,l=e.dataTestIdActive,i=e.dataTestIdInactive,o=e.activeClassName,d=e.inactiveClassName,g=t.useContext(c),P=function(e){var n;return t.createElement("li",{key:e},t.createElement(r.type,Object.assign({"data-testid":a((n={},n[""+l]=l&&g.currentPage+1===e,n[i+"-"+e]=l&&g.currentPage+1!==e,n))||void 0,tabIndex:0,onKeyPress:function(t){"Enter"===t.key&&g.setCurrentPage(e-1)},onClick:function(){return g.setCurrentPage(e-1)},className:a(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 a,r,s,u,l,i,o,d,g,P,m,p,v,f,b,x,N,h,C,T,E,I=e.dataTestId,y=n(e,["dataTestId"]),M=(r=(a=y).currentPage,s=a.setCurrentPage,l=void 0===(u=a.truncableText)?"...":u,o=void 0===(i=a.truncableClassName)?"":i,d=a.totalPages,g=a.edgePageCount,P=a.middlePagesSiblingCount,m=Array(d).fill(0).map((function(e,t){return t+1})),p=r>1,v=r<d,f=r<=P,b=r+P>=d,x=t.useMemo((function(){var e=2*P+1;return f?m.slice(0,e):b?m.slice(-e):m.slice(r-P,r+P+1)}),[r,m]),N=t.useMemo((function(){return f||m.slice(0,x[0]-1).length<1?[]:m.slice(0,g).filter((function(e){return!x.includes(e)}))}),[r,m]),h=t.useMemo((function(){return m.slice(x[x.length-1],m[m.length])}),[m,x]),C=t.useMemo((function(){return b||h.length<1?[]:m.slice(m.length-g,m.length).filter((function(e){return!x.includes(e)}))}),[x,m]),T=t.useMemo((function(){return x[0]>N[N.length-1]+1}),[N,x]),E=t.useMemo((function(){return x[x.length-1]+1<C[0]}),[C,x]),{currentPage:r,setCurrentPage:s,truncableText:l,truncableClassName:o,pages:m,hasPreviousPage:p,hasNextPage:v,previousPages:N,isPreviousTruncable:T,middlePages:x,isNextTruncable:E,nextPages:C});return t.createElement(c.Provider,{value:M},t.createElement("div",{className:y.className,"data-testid":I},y.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("classnames"));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,b,x,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,b=r+P>=d,x=t.useMemo((function(){var e=2*P+1;return f?m.slice(0,e):b?m.slice(-e):m.slice(r-P,r+P+1)}),[r,m]),N=t.useMemo((function(){return f||m.slice(0,x[0]-1).length<1?[]:m.slice(0,g).filter((function(e){return!x.includes(e)}))}),[r,m]),C=t.useMemo((function(){return m.slice(x[x.length-1],m[m.length])}),[m,x]),h=t.useMemo((function(){return b||C.length<1?[]:m.slice(m.length-g,m.length).filter((function(e){return!x.includes(e)}))}),[x,m]),T=t.useMemo((function(){return x[0]>N[N.length-1]+1}),[N,x]),E=t.useMemo((function(){return x[x.length-1]+1<h[0]}),[h,x]),{currentPage:r,setCurrentPage:s,truncableText:l,truncableClassName:o,pages:m,hasPreviousPage:p,hasNextPage:v,previousPages:N,isPreviousTruncable:T,middlePages:x,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

@@ -121,2 +121,3 @@ import React from 'react';

var disabled = pagination.currentPage === 0;
return React.createElement(as.type, Object.assign({}, buttonProps, as.props, {

@@ -127,5 +128,12 @@ className: classNames(className, as.props.className),

},
tabIndex: pagination.currentPage === 0 ? -1 : 0,
disabled: pagination.currentPage === 0,
"data-testid": dataTestId
tabIndex: disabled ? "-1" : 0,
disabled: disabled,
"data-testid": dataTestId,
onKeyPress: function onKeyPress(event) {
event.preventDefault();
if (event.key === "Enter" && !disabled) {
previous();
}
}
}), (_as$props$children = as.props.children) != null ? _as$props$children : children);

@@ -151,2 +159,3 @@ };

var disabled = pagination.currentPage === pagination.pages.length - 1;
return React.createElement(as.type, Object.assign({}, buttonProps, as.props, {

@@ -157,5 +166,12 @@ className: classNames(className, as.props.className),

},
tabIndex: pagination.currentPage === pagination.pages.length - 1 ? -1 : 0,
disabled: pagination.currentPage === pagination.pages.length - 1,
"data-testid": dataTestId
tabIndex: disabled ? "-1" : 0,
disabled: disabled,
"data-testid": dataTestId,
onKeyPress: function onKeyPress(event) {
event.preventDefault();
if (event.key === "Enter" && !disabled) {
next();
}
}
}), (_as$props$children2 = as.props.children) != null ? _as$props$children2 : children);

@@ -162,0 +178,0 @@ };

{
"name": "react-headless-pagination",
"author": "Thijs Smudde",
"version": "1.1.3",
"version": "1.1.4",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc