@helpway/react 0.8.3 → 0.10.0

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/dist/index.d.ts CHANGED
@@ -246,6 +246,26 @@ declare function useUnread(): {
246
246
  */
247
247
  declare function useRealtime(handler: (event: RealtimeEvent) => void): void;
248
248
 
249
+ /**
250
+ * WidgetLogo — chat-header avatar. Renders WHO is talking to the
251
+ * visitor right now. Resolution chain:
252
+ * 1. Active conversation's assigned support user (assigneeName +
253
+ * assigneeImage from the widget API). When a human takes over a
254
+ * conversation the visitor sees that human, not the AI agent.
255
+ * 2. Agent uploaded image (agentConfig.avatarUrl)
256
+ * 3. Agent icon preset (avatarPreset + brandColor)
257
+ * 4. Website logo (website.logoUrl)
258
+ * 5. Helpway brand mark (octagonal) as the true last-resort fallback
259
+ *
260
+ * The `forceAgent` escape hatch skips the assignee lookup — used by
261
+ * surfaces that mean "the agent" specifically (welcome card, conversation
262
+ * list rows where we want the persistent brand, etc.) rather than "the
263
+ * person currently helping you".
264
+ */
265
+ declare function WidgetLogo({ className, forceAgent, }: {
266
+ className?: string;
267
+ forceAgent?: boolean;
268
+ }): react_jsx_runtime.JSX.Element;
249
269
  /**
250
270
  * Unified support widget — Intercom-style with tab navigation.
251
271
  * Two tabs: Home + Messages. Sub-views: conversation + new conversation.
@@ -273,6 +293,7 @@ interface MessageListProps {
273
293
  visitorName?: string;
274
294
  isTyping?: boolean;
275
295
  isAiProcessing?: boolean;
296
+ streamingText?: string;
276
297
  hasMore?: boolean;
277
298
  isLoadingMore?: boolean;
278
299
  onLoadMore?: () => void;
@@ -280,7 +301,7 @@ interface MessageListProps {
280
301
  renderAfterMessages?: react__default.ReactNode;
281
302
  }
282
303
  /** Timeline with date separators, typing indicator, infinite scroll, and AI processing state */
283
- declare function MessageList({ items, visitorName, isTyping, isAiProcessing, hasMore, isLoadingMore, onLoadMore, renderAfterMessages, }: MessageListProps): react_jsx_runtime.JSX.Element;
304
+ declare function MessageList({ items, visitorName, isTyping, isAiProcessing, streamingText, hasMore, isLoadingMore, onLoadMore, renderAfterMessages, }: MessageListProps): react_jsx_runtime.JSX.Element;
284
305
 
285
306
  interface ComposerProps {
286
307
  text: string;
@@ -303,6 +324,57 @@ interface ComposerProps {
303
324
  /** Widget composer — auto-resize, Enter-to-send, paste/drop attachments */
304
325
  declare function Composer({ text, onTextChange, onSubmit, onTyping, isSubmitting, placeholder, compact, attachments, onAddFiles, onRemoveAttachment, disabled, }: ComposerProps): react_jsx_runtime.JSX.Element;
305
326
 
327
+ /** Where the preview is anchored — controls only the outer positioning. */
328
+ type MessagePreviewPlacement = "launcher" | "anchored";
329
+ interface MessagePreviewProps {
330
+ /** Called when the visitor taps the preview (or a quick reply). The
331
+ * active conversation is already switched to the one that pinged —
332
+ * the consumer just has to reveal the chat surface. */
333
+ onOpen: () => void;
334
+ /**
335
+ * The avatar node shown in the header. Injected by the consumer so
336
+ * this component stays decoupled from avatar resolution — the default
337
+ * widget passes `<WidgetLogo />`; a custom surface can pass its own.
338
+ */
339
+ avatar: ReactNode;
340
+ /**
341
+ * Outer positioning mode. `"launcher"` (default) keeps the original
342
+ * absolute placement above the floating bubble — DefaultWidget relies
343
+ * on this, so the default is unchanged. `"anchored"` drops the
344
+ * absolute/bottom/right rules (via `hw-preview--anchored`) so a
345
+ * consumer can pin it to their own trigger (e.g. a sidebar item).
346
+ */
347
+ placement?: MessagePreviewPlacement;
348
+ /**
349
+ * Auto-dismiss delay in ms. Default `8000` (the launcher behaviour).
350
+ * Pass `null` (or `0`) to keep the preview until the visitor acts on
351
+ * it — useful for an anchored surface where it isn't competing with
352
+ * page content for attention. Quick-reply previews never auto-dismiss
353
+ * regardless, since the visitor needs time to choose.
354
+ */
355
+ autoDismissMs?: number | null;
356
+ /**
357
+ * Optional caption rendered as a separated footer beneath the message
358
+ * (e.g. a source label like "via Helpway"). Omitted for the launcher
359
+ * so its visual stays byte-identical to the original.
360
+ */
361
+ footer?: ReactNode;
362
+ }
363
+ /**
364
+ * `<MessagePreview>` — the proactive incoming-message bubble shown while
365
+ * the chat surface is closed. Reads `incomingPreview` from the widget
366
+ * store, auto-dismisses after 8s (unless quick replies are present), and
367
+ * on tap switches to the pinging conversation before calling `onOpen`.
368
+ *
369
+ * Extracted from the default widget so `hideLauncher` integrations can
370
+ * surface the *exact same* preview next to their own UI instead of the
371
+ * floating launcher. Visual/markup is byte-identical to the launcher
372
+ * version — only the outer positioning is parameterised via `placement`.
373
+ *
374
+ * Must be rendered inside `<SupportProvider>`.
375
+ */
376
+ declare function MessagePreview({ onOpen, avatar, placement, autoDismissMs, footer, }: MessagePreviewProps): react_jsx_runtime.JSX.Element | null;
377
+
306
378
  /**
307
379
  * Lightweight Markdown → HTML renderer.
308
380
  * Zero dependencies. Handles common patterns:
@@ -331,4 +403,4 @@ declare function MarkdownContent({ bodyHtml, bodyMarkdown, className, }: {
331
403
  className?: string;
332
404
  }): react_jsx_runtime.JSX.Element | null;
333
405
 
334
- export { Composer, DefaultWidget, type HelpwayPublicAPI, HelpwayWidget, type HelpwayWidgetProps, type IdentifyData, MarkdownContent, MessageBubble, MessageList, SupportProvider, linkifyText, renderMarkdown, useComposer, useConversations, useIdentify, usePresence, useRealtime, useTimeline, useUnread, useWidget, useWidgetStore };
406
+ export { Composer, DefaultWidget, type HelpwayPublicAPI, HelpwayWidget, type HelpwayWidgetProps, type IdentifyData, MarkdownContent, MessageBubble, MessageList, MessagePreview, type MessagePreviewPlacement, type MessagePreviewProps, SupportProvider, WidgetLogo, linkifyText, renderMarkdown, useComposer, useConversations, useIdentify, usePresence, useRealtime, useTimeline, useUnread, useWidget, useWidgetStore };