@bexis2/bexis2-core-ui 0.4.17 → 0.4.19

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,10 @@
1
1
  # bexis-core-ui
2
+ ## 0.4.19
3
+ ## 0.4.18
4
+ - Updates indicator text for current page and possible number of pages in a Table
5
+ - Fixes client-side search on Table
6
+ - Adds "No rows available" text in Table if search or filter returns no rows.
7
+
2
8
  ## 0.4.17
3
9
  - Table
4
10
  - Fix client-side search
@@ -5,12 +5,12 @@ export let groupSelection = false;
5
5
  export let groups;
6
6
  export let showAll = false;
7
7
  export let open = false;
8
- let selected;
9
- let selectedItems = {};
10
- let selectedGroups = {};
11
- const dispatch = createEventDispatcher();
12
- const modalStore = getModalStore();
13
- const showMore = (group) => {
8
+ export const showMore = (groupName) => {
9
+ const group = selected[groupName];
10
+ dispatch("showMoreOpenChange", {
11
+ group: group.name,
12
+ open: true
13
+ });
14
14
  modalStore.trigger({
15
15
  type: "component",
16
16
  title: `${group.displayName}`,
@@ -24,13 +24,37 @@ const showMore = (group) => {
24
24
  }
25
25
  });
26
26
  };
27
+ let selected;
28
+ let selectedItems = {};
29
+ let selectedGroups = {};
30
+ const dispatch = createEventDispatcher();
31
+ const modalStore = getModalStore();
27
32
  const handleSave = (group) => {
28
- Object.keys(group.children).forEach((key) => {
29
- selectedItems[group.name][key] = group.children[key].selected || false;
33
+ const { name: groupName, children } = group;
34
+ dispatch("showMoreOpenChange", {
35
+ group: groupName,
36
+ open: false
30
37
  });
38
+ for (const key in children) {
39
+ const selectedValue = children[key].selected || false;
40
+ selectedItems[groupName][key] = selectedValue;
41
+ if (selected[groupName].children[key].selected !== selectedValue) {
42
+ selected[groupName].children[key].selected = selectedValue;
43
+ }
44
+ }
45
+ dispatch("showMoreSelect", [
46
+ {
47
+ parent: groupName,
48
+ selected: Object.keys(children).map((key) => children[key].selected)
49
+ }
50
+ ]);
31
51
  modalStore.close();
32
52
  };
33
- const handleCancel = () => {
53
+ const handleCancel = (groupName) => {
54
+ dispatch("showMoreOpenChange", {
55
+ group: groupName,
56
+ open: false
57
+ });
34
58
  modalStore.close();
35
59
  };
36
60
  const mapSelected = (type) => {
@@ -58,7 +82,7 @@ const mapSelected = (type) => {
58
82
  }
59
83
  });
60
84
  }
61
- changed.length && dispatch("change", changed);
85
+ changed.length && dispatch("facetSelect", changed);
62
86
  };
63
87
  const sortOptions = () => {
64
88
  Object.keys(selected).forEach((group) => {
@@ -107,7 +131,7 @@ groups.subscribe((data) => {
107
131
  });
108
132
  });
109
133
  $: displayedGroups = structuredClone($groups);
110
- $: selectedItems, mapSelected("items"), sortOptions();
134
+ $: selectedItems, mapSelected("items");
111
135
  $: selectedGroups, mapSelected("groups");
112
136
  </script>
113
137
 
@@ -145,7 +169,7 @@ $: selectedGroups, mapSelected("groups");
145
169
  <!-- Trigger for the Modal to view all options -->
146
170
  {#if group.children.length > 5}
147
171
  <TreeViewItem hyphenOpacity="opacity-0">
148
- <button class="anchor" on:click={() => showMore(selected[group.name])}>more</button
172
+ <button class="anchor" on:click={() => showMore(group.name)}>more</button
149
173
  ></TreeViewItem
150
174
  >
151
175
  {/if}
@@ -7,9 +7,12 @@ declare const __propDef: {
7
7
  groups: Writable<FacetGroup[]>;
8
8
  showAll?: boolean;
9
9
  open?: boolean;
10
+ showMore?: (groupName: string) => void;
10
11
  };
11
12
  events: {
12
- change: CustomEvent<any>;
13
+ showMoreOpenChange: CustomEvent<any>;
14
+ showMoreSelect: CustomEvent<any>;
15
+ facetSelect: CustomEvent<any>;
13
16
  } & {
14
17
  [evt: string]: CustomEvent<any>;
15
18
  };
@@ -19,5 +22,6 @@ export type FacetsProps = typeof __propDef.props;
19
22
  export type FacetsEvents = typeof __propDef.events;
20
23
  export type FacetsSlots = typeof __propDef.slots;
21
24
  export default class Facets extends SvelteComponent<FacetsProps, FacetsEvents, FacetsSlots> {
25
+ get showMore(): (groupName: string) => void;
22
26
  }
23
27
  export {};
@@ -17,7 +17,7 @@ const onSave = () => {
17
17
  const onCancel = () => {
18
18
  console.log(selected, group.children);
19
19
  selected = structuredClone(group.children);
20
- handleCancel();
20
+ handleCancel(group.name);
21
21
  };
22
22
  const gridClass = (items) => {
23
23
  if (items.length >= 50) {
@@ -4,7 +4,7 @@ declare const __propDef: {
4
4
  props: {
5
5
  group: SelectedFacetGroup;
6
6
  handleSave: (group: SelectedFacetGroup) => {};
7
- handleCancel: () => {};
7
+ handleCancel: (groupName: string) => {};
8
8
  };
9
9
  events: {
10
10
  [evt: string]: CustomEvent<any>;
@@ -322,10 +322,11 @@ $: $hiddenColumnIds = shownColumns.filter((col) => !col.visible).map((col) => co
322
322
  class="flex gap-2"
323
323
  on:submit|preventDefault={() => {
324
324
  if (serverSide && !sendModel) {
325
- throw new Error('Server-side configuration is missing');
326
- } else {
327
- sendModel.q = searchValue;
328
- }
325
+ throw new Error('Server-side configuration is missing');
326
+ } else {
327
+ sendModel.q = searchValue;
328
+ }
329
+
329
330
  $filterValue = searchValue;
330
331
  }}
331
332
  >
@@ -342,12 +343,10 @@ sendModel.q = searchValue;
342
343
  class="absolute right-3 items-center"
343
344
  on:click|preventDefault={() => {
344
345
  if (serverSide && !sendModel) {
345
- throw new Error('Server-side configuration is missing');
346
- } else {
347
- sendModel.q = '';
348
- }
349
-
350
- $filterValue = searchValue;
346
+ throw new Error('Server-side configuration is missing');
347
+ } else {
348
+ sendModel.q = '';
349
+ }
351
350
 
352
351
  searchValue = '';
353
352
  $filterValue = '';
@@ -360,10 +359,10 @@ sendModel.q = '';
360
359
  class="btn variant-filled-primary"
361
360
  on:click|preventDefault={() => {
362
361
  if (serverSide && !sendModel) {
363
- throw new Error('Server-side configuration is missing');
364
- } else {
365
- sendModel.q = searchValue;
366
- }
362
+ throw new Error('Server-side configuration is missing');
363
+ } else {
364
+ sendModel.q = searchValue;
365
+ }
367
366
 
368
367
  $filterValue = searchValue;
369
368
  }}>Search</button
@@ -506,6 +505,13 @@ sendModel.q = searchValue;
506
505
  {/each}
507
506
  </tbody>
508
507
  </table>
508
+ {#if $pageRows.length === 0}
509
+ <div
510
+ class="p-8 flex items-center justify-center bg-tertiary-500/30 dark:bg-tertiary-900/10"
511
+ >
512
+ No rows available
513
+ </div>
514
+ {/if}
509
515
  </div>
510
516
  </div>
511
517
  {:else}
@@ -107,11 +107,7 @@ $: $pageSize = pageSizeDropdownValue;
107
107
  <div class="flex justify-end items-center">
108
108
  <span class="text-sm text-gray-500">
109
109
  {#if $pageCount > 0}
110
- {#if $pageCount == 1}
111
- 1 page
112
- {:else}
113
- {$pageCount} pages
114
- {/if}
110
+ Page {$pageIndex + 1} of {$pageCount}
115
111
  {:else}
116
112
  No pages
117
113
  {/if}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bexis2/bexis2-core-ui",
3
- "version": "0.4.17",
3
+ "version": "0.4.19",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite dev",
@@ -11,18 +11,14 @@
11
11
  export let showAll = false;
12
12
  export let open = false;
13
13
 
14
- let selected: { [key: string]: SelectedFacetGroup };
15
- let selectedItems: {
16
- [key: string]: {
17
- [key: string]: boolean;
18
- };
19
- } = {};
20
- let selectedGroups: { [key: string]: boolean } = {};
14
+ export const showMore = (groupName: string) => {
15
+ const group: SelectedFacetGroup = selected[groupName];
21
16
 
22
- const dispatch = createEventDispatcher();
17
+ dispatch('showMoreOpenChange', {
18
+ group: group.name,
19
+ open: true
20
+ });
23
21
 
24
- const modalStore = getModalStore();
25
- const showMore = (group: SelectedFacetGroup) => {
26
22
  modalStore.trigger({
27
23
  type: 'component',
28
24
  title: `${group.displayName}`,
@@ -37,14 +33,50 @@
37
33
  });
38
34
  };
39
35
 
36
+ let selected: { [key: string]: SelectedFacetGroup };
37
+ let selectedItems: {
38
+ [key: string]: {
39
+ [key: string]: boolean;
40
+ };
41
+ } = {};
42
+ let selectedGroups: { [key: string]: boolean } = {};
43
+
44
+ const dispatch = createEventDispatcher();
45
+
46
+ const modalStore = getModalStore();
47
+
40
48
  const handleSave = (group: SelectedFacetGroup) => {
41
- Object.keys(group.children).forEach((key) => {
42
- selectedItems[group.name][key] = group.children[key].selected || false;
49
+ const { name: groupName, children } = group;
50
+
51
+ dispatch('showMoreOpenChange', {
52
+ group: groupName,
53
+ open: false
43
54
  });
55
+
56
+ for (const key in children) {
57
+ const selectedValue = children[key].selected || false;
58
+ selectedItems[groupName][key] = selectedValue;
59
+
60
+ if (selected[groupName].children[key].selected !== selectedValue) {
61
+ selected[groupName].children[key].selected = selectedValue;
62
+ }
63
+ }
64
+
65
+ dispatch('showMoreSelect', [
66
+ {
67
+ parent: groupName,
68
+ selected: Object.keys(children).map((key) => children[key].selected)
69
+ }
70
+ ]);
71
+
44
72
  modalStore.close();
45
73
  };
46
74
 
47
- const handleCancel = () => {
75
+ const handleCancel = (groupName: string) => {
76
+ dispatch('showMoreOpenChange', {
77
+ group: groupName,
78
+ open: false
79
+ });
48
80
  modalStore.close();
49
81
  };
50
82
 
@@ -75,9 +107,10 @@
75
107
  });
76
108
  }
77
109
 
78
- changed.length && dispatch('change', changed);
110
+ changed.length && dispatch('facetSelect', changed);
79
111
  };
80
112
 
113
+ // Keeping the sorting function, but stays unused for now
81
114
  const sortOptions = () => {
82
115
  // Sort facets in a descending order if count exits, or sort alphabetically
83
116
  Object.keys(selected).forEach((group) => {
@@ -139,7 +172,7 @@
139
172
  });
140
173
 
141
174
  $: displayedGroups = structuredClone($groups);
142
- $: selectedItems, mapSelected('items'), sortOptions();
175
+ $: selectedItems, mapSelected('items'); // sortOptions(); // Sorting is not used for now
143
176
  $: selectedGroups, mapSelected('groups');
144
177
  </script>
145
178
 
@@ -177,7 +210,7 @@
177
210
  <!-- Trigger for the Modal to view all options -->
178
211
  {#if group.children.length > 5}
179
212
  <TreeViewItem hyphenOpacity="opacity-0">
180
- <button class="anchor" on:click={() => showMore(selected[group.name])}>more</button
213
+ <button class="anchor" on:click={() => showMore(group.name)}>more</button
181
214
  ></TreeViewItem
182
215
  >
183
216
  {/if}
@@ -3,7 +3,7 @@
3
3
 
4
4
  export let group: SelectedFacetGroup;
5
5
  export let handleSave: (group: SelectedFacetGroup) => {};
6
- export let handleCancel: () => {};
6
+ export let handleCancel: (groupName: string) => {};
7
7
 
8
8
  let selected = structuredClone(group.children);
9
9
 
@@ -25,7 +25,7 @@
25
25
  const onCancel = () => {
26
26
  console.log(selected, group.children);
27
27
  selected = structuredClone(group.children);
28
- handleCancel();
28
+ handleCancel(group.name);
29
29
  };
30
30
 
31
31
  const gridClass = (items: any[]) => {
@@ -390,10 +390,11 @@
390
390
  class="flex gap-2"
391
391
  on:submit|preventDefault={() => {
392
392
  if (serverSide && !sendModel) {
393
- throw new Error('Server-side configuration is missing');
394
- } else {
395
- sendModel.q = searchValue;
396
- }
393
+ throw new Error('Server-side configuration is missing');
394
+ } else {
395
+ sendModel.q = searchValue;
396
+ }
397
+
397
398
  $filterValue = searchValue;
398
399
  }}
399
400
  >
@@ -410,12 +411,10 @@ sendModel.q = searchValue;
410
411
  class="absolute right-3 items-center"
411
412
  on:click|preventDefault={() => {
412
413
  if (serverSide && !sendModel) {
413
- throw new Error('Server-side configuration is missing');
414
- } else {
415
- sendModel.q = '';
416
- }
417
-
418
- $filterValue = searchValue;
414
+ throw new Error('Server-side configuration is missing');
415
+ } else {
416
+ sendModel.q = '';
417
+ }
419
418
 
420
419
  searchValue = '';
421
420
  $filterValue = '';
@@ -428,10 +427,10 @@ sendModel.q = '';
428
427
  class="btn variant-filled-primary"
429
428
  on:click|preventDefault={() => {
430
429
  if (serverSide && !sendModel) {
431
- throw new Error('Server-side configuration is missing');
432
- } else {
433
- sendModel.q = searchValue;
434
- }
430
+ throw new Error('Server-side configuration is missing');
431
+ } else {
432
+ sendModel.q = searchValue;
433
+ }
435
434
 
436
435
  $filterValue = searchValue;
437
436
  }}>Search</button
@@ -574,6 +573,13 @@ sendModel.q = searchValue;
574
573
  {/each}
575
574
  </tbody>
576
575
  </table>
576
+ {#if $pageRows.length === 0}
577
+ <div
578
+ class="p-8 flex items-center justify-center bg-tertiary-500/30 dark:bg-tertiary-900/10"
579
+ >
580
+ No rows available
581
+ </div>
582
+ {/if}
577
583
  </div>
578
584
  </div>
579
585
  {:else}
@@ -117,11 +117,7 @@
117
117
  <div class="flex justify-end items-center">
118
118
  <span class="text-sm text-gray-500">
119
119
  {#if $pageCount > 0}
120
- {#if $pageCount == 1}
121
- 1 page
122
- {:else}
123
- {$pageCount} pages
124
- {/if}
120
+ Page {$pageIndex + 1} of {$pageCount}
125
121
  {:else}
126
122
  No pages
127
123
  {/if}