UNPKG
@visa/nova-react
Version:
latest (3.1.0)
3.1.0
3.0.0
2.5.4
2.5.3
2.5.2
Visa Product Design System Nova React library. Compatible with React ^19.
@visa/nova-react
/
use-pagination
/
utils.js
2 lines
(1 loc)
•
307 B
JavaScript
View Raw
1
2
"use strict"
;
exports
.
calculatePagesFromTo
=
(
t,r,a,e=
1
)=>
{
if
(r<
1
||t<
1
)
return
{
0
:
0
,
1
:
0
,
from
:
0
,
to
:
0
};
const
o=a-e+
1
,s=
Math
.
max
((o-
1
)*r+
1
,
0
),c=
Math
.
max
(s+r-
1
>t?
t
:s+r-
1
,
0
);
return
{
0
:s,
1
:c,
from
:s,
to
:c}},
exports
.
calculateTotalPages
=
(
t,r
)=>
Math
.
ceil
(t/r),
exports
.
generateArray
=
(
t,r
)=>
Array
.
from
({
length
:r},
(
r,a
)=>
a+t);