@bexis2/bexis2-core-ui 0.4.27 → 0.4.29

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/README.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # bexis-core-ui
2
- ## 04.27
2
+
3
+ ## 0.4.29
4
+ - table
5
+ - Fixes the appearance issues related to Table paginator.
6
+ -
7
+ ## 0.4.28
8
+ - Fixes issue with options component not displaying items correctly
9
+ - New pagination component
10
+ - Removes the option for selecting page index string type of "pages" or "items". "items" will be the default and only option to show pagination info now.
11
+
12
+ ## 0.4.27
3
13
  - Fixes the issue with updating the number of displayed items correctly.
4
14
  - Makes "items" the default type for displaying pagination info.
5
15
 
@@ -50,8 +50,6 @@ let {
50
50
  // Whether to display the search input
51
51
  pageSizes = [5, 10, 20, 50, 100],
52
52
  // Page sizes to display in the pagination component
53
- pageIndexStringType = "items",
54
- // items by default
55
53
  fitToScreen = true,
56
54
  // Whether to fit the table to the screen,
57
55
  exportable = false,
@@ -566,7 +564,7 @@ $: $hiddenColumnIds = shownColumns.filter((col) => !col.visible).map((col) => co
566
564
  ? utils.minWidth(cell.id, columns)
567
565
  : $colWidths[index]
568
566
  }px;`
569
- : 'max-width: min-content;'}
567
+ : ''}
570
568
  >
571
569
  <Render of={cell.render()} />
572
570
  </div>
@@ -608,7 +606,6 @@ $: $hiddenColumnIds = shownColumns.filter((col) => !col.visible).map((col) => co
608
606
  {serverItemCount}
609
607
  updateTable={updateTableWithParams}
610
608
  {pageSizes}
611
- {pageIndexStringType}
612
609
  id={tableId}
613
610
  />
614
611
  {:else}
@@ -617,7 +614,6 @@ $: $hiddenColumnIds = shownColumns.filter((col) => !col.visible).map((col) => co
617
614
  pageConfig={pluginStates.page}
618
615
  {pageSizes}
619
616
  id={tableId}
620
- {pageIndexStringType}
621
617
  />
622
618
  {/if}
623
619
  {/if}
@@ -1,33 +1,12 @@
1
1
  <script>import Fa from "svelte-fa";
2
- import {
3
- faAnglesRight,
4
- faAngleRight,
5
- faAnglesLeft,
6
- faAngleLeft,
7
- faChevronDown
8
- } from "@fortawesome/free-solid-svg-icons";
9
- import { ListBox, ListBoxItem, popup } from "@skeletonlabs/skeleton";
2
+ import { faChevronDown } from "@fortawesome/free-solid-svg-icons";
3
+ import { ListBox, ListBoxItem, Paginator, popup } from "@skeletonlabs/skeleton";
10
4
  export let itemCount;
11
5
  export let pageConfig;
12
6
  export let pageSizes;
13
- export let pageIndexStringType;
14
7
  export let id;
15
8
  let indexInformation = "";
16
- const { pageIndex, pageCount, pageSize, hasNextPage, hasPreviousPage } = pageConfig;
17
- const goToFirstPage = () => $pageIndex = 0;
18
- const goToLastPage = () => $pageIndex = $pageCount - 1;
19
- const goToNextPage = () => $pageIndex += 1;
20
- const goToPreviousPage = () => $pageIndex -= 1;
21
- const handleChange = (e) => {
22
- const value = e.target.value;
23
- if (value > $pageCount) {
24
- $pageIndex = $pageCount - 1;
25
- } else if (value < 1) {
26
- $pageIndex = 0;
27
- } else {
28
- $pageIndex = value - 1;
29
- }
30
- };
9
+ const { pageIndex, pageCount, pageSize } = pageConfig;
31
10
  let pageSizeDropdownValue = $pageSize;
32
11
  const pageSizePopup = {
33
12
  event: "click",
@@ -36,45 +15,31 @@ const pageSizePopup = {
36
15
  closeQuery: ".listbox-item"
37
16
  };
38
17
  const getIndexInfomationString = () => {
39
- if (pageIndexStringType === "pages") {
40
- return $pageCount > 0 ? `Page ${$pageIndex + 1} of ${$pageCount}` : "No pages";
41
- } else {
42
- return itemCount === 0 ? "No items" : `Displaying items ${$pageIndex * $pageSize + 1} - ${Math.min(
43
- ($pageIndex + 1) * $pageSize,
44
- itemCount
45
- )} of ${Math.min($pageCount * $pageSize, itemCount)}`;
46
- }
18
+ return itemCount === 0 ? "No items" : `Displaying items ${$pageIndex * $pageSize + 1} - ${Math.min(
19
+ ($pageIndex + 1) * $pageSize,
20
+ itemCount
21
+ )} of ${Math.min($pageCount * $pageSize, itemCount)}`;
22
+ };
23
+ $: paginationSettings = {
24
+ size: itemCount,
25
+ limit: $pageSize,
26
+ page: $pageIndex,
27
+ amounts: pageSizes
47
28
  };
48
- $: goToFirstPageDisabled = !$pageIndex;
49
- $: goToLastPageDisabled = $pageIndex == $pageCount - 1;
50
- $: goToNextPageDisabled = !$hasNextPage;
51
- $: goToPreviousPageDisabled = !$hasPreviousPage;
52
29
  $: $pageSize = pageSizeDropdownValue;
53
30
  $: $pageCount, $pageIndex, $pageSize, itemCount, indexInformation = getIndexInfomationString();
54
31
  </script>
55
32
 
56
- <div class="flex justify-between w-full items-stretch gap-10">
33
+ <div class="grid grid-cols-3 w-full items-stretch gap-10">
57
34
  <div class="flex justify-start">
58
- <!-- <select
59
- name="pageSize"
60
- id="{id}-pageSize"
61
- class="select variant-filled-primary w-min font-bold"
62
- bind:value={$pageSize}
63
- >
64
- {#each pageSizes as size}
65
- <option value={size} class="">{size}</option>
66
- {/each}
67
- </select> -->
68
-
69
35
  <button
70
36
  aria-label="Open menu to select number of items to display per page"
71
- class="btn variant-filled-primary w-20 justify-between"
37
+ class="btn variant-filled-primary w-20 !px-3 !py-1.5 justify-between"
72
38
  use:popup={pageSizePopup}
73
39
  >
74
40
  <span class="capitalize font-semibold">{pageSizeDropdownValue}</span>
75
41
  <Fa icon={faChevronDown} size="xs" />
76
42
  </button>
77
-
78
43
  <div class="card w-20 shadow-xl py-2" data-popup={`#${id}-pageSizeDropdown`}>
79
44
  <ListBox rounded="rounded-none">
80
45
  {#each pageSizes as size}
@@ -86,48 +51,19 @@ $: $pageCount, $pageIndex, $pageSize, itemCount, indexInformation = getIndexInfo
86
51
  <div class="arrow bg-surface-100-800-token" />
87
52
  </div>
88
53
  </div>
89
- <div class="flex justify-center gap-1">
90
- <button
91
- class="btn btn-sm variant-filled-primary"
92
- on:click|preventDefault={goToFirstPage}
93
- aria-label="Go to first page"
94
- disabled={goToFirstPageDisabled}
95
- id="{id}-first"
96
- >
97
- <Fa icon={faAnglesLeft} /></button
98
- >
99
- <button
100
- class="btn btn-sm variant-filled-primary"
101
- id="{id}-previous"
102
- aria-label="Go to previous page"
103
- on:click|preventDefault={goToPreviousPage}
104
- disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
105
- >
106
- <input
107
- type="number"
108
- class="input border border-primary-500 rounded flex w-24"
109
- value={$pageIndex + 1}
110
- max={$pageCount}
111
- aria-label="Current page"
112
- min={1}
113
- on:change={handleChange}
54
+ <div class="flex justify-center">
55
+ <Paginator
56
+ on:page={(page) => ($pageIndex = page.detail)}
57
+ settings={paginationSettings}
58
+ select="hidden"
59
+ active="active"
60
+ controlVariant=""
61
+ regionControl="btn-group"
62
+ maxNumerals={1}
63
+ showNumerals
114
64
  />
115
- <button
116
- class="btn btn-sm variant-filled-primary"
117
- id="{id}-next"
118
- aria-label="Go to next page"
119
- on:click|preventDefault={goToNextPage}
120
- disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
121
- >
122
- <button
123
- class="btn btn-sm variant-filled-primary"
124
- aria-label="Go to last page"
125
- id="{id}-last"
126
- on:click|preventDefault={goToLastPage}
127
- disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
128
- >
129
65
  </div>
130
- <div class="flex justify-end items-center">
131
- <span class="text-sm text-gray-500">{indexInformation}</span>
66
+ <div class="flex justify-end items-center text-on-primary-token">
67
+ <span class="text-xs text-gray-500">{indexInformation}</span>
132
68
  </div>
133
69
  </div>
@@ -4,7 +4,6 @@ declare const __propDef: {
4
4
  itemCount: any;
5
5
  pageConfig: any;
6
6
  pageSizes: any;
7
- pageIndexStringType: any;
8
7
  id: any;
9
8
  };
10
9
  events: {
@@ -8,7 +8,6 @@ import {
8
8
  export let id;
9
9
  export let pageIndex;
10
10
  export let pageSize;
11
- export let pageIndexStringType;
12
11
  export let pageSizes;
13
12
  export let serverItemCount;
14
13
  export let updateTable;
@@ -48,11 +47,10 @@ const goTo = (dst) => {
48
47
  updateTable();
49
48
  };
50
49
  const getIndexInfomationString = () => {
51
- if (pageIndexStringType === "pages") {
52
- return pageCount > 0 ? `Page ${$pageIndex + 1} of ${pageCount}` : "No pages";
53
- } else {
54
- return `Showing ${$pageIndex * $pageSize + 1} - ${($pageIndex + 1) * $pageSize} of ${pageCount * $pageSize} items`;
55
- }
50
+ return serverItemCount === 0 ? "No items" : `Displaying items ${$pageIndex * $pageSize + 1} - ${Math.min(
51
+ ($pageIndex + 1) * $pageSize,
52
+ serverItemCount
53
+ )} of ${Math.min(pageCount * $pageSize, serverItemCount)}`;
56
54
  };
57
55
  $: pageCount = Math.ceil($serverItemCount / $pageSize);
58
56
  $: goToFirstPageDisabled = !$pageIndex;
@@ -4,7 +4,6 @@ declare const __propDef: {
4
4
  id: any;
5
5
  pageIndex: any;
6
6
  pageSize: any;
7
- pageIndexStringType: any;
8
7
  pageSizes: any;
9
8
  serverItemCount: any;
10
9
  updateTable: any;
@@ -6,6 +6,12 @@ import type { Columns, Filter, ServerColumn, ServerConfig } from '../../models/M
6
6
  export declare const minWidth: (id: string, columns: Columns | undefined) => number;
7
7
  export declare const fixedWidth: (id: string, columns: Columns | undefined) => number;
8
8
  export declare const cellStyle: (id: string, columns: Columns | undefined) => string;
9
+ export declare const getResizeStyles: (rowHeights: {
10
+ [key: number]: {
11
+ max: number;
12
+ min: number;
13
+ };
14
+ }, id: string | number, index: number) => string;
9
15
  export declare const normalizeFilters: (filters: {
10
16
  [key: string]: { [key in FilterOptionsEnum]?: number | string | Date; };
11
17
  }) => Filter[];
@@ -26,9 +32,3 @@ export declare const getMaxCellHeightInRow: (tableRef: HTMLTableElement, resizab
26
32
  };
27
33
  }>, tableId: string, rowHeight: number | null) => void;
28
34
  export declare const getMinCellWidthInColumn: (tableRef: HTMLTableElement, colWidths: Writable<number[]>, headerRowsLength: number, resizable: "columns" | "rows" | "none" | "both") => void;
29
- export declare const getResizeStyles: (rowHeights: {
30
- [key: number]: {
31
- max: number;
32
- min: number;
33
- };
34
- }, id: string | number, index: number) => string;
@@ -27,6 +27,16 @@ export const cellStyle = (id, columns) => {
27
27
  // Create and return styles separated by ';'
28
28
  return styles.join(';');
29
29
  };
30
+ // Styles for resizing the cells
31
+ export const getResizeStyles = (rowHeights, id, index) => {
32
+ return `
33
+ min-height: ${rowHeights && rowHeights[+id] ? `${rowHeights[+id].min}px` : 'auto'};
34
+ max-height: ${index !== 0 && rowHeights && rowHeights[+id]
35
+ ? `${rowHeights[+id].max}px`
36
+ : 'auto'};
37
+ height: ${rowHeights && rowHeights[+id] ? `${rowHeights[+id].min}px` : 'auto'};
38
+ `;
39
+ };
30
40
  // Function to normalize the filters for back-end
31
41
  export const normalizeFilters = (filters) => {
32
42
  let filter = [];
@@ -44,6 +54,7 @@ export const normalizeFilters = (filters) => {
44
54
  });
45
55
  return filter;
46
56
  };
57
+ // Creates a CSV file and downloads it
47
58
  export const exportAsCsv = (tableId, exportedData) => {
48
59
  // Creating a hidden anchor element to download the CSV file
49
60
  const anchor = document.createElement('a');
@@ -54,6 +65,7 @@ export const exportAsCsv = (tableId, exportedData) => {
54
65
  anchor.click();
55
66
  document.body.removeChild(anchor);
56
67
  };
68
+ // Function to convert JSON data to CSV format
57
69
  export const jsonToCsv = (data) => {
58
70
  const json = JSON.parse(data);
59
71
  if (json.length === 0)
@@ -115,6 +127,7 @@ export const resetResize = (headerRows, pageRows, tableId, columns, resizable) =
115
127
  });
116
128
  }
117
129
  };
130
+ // Finds the mapping for missing values
118
131
  export const missingValuesFn = (key, missingValues) => {
119
132
  const foundKey = typeof key === 'number' && key.toString().includes('e')
120
133
  ? Object.keys(missingValues).find((item) => {
@@ -175,6 +188,7 @@ export const updateTable = async (pageSize, pageIndex, server, filters, data, se
175
188
  serverItems?.set(response.count);
176
189
  return response;
177
190
  };
191
+ // Function to convert server data to client data
178
192
  export const convertServerColumns = (serverColumns, columns) => {
179
193
  const columnsConfig = {};
180
194
  serverColumns.forEach((col) => {
@@ -277,12 +291,3 @@ export const getMinCellWidthInColumn = (tableRef, colWidths, headerRowsLength, r
277
291
  return cw;
278
292
  });
279
293
  };
280
- export const getResizeStyles = (rowHeights, id, index) => {
281
- return `
282
- min-height: ${rowHeights && rowHeights[+id] ? `${rowHeights[+id].min}px` : 'auto'};
283
- max-height: ${index !== 0 && rowHeights && rowHeights[+id]
284
- ? `${rowHeights[+id].max}px`
285
- : 'auto'};
286
- height: ${rowHeights && rowHeights[+id] ? `${rowHeights[+id].min}px` : 'auto'};
287
- `;
288
- };
@@ -100,7 +100,6 @@ export interface TableConfig<T> {
100
100
  exportable?: boolean;
101
101
  pageSizes?: number[];
102
102
  defaultPageSize?: number;
103
- pageIndexStringType?: 'items' | 'pages';
104
103
  optionsComponent?: typeof SvelteComponent;
105
104
  server?: ServerConfig;
106
105
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bexis2/bexis2-core-ui",
3
- "version": "0.4.27",
3
+ "version": "0.4.29",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -48,7 +48,6 @@
48
48
  toggle = false, // Whether to display the fitToScreen toggle
49
49
  search = true, // Whether to display the search input
50
50
  pageSizes = [5, 10, 20, 50, 100], // Page sizes to display in the pagination component
51
- pageIndexStringType = 'items', // items by default
52
51
  fitToScreen = true, // Whether to fit the table to the screen,
53
52
  exportable = false, // Whether to display the export button and enable export functionality
54
53
  server
@@ -644,7 +643,7 @@
644
643
  ? utils.minWidth(cell.id, columns)
645
644
  : $colWidths[index]
646
645
  }px;`
647
- : 'max-width: min-content;'}
646
+ : ''}
648
647
  >
649
648
  <Render of={cell.render()} />
650
649
  </div>
@@ -686,7 +685,6 @@
686
685
  {serverItemCount}
687
686
  updateTable={updateTableWithParams}
688
687
  {pageSizes}
689
- {pageIndexStringType}
690
688
  id={tableId}
691
689
  />
692
690
  {:else}
@@ -695,7 +693,6 @@
695
693
  pageConfig={pluginStates.page}
696
694
  {pageSizes}
697
695
  id={tableId}
698
- {pageIndexStringType}
699
696
  />
700
697
  {/if}
701
698
  {/if}
@@ -1,41 +1,17 @@
1
1
  <script lang="ts">
2
2
  import Fa from 'svelte-fa';
3
- import {
4
- faAnglesRight,
5
- faAngleRight,
6
- faAnglesLeft,
7
- faAngleLeft,
8
- faChevronDown
9
- } from '@fortawesome/free-solid-svg-icons';
10
- import { ListBox, ListBoxItem, popup, type PopupSettings } from '@skeletonlabs/skeleton';
3
+ import { faChevronDown } from '@fortawesome/free-solid-svg-icons';
4
+ import { ListBox, ListBoxItem, Paginator, popup } from '@skeletonlabs/skeleton';
5
+ import type { PopupSettings } from '@skeletonlabs/skeleton';
11
6
 
12
7
  export let itemCount;
13
8
  export let pageConfig;
14
9
  export let pageSizes;
15
- export let pageIndexStringType;
16
10
  export let id;
17
11
 
18
12
  let indexInformation = '';
19
13
 
20
- const { pageIndex, pageCount, pageSize, hasNextPage, hasPreviousPage } = pageConfig;
21
-
22
- const goToFirstPage = () => ($pageIndex = 0);
23
- const goToLastPage = () => ($pageIndex = $pageCount - 1);
24
- const goToNextPage = () => ($pageIndex += 1);
25
- const goToPreviousPage = () => ($pageIndex -= 1);
26
-
27
- // Handles the input change event
28
- const handleChange = (e) => {
29
- const value = e.target.value;
30
-
31
- if (value > $pageCount) {
32
- $pageIndex = $pageCount - 1;
33
- } else if (value < 1) {
34
- $pageIndex = 0;
35
- } else {
36
- $pageIndex = value - 1;
37
- }
38
- };
14
+ const { pageIndex, pageCount, pageSize } = pageConfig;
39
15
 
40
16
  let pageSizeDropdownValue: string = $pageSize;
41
17
 
@@ -47,46 +23,34 @@
47
23
  };
48
24
 
49
25
  const getIndexInfomationString = () => {
50
- if (pageIndexStringType === 'pages') {
51
- return $pageCount > 0 ? `Page ${$pageIndex + 1} of ${$pageCount}` : 'No pages';
52
- } else {
53
- return itemCount === 0 ? 'No items' : `Displaying items ${$pageIndex * $pageSize + 1} - ${Math.min(
54
- ($pageIndex + 1) * $pageSize,
55
- itemCount
56
- )} of ${Math.min($pageCount * $pageSize, itemCount)}`;
57
- }
26
+ return itemCount === 0
27
+ ? 'No items'
28
+ : `Displaying items ${$pageIndex * $pageSize + 1} - ${Math.min(
29
+ ($pageIndex + 1) * $pageSize,
30
+ itemCount
31
+ )} of ${Math.min($pageCount * $pageSize, itemCount)}`;
58
32
  };
59
33
 
60
- $: goToFirstPageDisabled = !$pageIndex;
61
- $: goToLastPageDisabled = $pageIndex == $pageCount - 1;
62
- $: goToNextPageDisabled = !$hasNextPage;
63
- $: goToPreviousPageDisabled = !$hasPreviousPage;
34
+ $: paginationSettings = {
35
+ size: itemCount,
36
+ limit: $pageSize,
37
+ page: $pageIndex,
38
+ amounts: pageSizes
39
+ };
64
40
  $: $pageSize = pageSizeDropdownValue;
65
41
  $: $pageCount, $pageIndex, $pageSize, itemCount, (indexInformation = getIndexInfomationString());
66
42
  </script>
67
43
 
68
- <div class="flex justify-between w-full items-stretch gap-10">
44
+ <div class="grid grid-cols-3 w-full items-stretch gap-10">
69
45
  <div class="flex justify-start">
70
- <!-- <select
71
- name="pageSize"
72
- id="{id}-pageSize"
73
- class="select variant-filled-primary w-min font-bold"
74
- bind:value={$pageSize}
75
- >
76
- {#each pageSizes as size}
77
- <option value={size} class="">{size}</option>
78
- {/each}
79
- </select> -->
80
-
81
46
  <button
82
47
  aria-label="Open menu to select number of items to display per page"
83
- class="btn variant-filled-primary w-20 justify-between"
48
+ class="btn variant-filled-primary w-20 !px-3 !py-1.5 justify-between"
84
49
  use:popup={pageSizePopup}
85
50
  >
86
51
  <span class="capitalize font-semibold">{pageSizeDropdownValue}</span>
87
52
  <Fa icon={faChevronDown} size="xs" />
88
53
  </button>
89
-
90
54
  <div class="card w-20 shadow-xl py-2" data-popup={`#${id}-pageSizeDropdown`}>
91
55
  <ListBox rounded="rounded-none">
92
56
  {#each pageSizes as size}
@@ -98,48 +62,19 @@
98
62
  <div class="arrow bg-surface-100-800-token" />
99
63
  </div>
100
64
  </div>
101
- <div class="flex justify-center gap-1">
102
- <button
103
- class="btn btn-sm variant-filled-primary"
104
- on:click|preventDefault={goToFirstPage}
105
- aria-label="Go to first page"
106
- disabled={goToFirstPageDisabled}
107
- id="{id}-first"
108
- >
109
- <Fa icon={faAnglesLeft} /></button
110
- >
111
- <button
112
- class="btn btn-sm variant-filled-primary"
113
- id="{id}-previous"
114
- aria-label="Go to previous page"
115
- on:click|preventDefault={goToPreviousPage}
116
- disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
117
- >
118
- <input
119
- type="number"
120
- class="input border border-primary-500 rounded flex w-24"
121
- value={$pageIndex + 1}
122
- max={$pageCount}
123
- aria-label="Current page"
124
- min={1}
125
- on:change={handleChange}
65
+ <div class="flex justify-center">
66
+ <Paginator
67
+ on:page={(page) => ($pageIndex = page.detail)}
68
+ settings={paginationSettings}
69
+ select="hidden"
70
+ active="active"
71
+ controlVariant=""
72
+ regionControl="btn-group"
73
+ maxNumerals={1}
74
+ showNumerals
126
75
  />
127
- <button
128
- class="btn btn-sm variant-filled-primary"
129
- id="{id}-next"
130
- aria-label="Go to next page"
131
- on:click|preventDefault={goToNextPage}
132
- disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
133
- >
134
- <button
135
- class="btn btn-sm variant-filled-primary"
136
- aria-label="Go to last page"
137
- id="{id}-last"
138
- on:click|preventDefault={goToLastPage}
139
- disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
140
- >
141
76
  </div>
142
- <div class="flex justify-end items-center">
143
- <span class="text-sm text-gray-500">{indexInformation}</span>
77
+ <div class="flex justify-end items-center text-on-primary-token">
78
+ <span class="text-xs text-gray-500">{indexInformation}</span>
144
79
  </div>
145
80
  </div>
@@ -10,7 +10,6 @@
10
10
  export let id; // Unique table ID
11
11
  export let pageIndex;
12
12
  export let pageSize;
13
- export let pageIndexStringType;
14
13
  export let pageSizes; // Available page sizes
15
14
  export let serverItemCount; // Total number of items expected from the server. `serverSide` must be true on table config.
16
15
  export let updateTable; // Function to update table
@@ -63,13 +62,12 @@
63
62
  };
64
63
 
65
64
  const getIndexInfomationString = () => {
66
- if (pageIndexStringType === 'pages') {
67
- return pageCount > 0 ? `Page ${$pageIndex + 1} of ${pageCount}` : 'No pages';
68
- } else {
69
- return `Showing ${$pageIndex * $pageSize + 1} - ${($pageIndex + 1) * $pageSize} of ${
70
- pageCount * $pageSize
71
- } items`;
72
- }
65
+ return serverItemCount === 0
66
+ ? 'No items'
67
+ : `Displaying items ${$pageIndex * $pageSize + 1} - ${Math.min(
68
+ ($pageIndex + 1) * $pageSize,
69
+ serverItemCount
70
+ )} of ${Math.min(pageCount * $pageSize, serverItemCount)}`;
73
71
  };
74
72
 
75
73
  $: pageCount = Math.ceil($serverItemCount / $pageSize);
@@ -33,6 +33,21 @@ export const cellStyle = (id: string, columns: Columns | undefined) => {
33
33
  // Create and return styles separated by ';'
34
34
  return styles.join(';');
35
35
  };
36
+ // Styles for resizing the cells
37
+ export const getResizeStyles = (
38
+ rowHeights: { [key: number]: { max: number; min: number } },
39
+ id: string | number,
40
+ index: number
41
+ ) => {
42
+ return `
43
+ min-height: ${rowHeights && rowHeights[+id] ? `${rowHeights[+id].min}px` : 'auto'};
44
+ max-height: ${index !== 0 && rowHeights && rowHeights[+id]
45
+ ? `${rowHeights[+id].max}px`
46
+ : 'auto'
47
+ };
48
+ height: ${rowHeights && rowHeights[+id] ? `${rowHeights[+id].min}px` : 'auto'};
49
+ `;
50
+ }
36
51
  // Function to normalize the filters for back-end
37
52
  export const normalizeFilters = (filters: {
38
53
  [key: string]: { [key in FilterOptionsEnum]?: number | string | Date };
@@ -54,7 +69,7 @@ export const normalizeFilters = (filters: {
54
69
 
55
70
  return filter;
56
71
  };
57
-
72
+ // Creates a CSV file and downloads it
58
73
  export const exportAsCsv = (tableId: string, exportedData: string) => {
59
74
  // Creating a hidden anchor element to download the CSV file
60
75
  const anchor = document.createElement('a');
@@ -65,7 +80,7 @@ export const exportAsCsv = (tableId: string, exportedData: string) => {
65
80
  anchor.click();
66
81
  document.body.removeChild(anchor);
67
82
  };
68
-
83
+ // Function to convert JSON data to CSV format
69
84
  export const jsonToCsv = (data: string): string => {
70
85
  const json = JSON.parse(data);
71
86
 
@@ -96,7 +111,6 @@ export const jsonToCsv = (data: string): string => {
96
111
  // Join rows with newlines
97
112
  return rows.join('\n');
98
113
  }
99
-
100
114
  // Resetting the resized columns and/or rows
101
115
  export const resetResize = (
102
116
  headerRows: any,
@@ -140,7 +154,7 @@ export const resetResize = (
140
154
  });
141
155
  }
142
156
  };
143
-
157
+ // Finds the mapping for missing values
144
158
  export const missingValuesFn = (
145
159
  key: number | string,
146
160
  missingValues: { [key: string | number]: string }
@@ -160,7 +174,6 @@ export const missingValuesFn = (
160
174
 
161
175
  return foundKey ? missingValues[foundKey] : key;
162
176
  };
163
-
164
177
  // Function to update the server-side table data
165
178
  export const updateTable = async (
166
179
  pageSize: number,
@@ -230,7 +243,7 @@ export const updateTable = async (
230
243
 
231
244
  return response;
232
245
  };
233
-
246
+ // Function to convert server data to client data
234
247
  export const convertServerColumns = (
235
248
  serverColumns: ServerColumn[],
236
249
  columns: Columns | undefined
@@ -288,7 +301,6 @@ export const convertServerColumns = (
288
301
 
289
302
  return columnsConfig;
290
303
  };
291
-
292
304
  // Calculates the maximum height of the cells in each row
293
305
  export const getMaxCellHeightInRow = (
294
306
  tableRef: HTMLTableElement,
@@ -329,7 +341,6 @@ export const getMaxCellHeightInRow = (
329
341
  });
330
342
  });
331
343
  };
332
-
333
344
  // Calculates the minimum width of the cells in each column
334
345
  export const getMinCellWidthInColumn = (
335
346
  tableRef: HTMLTableElement,
@@ -355,19 +366,4 @@ export const getMinCellWidthInColumn = (
355
366
  });
356
367
  return cw;
357
368
  });
358
- };
359
-
360
- export const getResizeStyles = (
361
- rowHeights: { [key: number]: { max: number; min: number } },
362
- id: string | number,
363
- index: number
364
- ) => {
365
- return `
366
- min-height: ${rowHeights && rowHeights[+id] ? `${rowHeights[+id].min}px` : 'auto'};
367
- max-height: ${index !== 0 && rowHeights && rowHeights[+id]
368
- ? `${rowHeights[+id].max}px`
369
- : 'auto'
370
- };
371
- height: ${rowHeights && rowHeights[+id] ? `${rowHeights[+id].min}px` : 'auto'};
372
- `;
373
- }
369
+ };
@@ -127,7 +127,6 @@ export interface TableConfig<T> {
127
127
  exportable?: boolean; // false by default
128
128
  pageSizes?: number[]; // [5, 10, 20, 50, 100] by default
129
129
  defaultPageSize?: number; // 10 by default
130
- pageIndexStringType?: 'items' | 'pages'; // pages by default
131
130
  optionsComponent?: typeof SvelteComponent;
132
131
 
133
132
  server?: ServerConfig;