@assistant-ui/react 0.7.90 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloud/auiV0.js.map +1 -1
- package/dist/cloud/auiV0.mjs.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +0 -1
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +0 -3
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +0 -2
- package/dist/internal.mjs.map +1 -1
- package/dist/model-context/ModelContextTypes.d.ts +11 -0
- package/dist/model-context/ModelContextTypes.d.ts.map +1 -1
- package/dist/model-context/ModelContextTypes.js.map +1 -1
- package/dist/model-context/ModelContextTypes.mjs.map +1 -1
- package/dist/model-context/makeAssistantVisible.d.ts.map +1 -1
- package/dist/model-context/makeAssistantVisible.js +7 -3
- package/dist/model-context/makeAssistantVisible.js.map +1 -1
- package/dist/model-context/makeAssistantVisible.mjs +7 -3
- package/dist/model-context/makeAssistantVisible.mjs.map +1 -1
- package/dist/primitives/contentPart/index.d.ts +0 -1
- package/dist/primitives/contentPart/index.d.ts.map +1 -1
- package/dist/primitives/contentPart/index.js +0 -3
- package/dist/primitives/contentPart/index.js.map +1 -1
- package/dist/primitives/contentPart/index.mjs +0 -2
- package/dist/primitives/contentPart/index.mjs.map +1 -1
- package/dist/primitives/index.d.ts +0 -1
- package/dist/primitives/index.d.ts.map +1 -1
- package/dist/primitives/index.js +0 -3
- package/dist/primitives/index.js.map +1 -1
- package/dist/primitives/index.mjs +0 -2
- package/dist/primitives/index.mjs.map +1 -1
- package/dist/primitives/message/MessageContent.d.ts +1 -2
- package/dist/primitives/message/MessageContent.d.ts.map +1 -1
- package/dist/primitives/message/MessageContent.js +2 -7
- package/dist/primitives/message/MessageContent.js.map +1 -1
- package/dist/primitives/message/MessageContent.mjs +2 -7
- package/dist/primitives/message/MessageContent.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +1 -3
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +1 -3
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.d.ts.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.js +1 -6
- package/dist/runtimes/edge/converters/toCoreMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/toCoreMessages.mjs +1 -6
- package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
- package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts +2 -2
- package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.js +0 -3
- package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
- package/dist/runtimes/external-store/ThreadMessageLike.mjs +0 -3
- package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
- package/dist/types/AssistantTypes.d.ts +3 -7
- package/dist/types/AssistantTypes.d.ts.map +1 -1
- package/dist/types/AssistantTypes.js.map +1 -1
- package/dist/types/ContentPartComponentTypes.d.ts +1 -3
- package/dist/types/ContentPartComponentTypes.d.ts.map +1 -1
- package/dist/types/ContentPartComponentTypes.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -21
- package/src/cloud/auiV0.ts +1 -1
- package/src/index.ts +0 -1
- package/src/internal.ts +0 -1
- package/src/model-context/ModelContextTypes.ts +19 -0
- package/src/model-context/makeAssistantVisible.tsx +9 -3
- package/src/primitives/contentPart/index.ts +0 -1
- package/src/primitives/index.ts +0 -1
- package/src/primitives/message/MessageContent.tsx +0 -9
- package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +1 -3
- package/src/runtimes/edge/converters/toCoreMessages.ts +11 -14
- package/src/runtimes/edge/converters/toLanguageModelMessages.ts +2 -2
- package/src/runtimes/external-store/ThreadMessageLike.tsx +0 -6
- package/src/types/AssistantTypes.ts +4 -9
- package/src/types/ContentPartComponentTypes.tsx +0 -4
- package/src/types/index.ts +0 -2
- package/dist/primitives/contentPart/ContentPartDisplay.d.ts +0 -9
- package/dist/primitives/contentPart/ContentPartDisplay.d.ts.map +0 -1
- package/dist/primitives/contentPart/ContentPartDisplay.js +0 -37
- package/dist/primitives/contentPart/ContentPartDisplay.js.map +0 -1
- package/dist/primitives/contentPart/ContentPartDisplay.mjs +0 -13
- package/dist/primitives/contentPart/ContentPartDisplay.mjs.map +0 -1
- package/dist/primitives/contentPart/useContentPartDisplay.d.ts +0 -8
- package/dist/primitives/contentPart/useContentPartDisplay.d.ts.map +0 -1
- package/dist/primitives/contentPart/useContentPartDisplay.js +0 -42
- package/dist/primitives/contentPart/useContentPartDisplay.js.map +0 -1
- package/dist/primitives/contentPart/useContentPartDisplay.mjs +0 -18
- package/dist/primitives/contentPart/useContentPartDisplay.mjs.map +0 -1
- package/dist/styles/index.css +0 -1261
- package/dist/styles/index.css.map +0 -1
- package/dist/styles/modal.css +0 -143
- package/dist/styles/modal.css.map +0 -1
- package/dist/styles/tailwindcss/base-components.css +0 -69
- package/dist/styles/tailwindcss/base-components.css.json +0 -48
- package/dist/styles/tailwindcss/modal.css +0 -29
- package/dist/styles/tailwindcss/modal.css.json +0 -26
- package/dist/styles/tailwindcss/thread.css +0 -262
- package/dist/styles/tailwindcss/thread.css.json +0 -183
- package/dist/styles/themes/default.css +0 -64
- package/dist/styles/themes/default.css.json +0 -46
- package/dist/styles/themes/shadcn-extras.css +0 -4
- package/dist/styles/themes/shadcn-extras.css.json +0 -5
- package/dist/tailwindcss/index.d.ts +0 -49
- package/dist/tailwindcss/index.d.ts.map +0 -1
- package/dist/tailwindcss/index.js +0 -189
- package/dist/tailwindcss/index.js.map +0 -1
- package/dist/tailwindcss/index.mjs +0 -181
- package/dist/tailwindcss/index.mjs.map +0 -1
- package/dist/ui/assistant-action-bar.d.ts +0 -24
- package/dist/ui/assistant-action-bar.d.ts.map +0 -1
- package/dist/ui/assistant-action-bar.js +0 -193
- package/dist/ui/assistant-action-bar.js.map +0 -1
- package/dist/ui/assistant-action-bar.mjs +0 -181
- package/dist/ui/assistant-action-bar.mjs.map +0 -1
- package/dist/ui/assistant-message.d.ts +0 -13
- package/dist/ui/assistant-message.d.ts.map +0 -1
- package/dist/ui/assistant-message.js +0 -107
- package/dist/ui/assistant-message.js.map +0 -1
- package/dist/ui/assistant-message.mjs +0 -77
- package/dist/ui/assistant-message.mjs.map +0 -1
- package/dist/ui/assistant-modal.d.ts +0 -23
- package/dist/ui/assistant-modal.d.ts.map +0 -1
- package/dist/ui/assistant-modal.js +0 -126
- package/dist/ui/assistant-modal.js.map +0 -1
- package/dist/ui/assistant-modal.mjs +0 -99
- package/dist/ui/assistant-modal.mjs.map +0 -1
- package/dist/ui/attachment-ui.d.ts +0 -12
- package/dist/ui/attachment-ui.d.ts.map +0 -1
- package/dist/ui/attachment-ui.js +0 -170
- package/dist/ui/attachment-ui.js.map +0 -1
- package/dist/ui/attachment-ui.mjs +0 -160
- package/dist/ui/attachment-ui.mjs.map +0 -1
- package/dist/ui/base/CircleStopIcon.d.ts +0 -3
- package/dist/ui/base/CircleStopIcon.d.ts.map +0 -1
- package/dist/ui/base/CircleStopIcon.js +0 -45
- package/dist/ui/base/CircleStopIcon.js.map +0 -1
- package/dist/ui/base/CircleStopIcon.mjs +0 -20
- package/dist/ui/base/CircleStopIcon.mjs.map +0 -1
- package/dist/ui/base/avatar.d.ts +0 -12
- package/dist/ui/base/avatar.d.ts.map +0 -1
- package/dist/ui/base/avatar.js +0 -69
- package/dist/ui/base/avatar.js.map +0 -1
- package/dist/ui/base/avatar.mjs +0 -31
- package/dist/ui/base/avatar.mjs.map +0 -1
- package/dist/ui/base/button.d.ts +0 -16
- package/dist/ui/base/button.d.ts.map +0 -1
- package/dist/ui/base/button.js +0 -66
- package/dist/ui/base/button.js.map +0 -1
- package/dist/ui/base/button.mjs +0 -40
- package/dist/ui/base/button.mjs.map +0 -1
- package/dist/ui/base/dialog.d.ts +0 -9
- package/dist/ui/base/dialog.d.ts.map +0 -1
- package/dist/ui/base/dialog.js +0 -80
- package/dist/ui/base/dialog.js.map +0 -1
- package/dist/ui/base/dialog.mjs +0 -40
- package/dist/ui/base/dialog.mjs.map +0 -1
- package/dist/ui/base/index.d.ts +0 -6
- package/dist/ui/base/index.d.ts.map +0 -1
- package/dist/ui/base/index.js +0 -55
- package/dist/ui/base/index.js.map +0 -1
- package/dist/ui/base/index.mjs +0 -25
- package/dist/ui/base/index.mjs.map +0 -1
- package/dist/ui/base/tooltip-icon-button.d.ts +0 -17
- package/dist/ui/base/tooltip-icon-button.d.ts.map +0 -1
- package/dist/ui/base/tooltip-icon-button.js +0 -44
- package/dist/ui/base/tooltip-icon-button.js.map +0 -1
- package/dist/ui/base/tooltip-icon-button.mjs +0 -19
- package/dist/ui/base/tooltip-icon-button.mjs.map +0 -1
- package/dist/ui/base/tooltip.d.ts +0 -6
- package/dist/ui/base/tooltip.d.ts.map +0 -1
- package/dist/ui/base/tooltip.js +0 -57
- package/dist/ui/base/tooltip.js.map +0 -1
- package/dist/ui/base/tooltip.mjs +0 -20
- package/dist/ui/base/tooltip.mjs.map +0 -1
- package/dist/ui/branch-picker.d.ts +0 -15
- package/dist/ui/branch-picker.d.ts.map +0 -1
- package/dist/ui/branch-picker.js +0 -89
- package/dist/ui/branch-picker.js.map +0 -1
- package/dist/ui/branch-picker.mjs +0 -69
- package/dist/ui/branch-picker.mjs.map +0 -1
- package/dist/ui/composer.d.ts +0 -25
- package/dist/ui/composer.d.ts.map +0 -1
- package/dist/ui/composer.js +0 -168
- package/dist/ui/composer.js.map +0 -1
- package/dist/ui/composer.mjs +0 -138
- package/dist/ui/composer.mjs.map +0 -1
- package/dist/ui/content-part.d.ts +0 -7
- package/dist/ui/content-part.d.ts.map +0 -1
- package/dist/ui/content-part.js +0 -61
- package/dist/ui/content-part.js.map +0 -1
- package/dist/ui/content-part.mjs +0 -27
- package/dist/ui/content-part.mjs.map +0 -1
- package/dist/ui/edit-composer.d.ts +0 -22
- package/dist/ui/edit-composer.d.ts.map +0 -1
- package/dist/ui/edit-composer.js +0 -77
- package/dist/ui/edit-composer.js.map +0 -1
- package/dist/ui/edit-composer.mjs +0 -57
- package/dist/ui/edit-composer.mjs.map +0 -1
- package/dist/ui/index.d.ts +0 -75
- package/dist/ui/index.d.ts.map +0 -1
- package/dist/ui/index.js +0 -86
- package/dist/ui/index.js.map +0 -1
- package/dist/ui/index.mjs +0 -38
- package/dist/ui/index.mjs.map +0 -1
- package/dist/ui/thread-config.d.ts +0 -162
- package/dist/ui/thread-config.d.ts.map +0 -1
- package/dist/ui/thread-config.js +0 -63
- package/dist/ui/thread-config.js.map +0 -1
- package/dist/ui/thread-config.mjs +0 -41
- package/dist/ui/thread-config.mjs.map +0 -1
- package/dist/ui/thread-list-item.d.ts +0 -13
- package/dist/ui/thread-list-item.d.ts.map +0 -1
- package/dist/ui/thread-list-item.js +0 -94
- package/dist/ui/thread-list-item.js.map +0 -1
- package/dist/ui/thread-list-item.mjs +0 -64
- package/dist/ui/thread-list-item.mjs.map +0 -1
- package/dist/ui/thread-list.d.ts +0 -27
- package/dist/ui/thread-list.d.ts.map +0 -1
- package/dist/ui/thread-list.js +0 -91
- package/dist/ui/thread-list.js.map +0 -1
- package/dist/ui/thread-list.mjs +0 -61
- package/dist/ui/thread-list.mjs.map +0 -1
- package/dist/ui/thread-welcome.d.ts +0 -21
- package/dist/ui/thread-welcome.d.ts.map +0 -1
- package/dist/ui/thread-welcome.js +0 -101
- package/dist/ui/thread-welcome.js.map +0 -1
- package/dist/ui/thread-welcome.mjs +0 -81
- package/dist/ui/thread-welcome.mjs.map +0 -1
- package/dist/ui/thread.d.ts +0 -30
- package/dist/ui/thread.d.ts.map +0 -1
- package/dist/ui/thread.js +0 -152
- package/dist/ui/thread.js.map +0 -1
- package/dist/ui/thread.mjs +0 -125
- package/dist/ui/thread.mjs.map +0 -1
- package/dist/ui/user-action-bar.d.ts +0 -16
- package/dist/ui/user-action-bar.d.ts.map +0 -1
- package/dist/ui/user-action-bar.js +0 -63
- package/dist/ui/user-action-bar.js.map +0 -1
- package/dist/ui/user-action-bar.mjs +0 -43
- package/dist/ui/user-action-bar.mjs.map +0 -1
- package/dist/ui/user-message.d.ts +0 -13
- package/dist/ui/user-message.d.ts.map +0 -1
- package/dist/ui/user-message.js +0 -96
- package/dist/ui/user-message.js.map +0 -1
- package/dist/ui/user-message.mjs +0 -65
- package/dist/ui/user-message.mjs.map +0 -1
- package/dist/ui/utils/withDefaults.d.ts +0 -7
- package/dist/ui/utils/withDefaults.d.ts.map +0 -1
- package/dist/ui/utils/withDefaults.js +0 -66
- package/dist/ui/utils/withDefaults.js.map +0 -1
- package/dist/ui/utils/withDefaults.mjs +0 -30
- package/dist/ui/utils/withDefaults.mjs.map +0 -1
- package/src/primitives/contentPart/ContentPartDisplay.tsx +0 -20
- package/src/primitives/contentPart/useContentPartDisplay.tsx +0 -21
- package/src/styles/base.css +0 -37
- package/src/styles/index.css +0 -4
- package/src/styles/modal.css +0 -1
- package/src/styles/tailwindcss/base-components.css +0 -69
- package/src/styles/tailwindcss/modal.css +0 -29
- package/src/styles/tailwindcss/thread.css +0 -262
- package/src/styles/themes/default.css +0 -64
- package/src/styles/themes/shadcn-extras.css +0 -4
- package/src/tailwindcss/index.ts +0 -149
- package/src/ui/assistant-action-bar.tsx +0 -301
- package/src/ui/assistant-message.tsx +0 -96
- package/src/ui/assistant-modal.tsx +0 -146
- package/src/ui/attachment-ui.tsx +0 -211
- package/src/ui/base/CircleStopIcon.tsx +0 -17
- package/src/ui/base/avatar.tsx +0 -41
- package/src/ui/base/button.tsx +0 -42
- package/src/ui/base/dialog.tsx +0 -113
- package/src/ui/base/index.ts +0 -15
- package/src/ui/base/tooltip-icon-button.tsx +0 -29
- package/src/ui/base/tooltip.tsx +0 -22
- package/src/ui/branch-picker.tsx +0 -117
- package/src/ui/composer.tsx +0 -210
- package/src/ui/content-part.tsx +0 -23
- package/src/ui/edit-composer.tsx +0 -98
- package/src/ui/index.ts +0 -98
- package/src/ui/thread-config.tsx +0 -246
- package/src/ui/thread-list-item.tsx +0 -91
- package/src/ui/thread-list.tsx +0 -78
- package/src/ui/thread-welcome.tsx +0 -140
- package/src/ui/thread.tsx +0 -176
- package/src/ui/user-action-bar.tsx +0 -66
- package/src/ui/user-message.tsx +0 -92
- package/src/ui/utils/withDefaults.tsx +0 -35
- package/tailwindcss/README.md +0 -1
- package/tailwindcss/package-lock.json +0 -6
- package/tailwindcss/package.json +0 -5
package/src/ui/attachment-ui.tsx
DELETED
@@ -1,211 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import {
|
4
|
-
forwardRef,
|
5
|
-
PropsWithChildren,
|
6
|
-
useEffect,
|
7
|
-
useState,
|
8
|
-
type FC,
|
9
|
-
} from "react";
|
10
|
-
import { CircleXIcon, FileIcon } from "lucide-react";
|
11
|
-
import { withDefaults } from "./utils/withDefaults";
|
12
|
-
import { useThreadConfig } from "./thread-config";
|
13
|
-
import { TooltipIconButton } from "./base/tooltip-icon-button";
|
14
|
-
import { AttachmentPrimitive } from "../primitives";
|
15
|
-
import { useAttachment } from "../context/react/AttachmentContext";
|
16
|
-
import {
|
17
|
-
AvatarImage,
|
18
|
-
AvatarRoot,
|
19
|
-
Tooltip,
|
20
|
-
TooltipContent,
|
21
|
-
TooltipTrigger,
|
22
|
-
} from "./base";
|
23
|
-
import { Dialog, DialogTrigger, DialogContent } from "./base/dialog";
|
24
|
-
import { AvatarFallback } from "@radix-ui/react-avatar";
|
25
|
-
import { useShallow } from "zustand/shallow";
|
26
|
-
import { DialogTitle } from "@radix-ui/react-dialog";
|
27
|
-
|
28
|
-
const AttachmentRoot = withDefaults(AttachmentPrimitive.Root, {
|
29
|
-
className: "aui-attachment-root",
|
30
|
-
});
|
31
|
-
|
32
|
-
const AttachmentContent = withDefaults("div", {
|
33
|
-
className: "aui-attachment-content",
|
34
|
-
});
|
35
|
-
|
36
|
-
AttachmentRoot.displayName = "AttachmentRoot";
|
37
|
-
|
38
|
-
const useFileSrc = (file: File | undefined) => {
|
39
|
-
const [src, setSrc] = useState<string | undefined>(undefined);
|
40
|
-
|
41
|
-
useEffect(() => {
|
42
|
-
if (!file) {
|
43
|
-
setSrc(undefined);
|
44
|
-
return;
|
45
|
-
}
|
46
|
-
|
47
|
-
const objectUrl = URL.createObjectURL(file);
|
48
|
-
setSrc(objectUrl);
|
49
|
-
|
50
|
-
return () => {
|
51
|
-
URL.revokeObjectURL(objectUrl);
|
52
|
-
};
|
53
|
-
}, [file]);
|
54
|
-
|
55
|
-
return src;
|
56
|
-
};
|
57
|
-
|
58
|
-
const useAttachmentSrc = () => {
|
59
|
-
const { file, src } = useAttachment(
|
60
|
-
useShallow((a): { file?: File; src?: string } => {
|
61
|
-
if (a.type !== "image") return {};
|
62
|
-
if (a.file) return { file: a.file };
|
63
|
-
const src = a.content?.filter((c) => c.type === "image")[0]?.image;
|
64
|
-
if (!src) return {};
|
65
|
-
return { src };
|
66
|
-
}),
|
67
|
-
);
|
68
|
-
|
69
|
-
return useFileSrc(file) ?? src;
|
70
|
-
};
|
71
|
-
|
72
|
-
type AttachmentPreviewProps = {
|
73
|
-
src: string;
|
74
|
-
};
|
75
|
-
|
76
|
-
const AttachmentPreview: FC<AttachmentPreviewProps> = ({ src }) => {
|
77
|
-
const [isLoaded, setIsLoaded] = useState(false);
|
78
|
-
|
79
|
-
return (
|
80
|
-
// eslint-disable-next-line @next/next/no-img-element
|
81
|
-
<img
|
82
|
-
src={src}
|
83
|
-
style={{
|
84
|
-
width: "auto",
|
85
|
-
height: "auto",
|
86
|
-
maxWidth: "75dvh",
|
87
|
-
maxHeight: "75dvh",
|
88
|
-
display: isLoaded ? "block" : "none",
|
89
|
-
overflow: "clip",
|
90
|
-
}}
|
91
|
-
onLoad={() => setIsLoaded(true)}
|
92
|
-
alt="Image Preview"
|
93
|
-
/>
|
94
|
-
);
|
95
|
-
};
|
96
|
-
|
97
|
-
const AttachmentPreviewDialog: FC<PropsWithChildren> = ({ children }) => {
|
98
|
-
const src = useAttachmentSrc();
|
99
|
-
|
100
|
-
if (!src) return children;
|
101
|
-
|
102
|
-
return (
|
103
|
-
<Dialog>
|
104
|
-
<DialogTrigger className="aui-attachment-preview-trigger" asChild>
|
105
|
-
{children}
|
106
|
-
</DialogTrigger>
|
107
|
-
<DialogContent>
|
108
|
-
<DialogTitle className="aui-sr-only">
|
109
|
-
Image Attachment Preview
|
110
|
-
</DialogTitle>
|
111
|
-
<AttachmentPreview src={src} />
|
112
|
-
</DialogContent>
|
113
|
-
</Dialog>
|
114
|
-
);
|
115
|
-
};
|
116
|
-
|
117
|
-
const AttachmentThumb: FC = () => {
|
118
|
-
const isImage = useAttachment((a) => a.type === "image");
|
119
|
-
const src = useAttachmentSrc();
|
120
|
-
return (
|
121
|
-
<AvatarRoot className="aui-attachment-thumb">
|
122
|
-
<AvatarFallback delayMs={isImage ? 200 : 0}>
|
123
|
-
<FileIcon />
|
124
|
-
</AvatarFallback>
|
125
|
-
<AvatarImage src={src}></AvatarImage>
|
126
|
-
</AvatarRoot>
|
127
|
-
);
|
128
|
-
};
|
129
|
-
|
130
|
-
const AttachmentUI: FC = () => {
|
131
|
-
const canRemove = useAttachment((a) => a.source !== "message");
|
132
|
-
const typeLabel = useAttachment((a) => {
|
133
|
-
const type = a.type;
|
134
|
-
switch (type) {
|
135
|
-
case "image":
|
136
|
-
return "Image";
|
137
|
-
case "document":
|
138
|
-
return "Document";
|
139
|
-
case "file":
|
140
|
-
return "File";
|
141
|
-
default:
|
142
|
-
const _exhaustiveCheck: never = type;
|
143
|
-
throw new Error(`Unknown attachment type: ${_exhaustiveCheck}`);
|
144
|
-
}
|
145
|
-
});
|
146
|
-
return (
|
147
|
-
<Tooltip>
|
148
|
-
<AttachmentRoot>
|
149
|
-
<AttachmentPreviewDialog>
|
150
|
-
<TooltipTrigger asChild>
|
151
|
-
<AttachmentContent>
|
152
|
-
<AttachmentThumb />
|
153
|
-
<div className="aui-attachment-text">
|
154
|
-
<p className="aui-attachment-name">
|
155
|
-
<AttachmentPrimitive.Name />
|
156
|
-
</p>
|
157
|
-
<p className="aui-attachment-type">{typeLabel}</p>
|
158
|
-
</div>
|
159
|
-
</AttachmentContent>
|
160
|
-
</TooltipTrigger>
|
161
|
-
</AttachmentPreviewDialog>
|
162
|
-
{canRemove && <AttachmentRemove />}
|
163
|
-
</AttachmentRoot>
|
164
|
-
<TooltipContent side="top">
|
165
|
-
<AttachmentPrimitive.Name />
|
166
|
-
</TooltipContent>
|
167
|
-
</Tooltip>
|
168
|
-
);
|
169
|
-
};
|
170
|
-
|
171
|
-
AttachmentUI.displayName = "Attachment";
|
172
|
-
|
173
|
-
namespace AttachmentRemove {
|
174
|
-
export type Element = HTMLButtonElement;
|
175
|
-
export type Props = Partial<TooltipIconButton.Props>;
|
176
|
-
}
|
177
|
-
|
178
|
-
const AttachmentRemove = forwardRef<
|
179
|
-
AttachmentRemove.Element,
|
180
|
-
AttachmentRemove.Props
|
181
|
-
>((props, ref) => {
|
182
|
-
const {
|
183
|
-
strings: {
|
184
|
-
composer: { removeAttachment: { tooltip = "Remove file" } = {} } = {},
|
185
|
-
} = {},
|
186
|
-
} = useThreadConfig();
|
187
|
-
|
188
|
-
return (
|
189
|
-
<AttachmentPrimitive.Remove asChild>
|
190
|
-
<TooltipIconButton
|
191
|
-
tooltip={tooltip}
|
192
|
-
className="aui-attachment-remove"
|
193
|
-
side="top"
|
194
|
-
{...props}
|
195
|
-
ref={ref}
|
196
|
-
>
|
197
|
-
{props.children ?? <CircleXIcon />}
|
198
|
-
</TooltipIconButton>
|
199
|
-
</AttachmentPrimitive.Remove>
|
200
|
-
);
|
201
|
-
});
|
202
|
-
|
203
|
-
AttachmentRemove.displayName = "AttachmentRemove";
|
204
|
-
|
205
|
-
const exports = {
|
206
|
-
Root: AttachmentRoot,
|
207
|
-
Remove: AttachmentRemove,
|
208
|
-
};
|
209
|
-
|
210
|
-
export default Object.assign(AttachmentUI, exports) as typeof AttachmentUI &
|
211
|
-
typeof exports;
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { FC } from "react";
|
2
|
-
|
3
|
-
export const CircleStopIcon: FC = () => {
|
4
|
-
return (
|
5
|
-
<svg
|
6
|
-
xmlns="http://www.w3.org/2000/svg"
|
7
|
-
viewBox="0 0 16 16"
|
8
|
-
fill="currentColor"
|
9
|
-
width="16"
|
10
|
-
height="16"
|
11
|
-
>
|
12
|
-
<rect width="10" height="10" x="3" y="3" rx="2" />
|
13
|
-
</svg>
|
14
|
-
);
|
15
|
-
};
|
16
|
-
|
17
|
-
CircleStopIcon.displayName = "CircleStopIcon";
|
package/src/ui/base/avatar.tsx
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
import type { FC } from "react";
|
2
|
-
import * as AvatarPrimitive from "@radix-ui/react-avatar";
|
3
|
-
|
4
|
-
import { withDefaults } from "../utils/withDefaults";
|
5
|
-
|
6
|
-
export type AvatarProps = {
|
7
|
-
src?: string | undefined;
|
8
|
-
alt?: string | undefined;
|
9
|
-
fallback?: string | undefined;
|
10
|
-
};
|
11
|
-
|
12
|
-
export const Avatar: FC<AvatarProps> = ({ src, alt, fallback }) => {
|
13
|
-
if (src == null && fallback == null) return null;
|
14
|
-
|
15
|
-
return (
|
16
|
-
<AvatarRoot>
|
17
|
-
{src != null && <AvatarImage src={src} alt={alt} />}
|
18
|
-
{fallback != null && <AvatarFallback>{fallback}</AvatarFallback>}
|
19
|
-
</AvatarRoot>
|
20
|
-
);
|
21
|
-
};
|
22
|
-
|
23
|
-
Avatar.displayName = "Avatar";
|
24
|
-
|
25
|
-
export const AvatarRoot = withDefaults(AvatarPrimitive.Root, {
|
26
|
-
className: "aui-avatar-root",
|
27
|
-
});
|
28
|
-
|
29
|
-
AvatarRoot.displayName = "AvatarRoot";
|
30
|
-
|
31
|
-
export const AvatarImage = withDefaults(AvatarPrimitive.Image, {
|
32
|
-
className: "aui-avatar-image",
|
33
|
-
});
|
34
|
-
|
35
|
-
AvatarImage.displayName = "AvatarImage";
|
36
|
-
|
37
|
-
export const AvatarFallback = withDefaults(AvatarPrimitive.Fallback, {
|
38
|
-
className: "aui-avatar-fallback",
|
39
|
-
});
|
40
|
-
|
41
|
-
AvatarFallback.displayName = "AvatarFallback";
|
package/src/ui/base/button.tsx
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
import { cva, type VariantProps } from "class-variance-authority";
|
2
|
-
import { Primitive } from "@radix-ui/react-primitive";
|
3
|
-
import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
|
4
|
-
|
5
|
-
const buttonVariants = cva("aui-button", {
|
6
|
-
variants: {
|
7
|
-
variant: {
|
8
|
-
default: "aui-button-primary",
|
9
|
-
outline: "aui-button-outline",
|
10
|
-
ghost: "aui-button-ghost",
|
11
|
-
},
|
12
|
-
size: {
|
13
|
-
default: "aui-button-medium",
|
14
|
-
icon: "aui-button-icon",
|
15
|
-
},
|
16
|
-
},
|
17
|
-
defaultVariants: {
|
18
|
-
variant: "default",
|
19
|
-
size: "default",
|
20
|
-
},
|
21
|
-
});
|
22
|
-
|
23
|
-
type ButtonElement = ComponentRef<typeof Primitive.button>;
|
24
|
-
|
25
|
-
export type ButtonProps = ComponentPropsWithoutRef<typeof Primitive.button> &
|
26
|
-
VariantProps<typeof buttonVariants>;
|
27
|
-
|
28
|
-
const Button = forwardRef<ButtonElement, ButtonProps>(
|
29
|
-
({ className, variant, size, ...props }, ref) => {
|
30
|
-
return (
|
31
|
-
<Primitive.button
|
32
|
-
className={buttonVariants({ variant, size, className })}
|
33
|
-
{...props}
|
34
|
-
ref={ref}
|
35
|
-
/>
|
36
|
-
);
|
37
|
-
},
|
38
|
-
);
|
39
|
-
|
40
|
-
Button.displayName = "Button";
|
41
|
-
|
42
|
-
export { Button, buttonVariants };
|
package/src/ui/base/dialog.tsx
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
2
|
-
|
3
|
-
import classNames from "classnames";
|
4
|
-
import { ComponentPropsWithoutRef, ComponentRef, forwardRef } from "react";
|
5
|
-
|
6
|
-
const Dialog = DialogPrimitive.Root;
|
7
|
-
|
8
|
-
const DialogTrigger = DialogPrimitive.Trigger;
|
9
|
-
|
10
|
-
const DialogPortal = DialogPrimitive.Portal;
|
11
|
-
|
12
|
-
const DialogClose = DialogPrimitive.Close;
|
13
|
-
|
14
|
-
const DialogOverlay = forwardRef<
|
15
|
-
ComponentRef<typeof DialogPrimitive.Overlay>,
|
16
|
-
ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
|
17
|
-
>(({ className, ...props }, ref) => (
|
18
|
-
<DialogPrimitive.Overlay
|
19
|
-
ref={ref}
|
20
|
-
className={classNames("aui-dialog-overlay", className)}
|
21
|
-
{...props}
|
22
|
-
/>
|
23
|
-
));
|
24
|
-
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
25
|
-
|
26
|
-
const DialogContent = forwardRef<
|
27
|
-
ComponentRef<typeof DialogPrimitive.Content>,
|
28
|
-
ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
29
|
-
>(({ className, children, ...props }, ref) => (
|
30
|
-
<DialogPortal>
|
31
|
-
<DialogOverlay />
|
32
|
-
<DialogPrimitive.Content
|
33
|
-
ref={ref}
|
34
|
-
className={classNames("aui-dialog-content", className)}
|
35
|
-
{...props}
|
36
|
-
>
|
37
|
-
{children}
|
38
|
-
{/* <DialogPrimitive.Close className="ring-offset-aui-background focus:ring-aui-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:pointer-events-none">
|
39
|
-
<XIcon className="h-4 w-4" />
|
40
|
-
<span className="sr-only">Close</span>
|
41
|
-
</DialogPrimitive.Close> */}
|
42
|
-
</DialogPrimitive.Content>
|
43
|
-
</DialogPortal>
|
44
|
-
));
|
45
|
-
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
46
|
-
|
47
|
-
// const DialogHeader = ({
|
48
|
-
// className,
|
49
|
-
// ...props
|
50
|
-
// }: HTMLAttributes<HTMLDivElement>) => (
|
51
|
-
// <div
|
52
|
-
// className={classNames(
|
53
|
-
// "flex flex-col space-y-1.5 text-center sm:text-left",
|
54
|
-
// className,
|
55
|
-
// )}
|
56
|
-
// {...props}
|
57
|
-
// />
|
58
|
-
// );
|
59
|
-
// DialogHeader.displayName = "DialogHeader";
|
60
|
-
|
61
|
-
// const DialogFooter = ({
|
62
|
-
// className,
|
63
|
-
// ...props
|
64
|
-
// }: HTMLAttributes<HTMLDivElement>) => (
|
65
|
-
// <div
|
66
|
-
// className={classNames(
|
67
|
-
// "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
68
|
-
// className,
|
69
|
-
// )}
|
70
|
-
// {...props}
|
71
|
-
// />
|
72
|
-
// );
|
73
|
-
// DialogFooter.displayName = "DialogFooter";
|
74
|
-
|
75
|
-
// const DialogTitle = forwardRef<
|
76
|
-
// ComponentRef<typeof DialogPrimitive.Title>,
|
77
|
-
// ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
|
78
|
-
// >(({ className, ...props }, ref) => (
|
79
|
-
// <DialogPrimitive.Title
|
80
|
-
// ref={ref}
|
81
|
-
// className={classNames(
|
82
|
-
// "text-lg font-semibold leading-none tracking-tight",
|
83
|
-
// className,
|
84
|
-
// )}
|
85
|
-
// {...props}
|
86
|
-
// />
|
87
|
-
// ));
|
88
|
-
// DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
89
|
-
|
90
|
-
// const DialogDescription = forwardRef<
|
91
|
-
// ComponentRef<typeof DialogPrimitive.Description>,
|
92
|
-
// ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
|
93
|
-
// >(({ className, ...props }, ref) => (
|
94
|
-
// <DialogPrimitive.Description
|
95
|
-
// ref={ref}
|
96
|
-
// className={classNames("text-muted-foreground text-sm", className)}
|
97
|
-
// {...props}
|
98
|
-
// />
|
99
|
-
// ));
|
100
|
-
// DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
101
|
-
|
102
|
-
export {
|
103
|
-
Dialog,
|
104
|
-
DialogPortal,
|
105
|
-
DialogOverlay,
|
106
|
-
DialogTrigger,
|
107
|
-
DialogClose,
|
108
|
-
DialogContent,
|
109
|
-
// DialogHeader,
|
110
|
-
// DialogFooter,
|
111
|
-
// DialogTitle,
|
112
|
-
// DialogDescription,
|
113
|
-
};
|
package/src/ui/base/index.ts
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
export {
|
2
|
-
Avatar,
|
3
|
-
AvatarRoot,
|
4
|
-
AvatarImage,
|
5
|
-
AvatarFallback,
|
6
|
-
type AvatarProps,
|
7
|
-
} from "./avatar";
|
8
|
-
|
9
|
-
export { Button, buttonVariants, type ButtonProps } from "./button";
|
10
|
-
|
11
|
-
export { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
|
12
|
-
|
13
|
-
export { TooltipIconButton } from "./tooltip-icon-button";
|
14
|
-
|
15
|
-
export { CircleStopIcon } from "./CircleStopIcon";
|
@@ -1,29 +0,0 @@
|
|
1
|
-
import { forwardRef } from "react";
|
2
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
|
3
|
-
import { Button, ButtonProps } from "./button";
|
4
|
-
|
5
|
-
export namespace TooltipIconButton {
|
6
|
-
export type Props = ButtonProps & {
|
7
|
-
tooltip: string;
|
8
|
-
side?: "top" | "bottom" | "left" | "right";
|
9
|
-
};
|
10
|
-
}
|
11
|
-
|
12
|
-
export const TooltipIconButton = forwardRef<
|
13
|
-
HTMLButtonElement,
|
14
|
-
TooltipIconButton.Props
|
15
|
-
>(({ children, tooltip, side = "bottom", ...rest }, ref) => {
|
16
|
-
return (
|
17
|
-
<Tooltip>
|
18
|
-
<TooltipTrigger asChild>
|
19
|
-
<Button variant="ghost" size="icon" {...rest} ref={ref}>
|
20
|
-
{children}
|
21
|
-
<span className="aui-sr-only">{tooltip}</span>
|
22
|
-
</Button>
|
23
|
-
</TooltipTrigger>
|
24
|
-
<TooltipContent side={side}>{tooltip}</TooltipContent>
|
25
|
-
</Tooltip>
|
26
|
-
);
|
27
|
-
});
|
28
|
-
|
29
|
-
TooltipIconButton.displayName = "TooltipIconButton";
|
package/src/ui/base/tooltip.tsx
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
2
|
-
import { withDefaults } from "../utils/withDefaults";
|
3
|
-
import { FC } from "react";
|
4
|
-
|
5
|
-
export const Tooltip: FC<TooltipPrimitive.TooltipProps> = (props) => {
|
6
|
-
return (
|
7
|
-
<TooltipPrimitive.Provider>
|
8
|
-
<TooltipPrimitive.Root {...props} />
|
9
|
-
</TooltipPrimitive.Provider>
|
10
|
-
);
|
11
|
-
};
|
12
|
-
|
13
|
-
Tooltip.displayName = "Tooltip";
|
14
|
-
|
15
|
-
export const TooltipTrigger = TooltipPrimitive.Trigger;
|
16
|
-
|
17
|
-
export const TooltipContent = withDefaults(TooltipPrimitive.Content, {
|
18
|
-
sideOffset: 4,
|
19
|
-
className: "aui-tooltip-content",
|
20
|
-
});
|
21
|
-
|
22
|
-
TooltipContent.displayName = "TooltipContent";
|
package/src/ui/branch-picker.tsx
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
import { ComponentPropsWithoutRef, forwardRef, type FC } from "react";
|
4
|
-
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
5
|
-
|
6
|
-
import { TooltipIconButton } from "./base/tooltip-icon-button";
|
7
|
-
import { withDefaults } from "./utils/withDefaults";
|
8
|
-
import { useThreadConfig } from "./thread-config";
|
9
|
-
import { BranchPickerPrimitive } from "../primitives";
|
10
|
-
import { useThread } from "../context";
|
11
|
-
|
12
|
-
const useAllowBranchPicker = (ensureCapability = false) => {
|
13
|
-
const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
|
14
|
-
const branchPickerSupported = useThread((t) => t.capabilities.edit);
|
15
|
-
return allowBranchPicker && (!ensureCapability || branchPickerSupported);
|
16
|
-
};
|
17
|
-
|
18
|
-
const BranchPicker: FC = () => {
|
19
|
-
const allowBranchPicker = useAllowBranchPicker(true);
|
20
|
-
if (!allowBranchPicker) return null;
|
21
|
-
return (
|
22
|
-
<BranchPickerRoot hideWhenSingleBranch>
|
23
|
-
<BranchPickerPrevious />
|
24
|
-
<BranchPickerState />
|
25
|
-
<BranchPickerNext />
|
26
|
-
</BranchPickerRoot>
|
27
|
-
);
|
28
|
-
};
|
29
|
-
|
30
|
-
BranchPicker.displayName = "BranchPicker";
|
31
|
-
|
32
|
-
const BranchPickerRoot = withDefaults(BranchPickerPrimitive.Root, {
|
33
|
-
className: "aui-branch-picker-root",
|
34
|
-
});
|
35
|
-
|
36
|
-
BranchPickerRoot.displayName = "BranchPickerRoot";
|
37
|
-
|
38
|
-
namespace BranchPickerPrevious {
|
39
|
-
export type Element = BranchPickerPrimitive.Previous.Element;
|
40
|
-
export type Props = Partial<TooltipIconButton.Props>;
|
41
|
-
}
|
42
|
-
|
43
|
-
const BranchPickerPrevious = forwardRef<
|
44
|
-
BranchPickerPrevious.Element,
|
45
|
-
BranchPickerPrevious.Props
|
46
|
-
>((props, ref) => {
|
47
|
-
const {
|
48
|
-
strings: {
|
49
|
-
branchPicker: { previous: { tooltip = "Previous" } = {} } = {},
|
50
|
-
} = {},
|
51
|
-
} = useThreadConfig();
|
52
|
-
const allowBranchPicker = useAllowBranchPicker();
|
53
|
-
return (
|
54
|
-
<BranchPickerPrimitive.Previous disabled={!allowBranchPicker} asChild>
|
55
|
-
<TooltipIconButton tooltip={tooltip} {...props} ref={ref}>
|
56
|
-
{props.children ?? <ChevronLeftIcon />}
|
57
|
-
</TooltipIconButton>
|
58
|
-
</BranchPickerPrimitive.Previous>
|
59
|
-
);
|
60
|
-
});
|
61
|
-
|
62
|
-
BranchPickerPrevious.displayName = "BranchPickerPrevious";
|
63
|
-
|
64
|
-
const BranchPickerStateWrapper = withDefaults("span", {
|
65
|
-
className: "aui-branch-picker-state",
|
66
|
-
});
|
67
|
-
|
68
|
-
namespace BranchPickerState {
|
69
|
-
export type Element = HTMLSpanElement;
|
70
|
-
export type Props = ComponentPropsWithoutRef<"span">;
|
71
|
-
}
|
72
|
-
|
73
|
-
const BranchPickerState = forwardRef<
|
74
|
-
BranchPickerState.Element,
|
75
|
-
BranchPickerState.Props
|
76
|
-
>((props, ref) => {
|
77
|
-
return (
|
78
|
-
<BranchPickerStateWrapper {...props} ref={ref}>
|
79
|
-
<BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />
|
80
|
-
</BranchPickerStateWrapper>
|
81
|
-
);
|
82
|
-
});
|
83
|
-
|
84
|
-
BranchPickerState.displayName = "BranchPickerState";
|
85
|
-
|
86
|
-
namespace BranchPickerNext {
|
87
|
-
export type Element = BranchPickerPrimitive.Next.Element;
|
88
|
-
export type Props = Partial<TooltipIconButton.Props>;
|
89
|
-
}
|
90
|
-
|
91
|
-
const BranchPickerNext = forwardRef<
|
92
|
-
BranchPickerNext.Element,
|
93
|
-
BranchPickerNext.Props
|
94
|
-
>((props, ref) => {
|
95
|
-
const {
|
96
|
-
strings: { branchPicker: { next: { tooltip = "Next" } = {} } = {} } = {},
|
97
|
-
} = useThreadConfig();
|
98
|
-
const allowBranchPicker = useAllowBranchPicker();
|
99
|
-
return (
|
100
|
-
<BranchPickerPrimitive.Next disabled={!allowBranchPicker} asChild>
|
101
|
-
<TooltipIconButton tooltip={tooltip} {...props} ref={ref}>
|
102
|
-
{props.children ?? <ChevronRightIcon />}
|
103
|
-
</TooltipIconButton>
|
104
|
-
</BranchPickerPrimitive.Next>
|
105
|
-
);
|
106
|
-
});
|
107
|
-
|
108
|
-
BranchPickerNext.displayName = "BranchPickerNext";
|
109
|
-
|
110
|
-
const exports = {
|
111
|
-
Root: BranchPickerRoot,
|
112
|
-
Previous: BranchPickerPrevious,
|
113
|
-
Next: BranchPickerNext,
|
114
|
-
};
|
115
|
-
|
116
|
-
export default Object.assign(BranchPicker, exports) as typeof BranchPicker &
|
117
|
-
typeof exports;
|