@dashx/react 0.4.2 → 0.4.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.
@@ -0,0 +1,254 @@
1
+ import type { VariantProps } from 'tailwind-variants';
2
+ declare const button: import("tailwind-variants").TVReturnType<{
3
+ size: {
4
+ extrasmall: string;
5
+ small: string;
6
+ medium: string;
7
+ large: string;
8
+ extralarge: string;
9
+ };
10
+ variant: {
11
+ fill: string;
12
+ outline: string;
13
+ simple: string;
14
+ ghost: string;
15
+ };
16
+ mode: {
17
+ distinct: string;
18
+ subtle: string;
19
+ negative: string;
20
+ };
21
+ roundness: {};
22
+ elevation: {};
23
+ shape: {
24
+ square: string;
25
+ rect: string;
26
+ };
27
+ inset: {
28
+ left: string;
29
+ right: string;
30
+ both: string;
31
+ };
32
+ }, undefined, "ease-fluid inline-flex items-center justify-center gap-2 outline-none transition-[box-shadow,background-color,color] duration-300 select-none data-[focus-visible]:outline-2 data-[focus-visible]:outline-offset-2 data-[disabled]:pointer-events-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[disabled]:shadow-none", import("tailwind-variants/dist/config.js").TVConfig<{
33
+ size: {
34
+ extrasmall: string;
35
+ small: string;
36
+ medium: string;
37
+ large: string;
38
+ extralarge: string;
39
+ };
40
+ variant: {
41
+ fill: string;
42
+ outline: string;
43
+ simple: string;
44
+ ghost: string;
45
+ };
46
+ mode: {
47
+ distinct: string;
48
+ subtle: string;
49
+ negative: string;
50
+ };
51
+ roundness: {};
52
+ elevation: {};
53
+ shape: {
54
+ square: string;
55
+ rect: string;
56
+ };
57
+ inset: {
58
+ left: string;
59
+ right: string;
60
+ both: string;
61
+ };
62
+ }, {
63
+ size: {
64
+ extrasmall: string;
65
+ small: string;
66
+ medium: string;
67
+ large: string;
68
+ extralarge: string;
69
+ };
70
+ roundness: {
71
+ none: string;
72
+ small: string;
73
+ medium: string;
74
+ large: string;
75
+ full: string;
76
+ };
77
+ elevation: {
78
+ none: string;
79
+ small: string;
80
+ medium: string;
81
+ large: string;
82
+ };
83
+ }>, {
84
+ size: {
85
+ extrasmall: string;
86
+ small: string;
87
+ medium: string;
88
+ large: string;
89
+ extralarge: string;
90
+ };
91
+ roundness: {
92
+ none: string;
93
+ small: string;
94
+ medium: string;
95
+ large: string;
96
+ full: string;
97
+ };
98
+ elevation: {
99
+ none: string;
100
+ small: string;
101
+ medium: string;
102
+ large: string;
103
+ };
104
+ }, undefined, import("tailwind-variants").TVReturnType<{
105
+ size: {
106
+ extrasmall: string;
107
+ small: string;
108
+ medium: string;
109
+ large: string;
110
+ extralarge: string;
111
+ };
112
+ roundness: {
113
+ none: string;
114
+ small: string;
115
+ medium: string;
116
+ large: string;
117
+ full: string;
118
+ };
119
+ elevation: {
120
+ none: string;
121
+ small: string;
122
+ medium: string;
123
+ large: string;
124
+ };
125
+ }, undefined, undefined, import("tailwind-variants/dist/config.js").TVConfig<{
126
+ size: {
127
+ extrasmall: string;
128
+ small: string;
129
+ medium: string;
130
+ large: string;
131
+ extralarge: string;
132
+ };
133
+ roundness: {
134
+ none: string;
135
+ small: string;
136
+ medium: string;
137
+ large: string;
138
+ full: string;
139
+ };
140
+ elevation: {
141
+ none: string;
142
+ small: string;
143
+ medium: string;
144
+ large: string;
145
+ };
146
+ }, {
147
+ size: {
148
+ extrasmall: string;
149
+ small: string;
150
+ medium: string;
151
+ large: string;
152
+ extralarge: string;
153
+ };
154
+ roundness: {
155
+ none: string;
156
+ small: string;
157
+ medium: string;
158
+ large: string;
159
+ full: string;
160
+ };
161
+ elevation: {
162
+ none: string;
163
+ small: string;
164
+ medium: string;
165
+ large: string;
166
+ };
167
+ }>, {
168
+ size: {
169
+ extrasmall: string;
170
+ small: string;
171
+ medium: string;
172
+ large: string;
173
+ extralarge: string;
174
+ };
175
+ roundness: {
176
+ none: string;
177
+ small: string;
178
+ medium: string;
179
+ large: string;
180
+ full: string;
181
+ };
182
+ elevation: {
183
+ none: string;
184
+ small: string;
185
+ medium: string;
186
+ large: string;
187
+ };
188
+ }, undefined, import("tailwind-variants").TVReturnType<{
189
+ size: {
190
+ extrasmall: string;
191
+ small: string;
192
+ medium: string;
193
+ large: string;
194
+ extralarge: string;
195
+ };
196
+ roundness: {
197
+ none: string;
198
+ small: string;
199
+ medium: string;
200
+ large: string;
201
+ full: string;
202
+ };
203
+ elevation: {
204
+ none: string;
205
+ small: string;
206
+ medium: string;
207
+ large: string;
208
+ };
209
+ }, undefined, undefined, import("tailwind-variants/dist/config.js").TVConfig<{
210
+ size: {
211
+ extrasmall: string;
212
+ small: string;
213
+ medium: string;
214
+ large: string;
215
+ extralarge: string;
216
+ };
217
+ roundness: {
218
+ none: string;
219
+ small: string;
220
+ medium: string;
221
+ large: string;
222
+ full: string;
223
+ };
224
+ elevation: {
225
+ none: string;
226
+ small: string;
227
+ medium: string;
228
+ large: string;
229
+ };
230
+ }, {
231
+ size: {
232
+ extrasmall: string;
233
+ small: string;
234
+ medium: string;
235
+ large: string;
236
+ extralarge: string;
237
+ };
238
+ roundness: {
239
+ none: string;
240
+ small: string;
241
+ medium: string;
242
+ large: string;
243
+ full: string;
244
+ };
245
+ elevation: {
246
+ none: string;
247
+ small: string;
248
+ medium: string;
249
+ large: string;
250
+ };
251
+ }>, unknown, unknown, undefined>>>;
252
+ type ButtonVariantProps = VariantProps<typeof button>;
253
+ export type { ButtonVariantProps };
254
+ export { button };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashx/react",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "license": "UNLICENSED",
5
5
  "type": "commonjs",
6
6
  "main": "./dist/cjs/index.js",
@@ -65,8 +65,10 @@ const useInApp = ({ showToast = true }: UseInAppOptions = {}): UseInAppHookRespo
65
65
  };
66
66
 
67
67
  useEffect(() => {
68
- // Set up in-app message watchers (automatically refetch on WebSocket reconnection)
69
- dashX.watchFetchInAppMessages((nextMessages) => {
68
+ // Set up in-app message watchers (automatically refetch on WebSocket reconnection).
69
+ // Both return an unsubscribe; without calling it the watchQuery subscriptions outlive
70
+ // the component and keep pushing state into it after unmount.
71
+ const unwatchMessages = dashX.watchFetchInAppMessages((nextMessages) => {
70
72
  setMessages(nextMessages);
71
73
  // While the list is a single page (initial load, empty inbox, or a reconnect
72
74
  // refetch of page 1), a full page implies more; past that, loadMore owns hasMore.
@@ -74,7 +76,12 @@ const useInApp = ({ showToast = true }: UseInAppOptions = {}): UseInAppHookRespo
74
76
  setHasMore(nextMessages.length === IN_APP_MESSAGES_PAGE_SIZE);
75
77
  }
76
78
  });
77
- dashX.watchFetchInAppMessagesAggregate(setUnreadMessagesCount);
79
+ const unwatchAggregate = dashX.watchFetchInAppMessagesAggregate(setUnreadMessagesCount);
80
+
81
+ return () => {
82
+ unwatchMessages();
83
+ unwatchAggregate();
84
+ };
78
85
  }, [dashX]);
79
86
 
80
87
  useEffect(() => {
package/CHANGELOG.md DELETED
@@ -1,81 +0,0 @@
1
- # Changelog
2
-
3
- All notable changes to `@dashx/react` are documented in this file. Format loosely follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), versions follow [SemVer](https://semver.org/).
4
-
5
- ## [0.4.1] — 2026-08-05
6
-
7
- ### Changed
8
-
9
- - **`useInAppChatNotifications`'s `onActivate` now receives the message that raised the notification.**
10
-
11
- ```diff
12
- - onActivate?: () => void
13
- + onActivate?: (message: InAppChatMessageData) => void
14
- ```
15
-
16
- Notifications are tagged per conversation, so a surface watching more than one thread could raise several at once — but the old zero-argument callback gave the handler no way to tell them apart, and it closed over whichever message arrived last. Clicking an older notification opened the wrong conversation.
17
-
18
- **Backward compatible.** A `() => void` handler is still assignable and still behaves as before; take the parameter only if you need to route by `message.conversationId`. `InAppChatMessageData` is imported from `@dashx/browser`, same as the existing `renderBody` option on this hook.
19
-
20
- ## [0.4.0] — 2026-07-29
21
-
22
- ### Changed
23
-
24
- - **BREAKING — In-App Chat no longer creates conversations; the caller supplies one.** `useInAppChat` and both widgets participate in an EXISTING conversation:
25
-
26
- ```diff
27
- - useInAppChat({ identityId, idempotencyKey, initialMessage? })
28
- + useInAppChat({ identityId, conversationId })
29
- ```
30
-
31
- `idempotencyKey` and `initialMessage` are gone, along with the create-on-mount behaviour. `<InAppChat>` and `<InAppChatButton>` take a required `conversationId` prop in place of `idempotencyKey`/`initialMessage`.
32
-
33
- **Why.** Creating a chat is now server-only in DashX: identity-token callers are rejected outright, and the operation requires an `accountUid` naming the visitor — a claim no browser should be able to make. The conversation's `data`/`issueProperties` are metadata the agent console trusts, so they must be derived server-side. `@dashx/browser@0.10.0` therefore removes `startInAppChatConversation`, which is what this hook used.
34
-
35
- **Migration.** Create the conversation in your backend (for JVM services, `dashx-java` ≥ 1.5.0 exposes `DashX.startInAppChatConversation(input)`), return the id to your client, and pass it in:
36
-
37
- ```tsx
38
- const { conversationId } = useMyBackendChatSession(); // your endpoint
39
- <InAppChatButton identityId="<chat-identity-id>" conversationId={conversationId} />
40
- ```
41
-
42
- `conversationId` accepts `null` while you're still fetching it — the hook stays idle (no subscription, no history fetch) rather than guessing, so you can render the widget unconditionally.
43
- - **`conversationId` is no longer returned from the hook.** The caller now owns it, so echoing it back was noise. Everything else in the response is unchanged: `messages`, `isLoading`, `isConnected`, `error`, `sendMessage`.
44
- - `sendMessage(text)` returns `false` when there is no `conversationId` yet (or the hook is disabled) — same contract as before, so callers that keep the composer populated on `false` need no change.
45
- - **`@dashx/browser` dependency raised to `^0.10.0`** (a regular `dependencies` entry, as before), which is the release that removes the creation method.
46
-
47
- ### Unchanged
48
-
49
- - History fetch, realtime subscribe, optimistic send + reconciliation, reconnect refetch, and the notification hook all behave exactly as before. `<InAppChatButton>` still activates lazily on first open, so a launcher the visitor never opens does no chat work.
50
-
51
- ## [0.3.0] — 2026-06-18
52
-
53
- ### Added
54
-
55
- - **In-App Chat hook + widgets.** A two-way in-app chat surface for visitors:
56
- - `useInAppChat({ identityId, idempotencyKey, initialMessage? })` — manages the conversation lifecycle (start → subscribe → fetch history), exposes `messages`, `sendMessage(text)`, and loading/error state, and reconciles optimistic sends against the realtime echoes (deduping by message id and external uid). Refetches history on reconnect so a reply that landed during an outage isn't missed.
57
- - `<InAppChat>` — the chat surface (header / message list / composer).
58
- - `<InAppChatButton>` — a floating launcher that opens `<InAppChat>` in a popover. Props: `identityId`, `idempotencyKey`, `position` (`'bottom-right'` | `'bottom-left'` | `'top-right'` | `'top-left'`, default `'bottom-right'`), and `theme` (accent color, mode, roundness, …). The chat mounts lazily on open, so no conversation is created until the visitor opens the launcher.
59
-
60
- In-App Chat requires a visitor identity token configured on `DashXProvider` (see below); render the chat only once that token is available.
61
-
62
- Example — `<InAppChatButton>` with a `theme` override (all `ThemeProps` fields are optional and otherwise inherit from a surrounding `<Theme>` / `DashXProvider`):
63
-
64
- ```tsx
65
- <InAppChatButton
66
- identityId="<dashx-chat-identity-id>"
67
- idempotencyKey="main"
68
- position="bottom-right"
69
- theme={{
70
- accentBaseColor: '#6d28d9',
71
- mode: 'dark',
72
- roundness: 'large',
73
- }}
74
- />
75
- ```
76
- - **`DashXProvider` identity props.** New optional `identityUid?` and `identityToken?`. When set, the identity is applied on both transports — the Apollo `X-Identity-Token` header and the WebSocket handshake — which is the visitor auth In-App Chat needs. Pass `null` to clear on logout; omit (`undefined`) to leave unchanged. Pair `identityUid` with `identityToken` to address the same identity on both transports.
77
-
78
- ### Changed
79
-
80
- - **Bumped `@dashx/browser` to `^0.8.0`** — for the In-App Chat client methods, the `subscribeToChannel` helper, and the `setIdentity` "undefined = leave unchanged" semantics this provider relies on.
81
- - **Identity is now applied synchronously at client creation**, and the provider reconnects its own WebSocket when `identityToken` changes (so tracked chat channels re-subscribe under the new identity). Existing consumers that pass neither `identityUid` nor `identityToken` are unaffected — no extra `setIdentity` call, no reconnect, and the client is not recreated.