@memobit/libs 4.2.0 → 4.2.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.
@@ -1 +1 @@
1
- .pagination{align-items:center;gap:var(--spacing-12);flex-wrap:wrap;justify-content:space-around;width:100%;display:flex}.pagination__pages{justify-content:center;align-items:center;gap:var(--spacing-8);flex:1;display:flex}.pagination--left .pagination__pages{justify-content:flex-start}.pagination--center .pagination__pages{flex:none;justify-content:center}.pagination--right{flex-direction:row-reverse}.pagination--right .pagination__pages,.pagination--single{justify-content:flex-end}.pagination .page-info{color:var(--body-color);font-size:var(--font-size-sm)}.pagination__page-size{align-items:center;gap:var(--spacing-8);font-size:var(--font-size-sm);color:var(--body-color);display:flex}.pagination__page-size .dropdown-container{min-width:120px}@media (width>=769px) and (width<=1024px){.pagination__pages{flex-wrap:wrap}.pagination .page-info{text-align:center;width:100%;margin-top:var(--spacing-8)}}@media (width<=768px){.pagination{flex-direction:column;align-items:stretch}.pagination__pages{flex-wrap:wrap;justify-content:center}.pagination__page-size{justify-content:center}.pagination--single .pagination__page-size{justify-content:flex-end}}
1
+ .pagination{align-items:center;gap:var(--spacing-12);flex-wrap:wrap;justify-content:space-around;width:100%;display:flex}.pagination__pages{justify-content:center;align-items:center;gap:var(--spacing-8);flex:1;display:flex;position:relative}.pagination__pages .button{font-variant-numeric:tabular-nums}.pagination__probe{visibility:hidden;pointer-events:none;display:flex;position:absolute;top:0;left:0}.pagination--left .pagination__pages{justify-content:flex-start}.pagination--center .pagination__pages{flex:none;justify-content:center}.pagination--right{flex-direction:row-reverse}.pagination--right .pagination__pages,.pagination--single{justify-content:flex-end}.pagination .page-info{color:var(--body-color);font-size:var(--font-size-sm)}.pagination__page-size{align-items:center;gap:var(--spacing-8);font-size:var(--font-size-sm);color:var(--body-color);display:flex}.pagination__page-size .dropdown-container{min-width:120px}@media (width>=769px) and (width<=1024px){.pagination__pages{flex-wrap:wrap}.pagination .page-info{text-align:center;width:100%;margin-top:var(--spacing-8)}}@media (width<=768px){.pagination{flex-direction:column;align-items:stretch}.pagination__pages{justify-content:center;gap:var(--spacing-4);flex-wrap:wrap}.pagination__pages .button{padding-inline:var(--spacing-8)}.pagination__page-size{justify-content:center}.pagination--single .pagination__page-size{justify-content:flex-end}}
@@ -1,90 +1,124 @@
1
1
  import './Pagination.css';
2
- import { libMessages as y } from "../../contexts/LanguageContext/libMessages.js";
3
- import { useMessages as L } from "../../hooks/useLanguage.js";
4
- import { Button as h } from "../Button/Button2.js";
5
- import { Dropdown as O } from "../Dropdown/Dropdown2.js";
6
- import { useBreakpoint as I } from "../../hooks/useBreakpoint.js";
2
+ import { libMessages as O } from "../../contexts/LanguageContext/libMessages.js";
3
+ import { useMessages as K } from "../../hooks/useLanguage.js";
4
+ import { Button as d } from "../Button/Button2.js";
5
+ import { Dropdown as U } from "../Dropdown/Dropdown2.js";
6
+ import { useBreakpoint as X } from "../../hooks/useBreakpoint.js";
7
+ import { getPageItems as q } from "./pageItems.js";
7
8
  /* empty css */
8
- import { useCallback as R, useEffect as V, useRef as $, useState as j } from "react";
9
- import { jsx as t, jsxs as m } from "react/jsx-runtime";
10
- var C = 120, H = 45, U = 8, G = 4, Y = ({ currentPage: i, totalPages: n, totalItems: u, onPageChange: f, showPagesNumbers: D = !1, pageSizeOptions: o, pageSize: v, onPageSizeChange: b, pageSizeLabel: N, horizontalAlign: k = "left" }) => {
11
- const a = L(y), { isAtLeast: l, isMobile: w } = I(), d = $(null), [c, A] = j(w ? 0 : 2), p = R(() => {
12
- const s = d.current, e = s?.parentElement;
13
- if (!s || !e) return;
14
- let r = 0;
15
- for (const x of e.children) x !== s && (r += x.offsetWidth + U);
16
- const W = e.clientWidth - r - ((l("desktop") ? C : H) * 2 + 90 + 90 + 48), B = Math.floor(W / 53), E = Math.min(G, Math.max(0, Math.floor(B / 2)));
17
- A(E);
18
- }, [l]);
19
- V(() => {
20
- const s = d.current, e = s?.parentElement;
21
- if (!s || !e) return;
22
- const r = new ResizeObserver(() => {
23
- p();
24
- });
25
- return r.observe(s), r.observe(e), p(), () => r.disconnect();
26
- }, [p]);
27
- const M = o && v !== void 0 && b, _ = o?.map((s) => ({
28
- label: `${s}`,
29
- value: s
30
- })), T = () => {
31
- const s = [], e = [];
32
- for (let r = Math.max(2, i - c); r <= Math.min(n - 1, i + c); r++) s.push(r);
33
- return i - c > 2 ? e.push(1, "...") : e.push(1), e.push(...s), i + c < n - 1 ? e.push("...", n) : n > 1 && e.push(n), e;
34
- };
35
- return u !== void 0 && o?.length && u <= Math.min(...o) || n <= 1 && !M ? null : /* @__PURE__ */ m("div", {
36
- className: `pagination pagination--${k}${n <= 1 ? " pagination--single" : ""}`,
9
+ import { useCallback as z, useLayoutEffect as H, useRef as h, useState as J } from "react";
10
+ import { jsx as o, jsxs as m } from "react/jsx-runtime";
11
+ var Q = 5, W = "...", T = 1, g = (r) => r.getBoundingClientRect().width, V = (r, t) => r.room === t.room && r.gap === t.gap && r.ellipsis === t.ellipsis && r.byDigits.length === t.byDigits.length && r.byDigits.every((n, i) => n === t.byDigits[i]), Y = (r, t) => {
12
+ const n = getComputedStyle(r), i = r.clientWidth - parseFloat(n.paddingLeft) - parseFloat(n.paddingRight);
13
+ if (n.flexDirection.startsWith("column")) return i;
14
+ const b = parseFloat(n.columnGap) || 0;
15
+ let l = 0;
16
+ for (const p of r.children) {
17
+ if (p === t) continue;
18
+ const u = g(p);
19
+ u >= i || (l += u + b);
20
+ }
21
+ return i - l;
22
+ }, ae = ({ currentPage: r, totalPages: t, totalItems: n, onPageChange: i, showPagesNumbers: b = !1, pageSizeOptions: l, pageSize: p, onPageSizeChange: u, pageSizeLabel: F, horizontalAlign: G = "left" }) => {
23
+ const f = K(O), { isAtLeast: R } = X(), v = h(null), y = h(null), w = h(null), _ = h(null), [c, I] = J(null), k = n !== void 0 && !!l?.length && n <= Math.min(...l), A = t > 1 && !k, E = String(t).length, D = z(() => {
24
+ const e = v.current, s = e?.parentElement, a = y.current, B = w.current, C = _.current;
25
+ if (!e || !s || !a || !B || !C) return;
26
+ const [$ = 0, ...j] = Array.from(C.children, g), S = {
27
+ room: Y(s, e) - g(a) - g(B) - T,
28
+ gap: parseFloat(getComputedStyle(e).columnGap) || 0,
29
+ ellipsis: $,
30
+ byDigits: j
31
+ };
32
+ I((N) => N && V(N, S) ? N : S);
33
+ }, []), M = (e) => c ? e.reduce((s, a) => s + c.gap + (typeof a == "number" ? c.byDigits[String(a).length - 1] ?? 0 : c.ellipsis), c.gap) <= c.room : !0;
34
+ H(() => {
35
+ const e = v.current?.parentElement;
36
+ if (!A || !e) return;
37
+ const s = new ResizeObserver(D);
38
+ for (const a of [
39
+ e,
40
+ ...e.children,
41
+ y.current,
42
+ w.current,
43
+ _.current
44
+ ]) a && s.observe(a);
45
+ return D(), () => s.disconnect();
46
+ }, [A, D]);
47
+ const L = l && p !== void 0 && u, x = l?.map((e) => ({
48
+ label: `${e}`,
49
+ value: e
50
+ }));
51
+ return k || t <= 1 && !L ? null : /* @__PURE__ */ m("div", {
52
+ className: `pagination pagination--${G}${t <= 1 ? " pagination--single" : ""}`,
37
53
  children: [
38
- n > 1 && /* @__PURE__ */ m("div", {
54
+ A && /* @__PURE__ */ m("div", {
39
55
  className: "pagination__pages",
40
- ref: d,
56
+ ref: v,
41
57
  children: [
42
- /* @__PURE__ */ t(h, {
58
+ /* @__PURE__ */ o(d, {
59
+ ref: y,
43
60
  variant: "default",
44
61
  borders: "sharp",
45
- disabled: i === 1,
46
- icon: "previous",
47
- onClick: () => f(i - 1),
48
- children: l("desktop") ? a.previous : ""
62
+ disabled: r === 1,
63
+ icon: "caret-left",
64
+ onClick: () => i(r - 1),
65
+ children: R("desktop") ? f.previous : ""
49
66
  }),
50
- T().map((s, e) => /* @__PURE__ */ t(h, {
67
+ q(r, t, M, Q).map((e) => typeof e == "number" ? /* @__PURE__ */ o(d, {
51
68
  borders: "sharp",
52
- variant: s === i ? "warning" : "default",
53
- disabled: typeof s == "string",
54
- onClick: () => typeof s == "number" && f(s),
55
- children: s
69
+ variant: e === r ? "warning" : "default",
70
+ onClick: () => i(e),
71
+ children: e
72
+ }, e) : /* @__PURE__ */ o(d, {
73
+ borders: "sharp",
74
+ variant: "default",
75
+ disabled: !0,
76
+ children: W
56
77
  }, e)),
57
- /* @__PURE__ */ t(h, {
78
+ /* @__PURE__ */ o(d, {
79
+ ref: w,
58
80
  variant: "default",
59
81
  borders: "sharp",
60
- disabled: i === n,
61
- sufixIcon: "next",
62
- onClick: () => f(i + 1),
63
- children: l("desktop") ? a.next : ""
82
+ disabled: r === t,
83
+ sufixIcon: "caret-right",
84
+ onClick: () => i(r + 1),
85
+ children: R("desktop") ? f.next : ""
86
+ }),
87
+ /* @__PURE__ */ m("span", {
88
+ className: "pagination__probe",
89
+ ref: _,
90
+ children: [/* @__PURE__ */ o(d, {
91
+ borders: "sharp",
92
+ disabled: !0,
93
+ children: W
94
+ }), Array.from({ length: E }, (e, s) => /* @__PURE__ */ o(d, {
95
+ borders: "sharp",
96
+ children: "8".repeat(s + 1)
97
+ }, s))]
64
98
  })
65
99
  ]
66
100
  }),
67
- M && _ && /* @__PURE__ */ m("div", {
101
+ L && x && /* @__PURE__ */ m("div", {
68
102
  className: "pagination__page-size",
69
- children: [/* @__PURE__ */ t("span", { children: N ?? a.rows }), /* @__PURE__ */ t(O, {
103
+ children: [/* @__PURE__ */ o("span", { children: F ?? f.rows }), /* @__PURE__ */ o(U, {
70
104
  name: "pageSize",
71
- options: _,
72
- value: v,
105
+ options: x,
106
+ value: p,
73
107
  clearable: !1,
74
108
  searchable: !1,
75
109
  usePortal: !1,
76
- onChange: (s) => {
77
- s && !Array.isArray(s) && b(Number(s.value));
110
+ onChange: (e) => {
111
+ e && !Array.isArray(e) && u(Number(e.value));
78
112
  }
79
113
  })]
80
114
  }),
81
- D && /* @__PURE__ */ t("span", {
115
+ b && /* @__PURE__ */ o("span", {
82
116
  className: "page-info",
83
- children: a.pageOf(i, n)
117
+ children: f.pageOf(r, t)
84
118
  })
85
119
  ]
86
120
  });
87
121
  };
88
122
  export {
89
- Y as Pagination
123
+ ae as Pagination
90
124
  };
@@ -0,0 +1,34 @@
1
+ var o = (e, n) => Array.from({ length: Math.max(0, n - e + 1) }, (a, r) => e + r), i = (e, n, a, r) => {
2
+ if (n <= 1) return [1];
3
+ const s = Math.max(2, e - a), t = Math.min(n - 1, e + r), f = s > 3 ? ["start-gap"] : o(2, s - 1), g = t < n - 2 ? ["end-gap"] : o(t + 1, n - 1);
4
+ return [
5
+ 1,
6
+ ...f,
7
+ ...o(s, t),
8
+ ...g,
9
+ n
10
+ ];
11
+ }, m = (e, n, a) => {
12
+ let r = e, s = e;
13
+ for (; ; ) {
14
+ const t = s < n && a(o(r, s + 1)), f = r > 1 && a(o(r - 1, s));
15
+ if (t && (s - e <= e - r || !f)) s += 1;
16
+ else if (f) r -= 1;
17
+ else return o(r, s);
18
+ }
19
+ }, d = (e, n, a, r) => {
20
+ const s = (l) => l !== null && a(l);
21
+ let t = 0, f = 0, g = i(e, n, t, f);
22
+ if (!a(g)) return m(e, n, a);
23
+ for (; ; ) {
24
+ const l = t < r && e - t > 3 ? i(e, n, t + 1, f) : null, h = f < r && e + f < n - 2 ? i(e, n, t, f + 1) : null;
25
+ if (s(h) && (f <= t || !s(l)))
26
+ f += 1, g = h;
27
+ else if (s(l))
28
+ t += 1, g = l;
29
+ else return g;
30
+ }
31
+ };
32
+ export {
33
+ d as getPageItems
34
+ };
@@ -23,7 +23,7 @@ var r = (i) => {
23
23
  const o = {
24
24
  ...i,
25
25
  lib: d,
26
- libBuildNumber: 688,
26
+ libBuildNumber: 690,
27
27
  libCommit: n,
28
28
  libBuildDate: t
29
29
  };
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
- var I = "4.2.0", B = 688, L = "339e81f", _ = "2026-11-12T14:49:28.193Z", r = "688";
1
+ var I = "4.2.1", B = 690, L = "3b389dd", _ = "2026-11-16T09:38:17.765Z", r = "690";
2
2
  export {
3
3
  _ as LIB_BUILD_DATE,
4
4
  r as LIB_BUILD_ID,
package/dist/version.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "4.2.0",
3
- "buildNumber": 688,
4
- "commit": "339e81f",
5
- "buildDate": "2026-11-12T14:49:28.193Z"
2
+ "version": "4.2.1",
3
+ "buildNumber": 690,
4
+ "commit": "3b389dd",
5
+ "buildDate": "2026-11-16T09:38:17.765Z"
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memobit/libs",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "React component library powering the Memobit apps — 100+ components, helpers and hooks. Icons ship as @memobit/icons and themes as @memobit/themes. TypeScript-first, ESM-only, React 19.",
5
5
  "keywords": [
6
6
  "react",