@starasia/pagination 2.0.0 → 3.0.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.
- package/dist/pagination.es.js +60 -60
- package/dist/pagination.umd.js +16 -16
- package/package.json +6 -6
package/dist/pagination.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as b, jsx as
|
|
1
|
+
import { jsxs as b, jsx as s } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo as u } from "react";
|
|
3
3
|
const y = `@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap");
|
|
4
4
|
|
|
@@ -13,12 +13,12 @@ const y = `@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght
|
|
|
13
13
|
--sa-pagination-radius: var(--sa-radii-base, 0.25rem);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
.
|
|
16
|
+
.sa-pagination-container {
|
|
17
17
|
display: flex;
|
|
18
18
|
list-style-type: none;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
.
|
|
21
|
+
.sa-pagination-item {
|
|
22
22
|
padding: var(--sa-spacing-xs, 4px)
|
|
23
23
|
var(--sa-spacing-sm, 8px);
|
|
24
24
|
text-align: center;
|
|
@@ -35,35 +35,35 @@ const y = `@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght
|
|
|
35
35
|
font-family: "Montserrat";
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
.
|
|
38
|
+
.sa-pagination-item.sa-pagination-item-responsive {
|
|
39
39
|
margin: auto 0;
|
|
40
40
|
font-size: var(--sa-font-size-sm, 12px);
|
|
41
41
|
padding: var(--sa-spacing-xs, 4px)
|
|
42
42
|
var(--sa-spacing-sm, 8px);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
.
|
|
45
|
+
.sa-pagination-item.sa-pagination-dots:hover {
|
|
46
46
|
background-color: transparent;
|
|
47
47
|
cursor: default;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
.
|
|
50
|
+
.sa-pagination-item:hover {
|
|
51
51
|
background-color: var(--sa-pagination-bg-hover);
|
|
52
52
|
cursor: pointer;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
.
|
|
55
|
+
.sa-pagination-item.sa-pagination-selected {
|
|
56
56
|
background-color: var(--sa-pagination-bg-selected);
|
|
57
57
|
color: var(--sa-pagination-color-selected) !important;
|
|
58
58
|
font-weight: var(--sa-font-weight-medium, 400);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
.
|
|
61
|
+
.sa-pagination-selected {
|
|
62
62
|
background-color: var(--sa-pagination-bg-active) !important;
|
|
63
63
|
border-radius: 8px !important;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
.
|
|
66
|
+
.sa-pagination-arrow::before {
|
|
67
67
|
position: relative;
|
|
68
68
|
/* top: 3pt; Uncomment this to lower the icons as requested in comments*/
|
|
69
69
|
content: "";
|
|
@@ -77,122 +77,122 @@ const y = `@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght
|
|
|
77
77
|
var(--sa-pagination-text);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
.
|
|
80
|
+
.sa-pagination-arrow.sa-pagination-left {
|
|
81
81
|
transform: rotate(-135deg) translateX(-25%);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
.
|
|
84
|
+
.sa-pagination-arrow.sa-pagination-right {
|
|
85
85
|
transform: rotate(45deg);
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
.
|
|
88
|
+
.sa-pagination-item.sa-pagination-disabled {
|
|
89
89
|
pointer-events: none;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
.
|
|
93
|
-
.
|
|
92
|
+
.sa-pagination-item.sa-pagination-disabled
|
|
93
|
+
.sa-pagination-arrow::before {
|
|
94
94
|
border-right: var(--sa-border, 1px) solid
|
|
95
95
|
var(--sa-pagination-divider);
|
|
96
96
|
border-top: var(--sa-border, 1px) solid
|
|
97
97
|
var(--sa-pagination-divider);
|
|
98
98
|
}
|
|
99
|
-
.
|
|
99
|
+
.sa-pagination-item.sa-pagination-disabled:hover {
|
|
100
100
|
background-color: transparent;
|
|
101
101
|
cursor: default;
|
|
102
102
|
}
|
|
103
|
-
`, d = "...", f = (t,
|
|
104
|
-
let
|
|
105
|
-
return Array.from({ length:
|
|
103
|
+
`, d = "...", f = (t, a) => {
|
|
104
|
+
let e = a - t + 1;
|
|
105
|
+
return Array.from({ length: e }, (i, n) => n + t);
|
|
106
106
|
}, w = ({
|
|
107
107
|
totalCount: t,
|
|
108
108
|
// pageSize,
|
|
109
|
-
siblingCount:
|
|
110
|
-
currentPage:
|
|
109
|
+
siblingCount: a = 1,
|
|
110
|
+
currentPage: e
|
|
111
111
|
}) => u(() => {
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
return f(1,
|
|
115
|
-
const c = Math.max(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
), p = c > 2,
|
|
119
|
-
if (!p &&
|
|
120
|
-
let g = 3 + 2 *
|
|
121
|
-
return [...f(1, g), d,
|
|
112
|
+
const n = t;
|
|
113
|
+
if (a + 5 >= n)
|
|
114
|
+
return f(1, n);
|
|
115
|
+
const c = Math.max(e - a, 1), m = Math.min(
|
|
116
|
+
e + a,
|
|
117
|
+
n
|
|
118
|
+
), p = c > 2, o = m < n - 2, l = 1, x = n;
|
|
119
|
+
if (!p && o) {
|
|
120
|
+
let g = 3 + 2 * a;
|
|
121
|
+
return [...f(1, g), d, n];
|
|
122
122
|
}
|
|
123
|
-
if (p && !
|
|
124
|
-
let g = 3 + 2 *
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
if (p && !o) {
|
|
124
|
+
let g = 3 + 2 * a, v = f(
|
|
125
|
+
n - g + 1,
|
|
126
|
+
n
|
|
127
127
|
);
|
|
128
128
|
return [l, d, ...v];
|
|
129
129
|
}
|
|
130
|
-
if (p &&
|
|
130
|
+
if (p && o) {
|
|
131
131
|
let g = f(c, m);
|
|
132
132
|
return [l, d, ...g, d, x];
|
|
133
133
|
}
|
|
134
|
-
}, [t,
|
|
134
|
+
}, [t, a, e]), h = "sa-pagination-styles", k = (t) => {
|
|
135
135
|
if (!document.getElementById(h)) {
|
|
136
|
-
const
|
|
137
|
-
|
|
136
|
+
const a = document.createElement("style");
|
|
137
|
+
a.id = h, a.textContent = t, document.head.appendChild(a);
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
140
|
k(y);
|
|
141
141
|
const R = ({
|
|
142
142
|
onPageChange: t,
|
|
143
|
-
totalCount:
|
|
144
|
-
siblingCount:
|
|
143
|
+
totalCount: a,
|
|
144
|
+
siblingCount: e = 1,
|
|
145
145
|
currentPage: i,
|
|
146
|
-
size:
|
|
146
|
+
size: n = "md"
|
|
147
147
|
}) => {
|
|
148
|
-
const
|
|
148
|
+
const r = w({
|
|
149
149
|
currentPage: i,
|
|
150
|
-
totalCount:
|
|
151
|
-
siblingCount:
|
|
150
|
+
totalCount: a,
|
|
151
|
+
siblingCount: e
|
|
152
152
|
// pageSize
|
|
153
153
|
});
|
|
154
|
-
if (i === 0 ||
|
|
154
|
+
if (i === 0 || r.length < 2)
|
|
155
155
|
return null;
|
|
156
156
|
const c = () => {
|
|
157
157
|
t(i + 1);
|
|
158
158
|
}, m = () => {
|
|
159
159
|
t(i - 1);
|
|
160
160
|
};
|
|
161
|
-
let p =
|
|
162
|
-
return /* @__PURE__ */ b("ul", { className: "
|
|
163
|
-
/* @__PURE__ */
|
|
161
|
+
let p = r[r.length - 1];
|
|
162
|
+
return /* @__PURE__ */ b("ul", { className: "sa-pagination-container", style: { padding: 0 }, children: [
|
|
163
|
+
/* @__PURE__ */ s(
|
|
164
164
|
"li",
|
|
165
165
|
{
|
|
166
|
-
className: `
|
|
166
|
+
className: `sa-pagination-item ${i === 1 ? "sa-pagination-disabled" : null} ${n === "sm" ? "sa-pagination-item-responsive" : ""}`,
|
|
167
167
|
onClick: m,
|
|
168
|
-
children: /* @__PURE__ */
|
|
168
|
+
children: /* @__PURE__ */ s("div", { className: "sa-pagination-arrow sa-pagination-left" })
|
|
169
169
|
}
|
|
170
170
|
),
|
|
171
|
-
|
|
171
|
+
r.map((o, l) => o === d ? /* @__PURE__ */ s(
|
|
172
172
|
"li",
|
|
173
173
|
{
|
|
174
|
-
className: `
|
|
174
|
+
className: `sa-pagination-item sa-pagination-dots ${n === "sm" ? "sa-pagination-item-responsive" : ""}`,
|
|
175
175
|
children: "…"
|
|
176
176
|
},
|
|
177
177
|
l
|
|
178
|
-
) : /* @__PURE__ */
|
|
178
|
+
) : /* @__PURE__ */ s(
|
|
179
179
|
"li",
|
|
180
180
|
{
|
|
181
|
-
className: `
|
|
182
|
-
onClick: () => t(Number(
|
|
183
|
-
children:
|
|
181
|
+
className: `sa-pagination-item ${o === i ? "sa-pagination-selected" : null} ${n === "sm" ? "sa-pagination-item-responsive" : ""}`,
|
|
182
|
+
onClick: () => t(Number(o)),
|
|
183
|
+
children: o
|
|
184
184
|
},
|
|
185
185
|
l
|
|
186
186
|
)),
|
|
187
|
-
/* @__PURE__ */
|
|
187
|
+
/* @__PURE__ */ s(
|
|
188
188
|
"li",
|
|
189
189
|
{
|
|
190
|
-
className: `
|
|
190
|
+
className: `sa-pagination-item ${i === p ? "sa-pagination-disabled" : null} ${n === "sm" ? "sa-pagination-item-responsive" : ""}`,
|
|
191
191
|
onClick: c,
|
|
192
|
-
children: /* @__PURE__ */
|
|
192
|
+
children: /* @__PURE__ */ s(
|
|
193
193
|
"div",
|
|
194
194
|
{
|
|
195
|
-
className: "
|
|
195
|
+
className: "sa-pagination-arrow sa-pagination-right"
|
|
196
196
|
}
|
|
197
197
|
)
|
|
198
198
|
}
|
package/dist/pagination.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],t):(o=typeof globalThis<"u"?globalThis:o||self,t(o.Pagination={},o.jsxRuntime,o.React))})(this,function(o,t,x){"use strict";const b=`@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap");
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
4
|
--sa-pagination-text: var(--sa-color-gray-700, #6b6e76);
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
--sa-pagination-radius: var(--sa-radii-base, 0.25rem);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.
|
|
14
|
+
.sa-pagination-container {
|
|
15
15
|
display: flex;
|
|
16
16
|
list-style-type: none;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.
|
|
19
|
+
.sa-pagination-item {
|
|
20
20
|
padding: var(--sa-spacing-xs, 4px)
|
|
21
21
|
var(--sa-spacing-sm, 8px);
|
|
22
22
|
text-align: center;
|
|
@@ -33,35 +33,35 @@
|
|
|
33
33
|
font-family: "Montserrat";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
.
|
|
36
|
+
.sa-pagination-item.sa-pagination-item-responsive {
|
|
37
37
|
margin: auto 0;
|
|
38
38
|
font-size: var(--sa-font-size-sm, 12px);
|
|
39
39
|
padding: var(--sa-spacing-xs, 4px)
|
|
40
40
|
var(--sa-spacing-sm, 8px);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
.
|
|
43
|
+
.sa-pagination-item.sa-pagination-dots:hover {
|
|
44
44
|
background-color: transparent;
|
|
45
45
|
cursor: default;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
.
|
|
48
|
+
.sa-pagination-item:hover {
|
|
49
49
|
background-color: var(--sa-pagination-bg-hover);
|
|
50
50
|
cursor: pointer;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
.
|
|
53
|
+
.sa-pagination-item.sa-pagination-selected {
|
|
54
54
|
background-color: var(--sa-pagination-bg-selected);
|
|
55
55
|
color: var(--sa-pagination-color-selected) !important;
|
|
56
56
|
font-weight: var(--sa-font-weight-medium, 400);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
.
|
|
59
|
+
.sa-pagination-selected {
|
|
60
60
|
background-color: var(--sa-pagination-bg-active) !important;
|
|
61
61
|
border-radius: 8px !important;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
.
|
|
64
|
+
.sa-pagination-arrow::before {
|
|
65
65
|
position: relative;
|
|
66
66
|
/* top: 3pt; Uncomment this to lower the icons as requested in comments*/
|
|
67
67
|
content: "";
|
|
@@ -75,27 +75,27 @@
|
|
|
75
75
|
var(--sa-pagination-text);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
.
|
|
78
|
+
.sa-pagination-arrow.sa-pagination-left {
|
|
79
79
|
transform: rotate(-135deg) translateX(-25%);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
.
|
|
82
|
+
.sa-pagination-arrow.sa-pagination-right {
|
|
83
83
|
transform: rotate(45deg);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
.
|
|
86
|
+
.sa-pagination-item.sa-pagination-disabled {
|
|
87
87
|
pointer-events: none;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
.
|
|
91
|
-
.
|
|
90
|
+
.sa-pagination-item.sa-pagination-disabled
|
|
91
|
+
.sa-pagination-arrow::before {
|
|
92
92
|
border-right: var(--sa-border, 1px) solid
|
|
93
93
|
var(--sa-pagination-divider);
|
|
94
94
|
border-top: var(--sa-border, 1px) solid
|
|
95
95
|
var(--sa-pagination-divider);
|
|
96
96
|
}
|
|
97
|
-
.
|
|
97
|
+
.sa-pagination-item.sa-pagination-disabled:hover {
|
|
98
98
|
background-color: transparent;
|
|
99
99
|
cursor: default;
|
|
100
100
|
}
|
|
101
|
-
`,p="...",m=(i,
|
|
101
|
+
`,p="...",m=(i,a)=>{let r=a-i+1;return Array.from({length:r},(e,n)=>n+i)},y=({totalCount:i,siblingCount:a=1,currentPage:r})=>x.useMemo(()=>{const n=i;if(a+5>=n)return m(1,n);const f=Math.max(r-a,1),v=Math.min(r+a,n),d=f>2,s=v<n-2,g=1,k=n;if(!d&&s){let c=3+2*a;return[...m(1,c),p,n]}if(d&&!s){let c=3+2*a,u=m(n-c+1,n);return[g,p,...u]}if(d&&s){let c=m(f,v);return[g,p,...c,p,k]}},[i,a,r]),h="sa-pagination-styles";(i=>{if(!document.getElementById(h)){const a=document.createElement("style");a.id=h,a.textContent=i,document.head.appendChild(a)}})(b);const w=({onPageChange:i,totalCount:a,siblingCount:r=1,currentPage:e,size:n="md"})=>{const l=y({currentPage:e,totalCount:a,siblingCount:r});if(e===0||l.length<2)return null;const f=()=>{i(e+1)},v=()=>{i(e-1)};let d=l[l.length-1];return t.jsxs("ul",{className:"sa-pagination-container",style:{padding:0},children:[t.jsx("li",{className:`sa-pagination-item ${e===1?"sa-pagination-disabled":null} ${n==="sm"?"sa-pagination-item-responsive":""}`,onClick:v,children:t.jsx("div",{className:"sa-pagination-arrow sa-pagination-left"})}),l.map((s,g)=>s===p?t.jsx("li",{className:`sa-pagination-item sa-pagination-dots ${n==="sm"?"sa-pagination-item-responsive":""}`,children:"…"},g):t.jsx("li",{className:`sa-pagination-item ${s===e?"sa-pagination-selected":null} ${n==="sm"?"sa-pagination-item-responsive":""}`,onClick:()=>i(Number(s)),children:s},g)),t.jsx("li",{className:`sa-pagination-item ${e===d?"sa-pagination-disabled":null} ${n==="sm"?"sa-pagination-item-responsive":""}`,onClick:f,children:t.jsx("div",{className:"sa-pagination-arrow sa-pagination-right"})})]})};o.Pagination=w,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starasia/pagination",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "pagination component for starasia UI",
|
|
5
5
|
"author": "Prawito Hudoro",
|
|
6
6
|
"main": "dist/pagination.umd.js",
|
|
@@ -12,10 +12,6 @@
|
|
|
12
12
|
"dist/*.map",
|
|
13
13
|
"dist/*.css"
|
|
14
14
|
],
|
|
15
|
-
"scripts": {
|
|
16
|
-
"dev": "vite --config vite.config.ts --port 3000",
|
|
17
|
-
"build": "vite build --config vite.config.ts"
|
|
18
|
-
},
|
|
19
15
|
"keywords": [],
|
|
20
16
|
"license": "ISC",
|
|
21
17
|
"type": "module",
|
|
@@ -37,5 +33,9 @@
|
|
|
37
33
|
"react-dom": "^18.2.0",
|
|
38
34
|
"@types/react": "^18.2.55",
|
|
39
35
|
"@types/react-dom": "^18.2.19"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"dev": "vite --config vite.config.ts --port 3000",
|
|
39
|
+
"build": "vite build --config vite.config.ts"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|