@cossistant/react 0.0.28 → 0.0.30
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/README.md +1 -1
- package/_virtual/rolldown_runtime.js +9 -23
- package/hooks/index.d.ts +3 -3
- package/hooks/private/store/use-conversations-store.d.ts +2 -0
- package/hooks/private/store/use-conversations-store.d.ts.map +1 -1
- package/hooks/private/store/use-conversations-store.js +15 -8
- package/hooks/private/store/use-conversations-store.js.map +1 -1
- package/hooks/private/store/use-store-selector.d.ts +3 -0
- package/hooks/private/store/use-store-selector.d.ts.map +1 -1
- package/hooks/private/store/use-store-selector.js +4 -8
- package/hooks/private/store/use-store-selector.js.map +1 -1
- package/hooks/private/store/use-website-store.d.ts +3 -1
- package/hooks/private/store/use-website-store.d.ts.map +1 -1
- package/hooks/private/store/use-website-store.js +14 -6
- package/hooks/private/store/use-website-store.js.map +1 -1
- package/hooks/private/use-client-query.d.ts +1 -1
- package/hooks/private/use-client-query.d.ts.map +1 -1
- package/hooks/private/use-client-query.js +1 -0
- package/hooks/private/use-client-query.js.map +1 -1
- package/hooks/private/use-default-messages.d.ts +1 -1
- package/hooks/private/use-grouped-messages.d.ts +10 -7
- package/hooks/private/use-grouped-messages.d.ts.map +1 -1
- package/hooks/private/use-grouped-messages.js +44 -11
- package/hooks/private/use-grouped-messages.js.map +1 -1
- package/hooks/private/use-rest-client.d.ts +13 -3
- package/hooks/private/use-rest-client.d.ts.map +1 -1
- package/hooks/private/use-rest-client.js +49 -22
- package/hooks/private/use-rest-client.js.map +1 -1
- package/hooks/private/use-visitor-typing-reporter.d.ts +1 -1
- package/hooks/use-conversation-auto-seen.d.ts +1 -1
- package/hooks/use-conversation-page.d.ts +1 -1
- package/hooks/use-conversation-page.d.ts.map +1 -1
- package/hooks/use-conversation-page.js +10 -3
- package/hooks/use-conversation-page.js.map +1 -1
- package/hooks/use-conversation-preview.d.ts +3 -1
- package/hooks/use-conversation-preview.d.ts.map +1 -1
- package/hooks/use-conversation-preview.js +6 -3
- package/hooks/use-conversation-preview.js.map +1 -1
- package/hooks/use-conversation-seen.d.ts +1 -1
- package/hooks/use-conversation-seen.js +1 -1
- package/hooks/use-conversation-seen.js.map +1 -1
- package/hooks/use-conversation-timeline-items.d.ts +1 -1
- package/hooks/use-conversation-timeline-items.js +2 -3
- package/hooks/use-conversation-timeline-items.js.map +1 -1
- package/hooks/use-conversation-timeline.d.ts +1 -1
- package/hooks/use-conversation-timeline.d.ts.map +1 -1
- package/hooks/use-conversation-timeline.js +1 -3
- package/hooks/use-conversation-timeline.js.map +1 -1
- package/hooks/use-conversation.d.ts +1 -1
- package/hooks/use-conversation.js +2 -3
- package/hooks/use-conversation.js.map +1 -1
- package/hooks/use-conversations.d.ts +1 -1
- package/hooks/use-conversations.js +5 -3
- package/hooks/use-conversations.js.map +1 -1
- package/hooks/use-create-conversation.d.ts +3 -3
- package/hooks/use-create-conversation.js +1 -0
- package/hooks/use-create-conversation.js.map +1 -1
- package/hooks/use-file-upload.d.ts +1 -1
- package/hooks/use-file-upload.js +3 -3
- package/hooks/use-file-upload.js.map +1 -1
- package/hooks/use-home-page.js +3 -3
- package/hooks/use-home-page.js.map +1 -1
- package/hooks/use-message-composer.d.ts +10 -3
- package/hooks/use-message-composer.d.ts.map +1 -1
- package/hooks/use-message-composer.js +5 -2
- package/hooks/use-message-composer.js.map +1 -1
- package/hooks/use-realtime-support.d.ts +1 -1
- package/hooks/use-send-message.d.ts +8 -2
- package/hooks/use-send-message.d.ts.map +1 -1
- package/hooks/use-send-message.js +5 -3
- package/hooks/use-send-message.js.map +1 -1
- package/hooks/use-visitor.js +2 -2
- package/hooks/use-visitor.js.map +1 -1
- package/identify-visitor.d.ts.map +1 -1
- package/identify-visitor.js +15 -1
- package/identify-visitor.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +1 -1
- package/package.json +5 -3
- package/{conversation.d.ts → packages/types/src/api/conversation.d.ts} +368 -64
- package/packages/types/src/api/conversation.d.ts.map +1 -0
- package/packages/types/src/api/timeline-item.d.ts +460 -0
- package/packages/types/src/api/timeline-item.d.ts.map +1 -0
- package/packages/types/src/realtime-events.d.ts +1004 -0
- package/packages/types/src/realtime-events.d.ts.map +1 -0
- package/{schemas3.d.ts → packages/types/src/schemas.d.ts} +95 -19
- package/packages/types/src/schemas.d.ts.map +1 -0
- package/primitives/avatar/avatar.js +1 -1
- package/primitives/avatar/avatar.js.map +1 -1
- package/primitives/avatar/fallback.d.ts.map +1 -1
- package/primitives/avatar/fallback.js +2 -2
- package/primitives/avatar/fallback.js.map +1 -1
- package/primitives/avatar/image.d.ts +1 -1
- package/primitives/avatar/image.js +1 -1
- package/primitives/avatar/image.js.map +1 -1
- package/primitives/button.js +1 -1
- package/primitives/button.js.map +1 -1
- package/primitives/conversation-timeline.d.ts +1 -1
- package/primitives/conversation-timeline.js +4 -4
- package/primitives/conversation-timeline.js.map +1 -1
- package/primitives/day-separator.d.ts +76 -0
- package/primitives/day-separator.d.ts.map +1 -0
- package/primitives/day-separator.js +111 -0
- package/primitives/day-separator.js.map +1 -0
- package/primitives/index.d.ts +3 -2
- package/primitives/index.js +6 -1
- package/primitives/index.parts.d.ts +2 -1
- package/primitives/index.parts.js +2 -1
- package/primitives/multimodal-input.d.ts +2 -2
- package/primitives/multimodal-input.d.ts.map +1 -1
- package/primitives/multimodal-input.js +2 -2
- package/primitives/multimodal-input.js.map +1 -1
- package/primitives/timeline-item-attachments.d.ts +1 -1
- package/primitives/timeline-item-attachments.js +6 -7
- package/primitives/timeline-item-attachments.js.map +1 -1
- package/primitives/timeline-item-group.d.ts +1 -1
- package/primitives/timeline-item-group.d.ts.map +1 -1
- package/primitives/timeline-item-group.js +8 -8
- package/primitives/timeline-item-group.js.map +1 -1
- package/primitives/timeline-item.d.ts +1 -1
- package/primitives/timeline-item.d.ts.map +1 -1
- package/primitives/timeline-item.js +33 -8
- package/primitives/timeline-item.js.map +1 -1
- package/primitives/trigger.js +1 -1
- package/primitives/trigger.js.map +1 -1
- package/primitives/window.js +1 -1
- package/primitives/window.js.map +1 -1
- package/provider.d.ts +4 -2
- package/provider.d.ts.map +1 -1
- package/provider.js +56 -8
- package/provider.js.map +1 -1
- package/realtime/event-filter.d.ts +4 -1
- package/realtime/event-filter.d.ts.map +1 -1
- package/realtime/event-filter.js +14 -0
- package/realtime/event-filter.js.map +1 -1
- package/realtime/provider.d.ts +1 -1
- package/realtime/provider.d.ts.map +1 -1
- package/realtime/provider.js +1 -2
- package/realtime/provider.js.map +1 -1
- package/realtime/seen-store.d.ts +2 -2
- package/realtime/support-provider.js +6 -1
- package/realtime/support-provider.js.map +1 -1
- package/realtime/typing-store.d.ts +1 -1
- package/realtime/use-realtime.d.ts +1 -1
- package/support/components/avatar-stack.d.ts.map +1 -1
- package/support/components/avatar-stack.js +32 -12
- package/support/components/avatar-stack.js.map +1 -1
- package/support/components/avatar.d.ts +34 -3
- package/support/components/avatar.d.ts.map +1 -1
- package/support/components/avatar.js +61 -8
- package/support/components/avatar.js.map +1 -1
- package/support/components/button.d.ts +4 -2
- package/support/components/button.d.ts.map +1 -1
- package/support/components/button.js +3 -3
- package/support/components/button.js.map +1 -1
- package/support/components/configuration-error.d.ts +16 -0
- package/support/components/configuration-error.d.ts.map +1 -0
- package/support/components/configuration-error.js +162 -0
- package/support/components/configuration-error.js.map +1 -0
- package/support/components/content.js +1 -2
- package/support/components/content.js.map +1 -1
- package/support/components/conversation-button-link.js +18 -23
- package/support/components/conversation-button-link.js.map +1 -1
- package/support/components/conversation-event.d.ts.map +1 -1
- package/support/components/conversation-event.js +7 -5
- package/support/components/conversation-event.js.map +1 -1
- package/support/components/conversation-timeline.d.ts +6 -1
- package/support/components/conversation-timeline.d.ts.map +1 -1
- package/support/components/conversation-timeline.js +22 -2
- package/support/components/conversation-timeline.js.map +1 -1
- package/support/components/header.js +1 -1
- package/support/components/image-lightbox.d.ts +1 -1
- package/support/components/image-lightbox.js +1 -2
- package/support/components/image-lightbox.js.map +1 -1
- package/support/components/index.js +1 -1
- package/support/components/multimodal-input.js +0 -1
- package/support/components/multimodal-input.js.map +1 -1
- package/support/components/navigation-tab.js +1 -1
- package/support/components/online-indicator.d.ts +50 -0
- package/support/components/online-indicator.d.ts.map +1 -0
- package/support/components/online-indicator.js +65 -0
- package/support/components/online-indicator.js.map +1 -0
- package/support/components/root.js +0 -1
- package/support/components/root.js.map +1 -1
- package/support/components/timeline-identification-tool.js +4 -4
- package/support/components/timeline-identification-tool.js.map +1 -1
- package/support/components/timeline-message-group.d.ts +1 -1
- package/support/components/timeline-message-group.d.ts.map +1 -1
- package/support/components/timeline-message-group.js +6 -4
- package/support/components/timeline-message-group.js.map +1 -1
- package/support/components/timeline-message-item.d.ts +1 -1
- package/support/components/timeline-message-item.js +4 -4
- package/support/components/timeline-message-item.js.map +1 -1
- package/support/components/trigger.js +1 -2
- package/support/components/trigger.js.map +1 -1
- package/support/components/typing-indicator.js +1 -1
- package/support/components/typing-indicator.js.map +1 -1
- package/support/context/controlled-state.js +0 -1
- package/support/context/controlled-state.js.map +1 -1
- package/support/context/events.d.ts +1 -1
- package/support/context/events.js +0 -1
- package/support/context/events.js.map +1 -1
- package/support/context/handle.js +0 -1
- package/support/context/handle.js.map +1 -1
- package/support/context/identification.d.ts +33 -0
- package/support/context/identification.d.ts.map +1 -0
- package/support/context/identification.js +34 -0
- package/support/context/identification.js.map +1 -0
- package/support/context/positioning.js +0 -1
- package/support/context/positioning.js.map +1 -1
- package/support/context/slots.js +0 -1
- package/support/context/slots.js.map +1 -1
- package/support/context/websocket.d.ts +1 -1
- package/support/context/websocket.js +0 -1
- package/support/context/websocket.js.map +1 -1
- package/support/index.d.ts.map +1 -1
- package/support/index.js +51 -18
- package/support/index.js.map +1 -1
- package/support/pages/conversation-history.js +2 -1
- package/support/pages/conversation-history.js.map +1 -1
- package/support/pages/conversation.d.ts +1 -1
- package/support/pages/conversation.js +1 -1
- package/support/pages/conversation.js.map +1 -1
- package/support/pages/home.js +5 -3
- package/support/pages/home.js.map +1 -1
- package/support/router.d.ts.map +1 -1
- package/support/router.js +4 -0
- package/support/router.js.map +1 -1
- package/support/store/support-store.js +0 -1
- package/support/store/support-store.js.map +1 -1
- package/support/{support-C7Xaw-N6.css → support-DmViRaga.css} +2 -2
- package/support/{support-C7Xaw-N6.css.map → support-DmViRaga.css.map} +1 -1
- package/support/text/index.d.ts +1 -1
- package/support/text/index.d.ts.map +1 -1
- package/support/text/index.js +1 -1
- package/support/text/index.js.map +1 -1
- package/support/text/locales/en.js +1 -1
- package/support/text/locales/en.js.map +1 -1
- package/support/text/locales/es.js +1 -1
- package/support/text/locales/es.js.map +1 -1
- package/support/text/locales/fr.js +1 -1
- package/support/text/locales/fr.js.map +1 -1
- package/support/utils/index.d.ts +1 -1
- package/support-config.js +0 -1
- package/support-config.js.map +1 -1
- package/support.css +1 -1
- package/tailwind.css +1 -1
- package/utils/conversation.d.ts.map +1 -1
- package/utils/conversation.js +1 -3
- package/utils/conversation.js.map +1 -1
- package/utils/use-render-element.d.ts.map +1 -1
- package/utils/use-render-element.js +20 -5
- package/utils/use-render-element.js.map +1 -1
- package/api.d.ts +0 -71
- package/api.d.ts.map +0 -1
- package/checks.d.ts +0 -189
- package/checks.d.ts.map +0 -1
- package/clsx.d.ts +0 -7
- package/clsx.d.ts.map +0 -1
- package/coerce.d.ts +0 -9
- package/coerce.d.ts.map +0 -1
- package/conversation.d.ts.map +0 -1
- package/core.d.ts +0 -35
- package/core.d.ts.map +0 -1
- package/errors.d.ts +0 -121
- package/errors.d.ts.map +0 -1
- package/errors2.d.ts +0 -24
- package/errors2.d.ts.map +0 -1
- package/index2.d.ts +0 -4
- package/index3.d.ts +0 -1
- package/metadata.d.ts +0 -1
- package/openapi-generator.d.ts +0 -1
- package/openapi-generator2.d.ts +0 -1
- package/openapi-generator3.d.ts +0 -1
- package/openapi30.d.ts +0 -125
- package/openapi30.d.ts.map +0 -1
- package/openapi31.d.ts +0 -131
- package/openapi31.d.ts.map +0 -1
- package/parse.d.ts +0 -17
- package/parse.d.ts.map +0 -1
- package/realtime-events.d.ts +0 -482
- package/realtime-events.d.ts.map +0 -1
- package/registries.d.ts +0 -32
- package/registries.d.ts.map +0 -1
- package/schemas.d.ts +0 -673
- package/schemas.d.ts.map +0 -1
- package/schemas2.d.ts +0 -320
- package/schemas2.d.ts.map +0 -1
- package/schemas3.d.ts.map +0 -1
- package/specification-extension.d.ts +0 -9
- package/specification-extension.d.ts.map +0 -1
- package/standard-schema.d.ts +0 -59
- package/standard-schema.d.ts.map +0 -1
- package/timeline-item.d.ts +0 -227
- package/timeline-item.d.ts.map +0 -1
- package/util.d.ts +0 -41
- package/util.d.ts.map +0 -1
- package/versions.d.ts +0 -9
- package/versions.d.ts.map +0 -1
- package/zod-extensions.d.ts +0 -39
- package/zod-extensions.d.ts.map +0 -1
package/primitives/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { AvatarFallback } from "./avatar/fallback.js";
|
|
|
5
5
|
import { AvatarImage } from "./avatar/image.js";
|
|
6
6
|
import { Button } from "./button.js";
|
|
7
7
|
import { ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading } from "./conversation-timeline.js";
|
|
8
|
+
import { DaySeparator, DaySeparatorLabel, DaySeparatorLabelProps, DaySeparatorLine, DaySeparatorLineProps, DaySeparatorProps, DaySeparatorRenderProps, defaultFormatDate } from "./day-separator.js";
|
|
8
9
|
import { FileInput, MultimodalInput, SupportInput } from "./multimodal-input.js";
|
|
9
10
|
import { PageDefinition, Router, RouterProps } from "./router.js";
|
|
10
11
|
import { TimelineItem, TimelineItemContent, TimelineItemTimestamp } from "./timeline-item.js";
|
|
@@ -16,8 +17,8 @@ import "./index.parts.js";
|
|
|
16
17
|
|
|
17
18
|
//#region src/primitives/index.d.ts
|
|
18
19
|
declare namespace index_d_exports {
|
|
19
|
-
export { Avatar, AvatarFallback, AvatarImage, Button, SupportConfig as Config, ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading, FileInput, SupportInput as Input, MultimodalInput, PageDefinition, Router, RouterProps, TimelineItem, TimelineItemAttachments, TimelineItemContent, TimelineItemFiles, TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator, TimelineItemImages, TimelineItemTimestamp, SupportTrigger as Trigger, TriggerProps, TriggerRenderProps, TypingIndicator, TypingIndicatorProps, TypingParticipant, TypingParticipantType, SupportWindow as Window, extractFileParts, extractImageParts, hasAttachments };
|
|
20
|
+
export { Avatar, AvatarFallback, AvatarImage, Button, SupportConfig as Config, ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading, DaySeparator, DaySeparatorLabel, DaySeparatorLabelProps, DaySeparatorLine, DaySeparatorLineProps, DaySeparatorProps, DaySeparatorRenderProps, FileInput, SupportInput as Input, MultimodalInput, PageDefinition, Router, RouterProps, TimelineItem, TimelineItemAttachments, TimelineItemContent, TimelineItemFiles, TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator, TimelineItemImages, TimelineItemTimestamp, SupportTrigger as Trigger, TriggerProps, TriggerRenderProps, TypingIndicator, TypingIndicatorProps, TypingParticipant, TypingParticipantType, SupportWindow as Window, defaultFormatDate, extractFileParts, extractImageParts, hasAttachments };
|
|
20
21
|
}
|
|
21
22
|
//#endregion
|
|
22
|
-
export { Avatar, AvatarFallback, AvatarImage, Button, SupportConfig as Config, ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading, FileInput, SupportInput as Input, MultimodalInput, PageDefinition, Router, RouterProps, TimelineItem, TimelineItemAttachments, TimelineItemContent, TimelineItemFiles, TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator, TimelineItemImages, TimelineItemTimestamp, SupportTrigger as Trigger, TriggerProps, TriggerRenderProps, TypingIndicator, TypingIndicatorProps, TypingParticipant, TypingParticipantType, SupportWindow as Window, extractFileParts, extractImageParts, hasAttachments, index_d_exports };
|
|
23
|
+
export { Avatar, AvatarFallback, AvatarImage, Button, SupportConfig as Config, ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading, DaySeparator, DaySeparatorLabel, DaySeparatorLabelProps, DaySeparatorLine, DaySeparatorLineProps, DaySeparatorProps, DaySeparatorRenderProps, FileInput, SupportInput as Input, MultimodalInput, PageDefinition, Router, RouterProps, TimelineItem, TimelineItemAttachments, TimelineItemContent, TimelineItemFiles, TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator, TimelineItemImages, TimelineItemTimestamp, SupportTrigger as Trigger, TriggerProps, TriggerRenderProps, TypingIndicator, TypingIndicatorProps, TypingParticipant, TypingParticipantType, SupportWindow as Window, defaultFormatDate, extractFileParts, extractImageParts, hasAttachments, index_d_exports };
|
|
23
24
|
//# sourceMappingURL=index.d.ts.map
|
package/primitives/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { TypingIndicator } from "../support/components/typing-indicator.js";
|
|
|
6
6
|
import { SupportConfig } from "../support-config.js";
|
|
7
7
|
import { Button } from "./button.js";
|
|
8
8
|
import { ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading } from "./conversation-timeline.js";
|
|
9
|
+
import { DaySeparator, DaySeparatorLabel, DaySeparatorLine, defaultFormatDate } from "./day-separator.js";
|
|
9
10
|
import { FileInput, MultimodalInput, SupportInput } from "./multimodal-input.js";
|
|
10
11
|
import { Router } from "./router.js";
|
|
11
12
|
import { TimelineItem, TimelineItemContent, TimelineItemTimestamp } from "./timeline-item.js";
|
|
@@ -25,6 +26,9 @@ var primitives_exports = /* @__PURE__ */ __export({
|
|
|
25
26
|
ConversationTimelineContainer: () => ConversationTimelineContainer,
|
|
26
27
|
ConversationTimelineEmpty: () => ConversationTimelineEmpty,
|
|
27
28
|
ConversationTimelineLoading: () => ConversationTimelineLoading,
|
|
29
|
+
DaySeparator: () => DaySeparator,
|
|
30
|
+
DaySeparatorLabel: () => DaySeparatorLabel,
|
|
31
|
+
DaySeparatorLine: () => DaySeparatorLine,
|
|
28
32
|
FileInput: () => FileInput,
|
|
29
33
|
Input: () => SupportInput,
|
|
30
34
|
MultimodalInput: () => MultimodalInput,
|
|
@@ -44,11 +48,12 @@ var primitives_exports = /* @__PURE__ */ __export({
|
|
|
44
48
|
Trigger: () => SupportTrigger,
|
|
45
49
|
TypingIndicator: () => TypingIndicator,
|
|
46
50
|
Window: () => SupportWindow,
|
|
51
|
+
defaultFormatDate: () => defaultFormatDate,
|
|
47
52
|
extractFileParts: () => extractFileParts,
|
|
48
53
|
extractImageParts: () => extractImageParts,
|
|
49
54
|
hasAttachments: () => hasAttachments
|
|
50
55
|
});
|
|
51
56
|
|
|
52
57
|
//#endregion
|
|
53
|
-
export { Avatar, AvatarFallback, AvatarImage, Button, SupportConfig as Config, ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading, FileInput, SupportInput as Input, MultimodalInput, Router, TimelineItem, TimelineItemAttachments, TimelineItemContent, TimelineItemFiles, TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator, TimelineItemImages, TimelineItemTimestamp, SupportTrigger as Trigger, TypingIndicator, SupportWindow as Window, extractFileParts, extractImageParts, hasAttachments, primitives_exports };
|
|
58
|
+
export { Avatar, AvatarFallback, AvatarImage, Button, SupportConfig as Config, ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading, DaySeparator, DaySeparatorLabel, DaySeparatorLine, FileInput, SupportInput as Input, MultimodalInput, Router, TimelineItem, TimelineItemAttachments, TimelineItemContent, TimelineItemFiles, TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator, TimelineItemImages, TimelineItemTimestamp, SupportTrigger as Trigger, TypingIndicator, SupportWindow as Window, defaultFormatDate, extractFileParts, extractImageParts, hasAttachments, primitives_exports };
|
|
54
59
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,6 +6,7 @@ import { AvatarImage } from "./avatar/image.js";
|
|
|
6
6
|
import "./avatar/index.js";
|
|
7
7
|
import { Button } from "./button.js";
|
|
8
8
|
import { ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading } from "./conversation-timeline.js";
|
|
9
|
+
import { DaySeparator, DaySeparatorLabel, DaySeparatorLabelProps, DaySeparatorLine, DaySeparatorLineProps, DaySeparatorProps, DaySeparatorRenderProps, defaultFormatDate } from "./day-separator.js";
|
|
9
10
|
import { FileInput, MultimodalInput, SupportInput } from "./multimodal-input.js";
|
|
10
11
|
import { PageDefinition, Router, RouterProps } from "./router.js";
|
|
11
12
|
import { TimelineItem, TimelineItemContent, TimelineItemTimestamp } from "./timeline-item.js";
|
|
@@ -13,4 +14,4 @@ import { TimelineItemAttachments, TimelineItemFiles, TimelineItemImages, extract
|
|
|
13
14
|
import { TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator } from "./timeline-item-group.js";
|
|
14
15
|
import { SupportTrigger, TriggerProps, TriggerRenderProps } from "./trigger.js";
|
|
15
16
|
import { SupportWindow } from "./window.js";
|
|
16
|
-
export { Avatar, AvatarFallback, AvatarImage, Button, SupportConfig as Config, ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading, FileInput, SupportInput as Input, MultimodalInput, type PageDefinition, Router, type RouterProps, TimelineItem, TimelineItemAttachments, TimelineItemContent, TimelineItemFiles, TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator, TimelineItemImages, TimelineItemTimestamp, SupportTrigger as Trigger, type TriggerProps, type TriggerRenderProps, TypingIndicator, type TypingIndicatorProps, type TypingParticipant, type TypingParticipantType, SupportWindow as Window, extractFileParts, extractImageParts, hasAttachments };
|
|
17
|
+
export { Avatar, AvatarFallback, AvatarImage, Button, SupportConfig as Config, ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading, DaySeparator, DaySeparatorLabel, type DaySeparatorLabelProps, DaySeparatorLine, type DaySeparatorLineProps, type DaySeparatorProps, type DaySeparatorRenderProps, FileInput, SupportInput as Input, MultimodalInput, type PageDefinition, Router, type RouterProps, TimelineItem, TimelineItemAttachments, TimelineItemContent, TimelineItemFiles, TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator, TimelineItemImages, TimelineItemTimestamp, SupportTrigger as Trigger, type TriggerProps, type TriggerRenderProps, TypingIndicator, type TypingIndicatorProps, type TypingParticipant, type TypingParticipantType, SupportWindow as Window, defaultFormatDate, extractFileParts, extractImageParts, hasAttachments };
|
|
@@ -5,6 +5,7 @@ import { TypingIndicator } from "../support/components/typing-indicator.js";
|
|
|
5
5
|
import { SupportConfig } from "../support-config.js";
|
|
6
6
|
import { Button } from "./button.js";
|
|
7
7
|
import { ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading } from "./conversation-timeline.js";
|
|
8
|
+
import { DaySeparator, DaySeparatorLabel, DaySeparatorLine, defaultFormatDate } from "./day-separator.js";
|
|
8
9
|
import { FileInput, MultimodalInput, SupportInput } from "./multimodal-input.js";
|
|
9
10
|
import { Router } from "./router.js";
|
|
10
11
|
import { TimelineItem, TimelineItemContent, TimelineItemTimestamp } from "./timeline-item.js";
|
|
@@ -13,4 +14,4 @@ import { TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, T
|
|
|
13
14
|
import { SupportTrigger } from "./trigger.js";
|
|
14
15
|
import { SupportWindow } from "./window.js";
|
|
15
16
|
|
|
16
|
-
export { Avatar, AvatarFallback, AvatarImage, Button, SupportConfig as Config, ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading, FileInput, SupportInput as Input, MultimodalInput, Router, TimelineItem, TimelineItemAttachments, TimelineItemContent, TimelineItemFiles, TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator, TimelineItemImages, TimelineItemTimestamp, SupportTrigger as Trigger, TypingIndicator, SupportWindow as Window, extractFileParts, extractImageParts, hasAttachments };
|
|
17
|
+
export { Avatar, AvatarFallback, AvatarImage, Button, SupportConfig as Config, ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading, DaySeparator, DaySeparatorLabel, DaySeparatorLine, FileInput, SupportInput as Input, MultimodalInput, Router, TimelineItem, TimelineItemAttachments, TimelineItemContent, TimelineItemFiles, TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator, TimelineItemImages, TimelineItemTimestamp, SupportTrigger as Trigger, TypingIndicator, SupportWindow as Window, defaultFormatDate, extractFileParts, extractImageParts, hasAttachments };
|
|
@@ -16,7 +16,7 @@ type MultimodalInputProps = Omit<React$1.TextareaHTMLAttributes<HTMLTextAreaElem
|
|
|
16
16
|
* clipboard uploads and auto-resizing while remaining composable via
|
|
17
17
|
* `asChild`.
|
|
18
18
|
*/
|
|
19
|
-
declare const MultimodalInput: React$1.ForwardRefExoticComponent<Omit<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, "
|
|
19
|
+
declare const MultimodalInput: React$1.ForwardRefExoticComponent<Omit<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "onChange"> & {
|
|
20
20
|
value: string;
|
|
21
21
|
onChange: (value: string) => void;
|
|
22
22
|
onSubmit?: () => void;
|
|
@@ -38,7 +38,7 @@ declare const FileInput: React$1.ForwardRefExoticComponent<React$1.InputHTMLAttr
|
|
|
38
38
|
onFileSelect?: (files: File[]) => void;
|
|
39
39
|
asChild?: boolean;
|
|
40
40
|
} & React$1.RefAttributes<HTMLInputElement>>;
|
|
41
|
-
declare const SupportInput: React$1.ForwardRefExoticComponent<Omit<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, "
|
|
41
|
+
declare const SupportInput: React$1.ForwardRefExoticComponent<Omit<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, "value" | "onChange"> & {
|
|
42
42
|
value: string;
|
|
43
43
|
onChange: (value: string) => void;
|
|
44
44
|
onSubmit?: () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multimodal-input.d.ts","names":[],"sources":["../../src/primitives/multimodal-input.tsx"],"sourcesContent":[],"mappings":";;;KAGY,oBAAA,GAAuB,KAClC,OAAA,CAAM,uBAAuB;;EADlB,QAAA,EAAA,CAAA,KAAA,EAAA,MAAoB,EAAA,GAAA,IAAA;EACF,QAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EAA7B,YAAM,CAAA,EAAA,CAAA,KAAA,EAMiB,IANjB,EAAA,EAAA,GAAA,IAAA;EAD4B,OAAA,CAAA,EAAA,OAAA;EAOX,SAAA,CAAA,EAAA,MAAA;EAGf,KAAA,CAAA,EAAA,KAAA,GAAA,IAAA;EAAK,QAAA,CAAA,EAAA,OAAA;AASd,CAAA;;;;;;cAAa,iBAAe,OAAA,CAAA,0BAAA,KAAA,OAAA,CAAA,uBAAA;;EAAA,QAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EAAA,QAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EA4GhB,Y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
|
9
9
|
*/
|
|
10
10
|
const MultimodalInput = (() => {
|
|
11
|
-
const Component = React$1.forwardRef(({ value, onChange, onSubmit, onFileSelect, className, asChild = false, error, disabled
|
|
11
|
+
const Component = React$1.forwardRef(({ value, onChange, onSubmit, onFileSelect, className, asChild = false, error, disabled, ...props }, ref) => {
|
|
12
12
|
const innerRef = React$1.useRef(null);
|
|
13
13
|
React$1.useImperativeHandle(ref, () => innerRef.current);
|
|
14
14
|
const handleChange = (e) => {
|
|
@@ -74,7 +74,7 @@ const MultimodalInput = (() => {
|
|
|
74
74
|
* chat UIs want an explicit attachment button.
|
|
75
75
|
*/
|
|
76
76
|
const FileInput = (() => {
|
|
77
|
-
const Component = React$1.forwardRef(({ onFileSelect, asChild = false, className
|
|
77
|
+
const Component = React$1.forwardRef(({ onFileSelect, asChild = false, className, ...props }, ref) => {
|
|
78
78
|
const handleChange = (e) => {
|
|
79
79
|
const files = Array.from(e.target.files || []);
|
|
80
80
|
if (files.length > 0 && onFileSelect) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multimodal-input.js","names":["React","files: File[]"],"sources":["../../src/primitives/multimodal-input.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\nexport type MultimodalInputProps = Omit<\n\tReact.TextareaHTMLAttributes<HTMLTextAreaElement>,\n\t\"value\" | \"onChange\"\n> & {\n\tvalue: string;\n\tonChange: (value: string) => void;\n\tonSubmit?: () => void;\n\tonFileSelect?: (files: File[]) => void;\n\tasChild?: boolean;\n\tclassName?: string;\n\terror?: Error | null;\n\tdisabled?: boolean;\n};\n\n/**\n * Textarea tailored for support conversations. Handles keyboard submit,\n * clipboard uploads and auto-resizing while remaining composable via\n * `asChild`.\n */\nexport const MultimodalInput = (() => {\n\tconst Component = React.forwardRef<HTMLTextAreaElement, MultimodalInputProps>(\n\t\t(\n\t\t\t{\n\t\t\t\tvalue,\n\t\t\t\tonChange,\n\t\t\t\tonSubmit,\n\t\t\t\tonFileSelect,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\terror,\n\t\t\t\tdisabled,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst innerRef = React.useRef<HTMLTextAreaElement | null>(null);\n\n\t\t\tReact.useImperativeHandle(\n\t\t\t\tref,\n\t\t\t\t() => innerRef.current as HTMLTextAreaElement\n\t\t\t);\n\n\t\t\tconst handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n\t\t\t\tonChange(e.target.value);\n\t\t\t};\n\n\t\t\tconst handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n\t\t\t\tif (e.key === \"Enter\" && !e.shiftKey) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tonSubmit?.();\n\t\t\t\t}\n\t\t\t\tprops.onKeyDown?.(e);\n\t\t\t};\n\n\t\t\t// Handle paste events for images\n\t\t\tconst handlePaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n\t\t\t\tconst items = Array.from(e.clipboardData.items);\n\t\t\t\tconst files: File[] = [];\n\n\t\t\t\tfor (const item of items) {\n\t\t\t\t\tif (item.kind === \"file\") {\n\t\t\t\t\t\tconst file = item.getAsFile();\n\t\t\t\t\t\tif (file) {\n\t\t\t\t\t\t\tfiles.push(file);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (files.length > 0 && onFileSelect) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tonFileSelect(files);\n\t\t\t\t}\n\n\t\t\t\tprops.onPaste?.(e);\n\t\t\t};\n\n\t\t\t// Auto-resize\n\t\t\tReact.useLayoutEffect(() => {\n\t\t\t\tconst el = innerRef.current;\n\t\t\t\tif (!el) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Reset height to auto to get the correct scrollHeight\n\t\t\t\tel.style.height = \"auto\";\n\t\t\t\t// Ensure overflow is visible during measurement\n\t\t\t\tconst originalOverflow = el.style.overflow;\n\t\t\t\tel.style.overflow = \"hidden\";\n\t\t\t\t// Set the new height\n\t\t\t\tel.style.height = `${el.scrollHeight}px`;\n\t\t\t\t// Restore original overflow\n\t\t\t\tel.style.overflow = originalOverflow;\n\t\t\t}, [value]);\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"textarea\",\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: innerRef,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\trows: 1,\n\t\t\t\t\t\tonChange: handleChange,\n\t\t\t\t\t\tonKeyDown: handleKeyDown,\n\t\t\t\t\t\tonPaste: handlePaste,\n\t\t\t\t\t\tdisabled,\n\t\t\t\t\t\t\"aria-invalid\": error ? \"true\" : undefined,\n\t\t\t\t\t\t\"aria-describedby\": error ? \"multimodal-input-error\" : undefined,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...props.style,\n\t\t\t\t\t\t\tminHeight: \"1.5rem\",\n\t\t\t\t\t\t\toverflow: \"hidden\",\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 = \"MultimodalInput\";\n\treturn Component;\n})();\n\n// File input component for multimodal input\nexport type FileInputProps = React.InputHTMLAttributes<HTMLInputElement> & {\n\tonFileSelect?: (files: File[]) => void;\n\tasChild?: boolean;\n};\n\n/**\n * Hidden file selector that feeds uploads back into the multimodal input when\n * chat UIs want an explicit attachment button.\n */\nexport const FileInput = (() => {\n\tconst Component = React.forwardRef<HTMLInputElement, FileInputProps>(\n\t\t({ onFileSelect, asChild = false, className, ...props }, ref) => {\n\t\t\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\t\tconst files = Array.from(e.target.files || []);\n\t\t\t\tif (files.length > 0 && onFileSelect) {\n\t\t\t\t\tonFileSelect(files);\n\t\t\t\t\t// Reset input to allow selecting the same file again\n\t\t\t\t\te.target.value = \"\";\n\t\t\t\t}\n\t\t\t\tprops.onChange?.(e);\n\t\t\t};\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"input\",\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\ttype: \"file\",\n\t\t\t\t\t\tmultiple: true,\n\t\t\t\t\t\tonChange: handleChange,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"FileInput\";\n\treturn Component;\n})();\n\n// Export the old name for backward compatibility\nexport const SupportInput = MultimodalInput;\n"],"mappings":";;;;;;;;;AAsBA,MAAa,yBAAyB;CACrC,MAAM,YAAYA,QAAM,YAEtB,EACC,OACA,UACA,UACA,cACA,WACA,UAAU,OACV,OACA,
|
|
1
|
+
{"version":3,"file":"multimodal-input.js","names":["React","files: File[]"],"sources":["../../src/primitives/multimodal-input.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\nexport type MultimodalInputProps = Omit<\n\tReact.TextareaHTMLAttributes<HTMLTextAreaElement>,\n\t\"value\" | \"onChange\"\n> & {\n\tvalue: string;\n\tonChange: (value: string) => void;\n\tonSubmit?: () => void;\n\tonFileSelect?: (files: File[]) => void;\n\tasChild?: boolean;\n\tclassName?: string;\n\terror?: Error | null;\n\tdisabled?: boolean;\n};\n\n/**\n * Textarea tailored for support conversations. Handles keyboard submit,\n * clipboard uploads and auto-resizing while remaining composable via\n * `asChild`.\n */\nexport const MultimodalInput = (() => {\n\tconst Component = React.forwardRef<HTMLTextAreaElement, MultimodalInputProps>(\n\t\t(\n\t\t\t{\n\t\t\t\tvalue,\n\t\t\t\tonChange,\n\t\t\t\tonSubmit,\n\t\t\t\tonFileSelect,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\terror,\n\t\t\t\tdisabled,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst innerRef = React.useRef<HTMLTextAreaElement | null>(null);\n\n\t\t\tReact.useImperativeHandle(\n\t\t\t\tref,\n\t\t\t\t() => innerRef.current as HTMLTextAreaElement\n\t\t\t);\n\n\t\t\tconst handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n\t\t\t\tonChange(e.target.value);\n\t\t\t};\n\n\t\t\tconst handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\n\t\t\t\tif (e.key === \"Enter\" && !e.shiftKey) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tonSubmit?.();\n\t\t\t\t}\n\t\t\t\tprops.onKeyDown?.(e);\n\t\t\t};\n\n\t\t\t// Handle paste events for images\n\t\t\tconst handlePaste = (e: React.ClipboardEvent<HTMLTextAreaElement>) => {\n\t\t\t\tconst items = Array.from(e.clipboardData.items);\n\t\t\t\tconst files: File[] = [];\n\n\t\t\t\tfor (const item of items) {\n\t\t\t\t\tif (item.kind === \"file\") {\n\t\t\t\t\t\tconst file = item.getAsFile();\n\t\t\t\t\t\tif (file) {\n\t\t\t\t\t\t\tfiles.push(file);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (files.length > 0 && onFileSelect) {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tonFileSelect(files);\n\t\t\t\t}\n\n\t\t\t\tprops.onPaste?.(e);\n\t\t\t};\n\n\t\t\t// Auto-resize\n\t\t\tReact.useLayoutEffect(() => {\n\t\t\t\tconst el = innerRef.current;\n\t\t\t\tif (!el) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Reset height to auto to get the correct scrollHeight\n\t\t\t\tel.style.height = \"auto\";\n\t\t\t\t// Ensure overflow is visible during measurement\n\t\t\t\tconst originalOverflow = el.style.overflow;\n\t\t\t\tel.style.overflow = \"hidden\";\n\t\t\t\t// Set the new height\n\t\t\t\tel.style.height = `${el.scrollHeight}px`;\n\t\t\t\t// Restore original overflow\n\t\t\t\tel.style.overflow = originalOverflow;\n\t\t\t}, [value]);\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"textarea\",\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: innerRef,\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t...props,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\trows: 1,\n\t\t\t\t\t\tonChange: handleChange,\n\t\t\t\t\t\tonKeyDown: handleKeyDown,\n\t\t\t\t\t\tonPaste: handlePaste,\n\t\t\t\t\t\tdisabled,\n\t\t\t\t\t\t\"aria-invalid\": error ? \"true\" : undefined,\n\t\t\t\t\t\t\"aria-describedby\": error ? \"multimodal-input-error\" : undefined,\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\t...props.style,\n\t\t\t\t\t\t\tminHeight: \"1.5rem\",\n\t\t\t\t\t\t\toverflow: \"hidden\",\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 = \"MultimodalInput\";\n\treturn Component;\n})();\n\n// File input component for multimodal input\nexport type FileInputProps = React.InputHTMLAttributes<HTMLInputElement> & {\n\tonFileSelect?: (files: File[]) => void;\n\tasChild?: boolean;\n};\n\n/**\n * Hidden file selector that feeds uploads back into the multimodal input when\n * chat UIs want an explicit attachment button.\n */\nexport const FileInput = (() => {\n\tconst Component = React.forwardRef<HTMLInputElement, FileInputProps>(\n\t\t({ onFileSelect, asChild = false, className, ...props }, ref) => {\n\t\t\tconst handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n\t\t\t\tconst files = Array.from(e.target.files || []);\n\t\t\t\tif (files.length > 0 && onFileSelect) {\n\t\t\t\t\tonFileSelect(files);\n\t\t\t\t\t// Reset input to allow selecting the same file again\n\t\t\t\t\te.target.value = \"\";\n\t\t\t\t}\n\t\t\t\tprops.onChange?.(e);\n\t\t\t};\n\n\t\t\treturn useRenderElement(\n\t\t\t\t\"input\",\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\ttype: \"file\",\n\t\t\t\t\t\tmultiple: true,\n\t\t\t\t\t\tonChange: handleChange,\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t);\n\n\tComponent.displayName = \"FileInput\";\n\treturn Component;\n})();\n\n// Export the old name for backward compatibility\nexport const SupportInput = MultimodalInput;\n"],"mappings":";;;;;;;;;AAsBA,MAAa,yBAAyB;CACrC,MAAM,YAAYA,QAAM,YAEtB,EACC,OACA,UACA,UACA,cACA,WACA,UAAU,OACV,OACA,UACA,GAAG,SAEJ,QACI;EACJ,MAAM,WAAWA,QAAM,OAAmC,KAAK;AAE/D,UAAM,oBACL,WACM,SAAS,QACf;EAED,MAAM,gBAAgB,MAA8C;AACnE,YAAS,EAAE,OAAO,MAAM;;EAGzB,MAAM,iBAAiB,MAAgD;AACtE,OAAI,EAAE,QAAQ,WAAW,CAAC,EAAE,UAAU;AACrC,MAAE,gBAAgB;AAClB,gBAAY;;AAEb,SAAM,YAAY,EAAE;;EAIrB,MAAM,eAAe,MAAiD;GACrE,MAAM,QAAQ,MAAM,KAAK,EAAE,cAAc,MAAM;GAC/C,MAAMC,QAAgB,EAAE;AAExB,QAAK,MAAM,QAAQ,MAClB,KAAI,KAAK,SAAS,QAAQ;IACzB,MAAM,OAAO,KAAK,WAAW;AAC7B,QAAI,KACH,OAAM,KAAK,KAAK;;AAKnB,OAAI,MAAM,SAAS,KAAK,cAAc;AACrC,MAAE,gBAAgB;AAClB,iBAAa,MAAM;;AAGpB,SAAM,UAAU,EAAE;;AAInB,UAAM,sBAAsB;GAC3B,MAAM,KAAK,SAAS;AACpB,OAAI,CAAC,GACJ;AAGD,MAAG,MAAM,SAAS;GAElB,MAAM,mBAAmB,GAAG,MAAM;AAClC,MAAG,MAAM,WAAW;AAEpB,MAAG,MAAM,SAAS,GAAG,GAAG,aAAa;AAErC,MAAG,MAAM,WAAW;KAClB,CAAC,MAAM,CAAC;AAEX,SAAO,iBACN,YACA;GACC;GACA;GACA,EACD;GACC,KAAK;GACL,OAAO;IACN,GAAG;IACH;IACA,MAAM;IACN,UAAU;IACV,WAAW;IACX,SAAS;IACT;IACA,gBAAgB,QAAQ,SAAS;IACjC,oBAAoB,QAAQ,2BAA2B;IACvD,OAAO;KACN,GAAG,MAAM;KACT,WAAW;KACX,UAAU;KACV;IACD;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ;;;;;AAYJ,MAAa,mBAAmB;CAC/B,MAAM,YAAYD,QAAM,YACtB,EAAE,cAAc,UAAU,OAAO,WAAW,GAAG,SAAS,QAAQ;EAChE,MAAM,gBAAgB,MAA2C;GAChE,MAAM,QAAQ,MAAM,KAAK,EAAE,OAAO,SAAS,EAAE,CAAC;AAC9C,OAAI,MAAM,SAAS,KAAK,cAAc;AACrC,iBAAa,MAAM;AAEnB,MAAE,OAAO,QAAQ;;AAElB,SAAM,WAAW,EAAE;;AAGpB,SAAO,iBACN,SACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;IACN,GAAG;IACH,MAAM;IACN,UAAU;IACV,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ;AAGJ,MAAa,eAAe"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TimelineItemParts, TimelinePartFile, TimelinePartImage } from "../timeline-item.js";
|
|
1
|
+
import { TimelineItemParts, TimelinePartFile, TimelinePartImage } from "../packages/types/src/api/timeline-item.js";
|
|
2
2
|
import * as React$1 from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/primitives/timeline-item-attachments.d.ts
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
import { useRenderElement } from "../utils/use-render-element.js";
|
|
5
4
|
import * as React$1 from "react";
|
|
6
5
|
import { formatFileSize } from "@cossistant/core";
|
|
@@ -30,7 +29,7 @@ function hasAttachments(parts) {
|
|
|
30
29
|
* Supports custom rendering via children render prop.
|
|
31
30
|
*/
|
|
32
31
|
const TimelineItemImages = (() => {
|
|
33
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false, images, onImageClick
|
|
32
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, images, onImageClick, ...props }, ref) => {
|
|
34
33
|
if (images.length === 0) return null;
|
|
35
34
|
const content = typeof children === "function" ? children(images, onImageClick) : children || /* @__PURE__ */ jsx("div", {
|
|
36
35
|
className: "flex flex-wrap gap-2",
|
|
@@ -39,7 +38,7 @@ const TimelineItemImages = (() => {
|
|
|
39
38
|
onClick: () => onImageClick?.(index),
|
|
40
39
|
type: "button",
|
|
41
40
|
children: /* @__PURE__ */ jsx("img", {
|
|
42
|
-
alt: image.
|
|
41
|
+
alt: image.filename || `Image ${index + 1}`,
|
|
43
42
|
className: "max-h-[200px] max-w-[300px] cursor-pointer rounded-lg object-cover transition-transform group-hover:scale-105",
|
|
44
43
|
loading: "lazy",
|
|
45
44
|
src: image.url
|
|
@@ -74,13 +73,13 @@ function getFileIcon(mediaType) {
|
|
|
74
73
|
* Supports custom rendering via children render prop.
|
|
75
74
|
*/
|
|
76
75
|
const TimelineItemFiles = (() => {
|
|
77
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false, files
|
|
76
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, files, ...props }, ref) => {
|
|
78
77
|
if (files.length === 0) return null;
|
|
79
78
|
const content = typeof children === "function" ? children(files) : children || /* @__PURE__ */ jsx("div", {
|
|
80
79
|
className: "flex flex-col gap-2",
|
|
81
80
|
children: files.map((file) => /* @__PURE__ */ jsxs("a", {
|
|
82
81
|
className: "flex items-center gap-2 rounded-lg bg-co-muted/50 px-3 py-2 text-sm transition-colors hover:bg-co-muted",
|
|
83
|
-
download: file.
|
|
82
|
+
download: file.filename,
|
|
84
83
|
href: file.url,
|
|
85
84
|
rel: "noopener noreferrer",
|
|
86
85
|
target: "_blank",
|
|
@@ -91,7 +90,7 @@ const TimelineItemFiles = (() => {
|
|
|
91
90
|
}),
|
|
92
91
|
/* @__PURE__ */ jsx("span", {
|
|
93
92
|
className: "flex-1 truncate font-medium",
|
|
94
|
-
children: file.
|
|
93
|
+
children: file.filename || "Download file"
|
|
95
94
|
}),
|
|
96
95
|
file.size && /* @__PURE__ */ jsx("span", {
|
|
97
96
|
className: "text-co-muted-foreground text-xs",
|
|
@@ -119,7 +118,7 @@ const TimelineItemFiles = (() => {
|
|
|
119
118
|
* Extracts the appropriate parts and renders them in a single container.
|
|
120
119
|
*/
|
|
121
120
|
const TimelineItemAttachments = (() => {
|
|
122
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false, parts, onImageClick, imagesClassName, filesClassName
|
|
121
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, parts, onImageClick, imagesClassName, filesClassName, ...props }, ref) => {
|
|
123
122
|
const images = extractImageParts(parts);
|
|
124
123
|
const files = extractFileParts(parts);
|
|
125
124
|
if (images.length === 0 && files.length === 0) return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-item-attachments.js","names":["React"],"sources":["../../src/primitives/timeline-item-attachments.tsx"],"sourcesContent":["\"use client\";\n\nimport { formatFileSize } from \"@cossistant/core\";\nimport type {\n\tTimelineItemParts,\n\tTimelinePartFile,\n\tTimelinePartImage,\n} from \"@cossistant/types/api/timeline-item\";\nimport * as React from \"react\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\n/**\n * Extract image parts from timeline item parts array.\n */\nexport function extractImageParts(\n\tparts: TimelineItemParts\n): TimelinePartImage[] {\n\treturn parts.filter(\n\t\t(part): part is TimelinePartImage => part.type === \"image\"\n\t);\n}\n\n/**\n * Extract file parts from timeline item parts array.\n */\nexport function extractFileParts(parts: TimelineItemParts): TimelinePartFile[] {\n\treturn parts.filter((part): part is TimelinePartFile => part.type === \"file\");\n}\n\n/**\n * Check if timeline item has any attachments (images or files).\n */\nexport function hasAttachments(parts: TimelineItemParts): boolean {\n\treturn parts.some((part) => part.type === \"image\" || part.type === \"file\");\n}\n\n// ============================================================================\n// TimelineItemImages\n// ============================================================================\n\nexport type TimelineItemImagesProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((\n\t\t\t\timages: TimelinePartImage[],\n\t\t\t\tonImageClick?: (index: number) => void\n\t\t ) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\timages: TimelinePartImage[];\n\t/**\n\t * Callback when an image is clicked (for lightbox).\n\t */\n\tonImageClick?: (index: number) => void;\n};\n\n/**\n * Renders a grid of image thumbnails from timeline item parts.\n * Supports custom rendering via children render prop.\n */\nexport const TimelineItemImages = (() => {\n\tconst Component = React.forwardRef<HTMLDivElement, TimelineItemImagesProps>(\n\t\t(\n\t\t\t{ children, className, asChild = false, images, onImageClick, ...props },\n\t\t\tref\n\t\t) => {\n\t\t\tif (images.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children(images, onImageClick)\n\t\t\t\t\t: children || (\n\t\t\t\t\t\t\t<div className=\"flex flex-wrap gap-2\">\n\t\t\t\t\t\t\t\t{images.map((image, index) => (\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\tclassName=\"group relative overflow-hidden rounded-lg focus:outline-none focus:ring-2 focus:ring-offset-2\"\n\t\t\t\t\t\t\t\t\t\tkey={image.url}\n\t\t\t\t\t\t\t\t\t\tonClick={() => onImageClick?.(index)}\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{/* biome-ignore lint/performance/noImgElement: React package, not Next.js specific */}\n\t\t\t\t\t\t\t\t\t\t{/* biome-ignore lint/nursery/useImageSize: Dynamic image dimensions not known at render time */}\n\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\talt={image.fileName || `Image ${index + 1}`}\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"max-h-[200px] max-w-[300px] cursor-pointer rounded-lg object-cover transition-transform group-hover:scale-105\"\n\t\t\t\t\t\t\t\t\t\t\tloading=\"lazy\"\n\t\t\t\t\t\t\t\t\t\t\tsrc={image.url}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\n\t\t\t// biome-ignore lint/correctness/useHookAtTopLevel: useRenderElement is a utility function, not a hook\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 = \"TimelineItemImages\";\n\treturn Component;\n})();\n\n// ============================================================================\n// TimelineItemFiles\n// ============================================================================\n\nexport type TimelineItemFilesProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode | ((files: TimelinePartFile[]) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\tfiles: TimelinePartFile[];\n};\n\n/**\n * Get file icon based on MIME type.\n */\nfunction getFileIcon(mediaType: string): string {\n\tif (mediaType === \"application/pdf\") {\n\t\treturn \"📄\";\n\t}\n\tif (mediaType === \"application/zip\") {\n\t\treturn \"🗜️\";\n\t}\n\tif (mediaType.startsWith(\"text/\")) {\n\t\treturn \"📝\";\n\t}\n\treturn \"📎\";\n}\n\n/**\n * Renders a list of file attachments from timeline item parts.\n * Supports custom rendering via children render prop.\n */\nexport const TimelineItemFiles = (() => {\n\tconst Component = React.forwardRef<HTMLDivElement, TimelineItemFilesProps>(\n\t\t({ children, className, asChild = false, files, ...props }, ref) => {\n\t\t\tif (files.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children(files)\n\t\t\t\t\t: children || (\n\t\t\t\t\t\t\t<div className=\"flex flex-col gap-2\">\n\t\t\t\t\t\t\t\t{files.map((file) => (\n\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\tclassName=\"flex items-center gap-2 rounded-lg bg-co-muted/50 px-3 py-2 text-sm transition-colors hover:bg-co-muted\"\n\t\t\t\t\t\t\t\t\t\tdownload={file.fileName}\n\t\t\t\t\t\t\t\t\t\thref={file.url}\n\t\t\t\t\t\t\t\t\t\tkey={file.url}\n\t\t\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span className=\"text-lg\">\n\t\t\t\t\t\t\t\t\t\t\t{getFileIcon(file.mediaType)}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t<span className=\"flex-1 truncate font-medium\">\n\t\t\t\t\t\t\t\t\t\t\t{file.fileName || \"Download file\"}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t{file.size && (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"text-co-muted-foreground text-xs\">\n\t\t\t\t\t\t\t\t\t\t\t\t{formatFileSize(file.size)}\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\n\t\t\t// biome-ignore lint/correctness/useHookAtTopLevel: useRenderElement is a utility function, not a hook\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 = \"TimelineItemFiles\";\n\treturn Component;\n})();\n\n// ============================================================================\n// TimelineItemAttachments (convenience wrapper)\n// ============================================================================\n\nexport type TimelineItemAttachmentsProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode;\n\tasChild?: boolean;\n\tclassName?: string;\n\tparts: TimelineItemParts;\n\t/**\n\t * Callback when an image is clicked (for lightbox).\n\t */\n\tonImageClick?: (index: number) => void;\n\t/**\n\t * Custom className for the images container.\n\t */\n\timagesClassName?: string;\n\t/**\n\t * Custom className for the files container.\n\t */\n\tfilesClassName?: string;\n};\n\n/**\n * Convenience component that renders both images and files from timeline parts.\n * Extracts the appropriate parts and renders them in a single container.\n */\nexport const TimelineItemAttachments = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemAttachmentsProps\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\tparts,\n\t\t\t\tonImageClick,\n\t\t\t\timagesClassName,\n\t\t\t\tfilesClassName,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst images = extractImageParts(parts);\n\t\t\tconst files = extractFileParts(parts);\n\n\t\t\tif (images.length === 0 && files.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst content = children || (\n\t\t\t\t<>\n\t\t\t\t\t{images.length > 0 && (\n\t\t\t\t\t\t<TimelineItemImages\n\t\t\t\t\t\t\tclassName={imagesClassName}\n\t\t\t\t\t\t\timages={images}\n\t\t\t\t\t\t\tonImageClick={onImageClick}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t{files.length > 0 && (\n\t\t\t\t\t\t<TimelineItemFiles className={filesClassName} files={files} />\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t);\n\n\t\t\t// biome-ignore lint/correctness/useHookAtTopLevel: useRenderElement is a utility function, not a hook\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 = \"TimelineItemAttachments\";\n\treturn Component;\n})();\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,kBACf,OACsB;AACtB,QAAO,MAAM,QACX,SAAoC,KAAK,SAAS,QACnD;;;;;AAMF,SAAgB,iBAAiB,OAA8C;AAC9E,QAAO,MAAM,QAAQ,SAAmC,KAAK,SAAS,OAAO;;;;;AAM9E,SAAgB,eAAe,OAAmC;AACjE,QAAO,MAAM,MAAM,SAAS,KAAK,SAAS,WAAW,KAAK,SAAS,OAAO;;;;;;AA8B3E,MAAa,4BAA4B;CACxC,MAAM,YAAYA,QAAM,YAEtB,EAAE,UAAU,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AO;IACN,GAAG;IACH,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ;;;;;AAgCJ,MAAa,iCAAiC;CAC7C,MAAM,YAAYA,QAAM,YAKtB,EACC,UACA,WACA,UAAU,OACV,OACA,cACA,iBACA,eACA,GAAG,SAEJ,QACI;EACJ,MAAM,SAAS,kBAAkB,MAAM;EACvC,MAAM,QAAQ,iBAAiB,MAAM;AAErC,MAAI,OAAO,WAAW,KAAK,MAAM,WAAW,EAC3C,QAAO;EAGR,MAAM,UAAU,YACf,4CACE,OAAO,SAAS,KAChB,oBAAC;GACA,WAAW;GACH;GACM;IACb,EAEF,MAAM,SAAS,KACf,oBAAC;GAAkB,WAAW;GAAuB;IAAS,IAE7D;AAIJ,SAAO,iBACN,OACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;IACN,GAAG;IACH,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ"}
|
|
1
|
+
{"version":3,"file":"timeline-item-attachments.js","names":["React"],"sources":["../../src/primitives/timeline-item-attachments.tsx"],"sourcesContent":["\"use client\";\n\nimport { formatFileSize } from \"@cossistant/core\";\nimport type {\n\tTimelineItemParts,\n\tTimelinePartFile,\n\tTimelinePartImage,\n} from \"@cossistant/types/api/timeline-item\";\nimport * as React from \"react\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\n/**\n * Extract image parts from timeline item parts array.\n */\nexport function extractImageParts(\n\tparts: TimelineItemParts\n): TimelinePartImage[] {\n\treturn parts.filter(\n\t\t(part): part is TimelinePartImage => part.type === \"image\"\n\t);\n}\n\n/**\n * Extract file parts from timeline item parts array.\n */\nexport function extractFileParts(parts: TimelineItemParts): TimelinePartFile[] {\n\treturn parts.filter((part): part is TimelinePartFile => part.type === \"file\");\n}\n\n/**\n * Check if timeline item has any attachments (images or files).\n */\nexport function hasAttachments(parts: TimelineItemParts): boolean {\n\treturn parts.some((part) => part.type === \"image\" || part.type === \"file\");\n}\n\n// ============================================================================\n// TimelineItemImages\n// ============================================================================\n\nexport type TimelineItemImagesProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?:\n\t\t| React.ReactNode\n\t\t| ((\n\t\t\t\timages: TimelinePartImage[],\n\t\t\t\tonImageClick?: (index: number) => void\n\t\t ) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\timages: TimelinePartImage[];\n\t/**\n\t * Callback when an image is clicked (for lightbox).\n\t */\n\tonImageClick?: (index: number) => void;\n};\n\n/**\n * Renders a grid of image thumbnails from timeline item parts.\n * Supports custom rendering via children render prop.\n */\nexport const TimelineItemImages = (() => {\n\tconst Component = React.forwardRef<HTMLDivElement, TimelineItemImagesProps>(\n\t\t(\n\t\t\t{ children, className, asChild = false, images, onImageClick, ...props },\n\t\t\tref\n\t\t) => {\n\t\t\tif (images.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children(images, onImageClick)\n\t\t\t\t\t: children || (\n\t\t\t\t\t\t\t<div className=\"flex flex-wrap gap-2\">\n\t\t\t\t\t\t\t\t{images.map((image, index) => (\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\tclassName=\"group relative overflow-hidden rounded-lg focus:outline-none focus:ring-2 focus:ring-offset-2\"\n\t\t\t\t\t\t\t\t\t\tkey={image.url}\n\t\t\t\t\t\t\t\t\t\tonClick={() => onImageClick?.(index)}\n\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{/* biome-ignore lint/performance/noImgElement: React package, not Next.js specific */}\n\t\t\t\t\t\t\t\t\t\t{/* biome-ignore lint/nursery/useImageSize: Dynamic image dimensions not known at render time */}\n\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\talt={image.filename || `Image ${index + 1}`}\n\t\t\t\t\t\t\t\t\t\t\tclassName=\"max-h-[200px] max-w-[300px] cursor-pointer rounded-lg object-cover transition-transform group-hover:scale-105\"\n\t\t\t\t\t\t\t\t\t\t\tloading=\"lazy\"\n\t\t\t\t\t\t\t\t\t\t\tsrc={image.url}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\n\t\t\t// biome-ignore lint/correctness/useHookAtTopLevel: useRenderElement is a utility function, not a hook\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 = \"TimelineItemImages\";\n\treturn Component;\n})();\n\n// ============================================================================\n// TimelineItemFiles\n// ============================================================================\n\nexport type TimelineItemFilesProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode | ((files: TimelinePartFile[]) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\tfiles: TimelinePartFile[];\n};\n\n/**\n * Get file icon based on MIME type.\n */\nfunction getFileIcon(mediaType: string): string {\n\tif (mediaType === \"application/pdf\") {\n\t\treturn \"📄\";\n\t}\n\tif (mediaType === \"application/zip\") {\n\t\treturn \"🗜️\";\n\t}\n\tif (mediaType.startsWith(\"text/\")) {\n\t\treturn \"📝\";\n\t}\n\treturn \"📎\";\n}\n\n/**\n * Renders a list of file attachments from timeline item parts.\n * Supports custom rendering via children render prop.\n */\nexport const TimelineItemFiles = (() => {\n\tconst Component = React.forwardRef<HTMLDivElement, TimelineItemFilesProps>(\n\t\t({ children, className, asChild = false, files, ...props }, ref) => {\n\t\t\tif (files.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst content =\n\t\t\t\ttypeof children === \"function\"\n\t\t\t\t\t? children(files)\n\t\t\t\t\t: children || (\n\t\t\t\t\t\t\t<div className=\"flex flex-col gap-2\">\n\t\t\t\t\t\t\t\t{files.map((file) => (\n\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\tclassName=\"flex items-center gap-2 rounded-lg bg-co-muted/50 px-3 py-2 text-sm transition-colors hover:bg-co-muted\"\n\t\t\t\t\t\t\t\t\t\tdownload={file.filename}\n\t\t\t\t\t\t\t\t\t\thref={file.url}\n\t\t\t\t\t\t\t\t\t\tkey={file.url}\n\t\t\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span className=\"text-lg\">\n\t\t\t\t\t\t\t\t\t\t\t{getFileIcon(file.mediaType)}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t<span className=\"flex-1 truncate font-medium\">\n\t\t\t\t\t\t\t\t\t\t\t{file.filename || \"Download file\"}\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t{file.size && (\n\t\t\t\t\t\t\t\t\t\t\t<span className=\"text-co-muted-foreground text-xs\">\n\t\t\t\t\t\t\t\t\t\t\t\t{formatFileSize(file.size)}\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t);\n\n\t\t\t// biome-ignore lint/correctness/useHookAtTopLevel: useRenderElement is a utility function, not a hook\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 = \"TimelineItemFiles\";\n\treturn Component;\n})();\n\n// ============================================================================\n// TimelineItemAttachments (convenience wrapper)\n// ============================================================================\n\nexport type TimelineItemAttachmentsProps = Omit<\n\tReact.HTMLAttributes<HTMLDivElement>,\n\t\"children\"\n> & {\n\tchildren?: React.ReactNode;\n\tasChild?: boolean;\n\tclassName?: string;\n\tparts: TimelineItemParts;\n\t/**\n\t * Callback when an image is clicked (for lightbox).\n\t */\n\tonImageClick?: (index: number) => void;\n\t/**\n\t * Custom className for the images container.\n\t */\n\timagesClassName?: string;\n\t/**\n\t * Custom className for the files container.\n\t */\n\tfilesClassName?: string;\n};\n\n/**\n * Convenience component that renders both images and files from timeline parts.\n * Extracts the appropriate parts and renders them in a single container.\n */\nexport const TimelineItemAttachments = (() => {\n\tconst Component = React.forwardRef<\n\t\tHTMLDivElement,\n\t\tTimelineItemAttachmentsProps\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\tparts,\n\t\t\t\tonImageClick,\n\t\t\t\timagesClassName,\n\t\t\t\tfilesClassName,\n\t\t\t\t...props\n\t\t\t},\n\t\t\tref\n\t\t) => {\n\t\t\tconst images = extractImageParts(parts);\n\t\t\tconst files = extractFileParts(parts);\n\n\t\t\tif (images.length === 0 && files.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst content = children || (\n\t\t\t\t<>\n\t\t\t\t\t{images.length > 0 && (\n\t\t\t\t\t\t<TimelineItemImages\n\t\t\t\t\t\t\tclassName={imagesClassName}\n\t\t\t\t\t\t\timages={images}\n\t\t\t\t\t\t\tonImageClick={onImageClick}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\t\t\t\t{files.length > 0 && (\n\t\t\t\t\t\t<TimelineItemFiles className={filesClassName} files={files} />\n\t\t\t\t\t)}\n\t\t\t\t</>\n\t\t\t);\n\n\t\t\t// biome-ignore lint/correctness/useHookAtTopLevel: useRenderElement is a utility function, not a hook\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 = \"TimelineItemAttachments\";\n\treturn Component;\n})();\n"],"mappings":";;;;;;;;;;;AAcA,SAAgB,kBACf,OACsB;AACtB,QAAO,MAAM,QACX,SAAoC,KAAK,SAAS,QACnD;;;;;AAMF,SAAgB,iBAAiB,OAA8C;AAC9E,QAAO,MAAM,QAAQ,SAAmC,KAAK,SAAS,OAAO;;;;;AAM9E,SAAgB,eAAe,OAAmC;AACjE,QAAO,MAAM,MAAM,SAAS,KAAK,SAAS,WAAW,KAAK,SAAS,OAAO;;;;;;AA8B3E,MAAa,4BAA4B;CACxC,MAAM,YAAYA,QAAM,YAEtB,EAAE,UAAU,WAAW,UAAU,OAAO,QAAQ,cAAc,GAAG,SACjE,QACI;AACJ,MAAI,OAAO,WAAW,EACrB,QAAO;EAGR,MAAM,UACL,OAAO,aAAa,aACjB,SAAS,QAAQ,aAAa,GAC9B,YACA,oBAAC;GAAI,WAAU;aACb,OAAO,KAAK,OAAO,UACnB,oBAAC;IACA,WAAU;IAEV,eAAe,eAAe,MAAM;IACpC,MAAK;cAIL,oBAAC;KACA,KAAK,MAAM,YAAY,SAAS,QAAQ;KACxC,WAAU;KACV,SAAQ;KACR,KAAK,MAAM;MACV;MAXG,M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E,OAAO,SAAS,KAChB,oBAAC;GACA,WAAW;GACH;GACM;IACb,EAEF,MAAM,SAAS,KACf,oBAAC;GAAkB,WAAW;GAAuB;IAAS,IAE7D;AAIJ,SAAO,iBACN,OACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;IACN,GAAG;IACH,UAAU;IACV;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-item-group.d.ts","names":[],"sources":["../../src/primitives/timeline-item-group.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AASA;AAyBA;AACsB,KA1BV,4BAAA,GA0BU;EAArB,UAAM,EAxBM,UAwBN;EAD8B,QAAA,EAAA,MAAA;EAKjC,UAAM,CAAA,EA1BI,UA0BJ;EACG,cAAA,EAAA,OAAA;EAAiC,kBAAM,EAAA,OAAA;EAG5C,SAAA,EAAA,OAAA;EAIM,IAAA,EAAA,OAAA;EAIK,YAAA,EAAA,OAAA;EAAG,SAAA,EAAA,MAAA;EAST,WAAA,EAAA,MAAA,
|
|
1
|
+
{"version":3,"file":"timeline-item-group.d.ts","names":[],"sources":["../../src/primitives/timeline-item-group.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AASA;AAyBA;AACsB,KA1BV,4BAAA,GA0BU;EAArB,UAAM,EAxBM,UAwBN;EAD8B,QAAA,EAAA,MAAA;EAKjC,UAAM,CAAA,EA1BI,UA0BJ;EACG,cAAA,EAAA,OAAA;EAAiC,kBAAM,EAAA,OAAA;EAG5C,SAAA,EAAA,OAAA;EAIM,IAAA,EAAA,OAAA;EAIK,YAAA,EAAA,OAAA;EAAG,SAAA,EAAA,MAAA;EAST,WAAA,EAAA,MAAA,GAuGT,SAAA;EAvG0B,UAAA,EAAA,MAAA,GAAA,SAAA;EAAA,mBAAA,CAAA,EAAA,OAAA;EAAA,SAAA,CAAA,EAAA,SAAA,MAAA,EAAA;CArB1B;AACS,KAND,sBAAA,GAAyB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*/
|
|
11
11
|
const TimelineItemGroup = (() => {
|
|
12
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false, items = [], viewerId, seenByIds = [], lastReadItemIds
|
|
13
|
-
const { viewerType
|
|
12
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, items = [], viewerId, seenByIds = [], lastReadItemIds, ...restProps }, ref) => {
|
|
13
|
+
const { viewerType, ...elementProps } = restProps;
|
|
14
14
|
const firstItem = items[0];
|
|
15
|
-
const lastItem = items
|
|
15
|
+
const lastItem = items.at(-1);
|
|
16
16
|
let senderId = "";
|
|
17
17
|
let senderType;
|
|
18
18
|
if (firstItem?.visitorId) {
|
|
@@ -72,7 +72,7 @@ const TimelineItemGroup = (() => {
|
|
|
72
72
|
* badge or any other sender metadata supplied by the consumer UI.
|
|
73
73
|
*/
|
|
74
74
|
const TimelineItemGroupAvatar = (() => {
|
|
75
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false
|
|
75
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, ...props }, ref) => useRenderElement("div", {
|
|
76
76
|
className,
|
|
77
77
|
asChild
|
|
78
78
|
}, {
|
|
@@ -91,7 +91,7 @@ const TimelineItemGroupAvatar = (() => {
|
|
|
91
91
|
* metadata supplied by `TimelineItemGroup`.
|
|
92
92
|
*/
|
|
93
93
|
const TimelineItemGroupHeader = (() => {
|
|
94
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false, name, senderId, senderType
|
|
94
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, name, senderId, senderType, ...props }, ref) => {
|
|
95
95
|
const content = typeof children === "function" ? children({
|
|
96
96
|
name,
|
|
97
97
|
senderId,
|
|
@@ -117,7 +117,7 @@ const TimelineItemGroupHeader = (() => {
|
|
|
117
117
|
* parent group.
|
|
118
118
|
*/
|
|
119
119
|
const TimelineItemGroupContent = (() => {
|
|
120
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false
|
|
120
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, ...props }, ref) => useRenderElement("div", {
|
|
121
121
|
className,
|
|
122
122
|
asChild
|
|
123
123
|
}, {
|
|
@@ -136,7 +136,7 @@ const TimelineItemGroupContent = (() => {
|
|
|
136
136
|
* displays.
|
|
137
137
|
*/
|
|
138
138
|
const TimelineItemGroupSeenIndicator = (() => {
|
|
139
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false, seenByIds = []
|
|
139
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, seenByIds = [], ...props }, ref) => {
|
|
140
140
|
const hasBeenSeen = seenByIds.length > 0;
|
|
141
141
|
const content = typeof children === "function" ? children({
|
|
142
142
|
seenByIds,
|
|
@@ -162,7 +162,7 @@ const TimelineItemGroupSeenIndicator = (() => {
|
|
|
162
162
|
* basic label.
|
|
163
163
|
*/
|
|
164
164
|
const TimelineItemGroupReadIndicator = (() => {
|
|
165
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false, itemId, lastReadItemIds
|
|
165
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, itemId, lastReadItemIds, ...props }, ref) => {
|
|
166
166
|
const { lastReaderIds, readers } = React$1.useMemo(() => {
|
|
167
167
|
const _lastReaderIds = [];
|
|
168
168
|
const _readers = [];
|
|
@@ -1 +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?: readonly 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?: readonly 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 = [] as readonly string[],\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: readonly string[];\n\t\t\t\thasBeenSeen: boolean;\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\tseenByIds?: readonly 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{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\tseenByIds = [] as readonly string[],\n\t\t\t\t...props\n\t\t\t},\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,QACI;EACJ,MAAM,EAAE,WAAY,GAAG,iBAAiB;EAGxC,MAAM,YAAY,MAAM;EAExB,MAAM,WAAW,MAAM,MAAM,SAAS;EAGtC,IAAI,WAAW;EACf,IAAIC;AAEJ,MAAI,WAAW,WAAW;AACzB,cAAW,UAAU;AACrB,gBAAa;aACH,WAAW,WAAW;AAChC,cAAW,UAAU;AACrB,gBAAa;aACH,WAAW,QAAQ;AAC7B,cAAW,UAAU;AACrB,gBAAa;SACP;AAEN,cAAW,WAAW,MAAM;AAC5B,gBAAa;;EAId,MAAM,iBAAiB,WACpB,aAAa,WACb,aACC,eAAe,aACf;EACJ,MAAM,qBAAqB,WACxB,aAAa,WACb,aACC,eAAe,aACf;EAGJ,MAAM,YAAY,eAAe;EACjC,MAAM,OAAO,eAAe;EAC5B,MAAM,eAAe,eAAe;EAGpC,MAAM,sBAAsB,WACzB,UAAU,SAAS,SAAS,GAC5B;EAEH,MAAMC,cAA4C;GACjD;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,MAAM;GACjB,aAAa,WAAW;GACxB,YAAY,UAAU;GACtB;GACA;GACA;EAED,MAAM,UACL,OAAO,aAAa,aAAa,SAAS,YAAY,GAAG;AAE1D,SAAO,iBACN,OACA;GACC;GACA;GACA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;GACD,CACD;GAEF;AAED,WAAU,cAAc;AACxB,QAAO;IACJ;;;;;;AAuBJ,MAAa,wCAAwC;CACpD,MAAM,YAAYA,QAAM,YAKtB,EACC,UACA,WACA,UAAU,OACV,QACA,gBACA,GAAG,SAEJ,QACI;EAEJ,MAAM,EAAE,eAAe,YAAYA,QAAM,cAAc;GACtD,MAAMG,iBAA2B,EAAE;GACnC,MAAMC,WAA2D,EAAE;AAEnE,OAAI,gBACH,iBAAgB,SAAS,YAAY,WAAW;AAC/C,QAAI,eAAe,QAAQ;AAC1B,oBAAe,KAAK,OAAO;AAC3B,cAAS,KAAK;MAAE;MAAQ,YAAY;MAAM,CAAC;;KAE3C;AAGH,UAAO;IAAE,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"}
|
|
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?: readonly 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?: readonly 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 = [] as readonly string[],\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\tconst lastItem = items.at(-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: readonly string[];\n\t\t\t\thasBeenSeen: boolean;\n\t\t }) => React.ReactNode);\n\tasChild?: boolean;\n\tclassName?: string;\n\tseenByIds?: readonly 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{\n\t\t\t\tchildren,\n\t\t\t\tclassName,\n\t\t\t\tasChild = false,\n\t\t\t\tseenByIds = [] as readonly string[],\n\t\t\t\t...props\n\t\t\t},\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,iBACA,GAAG,aAEJ,QACI;EACJ,MAAM,EAAE,YAAY,GAAG,iBAAiB;EAGxC,MAAM,YAAY,MAAM;EACxB,MAAM,WAAW,MAAM,GAAG,GAAG;EAG7B,IAAI,WAAW;EACf,IAAIC;AAEJ,MAAI,WAAW,WAAW;AACzB,cAAW,UAAU;AACrB,gBAAa;aACH,WAAW,WAAW;AAChC,cAAW,UAAU;AACrB,gBAAa;aACH,WAAW,QAAQ;AAC7B,cAAW,UAAU;AACrB,gBAAa;SACP;AAEN,cAAW,WAAW,MAAM;AAC5B,gBAAa;;EAId,MAAM,iBAAiB,WACpB,aAAa,WACb,aACC,eAAe,aACf;EACJ,MAAM,qBAAqB,WACxB,aAAa,WACb,aACC,eAAe,aACf;EAGJ,MAAM,YAAY,eAAe;EACjC,MAAM,OAAO,eAAe;EAC5B,MAAM,eAAe,eAAe;EAGpC,MAAM,sBAAsB,WACzB,UAAU,SAAS,SAAS,GAC5B;EAEH,MAAMC,cAA4C;GACjD;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,WAAW,MAAM;GACjB,aAAa,WAAW;GACxB,YAAY,UAAU;GACtB;GACA;GACA;EAED,MAAM,UACL,OAAO,aAAa,aAAa,SAAS,YAAY,GAAG;AAE1D,SAAO,iBACN,OACA;GACC;GACA;GACA,EACD;GACC;GACA,OAAO;GACP,OAAO;IACN,MAAM;IACN,cAAc,4BAA4B;IAC1C,GAAG;IACH,UAAU;IACV;GACD,CACD;GAE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,YAKtB,EACC,UACA,WACA,UAAU,OACV,QACA,iBACA,GAAG,SAEJ,QACI;EAEJ,MAAM,EAAE,eAAe,YAAYA,QAAM,cAAc;GACtD,MAAMG,iBAA2B,EAAE;GACnC,MAAMC,WAA2D,EAAE;AAEnE,OAAI,gBACH,iBAAgB,SAAS,YAAY,WAAW;AAC/C,QAAI,eAAe,QAAQ;AAC1B,oBAAe,KAAK,OAAO;AAC3B,cAAS,KAAK;MAAE;MAAQ,YAAY;MAAM,CAAC;;KAE3C;AAGH,UAAO;IAAE,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline-item.d.ts","names":[],"sources":["../../src/primitives/timeline-item.tsx"],"sourcesContent":[],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"timeline-item.d.ts","names":[],"sources":["../../src/primitives/timeline-item.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAUA;AAUA;AACsB,KAXV,uBAAA,GAWU;EAArB,SAAM,EAAA,OAAA;EADyB,IAAA,EAAA,OAAA;EAK5B,OAAM,EAAA,OAAA;EACG,SAAA,EAZD,IAYC;EAA4B,IAAA,EAAM,MAAA,GAAA,IAAA;EAGxC,UAAA,EAAA,SAAA,GAAA,IAAA,GAAA,OAAA;EAAgB,QAAA,EAAA,SAAA,GAAA,OAAA,GAAA,gBAAA;AAQvB,CAAA;AAAyB,KAjBb,iBAAA,GAAoB,IAiBP,CAhBxB,OAAA,CAAM,cAgBkB,CAhBH,cAgBG,CAAA,EAAA,UAAA,CAAA,GAAA;EAAA,QAAA,CA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,CAAA,EAAA,OAAA;EAI7B,SAAM,CAAA,EAAA,MAAA;EAAyB,IAAA,CAAA,EAAA,MAAA,GAAA,IAAA;EAAS,cAAM,CAAA,EAAA,OAAA;CAG9C,wBAAA,eAAA,CAAA,CAAA;AACK,KARL,0BAAA,GAA6B,IAQxB,CAPhB,OAAA,CAAM,cAOU,CAPK,eAOL,CAAA,EAAA,UAAA,CAAA,GAAA;EAAI,QAAA,CAAA,EAJT,OAAA,CAAM,SAIG,GAAA,CAAA,CAAA,SAAA,EAJsB,IAItB,EAAA,GAJ+B,OAAA,CAAM,SAIrC,CAAA;EAOR,OAAA,CAAA,EAAA,OAAA;EAAqB,SAAA,CAAA,EAAA,MAAA;EAAA,SAAA,EARtB,IAQsB;EAAA,MAAA,CAAA,EAAA,CAAA,IAAA,EAPjB,IAOiB,EAAA,GAAA,MAAA;CAXtB;;;;;cAWC,uBAAqB,OAAA,CAAA,0BAAA,KAAA,OAAA,CAAA,eAAA;aAXtB,OAAA,CAAM,yBAAyB,SAAS,OAAA,CAAM;EAWxB,OAAA,CAAA,EAAA,OAAA;EAAA,SAAA,CAAA,EAAA,MAAA;aARtB;kBACK"}
|
|
@@ -2,6 +2,7 @@ import { useRenderElement } from "../utils/use-render-element.js";
|
|
|
2
2
|
import * as React$1 from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import ReactMarkdown from "react-markdown";
|
|
5
|
+
import remarkBreaks from "remark-breaks";
|
|
5
6
|
|
|
6
7
|
//#region src/primitives/timeline-item.tsx
|
|
7
8
|
/**
|
|
@@ -10,7 +11,7 @@ import ReactMarkdown from "react-markdown";
|
|
|
10
11
|
* both MESSAGE and EVENT timeline item types.
|
|
11
12
|
*/
|
|
12
13
|
const TimelineItem = (() => {
|
|
13
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false, item
|
|
14
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, item, ...props }, ref) => {
|
|
14
15
|
const isVisitor = item.visitorId !== null;
|
|
15
16
|
const isAI = item.aiAgentId !== null;
|
|
16
17
|
const isHuman = item.userId !== null && !isVisitor;
|
|
@@ -52,12 +53,15 @@ const TimelineItem = (() => {
|
|
|
52
53
|
const MemoizedMarkdownBlock = React$1.memo(({ content }) => {
|
|
53
54
|
return /* @__PURE__ */ jsx(ReactMarkdown, {
|
|
54
55
|
components: {
|
|
55
|
-
p: ({ children }) =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
p: ({ children }) => {
|
|
57
|
+
if (children === void 0 || children === null || children === "" || Array.isArray(children) && children.every((c) => c === "\n" || c === "" || c == null)) return null;
|
|
58
|
+
return /* @__PURE__ */ jsx("span", {
|
|
59
|
+
className: "mt-1 block first:mt-0",
|
|
60
|
+
children
|
|
61
|
+
});
|
|
62
|
+
},
|
|
59
63
|
br: () => /* @__PURE__ */ jsx("br", {}),
|
|
60
|
-
code: ({ children
|
|
64
|
+
code: ({ children, ...props }) => {
|
|
61
65
|
return !("className" in props && typeof props.className === "string" && props.className.includes("language-")) ? /* @__PURE__ */ jsx("code", {
|
|
62
66
|
className: "rounded bg-co-background-300 px-1 py-0.5 text-xs",
|
|
63
67
|
children
|
|
@@ -73,6 +77,26 @@ const MemoizedMarkdownBlock = React$1.memo(({ content }) => {
|
|
|
73
77
|
className: "font-semibold",
|
|
74
78
|
children
|
|
75
79
|
}),
|
|
80
|
+
ol: ({ children }) => /* @__PURE__ */ jsx("ol", {
|
|
81
|
+
className: "my-0 list-decimal pl-6",
|
|
82
|
+
children
|
|
83
|
+
}),
|
|
84
|
+
ul: ({ children }) => /* @__PURE__ */ jsx("ul", {
|
|
85
|
+
className: "my-0 list-disc pl-6",
|
|
86
|
+
children
|
|
87
|
+
}),
|
|
88
|
+
li: ({ children }) => /* @__PURE__ */ jsx("li", {
|
|
89
|
+
className: "[&>span.block]:mt-0 [&>span.block]:inline",
|
|
90
|
+
children
|
|
91
|
+
}),
|
|
92
|
+
blockquote: ({ children }) => /* @__PURE__ */ jsx("blockquote", {
|
|
93
|
+
className: "my-1 border-co-border border-l-2 pl-3 italic opacity-80",
|
|
94
|
+
children
|
|
95
|
+
}),
|
|
96
|
+
em: ({ children }) => /* @__PURE__ */ jsx("em", {
|
|
97
|
+
className: "italic",
|
|
98
|
+
children
|
|
99
|
+
}),
|
|
76
100
|
a: ({ href, children }) => /* @__PURE__ */ jsx("a", {
|
|
77
101
|
className: "underline hover:opacity-80",
|
|
78
102
|
href,
|
|
@@ -81,6 +105,7 @@ const MemoizedMarkdownBlock = React$1.memo(({ content }) => {
|
|
|
81
105
|
children
|
|
82
106
|
})
|
|
83
107
|
},
|
|
108
|
+
remarkPlugins: [remarkBreaks],
|
|
84
109
|
children: content
|
|
85
110
|
});
|
|
86
111
|
}, (prevProps, nextProps) => {
|
|
@@ -94,7 +119,7 @@ MemoizedMarkdownBlock.displayName = "MemoizedMarkdownBlock";
|
|
|
94
119
|
* formatting.
|
|
95
120
|
*/
|
|
96
121
|
const TimelineItemContent = (() => {
|
|
97
|
-
const Component = React$1.forwardRef(({ children, className, asChild = false, text = "", renderMarkdown = true
|
|
122
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, text = "", renderMarkdown = true, ...props }, ref) => {
|
|
98
123
|
const content = React$1.useMemo(() => {
|
|
99
124
|
const textContent = text ?? "";
|
|
100
125
|
if (typeof children === "function") return children(textContent);
|
|
@@ -129,7 +154,7 @@ const TimelineItemTimestamp = (() => {
|
|
|
129
154
|
const Component = React$1.forwardRef(({ children, className, asChild = false, timestamp, format = (date) => date.toLocaleTimeString([], {
|
|
130
155
|
hour: "2-digit",
|
|
131
156
|
minute: "2-digit"
|
|
132
|
-
})
|
|
157
|
+
}), ...props }, ref) => {
|
|
133
158
|
const content = typeof children === "function" ? children(timestamp) : children || format(timestamp);
|
|
134
159
|
return useRenderElement("span", {
|
|
135
160
|
className,
|