@anvia/react-ui 0.3.0 → 0.4.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/README.md +14 -1
- package/dist/attachment/index.js +2 -2
- package/dist/chat/index.d.ts +29 -4
- package/dist/chat/index.js +4 -4
- package/dist/{chunk-QHP4GSRG.js → chunk-32QFNRXR.js} +2 -2
- package/dist/{chunk-MXYHYD3O.js → chunk-657E5BPN.js} +2 -2
- package/dist/{chunk-5IHC7D4U.js → chunk-BCCU3VT5.js} +1 -1
- package/dist/chunk-BCCU3VT5.js.map +1 -0
- package/dist/{chunk-5Z2IWZ5O.js → chunk-FZANAMWH.js} +3 -3
- package/dist/{chunk-OKTDYMSA.js → chunk-GXB4VINL.js} +2 -2
- package/dist/{chunk-YDMDLFU4.js → chunk-JUNV3MUR.js} +2 -2
- package/dist/{chunk-LRAQW3ZK.js → chunk-KO36TK2O.js} +669 -47
- package/dist/chunk-KO36TK2O.js.map +1 -0
- package/dist/{chunk-IHRCKGRS.js → chunk-SE7I6ZXJ.js} +2 -2
- package/dist/{chunk-4Z7LULAM.js → chunk-TOBAQM2G.js} +2 -2
- package/dist/completion/index.js +2 -2
- package/dist/human-input/index.js +2 -2
- package/dist/image/index.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -9
- package/dist/message/index.js +3 -3
- package/dist/selection-toolbar/index.js +2 -2
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +1 -1
- package/dist/styles.css +20 -0
- package/dist/thread-C2-Xo08o.d.ts +102 -0
- package/dist/thread-list/index.js +2 -2
- package/package.json +11 -1
- package/dist/chunk-5IHC7D4U.js.map +0 -1
- package/dist/chunk-LRAQW3ZK.js.map +0 -1
- package/dist/thread-DYPvlsJa.d.ts +0 -38
- /package/dist/{chunk-QHP4GSRG.js.map → chunk-32QFNRXR.js.map} +0 -0
- /package/dist/{chunk-MXYHYD3O.js.map → chunk-657E5BPN.js.map} +0 -0
- /package/dist/{chunk-5Z2IWZ5O.js.map → chunk-FZANAMWH.js.map} +0 -0
- /package/dist/{chunk-OKTDYMSA.js.map → chunk-GXB4VINL.js.map} +0 -0
- /package/dist/{chunk-YDMDLFU4.js.map → chunk-JUNV3MUR.js.map} +0 -0
- /package/dist/{chunk-IHRCKGRS.js.map → chunk-SE7I6ZXJ.js.map} +0 -0
- /package/dist/{chunk-4Z7LULAM.js.map → chunk-TOBAQM2G.js.map} +0 -0
package/README.md
CHANGED
|
@@ -8,6 +8,13 @@ import { ChatProvider, Composer, Message, Thread } from "@anvia/react-ui";
|
|
|
8
8
|
|
|
9
9
|
export function SupportChat() {
|
|
10
10
|
const chat = useChat({ endpoint: "/api/chat" });
|
|
11
|
+
const triggers = [
|
|
12
|
+
{
|
|
13
|
+
id: "people",
|
|
14
|
+
char: "@",
|
|
15
|
+
items: [{ id: "user_ada", label: "Ada Lovelace", data: { type: "user" } }],
|
|
16
|
+
},
|
|
17
|
+
];
|
|
11
18
|
|
|
12
19
|
return (
|
|
13
20
|
<ChatProvider controller={chat}>
|
|
@@ -26,10 +33,11 @@ export function SupportChat() {
|
|
|
26
33
|
<Thread.Error />
|
|
27
34
|
<Thread.ScrollToBottom>Jump to latest</Thread.ScrollToBottom>
|
|
28
35
|
</Thread.Viewport>
|
|
29
|
-
<Composer.Root>
|
|
36
|
+
<Composer.Root triggers={triggers}>
|
|
30
37
|
<Composer.Attachments />
|
|
31
38
|
<Composer.AddAttachment>Attach</Composer.AddAttachment>
|
|
32
39
|
<Composer.Input maxRows={6} placeholder="Send a message..." />
|
|
40
|
+
<Composer.TriggerMenu />
|
|
33
41
|
<Composer.Stop>Stop</Composer.Stop>
|
|
34
42
|
<Composer.Submit>Send</Composer.Submit>
|
|
35
43
|
</Composer.Root>
|
|
@@ -46,3 +54,8 @@ The primitives are headless by default: pass `className` or `asChild` for design
|
|
|
46
54
|
integration, control `Composer.Root` with `input`/`attachments` props when needed, and use
|
|
47
55
|
`submitMessage` for custom composer payloads. Use `keepMounted` on optional collections when empty
|
|
48
56
|
wrappers are useful for layout.
|
|
57
|
+
|
|
58
|
+
`Composer.Input` is a Tiptap-backed rich composer. Configure `Composer.Root` with `triggers` to
|
|
59
|
+
support inline `@`, `/`, `$`, or other entity chips; selected entities are submitted under
|
|
60
|
+
`metadata.composer.entities`. Use `Composer.TextareaInput` when you need the previous native
|
|
61
|
+
textarea behavior.
|
package/dist/attachment/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Attachment
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-32QFNRXR.js";
|
|
4
4
|
import "../chunk-T3ZFZ3NP.js";
|
|
5
5
|
import {
|
|
6
6
|
useAttachment
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-BCCU3VT5.js";
|
|
8
8
|
export {
|
|
9
9
|
Attachment,
|
|
10
10
|
useAttachment
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { C as ChatController } from '../chat-B3kucz1w.js';
|
|
2
2
|
export { a as ChatProvider, b as ChatProviderProps, u as useChatContext } from '../chat-B3kucz1w.js';
|
|
3
|
-
import {
|
|
4
|
-
export { C as ComposerAttachmentInput, a as ComposerAttachmentsUpdate, b as ComposerContextValue, T as ThreadContextValue, u as useComposer,
|
|
3
|
+
import { d as ComposerEntity, f as ComposerQuote, g as ComposerTriggerDefinition, k as ComposerTriggerState, h as ComposerTriggerItem } from '../thread-C2-Xo08o.js';
|
|
4
|
+
export { C as ComposerAttachmentInput, a as ComposerAttachmentsUpdate, b as ComposerContextValue, c as ComposerEntitiesUpdate, e as ComposerEntityData, i as ComposerTriggerItems, j as ComposerTriggerItemsArgs, l as ComposerTriggerStateUpdate, T as ThreadContextValue, u as useComposer, m as useThread } from '../thread-C2-Xo08o.js';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { ReactNode } from 'react';
|
|
7
7
|
import { UIAttachment, UIMessage, UseChatStatus, ChatSuggestion } from '@anvia/react';
|
|
@@ -10,11 +10,14 @@ import { P as PrimitiveProps } from '../render-CRKWam2v.js';
|
|
|
10
10
|
type ComposerSubmitMessageArgs<TEvent = unknown> = {
|
|
11
11
|
input: string;
|
|
12
12
|
attachments: UIAttachment[];
|
|
13
|
+
entities: ComposerEntity[];
|
|
13
14
|
chat: ChatController<TEvent>;
|
|
14
15
|
quote?: ComposerQuote | undefined;
|
|
15
16
|
clear(): void;
|
|
16
17
|
};
|
|
17
18
|
type ComposerSubmitMessage<TEvent = unknown> = (args: ComposerSubmitMessageArgs<TEvent>) => Promise<void> | void;
|
|
19
|
+
type ComposerTriggerMenuChildren = ReactNode | ((trigger: ComposerTriggerState) => ReactNode);
|
|
20
|
+
type ComposerTriggerItemChildren = ReactNode | ((item: ComposerTriggerItem, trigger: ComposerTriggerState) => ReactNode);
|
|
18
21
|
type ComposerAttachmentsChildren = ReactNode | ((attachment: UIAttachment) => ReactNode);
|
|
19
22
|
declare const Composer: {
|
|
20
23
|
readonly Root: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.FormHTMLAttributes<HTMLFormElement>, HTMLFormElement>, "ref">, "asChild"> & {
|
|
@@ -22,14 +25,18 @@ declare const Composer: {
|
|
|
22
25
|
} & {
|
|
23
26
|
attachments?: UIAttachment[];
|
|
24
27
|
defaultAttachments?: UIAttachment[];
|
|
28
|
+
defaultEntities?: ComposerEntity[];
|
|
25
29
|
defaultInput?: string;
|
|
26
30
|
defaultQuote?: ComposerQuote | undefined;
|
|
31
|
+
entities?: ComposerEntity[];
|
|
27
32
|
input?: string;
|
|
28
33
|
onAttachmentsChange?: (attachments: UIAttachment[]) => void;
|
|
34
|
+
onEntitiesChange?: (entities: ComposerEntity[]) => void;
|
|
29
35
|
onInputChange?: (input: string) => void;
|
|
30
36
|
onQuoteChange?: (quote: ComposerQuote | undefined) => void;
|
|
31
37
|
quote?: ComposerQuote | undefined;
|
|
32
38
|
submitMessage?: ComposerSubmitMessage;
|
|
39
|
+
triggers?: ComposerTriggerDefinition[];
|
|
33
40
|
} & react.RefAttributes<HTMLFormElement>>;
|
|
34
41
|
readonly Quote: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"blockquote">, "children"> & {
|
|
35
42
|
children?: ReactNode | ((quote: ComposerQuote) => ReactNode);
|
|
@@ -37,13 +44,31 @@ declare const Composer: {
|
|
|
37
44
|
readonly ClearQuote: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
38
45
|
asChild?: boolean;
|
|
39
46
|
} & react.RefAttributes<HTMLButtonElement>>;
|
|
40
|
-
readonly Input: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.
|
|
47
|
+
readonly Input: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
48
|
+
asChild?: boolean;
|
|
49
|
+
} & {
|
|
50
|
+
autoResize?: boolean;
|
|
51
|
+
disabled?: boolean | undefined;
|
|
52
|
+
maxRows?: number;
|
|
53
|
+
minRows?: number;
|
|
54
|
+
placeholder?: string | undefined;
|
|
55
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
56
|
+
readonly TextareaInput: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref">, "asChild"> & {
|
|
41
57
|
asChild?: boolean;
|
|
42
58
|
} & {
|
|
43
59
|
autoResize?: boolean;
|
|
44
60
|
maxRows?: number;
|
|
45
61
|
minRows?: number;
|
|
46
62
|
} & react.RefAttributes<HTMLTextAreaElement>>;
|
|
63
|
+
readonly TriggerMenu: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
|
|
64
|
+
children?: ComposerTriggerMenuChildren;
|
|
65
|
+
keepMounted?: boolean;
|
|
66
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
67
|
+
readonly TriggerItem: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"button">, "children"> & {
|
|
68
|
+
children?: ComposerTriggerItemChildren;
|
|
69
|
+
index?: number | undefined;
|
|
70
|
+
item?: ComposerTriggerItem | undefined;
|
|
71
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
|
47
72
|
readonly Attachments: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
|
|
48
73
|
children?: ComposerAttachmentsChildren;
|
|
49
74
|
keepMounted?: boolean;
|
|
@@ -114,4 +139,4 @@ declare const Thread: {
|
|
|
114
139
|
} & react.RefAttributes<HTMLButtonElement>>;
|
|
115
140
|
};
|
|
116
141
|
|
|
117
|
-
export { ChatController, Composer, ComposerQuote, type ComposerSubmitMessage, type ComposerSubmitMessageArgs, Thread };
|
|
142
|
+
export { ChatController, Composer, ComposerEntity, ComposerQuote, type ComposerSubmitMessage, type ComposerSubmitMessageArgs, ComposerTriggerDefinition, ComposerTriggerItem, ComposerTriggerState, Thread };
|
package/dist/chat/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Composer,
|
|
3
3
|
Thread
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-KO36TK2O.js";
|
|
5
|
+
import "../chunk-FZANAMWH.js";
|
|
6
|
+
import "../chunk-32QFNRXR.js";
|
|
7
7
|
import "../chunk-T3ZFZ3NP.js";
|
|
8
8
|
import {
|
|
9
9
|
ChatProvider,
|
|
10
10
|
useChatContext,
|
|
11
11
|
useComposer,
|
|
12
12
|
useThread
|
|
13
|
-
} from "../chunk-
|
|
13
|
+
} from "../chunk-BCCU3VT5.js";
|
|
14
14
|
export {
|
|
15
15
|
ChatProvider,
|
|
16
16
|
Composer,
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-T3ZFZ3NP.js";
|
|
4
4
|
import {
|
|
5
5
|
useAttachment
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BCCU3VT5.js";
|
|
7
7
|
|
|
8
8
|
// src/attachment/parts.tsx
|
|
9
9
|
import { forwardRef, useCallback } from "react";
|
|
@@ -122,4 +122,4 @@ var Attachment = {
|
|
|
122
122
|
export {
|
|
123
123
|
Attachment
|
|
124
124
|
};
|
|
125
|
-
//# sourceMappingURL=chunk-
|
|
125
|
+
//# sourceMappingURL=chunk-32QFNRXR.js.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
InternalThreadListItemProvider,
|
|
6
6
|
useThreadList,
|
|
7
7
|
useThreadListItem
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-BCCU3VT5.js";
|
|
9
9
|
|
|
10
10
|
// src/thread-list/parts.tsx
|
|
11
11
|
import {
|
|
@@ -288,4 +288,4 @@ export {
|
|
|
288
288
|
ThreadList,
|
|
289
289
|
ThreadListItem
|
|
290
290
|
};
|
|
291
|
-
//# sourceMappingURL=chunk-
|
|
291
|
+
//# sourceMappingURL=chunk-657E5BPN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/contexts/attachment.tsx","../src/contexts/chat.tsx","../src/contexts/completion.tsx","../src/contexts/completion-input.tsx","../src/contexts/composer.tsx","../src/contexts/human-input.tsx","../src/contexts/image.tsx","../src/contexts/message.tsx","../src/contexts/selection-toolbar.tsx","../src/contexts/thread.tsx","../src/contexts/thread-list.tsx"],"sourcesContent":["import type { UIAttachment } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type AttachmentContextValue = {\n attachment: UIAttachment;\n remove?(): void;\n};\n\nconst AttachmentContext = createContext<AttachmentContextValue | undefined>(undefined);\n\nexport function InternalAttachmentProvider({\n value,\n children,\n}: {\n value: AttachmentContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(AttachmentContext.Provider, { value }, children);\n}\n\nexport function useAttachment(): AttachmentContextValue {\n const value = useContext(AttachmentContext);\n if (value === undefined) {\n throw new Error(\"Attachment primitives must be used inside Attachment.Root.\");\n }\n return value;\n}\n\nexport function useOptionalAttachment(): AttachmentContextValue | undefined {\n return useContext(AttachmentContext);\n}\n","import type { UseChatResult } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ChatController<TEvent = unknown> = UseChatResult<TEvent>;\n\nexport type ChatProviderProps<TEvent = unknown> = {\n controller: ChatController<TEvent>;\n children?: ReactNode;\n};\n\nconst ChatContext = createContext<ChatController | undefined>(undefined);\n\nexport function ChatProvider<TEvent = unknown>({\n controller,\n children,\n}: ChatProviderProps<TEvent>): ReactElement {\n return createElement(ChatContext.Provider, { value: controller as ChatController }, children);\n}\n\nexport function useChatContext<TEvent = unknown>(): ChatController<TEvent> {\n const value = useContext(ChatContext);\n if (value === undefined) {\n throw new Error(\"Anvia chat primitives must be used inside ChatProvider.\");\n }\n return value as ChatController<TEvent>;\n}\n\nexport function useHumanInput(): ChatController[\"humanInput\"] {\n return useChatContext().humanInput;\n}\n","import type { UseCompletionResult } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type CompletionController<TEvent = unknown> = UseCompletionResult<TEvent>;\n\nexport type CompletionProviderProps<TEvent = unknown> = {\n controller: CompletionController<TEvent>;\n children?: ReactNode;\n};\n\nconst CompletionContext = createContext<CompletionController | undefined>(undefined);\n\nexport function CompletionProvider<TEvent = unknown>({\n controller,\n children,\n}: CompletionProviderProps<TEvent>): ReactElement {\n return createElement(\n CompletionContext.Provider,\n { value: controller as CompletionController },\n children,\n );\n}\n\nexport function useCompletionContext<TEvent = unknown>(): CompletionController<TEvent> {\n const value = useContext(CompletionContext);\n if (value === undefined) {\n throw new Error(\"Anvia completion primitives must be used inside CompletionProvider.\");\n }\n return value as CompletionController<TEvent>;\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nimport type { CompletionController } from \"./completion\";\n\nexport type CompletionInputContextValue = {\n input: string;\n setInput(input: string): void;\n submit(): Promise<void>;\n stop(): void;\n status: CompletionController[\"status\"];\n canSubmit: boolean;\n canStop: boolean;\n};\n\nconst CompletionInputContext = createContext<CompletionInputContextValue | undefined>(undefined);\n\nexport function InternalCompletionInputProvider({\n value,\n children,\n}: {\n value: CompletionInputContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(CompletionInputContext.Provider, { value }, children);\n}\n\nexport function useCompletionInput(): CompletionInputContextValue {\n const value = useContext(CompletionInputContext);\n if (value === undefined) {\n throw new Error(\"Completion input primitives must be used inside Completion.Form.\");\n }\n return value;\n}\n","import type { CreateUIAttachment, UIAttachment } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\nimport type { ChatController } from \"./chat\";\n\nexport type ComposerEntityData =\n | string\n | number\n | boolean\n | null\n | ComposerEntityData[]\n | { [key: string]: ComposerEntityData | undefined };\n\nexport type ComposerAttachmentInput = File | CreateUIAttachment;\nexport type ComposerAttachmentsUpdate =\n | UIAttachment[]\n | ((attachments: UIAttachment[]) => UIAttachment[]);\nexport type ComposerEntitiesUpdate =\n | ComposerEntity[]\n | ((entities: ComposerEntity[]) => ComposerEntity[]);\nexport type ComposerQuote = {\n text: string;\n messageId: string;\n};\nexport type ComposerTriggerItem = {\n id: string;\n label: string;\n text?: string | undefined;\n detail?: ReactNode | undefined;\n data?: ComposerEntityData | undefined;\n disabled?: boolean | undefined;\n};\nexport type ComposerTriggerItemsArgs = {\n trigger: ComposerTriggerDefinition;\n query: string;\n input: string;\n entities: ComposerEntity[];\n signal: AbortSignal;\n};\nexport type ComposerTriggerItems =\n | ComposerTriggerItem[]\n | ((args: ComposerTriggerItemsArgs) => ComposerTriggerItem[] | Promise<ComposerTriggerItem[]>);\nexport type ComposerTriggerDefinition = {\n id: string;\n char: string;\n items: ComposerTriggerItems;\n minQueryLength?: number | undefined;\n allowedPrefixes?: string[] | null | undefined;\n startOfLine?: boolean | undefined;\n allowSpaces?: boolean | undefined;\n};\nexport type ComposerEntity = {\n id: string;\n triggerId: string;\n trigger: string;\n label: string;\n text: string;\n range: {\n from: number;\n to: number;\n };\n data?: ComposerEntityData | undefined;\n};\nexport type ComposerTriggerState = {\n trigger: ComposerTriggerDefinition;\n query: string;\n items: ComposerTriggerItem[];\n loading: boolean;\n selectedIndex: number;\n rect?: {\n top: number;\n right: number;\n bottom: number;\n left: number;\n width: number;\n height: number;\n };\n selectItem(item: ComposerTriggerItem): void;\n setSelectedIndex(index: number): void;\n};\nexport type ComposerTriggerStateUpdate =\n | ComposerTriggerState\n | undefined\n | ((state: ComposerTriggerState | undefined) => ComposerTriggerState | undefined);\n\nexport type ComposerContextValue = {\n input: string;\n setInput(input: string): void;\n attachments: UIAttachment[];\n setAttachments(update: ComposerAttachmentsUpdate): void;\n addAttachment(attachment: ComposerAttachmentInput): Promise<void>;\n removeAttachment(id: string): void;\n clearAttachments(): void;\n entities: ComposerEntity[];\n setEntities(update: ComposerEntitiesUpdate): void;\n quote?: ComposerQuote | undefined;\n setQuote(quote: ComposerQuote | undefined): void;\n clearQuote(): void;\n triggers: ComposerTriggerDefinition[];\n activeTrigger?: ComposerTriggerState | undefined;\n setActiveTrigger(update: ComposerTriggerStateUpdate): void;\n submit(): Promise<void>;\n stop(): void;\n status: ChatController[\"status\"];\n canSubmit: boolean;\n canStop: boolean;\n};\n\nconst ComposerContext = createContext<ComposerContextValue | undefined>(undefined);\n\nexport function InternalComposerProvider({\n value,\n children,\n}: {\n value: ComposerContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ComposerContext.Provider, { value }, children);\n}\n\nexport function useComposer(): ComposerContextValue {\n const value = useContext(ComposerContext);\n if (value === undefined) {\n throw new Error(\"Composer primitives must be used inside Composer.Root.\");\n }\n return value;\n}\n","import type {\n ToolApproval,\n ToolQuestion,\n ToolQuestionAnswer,\n ToolQuestionPrompt,\n} from \"@anvia/react\";\nimport {\n createContext,\n createElement,\n type ReactElement,\n type ReactNode,\n useContext,\n useMemo,\n useState,\n} from \"react\";\n\nexport type ApprovalContextValue = {\n approval: ToolApproval;\n reason: string;\n setReason(reason: string): void;\n};\n\nexport type QuestionContextValue = {\n question: ToolQuestion;\n answers: Record<string, ToolQuestionAnswer>;\n setAnswer(prompt: ToolQuestionPrompt, answer: ToolQuestionAnswer): void;\n};\n\nexport type QuestionPromptContextValue = {\n prompt: ToolQuestionPrompt;\n};\n\nconst ApprovalContext = createContext<ApprovalContextValue | undefined>(undefined);\nconst QuestionContext = createContext<QuestionContextValue | undefined>(undefined);\nconst QuestionPromptContext = createContext<QuestionPromptContextValue | undefined>(undefined);\n\nexport function InternalApprovalProvider({\n approval,\n children,\n}: {\n approval: ToolApproval;\n children?: ReactNode;\n}): ReactElement {\n const [reason, setReason] = useState(\"\");\n const value = useMemo<ApprovalContextValue>(\n () => ({ approval, reason, setReason }),\n [approval, reason],\n );\n\n return createElement(ApprovalContext.Provider, { value }, children);\n}\n\nexport function InternalQuestionProvider({\n value,\n children,\n}: {\n value: QuestionContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(QuestionContext.Provider, { value }, children);\n}\n\nexport function InternalQuestionPromptProvider({\n prompt,\n children,\n}: {\n prompt: ToolQuestionPrompt;\n children?: ReactNode;\n}): ReactElement {\n return createElement(QuestionPromptContext.Provider, { value: { prompt } }, children);\n}\n\nexport function useApproval(): ApprovalContextValue {\n const value = useContext(ApprovalContext);\n if (value === undefined) {\n throw new Error(\"Approval primitives must be used inside HumanInput.Approval.\");\n }\n return value;\n}\n\nexport function useQuestion(): QuestionContextValue {\n const value = useContext(QuestionContext);\n if (value === undefined) {\n throw new Error(\"Question primitives must be used inside HumanInput.Question.\");\n }\n return value;\n}\n\nexport function useQuestionPrompt(): QuestionPromptContextValue {\n const value = useContext(QuestionPromptContext);\n if (value === undefined) {\n throw new Error(\"Question choice primitives must be used inside HumanInput.QuestionPrompt.\");\n }\n return value;\n}\n","import type { UIAttachment } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ImageContextValue = {\n attachment: UIAttachment;\n src?: string;\n name?: string;\n mediaType?: string;\n isImage: boolean;\n zoomOpen: boolean;\n setZoomOpen(open: boolean): void;\n};\n\nconst ImageContext = createContext<ImageContextValue | undefined>(undefined);\n\nexport function InternalImageProvider({\n value,\n children,\n}: {\n value: ImageContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ImageContext.Provider, { value }, children);\n}\n\nexport function useImage(): ImageContextValue {\n const value = useContext(ImageContext);\n if (value === undefined) {\n throw new Error(\"Image primitives must be used inside Image.Root.\");\n }\n return value;\n}\n","import type { UIMessage, UIMessagePart } from \"@anvia/react\";\nimport { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type MessageContextValue = {\n message: UIMessage;\n};\n\nexport type MessagePartContextValue = {\n part: UIMessagePart;\n};\n\nconst MessageContext = createContext<MessageContextValue | undefined>(undefined);\nconst MessagePartContext = createContext<MessagePartContextValue | undefined>(undefined);\n\nexport function InternalMessageProvider({\n message,\n children,\n}: {\n message: UIMessage;\n children?: ReactNode;\n}): ReactElement {\n return createElement(MessageContext.Provider, { value: { message } }, children);\n}\n\nexport function InternalMessagePartProvider({\n part,\n children,\n}: {\n part: UIMessagePart;\n children?: ReactNode;\n}): ReactElement {\n return createElement(MessagePartContext.Provider, { value: { part } }, children);\n}\n\nexport function useMessage(): MessageContextValue {\n const value = useContext(MessageContext);\n if (value === undefined) {\n throw new Error(\"Message primitives must be used inside Message.Root or Thread.Messages.\");\n }\n return value;\n}\n\nexport function useMessagePart(): MessagePartContextValue {\n const value = useContext(MessagePartContext);\n if (value === undefined) {\n throw new Error(\"Message part primitives must be used inside Message.Parts or Message.Part.\");\n }\n return value;\n}\n\nexport function useOptionalMessagePart(): MessagePartContextValue | undefined {\n return useContext(MessagePartContext);\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type SelectionToolbarSelection = {\n text: string;\n messageId: string;\n rect: DOMRect;\n};\n\nexport type SelectionToolbarContextValue = {\n selection?: SelectionToolbarSelection;\n quote(): void;\n copy(): Promise<void>;\n clear(): void;\n};\n\nconst SelectionToolbarContext = createContext<SelectionToolbarContextValue | undefined>(undefined);\n\nexport function InternalSelectionToolbarProvider({\n value,\n children,\n}: {\n value: SelectionToolbarContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(SelectionToolbarContext.Provider, { value }, children);\n}\n\nexport function useSelectionToolbar(): SelectionToolbarContextValue {\n const value = useContext(SelectionToolbarContext);\n if (value === undefined) {\n throw new Error(\"SelectionToolbar primitives must be used inside SelectionToolbar.Root.\");\n }\n return value;\n}\n","import {\n createContext,\n createElement,\n type MutableRefObject,\n type ReactElement,\n type ReactNode,\n useContext,\n} from \"react\";\n\nexport type ThreadContextValue = {\n viewportRef: MutableRefObject<HTMLElement | null>;\n atBottom: boolean;\n setAtBottom(atBottom: boolean): void;\n scrollToBottom(behavior?: ScrollBehavior): void;\n};\n\nconst ThreadContext = createContext<ThreadContextValue | undefined>(undefined);\n\nexport function InternalThreadProvider({\n value,\n children,\n}: {\n value: ThreadContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ThreadContext.Provider, { value }, children);\n}\n\nexport function useThread(): ThreadContextValue {\n const value = useContext(ThreadContext);\n if (value === undefined) {\n throw new Error(\"Thread primitives must be used inside Thread.Root.\");\n }\n return value;\n}\n","import { createContext, createElement, type ReactElement, type ReactNode, useContext } from \"react\";\n\nexport type ThreadListRecord = {\n id: string;\n title?: string;\n createdAt?: string | Date;\n updatedAt?: string | Date;\n archived?: boolean;\n metadata?: unknown;\n};\n\nexport type ThreadListController = {\n threads: ThreadListRecord[];\n activeThreadId?: string;\n status?: \"idle\" | \"loading\" | \"error\";\n error?: unknown;\n createThread(): Promise<void> | void;\n switchThread(threadId: string): Promise<void> | void;\n archiveThread?(threadId: string): Promise<void> | void;\n unarchiveThread?(threadId: string): Promise<void> | void;\n deleteThread?(threadId: string): Promise<void> | void;\n};\n\nexport type ThreadListItemContextValue = {\n thread: ThreadListRecord;\n active: boolean;\n};\n\nexport type ThreadListProviderProps = {\n controller: ThreadListController;\n children?: ReactNode;\n};\n\nconst ThreadListContext = createContext<ThreadListController | undefined>(undefined);\nconst ThreadListItemContext = createContext<ThreadListItemContextValue | undefined>(undefined);\n\nexport function ThreadListProvider({\n controller,\n children,\n}: ThreadListProviderProps): ReactElement {\n return createElement(ThreadListContext.Provider, { value: controller }, children);\n}\n\nexport function InternalThreadListItemProvider({\n value,\n children,\n}: {\n value: ThreadListItemContextValue;\n children?: ReactNode;\n}): ReactElement {\n return createElement(ThreadListItemContext.Provider, { value }, children);\n}\n\nexport function useThreadList(): ThreadListController {\n const value = useContext(ThreadListContext);\n if (value === undefined) {\n throw new Error(\"ThreadList primitives must be used inside ThreadListProvider.\");\n }\n return value;\n}\n\nexport function useThreadListItem(): ThreadListItemContextValue {\n const value = useContext(ThreadListItemContext);\n if (value === undefined) {\n throw new Error(\"ThreadListItem primitives must be used inside ThreadList.Items.\");\n }\n return value;\n}\n"],"mappings":";AACA,SAAS,eAAe,eAAkD,kBAAkB;AAO5F,IAAM,oBAAoB,cAAkD,MAAS;AAE9E,SAAS,2BAA2B;AAAA,EACzC;AAAA,EACA;AACF,GAGiB;AACf,SAAO,cAAc,kBAAkB,UAAU,EAAE,MAAM,GAAG,QAAQ;AACtE;AAEO,SAAS,gBAAwC;AACtD,QAAM,QAAQ,WAAW,iBAAiB;AAC1C,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,4DAA4D;AAAA,EAC9E;AACA,SAAO;AACT;AAEO,SAAS,wBAA4D;AAC1E,SAAO,WAAW,iBAAiB;AACrC;;;AC7BA,SAAS,iBAAAA,gBAAe,iBAAAC,gB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,UAAM,IAAI,MAAM,+DAA+D;AAAA,EACjF;AACA,SAAO;AACT;AAEO,SAAS,oBAAgD;AAC9D,QAAM,QAAQA,aAAW,qBAAqB;AAC9C,MAAI,UAAU,QAAW;AACvB,UAAM,IAAI,MAAM,iEAAiE;AAAA,EACnF;AACA,SAAO;AACT;","names":["createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext","createContext","createElement","useContext"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Attachment
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-32QFNRXR.js";
|
|
4
4
|
import {
|
|
5
5
|
renderPrimitive
|
|
6
6
|
} from "./chunk-T3ZFZ3NP.js";
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
useMessage,
|
|
12
12
|
useMessagePart,
|
|
13
13
|
useOptionalMessagePart
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BCCU3VT5.js";
|
|
15
15
|
|
|
16
16
|
// src/message/actions.tsx
|
|
17
17
|
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
@@ -527,4 +527,4 @@ var Message = {
|
|
|
527
527
|
export {
|
|
528
528
|
Message
|
|
529
529
|
};
|
|
530
|
-
//# sourceMappingURL=chunk-
|
|
530
|
+
//# sourceMappingURL=chunk-FZANAMWH.js.map
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
InternalSelectionToolbarProvider,
|
|
6
6
|
useSelectionToolbar
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BCCU3VT5.js";
|
|
8
8
|
|
|
9
9
|
// src/selection-toolbar/parts.tsx
|
|
10
10
|
import {
|
|
@@ -233,4 +233,4 @@ var SelectionToolbar = {
|
|
|
233
233
|
export {
|
|
234
234
|
SelectionToolbar
|
|
235
235
|
};
|
|
236
|
-
//# sourceMappingURL=chunk-
|
|
236
|
+
//# sourceMappingURL=chunk-GXB4VINL.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
useHumanInput,
|
|
11
11
|
useQuestion,
|
|
12
12
|
useQuestionPrompt
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BCCU3VT5.js";
|
|
14
14
|
|
|
15
15
|
// src/human-input/approvals.tsx
|
|
16
16
|
import { forwardRef, useCallback } from "react";
|
|
@@ -408,4 +408,4 @@ var HumanInput = {
|
|
|
408
408
|
export {
|
|
409
409
|
HumanInput
|
|
410
410
|
};
|
|
411
|
-
//# sourceMappingURL=chunk-
|
|
411
|
+
//# sourceMappingURL=chunk-JUNV3MUR.js.map
|