@vc-shell/framework 1.0.273 → 1.0.274

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/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## [1.0.274](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.273...v1.0.274) (2024-08-19)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **ui:** vc-pagination pagesToShow logic refactor ([92153d8](https://github.com/VirtoCommerce/vc-shell/commit/92153d8a91990274682fca1490cdc5a9cc9e784a))
7
+
8
+
9
+
1
10
  ## [1.0.273](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.272...v1.0.273) (2024-08-16)
2
11
 
3
12
 
package/dist/framework.js CHANGED
@@ -26761,15 +26761,16 @@ const Cae = ["onClick"], Iae = ["disabled", "placeholder"], MI = /* @__PURE__ */
26761
26761
  (!/^\d$/.test(u.key) && !d.includes(u.key) || a.value >= n.pages && u.key !== "Backspace" && u.key !== "Delete") && u.preventDefault();
26762
26762
  }
26763
26763
  const c = re(() => {
26764
- const u = [];
26764
+ const u = [], f = n.pages, h = i.value;
26765
26765
  if (n.pages <= 5)
26766
- for (let f = 1; f <= n.pages; f++)
26767
- u.push(f);
26766
+ for (let m = 1; m <= n.pages; m++)
26767
+ u.push(m);
26768
26768
  else {
26769
- i.value >= 1 && u.push(1), i.value > 3 && u.push("...");
26770
- for (let f = Math.max(2, i.value - 2); f <= Math.min(n.pages - 1, i.value + 2); f++)
26771
- u.push(f);
26772
- i.value < n.pages - 2 && u.push("..."), i.value <= n.pages && u.push(n.pages);
26769
+ const m = (p, g) => {
26770
+ for (let v = p; v <= g; v++)
26771
+ u.push(v);
26772
+ };
26773
+ u.push(1), h <= 4 ? (m(2, 5), u.push("...")) : h >= f - 3 ? (u.push("..."), m(f - 4, f - 1)) : (u.push("..."), m(h - 1, h + 1), u.push("...")), u.push(n.pages);
26773
26774
  }
26774
26775
  return u;
26775
26776
  });
@@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AC,CAAC,CAAC,CAAC,CAAA;KACb,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AACN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vc-shell/framework",
3
- "version": "1.0.273",
3
+ "version": "1.0.274",
4
4
  "type": "module",
5
5
  "main": "./dist/framework.js",
6
6
  "types": "./dist/index.d.ts",
@@ -61,9 +61,9 @@
61
61
  "devDependencies": {
62
62
  "@types/dompurify": "^3.0.5",
63
63
  "@types/quill": "^2.0.14",
64
- "@vc-shell/api-client-generator": "^1.0.273",
65
- "@vc-shell/config-generator": "^1.0.273",
66
- "@vc-shell/ts-config": "^1.0.273",
64
+ "@vc-shell/api-client-generator": "^1.0.274",
65
+ "@vc-shell/config-generator": "^1.0.274",
66
+ "@vc-shell/ts-config": "^1.0.274",
67
67
  "@vitejs/plugin-vue": "^5.0.3",
68
68
  "cypress-signalr-mock": "^1.5.0",
69
69
  "sass": "^1.69.6",
@@ -125,26 +125,36 @@ function onKeyDown(e: KeyboardEvent) {
125
125
 
126
126
  const pagesToShow = computed(() => {
127
127
  const pages = [];
128
- const range = 2;
128
+ const range = 1;
129
+ const totalPages = props.pages;
130
+ const current = currentPage.value;
129
131
 
130
132
  if (props.pages <= 5) {
131
133
  for (let i = 1; i <= props.pages; i++) {
132
134
  pages.push(i);
133
135
  }
134
136
  } else {
135
- if (currentPage.value >= 1) pages.push(1);
136
- if (currentPage.value > 3) pages.push("...");
137
-
138
- for (
139
- let i = Math.max(2, currentPage.value - range);
140
- i <= Math.min(props.pages - 1, currentPage.value + range);
141
- i++
142
- ) {
143
- pages.push(i);
137
+ const addRange = (start: number, end: number) => {
138
+ for (let i = start; i <= end; i++) {
139
+ pages.push(i);
140
+ }
141
+ };
142
+
143
+ pages.push(1);
144
+
145
+ if (current <= 4) {
146
+ addRange(2, 5);
147
+ pages.push("...");
148
+ } else if (current >= totalPages - 3) {
149
+ pages.push("...");
150
+ addRange(totalPages - 4, totalPages - 1);
151
+ } else {
152
+ pages.push("...");
153
+ addRange(current - range, current + range);
154
+ pages.push("...");
144
155
  }
145
156
 
146
- if (currentPage.value < props.pages - 2) pages.push("...");
147
- if (currentPage.value <= props.pages) pages.push(props.pages);
157
+ pages.push(props.pages);
148
158
  }
149
159
 
150
160
  return pages;