@starasia/pagination 1.0.2 → 1.0.3
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 +35 -51
- package/dist/pagination.umd.js +8 -24
- package/package.json +6 -6
package/dist/pagination.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
1
|
+
import { jsxs as h, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as b } from "react";
|
|
3
3
|
const x = `@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap");
|
|
4
4
|
|
|
5
5
|
:root {
|
|
@@ -28,28 +28,12 @@ const x = `@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght
|
|
|
28
28
|
--starasia-ui-color-gray-50,
|
|
29
29
|
#f9fafb
|
|
30
30
|
);
|
|
31
|
-
/*
|
|
32
|
-
|
|
33
|
-
--starasia-ui-pagination-color-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
--starasia-ui-pagination-color-secondary-blue: var(
|
|
38
|
-
--starasia-ui-color-blue-500,
|
|
39
|
-
#3b82f6
|
|
40
|
-
);
|
|
41
|
-
--starasia-ui-pagination-color-tertiary-blue: var(
|
|
42
|
-
--starasia-ui-color-blue-300,
|
|
43
|
-
#93c5fd
|
|
44
|
-
);
|
|
45
|
-
--starasia-ui-pagination-color-quaternary-blue: var(
|
|
46
|
-
--starasia-ui-color-blue-100,
|
|
47
|
-
#dbeafe
|
|
48
|
-
);
|
|
49
|
-
--starasia-ui-pagination-color-quinary-blue: var(
|
|
50
|
-
--starasia-ui-color-blue-50,
|
|
51
|
-
#eff6ff
|
|
52
|
-
);
|
|
31
|
+
/* brand color */
|
|
32
|
+
--starasia-ui-pagination-color-primary-blue: var(--starasia-ui-brand-primary-default);
|
|
33
|
+
--starasia-ui-pagination-color-secondary-blue: var(--starasia-ui-brand-primary-default);
|
|
34
|
+
--starasia-ui-pagination-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary);
|
|
35
|
+
--starasia-ui-pagination-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary);
|
|
36
|
+
--starasia-ui-pagination-color-quinary-blue: var(--starasia-ui-brand-primary-tertiary);
|
|
53
37
|
|
|
54
38
|
/* border radius */
|
|
55
39
|
--starasia-ui-pagination-border-radius: var(--starasia-ui-radii-base, 4px);
|
|
@@ -148,7 +132,7 @@ const x = `@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght
|
|
|
148
132
|
background-color: transparent;
|
|
149
133
|
cursor: default;
|
|
150
134
|
}
|
|
151
|
-
`,
|
|
135
|
+
`, d = "...", m = (n, i) => {
|
|
152
136
|
let s = i - n + 1;
|
|
153
137
|
return Array.from({ length: s }, (t, a) => a + n);
|
|
154
138
|
}, w = ({
|
|
@@ -156,33 +140,33 @@ const x = `@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght
|
|
|
156
140
|
// pageSize,
|
|
157
141
|
siblingCount: i = 1,
|
|
158
142
|
currentPage: s
|
|
159
|
-
}) =>
|
|
143
|
+
}) => b(() => {
|
|
160
144
|
const a = n;
|
|
161
145
|
if (i + 5 >= a)
|
|
162
146
|
return m(1, a);
|
|
163
|
-
const
|
|
147
|
+
const u = Math.max(s - i, 1), c = Math.min(
|
|
164
148
|
s + i,
|
|
165
149
|
a
|
|
166
|
-
),
|
|
167
|
-
if (!
|
|
168
|
-
let
|
|
169
|
-
return [...m(1,
|
|
150
|
+
), g = u > 2, r = c < a - 2, p = 1, v = a;
|
|
151
|
+
if (!g && r) {
|
|
152
|
+
let l = 3 + 2 * i;
|
|
153
|
+
return [...m(1, l), d, a];
|
|
170
154
|
}
|
|
171
|
-
if (
|
|
172
|
-
let
|
|
173
|
-
a -
|
|
155
|
+
if (g && !r) {
|
|
156
|
+
let l = 3 + 2 * i, y = m(
|
|
157
|
+
a - l + 1,
|
|
174
158
|
a
|
|
175
159
|
);
|
|
176
|
-
return [
|
|
160
|
+
return [p, d, ...y];
|
|
177
161
|
}
|
|
178
|
-
if (
|
|
179
|
-
let
|
|
180
|
-
return [
|
|
162
|
+
if (g && r) {
|
|
163
|
+
let l = m(u, c);
|
|
164
|
+
return [p, d, ...l, d, v];
|
|
181
165
|
}
|
|
182
|
-
}, [n, i, s]),
|
|
183
|
-
if (!document.getElementById(
|
|
166
|
+
}, [n, i, s]), f = "starasia-pagination-styles", k = (n) => {
|
|
167
|
+
if (!document.getElementById(f)) {
|
|
184
168
|
const i = document.createElement("style");
|
|
185
|
-
i.id =
|
|
169
|
+
i.id = f, i.textContent = n, document.head.appendChild(i);
|
|
186
170
|
}
|
|
187
171
|
};
|
|
188
172
|
k(x);
|
|
@@ -201,28 +185,28 @@ const N = ({
|
|
|
201
185
|
});
|
|
202
186
|
if (t === 0 || e.length < 2)
|
|
203
187
|
return null;
|
|
204
|
-
const
|
|
188
|
+
const u = () => {
|
|
205
189
|
n(t + 1);
|
|
206
|
-
},
|
|
190
|
+
}, c = () => {
|
|
207
191
|
n(t - 1);
|
|
208
192
|
};
|
|
209
|
-
let
|
|
210
|
-
return /* @__PURE__ */
|
|
193
|
+
let g = e[e.length - 1];
|
|
194
|
+
return /* @__PURE__ */ h("ul", { className: "starasia-pagination-container", style: { padding: 0 }, children: [
|
|
211
195
|
/* @__PURE__ */ o(
|
|
212
196
|
"li",
|
|
213
197
|
{
|
|
214
198
|
className: `starasia-pagination-item ${t === 1 ? "starasia-pagination-disabled" : null} ${a === "sm" ? "starasia-pagination-item-responsive" : ""}`,
|
|
215
|
-
onClick:
|
|
199
|
+
onClick: c,
|
|
216
200
|
children: /* @__PURE__ */ o("div", { className: "starasia-pagination-arrow starasia-pagination-left" })
|
|
217
201
|
}
|
|
218
202
|
),
|
|
219
|
-
e.map((r,
|
|
203
|
+
e.map((r, p) => r === d ? /* @__PURE__ */ o(
|
|
220
204
|
"li",
|
|
221
205
|
{
|
|
222
206
|
className: `starasia-pagination-item starasia-pagination-dots ${a === "sm" ? "starasia-pagination-item-responsive" : ""}`,
|
|
223
207
|
children: "…"
|
|
224
208
|
},
|
|
225
|
-
|
|
209
|
+
p
|
|
226
210
|
) : /* @__PURE__ */ o(
|
|
227
211
|
"li",
|
|
228
212
|
{
|
|
@@ -230,13 +214,13 @@ const N = ({
|
|
|
230
214
|
onClick: () => n(Number(r)),
|
|
231
215
|
children: r
|
|
232
216
|
},
|
|
233
|
-
|
|
217
|
+
p
|
|
234
218
|
)),
|
|
235
219
|
/* @__PURE__ */ o(
|
|
236
220
|
"li",
|
|
237
221
|
{
|
|
238
|
-
className: `starasia-pagination-item ${t ===
|
|
239
|
-
onClick:
|
|
222
|
+
className: `starasia-pagination-item ${t === g ? "starasia-pagination-disabled" : null} ${a === "sm" ? "starasia-pagination-item-responsive" : ""}`,
|
|
223
|
+
onClick: u,
|
|
240
224
|
children: /* @__PURE__ */ o(
|
|
241
225
|
"div",
|
|
242
226
|
{
|
package/dist/pagination.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(s,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],n):(s=typeof globalThis<"u"?globalThis:s||self,n(s.Pagination={},s.jsxRuntime,s.React))})(this,function(s,n,h){"use strict";const b=`@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap");
|
|
2
2
|
|
|
3
3
|
:root {
|
|
4
4
|
/* spacing */
|
|
@@ -26,28 +26,12 @@
|
|
|
26
26
|
--starasia-ui-color-gray-50,
|
|
27
27
|
#f9fafb
|
|
28
28
|
);
|
|
29
|
-
/*
|
|
30
|
-
|
|
31
|
-
--starasia-ui-pagination-color-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
35
|
-
--starasia-ui-pagination-color-secondary-blue: var(
|
|
36
|
-
--starasia-ui-color-blue-500,
|
|
37
|
-
#3b82f6
|
|
38
|
-
);
|
|
39
|
-
--starasia-ui-pagination-color-tertiary-blue: var(
|
|
40
|
-
--starasia-ui-color-blue-300,
|
|
41
|
-
#93c5fd
|
|
42
|
-
);
|
|
43
|
-
--starasia-ui-pagination-color-quaternary-blue: var(
|
|
44
|
-
--starasia-ui-color-blue-100,
|
|
45
|
-
#dbeafe
|
|
46
|
-
);
|
|
47
|
-
--starasia-ui-pagination-color-quinary-blue: var(
|
|
48
|
-
--starasia-ui-color-blue-50,
|
|
49
|
-
#eff6ff
|
|
50
|
-
);
|
|
29
|
+
/* brand color */
|
|
30
|
+
--starasia-ui-pagination-color-primary-blue: var(--starasia-ui-brand-primary-default);
|
|
31
|
+
--starasia-ui-pagination-color-secondary-blue: var(--starasia-ui-brand-primary-default);
|
|
32
|
+
--starasia-ui-pagination-color-tertiary-blue: var(--starasia-ui-brand-primary-secondary);
|
|
33
|
+
--starasia-ui-pagination-color-quaternary-blue: var(--starasia-ui-brand-primary-tertiary);
|
|
34
|
+
--starasia-ui-pagination-color-quinary-blue: var(--starasia-ui-brand-primary-tertiary);
|
|
51
35
|
|
|
52
36
|
/* border radius */
|
|
53
37
|
--starasia-ui-pagination-border-radius: var(--starasia-ui-radii-base, 4px);
|
|
@@ -146,4 +130,4 @@
|
|
|
146
130
|
background-color: transparent;
|
|
147
131
|
cursor: default;
|
|
148
132
|
}
|
|
149
|
-
`,
|
|
133
|
+
`,g="...",u=(t,i)=>{let e=i-t+1;return Array.from({length:e},(r,a)=>a+t)},x=({totalCount:t,siblingCount:i=1,currentPage:e})=>h.useMemo(()=>{const a=t;if(i+5>=a)return u(1,a);const m=Math.max(e-i,1),y=Math.min(e+i,a),l=m>2,o=y<a-2,d=1,S=a;if(!l&&o){let c=3+2*i;return[...u(1,c),g,a]}if(l&&!o){let c=3+2*i,v=u(a-c+1,a);return[d,g,...v]}if(l&&o){let c=u(m,y);return[d,g,...c,g,S]}},[t,i,e]),f="starasia-pagination-styles";(t=>{if(!document.getElementById(f)){const i=document.createElement("style");i.id=f,i.textContent=t,document.head.appendChild(i)}})(b);const w=({onPageChange:t,totalCount:i,siblingCount:e=1,currentPage:r,size:a="md"})=>{const p=x({currentPage:r,totalCount:i,siblingCount:e});if(r===0||p.length<2)return null;const m=()=>{t(r+1)},y=()=>{t(r-1)};let l=p[p.length-1];return n.jsxs("ul",{className:"starasia-pagination-container",style:{padding:0},children:[n.jsx("li",{className:`starasia-pagination-item ${r===1?"starasia-pagination-disabled":null} ${a==="sm"?"starasia-pagination-item-responsive":""}`,onClick:y,children:n.jsx("div",{className:"starasia-pagination-arrow starasia-pagination-left"})}),p.map((o,d)=>o===g?n.jsx("li",{className:`starasia-pagination-item starasia-pagination-dots ${a==="sm"?"starasia-pagination-item-responsive":""}`,children:"…"},d):n.jsx("li",{className:`starasia-pagination-item ${o===r?"starasia-pagination-selected":null} ${a==="sm"?"starasia-pagination-item-responsive":""}`,onClick:()=>t(Number(o)),children:o},d)),n.jsx("li",{className:`starasia-pagination-item ${r===l?"starasia-pagination-disabled":null} ${a==="sm"?"starasia-pagination-item-responsive":""}`,onClick:m,children:n.jsx("div",{className:"starasia-pagination-arrow starasia-pagination-right"})})]})};s.Pagination=w,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starasia/pagination",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "pagination component for starasia UI",
|
|
5
5
|
"author": "Prawito Hudoro",
|
|
6
6
|
"main": "dist/pagination.umd.js",
|
|
@@ -12,6 +12,10 @@
|
|
|
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
|
+
},
|
|
15
19
|
"keywords": [],
|
|
16
20
|
"license": "ISC",
|
|
17
21
|
"type": "module",
|
|
@@ -33,9 +37,5 @@
|
|
|
33
37
|
"react-dom": "^18.2.0",
|
|
34
38
|
"@types/react": "^18.2.55",
|
|
35
39
|
"@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
|
+
}
|