@cossistant/react 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_virtual/rolldown_runtime.js +13 -0
- package/conversation.d.ts +312 -0
- package/conversation.d.ts.map +1 -0
- package/hooks/index.d.ts +23 -0
- package/hooks/index.js +24 -0
- package/hooks/private/store/use-conversations-store.d.ts +13 -0
- package/hooks/private/store/use-conversations-store.d.ts.map +1 -0
- package/hooks/private/store/use-conversations-store.js +34 -0
- package/hooks/private/store/use-conversations-store.js.map +1 -0
- package/hooks/private/store/use-store-selector.d.ts +10 -0
- package/hooks/private/store/use-store-selector.d.ts.map +1 -0
- package/hooks/private/store/use-store-selector.js +17 -0
- package/hooks/private/store/use-store-selector.js.map +1 -0
- package/hooks/private/store/use-website-store.d.ts +18 -0
- package/hooks/private/store/use-website-store.d.ts.map +1 -0
- package/hooks/private/store/use-website-store.js +39 -0
- package/hooks/private/store/use-website-store.js.map +1 -0
- package/hooks/private/use-client-query.d.ts +25 -0
- package/hooks/private/use-client-query.d.ts.map +1 -0
- package/hooks/private/use-client-query.js +122 -0
- package/hooks/private/use-client-query.js.map +1 -0
- package/hooks/private/use-default-messages.d.ts +18 -0
- package/hooks/private/use-default-messages.d.ts.map +1 -0
- package/hooks/private/use-default-messages.js +45 -0
- package/hooks/private/use-default-messages.js.map +1 -0
- package/hooks/private/use-grouped-messages.d.ts +54 -0
- package/hooks/private/use-grouped-messages.d.ts.map +1 -0
- package/hooks/private/use-grouped-messages.js +157 -0
- package/hooks/private/use-grouped-messages.js.map +1 -0
- package/hooks/private/use-multimodal-input.d.ts +40 -0
- package/hooks/private/use-multimodal-input.d.ts.map +1 -0
- package/hooks/private/use-multimodal-input.js +129 -0
- package/hooks/private/use-multimodal-input.js.map +1 -0
- package/hooks/private/use-rest-client.d.ts +17 -0
- package/hooks/private/use-rest-client.d.ts.map +1 -0
- package/hooks/private/use-rest-client.js +41 -0
- package/hooks/private/use-rest-client.js.map +1 -0
- package/hooks/private/use-visitor-typing-reporter.d.ts +19 -0
- package/hooks/private/use-visitor-typing-reporter.d.ts.map +1 -0
- package/hooks/private/use-visitor-typing-reporter.js +140 -0
- package/hooks/private/use-visitor-typing-reporter.js.map +1 -0
- package/hooks/use-composer-refocus.d.ts +20 -0
- package/hooks/use-composer-refocus.d.ts.map +1 -0
- package/hooks/use-composer-refocus.js +32 -0
- package/hooks/use-composer-refocus.js.map +1 -0
- package/hooks/use-conversation-auto-seen.d.ts +54 -0
- package/hooks/use-conversation-auto-seen.d.ts.map +1 -0
- package/hooks/use-conversation-auto-seen.js +106 -0
- package/hooks/use-conversation-auto-seen.js.map +1 -0
- package/hooks/use-conversation-history-page.d.ts +86 -0
- package/hooks/use-conversation-history-page.d.ts.map +1 -0
- package/hooks/use-conversation-history-page.js +97 -0
- package/hooks/use-conversation-history-page.js.map +1 -0
- package/hooks/use-conversation-lifecycle.d.ts +80 -0
- package/hooks/use-conversation-lifecycle.d.ts.map +1 -0
- package/hooks/use-conversation-lifecycle.js +54 -0
- package/hooks/use-conversation-lifecycle.js.map +1 -0
- package/hooks/use-conversation-page.d.ts +82 -0
- package/hooks/use-conversation-page.d.ts.map +1 -0
- package/hooks/use-conversation-page.js +138 -0
- package/hooks/use-conversation-page.js.map +1 -0
- package/hooks/use-conversation-seen.d.ts +17 -0
- package/hooks/use-conversation-seen.d.ts.map +1 -0
- package/hooks/use-conversation-seen.js +58 -0
- package/hooks/use-conversation-seen.js.map +1 -0
- package/hooks/use-conversation-timeline-items.d.ts +21 -0
- package/hooks/use-conversation-timeline-items.d.ts.map +1 -0
- package/hooks/use-conversation-timeline-items.js +87 -0
- package/hooks/use-conversation-timeline-items.js.map +1 -0
- package/hooks/use-conversation-typing.d.ts +13 -0
- package/hooks/use-conversation-typing.d.ts.map +1 -0
- package/hooks/use-conversation-typing.js +34 -0
- package/hooks/use-conversation-typing.js.map +1 -0
- package/hooks/use-conversation.d.ts +18 -0
- package/hooks/use-conversation.d.ts.map +1 -0
- package/hooks/use-conversation.js +44 -0
- package/hooks/use-conversation.js.map +1 -0
- package/hooks/use-conversations.d.ts +20 -0
- package/hooks/use-conversations.d.ts.map +1 -0
- package/hooks/use-conversations.js +68 -0
- package/hooks/use-conversations.js.map +1 -0
- package/hooks/use-create-conversation.d.ts +30 -0
- package/hooks/use-create-conversation.d.ts.map +1 -0
- package/hooks/use-create-conversation.js +67 -0
- package/hooks/use-create-conversation.js.map +1 -0
- package/hooks/use-home-page.d.ts +82 -0
- package/hooks/use-home-page.d.ts.map +1 -0
- package/hooks/use-home-page.js +89 -0
- package/hooks/use-home-page.js.map +1 -0
- package/hooks/use-message-composer.d.ts +88 -0
- package/hooks/use-message-composer.d.ts.map +1 -0
- package/hooks/use-message-composer.js +94 -0
- package/hooks/use-message-composer.js.map +1 -0
- package/hooks/use-realtime-support.d.ts +25 -0
- package/hooks/use-realtime-support.d.ts.map +1 -0
- package/hooks/use-realtime-support.js +29 -0
- package/hooks/use-realtime-support.js.map +1 -0
- package/hooks/use-send-message.d.ts +34 -0
- package/hooks/use-send-message.d.ts.map +1 -0
- package/hooks/use-send-message.js +118 -0
- package/hooks/use-send-message.js.map +1 -0
- package/hooks/use-visitor.d.ts +28 -0
- package/hooks/use-visitor.d.ts.map +1 -0
- package/hooks/use-visitor.js +59 -0
- package/hooks/use-visitor.js.map +1 -0
- package/hooks/use-window-visibility-focus.d.ts +9 -0
- package/hooks/use-window-visibility-focus.d.ts.map +1 -0
- package/hooks/use-window-visibility-focus.js +53 -0
- package/hooks/use-window-visibility-focus.js.map +1 -0
- package/identify-visitor.d.ts +18 -0
- package/identify-visitor.d.ts.map +1 -0
- package/identify-visitor.js +26 -0
- package/identify-visitor.js.map +1 -0
- package/index.d.ts +38 -0
- package/index.js +38 -0
- package/package.json +121 -0
- package/primitives/avatar/avatar.d.ts +31 -0
- package/primitives/avatar/avatar.d.ts.map +1 -0
- package/primitives/avatar/avatar.js +49 -0
- package/primitives/avatar/avatar.js.map +1 -0
- package/primitives/avatar/fallback.d.ts +24 -0
- package/primitives/avatar/fallback.d.ts.map +1 -0
- package/primitives/avatar/fallback.js +57 -0
- package/primitives/avatar/fallback.js.map +1 -0
- package/primitives/avatar/image.d.ts +27 -0
- package/primitives/avatar/image.d.ts.map +1 -0
- package/primitives/avatar/image.js +58 -0
- package/primitives/avatar/image.js.map +1 -0
- package/primitives/avatar/index.d.ts +4 -0
- package/primitives/avatar/index.js +5 -0
- package/primitives/avatar/index.parts.d.ts +4 -0
- package/primitives/avatar/index.parts.js +5 -0
- package/primitives/bubble.d.ts +28 -0
- package/primitives/bubble.d.ts.map +1 -0
- package/primitives/bubble.js +43 -0
- package/primitives/bubble.js.map +1 -0
- package/primitives/button.d.ts +19 -0
- package/primitives/button.d.ts.map +1 -0
- package/primitives/button.js +27 -0
- package/primitives/button.js.map +1 -0
- package/primitives/conversation-timeline.d.ts +86 -0
- package/primitives/conversation-timeline.d.ts.map +1 -0
- package/primitives/conversation-timeline.js +119 -0
- package/primitives/conversation-timeline.js.map +1 -0
- package/primitives/index.d.ts +20 -0
- package/primitives/index.d.ts.map +1 -0
- package/primitives/index.js +45 -0
- package/primitives/index.js.map +1 -0
- package/primitives/index.parts.d.ts +13 -0
- package/primitives/index.parts.js +14 -0
- package/primitives/multimodal-input.d.ts +53 -0
- package/primitives/multimodal-input.d.ts.map +1 -0
- package/primitives/multimodal-input.js +106 -0
- package/primitives/multimodal-input.js.map +1 -0
- package/primitives/timeline-item-group.d.ts +166 -0
- package/primitives/timeline-item-group.d.ts.map +1 -0
- package/primitives/timeline-item-group.js +204 -0
- package/primitives/timeline-item-group.js.map +1 -0
- package/primitives/timeline-item.d.ts +75 -0
- package/primitives/timeline-item.d.ts.map +1 -0
- package/primitives/timeline-item.js +145 -0
- package/primitives/timeline-item.js.map +1 -0
- package/primitives/window.d.ts +31 -0
- package/primitives/window.d.ts.map +1 -0
- package/primitives/window.js +58 -0
- package/primitives/window.js.map +1 -0
- package/provider.d.ts +95 -0
- package/provider.d.ts.map +1 -0
- package/provider.js +124 -0
- package/provider.js.map +1 -0
- package/realtime/event-filter.d.ts +8 -0
- package/realtime/event-filter.d.ts.map +1 -0
- package/realtime/event-filter.js +21 -0
- package/realtime/event-filter.js.map +1 -0
- package/realtime/index.d.ts +6 -0
- package/realtime/index.js +7 -0
- package/realtime/provider.d.ts +57 -0
- package/realtime/provider.d.ts.map +1 -0
- package/realtime/provider.js +351 -0
- package/realtime/provider.js.map +1 -0
- package/realtime/seen-store.d.ts +23 -0
- package/realtime/seen-store.d.ts.map +1 -0
- package/realtime/seen-store.js +34 -0
- package/realtime/seen-store.js.map +1 -0
- package/realtime/support-provider.d.ts +17 -0
- package/realtime/support-provider.d.ts.map +1 -0
- package/realtime/support-provider.js +54 -0
- package/realtime/support-provider.js.map +1 -0
- package/realtime/typing-store.d.ts +30 -0
- package/realtime/typing-store.d.ts.map +1 -0
- package/realtime/typing-store.js +34 -0
- package/realtime/typing-store.js.map +1 -0
- package/realtime/use-realtime.d.ts +29 -0
- package/realtime/use-realtime.d.ts.map +1 -0
- package/realtime/use-realtime.js +47 -0
- package/realtime/use-realtime.js.map +1 -0
- package/realtime-events.d.ts +344 -0
- package/realtime-events.d.ts.map +1 -0
- package/schemas.d.ts +90 -0
- package/schemas.d.ts.map +1 -0
- package/support/components/avatar-stack.d.ts +45 -0
- package/support/components/avatar-stack.d.ts.map +1 -0
- package/support/components/avatar-stack.js +72 -0
- package/support/components/avatar-stack.js.map +1 -0
- package/support/components/avatar.d.ts +15 -0
- package/support/components/avatar.d.ts.map +1 -0
- package/support/components/avatar.js +23 -0
- package/support/components/avatar.js.map +1 -0
- package/support/components/bubble.d.ts +10 -0
- package/support/components/bubble.d.ts.map +1 -0
- package/support/components/bubble.js +95 -0
- package/support/components/bubble.js.map +1 -0
- package/support/components/button.d.ts +20 -0
- package/support/components/button.d.ts.map +1 -0
- package/support/components/button.js +41 -0
- package/support/components/button.js.map +1 -0
- package/support/components/container.d.ts +14 -0
- package/support/components/container.d.ts.map +1 -0
- package/support/components/container.js +115 -0
- package/support/components/container.js.map +1 -0
- package/support/components/conversation-button-link.d.ts +34 -0
- package/support/components/conversation-button-link.d.ts.map +1 -0
- package/support/components/conversation-button-link.js +195 -0
- package/support/components/conversation-button-link.js.map +1 -0
- package/support/components/conversation-event.d.ts +14 -0
- package/support/components/conversation-event.d.ts.map +1 -0
- package/support/components/conversation-event.js +76 -0
- package/support/components/conversation-event.js.map +1 -0
- package/support/components/conversation-timeline.d.ts +17 -0
- package/support/components/conversation-timeline.d.ts.map +1 -0
- package/support/components/conversation-timeline.js +95 -0
- package/support/components/conversation-timeline.js.map +1 -0
- package/support/components/cossistant-branding.d.ts +12 -0
- package/support/components/cossistant-branding.d.ts.map +1 -0
- package/support/components/cossistant-branding.js +22 -0
- package/support/components/cossistant-branding.js.map +1 -0
- package/support/components/header.d.ts +11 -0
- package/support/components/header.d.ts.map +1 -0
- package/support/components/header.js +43 -0
- package/support/components/header.js.map +1 -0
- package/support/components/icons.d.ts +21 -0
- package/support/components/icons.d.ts.map +1 -0
- package/support/components/icons.js +131 -0
- package/support/components/icons.js.map +1 -0
- package/support/components/index.d.ts +11 -0
- package/support/components/index.js +12 -0
- package/support/components/multimodal-input.d.ts +28 -0
- package/support/components/multimodal-input.d.ts.map +1 -0
- package/support/components/multimodal-input.js +138 -0
- package/support/components/multimodal-input.js.map +1 -0
- package/support/components/navigation-tab.d.ts +7 -0
- package/support/components/navigation-tab.d.ts.map +1 -0
- package/support/components/navigation-tab.js +40 -0
- package/support/components/navigation-tab.js.map +1 -0
- package/support/components/support-content.d.ts +22 -0
- package/support/components/support-content.d.ts.map +1 -0
- package/support/components/support-content.js +50 -0
- package/support/components/support-content.js.map +1 -0
- package/support/components/text-effect.d.ts +49 -0
- package/support/components/text-effect.d.ts.map +1 -0
- package/support/components/text-effect.js +221 -0
- package/support/components/text-effect.js.map +1 -0
- package/support/components/timeline-message-group.d.ts +16 -0
- package/support/components/timeline-message-group.d.ts.map +1 -0
- package/support/components/timeline-message-group.js +117 -0
- package/support/components/timeline-message-group.js.map +1 -0
- package/support/components/timeline-message-item.d.ts +17 -0
- package/support/components/timeline-message-item.d.ts.map +1 -0
- package/support/components/timeline-message-item.js +42 -0
- package/support/components/timeline-message-item.js.map +1 -0
- package/support/components/typing-indicator.d.ts +26 -0
- package/support/components/typing-indicator.d.ts.map +1 -0
- package/support/components/typing-indicator.js +37 -0
- package/support/components/typing-indicator.js.map +1 -0
- package/support/components/watermark.d.ts +8 -0
- package/support/components/watermark.d.ts.map +1 -0
- package/support/components/watermark.js +34 -0
- package/support/components/watermark.js.map +1 -0
- package/support/context/config.d.ts +32 -0
- package/support/context/config.d.ts.map +1 -0
- package/support/context/config.js +27 -0
- package/support/context/config.js.map +1 -0
- package/support/context/websocket.d.ts +22 -0
- package/support/context/websocket.d.ts.map +1 -0
- package/support/context/websocket.js +113 -0
- package/support/context/websocket.js.map +1 -0
- package/support/index.d.ts +39 -0
- package/support/index.d.ts.map +1 -0
- package/support/index.js +43 -0
- package/support/index.js.map +1 -0
- package/support/pages/articles.d.ts +7 -0
- package/support/pages/articles.d.ts.map +1 -0
- package/support/pages/articles.js +39 -0
- package/support/pages/articles.js.map +1 -0
- package/support/pages/conversation-history.d.ts +18 -0
- package/support/pages/conversation-history.d.ts.map +1 -0
- package/support/pages/conversation-history.js +120 -0
- package/support/pages/conversation-history.js.map +1 -0
- package/support/pages/conversation.d.ts +32 -0
- package/support/pages/conversation.d.ts.map +1 -0
- package/support/pages/conversation.js +92 -0
- package/support/pages/conversation.js.map +1 -0
- package/support/pages/home.d.ts +20 -0
- package/support/pages/home.d.ts.map +1 -0
- package/support/pages/home.js +184 -0
- package/support/pages/home.js.map +1 -0
- package/support/router.d.ts +14 -0
- package/support/router.d.ts.map +1 -0
- package/support/router.js +31 -0
- package/support/router.js.map +1 -0
- package/support/store/index.d.ts +2 -0
- package/support/store/index.js +3 -0
- package/support/store/support-store.d.ts +42 -0
- package/support/store/support-store.d.ts.map +1 -0
- package/support/store/support-store.js +66 -0
- package/support/store/support-store.js.map +1 -0
- package/support/support-CMoDLQoC.css +408 -0
- package/support/support-CMoDLQoC.css.map +1 -0
- package/support/support.js +1 -0
- package/support/text/index.d.ts +35 -0
- package/support/text/index.d.ts.map +1 -0
- package/support/text/index.js +71 -0
- package/support/text/index.js.map +1 -0
- package/support/text/locales/en.d.ts +7 -0
- package/support/text/locales/en.d.ts.map +1 -0
- package/support/text/locales/en.js +65 -0
- package/support/text/locales/en.js.map +1 -0
- package/support/text/locales/es.d.ts +7 -0
- package/support/text/locales/es.d.ts.map +1 -0
- package/support/text/locales/es.js +64 -0
- package/support/text/locales/es.js.map +1 -0
- package/support/text/locales/fr.d.ts +7 -0
- package/support/text/locales/fr.d.ts.map +1 -0
- package/support/text/locales/fr.js +64 -0
- package/support/text/locales/fr.js.map +1 -0
- package/support/text/locales/keys.d.ts +216 -0
- package/support/text/locales/keys.d.ts.map +1 -0
- package/support/text/locales/keys.js +54 -0
- package/support/text/locales/keys.js.map +1 -0
- package/support/text/runtime.d.ts +17 -0
- package/support/text/runtime.d.ts.map +1 -0
- package/support/text/runtime.js +156 -0
- package/support/text/runtime.js.map +1 -0
- package/support/utils/index.d.ts +7 -0
- package/support/utils/index.d.ts.map +1 -0
- package/support/utils/index.js +11 -0
- package/support/utils/index.js.map +1 -0
- package/support/utils/time.d.ts +5 -0
- package/support/utils/time.d.ts.map +1 -0
- package/support/utils/time.js +28 -0
- package/support/utils/time.js.map +1 -0
- package/support-config.d.ts +20 -0
- package/support-config.d.ts.map +1 -0
- package/support-config.js +25 -0
- package/support-config.js.map +1 -0
- package/support.css +2 -0
- package/timeline-item.d.ts +133 -0
- package/timeline-item.d.ts.map +1 -0
- package/utils/id.d.ts +6 -0
- package/utils/id.d.ts.map +1 -0
- package/utils/id.js +13 -0
- package/utils/id.js.map +1 -0
- package/utils/index.d.ts +3 -0
- package/utils/index.js +4 -0
- package/utils/text.d.ts +5 -0
- package/utils/text.d.ts.map +1 -0
- package/utils/text.js +9 -0
- package/utils/text.js.map +1 -0
- package/utils/use-render-element.d.ts +22 -0
- package/utils/use-render-element.d.ts.map +1 -0
- package/utils/use-render-element.js +35 -0
- package/utils/use-render-element.js.map +1 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { cn } from "../utils/index.js";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
8
|
+
|
|
9
|
+
//#region src/support/components/text-effect.tsx
|
|
10
|
+
const SPACE_REGEX = /(\s+)/;
|
|
11
|
+
const defaultStaggerTimes = {
|
|
12
|
+
char: .03,
|
|
13
|
+
word: .05,
|
|
14
|
+
line: .1
|
|
15
|
+
};
|
|
16
|
+
const defaultContainerVariants = {
|
|
17
|
+
hidden: { opacity: 0 },
|
|
18
|
+
visible: {
|
|
19
|
+
opacity: 1,
|
|
20
|
+
transition: { staggerChildren: .05 }
|
|
21
|
+
},
|
|
22
|
+
exit: { transition: {
|
|
23
|
+
staggerChildren: .05,
|
|
24
|
+
staggerDirection: -1
|
|
25
|
+
} }
|
|
26
|
+
};
|
|
27
|
+
const defaultItemVariants = {
|
|
28
|
+
hidden: { opacity: 0 },
|
|
29
|
+
visible: { opacity: 1 },
|
|
30
|
+
exit: { opacity: 0 }
|
|
31
|
+
};
|
|
32
|
+
const presetVariants = {
|
|
33
|
+
blur: {
|
|
34
|
+
container: defaultContainerVariants,
|
|
35
|
+
item: {
|
|
36
|
+
hidden: {
|
|
37
|
+
opacity: 0,
|
|
38
|
+
filter: "blur(12px)"
|
|
39
|
+
},
|
|
40
|
+
visible: {
|
|
41
|
+
opacity: 1,
|
|
42
|
+
filter: "blur(0px)"
|
|
43
|
+
},
|
|
44
|
+
exit: {
|
|
45
|
+
opacity: 0,
|
|
46
|
+
filter: "blur(12px)"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"fade-in-blur": {
|
|
51
|
+
container: defaultContainerVariants,
|
|
52
|
+
item: {
|
|
53
|
+
hidden: {
|
|
54
|
+
opacity: 0,
|
|
55
|
+
y: 20,
|
|
56
|
+
filter: "blur(12px)"
|
|
57
|
+
},
|
|
58
|
+
visible: {
|
|
59
|
+
opacity: 1,
|
|
60
|
+
y: 0,
|
|
61
|
+
filter: "blur(0px)"
|
|
62
|
+
},
|
|
63
|
+
exit: {
|
|
64
|
+
opacity: 0,
|
|
65
|
+
y: 20,
|
|
66
|
+
filter: "blur(12px)"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
scale: {
|
|
71
|
+
container: defaultContainerVariants,
|
|
72
|
+
item: {
|
|
73
|
+
hidden: {
|
|
74
|
+
opacity: 0,
|
|
75
|
+
scale: 0
|
|
76
|
+
},
|
|
77
|
+
visible: {
|
|
78
|
+
opacity: 1,
|
|
79
|
+
scale: 1
|
|
80
|
+
},
|
|
81
|
+
exit: {
|
|
82
|
+
opacity: 0,
|
|
83
|
+
scale: 0
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
fade: {
|
|
88
|
+
container: defaultContainerVariants,
|
|
89
|
+
item: {
|
|
90
|
+
hidden: { opacity: 0 },
|
|
91
|
+
visible: { opacity: 1 },
|
|
92
|
+
exit: { opacity: 0 }
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
slide: {
|
|
96
|
+
container: defaultContainerVariants,
|
|
97
|
+
item: {
|
|
98
|
+
hidden: {
|
|
99
|
+
opacity: 0,
|
|
100
|
+
y: 20
|
|
101
|
+
},
|
|
102
|
+
visible: {
|
|
103
|
+
opacity: 1,
|
|
104
|
+
y: 0
|
|
105
|
+
},
|
|
106
|
+
exit: {
|
|
107
|
+
opacity: 0,
|
|
108
|
+
y: 20
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
const AnimationComponent = React.memo(({ segment, variants, per, segmentWrapperClassName }) => {
|
|
114
|
+
const content = per === "line" ? /* @__PURE__ */ jsx(motion.span, {
|
|
115
|
+
className: "block",
|
|
116
|
+
variants,
|
|
117
|
+
children: segment
|
|
118
|
+
}) : per === "word" ? /* @__PURE__ */ jsx(motion.span, {
|
|
119
|
+
"aria-hidden": "true",
|
|
120
|
+
className: "inline-block whitespace-pre",
|
|
121
|
+
variants,
|
|
122
|
+
children: segment
|
|
123
|
+
}) : /* @__PURE__ */ jsx(motion.span, {
|
|
124
|
+
className: "inline-block whitespace-pre",
|
|
125
|
+
children: segment.split("").map((char, charIndex) => /* @__PURE__ */ jsx(motion.span, {
|
|
126
|
+
"aria-hidden": "true",
|
|
127
|
+
className: "inline-block whitespace-pre",
|
|
128
|
+
variants,
|
|
129
|
+
children: char
|
|
130
|
+
}, `char-${charIndex}`))
|
|
131
|
+
});
|
|
132
|
+
if (!segmentWrapperClassName) return content;
|
|
133
|
+
return /* @__PURE__ */ jsx("span", {
|
|
134
|
+
className: cn(per === "line" ? "block" : "inline-block", segmentWrapperClassName),
|
|
135
|
+
children: content
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
AnimationComponent.displayName = "AnimationComponent";
|
|
139
|
+
const splitText = (text, per) => {
|
|
140
|
+
if (per === "line") return text.split("\n");
|
|
141
|
+
return text.split(SPACE_REGEX);
|
|
142
|
+
};
|
|
143
|
+
const hasTransition = (variant) => {
|
|
144
|
+
if (!variant) return false;
|
|
145
|
+
return typeof variant === "object" && "transition" in variant;
|
|
146
|
+
};
|
|
147
|
+
const createVariantsWithTransition = (baseVariants, transition) => {
|
|
148
|
+
if (!transition) return baseVariants;
|
|
149
|
+
const { exit: _,...mainTransition } = transition;
|
|
150
|
+
return {
|
|
151
|
+
...baseVariants,
|
|
152
|
+
visible: {
|
|
153
|
+
...baseVariants.visible,
|
|
154
|
+
transition: {
|
|
155
|
+
...hasTransition(baseVariants.visible) ? baseVariants.visible.transition : {},
|
|
156
|
+
...mainTransition
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
exit: {
|
|
160
|
+
...baseVariants.exit,
|
|
161
|
+
transition: {
|
|
162
|
+
...hasTransition(baseVariants.exit) ? baseVariants.exit.transition : {},
|
|
163
|
+
...mainTransition,
|
|
164
|
+
staggerDirection: -1
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
function TextEffect({ children, per = "word", as = "p", variants, className, preset = "fade", delay = 0, speedReveal = 1, speedSegment = 1, trigger = true, onAnimationComplete, onAnimationStart, segmentWrapperClassName, containerTransition, segmentTransition, style }) {
|
|
170
|
+
const segments = splitText(Array.isArray(children) ? children.join("") : children, per);
|
|
171
|
+
const MotionTag = motion[as];
|
|
172
|
+
const baseVariants = preset ? presetVariants[preset] : {
|
|
173
|
+
container: defaultContainerVariants,
|
|
174
|
+
item: defaultItemVariants
|
|
175
|
+
};
|
|
176
|
+
const stagger = defaultStaggerTimes[per] / speedReveal;
|
|
177
|
+
const baseDuration = .3 / speedSegment;
|
|
178
|
+
const customStagger = hasTransition(variants?.container?.visible ?? {}) ? (variants?.container?.visible).transition?.staggerChildren : void 0;
|
|
179
|
+
const customDelay = hasTransition(variants?.container?.visible ?? {}) ? (variants?.container?.visible).transition?.delayChildren : void 0;
|
|
180
|
+
const computedVariants = {
|
|
181
|
+
container: createVariantsWithTransition(variants?.container || baseVariants.container, {
|
|
182
|
+
staggerChildren: customStagger ?? stagger,
|
|
183
|
+
delayChildren: customDelay ?? delay,
|
|
184
|
+
...containerTransition,
|
|
185
|
+
exit: {
|
|
186
|
+
staggerChildren: customStagger ?? stagger,
|
|
187
|
+
staggerDirection: -1
|
|
188
|
+
}
|
|
189
|
+
}),
|
|
190
|
+
item: createVariantsWithTransition(variants?.item || baseVariants.item, {
|
|
191
|
+
duration: baseDuration,
|
|
192
|
+
...segmentTransition
|
|
193
|
+
})
|
|
194
|
+
};
|
|
195
|
+
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
196
|
+
mode: "popLayout",
|
|
197
|
+
children: trigger && /* @__PURE__ */ jsxs(MotionTag, {
|
|
198
|
+
animate: "visible",
|
|
199
|
+
className,
|
|
200
|
+
exit: "exit",
|
|
201
|
+
initial: "hidden",
|
|
202
|
+
onAnimationComplete,
|
|
203
|
+
onAnimationStart,
|
|
204
|
+
style,
|
|
205
|
+
variants: computedVariants.container,
|
|
206
|
+
children: [per !== "line" ? /* @__PURE__ */ jsx("span", {
|
|
207
|
+
className: "sr-only",
|
|
208
|
+
children
|
|
209
|
+
}) : null, segments.map((segment, index) => /* @__PURE__ */ jsx(AnimationComponent, {
|
|
210
|
+
per,
|
|
211
|
+
segment,
|
|
212
|
+
segmentWrapperClassName,
|
|
213
|
+
variants: computedVariants.item
|
|
214
|
+
}, `${per}-${index}-${segment}`))]
|
|
215
|
+
})
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
//#endregion
|
|
220
|
+
export { TextEffect };
|
|
221
|
+
//# sourceMappingURL=text-effect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-effect.js","names":["defaultStaggerTimes: Record<PerType, number>","defaultContainerVariants: Variants","defaultItemVariants: Variants","presetVariants: Record<\n\tPresetType,\n\t{ container: Variants; item: Variants }\n>","AnimationComponent: React.FC<{\n\tsegment: string;\n\tvariants: Variants;\n\tper: \"line\" | \"word\" | \"char\";\n\tsegmentWrapperClassName?: string;\n}>"],"sources":["../../../src/support/components/text-effect.tsx"],"sourcesContent":["\"use client\";\nimport type {\n\tTargetAndTransition,\n\tTransition,\n\tVariant,\n\tVariants,\n} from \"motion/react\";\nimport { AnimatePresence, motion } from \"motion/react\";\nimport React from \"react\";\nimport { cn } from \"../utils\";\n\nexport type PresetType = \"blur\" | \"fade-in-blur\" | \"scale\" | \"fade\" | \"slide\";\n\nexport type PerType = \"word\" | \"char\" | \"line\";\n\nconst SPACE_REGEX = /(\\s+)/;\n\nexport type TextEffectProps = {\n\tchildren: string | string[];\n\tper?: PerType;\n\tas?: keyof React.JSX.IntrinsicElements;\n\tvariants?: {\n\t\tcontainer?: Variants;\n\t\titem?: Variants;\n\t};\n\tclassName?: string;\n\tpreset?: PresetType;\n\tdelay?: number;\n\tspeedReveal?: number;\n\tspeedSegment?: number;\n\ttrigger?: boolean;\n\tonAnimationComplete?: () => void;\n\tonAnimationStart?: () => void;\n\tsegmentWrapperClassName?: string;\n\tcontainerTransition?: Transition;\n\tsegmentTransition?: Transition;\n\tstyle?: React.CSSProperties;\n};\n\nconst defaultStaggerTimes: Record<PerType, number> = {\n\tchar: 0.03,\n\tword: 0.05,\n\tline: 0.1,\n};\n\nconst defaultContainerVariants: Variants = {\n\thidden: { opacity: 0 },\n\tvisible: {\n\t\topacity: 1,\n\t\ttransition: {\n\t\t\tstaggerChildren: 0.05,\n\t\t},\n\t},\n\texit: {\n\t\ttransition: { staggerChildren: 0.05, staggerDirection: -1 },\n\t},\n};\n\nconst defaultItemVariants: Variants = {\n\thidden: { opacity: 0 },\n\tvisible: {\n\t\topacity: 1,\n\t},\n\texit: { opacity: 0 },\n};\n\nconst presetVariants: Record<\n\tPresetType,\n\t{ container: Variants; item: Variants }\n> = {\n\tblur: {\n\t\tcontainer: defaultContainerVariants,\n\t\titem: {\n\t\t\thidden: { opacity: 0, filter: \"blur(12px)\" },\n\t\t\tvisible: { opacity: 1, filter: \"blur(0px)\" },\n\t\t\texit: { opacity: 0, filter: \"blur(12px)\" },\n\t\t},\n\t},\n\t\"fade-in-blur\": {\n\t\tcontainer: defaultContainerVariants,\n\t\titem: {\n\t\t\thidden: { opacity: 0, y: 20, filter: \"blur(12px)\" },\n\t\t\tvisible: { opacity: 1, y: 0, filter: \"blur(0px)\" },\n\t\t\texit: { opacity: 0, y: 20, filter: \"blur(12px)\" },\n\t\t},\n\t},\n\tscale: {\n\t\tcontainer: defaultContainerVariants,\n\t\titem: {\n\t\t\thidden: { opacity: 0, scale: 0 },\n\t\t\tvisible: { opacity: 1, scale: 1 },\n\t\t\texit: { opacity: 0, scale: 0 },\n\t\t},\n\t},\n\tfade: {\n\t\tcontainer: defaultContainerVariants,\n\t\titem: {\n\t\t\thidden: { opacity: 0 },\n\t\t\tvisible: { opacity: 1 },\n\t\t\texit: { opacity: 0 },\n\t\t},\n\t},\n\tslide: {\n\t\tcontainer: defaultContainerVariants,\n\t\titem: {\n\t\t\thidden: { opacity: 0, y: 20 },\n\t\t\tvisible: { opacity: 1, y: 0 },\n\t\t\texit: { opacity: 0, y: 20 },\n\t\t},\n\t},\n};\n\nconst AnimationComponent: React.FC<{\n\tsegment: string;\n\tvariants: Variants;\n\tper: \"line\" | \"word\" | \"char\";\n\tsegmentWrapperClassName?: string;\n}> = React.memo(({ segment, variants, per, segmentWrapperClassName }) => {\n\tconst content =\n\t\tper === \"line\" ? (\n\t\t\t<motion.span className=\"block\" variants={variants}>\n\t\t\t\t{segment}\n\t\t\t</motion.span>\n\t\t) : per === \"word\" ? (\n\t\t\t<motion.span\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tclassName=\"inline-block whitespace-pre\"\n\t\t\t\tvariants={variants}\n\t\t\t>\n\t\t\t\t{segment}\n\t\t\t</motion.span>\n\t\t) : (\n\t\t\t<motion.span className=\"inline-block whitespace-pre\">\n\t\t\t\t{segment.split(\"\").map((char, charIndex) => (\n\t\t\t\t\t<motion.span\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tclassName=\"inline-block whitespace-pre\"\n\t\t\t\t\t\tkey={`char-${charIndex}`}\n\t\t\t\t\t\tvariants={variants}\n\t\t\t\t\t>\n\t\t\t\t\t\t{char}\n\t\t\t\t\t</motion.span>\n\t\t\t\t))}\n\t\t\t</motion.span>\n\t\t);\n\n\tif (!segmentWrapperClassName) {\n\t\treturn content;\n\t}\n\n\tconst defaultWrapperClassName = per === \"line\" ? \"block\" : \"inline-block\";\n\n\treturn (\n\t\t<span className={cn(defaultWrapperClassName, segmentWrapperClassName)}>\n\t\t\t{content}\n\t\t</span>\n\t);\n});\n\nAnimationComponent.displayName = \"AnimationComponent\";\n\nconst splitText = (text: string, per: PerType) => {\n\tif (per === \"line\") {\n\t\treturn text.split(\"\\n\");\n\t}\n\treturn text.split(SPACE_REGEX);\n};\n\nconst hasTransition = (\n\tvariant?: Variant\n): variant is TargetAndTransition & { transition?: Transition } => {\n\tif (!variant) {\n\t\treturn false;\n\t}\n\treturn typeof variant === \"object\" && \"transition\" in variant;\n};\n\nconst createVariantsWithTransition = (\n\tbaseVariants: Variants,\n\ttransition?: Transition & { exit?: Transition }\n): Variants => {\n\tif (!transition) {\n\t\treturn baseVariants;\n\t}\n\n\tconst { exit: _, ...mainTransition } = transition;\n\n\treturn {\n\t\t...baseVariants,\n\t\tvisible: {\n\t\t\t...baseVariants.visible,\n\t\t\ttransition: {\n\t\t\t\t...(hasTransition(baseVariants.visible)\n\t\t\t\t\t? baseVariants.visible.transition\n\t\t\t\t\t: {}),\n\t\t\t\t...mainTransition,\n\t\t\t},\n\t\t},\n\t\texit: {\n\t\t\t...baseVariants.exit,\n\t\t\ttransition: {\n\t\t\t\t...(hasTransition(baseVariants.exit)\n\t\t\t\t\t? baseVariants.exit.transition\n\t\t\t\t\t: {}),\n\t\t\t\t...mainTransition,\n\t\t\t\tstaggerDirection: -1,\n\t\t\t},\n\t\t},\n\t};\n};\n\nexport function TextEffect({\n\tchildren,\n\tper = \"word\",\n\tas = \"p\",\n\tvariants,\n\tclassName,\n\tpreset = \"fade\",\n\tdelay = 0,\n\tspeedReveal = 1,\n\tspeedSegment = 1,\n\ttrigger = true,\n\tonAnimationComplete,\n\tonAnimationStart,\n\tsegmentWrapperClassName,\n\tcontainerTransition,\n\tsegmentTransition,\n\tstyle,\n}: TextEffectProps) {\n\tconst segments = splitText(\n\t\tArray.isArray(children) ? children.join(\"\") : children,\n\t\tper\n\t);\n\tconst MotionTag = motion[as as keyof typeof motion] as typeof motion.div;\n\n\tconst baseVariants = preset\n\t\t? presetVariants[preset]\n\t\t: { container: defaultContainerVariants, item: defaultItemVariants };\n\n\tconst stagger = defaultStaggerTimes[per] / speedReveal;\n\n\tconst baseDuration = 0.3 / speedSegment;\n\n\tconst customStagger = hasTransition(variants?.container?.visible ?? {})\n\t\t? (variants?.container?.visible as TargetAndTransition).transition\n\t\t\t\t?.staggerChildren\n\t\t: undefined;\n\n\tconst customDelay = hasTransition(variants?.container?.visible ?? {})\n\t\t? (variants?.container?.visible as TargetAndTransition).transition\n\t\t\t\t?.delayChildren\n\t\t: undefined;\n\n\tconst computedVariants = {\n\t\tcontainer: createVariantsWithTransition(\n\t\t\tvariants?.container || baseVariants.container,\n\t\t\t{\n\t\t\t\tstaggerChildren: customStagger ?? stagger,\n\t\t\t\tdelayChildren: customDelay ?? delay,\n\t\t\t\t...containerTransition,\n\t\t\t\texit: {\n\t\t\t\t\tstaggerChildren: customStagger ?? stagger,\n\t\t\t\t\tstaggerDirection: -1,\n\t\t\t\t},\n\t\t\t}\n\t\t),\n\t\titem: createVariantsWithTransition(variants?.item || baseVariants.item, {\n\t\t\tduration: baseDuration,\n\t\t\t...segmentTransition,\n\t\t}),\n\t};\n\n\treturn (\n\t\t<AnimatePresence mode=\"popLayout\">\n\t\t\t{trigger && (\n\t\t\t\t<MotionTag\n\t\t\t\t\tanimate=\"visible\"\n\t\t\t\t\tclassName={className}\n\t\t\t\t\texit=\"exit\"\n\t\t\t\t\tinitial=\"hidden\"\n\t\t\t\t\tonAnimationComplete={onAnimationComplete}\n\t\t\t\t\tonAnimationStart={onAnimationStart}\n\t\t\t\t\tstyle={style}\n\t\t\t\t\tvariants={computedVariants.container}\n\t\t\t\t>\n\t\t\t\t\t{per !== \"line\" ? <span className=\"sr-only\">{children}</span> : null}\n\t\t\t\t\t{segments.map((segment, index) => (\n\t\t\t\t\t\t<AnimationComponent\n\t\t\t\t\t\t\tkey={`${per}-${index}-${segment}`}\n\t\t\t\t\t\t\tper={per}\n\t\t\t\t\t\t\tsegment={segment}\n\t\t\t\t\t\t\tsegmentWrapperClassName={segmentWrapperClassName}\n\t\t\t\t\t\t\tvariants={computedVariants.item}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</MotionTag>\n\t\t\t)}\n\t\t</AnimatePresence>\n\t);\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TimelineItem } from "../../timeline-item.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { AvailableAIAgent, AvailableHumanAgent } from "@cossistant/types";
|
|
4
|
+
|
|
5
|
+
//#region src/support/components/timeline-message-group.d.ts
|
|
6
|
+
type TimelineMessageGroupProps = {
|
|
7
|
+
items: TimelineItem[];
|
|
8
|
+
availableAIAgents: AvailableAIAgent[];
|
|
9
|
+
availableHumanAgents: AvailableHumanAgent[];
|
|
10
|
+
currentVisitorId?: string;
|
|
11
|
+
seenByIds?: string[];
|
|
12
|
+
};
|
|
13
|
+
declare const TimelineMessageGroup: React.FC<TimelineMessageGroupProps>;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { TimelineMessageGroup, TimelineMessageGroupProps };
|
|
16
|
+
//# sourceMappingURL=timeline-message-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-message-group.d.ts","names":[],"sources":["../../../src/support/components/timeline-message-group.tsx"],"sourcesContent":[],"mappings":";;;;;KAqCY,yBAAA;SACH;EADG,iBAAA,EAES,gBAFgB,EAAA;EAAA,oBAAA,EAGb,mBAHa,EAAA;kBAC5B,CAAA,EAAA,MAAA;WACY,CAAA,EAAA,MAAA,EAAA;;AACsB,cAK9B,oBAL8B,EAKR,KAAA,CAAM,EALE,CAKC,yBALD,CAAA"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { cn } from "../utils/index.js";
|
|
2
|
+
import { Avatar } from "./avatar.js";
|
|
3
|
+
import { CossistantLogo } from "./cossistant-branding.js";
|
|
4
|
+
import { TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupSeenIndicator } from "../../primitives/timeline-item-group.js";
|
|
5
|
+
import { TimelineMessageItem } from "./timeline-message-item.js";
|
|
6
|
+
import { useMemo } from "react";
|
|
7
|
+
import { SenderType } from "@cossistant/types";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { motion } from "motion/react";
|
|
10
|
+
|
|
11
|
+
//#region src/support/components/timeline-message-group.tsx
|
|
12
|
+
const MESSAGE_ANIMATION = {
|
|
13
|
+
initial: {
|
|
14
|
+
opacity: 0,
|
|
15
|
+
y: 6
|
|
16
|
+
},
|
|
17
|
+
animate: {
|
|
18
|
+
opacity: 1,
|
|
19
|
+
y: 0
|
|
20
|
+
},
|
|
21
|
+
exit: { opacity: 0 },
|
|
22
|
+
transition: {
|
|
23
|
+
duration: .1,
|
|
24
|
+
ease: [
|
|
25
|
+
.25,
|
|
26
|
+
.46,
|
|
27
|
+
.45,
|
|
28
|
+
.94
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const SEEN_ANIMATION = {
|
|
33
|
+
initial: { opacity: 0 },
|
|
34
|
+
animate: { opacity: 1 },
|
|
35
|
+
transition: {
|
|
36
|
+
duration: .1,
|
|
37
|
+
ease: "easeOut"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const TimelineMessageGroup = ({ items, availableAIAgents, availableHumanAgents, currentVisitorId, seenByIds = [] }) => {
|
|
41
|
+
const firstItem = items[0];
|
|
42
|
+
const humanAgent = availableHumanAgents.find((agent) => agent.id === firstItem?.userId);
|
|
43
|
+
const aiAgent = availableAIAgents.find((agent) => agent.id === firstItem?.aiAgentId);
|
|
44
|
+
const seenByNames = useMemo(() => {
|
|
45
|
+
const deduped = /* @__PURE__ */ new Set();
|
|
46
|
+
for (const id of seenByIds) {
|
|
47
|
+
const human = availableHumanAgents.find((agent) => agent.id === id);
|
|
48
|
+
if (human?.name) {
|
|
49
|
+
deduped.add(human.name);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
const ai = availableAIAgents.find((agent) => agent.id === id);
|
|
53
|
+
if (ai?.name) deduped.add(ai.name);
|
|
54
|
+
}
|
|
55
|
+
return Array.from(deduped);
|
|
56
|
+
}, [
|
|
57
|
+
seenByIds,
|
|
58
|
+
availableHumanAgents,
|
|
59
|
+
availableAIAgents
|
|
60
|
+
]);
|
|
61
|
+
if (items.length === 0) return null;
|
|
62
|
+
const hasSeenIndicator = seenByIds.length > 0 && seenByNames.length > 0;
|
|
63
|
+
return /* @__PURE__ */ jsx(TimelineItemGroup, {
|
|
64
|
+
items,
|
|
65
|
+
seenByIds,
|
|
66
|
+
viewerId: currentVisitorId,
|
|
67
|
+
viewerType: SenderType.VISITOR,
|
|
68
|
+
children: ({ isSentByViewer, isReceivedByViewer, isVisitor, isAI, isTeamMember }) => /* @__PURE__ */ jsxs("div", {
|
|
69
|
+
className: cn("flex w-full gap-2", isSentByViewer && "flex-row-reverse", isReceivedByViewer && "flex-row"),
|
|
70
|
+
children: [isReceivedByViewer && /* @__PURE__ */ jsx(TimelineItemGroupAvatar, {
|
|
71
|
+
className: "flex flex-shrink-0 flex-col justify-end",
|
|
72
|
+
children: isAI ? /* @__PURE__ */ jsx("div", {
|
|
73
|
+
className: "flex size-6 items-center justify-center rounded-full bg-primary/10",
|
|
74
|
+
children: /* @__PURE__ */ jsx(CossistantLogo, { className: "h-4 w-4 text-primary" })
|
|
75
|
+
}) : /* @__PURE__ */ jsx(Avatar, {
|
|
76
|
+
className: "size-6",
|
|
77
|
+
image: humanAgent?.image,
|
|
78
|
+
name: humanAgent?.name || "Support"
|
|
79
|
+
})
|
|
80
|
+
}), /* @__PURE__ */ jsxs(TimelineItemGroupContent, {
|
|
81
|
+
className: cn("flex flex-col gap-1", isSentByViewer && "items-end"),
|
|
82
|
+
children: [
|
|
83
|
+
isReceivedByViewer && /* @__PURE__ */ jsx(TimelineItemGroupHeader, {
|
|
84
|
+
className: "px-1 text-muted-foreground text-xs",
|
|
85
|
+
children: isAI ? aiAgent?.name || "AI Assistant" : humanAgent?.name || "Support"
|
|
86
|
+
}),
|
|
87
|
+
items.map((item, index) => /* @__PURE__ */ jsx(motion.div, {
|
|
88
|
+
...MESSAGE_ANIMATION,
|
|
89
|
+
children: /* @__PURE__ */ jsx(TimelineMessageItem, {
|
|
90
|
+
isLast: index === items.length - 1,
|
|
91
|
+
isSentByViewer,
|
|
92
|
+
item
|
|
93
|
+
})
|
|
94
|
+
}, item.id)),
|
|
95
|
+
isSentByViewer && /* @__PURE__ */ jsx("div", {
|
|
96
|
+
className: cn("", hasSeenIndicator && "mt-2"),
|
|
97
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
98
|
+
className: "min-h-[1.25rem]",
|
|
99
|
+
children: hasSeenIndicator && /* @__PURE__ */ jsx(motion.div, {
|
|
100
|
+
...SEEN_ANIMATION,
|
|
101
|
+
children: /* @__PURE__ */ jsx(TimelineItemGroupSeenIndicator, {
|
|
102
|
+
className: "px-1 text-muted-foreground text-xs",
|
|
103
|
+
seenByIds,
|
|
104
|
+
children: () => `Seen by ${seenByNames.join(", ")}`
|
|
105
|
+
})
|
|
106
|
+
}, "seen-indicator")
|
|
107
|
+
})
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
})]
|
|
111
|
+
})
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
export { TimelineMessageGroup };
|
|
117
|
+
//# sourceMappingURL=timeline-message-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-message-group.js","names":["TimelineMessageGroup: React.FC<TimelineMessageGroupProps>","PrimitiveTimelineItemGroup"],"sources":["../../../src/support/components/timeline-message-group.tsx"],"sourcesContent":["import type { AvailableAIAgent, AvailableHumanAgent } from \"@cossistant/types\";\nimport { SenderType } from \"@cossistant/types\";\nimport type { TimelineItem } from \"@cossistant/types/api/timeline-item\";\nimport { motion } from \"motion/react\";\nimport type React from \"react\";\nimport { useMemo } from \"react\";\nimport {\n TimelineItemGroup as PrimitiveTimelineItemGroup,\n TimelineItemGroupAvatar,\n TimelineItemGroupContent,\n TimelineItemGroupHeader,\n TimelineItemGroupSeenIndicator,\n} from \"../../primitives/timeline-item-group\";\nimport { cn } from \"../utils\";\nimport { Avatar } from \"./avatar\";\nimport { CossistantLogo } from \"./cossistant-branding\";\nimport { TimelineMessageItem } from \"./timeline-message-item\";\n\nconst MESSAGE_ANIMATION = {\n initial: { opacity: 0, y: 6 },\n animate: { opacity: 1, y: 0 },\n exit: { opacity: 0 },\n transition: {\n duration: 0.1,\n ease: [0.25, 0.46, 0.45, 0.94] as const, // easeOutCubic\n },\n} as const;\n\nconst SEEN_ANIMATION = {\n initial: { opacity: 0 },\n animate: { opacity: 1 },\n transition: {\n duration: 0.1,\n ease: \"easeOut\" as const,\n },\n} as const;\n\nexport type TimelineMessageGroupProps = {\n items: TimelineItem[];\n availableAIAgents: AvailableAIAgent[];\n availableHumanAgents: AvailableHumanAgent[];\n currentVisitorId?: string;\n seenByIds?: string[];\n};\n\nexport const TimelineMessageGroup: React.FC<TimelineMessageGroupProps> = ({\n items,\n availableAIAgents,\n availableHumanAgents,\n currentVisitorId,\n seenByIds = [],\n}) => {\n // Get agent info for the sender\n const firstItem = items[0];\n const humanAgent = availableHumanAgents.find(\n (agent) => agent.id === firstItem?.userId\n );\n const aiAgent = availableAIAgents.find(\n (agent) => agent.id === firstItem?.aiAgentId\n );\n\n const seenByNames = useMemo(() => {\n const deduped = new Set<string>();\n for (const id of seenByIds) {\n const human = availableHumanAgents.find((agent) => agent.id === id);\n if (human?.name) {\n deduped.add(human.name);\n continue;\n }\n const ai = availableAIAgents.find((agent) => agent.id === id);\n if (ai?.name) {\n deduped.add(ai.name);\n }\n }\n return Array.from(deduped);\n }, [seenByIds, availableHumanAgents, availableAIAgents]);\n\n if (items.length === 0) {\n return null;\n }\n\n const hasSeenIndicator = seenByIds.length > 0 && seenByNames.length > 0;\n\n return (\n <PrimitiveTimelineItemGroup\n items={items}\n seenByIds={seenByIds}\n viewerId={currentVisitorId}\n viewerType={SenderType.VISITOR}\n >\n {({\n isSentByViewer,\n isReceivedByViewer,\n isVisitor,\n isAI,\n isTeamMember,\n }) => (\n <div\n className={cn(\n \"flex w-full gap-2\",\n // Support widget POV: visitor messages are sent (right side)\n // Agent messages are received (left side)\n isSentByViewer && \"flex-row-reverse\",\n isReceivedByViewer && \"flex-row\"\n )}\n >\n {/* Avatar - only show for received messages (agents) */}\n {isReceivedByViewer && (\n <TimelineItemGroupAvatar className=\"flex flex-shrink-0 flex-col justify-end\">\n {isAI ? (\n <div className=\"flex size-6 items-center justify-center rounded-full bg-primary/10\">\n <CossistantLogo className=\"h-4 w-4 text-primary\" />\n </div>\n ) : (\n <Avatar\n className=\"size-6\"\n image={humanAgent?.image}\n name={humanAgent?.name || \"Support\"}\n />\n )}\n </TimelineItemGroupAvatar>\n )}\n\n <TimelineItemGroupContent\n className={cn(\"flex flex-col gap-1\", isSentByViewer && \"items-end\")}\n >\n {/* Header - show sender name for received messages (agents) */}\n {isReceivedByViewer && (\n <TimelineItemGroupHeader className=\"px-1 text-muted-foreground text-xs\">\n {isAI\n ? aiAgent?.name || \"AI Assistant\"\n : humanAgent?.name || \"Support\"}\n </TimelineItemGroupHeader>\n )}\n\n {items.map((item, index) => (\n <motion.div key={item.id} {...MESSAGE_ANIMATION}>\n <TimelineMessageItem\n isLast={index === items.length - 1}\n isSentByViewer={isSentByViewer}\n item={item}\n />\n </motion.div>\n ))}\n\n {isSentByViewer && (\n <div className={cn(\"\", hasSeenIndicator && \"mt-2\")}>\n <div className=\"min-h-[1.25rem]\">\n {hasSeenIndicator && (\n <motion.div key=\"seen-indicator\" {...SEEN_ANIMATION}>\n <TimelineItemGroupSeenIndicator\n className=\"px-1 text-muted-foreground text-xs\"\n seenByIds={seenByIds}\n >\n {() => `Seen by ${seenByNames.join(\", \")}`}\n </TimelineItemGroupSeenIndicator>\n </motion.div>\n )}\n </div>\n </div>\n )}\n </TimelineItemGroupContent>\n </div>\n )}\n </PrimitiveTimelineItemGroup>\n );\n};\n"],"mappings":";;;;;;;;;;;AAkBA,MAAM,oBAAoB;CACxB,SAAS;EAAE,SAAS;EAAG,GAAG;EAAG;CAC7B,SAAS;EAAE,SAAS;EAAG,GAAG;EAAG;CAC7B,MAAM,EAAE,SAAS,GAAG;CACpB,YAAY;EACV,UAAU;EACV,MAAM;GAAC;GAAM;GAAM;GAAM;GAAK;EAC/B;CACF;AAED,MAAM,iBAAiB;CACrB,SAAS,EAAE,SAAS,GAAG;CACvB,SAAS,EAAE,SAAS,GAAG;CACvB,YAAY;EACV,UAAU;EACV,MAAM;EACP;CACF;AAUD,MAAaA,wBAA6D,EACxE,OACA,mBACA,sBACA,kBACA,YAAY,EAAE,OACV;CAEJ,MAAM,YAAY,MAAM;CACxB,MAAM,aAAa,qBAAqB,MACrC,UAAU,MAAM,OAAO,WAAW,OACpC;CACD,MAAM,UAAU,kBAAkB,MAC/B,UAAU,MAAM,OAAO,WAAW,UACpC;CAED,MAAM,cAAc,cAAc;EAChC,MAAM,0BAAU,IAAI,KAAa;AACjC,OAAK,MAAM,MAAM,WAAW;GAC1B,MAAM,QAAQ,qBAAqB,MAAM,UAAU,MAAM,OAAO,GAAG;AACnE,OAAI,OAAO,MAAM;AACf,YAAQ,IAAI,MAAM,KAAK;AACvB;;GAEF,MAAM,KAAK,kBAAkB,MAAM,UAAU,MAAM,OAAO,GAAG;AAC7D,OAAI,IAAI,KACN,SAAQ,IAAI,GAAG,KAAK;;AAGxB,SAAO,MAAM,KAAK,QAAQ;IACzB;EAAC;EAAW;EAAsB;EAAkB,CAAC;AAExD,KAAI,MAAM,WAAW,EACnB,QAAO;CAGT,MAAM,mBAAmB,UAAU,SAAS,KAAK,YAAY,SAAS;AAEtE,QACE,oBAACC;EACQ;EACI;EACX,UAAU;EACV,YAAY,WAAW;aAErB,EACA,gBACA,oBACA,WACA,MACA,mBAEA,qBAAC;GACC,WAAW,GACT,qBAGA,kBAAkB,oBAClB,sBAAsB,WACvB;cAGA,sBACC,oBAAC;IAAwB,WAAU;cAChC,OACC,oBAAC;KAAI,WAAU;eACb,oBAAC,kBAAe,WAAU,yBAAyB;MAC/C,GAEN,oBAAC;KACC,WAAU;KACV,OAAO,YAAY;KACnB,MAAM,YAAY,QAAQ;MAC1B;KAEoB,EAG5B,qBAAC;IACC,WAAW,GAAG,uBAAuB,kBAAkB,YAAY;;KAGlE,sBACC,oBAAC;MAAwB,WAAU;gBAChC,OACG,SAAS,QAAQ,iBACjB,YAAY,QAAQ;OACA;KAG3B,MAAM,KAAK,MAAM,UAChB,oBAAC,OAAO;MAAkB,GAAI;gBAC5B,oBAAC;OACC,QAAQ,UAAU,MAAM,SAAS;OACjB;OACV;QACN;QALa,KAAK,GAMT,CACb;KAED,kBACC,oBAAC;MAAI,WAAW,GAAG,IAAI,oBAAoB,OAAO;gBAChD,oBAAC;OAAI,WAAU;iBACZ,oBACC,oBAAC,OAAO;QAAyB,GAAI;kBACnC,oBAAC;SACC,WAAU;SACC;yBAEJ,WAAW,YAAY,KAAK,KAAK;UACT;UANnB,iBAOH;QAEX;OACF;;KAEiB;IACvB;GAEmB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TimelineItem } from "../../timeline-item.js";
|
|
2
|
+
import * as react_jsx_runtime8 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/support/components/timeline-message-item.d.ts
|
|
5
|
+
type TimelineMessageItemProps = {
|
|
6
|
+
item: TimelineItem;
|
|
7
|
+
isLast?: boolean;
|
|
8
|
+
isSentByViewer?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare function TimelineMessageItem({
|
|
11
|
+
item,
|
|
12
|
+
isLast,
|
|
13
|
+
isSentByViewer
|
|
14
|
+
}: TimelineMessageItemProps): react_jsx_runtime8.JSX.Element;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { TimelineMessageItem, TimelineMessageItemProps };
|
|
17
|
+
//# sourceMappingURL=timeline-message-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-message-item.d.ts","names":[],"sources":["../../../src/support/components/timeline-message-item.tsx"],"sourcesContent":[],"mappings":";;;;KAUY,wBAAA;QACL;;EADK,cAAA,CAAA,EAAA,OAAA;AAMZ,CAAA;AAAmC,iBAAnB,mBAAA,CAAmB;EAAA,IAAA;EAAA,MAAA;EAAA;AAAA,CAAA,EAIhC,wBAJgC,CAAA,EAIR,kBAAA,CAAA,GAAA,CAAA,OAJQ"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { cn } from "../utils/index.js";
|
|
2
|
+
import { TimelineItem, TimelineItemContent, TimelineItemTimestamp } from "../../primitives/timeline-item.js";
|
|
3
|
+
import { useSupportText } from "../text/index.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/support/components/timeline-message-item.tsx
|
|
7
|
+
function TimelineMessageItem({ item, isLast = false, isSentByViewer }) {
|
|
8
|
+
const text = useSupportText();
|
|
9
|
+
return /* @__PURE__ */ jsx(TimelineItem, {
|
|
10
|
+
item,
|
|
11
|
+
children: ({ isVisitor, isAI, timestamp }) => {
|
|
12
|
+
const isSentByViewerFinal = isSentByViewer ?? isVisitor;
|
|
13
|
+
return /* @__PURE__ */ jsx("div", {
|
|
14
|
+
className: cn("flex w-full gap-2", isSentByViewerFinal && "flex-row-reverse", !isSentByViewerFinal && "flex-row"),
|
|
15
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
16
|
+
className: cn("flex w-full flex-1 flex-col gap-1", isSentByViewerFinal && "items-end"),
|
|
17
|
+
children: [/* @__PURE__ */ jsx(TimelineItemContent, {
|
|
18
|
+
className: cn("block w-max max-w-[300px] rounded-lg px-3.5 py-2.5 text-sm", {
|
|
19
|
+
"bg-co-background-300 text-foreground dark:bg-co-background-600": !isSentByViewerFinal,
|
|
20
|
+
"bg-primary text-primary-foreground": isSentByViewerFinal,
|
|
21
|
+
"rounded-br-sm": isLast && isSentByViewerFinal,
|
|
22
|
+
"rounded-bl-sm": isLast && !isSentByViewerFinal
|
|
23
|
+
}),
|
|
24
|
+
renderMarkdown: true,
|
|
25
|
+
text: item.text
|
|
26
|
+
}), isLast && /* @__PURE__ */ jsx(TimelineItemTimestamp, {
|
|
27
|
+
className: "px-1 text-muted-foreground text-xs",
|
|
28
|
+
timestamp,
|
|
29
|
+
children: () => /* @__PURE__ */ jsxs(Fragment, { children: [timestamp.toLocaleTimeString([], {
|
|
30
|
+
hour: "2-digit",
|
|
31
|
+
minute: "2-digit"
|
|
32
|
+
}), isAI && ` ${text("component.message.timestamp.aiIndicator")}`] })
|
|
33
|
+
})]
|
|
34
|
+
})
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { TimelineMessageItem };
|
|
42
|
+
//# sourceMappingURL=timeline-message-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-message-item.js","names":["PrimitiveTimelineItem"],"sources":["../../../src/support/components/timeline-message-item.tsx"],"sourcesContent":["import type { TimelineItem } from \"@cossistant/types/api/timeline-item\";\nimport type React from \"react\";\nimport {\n\tTimelineItem as PrimitiveTimelineItem,\n\tTimelineItemContent,\n\tTimelineItemTimestamp,\n} from \"../../primitives/timeline-item\";\nimport { useSupportText } from \"../text\";\nimport { cn } from \"../utils\";\n\nexport type TimelineMessageItemProps = {\n\titem: TimelineItem;\n\tisLast?: boolean;\n\tisSentByViewer?: boolean;\n};\n\nexport function TimelineMessageItem({\n\titem,\n\tisLast = false,\n\tisSentByViewer,\n}: TimelineMessageItemProps) {\n\tconst text = useSupportText();\n\treturn (\n\t\t<PrimitiveTimelineItem item={item}>\n\t\t\t{({ isVisitor, isAI, timestamp }) => {\n\t\t\t\t// Use passed isSentByViewer if provided, otherwise fall back to isVisitor\n\t\t\t\tconst isSentByViewerFinal = isSentByViewer ?? isVisitor;\n\n\t\t\t\treturn (\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\"flex w-full gap-2\",\n\t\t\t\t\t\t\tisSentByViewerFinal && \"flex-row-reverse\",\n\t\t\t\t\t\t\t!isSentByViewerFinal && \"flex-row\"\n\t\t\t\t\t\t)}\n\t\t\t\t\t>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\"flex w-full flex-1 flex-col gap-1\",\n\t\t\t\t\t\t\t\tisSentByViewerFinal && \"items-end\"\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TimelineItemContent\n\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t\"block w-max max-w-[300px] rounded-lg px-3.5 py-2.5 text-sm\",\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"bg-co-background-300 text-foreground dark:bg-co-background-600\":\n\t\t\t\t\t\t\t\t\t\t\t!isSentByViewerFinal,\n\t\t\t\t\t\t\t\t\t\t\"bg-primary text-primary-foreground\": isSentByViewerFinal,\n\t\t\t\t\t\t\t\t\t\t\"rounded-br-sm\": isLast && isSentByViewerFinal,\n\t\t\t\t\t\t\t\t\t\t\"rounded-bl-sm\": isLast && !isSentByViewerFinal,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\trenderMarkdown\n\t\t\t\t\t\t\t\ttext={item.text}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{isLast && (\n\t\t\t\t\t\t\t\t<TimelineItemTimestamp\n\t\t\t\t\t\t\t\t\tclassName=\"px-1 text-muted-foreground text-xs\"\n\t\t\t\t\t\t\t\t\ttimestamp={timestamp}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{() => (\n\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t{timestamp.toLocaleTimeString([], {\n\t\t\t\t\t\t\t\t\t\t\t\thour: \"2-digit\",\n\t\t\t\t\t\t\t\t\t\t\t\tminute: \"2-digit\",\n\t\t\t\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t\t\t\t\t{isAI &&\n\t\t\t\t\t\t\t\t\t\t\t\t` ${text(\"component.message.timestamp.aiIndicator\")}`}\n\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</TimelineItemTimestamp>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t);\n\t\t\t}}\n\t\t</PrimitiveTimelineItem>\n\t);\n}\n"],"mappings":";;;;;;AAgBA,SAAgB,oBAAoB,EACnC,MACA,SAAS,OACT,kBAC4B;CAC5B,MAAM,OAAO,gBAAgB;AAC7B,QACC,oBAACA;EAA4B;aAC1B,EAAE,WAAW,MAAM,gBAAgB;GAEpC,MAAM,sBAAsB,kBAAkB;AAE9C,UACC,oBAAC;IACA,WAAW,GACV,qBACA,uBAAuB,oBACvB,CAAC,uBAAuB,WACxB;cAED,qBAAC;KACA,WAAW,GACV,qCACA,uBAAuB,YACvB;gBAED,oBAAC;MACA,WAAW,GACV,8DACA;OACC,kEACC,CAAC;OACF,sCAAsC;OACtC,iBAAiB,UAAU;OAC3B,iBAAiB,UAAU,CAAC;OAC5B,CACD;MACD;MACA,MAAM,KAAK;OACV,EACD,UACA,oBAAC;MACA,WAAU;MACC;sBAGV,4CACE,UAAU,mBAAmB,EAAE,EAAE;OACjC,MAAM;OACN,QAAQ;OACR,CAAC,EACD,QACA,IAAI,KAAK,0CAA0C,MAClD;OAEmB;MAEpB;KACD;;GAGe"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
import { AvailableAIAgent, AvailableHumanAgent } from "@cossistant/types";
|
|
3
|
+
import * as react_jsx_runtime9 from "react/jsx-runtime";
|
|
4
|
+
|
|
5
|
+
//#region src/support/components/typing-indicator.d.ts
|
|
6
|
+
type TypingParticipantType = "visitor" | "team_member" | "ai";
|
|
7
|
+
type TypingParticipant = {
|
|
8
|
+
id: string;
|
|
9
|
+
type: TypingParticipantType;
|
|
10
|
+
};
|
|
11
|
+
type TypingIndicatorProps = React$1.HTMLAttributes<HTMLDivElement> & {
|
|
12
|
+
participants: TypingParticipant[];
|
|
13
|
+
availableAIAgents?: AvailableAIAgent[];
|
|
14
|
+
availableHumanAgents?: AvailableHumanAgent[];
|
|
15
|
+
withAvatars?: boolean;
|
|
16
|
+
};
|
|
17
|
+
declare const BouncingDots: () => react_jsx_runtime9.JSX.Element;
|
|
18
|
+
declare const TypingIndicator: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & {
|
|
19
|
+
participants: TypingParticipant[];
|
|
20
|
+
availableAIAgents?: AvailableAIAgent[];
|
|
21
|
+
availableHumanAgents?: AvailableHumanAgent[];
|
|
22
|
+
withAvatars?: boolean;
|
|
23
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { BouncingDots, TypingIndicator, TypingIndicatorProps, TypingParticipant, TypingParticipantType };
|
|
26
|
+
//# sourceMappingURL=typing-indicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typing-indicator.d.ts","names":[],"sources":["../../../src/support/components/typing-indicator.tsx"],"sourcesContent":[],"mappings":";;;;;KAKY,qBAAA;KAEA,iBAAA;;EAFA,IAAA,EAIL,qBAJ0B;AAEjC,CAAA;AAKY,KAAA,oBAAA,GAAuB,OAAA,CAAM,cAAT,CAAwB,cAAxB,CAAA,GAAA;EAAA,YAAA,EACjB,iBADiB,EAAA;mBAAwB,CAAA,EAEnC,gBAFmC,EAAA;sBAAf,CAAA,EAGjB,mBAHiB,EAAA;aAC1B,CAAA,EAAA,OAAA;;AAES,cAIX,YAJW,EAAA,GAAA,GAIC,kBAAA,CAAA,GAAA,CAAA,OAJD;AAAmB,cAY9B,eAZ8B,EAYf,OAAA,CAAA,yBAZe,CAYf,OAAA,CAAA,cAZe,CAYf,cAZe,CAAA,GAAA;EAI9B,YAAA,EANE,iBAMU,EAAA;EAQZ,iBAAA,CAuDZ,EApEoB,gBAoEpB,EAAA;EAAA,oBAAA,CAAA,EAnEuB,mBAmEvB,EAAA;aAvD2B,CAAA,EAAA,OAAA;yBAAA,eAAA,CAAA,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { cn } from "../utils/index.js";
|
|
2
|
+
import { AvatarStack } from "./avatar-stack.js";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
|
|
6
|
+
//#region src/support/components/typing-indicator.tsx
|
|
7
|
+
const BouncingDots = () => /* @__PURE__ */ jsxs("div", {
|
|
8
|
+
className: "flex gap-1",
|
|
9
|
+
children: [
|
|
10
|
+
/* @__PURE__ */ jsx("span", { className: "dot-bounce-1 size-1 rounded-full bg-co-primary" }),
|
|
11
|
+
/* @__PURE__ */ jsx("span", { className: "dot-bounce-2 size-1 rounded-full bg-co-primary" }),
|
|
12
|
+
/* @__PURE__ */ jsx("span", { className: "dot-bounce-3 size-1 rounded-full bg-co-primary" })
|
|
13
|
+
]
|
|
14
|
+
});
|
|
15
|
+
const TypingIndicator = React$1.forwardRef(({ participants, availableAIAgents = [], availableHumanAgents = [], withAvatars = true, className,...props }, ref) => {
|
|
16
|
+
if (!participants || participants.length === 0) return null;
|
|
17
|
+
const humanParticipantIds = participants.filter((p) => p.type === "team_member").map((p) => p.id);
|
|
18
|
+
const aiParticipantIds = participants.filter((p) => p.type === "ai").map((p) => p.id);
|
|
19
|
+
const typingHumanAgents = availableHumanAgents.filter((agent) => humanParticipantIds.includes(agent.id));
|
|
20
|
+
const typingAIAgents = availableAIAgents.filter((agent) => aiParticipantIds.includes(agent.id));
|
|
21
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
22
|
+
className: cn("flex items-center gap-6", className),
|
|
23
|
+
ref,
|
|
24
|
+
...props,
|
|
25
|
+
children: [withAvatars && /* @__PURE__ */ jsx(AvatarStack, {
|
|
26
|
+
aiAgents: typingAIAgents,
|
|
27
|
+
humanAgents: typingHumanAgents,
|
|
28
|
+
size: 24,
|
|
29
|
+
spacing: 16
|
|
30
|
+
}), /* @__PURE__ */ jsx(BouncingDots, {})]
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
TypingIndicator.displayName = "TypingIndicator";
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { BouncingDots, TypingIndicator };
|
|
37
|
+
//# sourceMappingURL=typing-indicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typing-indicator.js","names":["React"],"sources":["../../../src/support/components/typing-indicator.tsx"],"sourcesContent":["import type { AvailableAIAgent, AvailableHumanAgent } from \"@cossistant/types\";\nimport * as React from \"react\";\nimport { cn } from \"../utils\";\nimport { AvatarStack } from \"./avatar-stack\";\n\nexport type TypingParticipantType = \"visitor\" | \"team_member\" | \"ai\";\n\nexport type TypingParticipant = {\n\tid: string;\n\ttype: TypingParticipantType;\n};\n\nexport type TypingIndicatorProps = React.HTMLAttributes<HTMLDivElement> & {\n\tparticipants: TypingParticipant[];\n\tavailableAIAgents?: AvailableAIAgent[];\n\tavailableHumanAgents?: AvailableHumanAgent[];\n\twithAvatars?: boolean;\n};\n\nexport const BouncingDots = () => (\n\t<div className=\"flex gap-1\">\n\t\t<span className=\"dot-bounce-1 size-1 rounded-full bg-co-primary\" />\n\t\t<span className=\"dot-bounce-2 size-1 rounded-full bg-co-primary\" />\n\t\t<span className=\"dot-bounce-3 size-1 rounded-full bg-co-primary\" />\n\t</div>\n);\n\nexport const TypingIndicator = React.forwardRef<\n\tHTMLDivElement,\n\tTypingIndicatorProps\n>(\n\t(\n\t\t{\n\t\t\tparticipants,\n\t\t\tavailableAIAgents = [],\n\t\t\tavailableHumanAgents = [],\n\t\t\twithAvatars = true,\n\t\t\tclassName,\n\t\t\t...props\n\t\t},\n\t\tref\n\t) => {\n\t\tif (!participants || participants.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// Separate AI and human participants\n\t\tconst humanParticipantIds = participants\n\t\t\t.filter((p) => p.type === \"team_member\")\n\t\t\t.map((p) => p.id);\n\n\t\tconst aiParticipantIds = participants\n\t\t\t.filter((p) => p.type === \"ai\")\n\t\t\t.map((p) => p.id);\n\n\t\t// Get matching agents\n\t\tconst typingHumanAgents = availableHumanAgents.filter((agent) =>\n\t\t\thumanParticipantIds.includes(agent.id)\n\t\t);\n\n\t\tconst typingAIAgents = availableAIAgents.filter((agent) =>\n\t\t\taiParticipantIds.includes(agent.id)\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tclassName={cn(\"flex items-center gap-6\", className)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t>\n\t\t\t\t{withAvatars && (\n\t\t\t\t\t<AvatarStack\n\t\t\t\t\t\taiAgents={typingAIAgents}\n\t\t\t\t\t\thumanAgents={typingHumanAgents}\n\t\t\t\t\t\tsize={24}\n\t\t\t\t\t\tspacing={16}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<BouncingDots />\n\t\t\t</div>\n\t\t);\n\t}\n);\n\nTypingIndicator.displayName = \"TypingIndicator\";\n"],"mappings":";;;;;;AAmBA,MAAa,qBACZ,qBAAC;CAAI,WAAU;;EACd,oBAAC,UAAK,WAAU,mDAAmD;EACnE,oBAAC,UAAK,WAAU,mDAAmD;EACnE,oBAAC,UAAK,WAAU,mDAAmD;;EAC9D;AAGP,MAAa,kBAAkBA,QAAM,YAKnC,EACC,cACA,oBAAoB,EAAE,EACtB,uBAAuB,EAAE,EACzB,cAAc,MACd,UACA,GAAG,SAEJ,QACI;AACJ,KAAI,CAAC,gBAAgB,aAAa,WAAW,EAC5C,QAAO;CAIR,MAAM,sBAAsB,aAC1B,QAAQ,MAAM,EAAE,SAAS,cAAc,CACvC,KAAK,MAAM,EAAE,GAAG;CAElB,MAAM,mBAAmB,aACvB,QAAQ,MAAM,EAAE,SAAS,KAAK,CAC9B,KAAK,MAAM,EAAE,GAAG;CAGlB,MAAM,oBAAoB,qBAAqB,QAAQ,UACtD,oBAAoB,SAAS,MAAM,GAAG,CACtC;CAED,MAAM,iBAAiB,kBAAkB,QAAQ,UAChD,iBAAiB,SAAS,MAAM,GAAG,CACnC;AAED,QACC,qBAAC;EACA,WAAW,GAAG,2BAA2B,UAAU;EAC9C;EACL,GAAI;aAEH,eACA,oBAAC;GACA,UAAU;GACV,aAAa;GACb,MAAM;GACN,SAAS;IACR,EAEH,oBAAC,iBAAe;GACX;EAGR;AAED,gBAAgB,cAAc"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watermark.d.ts","names":[],"sources":["../../../src/support/components/watermark.tsx"],"sourcesContent":[],"mappings":";KAMY,cAAA;EAAA,SAAA,CAAA,EAAA,MAAc;AAI1B,CAAA;AAmCC,cAnCY,SAmCZ,EAnCuB,KAAA,CAAM,EAmC7B,CAnCgC,cAmChC,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { cn } from "../utils/index.js";
|
|
2
|
+
import { CossistantLogo } from "./cossistant-branding.js";
|
|
3
|
+
import { Text } from "../text/index.js";
|
|
4
|
+
import { useSupport } from "../../provider.js";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/support/components/watermark.tsx
|
|
9
|
+
const Watermark = ({ className }) => {
|
|
10
|
+
const { website } = useSupport();
|
|
11
|
+
const cossistantUrl = useMemo(() => {
|
|
12
|
+
if (!website) return "https://cossistant.com";
|
|
13
|
+
const url = new URL("https://cossistant.com");
|
|
14
|
+
url.searchParams.set("ref", "chatbox");
|
|
15
|
+
url.searchParams.set("domain", website.domain);
|
|
16
|
+
url.searchParams.set("name", website.name);
|
|
17
|
+
return url.toString();
|
|
18
|
+
}, [website]);
|
|
19
|
+
return /* @__PURE__ */ jsxs("a", {
|
|
20
|
+
className: cn("flex items-center gap-1.5 font-medium font-mono text-co-primary hover:text-co-blue", className),
|
|
21
|
+
href: cossistantUrl,
|
|
22
|
+
rel: "noopener noreferrer",
|
|
23
|
+
target: "_blank",
|
|
24
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
25
|
+
as: "span",
|
|
26
|
+
className: "text-co-muted-foreground text-xs",
|
|
27
|
+
textKey: "common.brand.watermark"
|
|
28
|
+
}), /* @__PURE__ */ jsx(CossistantLogo, { className: "h-3" })]
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { Watermark };
|
|
34
|
+
//# sourceMappingURL=watermark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"watermark.js","names":["Watermark: React.FC<WatermarkProps>"],"sources":["../../../src/support/components/watermark.tsx"],"sourcesContent":["import { useSupport } from \"@cossistant/react\";\nimport { useMemo } from \"react\";\nimport { Text } from \"../text\";\nimport { cn } from \"../utils\";\nimport { CossistantLogo } from \"./cossistant-branding\";\n\nexport type WatermarkProps = {\n\tclassName?: string;\n};\n\nexport const Watermark: React.FC<WatermarkProps> = ({ className }) => {\n\tconst { website } = useSupport();\n\n\tconst cossistantUrl = useMemo(() => {\n\t\tif (!website) {\n\t\t\treturn \"https://cossistant.com\";\n\t\t}\n\n\t\tconst url = new URL(\"https://cossistant.com\");\n\n\t\turl.searchParams.set(\"ref\", \"chatbox\");\n\t\turl.searchParams.set(\"domain\", website.domain);\n\t\turl.searchParams.set(\"name\", website.name);\n\n\t\treturn url.toString();\n\t}, [website]);\n\n\treturn (\n\t\t<a\n\t\t\tclassName={cn(\n\t\t\t\t\"flex items-center gap-1.5 font-medium font-mono text-co-primary hover:text-co-blue\",\n\t\t\t\tclassName\n\t\t\t)}\n\t\t\thref={cossistantUrl}\n\t\t\trel=\"noopener noreferrer\"\n\t\t\ttarget=\"_blank\"\n\t\t>\n\t\t\t<Text\n\t\t\t\tas=\"span\"\n\t\t\t\tclassName=\"text-co-muted-foreground text-xs\"\n\t\t\t\ttextKey=\"common.brand.watermark\"\n\t\t\t/>\n\t\t\t<CossistantLogo className=\"h-3\" />\n\t\t</a>\n\t);\n};\n"],"mappings":";;;;;;;;AAUA,MAAaA,aAAuC,EAAE,gBAAgB;CACrE,MAAM,EAAE,YAAY,YAAY;CAEhC,MAAM,gBAAgB,cAAc;AACnC,MAAI,CAAC,QACJ,QAAO;EAGR,MAAM,MAAM,IAAI,IAAI,yBAAyB;AAE7C,MAAI,aAAa,IAAI,OAAO,UAAU;AACtC,MAAI,aAAa,IAAI,UAAU,QAAQ,OAAO;AAC9C,MAAI,aAAa,IAAI,QAAQ,QAAQ,KAAK;AAE1C,SAAO,IAAI,UAAU;IACnB,CAAC,QAAQ,CAAC;AAEb,QACC,qBAAC;EACA,WAAW,GACV,sFACA,UACA;EACD,MAAM;EACN,KAAI;EACJ,QAAO;aAEP,oBAAC;GACA,IAAG;GACH,WAAU;GACV,SAAQ;IACP,EACF,oBAAC,kBAAe,WAAU,QAAQ;GAC/B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/support/context/config.d.ts
|
|
4
|
+
type SupportConfigSetters = {
|
|
5
|
+
open: () => void;
|
|
6
|
+
close: () => void;
|
|
7
|
+
toggle: () => void;
|
|
8
|
+
};
|
|
9
|
+
declare const useSupportConfig: () => {
|
|
10
|
+
open: () => void;
|
|
11
|
+
close: () => void;
|
|
12
|
+
toggle: () => void;
|
|
13
|
+
mode: "floating" | "responsive";
|
|
14
|
+
size: "normal" | "larger";
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
content: {
|
|
17
|
+
home?: {
|
|
18
|
+
header?: string;
|
|
19
|
+
subheader?: string;
|
|
20
|
+
ctaLabel?: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
declare const SupportConfigProvider: React.FC<{
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
mode?: "floating" | "responsive";
|
|
27
|
+
size?: "normal" | "larger";
|
|
28
|
+
defaultOpen?: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { SupportConfigProvider, SupportConfigSetters, useSupportConfig };
|
|
32
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","names":[],"sources":["../../../src/support/context/config.tsx"],"sourcesContent":[],"mappings":";;;KASY,oBAAA;;EAAA,KAAA,EAAA,GAAA,GAAA,IAAA;EAMC,MAAA,EAAA,GAAA,GAAA,IAAA;AAEb,CAAA;AAgBC,cAlBY,gBAkBZ,EAAA,GAAA,GAAA;MAfU,EAAA,GAAM,GAAA,IAAA;OADmB,EAAA,GAAM,GAAA,IAAA;EAAE,MAAA,EAAA,GAAA,GAAA,IAAA;;;;;;;;;;;;cAA/B,uBAAuB,KAAA,CAAM;YAC/B,KAAA,CAAM"}
|