@bexis2/bexis2-core-ui 0.4.35 → 0.4.37

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,4 +1,12 @@
1
1
  # bexis-core-ui
2
+ ## 0.4.37
3
+ - table
4
+ - Fix server side Pagination
5
+
6
+ ## 0.4.36
7
+ - table
8
+ - Fix server side Pagination
9
+
2
10
  ## 0.4.35
3
11
 
4
12
  - enlarge help and up to start button
@@ -16,7 +16,7 @@
16
16
  <Fa icon={faFileExcel} />
17
17
  {/if}
18
18
 
19
- {#if type.includes('text')}
19
+ {#if type.includes('text') || type.includes('plain') || type.includes('csv') || type.includes('application/octet-stream')}
20
20
  <Fa icon={faFileAlt} />
21
21
  {/if}
22
22
 
@@ -601,11 +601,10 @@ $: $hiddenColumnIds = shownColumns.filter((col) => !col.visible).map((col) => co
601
601
  {#if $data.length > 0 || (columns && Object.keys(columns).length > 0)}
602
602
  {#if serverSide}
603
603
  <TablePaginationServer
604
- {pageIndex}
605
- {pageSize}
606
- {serverItemCount}
607
- updateTable={updateTableWithParams}
604
+ pageConfig={pluginStates.page}
608
605
  {pageSizes}
606
+ itemCount={$serverItemCount}
607
+ updateTable={updateTableWithParams}
609
608
  id={tableId}
610
609
  />
611
610
  {:else}
@@ -1,127 +1,76 @@
1
1
  <script>import Fa from "svelte-fa";
2
- import {
3
- faAnglesRight,
4
- faAngleRight,
5
- faAnglesLeft,
6
- faAngleLeft
7
- } from "@fortawesome/free-solid-svg-icons";
8
- export let id;
9
- export let pageIndex;
10
- export let pageSize;
2
+ import { faChevronDown } from "@fortawesome/free-solid-svg-icons";
3
+ import { ListBox, ListBoxItem, Paginator, popup } from "@skeletonlabs/skeleton";
4
+ export let itemCount;
5
+ export let pageConfig;
11
6
  export let pageSizes;
12
- export let serverItemCount;
7
+ export let id;
13
8
  export let updateTable;
14
- let goToFirstPageDisabled = true;
15
- let goToLastPageDisabled = true;
16
- let goToNextPageDisabled = true;
17
- let goToPreviousPageDisabled = true;
18
9
  let indexInformation = "";
19
- const handleChange = (e) => {
20
- const value = e.target.value;
21
- if (value > pageCount) {
22
- $pageIndex = pageCount - 1;
23
- } else if (value < 1) {
24
- $pageIndex = 0;
25
- } else {
26
- $pageIndex = value - 1;
27
- }
28
- updateTable();
29
- };
30
- const goTo = (dst) => {
31
- switch (dst) {
32
- case "first":
33
- $pageIndex = 0;
34
- break;
35
- case "last":
36
- $pageIndex = pageCount - 1;
37
- break;
38
- case "next":
39
- $pageIndex += 1;
40
- break;
41
- case "previous":
42
- $pageIndex -= 1;
43
- break;
44
- default:
45
- break;
46
- }
47
- updateTable();
10
+ const { pageIndex, pageCount, pageSize } = pageConfig;
11
+ let pageSizeDropdownValue = $pageSize;
12
+ const pageSizePopup = {
13
+ event: "click",
14
+ target: `#${id}-pageSizeDropdown`,
15
+ placement: "bottom",
16
+ closeQuery: ".listbox-item"
48
17
  };
49
18
  const getIndexInfomationString = () => {
50
- return serverItemCount === 0 ? "No items" : `Displaying items ${$pageIndex * $pageSize + 1} - ${Math.min(
19
+ return itemCount === 0 ? "No items" : `Displaying items ${$pageIndex * $pageSize + 1} - ${Math.min(
51
20
  ($pageIndex + 1) * $pageSize,
52
- serverItemCount
53
- )} of ${Math.min(pageCount * $pageSize, serverItemCount)}`;
21
+ itemCount
22
+ )} of ${Math.min($pageCount * $pageSize, itemCount)}`;
23
+ };
24
+ $: paginationSettings = {
25
+ size: itemCount,
26
+ limit: $pageSize,
27
+ page: $pageIndex,
28
+ amounts: pageSizes
54
29
  };
55
- $: pageCount = Math.ceil($serverItemCount / $pageSize);
56
- $: goToFirstPageDisabled = !$pageIndex;
57
- $: goToLastPageDisabled = $pageIndex == pageCount - 1;
58
- $: goToNextPageDisabled = $pageIndex == pageCount - 1;
59
- $: goToPreviousPageDisabled = !$pageIndex;
60
- $: $pageSize && updateTable();
61
- $: pageCount, $pageIndex, $pageSize, indexInformation = getIndexInfomationString();
30
+ $: $pageSize = pageSizeDropdownValue;
31
+ $: $pageCount, $pageIndex, $pageSize, itemCount, indexInformation = getIndexInfomationString();
62
32
  updateTable();
63
33
  </script>
64
34
 
65
- <div class="flex justify-between w-full items-stretch gap-10">
35
+ <div class="grid grid-cols-3 w-full items-stretch gap-10">
66
36
  <div class="flex justify-start">
67
- <select
68
- name="pageSize"
69
- id="{id}-pageSize"
70
- aria-label="Open menu to select number of items per page"
71
- class="select variant-filled-primary w-min font-bold"
72
- bind:value={$pageSize}
73
- >
74
- {#each pageSizes as size}
75
- <option value={size} class="!bg-primary-700">{size}</option>
76
- {/each}
77
- </select>
78
- </div>
79
- <div class="flex justify-center gap-1">
80
- <button
81
- class="btn btn-sm variant-filled-primary"
82
- title="Go to first page"
83
- on:click|preventDefault={() => goTo('first')}
84
- disabled={goToFirstPageDisabled}
85
- aria-label="Go to first page"
86
- id="{id}-first"
87
- >
88
- <Fa icon={faAnglesLeft} /></button
89
- >
37
+ <!-- replace default select from Paginator below to be able to style properly -->
90
38
  <button
91
- class="btn btn-sm variant-filled-primary"
92
- title="Go to previous page"
93
- id="{id}-previous"
94
- aria-label="Go to previous page"
95
- on:click|preventDefault={() => goTo('previous')}
96
- disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
39
+ aria-label="Open menu to select number of items to display per page"
40
+ class="btn variant-filled-primary w-20 !px-3 !py-1.5 justify-between"
41
+ use:popup={pageSizePopup}
97
42
  >
98
- <input
99
- type="number"
100
- class="input border border-primary-500 rounded flex w-24"
101
- aria-label="Current page"
102
- value={$pageIndex + 1}
103
- max={pageCount}
104
- min={1}
105
- on:change={handleChange}
43
+ <span class="capitalize font-semibold">{pageSizeDropdownValue}</span>
44
+ <Fa icon={faChevronDown} size="xs" />
45
+ </button>
46
+ <div class="card w-20 shadow-xl py-2" data-popup={`#${id}-pageSizeDropdown`}>
47
+ <ListBox rounded="rounded-none">
48
+ {#each pageSizes as size}
49
+ <ListBoxItem
50
+ bind:group={pageSizeDropdownValue}
51
+ name="medium" value={size}
52
+ on:click={() => { $pageSize = size; updateTable(); }}
53
+ >{size}</ListBoxItem
54
+ >
55
+ {/each}
56
+ </ListBox>
57
+ <div class="arrow bg-surface-100-800-token" />
58
+ </div>
59
+ </div>
60
+ <div class="flex justify-center">
61
+ <Paginator
62
+ on:page={(page) => {$pageIndex = page.detail; updateTable(); }}
63
+ settings={paginationSettings}
64
+ select="hidden"
65
+ active="!variant-filled-secondary !text-on-secondary-token"
66
+ controlVariant="!text-on-primary-token"
67
+ buttonClasses="!rounded-none !px-3 !py-1.5 fill-current bg-primary-500 hover:!bg-primary-600 !text-on-primary-token disabled:grayscale disabled:!opacity-30"
68
+ regionControl="btn-group"
69
+ maxNumerals={1}
70
+ showNumerals
106
71
  />
107
- <button
108
- class="btn btn-sm variant-filled-primary"
109
- id="{id}-next"
110
- on:click|preventDefault={() => goTo('next')}
111
- aria-label="Go to next page"
112
- disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
113
- >
114
- <button
115
- class="btn btn-sm variant-filled-primary"
116
- id="{id}-last"
117
- aria-label="Go to last page"
118
- on:click|preventDefault={() => goTo('last')}
119
- disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
120
- >
121
72
  </div>
122
- <div class="flex justify-end items-center">
123
- <span class="text-sm text-gray-500">
124
- {indexInformation}
125
- </span>
73
+ <div class="flex justify-end items-center text-on-primary-token">
74
+ <span class="text-xs text-gray-500">{indexInformation}</span>
126
75
  </div>
127
76
  </div>
@@ -1,11 +1,10 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
- id: any;
5
- pageIndex: any;
6
- pageSize: any;
4
+ itemCount: any;
5
+ pageConfig: any;
7
6
  pageSizes: any;
8
- serverItemCount: any;
7
+ id: any;
9
8
  updateTable: any;
10
9
  };
11
10
  events: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bexis2/bexis2-core-ui",
3
- "version": "0.4.35",
3
+ "version": "0.4.37",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -16,7 +16,7 @@
16
16
  <Fa icon={faFileExcel} />
17
17
  {/if}
18
18
 
19
- {#if type.includes('text')}
19
+ {#if type.includes('text') || type.includes('plain') || type.includes('csv') || type.includes('application/octet-stream')}
20
20
  <Fa icon={faFileAlt} />
21
21
  {/if}
22
22
 
@@ -680,11 +680,10 @@
680
680
  {#if $data.length > 0 || (columns && Object.keys(columns).length > 0)}
681
681
  {#if serverSide}
682
682
  <TablePaginationServer
683
- {pageIndex}
684
- {pageSize}
685
- {serverItemCount}
686
- updateTable={updateTableWithParams}
683
+ pageConfig={pluginStates.page}
687
684
  {pageSizes}
685
+ itemCount={$serverItemCount}
686
+ updateTable={updateTableWithParams}
688
687
  id={tableId}
689
688
  />
690
689
  {:else}
@@ -1,146 +1,89 @@
1
1
  <script lang="ts">
2
2
  import Fa from 'svelte-fa';
3
- import {
4
- faAnglesRight,
5
- faAngleRight,
6
- faAnglesLeft,
7
- faAngleLeft
8
- } from '@fortawesome/free-solid-svg-icons';
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';
9
6
 
10
- export let id; // Unique table ID
11
- export let pageIndex;
12
- export let pageSize;
13
- export let pageSizes; // Available page sizes
14
- export let serverItemCount; // Total number of items expected from the server. `serverSide` must be true on table config.
7
+ export let itemCount;
8
+ export let pageConfig;
9
+ export let pageSizes;
10
+ export let id;
15
11
  export let updateTable; // Function to update table
16
12
 
17
- // Flags for disabling buttons
18
- let goToFirstPageDisabled = true;
19
- let goToLastPageDisabled = true;
20
- let goToNextPageDisabled = true;
21
- let goToPreviousPageDisabled = true;
22
-
23
- // Index information string
24
13
  let indexInformation = '';
25
14
 
26
- // Handles the input change event
27
- const handleChange = (e) => {
28
- const value = e.target.value;
29
-
30
- if (value > pageCount) {
31
- $pageIndex = pageCount - 1;
32
- } else if (value < 1) {
33
- $pageIndex = 0;
34
- } else {
35
- $pageIndex = value - 1;
36
- }
37
-
38
- updateTable();
39
- };
15
+ const { pageIndex, pageCount, pageSize } = pageConfig;
40
16
 
41
- // Main navigation function
42
- const goTo = (dst: string) => {
43
- switch (dst) {
44
- case 'first':
45
- $pageIndex = 0;
46
- break;
47
- case 'last':
48
- $pageIndex = pageCount - 1;
49
- break;
50
- case 'next':
51
- $pageIndex += 1;
52
- break;
53
- case 'previous':
54
- $pageIndex -= 1;
55
- break;
56
- default:
57
- break;
58
- }
17
+ let pageSizeDropdownValue: string = $pageSize;
59
18
 
60
- // Fetch data for new parameters
61
- updateTable();
19
+ const pageSizePopup: PopupSettings = {
20
+ event: 'click',
21
+ target: `#${id}-pageSizeDropdown`,
22
+ placement: 'bottom',
23
+ closeQuery: '.listbox-item'
62
24
  };
63
25
 
64
26
  const getIndexInfomationString = () => {
65
- return serverItemCount === 0
27
+ return itemCount === 0
66
28
  ? 'No items'
67
29
  : `Displaying items ${$pageIndex * $pageSize + 1} - ${Math.min(
68
30
  ($pageIndex + 1) * $pageSize,
69
- serverItemCount
70
- )} of ${Math.min(pageCount * $pageSize, serverItemCount)}`;
31
+ itemCount
32
+ )} of ${Math.min($pageCount * $pageSize, itemCount)}`;
71
33
  };
72
34
 
73
- $: pageCount = Math.ceil($serverItemCount / $pageSize);
74
- $: goToFirstPageDisabled = !$pageIndex;
75
- $: goToLastPageDisabled = $pageIndex == pageCount - 1;
76
- $: goToNextPageDisabled = $pageIndex == pageCount - 1;
77
- $: goToPreviousPageDisabled = !$pageIndex;
78
- $: $pageSize && updateTable(); // Update query when page size changes
79
- $: pageCount, $pageIndex, $pageSize, (indexInformation = getIndexInfomationString());
35
+ $: paginationSettings = {
36
+ size: itemCount,
37
+ limit: $pageSize,
38
+ page: $pageIndex,
39
+ amounts: pageSizes
40
+ };
41
+ $: $pageSize = pageSizeDropdownValue;
42
+ $: $pageCount, $pageIndex, $pageSize, itemCount, (indexInformation = getIndexInfomationString());
80
43
 
81
44
  updateTable();
45
+
82
46
  </script>
83
47
 
84
- <div class="flex justify-between w-full items-stretch gap-10">
48
+ <div class="grid grid-cols-3 w-full items-stretch gap-10">
85
49
  <div class="flex justify-start">
86
- <select
87
- name="pageSize"
88
- id="{id}-pageSize"
89
- aria-label="Open menu to select number of items per page"
90
- class="select variant-filled-primary w-min font-bold"
91
- bind:value={$pageSize}
92
- >
93
- {#each pageSizes as size}
94
- <option value={size} class="!bg-primary-700">{size}</option>
95
- {/each}
96
- </select>
97
- </div>
98
- <div class="flex justify-center gap-1">
50
+ <!-- replace default select from Paginator below to be able to style properly -->
99
51
  <button
100
- class="btn btn-sm variant-filled-primary"
101
- title="Go to first page"
102
- on:click|preventDefault={() => goTo('first')}
103
- disabled={goToFirstPageDisabled}
104
- aria-label="Go to first page"
105
- id="{id}-first"
52
+ aria-label="Open menu to select number of items to display per page"
53
+ class="btn variant-filled-primary w-20 !px-3 !py-1.5 justify-between"
54
+ use:popup={pageSizePopup}
106
55
  >
107
- <Fa icon={faAnglesLeft} /></button
108
- >
109
- <button
110
- class="btn btn-sm variant-filled-primary"
111
- title="Go to previous page"
112
- id="{id}-previous"
113
- aria-label="Go to previous page"
114
- on:click|preventDefault={() => goTo('previous')}
115
- disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
116
- >
117
- <input
118
- type="number"
119
- class="input border border-primary-500 rounded flex w-24"
120
- aria-label="Current page"
121
- value={$pageIndex + 1}
122
- max={pageCount}
123
- min={1}
124
- on:change={handleChange}
56
+ <span class="capitalize font-semibold">{pageSizeDropdownValue}</span>
57
+ <Fa icon={faChevronDown} size="xs" />
58
+ </button>
59
+ <div class="card w-20 shadow-xl py-2" data-popup={`#${id}-pageSizeDropdown`}>
60
+ <ListBox rounded="rounded-none">
61
+ {#each pageSizes as size}
62
+ <ListBoxItem
63
+ bind:group={pageSizeDropdownValue}
64
+ name="medium" value={size}
65
+ on:click={() => { $pageSize = size; updateTable(); }}
66
+ >{size}</ListBoxItem
67
+ >
68
+ {/each}
69
+ </ListBox>
70
+ <div class="arrow bg-surface-100-800-token" />
71
+ </div>
72
+ </div>
73
+ <div class="flex justify-center">
74
+ <Paginator
75
+ on:page={(page) => {$pageIndex = page.detail; updateTable(); }}
76
+ settings={paginationSettings}
77
+ select="hidden"
78
+ active="!variant-filled-secondary !text-on-secondary-token"
79
+ controlVariant="!text-on-primary-token"
80
+ buttonClasses="!rounded-none !px-3 !py-1.5 fill-current bg-primary-500 hover:!bg-primary-600 !text-on-primary-token disabled:grayscale disabled:!opacity-30"
81
+ regionControl="btn-group"
82
+ maxNumerals={1}
83
+ showNumerals
125
84
  />
126
- <button
127
- class="btn btn-sm variant-filled-primary"
128
- id="{id}-next"
129
- on:click|preventDefault={() => goTo('next')}
130
- aria-label="Go to next page"
131
- disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
132
- >
133
- <button
134
- class="btn btn-sm variant-filled-primary"
135
- id="{id}-last"
136
- aria-label="Go to last page"
137
- on:click|preventDefault={() => goTo('last')}
138
- disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
139
- >
140
85
  </div>
141
- <div class="flex justify-end items-center">
142
- <span class="text-sm text-gray-500">
143
- {indexInformation}
144
- </span>
86
+ <div class="flex justify-end items-center text-on-primary-token">
87
+ <span class="text-xs text-gray-500">{indexInformation}</span>
145
88
  </div>
146
89
  </div>