@cossistant/react 0.0.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.
- package/_virtual/rolldown_runtime.js +13 -0
- package/conversation.d.ts +312 -0
- package/conversation.d.ts.map +1 -0
- package/hooks/index.d.ts +23 -0
- package/hooks/index.js +24 -0
- package/hooks/private/store/use-conversations-store.d.ts +13 -0
- package/hooks/private/store/use-conversations-store.d.ts.map +1 -0
- package/hooks/private/store/use-conversations-store.js +34 -0
- package/hooks/private/store/use-conversations-store.js.map +1 -0
- package/hooks/private/store/use-store-selector.d.ts +10 -0
- package/hooks/private/store/use-store-selector.d.ts.map +1 -0
- package/hooks/private/store/use-store-selector.js +17 -0
- package/hooks/private/store/use-store-selector.js.map +1 -0
- package/hooks/private/store/use-website-store.d.ts +18 -0
- package/hooks/private/store/use-website-store.d.ts.map +1 -0
- package/hooks/private/store/use-website-store.js +39 -0
- package/hooks/private/store/use-website-store.js.map +1 -0
- package/hooks/private/use-client-query.d.ts +25 -0
- package/hooks/private/use-client-query.d.ts.map +1 -0
- package/hooks/private/use-client-query.js +122 -0
- package/hooks/private/use-client-query.js.map +1 -0
- package/hooks/private/use-default-messages.d.ts +18 -0
- package/hooks/private/use-default-messages.d.ts.map +1 -0
- package/hooks/private/use-default-messages.js +45 -0
- package/hooks/private/use-default-messages.js.map +1 -0
- package/hooks/private/use-grouped-messages.d.ts +54 -0
- package/hooks/private/use-grouped-messages.d.ts.map +1 -0
- package/hooks/private/use-grouped-messages.js +157 -0
- package/hooks/private/use-grouped-messages.js.map +1 -0
- package/hooks/private/use-multimodal-input.d.ts +40 -0
- package/hooks/private/use-multimodal-input.d.ts.map +1 -0
- package/hooks/private/use-multimodal-input.js +129 -0
- package/hooks/private/use-multimodal-input.js.map +1 -0
- package/hooks/private/use-rest-client.d.ts +17 -0
- package/hooks/private/use-rest-client.d.ts.map +1 -0
- package/hooks/private/use-rest-client.js +41 -0
- package/hooks/private/use-rest-client.js.map +1 -0
- package/hooks/private/use-visitor-typing-reporter.d.ts +19 -0
- package/hooks/private/use-visitor-typing-reporter.d.ts.map +1 -0
- package/hooks/private/use-visitor-typing-reporter.js +140 -0
- package/hooks/private/use-visitor-typing-reporter.js.map +1 -0
- package/hooks/use-composer-refocus.d.ts +20 -0
- package/hooks/use-composer-refocus.d.ts.map +1 -0
- package/hooks/use-composer-refocus.js +32 -0
- package/hooks/use-composer-refocus.js.map +1 -0
- package/hooks/use-conversation-auto-seen.d.ts +54 -0
- package/hooks/use-conversation-auto-seen.d.ts.map +1 -0
- package/hooks/use-conversation-auto-seen.js +106 -0
- package/hooks/use-conversation-auto-seen.js.map +1 -0
- package/hooks/use-conversation-history-page.d.ts +86 -0
- package/hooks/use-conversation-history-page.d.ts.map +1 -0
- package/hooks/use-conversation-history-page.js +97 -0
- package/hooks/use-conversation-history-page.js.map +1 -0
- package/hooks/use-conversation-lifecycle.d.ts +80 -0
- package/hooks/use-conversation-lifecycle.d.ts.map +1 -0
- package/hooks/use-conversation-lifecycle.js +54 -0
- package/hooks/use-conversation-lifecycle.js.map +1 -0
- package/hooks/use-conversation-page.d.ts +82 -0
- package/hooks/use-conversation-page.d.ts.map +1 -0
- package/hooks/use-conversation-page.js +138 -0
- package/hooks/use-conversation-page.js.map +1 -0
- package/hooks/use-conversation-seen.d.ts +17 -0
- package/hooks/use-conversation-seen.d.ts.map +1 -0
- package/hooks/use-conversation-seen.js +58 -0
- package/hooks/use-conversation-seen.js.map +1 -0
- package/hooks/use-conversation-timeline-items.d.ts +21 -0
- package/hooks/use-conversation-timeline-items.d.ts.map +1 -0
- package/hooks/use-conversation-timeline-items.js +87 -0
- package/hooks/use-conversation-timeline-items.js.map +1 -0
- package/hooks/use-conversation-typing.d.ts +13 -0
- package/hooks/use-conversation-typing.d.ts.map +1 -0
- package/hooks/use-conversation-typing.js +34 -0
- package/hooks/use-conversation-typing.js.map +1 -0
- package/hooks/use-conversation.d.ts +18 -0
- package/hooks/use-conversation.d.ts.map +1 -0
- package/hooks/use-conversation.js +44 -0
- package/hooks/use-conversation.js.map +1 -0
- package/hooks/use-conversations.d.ts +20 -0
- package/hooks/use-conversations.d.ts.map +1 -0
- package/hooks/use-conversations.js +68 -0
- package/hooks/use-conversations.js.map +1 -0
- package/hooks/use-create-conversation.d.ts +30 -0
- package/hooks/use-create-conversation.d.ts.map +1 -0
- package/hooks/use-create-conversation.js +67 -0
- package/hooks/use-create-conversation.js.map +1 -0
- package/hooks/use-home-page.d.ts +82 -0
- package/hooks/use-home-page.d.ts.map +1 -0
- package/hooks/use-home-page.js +89 -0
- package/hooks/use-home-page.js.map +1 -0
- package/hooks/use-message-composer.d.ts +88 -0
- package/hooks/use-message-composer.d.ts.map +1 -0
- package/hooks/use-message-composer.js +94 -0
- package/hooks/use-message-composer.js.map +1 -0
- package/hooks/use-realtime-support.d.ts +25 -0
- package/hooks/use-realtime-support.d.ts.map +1 -0
- package/hooks/use-realtime-support.js +29 -0
- package/hooks/use-realtime-support.js.map +1 -0
- package/hooks/use-send-message.d.ts +34 -0
- package/hooks/use-send-message.d.ts.map +1 -0
- package/hooks/use-send-message.js +118 -0
- package/hooks/use-send-message.js.map +1 -0
- package/hooks/use-visitor.d.ts +28 -0
- package/hooks/use-visitor.d.ts.map +1 -0
- package/hooks/use-visitor.js +59 -0
- package/hooks/use-visitor.js.map +1 -0
- package/hooks/use-window-visibility-focus.d.ts +9 -0
- package/hooks/use-window-visibility-focus.d.ts.map +1 -0
- package/hooks/use-window-visibility-focus.js +53 -0
- package/hooks/use-window-visibility-focus.js.map +1 -0
- package/identify-visitor.d.ts +18 -0
- package/identify-visitor.d.ts.map +1 -0
- package/identify-visitor.js +26 -0
- package/identify-visitor.js.map +1 -0
- package/index.d.ts +38 -0
- package/index.js +38 -0
- package/package.json +121 -0
- package/primitives/avatar/avatar.d.ts +31 -0
- package/primitives/avatar/avatar.d.ts.map +1 -0
- package/primitives/avatar/avatar.js +49 -0
- package/primitives/avatar/avatar.js.map +1 -0
- package/primitives/avatar/fallback.d.ts +24 -0
- package/primitives/avatar/fallback.d.ts.map +1 -0
- package/primitives/avatar/fallback.js +57 -0
- package/primitives/avatar/fallback.js.map +1 -0
- package/primitives/avatar/image.d.ts +27 -0
- package/primitives/avatar/image.d.ts.map +1 -0
- package/primitives/avatar/image.js +58 -0
- package/primitives/avatar/image.js.map +1 -0
- package/primitives/avatar/index.d.ts +4 -0
- package/primitives/avatar/index.js +5 -0
- package/primitives/avatar/index.parts.d.ts +4 -0
- package/primitives/avatar/index.parts.js +5 -0
- package/primitives/bubble.d.ts +28 -0
- package/primitives/bubble.d.ts.map +1 -0
- package/primitives/bubble.js +43 -0
- package/primitives/bubble.js.map +1 -0
- package/primitives/button.d.ts +19 -0
- package/primitives/button.d.ts.map +1 -0
- package/primitives/button.js +27 -0
- package/primitives/button.js.map +1 -0
- package/primitives/conversation-timeline.d.ts +86 -0
- package/primitives/conversation-timeline.d.ts.map +1 -0
- package/primitives/conversation-timeline.js +119 -0
- package/primitives/conversation-timeline.js.map +1 -0
- package/primitives/index.d.ts +20 -0
- package/primitives/index.d.ts.map +1 -0
- package/primitives/index.js +45 -0
- package/primitives/index.js.map +1 -0
- package/primitives/index.parts.d.ts +13 -0
- package/primitives/index.parts.js +14 -0
- package/primitives/multimodal-input.d.ts +53 -0
- package/primitives/multimodal-input.d.ts.map +1 -0
- package/primitives/multimodal-input.js +106 -0
- package/primitives/multimodal-input.js.map +1 -0
- package/primitives/timeline-item-group.d.ts +166 -0
- package/primitives/timeline-item-group.d.ts.map +1 -0
- package/primitives/timeline-item-group.js +204 -0
- package/primitives/timeline-item-group.js.map +1 -0
- package/primitives/timeline-item.d.ts +75 -0
- package/primitives/timeline-item.d.ts.map +1 -0
- package/primitives/timeline-item.js +145 -0
- package/primitives/timeline-item.js.map +1 -0
- package/primitives/window.d.ts +31 -0
- package/primitives/window.d.ts.map +1 -0
- package/primitives/window.js +58 -0
- package/primitives/window.js.map +1 -0
- package/provider.d.ts +95 -0
- package/provider.d.ts.map +1 -0
- package/provider.js +124 -0
- package/provider.js.map +1 -0
- package/realtime/event-filter.d.ts +8 -0
- package/realtime/event-filter.d.ts.map +1 -0
- package/realtime/event-filter.js +21 -0
- package/realtime/event-filter.js.map +1 -0
- package/realtime/index.d.ts +6 -0
- package/realtime/index.js +7 -0
- package/realtime/provider.d.ts +57 -0
- package/realtime/provider.d.ts.map +1 -0
- package/realtime/provider.js +351 -0
- package/realtime/provider.js.map +1 -0
- package/realtime/seen-store.d.ts +23 -0
- package/realtime/seen-store.d.ts.map +1 -0
- package/realtime/seen-store.js +34 -0
- package/realtime/seen-store.js.map +1 -0
- package/realtime/support-provider.d.ts +17 -0
- package/realtime/support-provider.d.ts.map +1 -0
- package/realtime/support-provider.js +54 -0
- package/realtime/support-provider.js.map +1 -0
- package/realtime/typing-store.d.ts +30 -0
- package/realtime/typing-store.d.ts.map +1 -0
- package/realtime/typing-store.js +34 -0
- package/realtime/typing-store.js.map +1 -0
- package/realtime/use-realtime.d.ts +29 -0
- package/realtime/use-realtime.d.ts.map +1 -0
- package/realtime/use-realtime.js +47 -0
- package/realtime/use-realtime.js.map +1 -0
- package/realtime-events.d.ts +344 -0
- package/realtime-events.d.ts.map +1 -0
- package/schemas.d.ts +90 -0
- package/schemas.d.ts.map +1 -0
- package/support/components/avatar-stack.d.ts +45 -0
- package/support/components/avatar-stack.d.ts.map +1 -0
- package/support/components/avatar-stack.js +72 -0
- package/support/components/avatar-stack.js.map +1 -0
- package/support/components/avatar.d.ts +15 -0
- package/support/components/avatar.d.ts.map +1 -0
- package/support/components/avatar.js +23 -0
- package/support/components/avatar.js.map +1 -0
- package/support/components/bubble.d.ts +10 -0
- package/support/components/bubble.d.ts.map +1 -0
- package/support/components/bubble.js +95 -0
- package/support/components/bubble.js.map +1 -0
- package/support/components/button.d.ts +20 -0
- package/support/components/button.d.ts.map +1 -0
- package/support/components/button.js +41 -0
- package/support/components/button.js.map +1 -0
- package/support/components/container.d.ts +14 -0
- package/support/components/container.d.ts.map +1 -0
- package/support/components/container.js +115 -0
- package/support/components/container.js.map +1 -0
- package/support/components/conversation-button-link.d.ts +34 -0
- package/support/components/conversation-button-link.d.ts.map +1 -0
- package/support/components/conversation-button-link.js +195 -0
- package/support/components/conversation-button-link.js.map +1 -0
- package/support/components/conversation-event.d.ts +14 -0
- package/support/components/conversation-event.d.ts.map +1 -0
- package/support/components/conversation-event.js +76 -0
- package/support/components/conversation-event.js.map +1 -0
- package/support/components/conversation-timeline.d.ts +17 -0
- package/support/components/conversation-timeline.d.ts.map +1 -0
- package/support/components/conversation-timeline.js +95 -0
- package/support/components/conversation-timeline.js.map +1 -0
- package/support/components/cossistant-branding.d.ts +12 -0
- package/support/components/cossistant-branding.d.ts.map +1 -0
- package/support/components/cossistant-branding.js +22 -0
- package/support/components/cossistant-branding.js.map +1 -0
- package/support/components/header.d.ts +11 -0
- package/support/components/header.d.ts.map +1 -0
- package/support/components/header.js +43 -0
- package/support/components/header.js.map +1 -0
- package/support/components/icons.d.ts +21 -0
- package/support/components/icons.d.ts.map +1 -0
- package/support/components/icons.js +131 -0
- package/support/components/icons.js.map +1 -0
- package/support/components/index.d.ts +11 -0
- package/support/components/index.js +12 -0
- package/support/components/multimodal-input.d.ts +28 -0
- package/support/components/multimodal-input.d.ts.map +1 -0
- package/support/components/multimodal-input.js +138 -0
- package/support/components/multimodal-input.js.map +1 -0
- package/support/components/navigation-tab.d.ts +7 -0
- package/support/components/navigation-tab.d.ts.map +1 -0
- package/support/components/navigation-tab.js +40 -0
- package/support/components/navigation-tab.js.map +1 -0
- package/support/components/support-content.d.ts +22 -0
- package/support/components/support-content.d.ts.map +1 -0
- package/support/components/support-content.js +50 -0
- package/support/components/support-content.js.map +1 -0
- package/support/components/text-effect.d.ts +49 -0
- package/support/components/text-effect.d.ts.map +1 -0
- package/support/components/text-effect.js +221 -0
- package/support/components/text-effect.js.map +1 -0
- package/support/components/timeline-message-group.d.ts +16 -0
- package/support/components/timeline-message-group.d.ts.map +1 -0
- package/support/components/timeline-message-group.js +117 -0
- package/support/components/timeline-message-group.js.map +1 -0
- package/support/components/timeline-message-item.d.ts +17 -0
- package/support/components/timeline-message-item.d.ts.map +1 -0
- package/support/components/timeline-message-item.js +42 -0
- package/support/components/timeline-message-item.js.map +1 -0
- package/support/components/typing-indicator.d.ts +26 -0
- package/support/components/typing-indicator.d.ts.map +1 -0
- package/support/components/typing-indicator.js +37 -0
- package/support/components/typing-indicator.js.map +1 -0
- package/support/components/watermark.d.ts +8 -0
- package/support/components/watermark.d.ts.map +1 -0
- package/support/components/watermark.js +34 -0
- package/support/components/watermark.js.map +1 -0
- package/support/context/config.d.ts +32 -0
- package/support/context/config.d.ts.map +1 -0
- package/support/context/config.js +27 -0
- package/support/context/config.js.map +1 -0
- package/support/context/websocket.d.ts +22 -0
- package/support/context/websocket.d.ts.map +1 -0
- package/support/context/websocket.js +113 -0
- package/support/context/websocket.js.map +1 -0
- package/support/index.d.ts +39 -0
- package/support/index.d.ts.map +1 -0
- package/support/index.js +43 -0
- package/support/index.js.map +1 -0
- package/support/pages/articles.d.ts +7 -0
- package/support/pages/articles.d.ts.map +1 -0
- package/support/pages/articles.js +39 -0
- package/support/pages/articles.js.map +1 -0
- package/support/pages/conversation-history.d.ts +18 -0
- package/support/pages/conversation-history.d.ts.map +1 -0
- package/support/pages/conversation-history.js +120 -0
- package/support/pages/conversation-history.js.map +1 -0
- package/support/pages/conversation.d.ts +32 -0
- package/support/pages/conversation.d.ts.map +1 -0
- package/support/pages/conversation.js +92 -0
- package/support/pages/conversation.js.map +1 -0
- package/support/pages/home.d.ts +20 -0
- package/support/pages/home.d.ts.map +1 -0
- package/support/pages/home.js +184 -0
- package/support/pages/home.js.map +1 -0
- package/support/router.d.ts +14 -0
- package/support/router.d.ts.map +1 -0
- package/support/router.js +31 -0
- package/support/router.js.map +1 -0
- package/support/store/index.d.ts +2 -0
- package/support/store/index.js +3 -0
- package/support/store/support-store.d.ts +42 -0
- package/support/store/support-store.d.ts.map +1 -0
- package/support/store/support-store.js +66 -0
- package/support/store/support-store.js.map +1 -0
- package/support/support-CMoDLQoC.css +408 -0
- package/support/support-CMoDLQoC.css.map +1 -0
- package/support/support.js +1 -0
- package/support/text/index.d.ts +35 -0
- package/support/text/index.d.ts.map +1 -0
- package/support/text/index.js +71 -0
- package/support/text/index.js.map +1 -0
- package/support/text/locales/en.d.ts +7 -0
- package/support/text/locales/en.d.ts.map +1 -0
- package/support/text/locales/en.js +65 -0
- package/support/text/locales/en.js.map +1 -0
- package/support/text/locales/es.d.ts +7 -0
- package/support/text/locales/es.d.ts.map +1 -0
- package/support/text/locales/es.js +64 -0
- package/support/text/locales/es.js.map +1 -0
- package/support/text/locales/fr.d.ts +7 -0
- package/support/text/locales/fr.d.ts.map +1 -0
- package/support/text/locales/fr.js +64 -0
- package/support/text/locales/fr.js.map +1 -0
- package/support/text/locales/keys.d.ts +216 -0
- package/support/text/locales/keys.d.ts.map +1 -0
- package/support/text/locales/keys.js +54 -0
- package/support/text/locales/keys.js.map +1 -0
- package/support/text/runtime.d.ts +17 -0
- package/support/text/runtime.d.ts.map +1 -0
- package/support/text/runtime.js +156 -0
- package/support/text/runtime.js.map +1 -0
- package/support/utils/index.d.ts +7 -0
- package/support/utils/index.d.ts.map +1 -0
- package/support/utils/index.js +11 -0
- package/support/utils/index.js.map +1 -0
- package/support/utils/time.d.ts +5 -0
- package/support/utils/time.d.ts.map +1 -0
- package/support/utils/time.js +28 -0
- package/support/utils/time.js.map +1 -0
- package/support-config.d.ts +20 -0
- package/support-config.d.ts.map +1 -0
- package/support-config.js +25 -0
- package/support-config.js.map +1 -0
- package/support.css +2 -0
- package/timeline-item.d.ts +133 -0
- package/timeline-item.d.ts.map +1 -0
- package/utils/id.d.ts +6 -0
- package/utils/id.d.ts.map +1 -0
- package/utils/id.js +13 -0
- package/utils/id.js.map +1 -0
- package/utils/index.d.ts +3 -0
- package/utils/index.js +4 -0
- package/utils/text.d.ts +5 -0
- package/utils/text.d.ts.map +1 -0
- package/utils/text.js +9 -0
- package/utils/text.js.map +1 -0
- package/utils/use-render-element.d.ts +22 -0
- package/utils/use-render-element.d.ts.map +1 -0
- package/utils/use-render-element.js +35 -0
- package/utils/use-render-element.js.map +1 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { TimelineItem } from "../timeline-item.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import { SenderType } from "@cossistant/types";
|
|
4
|
+
|
|
5
|
+
//#region src/primitives/timeline-item-group.d.ts
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Shape returned to render-prop children describing the grouped timeline items state
|
|
9
|
+
* and viewer specific flags.
|
|
10
|
+
*/
|
|
11
|
+
type TimelineItemGroupRenderProps = {
|
|
12
|
+
senderType: SenderType;
|
|
13
|
+
senderId: string;
|
|
14
|
+
viewerType?: SenderType;
|
|
15
|
+
isSentByViewer: boolean;
|
|
16
|
+
isReceivedByViewer: boolean;
|
|
17
|
+
isVisitor: boolean;
|
|
18
|
+
isAI: boolean;
|
|
19
|
+
isTeamMember: boolean;
|
|
20
|
+
itemCount: number;
|
|
21
|
+
firstItemId: string | undefined;
|
|
22
|
+
lastItemId: string | undefined;
|
|
23
|
+
hasBeenSeenByViewer?: boolean;
|
|
24
|
+
seenByIds?: string[];
|
|
25
|
+
};
|
|
26
|
+
type TimelineItemGroupProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
27
|
+
children?: React$1.ReactNode | ((props: TimelineItemGroupRenderProps) => React$1.ReactNode);
|
|
28
|
+
asChild?: boolean;
|
|
29
|
+
className?: string;
|
|
30
|
+
items: TimelineItem[];
|
|
31
|
+
viewerId?: string;
|
|
32
|
+
viewerType?: SenderType;
|
|
33
|
+
seenByIds?: string[];
|
|
34
|
+
lastReadItemIds?: Map<string, string>;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Groups sequential timeline items from the same sender and exposes render helpers
|
|
38
|
+
* that describe who sent the batch and whether the active viewer has seen it.
|
|
39
|
+
* Consumers can either render their own layout via a render prop or rely on
|
|
40
|
+
* slotted children. Typically used for MESSAGE-type items; EVENT items are usually rendered separately.
|
|
41
|
+
*/
|
|
42
|
+
declare const TimelineItemGroup: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
43
|
+
children?: React$1.ReactNode | ((props: TimelineItemGroupRenderProps) => React$1.ReactNode);
|
|
44
|
+
asChild?: boolean;
|
|
45
|
+
className?: string;
|
|
46
|
+
items: TimelineItem[];
|
|
47
|
+
viewerId?: string;
|
|
48
|
+
viewerType?: SenderType;
|
|
49
|
+
seenByIds?: string[];
|
|
50
|
+
lastReadItemIds?: Map<string, string>;
|
|
51
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
52
|
+
type TimelineItemGroupAvatarProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
53
|
+
children?: React$1.ReactNode;
|
|
54
|
+
asChild?: boolean;
|
|
55
|
+
className?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Optional slot rendered next to a grouped batch to display an avatar, agent
|
|
59
|
+
* badge or any other sender metadata supplied by the consumer UI.
|
|
60
|
+
*/
|
|
61
|
+
declare const TimelineItemGroupAvatar: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
62
|
+
children?: React$1.ReactNode;
|
|
63
|
+
asChild?: boolean;
|
|
64
|
+
className?: string;
|
|
65
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
66
|
+
type TimelineItemGroupHeaderProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
67
|
+
children?: React$1.ReactNode | ((props: {
|
|
68
|
+
name?: string;
|
|
69
|
+
senderId?: string;
|
|
70
|
+
senderType?: SenderType;
|
|
71
|
+
}) => React$1.ReactNode);
|
|
72
|
+
asChild?: boolean;
|
|
73
|
+
className?: string;
|
|
74
|
+
name?: string;
|
|
75
|
+
senderId?: string;
|
|
76
|
+
senderType?: SenderType;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Decorative or semantic wrapper rendered above a timeline item batch. Useful for
|
|
80
|
+
* injecting agent names, timestamps or custom status labels tied to the sender
|
|
81
|
+
* metadata supplied by `TimelineItemGroup`.
|
|
82
|
+
*/
|
|
83
|
+
declare const TimelineItemGroupHeader: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
84
|
+
children?: React$1.ReactNode | ((props: {
|
|
85
|
+
name?: string;
|
|
86
|
+
senderId?: string;
|
|
87
|
+
senderType?: SenderType;
|
|
88
|
+
}) => React$1.ReactNode);
|
|
89
|
+
asChild?: boolean;
|
|
90
|
+
className?: string;
|
|
91
|
+
name?: string;
|
|
92
|
+
senderId?: string;
|
|
93
|
+
senderType?: SenderType;
|
|
94
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
95
|
+
type TimelineItemGroupContentProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
96
|
+
children?: React$1.ReactNode;
|
|
97
|
+
asChild?: boolean;
|
|
98
|
+
className?: string;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Container for the actual timeline items within a batch. Consumers can
|
|
102
|
+
* override the structure while inheriting layout props passed down from the
|
|
103
|
+
* parent group.
|
|
104
|
+
*/
|
|
105
|
+
declare const TimelineItemGroupContent: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
106
|
+
children?: React$1.ReactNode;
|
|
107
|
+
asChild?: boolean;
|
|
108
|
+
className?: string;
|
|
109
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
110
|
+
type TimelineItemGroupSeenIndicatorProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
111
|
+
children?: React$1.ReactNode | ((props: {
|
|
112
|
+
seenByIds: string[];
|
|
113
|
+
hasBeenSeen: boolean;
|
|
114
|
+
}) => React$1.ReactNode);
|
|
115
|
+
asChild?: boolean;
|
|
116
|
+
className?: string;
|
|
117
|
+
seenByIds?: string[];
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* Utility slot for showing who has viewed the most recent timeline item in the
|
|
121
|
+
* group. Works with simple text children or a render prop for advanced
|
|
122
|
+
* displays.
|
|
123
|
+
*/
|
|
124
|
+
declare const TimelineItemGroupSeenIndicator: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
125
|
+
children?: React$1.ReactNode | ((props: {
|
|
126
|
+
seenByIds: string[];
|
|
127
|
+
hasBeenSeen: boolean;
|
|
128
|
+
}) => React$1.ReactNode);
|
|
129
|
+
asChild?: boolean;
|
|
130
|
+
className?: string;
|
|
131
|
+
seenByIds?: string[];
|
|
132
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
133
|
+
type TimelineItemGroupReadIndicatorProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
134
|
+
children?: React$1.ReactNode | ((props: {
|
|
135
|
+
readers: Array<{
|
|
136
|
+
userId: string;
|
|
137
|
+
isLastRead: boolean;
|
|
138
|
+
}>;
|
|
139
|
+
lastReaderIds: string[];
|
|
140
|
+
}) => React$1.ReactNode);
|
|
141
|
+
asChild?: boolean;
|
|
142
|
+
className?: string;
|
|
143
|
+
itemId: string;
|
|
144
|
+
lastReadItemIds?: Map<string, string>;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Renders read receipts for the tail timeline item in a group. It surfaces the list
|
|
148
|
+
* of readers and callers can decide whether to render avatars, tooltips or a
|
|
149
|
+
* basic label.
|
|
150
|
+
*/
|
|
151
|
+
declare const TimelineItemGroupReadIndicator: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
152
|
+
children?: React$1.ReactNode | ((props: {
|
|
153
|
+
readers: Array<{
|
|
154
|
+
userId: string;
|
|
155
|
+
isLastRead: boolean;
|
|
156
|
+
}>;
|
|
157
|
+
lastReaderIds: string[];
|
|
158
|
+
}) => React$1.ReactNode);
|
|
159
|
+
asChild?: boolean;
|
|
160
|
+
className?: string;
|
|
161
|
+
itemId: string;
|
|
162
|
+
lastReadItemIds?: Map<string, string>;
|
|
163
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
164
|
+
//#endregion
|
|
165
|
+
export { TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupAvatarProps, TimelineItemGroupContent, TimelineItemGroupContentProps, TimelineItemGroupHeader, TimelineItemGroupHeaderProps, TimelineItemGroupProps, TimelineItemGroupReadIndicator, TimelineItemGroupReadIndicatorProps, TimelineItemGroupRenderProps, TimelineItemGroupSeenIndicator, TimelineItemGroupSeenIndicatorProps };
|
|
166
|
+
//# sourceMappingURL=timeline-item-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-item-group.d.ts","names":[],"sources":["../../src/primitives/timeline-item-group.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AASA;;AAEa,KAFD,4BAAA,GAEC;YAEC,EAFD,UAEC;EAAU,QAAA,EAAA,MAAA;EAqBZ,UAAA,CAAA,EArBE,UAqBF;EAAsB,cAAA,EAAA,OAAA;oBACZ,EAAA,OAAA;WAArB,EAAM,OAAA;MAD8B,EAAA,OAAA;cAK3B,EAAA,OAAA;WACG,EAAA,MAAA;aAAuC,EAAA,MAAA,GAAA,SAAA;YAG5C,EAAA,MAAA,GAAA,SAAA;qBAIM,CAAA,EAAA,OAAA;WAIK,CAAA,EAAA,MAAA,EAAA;CAAG;AAST,KA1BD,sBAAA,GAAyB,IAkIjC,CAjIH,OAAA,CAAM,cAiIH,CAjIkB,cAiIlB,CAAA,EAAA,UAAA,CAAA,GAAA;EAAA,QAAA,CAAA,EA7HA,OAAA,CAAM,SA6HN,GAAA,CAAA,CAAA,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,OAAA,CAAM;aAEG;;;;;QAEH,OAAA,CAAM;;;;oBAIG"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { useRenderElement } from "../utils/use-render-element.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/primitives/timeline-item-group.tsx
|
|
5
|
+
/**
|
|
6
|
+
* Groups sequential timeline items from the same sender and exposes render helpers
|
|
7
|
+
* that describe who sent the batch and whether the active viewer has seen it.
|
|
8
|
+
* Consumers can either render their own layout via a render prop or rely on
|
|
9
|
+
* slotted children. Typically used for MESSAGE-type items; EVENT items are usually rendered separately.
|
|
10
|
+
*/
|
|
11
|
+
const TimelineItemGroup = (() => {
|
|
12
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, items = [], viewerId, seenByIds = [], lastReadItemIds,...restProps }, ref) => {
|
|
13
|
+
const { viewerType,...elementProps } = restProps;
|
|
14
|
+
const firstItem = items[0];
|
|
15
|
+
const lastItem = items[items.length - 1];
|
|
16
|
+
let senderId = "";
|
|
17
|
+
let senderType;
|
|
18
|
+
if (firstItem?.visitorId) {
|
|
19
|
+
senderId = firstItem.visitorId;
|
|
20
|
+
senderType = "visitor";
|
|
21
|
+
} else if (firstItem?.aiAgentId) {
|
|
22
|
+
senderId = firstItem.aiAgentId;
|
|
23
|
+
senderType = "ai";
|
|
24
|
+
} else if (firstItem?.userId) {
|
|
25
|
+
senderId = firstItem.userId;
|
|
26
|
+
senderType = "team_member";
|
|
27
|
+
} else {
|
|
28
|
+
senderId = firstItem?.id || "unknown";
|
|
29
|
+
senderType = "team_member";
|
|
30
|
+
}
|
|
31
|
+
const isSentByViewer = viewerId ? senderId === viewerId : viewerType ? senderType === viewerType : false;
|
|
32
|
+
const isReceivedByViewer = viewerId ? senderId !== viewerId : viewerType ? senderType !== viewerType : true;
|
|
33
|
+
const isVisitor = senderType === "visitor";
|
|
34
|
+
const isAI = senderType === "ai";
|
|
35
|
+
const isTeamMember = senderType === "team_member";
|
|
36
|
+
const hasBeenSeenByViewer = viewerId ? seenByIds.includes(viewerId) : void 0;
|
|
37
|
+
const renderProps = {
|
|
38
|
+
senderType,
|
|
39
|
+
senderId,
|
|
40
|
+
viewerType,
|
|
41
|
+
isSentByViewer,
|
|
42
|
+
isReceivedByViewer,
|
|
43
|
+
isVisitor,
|
|
44
|
+
isAI,
|
|
45
|
+
isTeamMember,
|
|
46
|
+
itemCount: items.length,
|
|
47
|
+
firstItemId: firstItem?.id,
|
|
48
|
+
lastItemId: lastItem?.id,
|
|
49
|
+
hasBeenSeenByViewer,
|
|
50
|
+
seenByIds
|
|
51
|
+
};
|
|
52
|
+
const content = typeof children === "function" ? children(renderProps) : children;
|
|
53
|
+
return useRenderElement("div", {
|
|
54
|
+
className,
|
|
55
|
+
asChild
|
|
56
|
+
}, {
|
|
57
|
+
ref,
|
|
58
|
+
state: renderProps,
|
|
59
|
+
props: {
|
|
60
|
+
role: "group",
|
|
61
|
+
"aria-label": `Timeline item group from ${senderType}`,
|
|
62
|
+
...elementProps,
|
|
63
|
+
children: content
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
Component.displayName = "TimelineItemGroup";
|
|
68
|
+
return Component;
|
|
69
|
+
})();
|
|
70
|
+
/**
|
|
71
|
+
* Optional slot rendered next to a grouped batch to display an avatar, agent
|
|
72
|
+
* badge or any other sender metadata supplied by the consumer UI.
|
|
73
|
+
*/
|
|
74
|
+
const TimelineItemGroupAvatar = (() => {
|
|
75
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false,...props }, ref) => useRenderElement("div", {
|
|
76
|
+
className,
|
|
77
|
+
asChild
|
|
78
|
+
}, {
|
|
79
|
+
ref,
|
|
80
|
+
props: {
|
|
81
|
+
...props,
|
|
82
|
+
children
|
|
83
|
+
}
|
|
84
|
+
}));
|
|
85
|
+
Component.displayName = "TimelineItemGroupAvatar";
|
|
86
|
+
return Component;
|
|
87
|
+
})();
|
|
88
|
+
/**
|
|
89
|
+
* Decorative or semantic wrapper rendered above a timeline item batch. Useful for
|
|
90
|
+
* injecting agent names, timestamps or custom status labels tied to the sender
|
|
91
|
+
* metadata supplied by `TimelineItemGroup`.
|
|
92
|
+
*/
|
|
93
|
+
const TimelineItemGroupHeader = (() => {
|
|
94
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, name, senderId, senderType,...props }, ref) => {
|
|
95
|
+
const content = typeof children === "function" ? children({
|
|
96
|
+
name,
|
|
97
|
+
senderId,
|
|
98
|
+
senderType
|
|
99
|
+
}) : children;
|
|
100
|
+
return useRenderElement("div", {
|
|
101
|
+
className,
|
|
102
|
+
asChild
|
|
103
|
+
}, {
|
|
104
|
+
ref,
|
|
105
|
+
props: {
|
|
106
|
+
...props,
|
|
107
|
+
children: content
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
Component.displayName = "TimelineItemGroupHeader";
|
|
112
|
+
return Component;
|
|
113
|
+
})();
|
|
114
|
+
/**
|
|
115
|
+
* Container for the actual timeline items within a batch. Consumers can
|
|
116
|
+
* override the structure while inheriting layout props passed down from the
|
|
117
|
+
* parent group.
|
|
118
|
+
*/
|
|
119
|
+
const TimelineItemGroupContent = (() => {
|
|
120
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false,...props }, ref) => useRenderElement("div", {
|
|
121
|
+
className,
|
|
122
|
+
asChild
|
|
123
|
+
}, {
|
|
124
|
+
ref,
|
|
125
|
+
props: {
|
|
126
|
+
...props,
|
|
127
|
+
children
|
|
128
|
+
}
|
|
129
|
+
}));
|
|
130
|
+
Component.displayName = "TimelineItemGroupContent";
|
|
131
|
+
return Component;
|
|
132
|
+
})();
|
|
133
|
+
/**
|
|
134
|
+
* Utility slot for showing who has viewed the most recent timeline item in the
|
|
135
|
+
* group. Works with simple text children or a render prop for advanced
|
|
136
|
+
* displays.
|
|
137
|
+
*/
|
|
138
|
+
const TimelineItemGroupSeenIndicator = (() => {
|
|
139
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, seenByIds = [],...props }, ref) => {
|
|
140
|
+
const hasBeenSeen = seenByIds.length > 0;
|
|
141
|
+
const content = typeof children === "function" ? children({
|
|
142
|
+
seenByIds,
|
|
143
|
+
hasBeenSeen
|
|
144
|
+
}) : children;
|
|
145
|
+
return useRenderElement("div", {
|
|
146
|
+
className,
|
|
147
|
+
asChild
|
|
148
|
+
}, {
|
|
149
|
+
ref,
|
|
150
|
+
props: {
|
|
151
|
+
...props,
|
|
152
|
+
children: content
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
Component.displayName = "TimelineItemGroupSeenIndicator";
|
|
157
|
+
return Component;
|
|
158
|
+
})();
|
|
159
|
+
/**
|
|
160
|
+
* Renders read receipts for the tail timeline item in a group. It surfaces the list
|
|
161
|
+
* of readers and callers can decide whether to render avatars, tooltips or a
|
|
162
|
+
* basic label.
|
|
163
|
+
*/
|
|
164
|
+
const TimelineItemGroupReadIndicator = (() => {
|
|
165
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, itemId, lastReadItemIds,...props }, ref) => {
|
|
166
|
+
const { lastReaderIds, readers } = React$1.useMemo(() => {
|
|
167
|
+
const _lastReaderIds = [];
|
|
168
|
+
const _readers = [];
|
|
169
|
+
if (lastReadItemIds) lastReadItemIds.forEach((lastItemId, userId) => {
|
|
170
|
+
if (lastItemId === itemId) {
|
|
171
|
+
_lastReaderIds.push(userId);
|
|
172
|
+
_readers.push({
|
|
173
|
+
userId,
|
|
174
|
+
isLastRead: true
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
return {
|
|
179
|
+
lastReaderIds: _lastReaderIds,
|
|
180
|
+
readers: _readers
|
|
181
|
+
};
|
|
182
|
+
}, [itemId, lastReadItemIds]);
|
|
183
|
+
const content = typeof children === "function" ? children({
|
|
184
|
+
readers,
|
|
185
|
+
lastReaderIds
|
|
186
|
+
}) : children;
|
|
187
|
+
return useRenderElement("div", {
|
|
188
|
+
className,
|
|
189
|
+
asChild
|
|
190
|
+
}, {
|
|
191
|
+
ref,
|
|
192
|
+
props: {
|
|
193
|
+
...props,
|
|
194
|
+
children: content
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
Component.displayName = "TimelineItemGroupReadIndicator";
|
|
199
|
+
return Component;
|
|
200
|
+
})();
|
|
201
|
+
|
|
202
|
+
//#endregion
|
|
203
|
+
export { TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator };
|
|
204
|
+
//# sourceMappingURL=timeline-item-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-item-group.js","names":["React","senderType: SenderType","renderProps: TimelineItemGroupRenderProps","_lastReaderIds: string[]","_readers: Array<{ userId: string; isLastRead: boolean }>"],"sources":["../../src/primitives/timeline-item-group.tsx"],"sourcesContent":["import type { SenderType } from \"@cossistant/types\";\nimport type { TimelineItem as TimelineItemType } from \"@cossistant/types/api/timeline-item\";\nimport * as React from \"react\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\n/**\n * Shape returned to render-prop children describing the grouped timeline items state\n * and viewer specific flags.\n */\nexport type TimelineItemGroupRenderProps = {\n\t// Sender information\n\tsenderType: SenderType;\n\tsenderId: string;\n\tviewerType?: SenderType;\n\n\t// POV flags - who is viewing\n\tisSentByViewer: boolean; // True if the current viewer sent these items\n\tisReceivedByViewer: boolean; // True if the current viewer received these items\n\n\t// Sender type flags for convenience\n\tisVisitor: boolean;\n\tisAI: boolean;\n\tisTeamMember: boolean;\n\n\t// Item info\n\titemCount: number;\n\tfirstItemId: string | undefined;\n\tlastItemId: string | undefined;\n\n\t// Seen status\n\thasBeenSeenByViewer?: boolean;\n\tseenByIds?: string[]; // IDs of users who have seen the last item in group\n};\n\nexport type TimelineItemGroupProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: TimelineItemGroupRenderProps) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\titems: TimelineItemType[];\n\n\t// POV context - who is viewing these timeline items\n\tviewerId?: string; // ID of the current viewer\n\tviewerType?: SenderType; // Type of the current viewer\n\n\t// Seen data\n\tseenByIds?: string[]; // IDs of users who have seen these timeline items\n\tlastReadItemIds?: Map<string, string>; // Map of userId -> lastItemId they read\n};\n\n/**\n * Groups sequential timeline items from the same sender and exposes render helpers\n * that describe who sent the batch and whether the active viewer has seen it.\n * Consumers can either render their own layout via a render prop or rely on\n * slotted children. Typically used for MESSAGE-type items; EVENT items are usually rendered separately.\n */\nexport const TimelineItemGroup = (() => {\n\tconst Component = React.forwardRef<HTMLDivElement, TimelineItemGroupProps>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\titems = [],\n\t\t\t\tviewerId,\n\t\t\t\tseenByIds = [],\n\t\t\t\tlastReadItemIds,\n\t\t\t\t...restProps\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst { viewerType, ...elementProps } = restProps;\n\n\t\t\t// Determine sender type from first timeline item in group\n\t\t\tconst firstItem = items[0];\n\t\t\t// biome-ignore lint/style/useAtIndex: ok\n\t\t\tconst lastItem = items[items.length - 1];\n\n\t\t\t// Determine sender info\n\t\t\tlet senderId = \"\";\n\t\t\tlet senderType: SenderType;\n\n\t\t\tif (firstItem?.visitorId) {\n\t\t\t\tsenderId = firstItem.visitorId;\n\t\t\t\tsenderType = \"visitor\" as SenderType;\n\t\t\t} else if (firstItem?.aiAgentId) {\n\t\t\t\tsenderId = firstItem.aiAgentId;\n\t\t\t\tsenderType = \"ai\" as SenderType;\n\t\t\t} else if (firstItem?.userId) {\n\t\t\t\tsenderId = firstItem.userId;\n\t\t\t\tsenderType = \"team_member\" as SenderType;\n\t\t\t} else {\n\t\t\t\t// Fallback\n\t\t\t\tsenderId = firstItem?.id || \"unknown\";\n\t\t\t\tsenderType = \"team_member\" as SenderType;\n\t\t\t}\n\n\t\t\t// Determine POV\n\t\t\tconst isSentByViewer = viewerId\n\t\t\t\t? senderId === viewerId\n\t\t\t\t: viewerType\n\t\t\t\t\t? senderType === viewerType\n\t\t\t\t\t: false;\n\t\t\tconst isReceivedByViewer = viewerId\n\t\t\t\t? senderId !== viewerId\n\t\t\t\t: viewerType\n\t\t\t\t\t? senderType !== viewerType\n\t\t\t\t\t: true;\n\n\t\t\t// Convenience flags\n\t\t\tconst isVisitor = senderType === \"visitor\";\n\t\t\tconst isAI = senderType === \"ai\";\n\t\t\tconst isTeamMember = senderType === \"team_member\";\n\n\t\t\t// Check if viewer has seen these timeline items\n\t\t\tconst hasBeenSeenByViewer = viewerId\n\t\t\t\t? seenByIds.includes(viewerId)\n\t\t\t\t: undefined;\n\n\t\t\tconst renderProps: TimelineItemGroupRenderProps = {\n\t\t\t\tsenderType,\n\t\t\t\tsenderId,\n\t\t\t\tviewerType,\n\t\t\t\tisSentByViewer,\n\t\t\t\tisReceivedByViewer,\n\t\t\t\tisVisitor,\n\t\t\t\tisAI,\n\t\t\t\tisTeamMember,\n\t\t\t\titemCount: items.length,\n\t\t\t\tfirstItemId: firstItem?.id,\n\t\t\t\tlastItemId: lastItem?.id,\n\t\t\t\thasBeenSeenByViewer,\n\t\t\t\tseenByIds,\n\t\t\t};\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\" ? children(renderProps) : children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tstate: renderProps,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\trole: \"group\",\n\t\t\t\t\t\t\"aria-label\": `Timeline item group from ${senderType}`,\n\t\t\t\t\t\t...elementProps,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroup\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupAvatarProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode;\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\n/**\n * Optional slot rendered next to a grouped batch to display an avatar, agent\n * badge or any other sender metadata supplied by the consumer UI.\n */\nexport const TimelineItemGroupAvatar = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupAvatarProps\n\t>(({ children, className, asChild = false, ...props }, ref) =>\n\t\tuseRenderElement(\n\t\t\t\"div\",\n\t\t\t{\n\t\t\t\tclassName,\n\t\t\t\tasChild,\n\t\t\t},\n\t\t\t{\n\t\t\t\tref,\n\t\t\t\tprops: {\n\t\t\t\t\t...props,\n\t\t\t\t\tchildren,\n\t\t\t\t},\n\t\t\t}\n\t\t)\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupAvatar\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupHeaderProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\tname?: string;\n\t\t\t\tsenderId?: string;\n\t\t\t\tsenderType?: SenderType;\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\tname?: string;\n\tsenderId?: string;\n\tsenderType?: SenderType;\n};\n\n/**\n * Decorative or semantic wrapper rendered above a timeline item batch. Useful for\n * injecting agent names, timestamps or custom status labels tied to the sender\n * metadata supplied by `TimelineItemGroup`.\n */\nexport const TimelineItemGroupHeader = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupHeaderProps\n\t>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\tname,\n\t\t\t\tsenderId,\n\t\t\t\tsenderType,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children({ name, senderId, senderType })\n\t\t\t\t\t: children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupHeader\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupContentProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode;\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\n/**\n * Container for the actual timeline items within a batch. Consumers can\n * override the structure while inheriting layout props passed down from the\n * parent group.\n */\nexport const TimelineItemGroupContent = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupContentProps\n\t>(({ children, className, asChild = false, ...props }, ref) =>\n\t\tuseRenderElement(\n\t\t\t\"div\",\n\t\t\t{\n\t\t\t\tclassName,\n\t\t\t\tasChild,\n\t\t\t},\n\t\t\t{\n\t\t\t\tref,\n\t\t\t\tprops: {\n\t\t\t\t\t...props,\n\t\t\t\t\tchildren,\n\t\t\t\t},\n\t\t\t}\n\t\t)\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupContent\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupSeenIndicatorProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\tseenByIds: string[];\n\t\t\t\thasBeenSeen: boolean;\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\tseenByIds?: string[];\n};\n\n/**\n * Utility slot for showing who has viewed the most recent timeline item in the\n * group. Works with simple text children or a render prop for advanced\n * displays.\n */\nexport const TimelineItemGroupSeenIndicator = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupSeenIndicatorProps\n\t>(\n\t\t(\n\t\t\t{ children, className, asChild = false, seenByIds = [], ...props },\n\t\t\tref\n\t\t) => {\n\t\t\tconst hasBeenSeen = seenByIds.length > 0;\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children({ seenByIds, hasBeenSeen })\n\t\t\t\t\t: children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupSeenIndicator\";\n\treturn Component;\n})();\n\nexport type TimelineItemGroupReadIndicatorProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: {\n\t\t\t\treaders: Array<{ userId: string; isLastRead: boolean }>;\n\t\t\t\tlastReaderIds: string[];\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\titemId: string;\n\tlastReadItemIds?: Map<string, string>;\n};\n\n/**\n * Renders read receipts for the tail timeline item in a group. It surfaces the list\n * of readers and callers can decide whether to render avatars, tooltips or a\n * basic label.\n */\nexport const TimelineItemGroupReadIndicator = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemGroupReadIndicatorProps\n\t>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\titemId,\n\t\t\t\tlastReadItemIds,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\t// Find all users who stopped reading at this timeline item\n\t\t\tconst { lastReaderIds, readers } = React.useMemo(() => {\n\t\t\t\tconst _lastReaderIds: string[] = [];\n\t\t\t\tconst _readers: Array<{ userId: string; isLastRead: boolean }> = [];\n\n\t\t\t\tif (lastReadItemIds) {\n\t\t\t\t\tlastReadItemIds.forEach((lastItemId, userId) => {\n\t\t\t\t\t\tif (lastItemId === itemId) {\n\t\t\t\t\t\t\t_lastReaderIds.push(userId);\n\t\t\t\t\t\t\t_readers.push({ userId, isLastRead: true });\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\treturn { lastReaderIds: _lastReaderIds, readers: _readers };\n\t\t\t}, [itemId, lastReadItemIds]);\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children({ readers, lastReaderIds })\n\t\t\t\t\t: children;\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemGroupReadIndicator\";\n\treturn Component;\n})();\n"],"mappings":";;;;;;;;;;AA4DA,MAAa,2BAA2B;CACvC,MAAM,YAAYA,QAAM,YAEtB,EACC,UACA,WACA,UAAU,OACV,QAAQ,EAAE,EACV,UACA,YAAY,EAAE,EACd,gBACA,GAAG,aAEJ,Q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eAAe;IAAgB,SAAS;IAAU;KACzD,CAAC,QAAQ,gBAAgB,CAAC;EAE7B,MAAM,UACL,OAAO,aAAa,aACjB,SAAS;GAAE;GAAS;GAAe,CAAC,GACpC;AAEJ,SAAO,iBACN,OACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;IACN,GAAG;IACH,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { TimelineItem as TimelineItem$1 } from "../timeline-item.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/primitives/timeline-item.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Metadata describing the origin of a timeline item and pre-parsed content that can
|
|
8
|
+
* be consumed by render-prop children.
|
|
9
|
+
*/
|
|
10
|
+
type TimelineItemRenderProps = {
|
|
11
|
+
isVisitor: boolean;
|
|
12
|
+
isAI: boolean;
|
|
13
|
+
isHuman: boolean;
|
|
14
|
+
timestamp: Date;
|
|
15
|
+
text: string | null;
|
|
16
|
+
senderType: "visitor" | "ai" | "human";
|
|
17
|
+
itemType: "message" | "event";
|
|
18
|
+
};
|
|
19
|
+
type TimelineItemProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
20
|
+
children?: React$1.ReactNode | ((props: TimelineItemRenderProps) => React$1.ReactNode);
|
|
21
|
+
asChild?: boolean;
|
|
22
|
+
className?: string;
|
|
23
|
+
item: TimelineItem$1;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Generic timeline item wrapper that adds accessibility attributes and resolves the
|
|
27
|
+
* sender type into convenient render props for custom layouts. Works with
|
|
28
|
+
* both MESSAGE and EVENT timeline item types.
|
|
29
|
+
*/
|
|
30
|
+
declare const TimelineItem: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
31
|
+
children?: React$1.ReactNode | ((props: TimelineItemRenderProps) => React$1.ReactNode);
|
|
32
|
+
asChild?: boolean;
|
|
33
|
+
className?: string;
|
|
34
|
+
item: TimelineItem$1;
|
|
35
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
type TimelineItemContentProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
37
|
+
children?: React$1.ReactNode | ((content: string) => React$1.ReactNode);
|
|
38
|
+
asChild?: boolean;
|
|
39
|
+
className?: string;
|
|
40
|
+
text?: string | null;
|
|
41
|
+
renderMarkdown?: boolean;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Renders the content of a timeline item, optionally piping Markdown content through a
|
|
45
|
+
* memoised renderer or handing the raw text to a render prop for custom
|
|
46
|
+
* formatting.
|
|
47
|
+
*/
|
|
48
|
+
declare const TimelineItemContent: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
49
|
+
children?: React$1.ReactNode | ((content: string) => React$1.ReactNode);
|
|
50
|
+
asChild?: boolean;
|
|
51
|
+
className?: string;
|
|
52
|
+
text?: string | null;
|
|
53
|
+
renderMarkdown?: boolean;
|
|
54
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
55
|
+
type TimelineItemTimestampProps = Omit<React$1.HTMLAttributes<HTMLSpanElement>, "children"> & {
|
|
56
|
+
children?: React$1.ReactNode | ((timestamp: Date) => React$1.ReactNode);
|
|
57
|
+
asChild?: boolean;
|
|
58
|
+
className?: string;
|
|
59
|
+
timestamp: Date;
|
|
60
|
+
format?: (date: Date) => string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Timestamp helper that renders a formatted date or allows callers to supply a
|
|
64
|
+
* render prop for custom time displays while preserving semantic markup.
|
|
65
|
+
*/
|
|
66
|
+
declare const TimelineItemTimestamp: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLSpanElement>, "children"> & {
|
|
67
|
+
children?: React$1.ReactNode | ((timestamp: Date) => React$1.ReactNode);
|
|
68
|
+
asChild?: boolean;
|
|
69
|
+
className?: string;
|
|
70
|
+
timestamp: Date;
|
|
71
|
+
format?: (date: Date) => string;
|
|
72
|
+
} & React$1.RefAttributes<HTMLSpanElement>>;
|
|
73
|
+
//#endregion
|
|
74
|
+
export { TimelineItem, TimelineItemContent, TimelineItemContentProps, TimelineItemProps, TimelineItemRenderProps, TimelineItemTimestamp, TimelineItemTimestampProps };
|
|
75
|
+
//# sourceMappingURL=timeline-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-item.d.ts","names":[],"sources":["../../src/primitives/timeline-item.tsx"],"sourcesContent":[],"mappings":";;;;;;;AASA;AAUA;AAA6B,KAVjB,uBAAA,GAUiB;WACP,EAAA,OAAA;MAArB,EAAA,OAAM;SADyB,EAAA,OAAA;WAK5B,EAXQ,IAWF;MACG,EAAA,MAAA,GAAA,IAAA;YAA4B,EAAM,SAAA,GAAA,IAAA,GAAA,OAAA;UAGxC,EAAA,SAAA,GAAA,OAAA;CAAgB;AAQV,KAjBD,iBAAA,GAAoB,IAuE5B,CAtEH,OAAA,CAAM,cAsEH,CAtEkB,cAsElB,CAAA,EAAA,UAAA,CAAA,GAAA;EAAA,QAAA,CAAA,EAlEA,OAAA,CAAM,SAkEN,GAAA,CAAA,CAAA,KAAA,EAjES,uBAiET,EAAA,GAjEqC,OAAA,CAAM,SAiE3C,CAAA;SAtDqB,CAAA,EAAA,OAAA;WAAA,CAAA,EAAA,MAAA;MAAA,EARlB,cAQkB;;;;;;;AAAA,cAAZ,YAAY,EAAA,OAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,OAAA,CAAA,cAAA,CAAA,cAAA,CAAA,EAAA,UAAA,CAAA,GAAA;EAAA,QAAA,CAAA,EAZrB,OAAA,CAAM,SAYe,GAAA,CAAA,CAAA,KAAA,EAXZ,uBAWY,EAAA,GAXgB,OAAA,CAAM,SAWtB,CAAA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eAAA,CAAA,EAAA,UAAA,CAAA,GAAA;UAXtB,CAAA,EAAA,OAAA,CAAM,SAAA,GAAA,CAAA,CAAA,SAAA,EAAyB,IAAzB,EAAA,GAAkC,OAAA,CAAM,SAAxC,CAAA;SAAyB,CAAA,EAAA,OAAA;WAAS,CAAA,EAAM,MAAA;WAG9C,EAAA,IAAA;QACK,CAAA,EAAA,CAAA,IAAA,EAAA,IAAA,EAAA,GAAA,MAAA"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { useRenderElement } from "../utils/use-render-element.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import ReactMarkdown from "react-markdown";
|
|
5
|
+
|
|
6
|
+
//#region src/primitives/timeline-item.tsx
|
|
7
|
+
/**
|
|
8
|
+
* Generic timeline item wrapper that adds accessibility attributes and resolves the
|
|
9
|
+
* sender type into convenient render props for custom layouts. Works with
|
|
10
|
+
* both MESSAGE and EVENT timeline item types.
|
|
11
|
+
*/
|
|
12
|
+
const TimelineItem = (() => {
|
|
13
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, item,...props }, ref) => {
|
|
14
|
+
const isVisitor = item.visitorId !== null;
|
|
15
|
+
const isAI = item.aiAgentId !== null;
|
|
16
|
+
const isHuman = item.userId !== null && !isVisitor;
|
|
17
|
+
const senderType = isVisitor ? "visitor" : isAI ? "ai" : "human";
|
|
18
|
+
const renderProps = {
|
|
19
|
+
isVisitor,
|
|
20
|
+
isAI,
|
|
21
|
+
isHuman,
|
|
22
|
+
timestamp: new Date(item.createdAt),
|
|
23
|
+
text: item.text,
|
|
24
|
+
senderType,
|
|
25
|
+
itemType: item.type
|
|
26
|
+
};
|
|
27
|
+
const content = typeof children === "function" ? children(renderProps) : children;
|
|
28
|
+
const itemTypeLabel = item.type === "event" ? "Event" : isVisitor ? "visitor" : isAI ? "AI assistant" : "human agent";
|
|
29
|
+
return useRenderElement("div", {
|
|
30
|
+
className,
|
|
31
|
+
asChild
|
|
32
|
+
}, {
|
|
33
|
+
ref,
|
|
34
|
+
state: renderProps,
|
|
35
|
+
props: {
|
|
36
|
+
role: "article",
|
|
37
|
+
"aria-label": `${item.type === "message" ? "Message" : "Event"} from ${itemTypeLabel}`,
|
|
38
|
+
...props,
|
|
39
|
+
children: content
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
Component.displayName = "TimelineItem";
|
|
44
|
+
return Component;
|
|
45
|
+
})();
|
|
46
|
+
const MemoizedMarkdownBlock = React$1.memo(({ content }) => {
|
|
47
|
+
return /* @__PURE__ */ jsx(ReactMarkdown, {
|
|
48
|
+
components: {
|
|
49
|
+
p: ({ children }) => /* @__PURE__ */ jsx("span", {
|
|
50
|
+
className: "inline",
|
|
51
|
+
children
|
|
52
|
+
}),
|
|
53
|
+
br: () => /* @__PURE__ */ jsx("br", {}),
|
|
54
|
+
code: ({ children,...props }) => {
|
|
55
|
+
return !("className" in props && typeof props.className === "string" && props.className.includes("language-")) ? /* @__PURE__ */ jsx("code", {
|
|
56
|
+
className: "rounded bg-co-background-300 px-1 py-0.5 text-xs",
|
|
57
|
+
children
|
|
58
|
+
}) : /* @__PURE__ */ jsx("pre", {
|
|
59
|
+
className: "overflow-x-auto rounded bg-co-background-300 p-2",
|
|
60
|
+
children: /* @__PURE__ */ jsx("code", {
|
|
61
|
+
className: "text-xs",
|
|
62
|
+
children
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
strong: ({ children }) => /* @__PURE__ */ jsx("strong", {
|
|
67
|
+
className: "font-semibold",
|
|
68
|
+
children
|
|
69
|
+
}),
|
|
70
|
+
a: ({ href, children }) => /* @__PURE__ */ jsx("a", {
|
|
71
|
+
className: "underline hover:opacity-80",
|
|
72
|
+
href,
|
|
73
|
+
rel: "noopener noreferrer",
|
|
74
|
+
target: "_blank",
|
|
75
|
+
children
|
|
76
|
+
})
|
|
77
|
+
},
|
|
78
|
+
children: content
|
|
79
|
+
});
|
|
80
|
+
}, (prevProps, nextProps) => {
|
|
81
|
+
if (prevProps.content !== nextProps.content) return false;
|
|
82
|
+
return true;
|
|
83
|
+
});
|
|
84
|
+
MemoizedMarkdownBlock.displayName = "MemoizedMarkdownBlock";
|
|
85
|
+
/**
|
|
86
|
+
* Renders the content of a timeline item, optionally piping Markdown content through a
|
|
87
|
+
* memoised renderer or handing the raw text to a render prop for custom
|
|
88
|
+
* formatting.
|
|
89
|
+
*/
|
|
90
|
+
const TimelineItemContent = (() => {
|
|
91
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, text = "", renderMarkdown = true,...props }, ref) => {
|
|
92
|
+
const content = React$1.useMemo(() => {
|
|
93
|
+
const textContent = text ?? "";
|
|
94
|
+
if (typeof children === "function") return children(textContent);
|
|
95
|
+
if (children) return children;
|
|
96
|
+
if (renderMarkdown && textContent) return /* @__PURE__ */ jsx(MemoizedMarkdownBlock, { content: textContent });
|
|
97
|
+
return textContent;
|
|
98
|
+
}, [
|
|
99
|
+
children,
|
|
100
|
+
text,
|
|
101
|
+
renderMarkdown
|
|
102
|
+
]);
|
|
103
|
+
return useRenderElement("div", {
|
|
104
|
+
className,
|
|
105
|
+
asChild
|
|
106
|
+
}, {
|
|
107
|
+
ref,
|
|
108
|
+
props: {
|
|
109
|
+
...props,
|
|
110
|
+
children: content,
|
|
111
|
+
style: { ...props.style }
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
Component.displayName = "TimelineItemContent";
|
|
116
|
+
return Component;
|
|
117
|
+
})();
|
|
118
|
+
/**
|
|
119
|
+
* Timestamp helper that renders a formatted date or allows callers to supply a
|
|
120
|
+
* render prop for custom time displays while preserving semantic markup.
|
|
121
|
+
*/
|
|
122
|
+
const TimelineItemTimestamp = (() => {
|
|
123
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, timestamp, format = (date) => date.toLocaleTimeString([], {
|
|
124
|
+
hour: "2-digit",
|
|
125
|
+
minute: "2-digit"
|
|
126
|
+
}),...props }, ref) => {
|
|
127
|
+
const content = typeof children === "function" ? children(timestamp) : children || format(timestamp);
|
|
128
|
+
return useRenderElement("span", {
|
|
129
|
+
className,
|
|
130
|
+
asChild
|
|
131
|
+
}, {
|
|
132
|
+
ref,
|
|
133
|
+
props: {
|
|
134
|
+
...props,
|
|
135
|
+
children: content
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
Component.displayName = "TimelineItemTimestamp";
|
|
140
|
+
return Component;
|
|
141
|
+
})();
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
export { TimelineItem, TimelineItemContent, TimelineItemTimestamp };
|
|
145
|
+
//# sourceMappingURL=timeline-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-item.js","names":["React","renderProps: TimelineItemRenderProps"],"sources":["../../src/primitives/timeline-item.tsx"],"sourcesContent":["import type { TimelineItem as TimelineItemType } from \"@cossistant/types/api/timeline-item\";\nimport * as React from \"react\";\nimport ReactMarkdown from \"react-markdown\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\n/**\n * Metadata describing the origin of a timeline item and pre-parsed content that can\n * be consumed by render-prop children.\n */\nexport type TimelineItemRenderProps = {\n\tisVisitor: boolean;\n\tisAI: boolean;\n\tisHuman: boolean;\n\ttimestamp: Date;\n\ttext: string | null;\n\tsenderType: \"visitor\" | \"ai\" | \"human\";\n\titemType: \"message\" | \"event\";\n};\n\nexport type TimelineItemProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((props: TimelineItemRenderProps) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\titem: TimelineItemType;\n};\n\n/**\n * Generic timeline item wrapper that adds accessibility attributes and resolves the\n * sender type into convenient render props for custom layouts. Works with\n * both MESSAGE and EVENT timeline item types.\n */\nexport const TimelineItem = (() => {\n\tconst Component = React.forwardRef<HTMLDivElement, TimelineItemProps>(\n\t\t({ children, className, asChild = false, item, ...props }, ref) => {\n\t\t\t// Determine sender type from timeline item properties\n\t\t\tconst isVisitor = item.visitorId !== null;\n\t\t\tconst isAI = item.aiAgentId !== null;\n\t\t\tconst isHuman = item.userId !== null && !isVisitor;\n\n\t\t\tconst senderType = isVisitor ? \"visitor\" : isAI ? \"ai\" : \"human\";\n\n\t\t\tconst renderProps: TimelineItemRenderProps = {\n\t\t\t\tisVisitor,\n\t\t\t\tisAI,\n\t\t\t\tisHuman,\n\t\t\t\ttimestamp: new Date(item.createdAt),\n\t\t\t\ttext: item.text,\n\t\t\t\tsenderType,\n\t\t\t\titemType: item.type,\n\t\t\t};\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\" ? children(renderProps) : children;\n\n\t\t\tconst itemTypeLabel =\n\t\t\t\titem.type === \"event\"\n\t\t\t\t\t? \"Event\"\n\t\t\t\t\t: isVisitor\n\t\t\t\t\t\t? \"visitor\"\n\t\t\t\t\t\t: isAI\n\t\t\t\t\t\t\t? \"AI assistant\"\n\t\t\t\t\t\t\t: \"human agent\";\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tstate: renderProps,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\trole: \"article\",\n\t\t\t\t\t\t\"aria-label\": `${item.type === \"message\" ? \"Message\" : \"Event\"} from ${itemTypeLabel}`,\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItem\";\n\treturn Component;\n})();\n\nconst MemoizedMarkdownBlock = React.memo(\n\t({ content }: { content: string }) => {\n\t\treturn (\n\t\t\t<ReactMarkdown\n\t\t\t\tcomponents={{\n\t\t\t\t\t// Customize paragraph rendering to prevent excessive spacing\n\t\t\t\t\tp: ({ children }) => <span className=\"inline\">{children}</span>,\n\t\t\t\t\t// Ensure proper line break handling\n\t\t\t\t\tbr: () => <br />,\n\t\t\t\t\t// Handle code blocks properly\n\t\t\t\t\tcode: ({ children, ...props }) => {\n\t\t\t\t\t\t// Check if it's inline code by looking at the parent element\n\t\t\t\t\t\tconst isInline = !(\n\t\t\t\t\t\t\t\"className\" in props &&\n\t\t\t\t\t\t\ttypeof props.className === \"string\" &&\n\t\t\t\t\t\t\tprops.className.includes(\"language-\")\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn isInline ? (\n\t\t\t\t\t\t\t<code className=\"rounded bg-co-background-300 px-1 py-0.5 text-xs\">\n\t\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t\t</code>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<pre className=\"overflow-x-auto rounded bg-co-background-300 p-2\">\n\t\t\t\t\t\t\t\t<code className=\"text-xs\">{children}</code>\n\t\t\t\t\t\t\t</pre>\n\t\t\t\t\t\t);\n\t\t\t\t\t},\n\t\t\t\t\t// Handle strong/bold text\n\t\t\t\t\tstrong: ({ children }) => (\n\t\t\t\t\t\t<strong className=\"font-semibold\">{children}</strong>\n\t\t\t\t\t),\n\t\t\t\t\t// Handle links\n\t\t\t\t\ta: ({ href, children }) => (\n\t\t\t\t\t\t<a\n\t\t\t\t\t\t\tclassName=\"underline hover:opacity-80\"\n\t\t\t\t\t\t\thref={href}\n\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{children}\n\t\t\t\t\t\t</a>\n\t\t\t\t\t),\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t{content}\n\t\t\t</ReactMarkdown>\n\t\t);\n\t},\n\t(prevProps, nextProps) => {\n\t\tif (prevProps.content !== nextProps.content) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n);\n\nMemoizedMarkdownBlock.displayName = \"MemoizedMarkdownBlock\";\n\nexport type TimelineItemContentProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode | ((content: string) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\ttext?: string | null;\n\trenderMarkdown?: boolean;\n};\n\n/**\n * Renders the content of a timeline item, optionally piping Markdown content through a\n * memoised renderer or handing the raw text to a render prop for custom\n * formatting.\n */\nexport const TimelineItemContent = (() => {\n\tconst Component = React.forwardRef<HTMLDivElement, TimelineItemContentProps>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\ttext = \"\",\n\t\t\t\trenderMarkdown = true,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst content = React.useMemo(() => {\n\t\t\t\tconst textContent = text ?? \"\";\n\t\t\t\tif (typeof children === \"function\") {\n\t\t\t\t\treturn children(textContent);\n\t\t\t\t}\n\t\t\t\tif (children) {\n\t\t\t\t\treturn children;\n\t\t\t\t}\n\t\t\t\tif (renderMarkdown && textContent) {\n\t\t\t\t\treturn <MemoizedMarkdownBlock content={textContent} />;\n\t\t\t\t}\n\t\t\t\treturn textContent;\n\t\t\t}, [children, text, renderMarkdown]);\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"div\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...props.style,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemContent\";\n\treturn Component;\n})();\n\nexport type TimelineItemTimestampProps = Omit<\n\tReact.HTMLAttributes<HTMLSpanElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode | ((timestamp: Date) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\ttimestamp: Date;\n\tformat?: (date: Date) => string;\n};\n\n/**\n * Timestamp helper that renders a formatted date or allows callers to supply a\n * render prop for custom time displays while preserving semantic markup.\n */\nexport const TimelineItemTimestamp = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLSpanElement,\n\t\tTimelineItemTimestampProps\n\t>(\n\t\t(\n\t\t\t{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\ttimestamp,\n\t\t\t\tformat = (date) =>\n\t\t\t\t\tdate.toLocaleTimeString([], {\n\t\t\t\t\t\thour: \"2-digit\",\n\t\t\t\t\t\tminute: \"2-digit\",\n\t\t\t\t\t}),\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children(timestamp)\n\t\t\t\t\t: children || format(timestamp);\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"span\",\n\t\t\t\t{\n\t\t\t\t\tclassName,\n\t\t\t\t\tasChild,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tref,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tchildren: content,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"TimelineItemTimestamp\";\n\treturn Component;\n})();\n"],"mappings":";;;;;;;;;;;AAoCA,MAAa,sBAAsB;CAClC,MAAM,YAAYA,QAAM,YACtB,EAAE,UAAU,WAAW,UAAU,OAAO,KAAM,GAAG,SAAS,QAAQ;EAElE,MAAM,YAAY,KAAK,cAAc;EACrC,MAAM,OAAO,KAAK,cAAc;EAChC,MAA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