@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.
@@ -1,5 +1,5 @@
1
- import { jsxs as b, jsx as o } from "react/jsx-runtime";
2
- import { useMemo as h } from "react";
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
- /* blue color */
32
- /* blue */
33
- --starasia-ui-pagination-color-primary-blue: var(
34
- --starasia-ui-color-blue-700,
35
- #1d4ed8
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
- `, u = "...", m = (n, i) => {
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
- }) => h(() => {
143
+ }) => b(() => {
160
144
  const a = n;
161
145
  if (i + 5 >= a)
162
146
  return m(1, a);
163
- const c = Math.max(s - i, 1), d = Math.min(
147
+ const u = Math.max(s - i, 1), c = Math.min(
164
148
  s + i,
165
149
  a
166
- ), l = c > 2, r = d < a - 2, g = 1, v = a;
167
- if (!l && r) {
168
- let p = 3 + 2 * i;
169
- return [...m(1, p), u, a];
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 (l && !r) {
172
- let p = 3 + 2 * i, f = m(
173
- a - p + 1,
155
+ if (g && !r) {
156
+ let l = 3 + 2 * i, y = m(
157
+ a - l + 1,
174
158
  a
175
159
  );
176
- return [g, u, ...f];
160
+ return [p, d, ...y];
177
161
  }
178
- if (l && r) {
179
- let p = m(c, d);
180
- return [g, u, ...p, u, v];
162
+ if (g && r) {
163
+ let l = m(u, c);
164
+ return [p, d, ...l, d, v];
181
165
  }
182
- }, [n, i, s]), y = "starasia-pagination-styles", k = (n) => {
183
- if (!document.getElementById(y)) {
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 = y, i.textContent = n, document.head.appendChild(i);
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 c = () => {
188
+ const u = () => {
205
189
  n(t + 1);
206
- }, d = () => {
190
+ }, c = () => {
207
191
  n(t - 1);
208
192
  };
209
- let l = e[e.length - 1];
210
- return /* @__PURE__ */ b("ul", { className: "starasia-pagination-container", style: { padding: 0 }, children: [
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: d,
199
+ onClick: c,
216
200
  children: /* @__PURE__ */ o("div", { className: "starasia-pagination-arrow starasia-pagination-left" })
217
201
  }
218
202
  ),
219
- e.map((r, g) => r === u ? /* @__PURE__ */ o(
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
- g
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
- g
217
+ p
234
218
  )),
235
219
  /* @__PURE__ */ o(
236
220
  "li",
237
221
  {
238
- className: `starasia-pagination-item ${t === l ? "starasia-pagination-disabled" : null} ${a === "sm" ? "starasia-pagination-item-responsive" : ""}`,
239
- onClick: c,
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
  {
@@ -1,4 +1,4 @@
1
- (function(r,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):(r=typeof globalThis<"u"?globalThis:r||self,n(r.Pagination={},r.jsxRuntime,r.React))})(this,function(r,n,h){"use strict";const b=`@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@500&display=swap");
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
- /* blue color */
30
- /* blue */
31
- --starasia-ui-pagination-color-primary-blue: var(
32
- --starasia-ui-color-blue-700,
33
- #1d4ed8
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
- `,l="...",d=(t,i)=>{let e=i-t+1;return Array.from({length:e},(s,a)=>a+t)},x=({totalCount:t,siblingCount:i=1,currentPage:e})=>h.useMemo(()=>{const a=t;if(i+5>=a)return d(1,a);const m=Math.max(e-i,1),f=Math.min(e+i,a),p=m>2,o=f<a-2,c=1,S=a;if(!p&&o){let u=3+2*i;return[...d(1,u),l,a]}if(p&&!o){let u=3+2*i,v=d(a-u+1,a);return[c,l,...v]}if(p&&o){let u=d(m,f);return[c,l,...u,l,S]}},[t,i,e]),y="starasia-pagination-styles";(t=>{if(!document.getElementById(y)){const i=document.createElement("style");i.id=y,i.textContent=t,document.head.appendChild(i)}})(b);const w=({onPageChange:t,totalCount:i,siblingCount:e=1,currentPage:s,size:a="md"})=>{const g=x({currentPage:s,totalCount:i,siblingCount:e});if(s===0||g.length<2)return null;const m=()=>{t(s+1)},f=()=>{t(s-1)};let p=g[g.length-1];return n.jsxs("ul",{className:"starasia-pagination-container",style:{padding:0},children:[n.jsx("li",{className:`starasia-pagination-item ${s===1?"starasia-pagination-disabled":null} ${a==="sm"?"starasia-pagination-item-responsive":""}`,onClick:f,children:n.jsx("div",{className:"starasia-pagination-arrow starasia-pagination-left"})}),g.map((o,c)=>o===l?n.jsx("li",{className:`starasia-pagination-item starasia-pagination-dots ${a==="sm"?"starasia-pagination-item-responsive":""}`,children:"…"},c):n.jsx("li",{className:`starasia-pagination-item ${o===s?"starasia-pagination-selected":null} ${a==="sm"?"starasia-pagination-item-responsive":""}`,onClick:()=>t(Number(o)),children:o},c)),n.jsx("li",{className:`starasia-pagination-item ${s===p?"starasia-pagination-disabled":null} ${a==="sm"?"starasia-pagination-item-responsive":""}`,onClick:m,children:n.jsx("div",{className:"starasia-pagination-arrow starasia-pagination-right"})})]})};r.Pagination=w,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
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.2",
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
+ }