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

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