@tuturuuu/ui 0.25.0 → 0.25.3

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/biome.json +1 -1
  3. package/package.json +13 -12
  4. package/src/components/ui/chat/chat-sidebar-items.tsx +25 -19
  5. package/src/components/ui/chat/chat-utils.test.ts +88 -2
  6. package/src/components/ui/chat/chat-workspace.tsx +1 -0
  7. package/src/components/ui/chat/composer-attachment-chip.tsx +128 -0
  8. package/src/components/ui/chat/external-message-content.test.ts +41 -0
  9. package/src/components/ui/chat/external-message-content.ts +28 -0
  10. package/src/components/ui/chat/message-bubble.tsx +4 -2
  11. package/src/components/ui/chat/message-composer.tsx +121 -33
  12. package/src/components/ui/chat/message-links.test.tsx +14 -0
  13. package/src/components/ui/chat/utils.ts +39 -3
  14. package/src/components/ui/custom/__tests__/workspace-select-helpers.test.ts +2 -6
  15. package/src/components/ui/custom/__tests__/workspace-select-invitations.test.tsx +141 -0
  16. package/src/components/ui/custom/education/courses/course-row-actions.tsx +1 -1
  17. package/src/components/ui/custom/education/modules/course-module-row-actions.tsx +1 -1
  18. package/src/components/ui/custom/notification-popover-client.tsx +97 -57
  19. package/src/components/ui/custom/structure.test.tsx +55 -1
  20. package/src/components/ui/custom/structure.tsx +10 -1
  21. package/src/components/ui/custom/tables/custom-data-table.tsx +3 -2
  22. package/src/components/ui/custom/tables/data-table-column-header.tsx +4 -3
  23. package/src/components/ui/custom/tables/data-table-faceted-filter.tsx +4 -3
  24. package/src/components/ui/custom/tables/data-table-pagination.tsx +6 -6
  25. package/src/components/ui/custom/tables/data-table-toolbar.tsx +5 -5
  26. package/src/components/ui/custom/tables/data-table-view-options.tsx +4 -3
  27. package/src/components/ui/custom/tables/data-table.tsx +69 -30
  28. package/src/components/ui/custom/workspace-select-icon.tsx +58 -0
  29. package/src/components/ui/custom/workspace-select-invitations.tsx +202 -0
  30. package/src/components/ui/custom/workspace-select.tsx +43 -61
  31. package/src/components/ui/finance/invoices/columns.test.tsx +3 -3
  32. package/src/components/ui/finance/invoices/columns.tsx +4 -2
  33. package/src/components/ui/finance/invoices/pending-columns.tsx +1 -1
  34. package/src/components/ui/finance/invoices/row-actions.tsx +1 -1
  35. package/src/components/ui/finance/transactions/categories/columns.test.tsx +5 -5
  36. package/src/components/ui/finance/transactions/categories/columns.tsx +4 -2
  37. package/src/components/ui/finance/transactions/categories/row-actions.tsx +1 -1
  38. package/src/components/ui/finance/transactions/columns.test.tsx +5 -5
  39. package/src/components/ui/finance/transactions/columns.tsx +4 -2
  40. package/src/components/ui/finance/transactions/row-actions.tsx +1 -1
  41. package/src/components/ui/finance/wallets/columns.tsx +4 -2
  42. package/src/components/ui/finance/wallets/row-actions.tsx +1 -1
  43. package/src/hooks/use-notifications.ts +16 -2
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
- import type { ColumnDef } from '@tanstack/react-table';
4
3
  import { FileText } from '@tuturuuu/icons';
5
4
  import type { PendingInvoice } from '@tuturuuu/types/primitives/PendingInvoice';
6
5
  import { Avatar, AvatarFallback, AvatarImage } from '@tuturuuu/ui/avatar';
7
6
  import { Button } from '@tuturuuu/ui/button';
7
+ import type { ColumnDef } from '@tuturuuu/ui/custom/tables/data-table';
8
8
  import { DataTableColumnHeader } from '@tuturuuu/ui/custom/tables/data-table-column-header';
9
9
  import { Popover, PopoverContent, PopoverTrigger } from '@tuturuuu/ui/popover';
10
10
  import { formatCurrency } from '@tuturuuu/utils/format';
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import { useQueryClient } from '@tanstack/react-query';
4
- import type { Row } from '@tanstack/react-table';
5
4
  import { Ellipsis, Eye } from '@tuturuuu/icons';
6
5
  import { deleteInvoice } from '@tuturuuu/internal-api/finance';
7
6
  import type { Invoice } from '@tuturuuu/types/primitives/Invoice';
@@ -17,6 +16,7 @@ import {
17
16
  AlertDialogTrigger,
18
17
  } from '@tuturuuu/ui/alert-dialog';
19
18
  import { Button } from '@tuturuuu/ui/button';
19
+ import type { Row } from '@tuturuuu/ui/custom/tables/data-table';
20
20
  import {
21
21
  DropdownMenu,
22
22
  DropdownMenuContent,
@@ -1,5 +1,5 @@
1
- import type { ColumnDef } from '@tanstack/react-table';
2
1
  import { render, screen, waitFor } from '@testing-library/react';
2
+ import type { ColumnDef } from '@tuturuuu/ui/custom/tables/data-table';
3
3
  import { beforeEach, describe, expect, it } from 'vitest';
4
4
  import { transactionCategoryColumns } from './columns';
5
5
 
@@ -15,8 +15,8 @@ function CategoryAmountCell({ amount }: { amount: number }) {
15
15
  });
16
16
  const amountColumn = columns.find(
17
17
  (column) =>
18
- (column as ColumnDef<unknown> & { accessorKey?: string }).accessorKey ===
19
- 'amount'
18
+ (column as ColumnDef<Record<string, unknown>> & { accessorKey?: string })
19
+ .accessorKey === 'amount'
20
20
  );
21
21
 
22
22
  if (typeof amountColumn?.cell !== 'function') return null;
@@ -45,8 +45,8 @@ function CategoryCountCell({ count }: { count: number }) {
45
45
  });
46
46
  const countColumn = columns.find(
47
47
  (column) =>
48
- (column as ColumnDef<unknown> & { accessorKey?: string }).accessorKey ===
49
- 'transaction_count'
48
+ (column as ColumnDef<Record<string, unknown>> & { accessorKey?: string })
49
+ .accessorKey === 'transaction_count'
50
50
  );
51
51
 
52
52
  if (typeof countColumn?.cell !== 'function') return null;
@@ -1,13 +1,15 @@
1
1
  'use client';
2
2
 
3
- import type { ColumnDef } from '@tanstack/react-table';
4
3
  import { ArrowDownCircle, ArrowUpCircle } from '@tuturuuu/icons';
5
4
  import type { TransactionCategoryWithStats } from '@tuturuuu/types/primitives/TransactionCategory';
6
5
  import {
7
6
  getIconComponentByKey,
8
7
  type PlatformIconKey,
9
8
  } from '@tuturuuu/ui/custom/icon-picker';
10
- import type { ColumnGeneratorOptions } from '@tuturuuu/ui/custom/tables/data-table';
9
+ import type {
10
+ ColumnDef,
11
+ ColumnGeneratorOptions,
12
+ } from '@tuturuuu/ui/custom/tables/data-table';
11
13
  import { DataTableColumnHeader } from '@tuturuuu/ui/custom/tables/data-table-column-header';
12
14
  import { TransactionCategoryRowActions } from '@tuturuuu/ui/finance/transactions/categories/row-actions';
13
15
  import { computeAccessibleLabelStyles } from '@tuturuuu/utils/label-colors';
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import { useMutation, useQueryClient } from '@tanstack/react-query';
4
- import type { Row } from '@tanstack/react-table';
5
4
  import { Ellipsis } from '@tuturuuu/icons';
6
5
  import { deleteTransactionCategory } from '@tuturuuu/internal-api/finance';
7
6
  import type { TransactionCategory } from '@tuturuuu/types/primitives/TransactionCategory';
@@ -18,6 +17,7 @@ import {
18
17
  } from '@tuturuuu/ui/alert-dialog';
19
18
  import { Button } from '@tuturuuu/ui/button';
20
19
  import ModifiableDialogTrigger from '@tuturuuu/ui/custom/modifiable-dialog-trigger';
20
+ import type { Row } from '@tuturuuu/ui/custom/tables/data-table';
21
21
  import {
22
22
  DropdownMenu,
23
23
  DropdownMenuContent,
@@ -1,5 +1,5 @@
1
- import type { ColumnDef } from '@tanstack/react-table';
2
1
  import { render, screen, waitFor } from '@testing-library/react';
2
+ import type { ColumnDef } from '@tuturuuu/ui/custom/tables/data-table';
3
3
  import { beforeEach, describe, expect, it, vi } from 'vitest';
4
4
  import { transactionColumns } from './columns';
5
5
 
@@ -23,8 +23,8 @@ function TransactionAmountCell({ amount }: { amount: number }) {
23
23
  });
24
24
  const amountColumn = columns.find(
25
25
  (column) =>
26
- (column as ColumnDef<unknown> & { accessorKey?: string }).accessorKey ===
27
- 'amount'
26
+ (column as ColumnDef<Record<string, unknown>> & { accessorKey?: string })
27
+ .accessorKey === 'amount'
28
28
  );
29
29
 
30
30
  if (typeof amountColumn?.cell !== 'function') return null;
@@ -57,8 +57,8 @@ function TransactionColumnCell({
57
57
  });
58
58
  const column = columns.find(
59
59
  (item) =>
60
- (item as ColumnDef<unknown> & { accessorKey?: string }).accessorKey ===
61
- accessorKey
60
+ (item as ColumnDef<Record<string, unknown>> & { accessorKey?: string })
61
+ .accessorKey === accessorKey
62
62
  );
63
63
 
64
64
  if (typeof column?.cell !== 'function') return null;
@@ -1,10 +1,12 @@
1
1
  'use client';
2
2
 
3
- import type { ColumnDef } from '@tanstack/react-table';
4
3
  import { Check, X } from '@tuturuuu/icons';
5
4
  import type { Transaction } from '@tuturuuu/types/primitives/Transaction';
6
5
  import { Avatar, AvatarFallback, AvatarImage } from '@tuturuuu/ui/avatar';
7
- import type { ColumnGeneratorOptions } from '@tuturuuu/ui/custom/tables/data-table';
6
+ import type {
7
+ ColumnDef,
8
+ ColumnGeneratorOptions,
9
+ } from '@tuturuuu/ui/custom/tables/data-table';
8
10
  import { TransactionRowActions } from '@tuturuuu/ui/finance/transactions/row-actions';
9
11
  import { formatCurrency } from '@tuturuuu/utils/format';
10
12
  import moment from 'moment';
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import { useQueryClient } from '@tanstack/react-query';
4
- import type { Row } from '@tanstack/react-table';
5
4
  import { Ellipsis, Eye } from '@tuturuuu/icons';
6
5
  import { deleteTransaction as deleteTransactionWithInternalApi } from '@tuturuuu/internal-api/finance';
7
6
  import type { Transaction } from '@tuturuuu/types/primitives/Transaction';
@@ -18,6 +17,7 @@ import {
18
17
  } from '@tuturuuu/ui/alert-dialog';
19
18
  import { Button } from '@tuturuuu/ui/button';
20
19
  import ModifiableDialogTrigger from '@tuturuuu/ui/custom/modifiable-dialog-trigger';
20
+ import type { Row } from '@tuturuuu/ui/custom/tables/data-table';
21
21
  import {
22
22
  DropdownMenu,
23
23
  DropdownMenuContent,
@@ -1,6 +1,5 @@
1
1
  'use client';
2
2
 
3
- import type { ColumnDef } from '@tanstack/react-table';
4
3
  import {
5
4
  BookOpen,
6
5
  Check,
@@ -14,7 +13,10 @@ import {
14
13
  } from '@tuturuuu/icons';
15
14
  import type { Wallet } from '@tuturuuu/types/primitives/Wallet';
16
15
  import { Badge } from '@tuturuuu/ui/badge';
17
- import type { ColumnGeneratorOptions } from '@tuturuuu/ui/custom/tables/data-table';
16
+ import type {
17
+ ColumnDef,
18
+ ColumnGeneratorOptions,
19
+ } from '@tuturuuu/ui/custom/tables/data-table';
18
20
  import { DataTableColumnHeader } from '@tuturuuu/ui/custom/tables/data-table-column-header';
19
21
  import { WalletRowActions } from '@tuturuuu/ui/finance/wallets/row-actions';
20
22
  import type { ExchangeRate } from '@tuturuuu/utils/exchange-rates';
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
 
3
3
  import { useQueryClient } from '@tanstack/react-query';
4
- import type { Row } from '@tanstack/react-table';
5
4
  import { Ellipsis, Eye } from '@tuturuuu/icons';
6
5
  import { deleteWallet as deleteWalletWithInternalApi } from '@tuturuuu/internal-api/finance';
7
6
  import type { Wallet } from '@tuturuuu/types/primitives/Wallet';
@@ -18,6 +17,7 @@ import {
18
17
  } from '@tuturuuu/ui/alert-dialog';
19
18
  import { Button } from '@tuturuuu/ui/button';
20
19
  import ModifiableDialogTrigger from '@tuturuuu/ui/custom/modifiable-dialog-trigger';
20
+ import type { Row } from '@tuturuuu/ui/custom/tables/data-table';
21
21
  import {
22
22
  DropdownMenu,
23
23
  DropdownMenuContent,
@@ -75,6 +75,7 @@ interface NotificationsPage {
75
75
  }
76
76
 
77
77
  interface UseNotificationsOptions {
78
+ cacheScope?: string;
78
79
  wsId?: string;
79
80
  limit?: number;
80
81
  offset?: number;
@@ -210,6 +211,7 @@ export function dedupeNotifications(
210
211
  * @param wsId - If provided, filters to specific workspace. If omitted, fetches all notifications across all workspaces.
211
212
  */
212
213
  export function useNotifications({
214
+ cacheScope,
213
215
  wsId,
214
216
  limit = 20,
215
217
  offset = 0,
@@ -226,6 +228,7 @@ export function useNotifications({
226
228
  unreadOnly,
227
229
  readOnly,
228
230
  type,
231
+ ...(cacheScope ? [cacheScope] : []),
229
232
  ],
230
233
  queryFn: async () => {
231
234
  const params = new URLSearchParams({
@@ -263,12 +266,14 @@ export function useNotifications({
263
266
  * Hook to fetch notifications with infinite scroll support
264
267
  */
265
268
  export function useInfiniteNotifications({
269
+ cacheScope,
266
270
  wsId,
267
271
  unreadOnly = false,
268
272
  readOnly = false,
269
273
  pageSize = 20,
270
274
  enabled = true,
271
275
  }: {
276
+ cacheScope?: string;
272
277
  wsId?: string;
273
278
  unreadOnly?: boolean;
274
279
  readOnly?: boolean;
@@ -282,6 +287,7 @@ export function useInfiniteNotifications({
282
287
  wsId || 'all',
283
288
  unreadOnly,
284
289
  readOnly,
290
+ ...(cacheScope ? [cacheScope] : []),
285
291
  ],
286
292
  queryFn: async ({ pageParam = 0 }) => {
287
293
  const params = new URLSearchParams({
@@ -317,9 +323,17 @@ export function useInfiniteNotifications({
317
323
  * Hook to get unread notification count.
318
324
  * If wsId is provided, scopes to that workspace. Otherwise returns total unread count.
319
325
  */
320
- export function useUnreadCount(wsId?: string, options?: { enabled?: boolean }) {
326
+ export function useUnreadCount(
327
+ wsId?: string,
328
+ options?: { cacheScope?: string; enabled?: boolean }
329
+ ) {
321
330
  return useQuery({
322
- queryKey: ['notifications', 'unread-count', wsId || 'all'],
331
+ queryKey: [
332
+ 'notifications',
333
+ 'unread-count',
334
+ wsId || 'all',
335
+ ...(options?.cacheScope ? [options.cacheScope] : []),
336
+ ],
323
337
  queryFn: async () => {
324
338
  const params = wsId ? `?wsId=${wsId}` : '';
325
339
  const response = await fetch(