@enki-tek/fms-web-components 0.1.60 → 0.1.62

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.
@@ -7,12 +7,12 @@ export let noOfItems = 300;
7
7
  export let itemPerPage = 30;
8
8
  export let currentPage = 1;
9
9
  export let size = "md";
10
- $:
11
- pageCount = Math.ceil(noOfItems / itemPerPage);
10
+ let pageCount = Math.ceil(noOfItems / itemPerPage);
12
11
  let pagesToShow = pageCount > DEFAULT_PAGE_COUNT ? DEFAULT_PAGE_COUNT : pageCount;
13
- let pageNumbers = [];
14
12
  let endPage;
15
- function calculatePageNumbers() {
13
+ const calculatePageNumbers = (noOfItems2) => {
14
+ pageCount = Math.ceil(noOfItems2 / itemPerPage);
15
+ pagesToShow = pageCount > DEFAULT_PAGE_COUNT ? DEFAULT_PAGE_COUNT : pageCount;
16
16
  const halfPagesToShow = Math.floor(pagesToShow / 2);
17
17
  let startPage = currentPage - halfPagesToShow;
18
18
  endPage = currentPage + halfPagesToShow;
@@ -24,11 +24,8 @@ function calculatePageNumbers() {
24
24
  endPage = pageCount;
25
25
  startPage = pageCount - pagesToShow + 1;
26
26
  }
27
- pageNumbers = Array(endPage - startPage + 1).fill().map((_, idx) => startPage + idx);
28
- }
29
- onMount(() => {
30
- calculatePageNumbers();
31
- });
27
+ return Array(endPage - startPage + 1).fill().map((_, idx) => startPage + idx);
28
+ };
32
29
  function gotoPage(page) {
33
30
  currentPage = page;
34
31
  dispatch("pageChanged", page);
@@ -49,7 +46,7 @@ function nextPage() {
49
46
  }
50
47
  }
51
48
  </script>
52
-
49
+ {#if calculatePageNumbers(noOfItems).length > 1}
53
50
  <Pagination {size} ariaLabel="Page navigation example">
54
51
  <PaginationItem disabled={currentPage === 1} class="eradius custom-pagination-list">
55
52
  <PaginationLink previous href="#" class="custom-pagination-link-add" on:click={prevPage}
@@ -57,7 +54,7 @@ function nextPage() {
57
54
  >
58
55
  </PaginationItem>
59
56
 
60
- {#each pageNumbers as page}
57
+ {#each calculatePageNumbers(noOfItems) as page}
61
58
  <PaginationItem active={currentPage == page} class="eradius custom-pagination-list">
62
59
  <PaginationLink
63
60
  class="eradius efs-small custom-pagination-link"
@@ -87,6 +84,7 @@ function nextPage() {
87
84
  >
88
85
  </PaginationItem>
89
86
  </Pagination>
87
+ {/if}
90
88
 
91
89
  <style>@import url(https://fonts.googleapis.com/icon?family=Material+Icons);
92
90
  @import url("https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enki-tek/fms-web-components",
3
- "version": "0.1.60",
3
+ "version": "0.1.62",
4
4
  "devDependencies": {
5
5
  "@storybook/addon-essentials": "^7.6.14",
6
6
  "@storybook/addon-interactions": "^7.6.14",