@cossistant/react 0.0.26 → 0.0.28
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/api.d.ts +1 -1
- package/api.d.ts.map +1 -1
- package/checks.d.ts +1 -1
- package/checks.d.ts.map +1 -1
- package/clsx.d.ts +1 -1
- package/clsx.d.ts.map +1 -1
- package/coerce.d.ts +1 -1
- package/coerce.d.ts.map +1 -1
- package/conversation.d.ts +3 -0
- package/conversation.d.ts.map +1 -1
- package/core.d.ts +1 -1
- package/core.d.ts.map +1 -1
- package/errors.d.ts +1 -1
- package/errors.d.ts.map +1 -1
- package/errors2.d.ts +1 -1
- package/errors2.d.ts.map +1 -1
- package/hooks/index.d.ts +2 -1
- package/hooks/index.js +6 -5
- package/hooks/private/store/use-website-store.js +2 -1
- package/hooks/private/store/use-website-store.js.map +1 -1
- package/hooks/private/use-client-query.d.ts +6 -0
- package/hooks/private/use-client-query.d.ts.map +1 -1
- package/hooks/private/use-client-query.js +26 -3
- package/hooks/private/use-client-query.js.map +1 -1
- package/hooks/private/use-multimodal-input.d.ts.map +1 -1
- package/hooks/private/use-multimodal-input.js +7 -5
- package/hooks/private/use-multimodal-input.js.map +1 -1
- package/hooks/private/use-visitor-typing-reporter.d.ts +18 -1
- package/hooks/private/use-visitor-typing-reporter.d.ts.map +1 -1
- package/hooks/private/use-visitor-typing-reporter.js +34 -4
- package/hooks/private/use-visitor-typing-reporter.js.map +1 -1
- package/hooks/use-conversation-page.d.ts +1 -0
- package/hooks/use-conversation-page.d.ts.map +1 -1
- package/hooks/use-conversation-page.js +6 -1
- package/hooks/use-conversation-page.js.map +1 -1
- package/hooks/use-conversation-preview.d.ts +2 -1
- package/hooks/use-conversation-preview.d.ts.map +1 -1
- package/hooks/use-conversation-preview.js +1 -1
- package/hooks/use-conversation-preview.js.map +1 -1
- package/hooks/use-conversation-timeline-items.js +2 -1
- package/hooks/use-conversation-timeline-items.js.map +1 -1
- package/hooks/use-conversation.js +2 -1
- package/hooks/use-conversation.js.map +1 -1
- package/hooks/use-conversations.js +1 -0
- package/hooks/use-conversations.js.map +1 -1
- package/hooks/use-create-conversation.d.ts.map +1 -1
- package/hooks/use-file-upload.d.ts +55 -0
- package/hooks/use-file-upload.d.ts.map +1 -0
- package/hooks/use-file-upload.js +100 -0
- package/hooks/use-file-upload.js.map +1 -0
- package/hooks/use-message-composer.d.ts +11 -0
- package/hooks/use-message-composer.d.ts.map +1 -1
- package/hooks/use-message-composer.js +7 -3
- package/hooks/use-message-composer.js.map +1 -1
- package/hooks/use-send-message.d.ts +1 -0
- package/hooks/use-send-message.d.ts.map +1 -1
- package/hooks/use-send-message.js +63 -11
- package/hooks/use-send-message.js.map +1 -1
- package/index.d.ts +6 -3
- package/index.js +13 -10
- package/openapi30.d.ts +1 -1
- package/openapi30.d.ts.map +1 -1
- package/openapi31.d.ts +1 -1
- package/openapi31.d.ts.map +1 -1
- package/package.json +4 -3
- package/parse.d.ts +1 -1
- package/parse.d.ts.map +1 -1
- package/primitives/avatar/image.d.ts +1 -1
- package/primitives/conversation-timeline.d.ts.map +1 -1
- package/primitives/conversation-timeline.js +10 -5
- package/primitives/conversation-timeline.js.map +1 -1
- package/primitives/index.d.ts +4 -3
- package/primitives/index.js +12 -5
- package/primitives/index.parts.d.ts +3 -2
- package/primitives/index.parts.js +4 -3
- package/primitives/multimodal-input.d.ts +2 -2
- package/primitives/multimodal-input.d.ts.map +1 -1
- package/primitives/timeline-item-attachments.d.ts +100 -0
- package/primitives/timeline-item-attachments.d.ts.map +1 -0
- package/primitives/timeline-item-attachments.js +151 -0
- package/primitives/timeline-item-attachments.js.map +1 -0
- package/primitives/trigger.d.ts +91 -0
- package/primitives/trigger.d.ts.map +1 -0
- package/primitives/trigger.js +74 -0
- package/primitives/trigger.js.map +1 -0
- package/primitives/window.d.ts +22 -1
- package/primitives/window.d.ts.map +1 -1
- package/primitives/window.js +91 -5
- package/primitives/window.js.map +1 -1
- package/provider.d.ts.map +1 -1
- package/provider.js +8 -3
- package/provider.js.map +1 -1
- package/realtime/index.js +1 -1
- package/realtime/provider.js +1 -1
- package/realtime/support-provider.js +1 -1
- package/realtime/support-provider.js.map +1 -1
- package/realtime-events.d.ts +40 -1
- package/realtime-events.d.ts.map +1 -1
- package/registries.d.ts +1 -1
- package/registries.d.ts.map +1 -1
- package/schemas.d.ts +1 -1
- package/schemas.d.ts.map +1 -1
- package/schemas2.d.ts +1 -1
- package/schemas2.d.ts.map +1 -1
- package/schemas3.d.ts +1 -0
- package/schemas3.d.ts.map +1 -1
- package/specification-extension.d.ts +1 -1
- package/specification-extension.d.ts.map +1 -1
- package/standard-schema.d.ts +1 -1
- package/standard-schema.d.ts.map +1 -1
- package/support/components/content.d.ts +30 -0
- package/support/components/content.d.ts.map +1 -0
- package/support/components/content.js +282 -0
- package/support/components/content.js.map +1 -0
- package/support/components/conversation-button-link.js +1 -1
- package/support/components/conversation-timeline.js +3 -3
- package/support/components/conversation-timeline.js.map +1 -1
- package/support/components/header.js +1 -1
- package/support/components/image-lightbox.d.ts +49 -0
- package/support/components/image-lightbox.d.ts.map +1 -0
- package/support/components/image-lightbox.js +142 -0
- package/support/components/image-lightbox.js.map +1 -0
- package/support/components/index.d.ts +5 -4
- package/support/components/index.js +4 -4
- package/support/components/multimodal-input.d.ts +4 -1
- package/support/components/multimodal-input.d.ts.map +1 -1
- package/support/components/multimodal-input.js +71 -45
- package/support/components/multimodal-input.js.map +1 -1
- package/support/components/navigation-tab.js +1 -1
- package/support/components/root.d.ts +23 -0
- package/support/components/root.d.ts.map +1 -0
- package/support/components/root.js +36 -0
- package/support/components/root.js.map +1 -0
- package/support/components/timeline-message-item.d.ts.map +1 -1
- package/support/components/timeline-message-item.js +82 -18
- package/support/components/timeline-message-item.js.map +1 -1
- package/support/components/trigger.d.ts +14 -0
- package/support/components/trigger.d.ts.map +1 -0
- package/support/components/{bubble.js → trigger.js} +16 -12
- package/support/components/trigger.js.map +1 -0
- package/support/components/typing-indicator.d.ts.map +1 -1
- package/support/components/typing-indicator.js +1 -0
- package/support/components/typing-indicator.js.map +1 -1
- package/support/context/controlled-state.d.ts +46 -0
- package/support/context/controlled-state.d.ts.map +1 -0
- package/support/context/controlled-state.js +34 -0
- package/support/context/controlled-state.js.map +1 -0
- package/support/context/events.d.ts +103 -0
- package/support/context/events.d.ts.map +1 -0
- package/support/context/events.js +139 -0
- package/support/context/events.js.map +1 -0
- package/support/context/handle.d.ts +90 -0
- package/support/context/handle.d.ts.map +1 -0
- package/support/context/handle.js +79 -0
- package/support/context/handle.js.map +1 -0
- package/support/context/positioning.d.ts +17 -0
- package/support/context/positioning.d.ts.map +1 -0
- package/support/context/positioning.js +26 -0
- package/support/context/positioning.js.map +1 -0
- package/support/context/slots.d.ts +85 -0
- package/support/context/slots.d.ts.map +1 -0
- package/support/context/slots.js +115 -0
- package/support/context/slots.js.map +1 -0
- package/support/context/websocket.d.ts +8 -1
- package/support/context/websocket.d.ts.map +1 -1
- package/support/context/websocket.js +8 -1
- package/support/context/websocket.js.map +1 -1
- package/support/index.d.ts +239 -54
- package/support/index.d.ts.map +1 -1
- package/support/index.js +254 -33
- package/support/index.js.map +1 -1
- package/support/pages/articles.d.ts.map +1 -1
- package/support/pages/articles.js +3 -4
- package/support/pages/articles.js.map +1 -1
- package/support/pages/conversation-history.js +2 -2
- package/support/pages/conversation.js +6 -5
- package/support/pages/conversation.js.map +1 -1
- package/support/pages/home.js +2 -2
- package/support/router.d.ts +52 -12
- package/support/router.d.ts.map +1 -1
- package/support/router.js +78 -30
- package/support/router.js.map +1 -1
- package/support/store/index.d.ts +2 -2
- package/support/store/support-store.d.ts +26 -20
- package/support/store/support-store.d.ts.map +1 -1
- package/support/store/support-store.js +47 -6
- package/support/store/support-store.js.map +1 -1
- package/support/{support-D2EgfIts.css → support-C7Xaw-N6.css} +1 -2
- package/support/support-C7Xaw-N6.css.map +1 -0
- package/support/text/index.js.map +1 -1
- package/support/types.d.ts +75 -12
- package/support/types.d.ts.map +1 -1
- package/support.css +2 -2
- package/tailwind.css +0 -1
- package/timeline-item.d.ts +68 -2
- package/timeline-item.d.ts.map +1 -1
- package/util.d.ts +1 -1
- package/util.d.ts.map +1 -1
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -1
- package/utils/merge-refs.d.ts +30 -0
- package/utils/merge-refs.d.ts.map +1 -0
- package/utils/merge-refs.js +46 -0
- package/utils/merge-refs.js.map +1 -0
- package/utils/use-render-element.d.ts.map +1 -1
- package/utils/use-render-element.js +20 -7
- package/utils/use-render-element.js.map +1 -1
- package/versions.d.ts +1 -1
- package/versions.d.ts.map +1 -1
- package/zod-extensions.d.ts +1 -1
- package/zod-extensions.d.ts.map +1 -1
- package/primitives/bubble.d.ts +0 -38
- package/primitives/bubble.d.ts.map +0 -1
- package/primitives/bubble.js +0 -57
- package/primitives/bubble.js.map +0 -1
- package/support/components/bubble.d.ts +0 -10
- package/support/components/bubble.d.ts.map +0 -1
- package/support/components/bubble.js.map +0 -1
- package/support/components/container.d.ts +0 -13
- package/support/components/container.d.ts.map +0 -1
- package/support/components/container.js +0 -109
- package/support/components/container.js.map +0 -1
- package/support/components/support-content.d.ts +0 -22
- package/support/components/support-content.d.ts.map +0 -1
- package/support/components/support-content.js +0 -48
- package/support/components/support-content.js.map +0 -1
- package/support/support-D2EgfIts.css.map +0 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { SupportConfig } from "../support-config.js";
|
|
2
1
|
import { Avatar } from "./avatar/avatar.js";
|
|
3
2
|
import { AvatarFallback } from "./avatar/fallback.js";
|
|
4
3
|
import { AvatarImage } from "./avatar/image.js";
|
|
5
4
|
import { TypingIndicator } from "../support/components/typing-indicator.js";
|
|
6
|
-
import {
|
|
5
|
+
import { SupportConfig } from "../support-config.js";
|
|
7
6
|
import { Button } from "./button.js";
|
|
8
7
|
import { ConversationTimeline, ConversationTimelineContainer, ConversationTimelineEmpty, ConversationTimelineLoading } from "./conversation-timeline.js";
|
|
9
8
|
import { FileInput, MultimodalInput, SupportInput } from "./multimodal-input.js";
|
|
10
9
|
import { Router } from "./router.js";
|
|
11
10
|
import { TimelineItem, TimelineItemContent, TimelineItemTimestamp } from "./timeline-item.js";
|
|
11
|
+
import { TimelineItemAttachments, TimelineItemFiles, TimelineItemImages, extractFileParts, extractImageParts, hasAttachments } from "./timeline-item-attachments.js";
|
|
12
12
|
import { TimelineItemGroup, TimelineItemGroupAvatar, TimelineItemGroupContent, TimelineItemGroupHeader, TimelineItemGroupReadIndicator, TimelineItemGroupSeenIndicator } from "./timeline-item-group.js";
|
|
13
|
+
import { SupportTrigger } from "./trigger.js";
|
|
13
14
|
import { SupportWindow } from "./window.js";
|
|
14
15
|
|
|
15
|
-
export { Avatar, AvatarFallback, AvatarImage,
|
|
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 };
|
|
@@ -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>, "onChange" | "value"> & {
|
|
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>, "onChange" | "value"> & {
|
|
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,YAAA,CAAA,EAAA,CAAA,KAAc,EAxHF,IAwHE,EAAA,EAAA,GAAA,IAAA;EAA6B,OAAA,CAAA,EAAA,OAAA;EAA1B,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,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EAAA,QAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EA4GhB,YAAA,CAAA,EAAA,CAAA,KAAc,EAxHF,IAwHE,EAAA,EAAA,GAAA,IAAA;EAA6B,OAAA,CAAA,EAAA,OAAA;EAA1B,SAAM,CAAA,EAAA,MAAA;EACX,KAAA,CAAA,EAtHf,KAsHe,GAAA,IAAA;EAAI,QAAA,CAAA,EAAA,OAAA;AAQ5B,CAAA,wBAkCI,oBAAA,CAAA,CAAA;AAlCkB,KATV,cAAA,GAAiB,OAAA,CAAM,mBASb,CATiC,gBASjC,CAAA,GAAA;EAAA,YAAA,CAAA,EAAA,CAAA,KAAA,EARE,IAQF,EAAA,EAAA,GAAA,IAAA;EARE,OAAA,CAAA,EAAA,OAAA;;;;;AA6CxB;AAAyB,cArCZ,SAqCY,EArCH,OAAA,CAAA,yBAqCG,CArCH,OAAA,CAAA,mBAqCG,CArCH,gBAqCG,CAAA,GAAA;EAAA,YAAA,CAAA,EAAA,CAAA,KAAA,EA7CD,IA6CC,EAAA,EAAA,GAAA,IAAA;EAAA,OAAA,CAAA,EAAA,OAAA;CAtKD,wBAAA,iBAAA,CAAA,CAAA;AAGf,cAmKI,YAnKJ,EAmKgB,OAAA,CAAA,yBAnKhB,CAmKgB,IAnKhB,CAmKgB,OAAA,CAAA,sBAnKhB,CAmKgB,mBAnKhB,CAAA,EAAA,UAAA,GAAA,OAAA,CAAA,GAAA;;;EAmKgB,QAAA,CAAA,EAAA,GAAA,GAAA,IAAA;EAAA,YAAA,CAAA,EAAA,CAAA,KAAA,EAtKD,IAsKC,EAAA,EAAA,GAAA,IAAA;;;UAnKhB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { TimelineItemParts, TimelinePartFile, TimelinePartImage } from "../timeline-item.js";
|
|
2
|
+
import * as React$1 from "react";
|
|
3
|
+
|
|
4
|
+
//#region src/primitives/timeline-item-attachments.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Extract image parts from timeline item parts array.
|
|
8
|
+
*/
|
|
9
|
+
declare function extractImageParts(parts: TimelineItemParts): TimelinePartImage[];
|
|
10
|
+
/**
|
|
11
|
+
* Extract file parts from timeline item parts array.
|
|
12
|
+
*/
|
|
13
|
+
declare function extractFileParts(parts: TimelineItemParts): TimelinePartFile[];
|
|
14
|
+
/**
|
|
15
|
+
* Check if timeline item has any attachments (images or files).
|
|
16
|
+
*/
|
|
17
|
+
declare function hasAttachments(parts: TimelineItemParts): boolean;
|
|
18
|
+
type TimelineItemImagesProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
19
|
+
children?: React$1.ReactNode | ((images: TimelinePartImage[], onImageClick?: (index: number) => void) => React$1.ReactNode);
|
|
20
|
+
asChild?: boolean;
|
|
21
|
+
className?: string;
|
|
22
|
+
images: TimelinePartImage[];
|
|
23
|
+
/**
|
|
24
|
+
* Callback when an image is clicked (for lightbox).
|
|
25
|
+
*/
|
|
26
|
+
onImageClick?: (index: number) => void;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Renders a grid of image thumbnails from timeline item parts.
|
|
30
|
+
* Supports custom rendering via children render prop.
|
|
31
|
+
*/
|
|
32
|
+
declare const TimelineItemImages: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
33
|
+
children?: React$1.ReactNode | ((images: TimelinePartImage[], onImageClick?: (index: number) => void) => React$1.ReactNode);
|
|
34
|
+
asChild?: boolean;
|
|
35
|
+
className?: string;
|
|
36
|
+
images: TimelinePartImage[];
|
|
37
|
+
/**
|
|
38
|
+
* Callback when an image is clicked (for lightbox).
|
|
39
|
+
*/
|
|
40
|
+
onImageClick?: (index: number) => void;
|
|
41
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
42
|
+
type TimelineItemFilesProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
43
|
+
children?: React$1.ReactNode | ((files: TimelinePartFile[]) => React$1.ReactNode);
|
|
44
|
+
asChild?: boolean;
|
|
45
|
+
className?: string;
|
|
46
|
+
files: TimelinePartFile[];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Renders a list of file attachments from timeline item parts.
|
|
50
|
+
* Supports custom rendering via children render prop.
|
|
51
|
+
*/
|
|
52
|
+
declare const TimelineItemFiles: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
53
|
+
children?: React$1.ReactNode | ((files: TimelinePartFile[]) => React$1.ReactNode);
|
|
54
|
+
asChild?: boolean;
|
|
55
|
+
className?: string;
|
|
56
|
+
files: TimelinePartFile[];
|
|
57
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
58
|
+
type TimelineItemAttachmentsProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
59
|
+
children?: React$1.ReactNode;
|
|
60
|
+
asChild?: boolean;
|
|
61
|
+
className?: string;
|
|
62
|
+
parts: TimelineItemParts;
|
|
63
|
+
/**
|
|
64
|
+
* Callback when an image is clicked (for lightbox).
|
|
65
|
+
*/
|
|
66
|
+
onImageClick?: (index: number) => void;
|
|
67
|
+
/**
|
|
68
|
+
* Custom className for the images container.
|
|
69
|
+
*/
|
|
70
|
+
imagesClassName?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Custom className for the files container.
|
|
73
|
+
*/
|
|
74
|
+
filesClassName?: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Convenience component that renders both images and files from timeline parts.
|
|
78
|
+
* Extracts the appropriate parts and renders them in a single container.
|
|
79
|
+
*/
|
|
80
|
+
declare const TimelineItemAttachments: React$1.ForwardRefExoticComponent<Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
81
|
+
children?: React$1.ReactNode;
|
|
82
|
+
asChild?: boolean;
|
|
83
|
+
className?: string;
|
|
84
|
+
parts: TimelineItemParts;
|
|
85
|
+
/**
|
|
86
|
+
* Callback when an image is clicked (for lightbox).
|
|
87
|
+
*/
|
|
88
|
+
onImageClick?: (index: number) => void;
|
|
89
|
+
/**
|
|
90
|
+
* Custom className for the images container.
|
|
91
|
+
*/
|
|
92
|
+
imagesClassName?: string;
|
|
93
|
+
/**
|
|
94
|
+
* Custom className for the files container.
|
|
95
|
+
*/
|
|
96
|
+
filesClassName?: string;
|
|
97
|
+
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
98
|
+
//#endregion
|
|
99
|
+
export { TimelineItemAttachments, TimelineItemAttachmentsProps, TimelineItemFiles, TimelineItemFilesProps, TimelineItemImages, TimelineItemImagesProps, extractFileParts, extractImageParts, hasAttachments };
|
|
100
|
+
//# sourceMappingURL=timeline-item-attachments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline-item-attachments.d.ts","names":[],"sources":["../../src/primitives/timeline-item-attachments.tsx"],"sourcesContent":[],"mappings":";;;;;;;AAcA;AAWgB,iBAXA,iBAAA,CAWwB,KAAA,EAVhC,iBAUoD,CAAA,EATzD,iBASyE,EAAA;AAO5E;AAQA;;AACC,iBAhBe,gBAAA,CAgBT,KAAA,EAhBiC,iBAgBjC,CAAA,EAhBqD,gBAgBrD,EAAA;;;;AAQE,iBAjBO,cAAA,CAiBD,KAAA,EAjBuB,iBAiBvB,CAAA,EAAA,OAAA;AAGN,KAZG,uBAAA,GAA0B,IAY7B,CAXR,OAAA,CAAM,cAWE,CAXa,cAWb,CAAA,EAAA,UAAA,CAAA,GAAA;EAAiB,QAAA,CAAA,EAPtB,OAAA,CAAM,SAOgB,GAAA,CAAA,CAAA,MAAA,EALd,iBAKc,EAAA,EAAA,YAAA,CAAA,EAAA,CAAA,KAAA,EAAA,MAAA,EAAA,GAAA,IAAA,EAAA,GAHjB,OAAA,CAAM,SAGW,CAAA;EAWb,OAAA,CAAA,EAAA,OAAA;EAAkB,SAAA,CAAA,EAAA,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FD,gBAyFC,EAAA,EAAA,GAzFsB,OAAA,CAAM,SAyF5B,CAAA;EAClB,OAAA,CAAA,EAAA,OAAA;EAArB,SAAM,CAAA,EAAA,MAAA;EADoC,KAAA,EAtFnC,gBAsFmC,EAAA;CAI/B,wBAAM,eAAA,CAAA,CAAA;AAGV,KAPI,4BAAA,GAA+B,IAOnC,CANP,OAAA,CAAM,cAMC,CANc,cAMd,CAAA,EAAA,UAAA,CAAA,GAAA;EAAiB,QAAA,CAAA,EAHb,OAAA,CAAM,SAGO;EAmBZ,OAAA,CAAA,EAAA,OAAA;EAAuB,SAAA,CAAA,EAAA,MAAA;EAAA,KAAA,EAnB5B,iBAmB4B;EAAA;;;;;;;;;;;;;;;;;cAAvB,yBAAuB,OAAA,CAAA,0BAAA,KAAA,OAAA,CAAA,eAAA;aAtBxB,OAAA,CAAM;;;SAGV"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import { useRenderElement } from "../utils/use-render-element.js";
|
|
5
|
+
import * as React$1 from "react";
|
|
6
|
+
import { formatFileSize } from "@cossistant/core";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
|
|
9
|
+
//#region src/primitives/timeline-item-attachments.tsx
|
|
10
|
+
/**
|
|
11
|
+
* Extract image parts from timeline item parts array.
|
|
12
|
+
*/
|
|
13
|
+
function extractImageParts(parts) {
|
|
14
|
+
return parts.filter((part) => part.type === "image");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Extract file parts from timeline item parts array.
|
|
18
|
+
*/
|
|
19
|
+
function extractFileParts(parts) {
|
|
20
|
+
return parts.filter((part) => part.type === "file");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check if timeline item has any attachments (images or files).
|
|
24
|
+
*/
|
|
25
|
+
function hasAttachments(parts) {
|
|
26
|
+
return parts.some((part) => part.type === "image" || part.type === "file");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Renders a grid of image thumbnails from timeline item parts.
|
|
30
|
+
* Supports custom rendering via children render prop.
|
|
31
|
+
*/
|
|
32
|
+
const TimelineItemImages = (() => {
|
|
33
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, images, onImageClick,...props }, ref) => {
|
|
34
|
+
if (images.length === 0) return null;
|
|
35
|
+
const content = typeof children === "function" ? children(images, onImageClick) : children || /* @__PURE__ */ jsx("div", {
|
|
36
|
+
className: "flex flex-wrap gap-2",
|
|
37
|
+
children: images.map((image, index) => /* @__PURE__ */ jsx("button", {
|
|
38
|
+
className: "group relative overflow-hidden rounded-lg focus:outline-none focus:ring-2 focus:ring-offset-2",
|
|
39
|
+
onClick: () => onImageClick?.(index),
|
|
40
|
+
type: "button",
|
|
41
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
42
|
+
alt: image.fileName || `Image ${index + 1}`,
|
|
43
|
+
className: "max-h-[200px] max-w-[300px] cursor-pointer rounded-lg object-cover transition-transform group-hover:scale-105",
|
|
44
|
+
loading: "lazy",
|
|
45
|
+
src: image.url
|
|
46
|
+
})
|
|
47
|
+
}, image.url))
|
|
48
|
+
});
|
|
49
|
+
return useRenderElement("div", {
|
|
50
|
+
className,
|
|
51
|
+
asChild
|
|
52
|
+
}, {
|
|
53
|
+
ref,
|
|
54
|
+
props: {
|
|
55
|
+
...props,
|
|
56
|
+
children: content
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
Component.displayName = "TimelineItemImages";
|
|
61
|
+
return Component;
|
|
62
|
+
})();
|
|
63
|
+
/**
|
|
64
|
+
* Get file icon based on MIME type.
|
|
65
|
+
*/
|
|
66
|
+
function getFileIcon(mediaType) {
|
|
67
|
+
if (mediaType === "application/pdf") return "📄";
|
|
68
|
+
if (mediaType === "application/zip") return "🗜️";
|
|
69
|
+
if (mediaType.startsWith("text/")) return "📝";
|
|
70
|
+
return "📎";
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Renders a list of file attachments from timeline item parts.
|
|
74
|
+
* Supports custom rendering via children render prop.
|
|
75
|
+
*/
|
|
76
|
+
const TimelineItemFiles = (() => {
|
|
77
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, files,...props }, ref) => {
|
|
78
|
+
if (files.length === 0) return null;
|
|
79
|
+
const content = typeof children === "function" ? children(files) : children || /* @__PURE__ */ jsx("div", {
|
|
80
|
+
className: "flex flex-col gap-2",
|
|
81
|
+
children: files.map((file) => /* @__PURE__ */ jsxs("a", {
|
|
82
|
+
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.fileName,
|
|
84
|
+
href: file.url,
|
|
85
|
+
rel: "noopener noreferrer",
|
|
86
|
+
target: "_blank",
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ jsx("span", {
|
|
89
|
+
className: "text-lg",
|
|
90
|
+
children: getFileIcon(file.mediaType)
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ jsx("span", {
|
|
93
|
+
className: "flex-1 truncate font-medium",
|
|
94
|
+
children: file.fileName || "Download file"
|
|
95
|
+
}),
|
|
96
|
+
file.size && /* @__PURE__ */ jsx("span", {
|
|
97
|
+
className: "text-co-muted-foreground text-xs",
|
|
98
|
+
children: formatFileSize(file.size)
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
}, file.url))
|
|
102
|
+
});
|
|
103
|
+
return useRenderElement("div", {
|
|
104
|
+
className,
|
|
105
|
+
asChild
|
|
106
|
+
}, {
|
|
107
|
+
ref,
|
|
108
|
+
props: {
|
|
109
|
+
...props,
|
|
110
|
+
children: content
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
Component.displayName = "TimelineItemFiles";
|
|
115
|
+
return Component;
|
|
116
|
+
})();
|
|
117
|
+
/**
|
|
118
|
+
* Convenience component that renders both images and files from timeline parts.
|
|
119
|
+
* Extracts the appropriate parts and renders them in a single container.
|
|
120
|
+
*/
|
|
121
|
+
const TimelineItemAttachments = (() => {
|
|
122
|
+
const Component = React$1.forwardRef(({ children, className, asChild = false, parts, onImageClick, imagesClassName, filesClassName,...props }, ref) => {
|
|
123
|
+
const images = extractImageParts(parts);
|
|
124
|
+
const files = extractFileParts(parts);
|
|
125
|
+
if (images.length === 0 && files.length === 0) return null;
|
|
126
|
+
const content = children || /* @__PURE__ */ jsxs(Fragment, { children: [images.length > 0 && /* @__PURE__ */ jsx(TimelineItemImages, {
|
|
127
|
+
className: imagesClassName,
|
|
128
|
+
images,
|
|
129
|
+
onImageClick
|
|
130
|
+
}), files.length > 0 && /* @__PURE__ */ jsx(TimelineItemFiles, {
|
|
131
|
+
className: filesClassName,
|
|
132
|
+
files
|
|
133
|
+
})] });
|
|
134
|
+
return useRenderElement("div", {
|
|
135
|
+
className,
|
|
136
|
+
asChild
|
|
137
|
+
}, {
|
|
138
|
+
ref,
|
|
139
|
+
props: {
|
|
140
|
+
...props,
|
|
141
|
+
children: content
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
Component.displayName = "TimelineItemAttachments";
|
|
146
|
+
return Component;
|
|
147
|
+
})();
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
export { TimelineItemAttachments, TimelineItemFiles, TimelineItemImages, extractFileParts, extractImageParts, hasAttachments };
|
|
151
|
+
//# sourceMappingURL=timeline-item-attachments.js.map
|
|
@@ -0,0 +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,WAAW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ACN,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"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import * as React$1 from "react";
|
|
2
|
+
|
|
3
|
+
//#region src/primitives/trigger.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Render props provided to the Trigger's children function.
|
|
7
|
+
*/
|
|
8
|
+
type TriggerRenderProps = {
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
unreadCount: number;
|
|
11
|
+
isTyping: boolean;
|
|
12
|
+
toggle: () => void;
|
|
13
|
+
};
|
|
14
|
+
type TriggerProps = Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, "children"> & {
|
|
15
|
+
/**
|
|
16
|
+
* Content to render inside the trigger.
|
|
17
|
+
* Can be a ReactNode or a function that receives render props.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Static content
|
|
21
|
+
* <Trigger>Help</Trigger>
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Dynamic content with render props
|
|
25
|
+
* <Trigger>
|
|
26
|
+
* {({ isOpen, unreadCount }) => (
|
|
27
|
+
* <span>{isOpen ? "Close" : `Help (${unreadCount})`}</span>
|
|
28
|
+
* )}
|
|
29
|
+
* </Trigger>
|
|
30
|
+
*/
|
|
31
|
+
children?: React$1.ReactNode | ((props: TriggerRenderProps) => React$1.ReactNode);
|
|
32
|
+
/**
|
|
33
|
+
* When true, the Trigger will render its children directly,
|
|
34
|
+
* passing all props to the child element.
|
|
35
|
+
*/
|
|
36
|
+
asChild?: boolean;
|
|
37
|
+
className?: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Trigger button that toggles the support window.
|
|
41
|
+
* Can be placed anywhere in the DOM - the window will position itself relative to this element.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // Simple usage
|
|
45
|
+
* <Trigger className="my-button">Need help?</Trigger>
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // With render props
|
|
49
|
+
* <Trigger>
|
|
50
|
+
* {({ isOpen, unreadCount, isTyping }) => (
|
|
51
|
+
* <button className="flex items-center gap-2">
|
|
52
|
+
* {isOpen ? "×" : "💬"}
|
|
53
|
+
* {unreadCount > 0 && <span className="badge">{unreadCount}</span>}
|
|
54
|
+
* </button>
|
|
55
|
+
* )}
|
|
56
|
+
* </Trigger>
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // With asChild pattern
|
|
60
|
+
* <Trigger asChild>
|
|
61
|
+
* <MyCustomButton>Help</MyCustomButton>
|
|
62
|
+
* </Trigger>
|
|
63
|
+
*/
|
|
64
|
+
declare const SupportTrigger: React$1.ForwardRefExoticComponent<Omit<React$1.ButtonHTMLAttributes<HTMLButtonElement>, "children"> & {
|
|
65
|
+
/**
|
|
66
|
+
* Content to render inside the trigger.
|
|
67
|
+
* Can be a ReactNode or a function that receives render props.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Static content
|
|
71
|
+
* <Trigger>Help</Trigger>
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* // Dynamic content with render props
|
|
75
|
+
* <Trigger>
|
|
76
|
+
* {({ isOpen, unreadCount }) => (
|
|
77
|
+
* <span>{isOpen ? "Close" : `Help (${unreadCount})`}</span>
|
|
78
|
+
* )}
|
|
79
|
+
* </Trigger>
|
|
80
|
+
*/
|
|
81
|
+
children?: React$1.ReactNode | ((props: TriggerRenderProps) => React$1.ReactNode);
|
|
82
|
+
/**
|
|
83
|
+
* When true, the Trigger will render its children directly,
|
|
84
|
+
* passing all props to the child element.
|
|
85
|
+
*/
|
|
86
|
+
asChild?: boolean;
|
|
87
|
+
className?: string;
|
|
88
|
+
} & React$1.RefAttributes<HTMLButtonElement>>;
|
|
89
|
+
//#endregion
|
|
90
|
+
export { SupportTrigger, TriggerProps, TriggerRenderProps };
|
|
91
|
+
//# sourceMappingURL=trigger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger.d.ts","names":[],"sources":["../../src/primitives/trigger.tsx"],"sourcesContent":[],"mappings":";;;;;;AAUA;AAOY,KAPA,kBAAA,GAOY;EACI,MAAA,EAAA,OAAA;EAA3B,WAAM,EAAA,MAAA;EADoB,QAAA,EAAA,OAAA;EAoBf,MAAM,EAAA,GAAA,GAAA,IAAA;CAAqB;AAAuB,KApBlD,YAAA,GAAe,IAoByC,CAnBnE,OAAA,CAAM,oBAmB6D,CAnBxC,iBAmBwC,CAAA,EAAA,UAAA,CAAA,GAAA;EAAS;AAkC7E;;;;;;;;;;;;;;;aAlCY,OAAA,CAAM,qBAAqB,uBAAuB,OAAA,CAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkCvD,gBAAc,OAAA,CAAA,0BAAA,KAAA,OAAA,CAAA,qBAAA;;;;;;;;;;;;;;;;;aAlCf,OAAA,CAAM,qBAAqB,uBAAuB,OAAA,CAAM"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { useRenderElement } from "../utils/use-render-element.js";
|
|
2
|
+
import { useTypingStore } from "../realtime/typing-store.js";
|
|
3
|
+
import { useTriggerRef } from "../support/context/positioning.js";
|
|
4
|
+
import { useSupportConfig } from "../support/store/support-store.js";
|
|
5
|
+
import { useSupport } from "../provider.js";
|
|
6
|
+
import * as React$1 from "react";
|
|
7
|
+
|
|
8
|
+
//#region src/primitives/trigger.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Trigger button that toggles the support window.
|
|
11
|
+
* Can be placed anywhere in the DOM - the window will position itself relative to this element.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Simple usage
|
|
15
|
+
* <Trigger className="my-button">Need help?</Trigger>
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // With render props
|
|
19
|
+
* <Trigger>
|
|
20
|
+
* {({ isOpen, unreadCount, isTyping }) => (
|
|
21
|
+
* <button className="flex items-center gap-2">
|
|
22
|
+
* {isOpen ? "×" : "💬"}
|
|
23
|
+
* {unreadCount > 0 && <span className="badge">{unreadCount}</span>}
|
|
24
|
+
* </button>
|
|
25
|
+
* )}
|
|
26
|
+
* </Trigger>
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // With asChild pattern
|
|
30
|
+
* <Trigger asChild>
|
|
31
|
+
* <MyCustomButton>Help</MyCustomButton>
|
|
32
|
+
* </Trigger>
|
|
33
|
+
*/
|
|
34
|
+
const SupportTrigger = React$1.forwardRef(({ children, className, asChild = false,...props }, ref) => {
|
|
35
|
+
const { isOpen, toggle } = useSupportConfig();
|
|
36
|
+
const { unreadCount, visitor } = useSupport();
|
|
37
|
+
const visitorId = visitor?.id ?? null;
|
|
38
|
+
const setTriggerElement = useTriggerRef()?.setTriggerElement;
|
|
39
|
+
const mergedRef = React$1.useCallback((element) => {
|
|
40
|
+
setTriggerElement?.(element);
|
|
41
|
+
if (typeof ref === "function") ref(element);
|
|
42
|
+
else if (ref) ref.current = element;
|
|
43
|
+
}, [ref, setTriggerElement]);
|
|
44
|
+
const renderProps = {
|
|
45
|
+
isOpen,
|
|
46
|
+
unreadCount,
|
|
47
|
+
isTyping: useTypingStore(React$1.useCallback((state) => Object.values(state.conversations).some((entries) => Object.values(entries).some((entry) => {
|
|
48
|
+
if (visitorId && entry.actorType === "visitor" && entry.actorId === visitorId) return false;
|
|
49
|
+
return true;
|
|
50
|
+
})), [visitorId])),
|
|
51
|
+
toggle
|
|
52
|
+
};
|
|
53
|
+
const content = typeof children === "function" ? children(renderProps) : children;
|
|
54
|
+
return useRenderElement("button", {
|
|
55
|
+
asChild,
|
|
56
|
+
className
|
|
57
|
+
}, {
|
|
58
|
+
ref: mergedRef,
|
|
59
|
+
state: renderProps,
|
|
60
|
+
props: {
|
|
61
|
+
type: "button",
|
|
62
|
+
"aria-haspopup": "dialog",
|
|
63
|
+
"aria-expanded": isOpen,
|
|
64
|
+
onClick: toggle,
|
|
65
|
+
...props,
|
|
66
|
+
children: content
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
SupportTrigger.displayName = "SupportTrigger";
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { SupportTrigger };
|
|
74
|
+
//# sourceMappingURL=trigger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger.js","names":["React","renderProps: TriggerRenderProps"],"sources":["../../src/primitives/trigger.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { useSupport } from \"../provider\";\nimport { useTypingStore } from \"../realtime/typing-store\";\nimport { useSupportConfig } from \"../support\";\nimport { useTriggerRef } from \"../support/context/positioning\";\nimport { useRenderElement } from \"../utils/use-render-element\";\n\n/**\n * Render props provided to the Trigger's children function.\n */\nexport type TriggerRenderProps = {\n\tisOpen: boolean;\n\tunreadCount: number;\n\tisTyping: boolean;\n\ttoggle: () => void;\n};\n\nexport type TriggerProps = Omit<\n\tReact.ButtonHTMLAttributes<HTMLButtonElement>,\n\t\"children\"\n> & {\n\t/**\n\t * Content to render inside the trigger.\n\t * Can be a ReactNode or a function that receives render props.\n\t *\n\t * @example\n\t * // Static content\n\t * <Trigger>Help</Trigger>\n\t *\n\t * @example\n\t * // Dynamic content with render props\n\t * <Trigger>\n\t * {({ isOpen, unreadCount }) => (\n\t * <span>{isOpen ? \"Close\" : `Help (${unreadCount})`}</span>\n\t * )}\n\t * </Trigger>\n\t */\n\tchildren?: React.ReactNode | ((props: TriggerRenderProps) => React.ReactNode);\n\t/**\n\t * When true, the Trigger will render its children directly,\n\t * passing all props to the child element.\n\t */\n\tasChild?: boolean;\n\tclassName?: string;\n};\n\n/**\n * Trigger button that toggles the support window.\n * Can be placed anywhere in the DOM - the window will position itself relative to this element.\n *\n * @example\n * // Simple usage\n * <Trigger className=\"my-button\">Need help?</Trigger>\n *\n * @example\n * // With render props\n * <Trigger>\n * {({ isOpen, unreadCount, isTyping }) => (\n * <button className=\"flex items-center gap-2\">\n * {isOpen ? \"×\" : \"💬\"}\n * {unreadCount > 0 && <span className=\"badge\">{unreadCount}</span>}\n * </button>\n * )}\n * </Trigger>\n *\n * @example\n * // With asChild pattern\n * <Trigger asChild>\n * <MyCustomButton>Help</MyCustomButton>\n * </Trigger>\n */\nexport const SupportTrigger = React.forwardRef<HTMLButtonElement, TriggerProps>(\n\t({ children, className, asChild = false, ...props }, ref) => {\n\t\tconst { isOpen, toggle } = useSupportConfig();\n\t\tconst { unreadCount, visitor } = useSupport();\n\t\tconst visitorId = visitor?.id ?? null;\n\t\tconst triggerRefContext = useTriggerRef();\n\n\t\t// Extract setTriggerElement for stable dependency (state setter has stable identity)\n\t\tconst setTriggerElement = triggerRefContext?.setTriggerElement;\n\n\t\t// Merge the external ref with the positioning context ref\n\t\t// Using setTriggerElement directly ensures stable ref callback identity\n\t\tconst mergedRef = React.useCallback(\n\t\t\t(element: HTMLButtonElement | null) => {\n\t\t\t\t// Set the positioning context ref\n\t\t\t\tsetTriggerElement?.(element);\n\n\t\t\t\t// Handle the forwarded ref\n\t\t\t\tif (typeof ref === \"function\") {\n\t\t\t\t\tref(element);\n\t\t\t\t} else if (ref) {\n\t\t\t\t\tref.current = element;\n\t\t\t\t}\n\t\t\t},\n\t\t\t[ref, setTriggerElement]\n\t\t);\n\n\t\tconst hasTyping = useTypingStore(\n\t\t\tReact.useCallback(\n\t\t\t\t(state) =>\n\t\t\t\t\tObject.values(state.conversations).some((entries) =>\n\t\t\t\t\t\tObject.values(entries).some((entry) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tvisitorId &&\n\t\t\t\t\t\t\t\tentry.actorType === \"visitor\" &&\n\t\t\t\t\t\t\t\tentry.actorId === visitorId\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t})\n\t\t\t\t\t),\n\t\t\t\t[visitorId]\n\t\t\t)\n\t\t);\n\n\t\tconst renderProps: TriggerRenderProps = {\n\t\t\tisOpen,\n\t\t\tunreadCount,\n\t\t\tisTyping: hasTyping,\n\t\t\ttoggle,\n\t\t};\n\n\t\tconst content =\n\t\t\ttypeof children === \"function\" ? children(renderProps) : children;\n\n\t\treturn useRenderElement(\n\t\t\t\"button\",\n\t\t\t{\n\t\t\t\tasChild,\n\t\t\t\tclassName,\n\t\t\t},\n\t\t\t{\n\t\t\t\tref: mergedRef,\n\t\t\t\tstate: renderProps,\n\t\t\t\tprops: {\n\t\t\t\t\ttype: \"button\",\n\t\t\t\t\t\"aria-haspopup\": \"dialog\",\n\t\t\t\t\t\"aria-expanded\": isOpen,\n\t\t\t\t\tonClick: toggle,\n\t\t\t\t\t...props,\n\t\t\t\t\tchildren: content,\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\t}\n);\n\nSupportTrigger.displayName = \"SupportTrigger\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAa,iBAAiBA,QAAM,YAClC,EAAE,UAAU,WAAW,UAAU,MAAO,GAAG,SAAS,QAAQ;CAC5D,MAAM,EAAE,QAAQ,WAAW,kBAAkB;CAC7C,MAAM,EAAE,aAAa,YAAY,YAAY;CAC7C,MAAM,YAAY,SAAS,MAAM;CAIjC,MAAM,oBAHoB,eAAe,EAGI;CAI7C,MAAM,YAAYA,QAAM,aACtB,YAAsC;AAEtC,sBAAoB,QAAQ;AAG5B,MAAI,OAAO,QAAQ,WAClB,KAAI,QAAQ;WACF,IACV,KAAI,UAAU;IAGhB,CAAC,KAAK,kBAAkB,CACxB;CAsBD,MAAMC,cAAkC;EACvC;EACA;EACA,UAvBiB,eACjBD,QAAM,aACJ,UACA,OAAO,OAAO,MAAM,cAAc,CAAC,MAAM,YACxC,OAAO,OAAO,QAAQ,CAAC,MAAM,UAAU;AACtC,OACC,aACA,MAAM,cAAc,aACpB,MAAM,YAAY,UAElB,QAAO;AAGR,UAAO;IACN,CACF,EACF,CAAC,UAAU,CACX,CACD;EAMA;EACA;CAED,MAAM,UACL,OAAO,aAAa,aAAa,SAAS,YAAY,GAAG;AAE1D,QAAO,iBACN,UACA;EACC;EACA;EACA,EACD;EACC,KAAK;EACL,OAAO;EACP,OAAO;GACN,MAAM;GACN,iBAAiB;GACjB,iBAAiB;GACjB,SAAS;GACT,GAAG;GACH,UAAU;GACV;EACD,CACD;EAEF;AAED,eAAe,cAAc"}
|
package/primitives/window.d.ts
CHANGED
|
@@ -11,10 +11,21 @@ type WindowProps = Omit<React$1.HTMLAttributes<HTMLDivElement>, "children"> & {
|
|
|
11
11
|
children?: React$1.ReactNode | ((props: WindowRenderProps) => React$1.ReactNode);
|
|
12
12
|
asChild?: boolean;
|
|
13
13
|
closeOnEscape?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to trap focus within the dialog when open.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
trapFocus?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Whether to restore focus to the previously focused element when closing.
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
restoreFocus?: boolean;
|
|
14
24
|
id?: string;
|
|
15
25
|
};
|
|
16
26
|
/**
|
|
17
|
-
* Dialog container with open/close state
|
|
27
|
+
* Dialog container with open/close state, escape key handling,
|
|
28
|
+
* focus trap, and focus restoration.
|
|
18
29
|
*
|
|
19
30
|
* @example
|
|
20
31
|
* <Window isOpen={isOpen} onOpenChange={setOpen}>
|
|
@@ -29,6 +40,16 @@ declare const SupportWindow: React$1.ForwardRefExoticComponent<Omit<React$1.HTML
|
|
|
29
40
|
children?: React$1.ReactNode | ((props: WindowRenderProps) => React$1.ReactNode);
|
|
30
41
|
asChild?: boolean;
|
|
31
42
|
closeOnEscape?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Whether to trap focus within the dialog when open.
|
|
45
|
+
* @default true
|
|
46
|
+
*/
|
|
47
|
+
trapFocus?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether to restore focus to the previously focused element when closing.
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
52
|
+
restoreFocus?: boolean;
|
|
32
53
|
id?: string;
|
|
33
54
|
} & React$1.RefAttributes<HTMLDivElement>>;
|
|
34
55
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window.d.ts","names":[],"sources":["../../src/primitives/window.tsx"],"sourcesContent":[],"mappings":";;;KAIY,iBAAA;;EAAA,KAAA,EAAA,GAAA,GAAA,IAAA;AAKZ,CAAA;AACsB,KADV,WAAA,GAAc,IACJ,CAArB,OAAA,CAAM,cAAe,CAAA,cAAA,CAAA,EAAA,UAAA,CAAA,GAAA;EAArB,MAAM,CAAA,EAAA,OAAA;EADmB,YAAA,CAAA,EAAA,CAAA,IAAA,EAAA,OAAA,EAAA,GAAA,IAAA;EAMd,QAAM,CAAA,EAAN,OAAA,CAAM,SAAA,GAAA,CAAA,CAAA,KAAA,EAAqB,iBAArB,EAAA,GAA2C,OAAA,CAAM,SAAjD,CAAA;EAAqB,OAAA,CAAA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