@starasia/pagination 3.1.0 → 3.1.1

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.
@@ -76,6 +76,11 @@ const z = `:root {
76
76
  height: 8px;
77
77
  }
78
78
 
79
+ /* PAGE NUMBERS — nudge text down 1px to compensate font cap-height offset */
80
+ .sa-pagination-page {
81
+ padding-top: 1px;
82
+ }
83
+
79
84
  /* HOVER & DOTS */
80
85
  .sa-pagination-item.sa-pagination-dots:hover {
81
86
  background-color: transparent;
@@ -88,10 +93,18 @@ const z = `:root {
88
93
  }
89
94
 
90
95
  /* ARROW */
96
+ .sa-pagination-arrow {
97
+ display: flex;
98
+ align-items: center;
99
+ justify-content: center;
100
+ line-height: 0;
101
+ padding-right: 2px;
102
+ padding-top: 2px;
103
+ }
104
+
91
105
  .sa-pagination-arrow::before {
92
- position: relative;
93
106
  content: "";
94
- display: inline-block;
107
+ display: block;
95
108
  width: 6px;
96
109
  height: 6px;
97
110
  border-right: var(--sa-border, 1px) solid var(--sa-pagination-text);
@@ -99,7 +112,7 @@ const z = `:root {
99
112
  }
100
113
 
101
114
  .sa-pagination-arrow.sa-pagination-left {
102
- transform: rotate(-135deg) translateX(-25%);
115
+ transform: rotate(-135deg);
103
116
  }
104
117
 
105
118
  .sa-pagination-arrow.sa-pagination-right {
@@ -147,7 +160,7 @@ const z = `:root {
147
160
  color: var(--sa-pagination-bg-active);
148
161
  font-weight: 600;
149
162
  }
150
- `, d = "...", v = (i, n) => {
163
+ `, l = "...", f = (i, n) => {
151
164
  let s = n - i + 1;
152
165
  return Array.from({ length: s }, (t, a) => a + i);
153
166
  }, w = ({
@@ -158,25 +171,25 @@ const z = `:root {
158
171
  }) => u(() => {
159
172
  const a = i;
160
173
  if (n + 5 >= a)
161
- return v(1, a);
174
+ return f(1, a);
162
175
  const e = Math.max(s - n, 1), c = Math.min(
163
176
  s + n,
164
177
  a
165
- ), p = e > 2, l = c < a - 2, m = 1, r = a;
166
- if (!p && l) {
178
+ ), p = e > 2, d = c < a - 2, m = 1, r = a;
179
+ if (!p && d) {
167
180
  let o = 3 + 2 * n;
168
- return [...v(1, o), d, a];
181
+ return [...f(1, o), l, a];
169
182
  }
170
- if (p && !l) {
171
- let o = 3 + 2 * n, h = v(
183
+ if (p && !d) {
184
+ let o = 3 + 2 * n, v = f(
172
185
  a - o + 1,
173
186
  a
174
187
  );
175
- return [m, d, ...h];
188
+ return [m, l, ...v];
176
189
  }
177
- if (p && l) {
178
- let o = v(e, c);
179
- return [m, d, ...o, d, r];
190
+ if (p && d) {
191
+ let o = f(e, c);
192
+ return [m, l, ...o, l, r];
180
193
  }
181
194
  }, [i, n, s]), x = "sa-pagination-styles", y = (i) => {
182
195
  if (!document.getElementById(x)) {
@@ -185,13 +198,13 @@ const z = `:root {
185
198
  }
186
199
  };
187
200
  y(z);
188
- const R = ({
201
+ const k = ({
189
202
  onPageChange: i,
190
203
  totalCount: n,
191
204
  siblingCount: s = 1,
192
205
  currentPage: t,
193
206
  size: a = "md",
194
- variant: f = "solid"
207
+ variant: h = "solid"
195
208
  }) => {
196
209
  const e = w({
197
210
  currentPage: t,
@@ -200,7 +213,7 @@ const R = ({
200
213
  });
201
214
  if (t === 0 || e.length < 2)
202
215
  return null;
203
- const c = () => i(t + 1), p = () => i(t - 1), l = e[e.length - 1], m = `sa-pagination-container sa-pagination-size-${a} sa-pagination-variant-${f}`;
216
+ const c = () => i(t + 1), p = () => i(t - 1), d = e[e.length - 1], m = `sa-pagination-container sa-pagination-size-${a} sa-pagination-variant-${h}`;
204
217
  return /* @__PURE__ */ b("ul", { className: m, style: { padding: 0 }, children: [
205
218
  /* @__PURE__ */ g(
206
219
  "li",
@@ -210,10 +223,10 @@ const R = ({
210
223
  children: /* @__PURE__ */ g("div", { className: "sa-pagination-arrow sa-pagination-left" })
211
224
  }
212
225
  ),
213
- e.map((r, o) => r === d ? /* @__PURE__ */ g("li", { className: "sa-pagination-item sa-pagination-dots", children: "…" }, o) : /* @__PURE__ */ g(
226
+ e.map((r, o) => r === l ? /* @__PURE__ */ g("li", { className: "sa-pagination-item sa-pagination-page sa-pagination-dots", children: "…" }, o) : /* @__PURE__ */ g(
214
227
  "li",
215
228
  {
216
- className: `sa-pagination-item${r === t ? " sa-pagination-selected" : ""}`,
229
+ className: `sa-pagination-item sa-pagination-page${r === t ? " sa-pagination-selected" : ""}`,
217
230
  onClick: () => i(Number(r)),
218
231
  children: r
219
232
  },
@@ -222,7 +235,7 @@ const R = ({
222
235
  /* @__PURE__ */ g(
223
236
  "li",
224
237
  {
225
- className: `sa-pagination-item${t === l ? " sa-pagination-disabled" : ""}`,
238
+ className: `sa-pagination-item${t === d ? " sa-pagination-disabled" : ""}`,
226
239
  onClick: c,
227
240
  children: /* @__PURE__ */ g("div", { className: "sa-pagination-arrow sa-pagination-right" })
228
241
  }
@@ -230,5 +243,5 @@ const R = ({
230
243
  ] });
231
244
  };
232
245
  export {
233
- R as Pagination
246
+ k as Pagination
234
247
  };
@@ -74,6 +74,11 @@
74
74
  height: 8px;
75
75
  }
76
76
 
77
+ /* PAGE NUMBERS — nudge text down 1px to compensate font cap-height offset */
78
+ .sa-pagination-page {
79
+ padding-top: 1px;
80
+ }
81
+
77
82
  /* HOVER & DOTS */
78
83
  .sa-pagination-item.sa-pagination-dots:hover {
79
84
  background-color: transparent;
@@ -86,10 +91,18 @@
86
91
  }
87
92
 
88
93
  /* ARROW */
94
+ .sa-pagination-arrow {
95
+ display: flex;
96
+ align-items: center;
97
+ justify-content: center;
98
+ line-height: 0;
99
+ padding-right: 2px;
100
+ padding-top: 2px;
101
+ }
102
+
89
103
  .sa-pagination-arrow::before {
90
- position: relative;
91
104
  content: "";
92
- display: inline-block;
105
+ display: block;
93
106
  width: 6px;
94
107
  height: 6px;
95
108
  border-right: var(--sa-border, 1px) solid var(--sa-pagination-text);
@@ -97,7 +110,7 @@
97
110
  }
98
111
 
99
112
  .sa-pagination-arrow.sa-pagination-left {
100
- transform: rotate(-135deg) translateX(-25%);
113
+ transform: rotate(-135deg);
101
114
  }
102
115
 
103
116
  .sa-pagination-arrow.sa-pagination-right {
@@ -145,4 +158,4 @@
145
158
  color: var(--sa-pagination-bg-active);
146
159
  font-weight: 600;
147
160
  }
148
- `,d="...",m=(t,n)=>{let r=n-t+1;return Array.from({length:r},(e,a)=>a+t)},y=({totalCount:t,siblingCount:n=1,currentPage:r})=>u.useMemo(()=>{const a=t;if(n+5>=a)return m(1,a);const g=Math.max(r-n,1),f=Math.min(r+n,a),l=g>2,c=f<a-2,v=1,p=a;if(!l&&c){let s=3+2*n;return[...m(1,s),d,a]}if(l&&!c){let s=3+2*n,b=m(a-s+1,a);return[v,d,...b]}if(l&&c){let s=m(g,f);return[v,d,...s,d,p]}},[t,n,r]),h="sa-pagination-styles";(t=>{if(!document.getElementById(h)){const n=document.createElement("style");n.id=h,n.textContent=t,document.head.appendChild(n)}})(z);const w=({onPageChange:t,totalCount:n,siblingCount:r=1,currentPage:e,size:a="md",variant:x="solid"})=>{const g=y({currentPage:e,totalCount:n,siblingCount:r});if(e===0||g.length<2)return null;const f=()=>t(e+1),l=()=>t(e-1),c=g[g.length-1],v=`sa-pagination-container sa-pagination-size-${a} sa-pagination-variant-${x}`;return i.jsxs("ul",{className:v,style:{padding:0},children:[i.jsx("li",{className:`sa-pagination-item${e===1?" sa-pagination-disabled":""}`,onClick:l,children:i.jsx("div",{className:"sa-pagination-arrow sa-pagination-left"})}),g.map((p,s)=>p===d?i.jsx("li",{className:"sa-pagination-item sa-pagination-dots",children:"…"},s):i.jsx("li",{className:`sa-pagination-item${p===e?" sa-pagination-selected":""}`,onClick:()=>t(Number(p)),children:p},s)),i.jsx("li",{className:`sa-pagination-item${e===c?" sa-pagination-disabled":""}`,onClick:f,children:i.jsx("div",{className:"sa-pagination-arrow sa-pagination-right"})})]})};o.Pagination=w,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
161
+ `,d="...",f=(t,n)=>{let r=n-t+1;return Array.from({length:r},(e,a)=>a+t)},y=({totalCount:t,siblingCount:n=1,currentPage:r})=>u.useMemo(()=>{const a=t;if(n+5>=a)return f(1,a);const g=Math.max(r-n,1),m=Math.min(r+n,a),l=g>2,c=m<a-2,h=1,p=a;if(!l&&c){let s=3+2*n;return[...f(1,s),d,a]}if(l&&!c){let s=3+2*n,b=f(a-s+1,a);return[h,d,...b]}if(l&&c){let s=f(g,m);return[h,d,...s,d,p]}},[t,n,r]),x="sa-pagination-styles";(t=>{if(!document.getElementById(x)){const n=document.createElement("style");n.id=x,n.textContent=t,document.head.appendChild(n)}})(z);const w=({onPageChange:t,totalCount:n,siblingCount:r=1,currentPage:e,size:a="md",variant:v="solid"})=>{const g=y({currentPage:e,totalCount:n,siblingCount:r});if(e===0||g.length<2)return null;const m=()=>t(e+1),l=()=>t(e-1),c=g[g.length-1],h=`sa-pagination-container sa-pagination-size-${a} sa-pagination-variant-${v}`;return i.jsxs("ul",{className:h,style:{padding:0},children:[i.jsx("li",{className:`sa-pagination-item${e===1?" sa-pagination-disabled":""}`,onClick:l,children:i.jsx("div",{className:"sa-pagination-arrow sa-pagination-left"})}),g.map((p,s)=>p===d?i.jsx("li",{className:"sa-pagination-item sa-pagination-page sa-pagination-dots",children:"…"},s):i.jsx("li",{className:`sa-pagination-item sa-pagination-page${p===e?" sa-pagination-selected":""}`,onClick:()=>t(Number(p)),children:p},s)),i.jsx("li",{className:`sa-pagination-item${e===c?" sa-pagination-disabled":""}`,onClick:m,children:i.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.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "pagination component for starasia UI",
5
5
  "author": "Prawito Hudoro",
6
6
  "main": "dist/pagination.umd.js",