@dashx/react 0.1.18 → 0.2.1

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 (91) hide show
  1. package/dist/cjs/components/button.js +1 -1
  2. package/dist/cjs/components/button.js.map +1 -1
  3. package/dist/cjs/components/flex.d.ts +4 -332
  4. package/dist/cjs/components/form.d.ts +3 -3
  5. package/dist/cjs/components/form.js +1 -1
  6. package/dist/cjs/components/form.js.map +1 -1
  7. package/dist/cjs/components/link.js.map +1 -1
  8. package/dist/cjs/hooks/use-agent.d.ts +8 -3
  9. package/dist/cjs/hooks/use-agent.js +1 -1
  10. package/dist/cjs/hooks/use-agent.js.map +3 -3
  11. package/dist/cjs/hooks/use-in-app.d.ts +5 -5
  12. package/dist/cjs/hooks/use-in-app.js +1 -1
  13. package/dist/cjs/hooks/use-in-app.js.map +3 -3
  14. package/dist/cjs/providers/DashXProvider.js +1 -1
  15. package/dist/cjs/providers/DashXProvider.js.map +2 -2
  16. package/dist/cjs/variants/avatar.d.ts +3 -117
  17. package/dist/cjs/variants/base-element.d.ts +2 -86
  18. package/dist/cjs/variants/base-field.d.ts +3 -129
  19. package/dist/cjs/variants/base-input.d.ts +1 -1
  20. package/dist/cjs/variants/button.d.ts +3 -138
  21. package/dist/cjs/variants/card.d.ts +2 -62
  22. package/dist/cjs/variants/checkbox.d.ts +1 -19
  23. package/dist/cjs/variants/field-error.d.ts +2 -86
  24. package/dist/cjs/variants/heading.d.ts +3 -234
  25. package/dist/cjs/variants/link.d.ts +4 -259
  26. package/dist/cjs/variants/popover.d.ts +5 -61
  27. package/dist/cjs/variants/text-area.d.ts +4 -161
  28. package/dist/cjs/variants/text-field.d.ts +4 -161
  29. package/dist/cjs/variants/text.d.ts +3 -235
  30. package/dist/cjs/variants/tooltip.d.ts +1 -1
  31. package/dist/cjs/variants/typography.d.ts +2 -182
  32. package/dist/cjs/widgets/ChatBody.d.ts +3 -2
  33. package/dist/cjs/widgets/ChatBody.js +1 -1
  34. package/dist/cjs/widgets/ChatBody.js.map +2 -2
  35. package/dist/cjs/widgets/MessageBell.d.ts +2 -0
  36. package/dist/cjs/widgets/MessageBell.js +2 -0
  37. package/dist/cjs/widgets/MessageBell.js.map +7 -0
  38. package/dist/cjs/widgets/index.d.ts +1 -1
  39. package/dist/cjs/widgets/index.js +1 -1
  40. package/dist/cjs/widgets/index.js.map +3 -3
  41. package/dist/esm/components/button.js +1 -1
  42. package/dist/esm/components/button.js.map +1 -1
  43. package/dist/esm/components/flex.d.ts +4 -332
  44. package/dist/esm/components/form.d.ts +3 -3
  45. package/dist/esm/components/form.js +1 -1
  46. package/dist/esm/components/form.js.map +1 -1
  47. package/dist/esm/components/link.js.map +1 -1
  48. package/dist/esm/hooks/use-agent.d.ts +8 -3
  49. package/dist/esm/hooks/use-agent.js +1 -1
  50. package/dist/esm/hooks/use-agent.js.map +3 -3
  51. package/dist/esm/hooks/use-in-app.d.ts +5 -5
  52. package/dist/esm/hooks/use-in-app.js +1 -1
  53. package/dist/esm/hooks/use-in-app.js.map +3 -3
  54. package/dist/esm/providers/DashXProvider.js +1 -1
  55. package/dist/esm/providers/DashXProvider.js.map +2 -2
  56. package/dist/esm/variants/avatar.d.ts +3 -117
  57. package/dist/esm/variants/base-element.d.ts +2 -86
  58. package/dist/esm/variants/base-field.d.ts +3 -129
  59. package/dist/esm/variants/base-input.d.ts +1 -1
  60. package/dist/esm/variants/button.d.ts +3 -138
  61. package/dist/esm/variants/card.d.ts +2 -62
  62. package/dist/esm/variants/checkbox.d.ts +1 -19
  63. package/dist/esm/variants/field-error.d.ts +2 -86
  64. package/dist/esm/variants/heading.d.ts +3 -234
  65. package/dist/esm/variants/link.d.ts +4 -259
  66. package/dist/esm/variants/popover.d.ts +5 -61
  67. package/dist/esm/variants/text-area.d.ts +4 -161
  68. package/dist/esm/variants/text-field.d.ts +4 -161
  69. package/dist/esm/variants/text.d.ts +3 -235
  70. package/dist/esm/variants/tooltip.d.ts +1 -1
  71. package/dist/esm/variants/typography.d.ts +2 -182
  72. package/dist/esm/widgets/ChatBody.d.ts +3 -2
  73. package/dist/esm/widgets/ChatBody.js +1 -1
  74. package/dist/esm/widgets/ChatBody.js.map +2 -2
  75. package/dist/esm/widgets/MessageBell.d.ts +2 -0
  76. package/dist/esm/widgets/MessageBell.js +2 -0
  77. package/dist/esm/widgets/MessageBell.js.map +7 -0
  78. package/dist/esm/widgets/index.d.ts +1 -1
  79. package/dist/esm/widgets/index.js +1 -1
  80. package/dist/esm/widgets/index.js.map +2 -2
  81. package/package.json +50 -51
  82. package/src/components/button.tsx +1 -1
  83. package/src/components/form.tsx +3 -3
  84. package/src/components/link.tsx +1 -1
  85. package/src/hooks/use-agent.ts +28 -9
  86. package/src/hooks/use-in-app.ts +20 -20
  87. package/src/providers/DashXProvider.tsx +1 -1
  88. package/src/widgets/ChatBody.tsx +4 -3
  89. package/src/widgets/{NotificationBell.tsx → MessageBell.tsx} +21 -21
  90. package/src/widgets/index.ts +1 -1
  91. package/styles.css +537 -566
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashx/react",
3
- "version": "0.1.18",
3
+ "version": "0.2.1",
4
4
  "license": "UNLICENSED",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/cjs/index.js",
@@ -75,61 +75,60 @@
75
75
  "clean": "rm -rf .turbo node_modules dist tokens layout *.css"
76
76
  },
77
77
  "dependencies": {
78
- "@dashx/browser": "^0.4.14",
78
+ "@dashx/browser": "^0.7.3",
79
79
  "@radix-ui/colors": "^3.0.0",
80
- "@radix-ui/primitive": "^1.0.1",
81
- "@radix-ui/react-accessible-icon": "^1.0.3",
82
- "@radix-ui/react-alert-dialog": "^1.0.5",
83
- "@radix-ui/react-aspect-ratio": "^1.0.3",
84
- "@radix-ui/react-avatar": "^1.0.4",
85
- "@radix-ui/react-checkbox": "^1.0.4",
86
- "@radix-ui/react-compose-refs": "^1.0.1",
87
- "@radix-ui/react-context": "^1.0.1",
88
- "@radix-ui/react-context-menu": "^2.1.5",
89
- "@radix-ui/react-dialog": "^1.0.5",
90
- "@radix-ui/react-direction": "^1.0.1",
91
- "@radix-ui/react-dropdown-menu": "^2.0.6",
92
- "@radix-ui/react-form": "^0.0.3",
93
- "@radix-ui/react-hover-card": "^1.0.7",
94
- "@radix-ui/react-navigation-menu": "^1.1.4",
95
- "@radix-ui/react-popover": "^1.0.7",
96
- "@radix-ui/react-portal": "^1.0.4",
97
- "@radix-ui/react-primitive": "^1.0.3",
98
- "@radix-ui/react-progress": "^1.0.3",
99
- "@radix-ui/react-radio-group": "^1.1.3",
100
- "@radix-ui/react-roving-focus": "^1.0.4",
101
- "@radix-ui/react-scroll-area": "^1.0.5",
102
- "@radix-ui/react-select": "^2.0.0",
103
- "@radix-ui/react-slider": "^1.1.2",
104
- "@radix-ui/react-slot": "^1.0.2",
105
- "@radix-ui/react-switch": "^1.0.3",
106
- "@radix-ui/react-tabs": "^1.0.4",
107
- "@radix-ui/react-toggle-group": "^1.0.4",
108
- "@radix-ui/react-tooltip": "^1.0.7",
109
- "@radix-ui/react-use-callback-ref": "^1.0.1",
110
- "@radix-ui/react-use-controllable-state": "^1.0.1",
111
- "@radix-ui/react-use-rect": "^1.1.0",
112
- "@radix-ui/react-visually-hidden": "^1.0.3",
113
- "@react-aria/utils": "^3.24.1",
114
- "@react-spectrum/button": "^3.16.4",
115
- "@react-spectrum/utils": "^3.11.7",
116
- "@react-types/shared": "^3.23.1",
117
- "@tailwindcss/postcss": "^4.0.0-alpha.15",
118
- "class-variance-authority": "^0.7.0",
80
+ "@radix-ui/primitive": "^1.1.3",
81
+ "@radix-ui/react-accessible-icon": "^1.1.8",
82
+ "@radix-ui/react-alert-dialog": "^1.1.15",
83
+ "@radix-ui/react-aspect-ratio": "^1.1.8",
84
+ "@radix-ui/react-avatar": "^1.1.11",
85
+ "@radix-ui/react-checkbox": "^1.3.3",
86
+ "@radix-ui/react-compose-refs": "^1.1.2",
87
+ "@radix-ui/react-context": "^1.1.3",
88
+ "@radix-ui/react-context-menu": "^2.2.16",
89
+ "@radix-ui/react-dialog": "^1.1.15",
90
+ "@radix-ui/react-direction": "^1.1.1",
91
+ "@radix-ui/react-dropdown-menu": "^2.1.16",
92
+ "@radix-ui/react-form": "^0.1.8",
93
+ "@radix-ui/react-hover-card": "^1.1.15",
94
+ "@radix-ui/react-navigation-menu": "^1.2.14",
95
+ "@radix-ui/react-popover": "^1.1.15",
96
+ "@radix-ui/react-portal": "^1.1.10",
97
+ "@radix-ui/react-primitive": "^2.1.4",
98
+ "@radix-ui/react-progress": "^1.1.8",
99
+ "@radix-ui/react-radio-group": "^1.3.8",
100
+ "@radix-ui/react-roving-focus": "^1.1.11",
101
+ "@radix-ui/react-scroll-area": "^1.2.10",
102
+ "@radix-ui/react-select": "^2.2.6",
103
+ "@radix-ui/react-slider": "^1.3.6",
104
+ "@radix-ui/react-slot": "^1.2.4",
105
+ "@radix-ui/react-switch": "^1.2.6",
106
+ "@radix-ui/react-tabs": "^1.1.13",
107
+ "@radix-ui/react-toggle-group": "^1.1.11",
108
+ "@radix-ui/react-tooltip": "^1.2.8",
109
+ "@radix-ui/react-use-callback-ref": "^1.1.1",
110
+ "@radix-ui/react-use-controllable-state": "^1.2.2",
111
+ "@radix-ui/react-use-rect": "^1.1.1",
112
+ "@radix-ui/react-visually-hidden": "^1.2.4",
113
+ "@react-aria/utils": "^3.34.1",
114
+ "@react-spectrum/button": "^3.18.1",
115
+ "@react-spectrum/utils": "^3.13.1",
116
+ "@react-types/shared": "^3.35.0",
117
+ "@tailwindcss/postcss": "^4.3.0",
118
+ "class-variance-authority": "^0.7.1",
119
119
  "classnames": "^2.5.1",
120
- "date-fns": "^3.6.0",
121
- "lucide-react": "^0.394.0",
122
- "prettier": "^3.2.5",
123
- "react-aria": "^3.33.1",
124
- "react-hot-toast": "^2.4.1",
120
+ "date-fns": "^4.4.0",
121
+ "lucide-react": "^1.17.0",
122
+ "react-aria": "^3.49.0",
123
+ "react-hot-toast": "^2.6.0",
125
124
  "react-markdown": "^10.1.0",
126
- "react-remove-scroll-bar": "2.3.4",
125
+ "react-remove-scroll-bar": "2.3.8",
127
126
  "react-use-websocket": "^4.8.1",
128
- "tailwind-merge": "^2.3.0",
129
- "tailwind-variants": "^0.2.1",
130
- "tailwindcss": "^4.0.0-alpha.15",
127
+ "tailwind-merge": "^3.6.0",
128
+ "tailwind-variants": "^3.2.2",
129
+ "tailwindcss": "^4.3.0",
131
130
  "tailwindcss-animate": "^1.0.7",
132
- "tailwindcss-react-aria-components": "^1.1.3",
131
+ "tailwindcss-react-aria-components": "^2.1.1",
133
132
  "uuid-random": "^1.3.2"
134
133
  },
135
134
  "peerDependencies": {
@@ -63,7 +63,7 @@ function _Button(props: ButtonProps, ref: React.ForwardedRef<HTMLButtonElement>)
63
63
  {...filterDOMProps(props)}
64
64
  {...mergeProps(buttonProps, focusProps, hoverProps)}
65
65
  slot={props.slot || undefined}
66
- ref={mergeRefs(ref, innerRef)}
66
+ ref={mergeRefs(ref, innerRef) as React.Ref<HTMLElement>}
67
67
  data-disabled={props.isDisabled || undefined}
68
68
  data-pressed={isPressed || undefined}
69
69
  data-hovered={isHovered || undefined}
@@ -2,15 +2,15 @@ import { FormContext } from 'react-aria-components';
2
2
  import { FormValidationContext } from 'react-stately';
3
3
  import { forwardRef } from 'react';
4
4
 
5
- import type { FormProps as _FormProps } from '@react-types/form';
6
5
  import type { CSSProperties, ForwardedRef, ReactNode } from 'react';
7
- import type { DOMProps } from '@react-types/shared';
6
+ import type { DOMProps, ValidationErrors } from '@react-types/shared';
8
7
 
9
- export interface FormProps extends _FormProps, DOMProps {
8
+ export interface FormProps extends DOMProps {
10
9
  className?: string;
11
10
  style?: CSSProperties;
12
11
  children?: ReactNode;
13
12
  noValidate?: boolean;
13
+ validationErrors?: ValidationErrors;
14
14
  }
15
15
 
16
16
  function _Form(props: FormProps, ref: ForwardedRef<HTMLFormElement>) {
@@ -71,7 +71,7 @@ function _Link(props: LinkProps, ref: ForwardedRef<HTMLAnchorElement>) {
71
71
  {...filterDOMProps(props)}
72
72
  {...mergeProps(linkProps, focusProps, hoverProps)}
73
73
  slot={props.slot || undefined}
74
- ref={mergeRefs(ref, innerRef)}
74
+ ref={mergeRefs(ref, innerRef) as any}
75
75
  data-disabled={props.isDisabled || undefined}
76
76
  data-pressed={isPressed || undefined}
77
77
  data-hovered={isHovered || undefined}
@@ -1,6 +1,6 @@
1
1
  import uuid from 'uuid-random';
2
2
  import { useState, useEffect, useCallback } from 'react';
3
- import type { AiAgent, AiNotification } from '@dashx/browser';
3
+ import type { AiAgent } from '@dashx/browser';
4
4
 
5
5
  import useDashXProvider from './use-dashx-provider.js';
6
6
 
@@ -8,10 +8,19 @@ type UseAgentHookProps = {
8
8
  publicEmbedKey: string;
9
9
  }
10
10
 
11
+ // UI-level chat message. `aiRole` is a presentation concern maintained by the
12
+ // hook (the SDK's invokeAiAgent messages don't carry a role) to distinguish
13
+ // user-entered messages from agent responses.
14
+ type AiMessage = {
15
+ id: string;
16
+ aiRole: 'user' | 'assistant';
17
+ renderedContent: any;
18
+ }
19
+
11
20
  type UseAgentHookResponse = {
12
21
  agent?: AiAgent;
13
22
  conversationId: string | null;
14
- messages: AiNotification[];
23
+ messages: AiMessage[];
15
24
  isThinking: boolean;
16
25
  error: string | null;
17
26
  sendMessage: (text: string) => Promise<void>;
@@ -23,7 +32,7 @@ const useAgent = ({ publicEmbedKey }: UseAgentHookProps): UseAgentHookResponse =
23
32
  const [agent, setAgent] = useState<AiAgent>();
24
33
 
25
34
  const [conversationId, setConversationId] = useState<string | null>(null);
26
- const [messages, setMessages] = useState<AiNotification[]>([]);
35
+ const [messages, setMessages] = useState<AiMessage[]>([]);
27
36
  const [isThinking, setIsThinking] = useState(false);
28
37
  const [error, setError] = useState<string | null>(null);
29
38
 
@@ -49,8 +58,8 @@ const useAgent = ({ publicEmbedKey }: UseAgentHookProps): UseAgentHookResponse =
49
58
  setMessages((prev) => [...prev, {
50
59
  id: uuid(),
51
60
  aiRole: 'user',
52
- renderedContent: text
53
- } as AiNotification]);
61
+ renderedContent: text,
62
+ }]);
54
63
  setIsThinking(true);
55
64
  setError(null);
56
65
 
@@ -60,11 +69,21 @@ const useAgent = ({ publicEmbedKey }: UseAgentHookProps): UseAgentHookResponse =
60
69
  publicEmbedKey,
61
70
  });
62
71
 
63
- if (response.conversationId && !conversationId) {
64
- setConversationId(response.conversationId);
72
+ const responseConversationId = response.messages.find(
73
+ (message) => message.conversationId,
74
+ )?.conversationId;
75
+ if (responseConversationId && !conversationId) {
76
+ setConversationId(responseConversationId);
65
77
  }
66
78
 
67
- setMessages((prev) => [...prev, response]);
79
+ setMessages((prev) => [
80
+ ...prev,
81
+ ...response.messages.map((message) => ({
82
+ id: message.id,
83
+ aiRole: 'assistant' as const,
84
+ renderedContent: message.renderedContent,
85
+ })),
86
+ ]);
68
87
  } catch (err) {
69
88
  setError('Failed to send message');
70
89
  } finally {
@@ -84,6 +103,6 @@ const useAgent = ({ publicEmbedKey }: UseAgentHookProps): UseAgentHookResponse =
84
103
  };
85
104
  };
86
105
 
87
- export type { UseAgentHookProps, UseAgentHookResponse };
106
+ export type { UseAgentHookProps, UseAgentHookResponse, AiMessage };
88
107
 
89
108
  export default useAgent;
@@ -1,42 +1,42 @@
1
1
  import toast from 'react-hot-toast';
2
2
  import { useEffect, useState } from 'react';
3
3
  import { WebsocketMessage } from '@dashx/browser';
4
- import type { InAppNotifications, WebsocketMessageType } from '@dashx/browser';
4
+ import type { InAppMessages, WebsocketMessageType } from '@dashx/browser';
5
5
 
6
6
  import useDashXProvider from './use-dashx-provider.js';
7
7
  import { useWebSocket } from '../providers/DashXProvider.js';
8
8
 
9
9
  type UseInAppHookResponse = {
10
- notifications: InAppNotifications;
11
- unreadNotificationsCount: number | null;
12
- markNotificationAsRead: (id: string) => Promise<any>;
13
- markNotificationAsUnread: (id: string) => Promise<any>;
10
+ messages: InAppMessages;
11
+ unreadMessagesCount: number | null;
12
+ markMessageAsRead: (id: string) => Promise<any>;
13
+ markMessageAsUnread: (id: string) => Promise<any>;
14
14
  };
15
15
 
16
16
  const useInApp = (): UseInAppHookResponse => {
17
17
  let dashX = useDashXProvider();
18
18
  const { subscribe } = useWebSocket();
19
- const [notifications, setNotifications] = useState<InAppNotifications>([]);
20
- const [unreadNotificationsCount, setUnreadNotificationsCount] = useState<number | null>(null);
19
+ const [messages, setMessages] = useState<InAppMessages>([]);
20
+ const [unreadMessagesCount, setUnreadMessagesCount] = useState<number | null>(null);
21
21
 
22
- const markNotificationAsRead = (id: string) => dashX.trackNotification({ id, status: 'READ' });
22
+ const markMessageAsRead = (id: string) => dashX.trackMessage({ id, status: 'READ' });
23
23
 
24
- const markNotificationAsUnread = async (id: string) =>
25
- dashX.trackNotification({ id, status: 'UNREAD' });
24
+ const markMessageAsUnread = async (id: string) =>
25
+ dashX.trackMessage({ id, status: 'UNREAD' });
26
26
 
27
27
 
28
28
  useEffect(() => {
29
- // Set up notification watchers (automatically refetch on WebSocket reconnection)
30
- dashX.watchFetchInAppNotifications(setNotifications);
31
- dashX.watchFetchInAppNotificationsAggregate(setUnreadNotificationsCount);
29
+ // Set up in-app message watchers (automatically refetch on WebSocket reconnection)
30
+ dashX.watchFetchInAppMessages(setMessages);
31
+ dashX.watchFetchInAppMessagesAggregate(setUnreadMessagesCount);
32
32
  }, [dashX]);
33
33
 
34
34
  useEffect(() => {
35
- // Subscribe to WebSocket messages for notifications
35
+ // Subscribe to WebSocket messages for in-app messages
36
36
  const unsubscribe = subscribe((message: WebsocketMessageType) => {
37
- // Handle only IN_APP_NOTIFICATION for toast display
37
+ // Handle only IN_APP_MESSAGE for toast display
38
38
  // The client handles all other message processing internally
39
- if (message?.type === WebsocketMessage.IN_APP_NOTIFICATION) {
39
+ if (message?.type === WebsocketMessage.IN_APP_MESSAGE) {
40
40
  toast(message.data.renderedContent.body);
41
41
  }
42
42
  });
@@ -45,10 +45,10 @@ const useInApp = (): UseInAppHookResponse => {
45
45
  }, [subscribe]);
46
46
 
47
47
  return {
48
- notifications,
49
- unreadNotificationsCount,
50
- markNotificationAsRead,
51
- markNotificationAsUnread,
48
+ messages,
49
+ unreadMessagesCount,
50
+ markMessageAsRead,
51
+ markMessageAsUnread,
52
52
  };
53
53
  };
54
54
 
@@ -31,7 +31,7 @@ function DashXProvider({
31
31
  }: React.PropsWithChildren<DashXProviderProps>) {
32
32
  const dashX = React.useMemo(
33
33
  () =>
34
- DashX({
34
+ DashX.configure({
35
35
  publicKey: publicKey,
36
36
  baseUri: baseUri,
37
37
  realtimeBaseUri: realtimeBaseUri,
@@ -1,18 +1,19 @@
1
1
  import * as ScrollArea from '@radix-ui/react-scroll-area';
2
2
  import React, { useEffect, useRef, useCallback } from 'react';
3
- import type { AiAgent, AiNotification, AiAgentStarterSuggestion } from '@dashx/browser';
3
+ import type { AiAgent, AiAgentStarterSuggestion } from '@dashx/browser';
4
4
 
5
5
  import { Button, Flex, Text } from '../components';
6
6
  import { cn } from '../utils/cn.js';
7
7
  import { MarkdownRenderer } from '../components/markdown-renderer.js';
8
8
  import useAutoScroll from '../hooks/use-auto-scroll.js';
9
+ import type { AiMessage } from '../hooks/use-agent.js';
9
10
 
10
11
  const AGENT_MESSAGE_WIDTH_CLASS = 'max-w-[max(80%,350px)]';
11
12
  const USER_MESSAGE_WIDTH_CLASS = 'max-w-[80%]';
12
13
 
13
14
  type ChatBodyProps = {
14
15
  agent: AiAgent;
15
- messages: AiNotification[];
16
+ messages: AiMessage[];
16
17
  isThinking: boolean;
17
18
  error: string | null;
18
19
  sendMessage: (message: string) => void;
@@ -84,7 +85,7 @@ const ChatBody = ({
84
85
  sendMessage(suggestion.content);
85
86
  };
86
87
 
87
- const renderMessage = (message: AiNotification, index: number) => {
88
+ const renderMessage = (message: AiMessage, index: number) => {
88
89
  const isUser = message.aiRole === 'user';
89
90
  const isLastMessage = index === messages.length - 1;
90
91
  const isLastAgentMessage = isLastMessage && !isUser;
@@ -4,12 +4,12 @@ import { useInApp } from '../hooks/index.js';
4
4
  import { Button, Card, Flex, Heading, Popover, Text, Theme, Tooltip } from '../components';
5
5
  import { Inbox, Mail, MailOpen, X } from '../icons/index.js';
6
6
 
7
- const NotificationBell = () => {
7
+ const MessageBell = () => {
8
8
  let {
9
- markNotificationAsRead,
10
- markNotificationAsUnread,
11
- notifications,
12
- unreadNotificationsCount,
9
+ markMessageAsRead,
10
+ markMessageAsUnread,
11
+ messages,
12
+ unreadMessagesCount,
13
13
  } = useInApp();
14
14
 
15
15
  return (
@@ -21,18 +21,18 @@ const NotificationBell = () => {
21
21
  <Button
22
22
  shape="square"
23
23
  roundness="full"
24
- variant={unreadNotificationsCount ? 'fill' : 'ghost'}
24
+ variant={unreadMessagesCount ? 'fill' : 'ghost'}
25
25
  >
26
26
  <Inbox />
27
27
  </Button>
28
28
  </Popover.Trigger>
29
29
  </Tooltip.Trigger>
30
- <Tooltip.Content content="Notification" />
30
+ <Tooltip.Content content="Messages" />
31
31
  </Tooltip.Root>
32
32
  <Popover.Content spacing="large" width="350px" height="450px">
33
33
  <Popover.Header asChild>
34
34
  <Flex justify="between" align="center">
35
- <Heading size={3}>Notifications</Heading>
35
+ <Heading size={3}>Messages</Heading>
36
36
  <Popover.Close>
37
37
  <Button shape="square" roundness="full" variant="ghost" mode="subtle" inset="right">
38
38
  <X />
@@ -42,22 +42,22 @@ const NotificationBell = () => {
42
42
  </Popover.Header>
43
43
  <Popover.Body>
44
44
  <Flex direction="column" gap={1}>
45
- {notifications.length === 0 && (
45
+ {messages.length === 0 && (
46
46
  <Flex justify="center" align="center">
47
47
  <Text variant="tertiary" size={2}>
48
- No notifications yet.
48
+ No messages yet.
49
49
  </Text>
50
50
  </Flex>
51
51
  )}
52
- {notifications.map((notification) => (
53
- <Card key={notification.id}>
52
+ {messages.map((message) => (
53
+ <Card key={message.id}>
54
54
  <Flex align="center" gap={4} justify="between">
55
55
  <Flex direction="column" gap={1}>
56
56
  <Text as="p" variant="secondary" weight="semibold" size={2}>
57
- {notification.renderedContent.body}
57
+ {message.renderedContent.body}
58
58
  </Text>
59
59
  <Text size={1} variant="tertiary">
60
- {intlFormatDistance(notification.sentAt, new Date())}
60
+ {intlFormatDistance(message.sentAt, new Date())}
61
61
  </Text>
62
62
  </Flex>
63
63
  <Tooltip.Root>
@@ -66,20 +66,20 @@ const NotificationBell = () => {
66
66
  shape="square"
67
67
  variant="ghost"
68
68
  roundness="full"
69
- mode={notification.readAt ? 'subtle' : 'distinct'}
69
+ mode={message.readAt ? 'subtle' : 'distinct'}
70
70
  onPress={() => {
71
- if (notification.readAt) {
72
- markNotificationAsUnread(notification.id);
71
+ if (message.readAt) {
72
+ markMessageAsUnread(message.id);
73
73
  } else {
74
- markNotificationAsRead(notification.id);
74
+ markMessageAsRead(message.id);
75
75
  }
76
76
  }}
77
77
  >
78
- {notification.readAt ? <MailOpen /> : <Mail />}
78
+ {message.readAt ? <MailOpen /> : <Mail />}
79
79
  </Button>
80
80
  </Tooltip.Trigger>
81
81
  <Tooltip.Content
82
- content={notification.readAt ? 'Mark as unread' : 'Mark as read'}
82
+ content={message.readAt ? 'Mark as unread' : 'Mark as read'}
83
83
  />
84
84
  </Tooltip.Root>
85
85
  </Flex>
@@ -98,4 +98,4 @@ const NotificationBell = () => {
98
98
  );
99
99
  };
100
100
 
101
- export default NotificationBell;
101
+ export default MessageBell;
@@ -1,5 +1,5 @@
1
1
  export { default as Chat } from './Chat.js';
2
2
  export { default as ChatPopover } from './ChatPopover.js';
3
- export { default as NotificationBell } from './NotificationBell.js';
3
+ export { default as MessageBell } from './MessageBell.js';
4
4
  export { default as Preference } from './Preference.js';
5
5
  export { default as Preferences } from './Preferences.js';