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.0 to 1.1.1

8

dist/Pagination/Pagination.d.ts
import React from "react";
import { IPaginationProps, ButtonProps, PageButtonProps } from "../types/types";
export declare const PrevButton: ({ className, children, dataTestId, ...buttonProps }: ButtonProps) => JSX.Element;
export declare const NextButton: ({ className, children, dataTestId, ...buttonProps }: ButtonProps) => JSX.Element;
export declare const PrevButton: ({ className, children, dataTestId, as, ...buttonProps }: ButtonProps) => JSX.Element;
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;

@@ -21,5 +21,5 @@ export declare const Pagination: {

}): JSX.Element;
PrevButton: ({ className, children, dataTestId, ...buttonProps }: ButtonProps) => JSX.Element;
NextButton: ({ className, children, dataTestId, ...buttonProps }: ButtonProps) => JSX.Element;
PrevButton: ({ className, children, dataTestId, as, ...buttonProps }: ButtonProps) => JSX.Element;
NextButton: ({ className, children, dataTestId, as, ...buttonProps }: ButtonProps) => JSX.Element;
PageButton: ({ as, className, dataTestIdActive, dataTestIdInactive, activeClassName, inactiveClassName, }: PageButtonProps) => JSX.Element;
};

@@ -113,3 +113,5 @@ 'use strict';

dataTestId = _ref.dataTestId,
buttonProps = _objectWithoutPropertiesLoose(_ref, ["className", "children", "dataTestId"]);
_ref$as = _ref.as,
as = _ref$as === void 0 ? React.createElement("button", null) : _ref$as,
buttonProps = _objectWithoutPropertiesLoose(_ref, ["className", "children", "dataTestId", "as"]);

@@ -124,5 +126,4 @@ var pagination = React.useContext(PaginationContext);

return React.createElement("button", Object.assign({
className: className
}, buttonProps, {
return React.createElement(as.type, Object.assign({}, buttonProps, as.props, {
className: classNames(className, as.props.className),
onClick: function onClick() {

@@ -139,3 +140,5 @@ return previous();

dataTestId = _ref2.dataTestId,
buttonProps = _objectWithoutPropertiesLoose(_ref2, ["className", "children", "dataTestId"]);
_ref2$as = _ref2.as,
as = _ref2$as === void 0 ? React.createElement("button", null) : _ref2$as,
buttonProps = _objectWithoutPropertiesLoose(_ref2, ["className", "children", "dataTestId", "as"]);

@@ -150,5 +153,4 @@ var pagination = React.useContext(PaginationContext);

return React.createElement("button", Object.assign({
className: className
}, buttonProps, {
return React.createElement(as.type, Object.assign({}, buttonProps, as.props, {
className: classNames(className, as.props.className),
onClick: function onClick() {

@@ -155,0 +157,0 @@ return next();

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

@@ -107,3 +107,5 @@ import React from 'react';

dataTestId = _ref.dataTestId,
buttonProps = _objectWithoutPropertiesLoose(_ref, ["className", "children", "dataTestId"]);
_ref$as = _ref.as,
as = _ref$as === void 0 ? React.createElement("button", null) : _ref$as,
buttonProps = _objectWithoutPropertiesLoose(_ref, ["className", "children", "dataTestId", "as"]);

@@ -118,5 +120,4 @@ var pagination = React.useContext(PaginationContext);

return React.createElement("button", Object.assign({
className: className
}, buttonProps, {
return React.createElement(as.type, Object.assign({}, buttonProps, as.props, {
className: classNames(className, as.props.className),
onClick: function onClick() {

@@ -133,3 +134,5 @@ return previous();

dataTestId = _ref2.dataTestId,
buttonProps = _objectWithoutPropertiesLoose(_ref2, ["className", "children", "dataTestId"]);
_ref2$as = _ref2.as,
as = _ref2$as === void 0 ? React.createElement("button", null) : _ref2$as,
buttonProps = _objectWithoutPropertiesLoose(_ref2, ["className", "children", "dataTestId", "as"]);

@@ -144,5 +147,4 @@ var pagination = React.useContext(PaginationContext);

return React.createElement("button", Object.assign({
className: className
}, buttonProps, {
return React.createElement(as.type, Object.assign({}, buttonProps, as.props, {
className: classNames(className, as.props.className),
onClick: function onClick() {

@@ -149,0 +151,0 @@ return next();

@@ -29,2 +29,3 @@ import { ButtonHTMLAttributes } from "react";

declare type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
as?: React.ReactElement;
children?: string | React.ReactNode;

@@ -31,0 +32,0 @@ className?: string;

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