@rkosafo/cai.components 0.0.72 → 0.0.74

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.
@@ -17,7 +17,10 @@
17
17
  onItemChecked,
18
18
  toggelImportant,
19
19
  toggleFavorited,
20
- onItemSelected
20
+ onItemSelected,
21
+ showCheckbox = true,
22
+ showMarkAsFavorite = true,
23
+ showMarkAsImportant = true
21
24
  }: MailingMessageCardProps = $props();
22
25
 
23
26
  function handleClik(e: any) {
@@ -41,30 +44,29 @@
41
44
  </script>
42
45
 
43
46
  <div
44
- class:bg-blue-100={isChecked}
45
47
  class:hover:bg-gray-200={!isChecked}
46
- class:bg-white={!isRead && !isChecked}
47
- class:shadow={!isRead && !isChecked}
48
- class:border={!isRead && !isChecked}
49
- class="flex items-center border-y px-2"
48
+ class="flex items-center border border-gray-300 bg-white px-2 shadow"
50
49
  role="button"
51
50
  tabindex="0"
52
51
  onkeydown={handleClik}
53
52
  onclick={handleClik}
54
53
  >
55
- <Checkbox
56
- checked={isChecked}
57
- class="cursor-pointer border-2 border-gray-400 transition-colors hover:ring-4 hover:ring-gray-400 focus:ring-0"
58
- onchange={(e) => {
59
- const target = e.target;
60
- onItemChecked?.({ checked: target.checked, id });
61
- }}
62
- />
54
+ {#if showCheckbox}
55
+ <Checkbox
56
+ checked={isChecked}
57
+ class="cursor-pointer border-2 border-gray-400 transition-colors hover:ring-4 hover:ring-gray-400 focus:ring-0"
58
+ onchange={(e) => {
59
+ const target = e.target;
60
+ onItemChecked?.({ checked: target.checked, id });
61
+ }}
62
+ />
63
+ {/if}
63
64
  <div class="my-1 flex w-full cursor-pointer items-center justify-between p-1">
64
- <div class="flex w-full items-center">
65
+ <div class="flex w-full items-center">
65
66
  <div class="flex">
66
67
  <div class="mr-4 flex items-center gap-1 space-x-1">
67
68
  <button
69
+ class:hidden={!showMarkAsFavorite}
68
70
  onclick={(e) => {
69
71
  toggleFavorited?.(id);
70
72
  }}
@@ -79,6 +81,7 @@
79
81
  />
80
82
  </button>
81
83
  <button
84
+ class:hidden={!showMarkAsImportant}
82
85
  onclick={(e) => {
83
86
  toggelImportant?.(id);
84
87
  }}
@@ -98,7 +101,7 @@
98
101
  <span class="mx-1">-</span>
99
102
  </div>
100
103
 
101
- <p class=" truncate max-l xl:max-w-2xl 2xl:max-w-5xl text-sm text-gray-600">{message}</p>
104
+ <p class=" max-l truncate text-sm text-gray-600 xl:max-w-2xl 2xl:max-w-5xl">{message}</p>
102
105
  </div>
103
106
  <div class="flex w-32 shrink-0 items-center justify-end">
104
107
  <span class="text-sm" class:font-bold={!isRead} class:text-gray-500={isRead}>
@@ -17,6 +17,7 @@
17
17
  import { PageInfo } from '../../utils/paginate.svelte.js';
18
18
  import AlertDialog from '../../ui/alertDialog/AlertDialog.svelte';
19
19
  import MailingMessageViewer from './MailingMessageViewer.svelte';
20
+ import debounce from 'lodash/debounce';
20
21
 
21
22
  let {
22
23
  showSidePanel = true,
@@ -30,6 +31,7 @@
30
31
  showFavoriteButton = true,
31
32
  showMarkAsSpamButton = true,
32
33
  showReplies = true,
34
+ showMarkAsImportantButton = true,
33
35
  readInbox = $bindable((skip?: number, take?: number, filter?: TableFilter<any>) => {
34
36
  return null;
35
37
  }),
@@ -73,6 +75,8 @@
73
75
  let selectedMessages = $state<number[]>([]);
74
76
  let messageSelected = $state<number>(0);
75
77
 
78
+ let paginationInfo = new PageInfo();
79
+
76
80
  function toggleSideBar(val: MailMenu) {
77
81
  const { title } = val;
78
82
  if (title === 'Inbox') activeBox = 'inbox';
@@ -318,11 +322,18 @@
318
322
 
319
323
  function updatePageInfo(val: MailPageInfo) {
320
324
  // console.log({ val });
321
- pageInfo.totalItems = 1;
322
- pageInfo.setHasNextPage(val.hasNextPage);
323
- pageInfo.setHasPrevPage(val.hasPreviousPage);
324
- pageInfo.setTotalPages(1);
325
- pageInfo.setPageSize(1);
325
+ paginationInfo.totalItems = 1;
326
+ paginationInfo.setHasNextPage(val.hasNextPage);
327
+ paginationInfo.setHasPrevPage(val.hasPreviousPage);
328
+ paginationInfo.setTotalPages(1);
329
+ paginationInfo.setPageSize(1);
330
+ }
331
+
332
+ const debouncedSearch = debounce(fetchData, 300);
333
+
334
+ function handleSearch(val: string) {
335
+ // query = val;
336
+ debouncedSearch(pageNumber, { search: val }, activeBox);
326
337
  }
327
338
 
328
339
  async function getIsRead(id: number): Promise<boolean> {
@@ -368,7 +379,8 @@
368
379
  onMarkAsSpamClick={handleMarkAsSpam}
369
380
  onToggleMarkReadClick={handleMarkAsRead}
370
381
  onToggleFavoriteClick={handleMarkAsFavorite}
371
- onBackClick={async () => {
382
+ onsearchChange={handleSearch}
383
+ onBackClick={() => {
372
384
  messageSelected = 0;
373
385
  selectedMessages = [];
374
386
  }}
@@ -378,11 +390,11 @@
378
390
  }}
379
391
  selectedMails={selectedMessages}
380
392
  pageInfo={{
381
- currentPage: pageInfo.currentPage,
382
- pageSize: pageInfo.pageSize,
383
- totalCount: pageInfo.totalItems,
384
- hasNextPage: pageInfo.hasNextPage,
385
- hasPreviousPage: pageInfo.hasPrevPage
393
+ currentPage: !messageSelected ? pageInfo.currentPage : paginationInfo.currentPage,
394
+ pageSize: !messageSelected ? pageInfo.pageSize : paginationInfo.pageSize,
395
+ totalCount: !messageSelected ? pageInfo.totalItems : paginationInfo.totalItems,
396
+ hasNextPage: !messageSelected ? pageInfo.hasNextPage : paginationInfo.hasNextPage,
397
+ hasPreviousPage: !messageSelected ? pageInfo.hasPrevPage : paginationInfo.hasPrevPage
386
398
  }}
387
399
  />
388
400
  </div>
@@ -404,6 +416,8 @@
404
416
  <MailingMessageCard
405
417
  {...message}
406
418
  onItemChecked={handleItemChecked}
419
+ showMarkAsFavorite={showFavoriteButton}
420
+ showMarkAsImportant={showMarkAsImportantButton}
407
421
  toggleFavorited={() => {
408
422
  selectedMessages = [message.id];
409
423
  handleMarkAsFavorite(message.isStared ? 'unfavorite' : 'favorite');
@@ -62,6 +62,7 @@ export interface MailingModuleProps {
62
62
  showMarkReadButton?: boolean;
63
63
  showFavoriteButton?: boolean;
64
64
  showMarkAsSpamButton?: boolean;
65
+ showMarkAsImportantButton?: boolean;
65
66
  readInbox: (skip?: number, take?: number, filter?: TableFilter<any>) => Promise<PaginatedResult<MailingMessage>> | PaginatedResult<MailingMessage> | null;
66
67
  readOutbox?: (skip?: number, take?: number, filter?: TableFilter<any>) => Promise<PaginatedResult<MailingMessage>> | PaginatedResult<MailingMessage> | null;
67
68
  toggleArchieve?: (id: string | number) => Promise<CrudResult<any>> | CrudResult<any> | null;
@@ -104,6 +105,9 @@ export interface MailingMessageCardProps extends MailingMessage {
104
105
  onItemChecked?: (val: MailingMessageCardChecked) => void;
105
106
  toggelImportant?: (id: number) => void;
106
107
  toggleFavorited?: (id: number) => void;
108
+ showMarkAsImportant?: boolean;
109
+ showMarkAsFavorite?: boolean;
110
+ showCheckbox?: boolean;
107
111
  }
108
112
  export type MailingActiveBox = 'inbox' | 'outbox';
109
113
  export interface MailingMessageViewerProps {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rkosafo/cai.components",
3
- "version": "0.0.72",
3
+ "version": "0.0.74",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.test.*",