@anvia/react-ui 0.2.0 → 0.3.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/attachment/index.js +2 -2
- package/dist/chat/index.d.ts +13 -2
- package/dist/chat/index.js +4 -4
- package/dist/{chunk-LSHD67YK.js → chunk-4Z7LULAM.js} +2 -2
- package/dist/{chunk-7AS6R7BB.js → chunk-5IHC7D4U.js} +93 -16
- package/dist/chunk-5IHC7D4U.js.map +1 -0
- package/dist/{chunk-AOZN3SWB.js → chunk-5Z2IWZ5O.js} +4 -3
- package/dist/{chunk-AOZN3SWB.js.map → chunk-5Z2IWZ5O.js.map} +1 -1
- package/dist/chunk-IHRCKGRS.js +432 -0
- package/dist/chunk-IHRCKGRS.js.map +1 -0
- package/dist/{chunk-AXZB6JSE.js → chunk-LRAQW3ZK.js} +125 -11
- package/dist/chunk-LRAQW3ZK.js.map +1 -0
- package/dist/chunk-MXYHYD3O.js +291 -0
- package/dist/chunk-MXYHYD3O.js.map +1 -0
- package/dist/chunk-OKTDYMSA.js +236 -0
- package/dist/chunk-OKTDYMSA.js.map +1 -0
- package/dist/{chunk-RRINF6FN.js → chunk-QHP4GSRG.js} +2 -2
- package/dist/{chunk-WK33ER4Q.js → chunk-YDMDLFU4.js} +2 -2
- package/dist/completion/index.js +2 -2
- package/dist/human-input/index.js +2 -2
- package/dist/image/index.d.ts +40 -0
- package/dist/image/index.js +12 -0
- package/dist/image/index.js.map +1 -0
- package/dist/image-DanUxcl2.d.ts +14 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +32 -8
- package/dist/message/index.js +3 -3
- package/dist/selection-toolbar/index.d.ts +21 -0
- package/dist/selection-toolbar/index.js +12 -0
- package/dist/selection-toolbar/index.js.map +1 -0
- package/dist/selection-toolbar-Cwjbuv5S.d.ts +14 -0
- package/dist/shared.d.ts +4 -1
- package/dist/shared.js +13 -3
- package/dist/styles.css +22 -0
- package/dist/{thread-CluT3m5k.d.ts → thread-DYPvlsJa.d.ts} +8 -1
- package/dist/thread-list/index.d.ts +47 -0
- package/dist/thread-list/index.js +18 -0
- package/dist/thread-list/index.js.map +1 -0
- package/dist/thread-list-On8db4XL.d.ts +34 -0
- package/package.json +17 -4
- package/dist/chunk-7AS6R7BB.js.map +0 -1
- package/dist/chunk-AXZB6JSE.js.map +0 -1
- /package/dist/{chunk-LSHD67YK.js.map → chunk-4Z7LULAM.js.map} +0 -0
- /package/dist/{chunk-RRINF6FN.js.map → chunk-QHP4GSRG.js.map} +0 -0
- /package/dist/{chunk-WK33ER4Q.js.map → chunk-YDMDLFU4.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/thread-list/parts.tsx","../src/thread-list/index.ts"],"sourcesContent":["import {\n forwardRef,\n type KeyboardEvent,\n type MouseEvent,\n type ReactNode,\n useCallback,\n} from \"react\";\n\nimport {\n InternalThreadListItemProvider,\n type ThreadListRecord,\n useThreadList,\n useThreadListItem,\n} from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype ThreadListRootProps = PrimitiveProps<\"div\">;\n\nconst ThreadListRoot = forwardRef<HTMLDivElement, ThreadListRootProps>(function ThreadListRoot(\n { onKeyDown, ...props },\n ref,\n) {\n const threadList = useThreadList();\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || ![\"ArrowDown\", \"ArrowUp\", \"Home\", \"End\"].includes(event.key)) {\n return;\n }\n const triggers = Array.from(\n event.currentTarget.querySelectorAll<HTMLButtonElement>(\n \"[data-anvia-thread-list-trigger]:not(:disabled)\",\n ),\n );\n if (triggers.length === 0) {\n return;\n }\n event.preventDefault();\n const activeElement = document.activeElement;\n const currentIndex =\n activeElement instanceof HTMLButtonElement ? triggers.indexOf(activeElement) : -1;\n const nextIndex = nextTriggerIndex(event.key, currentIndex, triggers.length);\n triggers[nextIndex]?.focus();\n },\n [onKeyDown],\n );\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n onKeyDown: handleKeyDown,\n \"data-anvia-thread-list\": \"\",\n \"data-state\": threadList.status ?? \"idle\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst ThreadListNew = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function ThreadListNew({ onClick, ...props }, ref) {\n const threadList = useThreadList();\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || props.disabled) {\n return;\n }\n void threadList.createThread();\n },\n [onClick, props.disabled, threadList],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"New chat\",\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-thread-list-new\": \"\",\n \"data-state\": props.disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\ntype ThreadListItemsChildren = ReactNode | ((thread: ThreadListRecord) => ReactNode);\n\ntype ThreadListItemsProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n archived?: boolean;\n children?: ThreadListItemsChildren;\n keepMounted?: boolean;\n};\n\nconst ThreadListItems = forwardRef<HTMLDivElement, ThreadListItemsProps>(function ThreadListItems(\n { archived = false, children, keepMounted = false, ...props },\n ref,\n) {\n const threadList = useThreadList();\n const threads = threadList.threads.filter((thread) => Boolean(thread.archived) === archived);\n const empty = threads.length === 0;\n if (empty && !keepMounted) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: threads.map((thread) => (\n <InternalThreadListItemProvider\n key={thread.id}\n value={{ thread, active: thread.id === threadList.activeThreadId }}\n >\n {typeof children === \"function\" ? children(thread) : (children ?? <DefaultThreadItem />)}\n </InternalThreadListItemProvider>\n )),\n \"data-anvia-thread-list-items\": \"\",\n \"data-archived\": archived ? \"\" : undefined,\n \"data-empty\": empty ? \"\" : undefined,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\ntype ThreadListEmptyProps = PrimitiveProps<\"div\"> & {\n archived?: boolean;\n};\n\nconst ThreadListEmpty = forwardRef<HTMLDivElement, ThreadListEmptyProps>(function ThreadListEmpty(\n { archived = false, ...props },\n ref,\n) {\n const threadList = useThreadList();\n const hasVisibleThreads = threadList.threads.some(\n (thread) => Boolean(thread.archived) === archived,\n );\n if (hasVisibleThreads) {\n return null;\n }\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n children: props.children ?? \"No conversations.\",\n \"data-anvia-thread-list-empty\": \"\",\n } as PrimitiveProps<\"div\">,\n ref,\n );\n});\n\nconst ThreadListItemRoot = forwardRef<HTMLDivElement, PrimitiveProps<\"div\">>(\n function ThreadListItemRoot(props, ref) {\n const item = useThreadListItem();\n\n return renderPrimitive(\n \"div\",\n {\n ...props,\n \"data-anvia-thread-list-item\": \"\",\n \"data-active\": item.active ? \"\" : undefined,\n \"data-thread-id\": item.thread.id,\n } as PrimitiveProps<\"div\">,\n ref,\n );\n },\n);\n\nconst ThreadListItemTrigger = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function ThreadListItemTrigger({ onClick, ...props }, ref) {\n const threadList = useThreadList();\n const item = useThreadListItem();\n const disabled = props.disabled ?? false;\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n void threadList.switchThread(item.thread.id);\n },\n [disabled, item.thread.id, onClick, threadList],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? <ThreadListItemTitle />,\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"aria-current\": item.active ? \"true\" : undefined,\n \"data-anvia-thread-list-trigger\": \"\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\ntype ThreadListItemTitleProps = PrimitiveProps<\"span\"> & {\n fallback?: ReactNode;\n};\n\nconst ThreadListItemTitle = forwardRef<HTMLSpanElement, ThreadListItemTitleProps>(\n function ThreadListItemTitle({ fallback = \"New chat\", ...props }, ref) {\n const { thread } = useThreadListItem();\n\n return renderPrimitive(\n \"span\",\n {\n ...props,\n children: props.children ?? thread.title ?? fallback,\n \"data-anvia-thread-list-title\": \"\",\n } as PrimitiveProps<\"span\">,\n ref,\n );\n },\n);\n\ntype ThreadListItemActionKey = \"archiveThread\" | \"unarchiveThread\" | \"deleteThread\";\ntype ThreadListItemActionDataAttribute =\n | \"data-anvia-thread-list-archive\"\n | \"data-anvia-thread-list-unarchive\"\n | \"data-anvia-thread-list-delete\";\n\nfunction createThreadListItemAction(\n action: ThreadListItemActionKey,\n defaultLabel: string,\n dataAttribute: ThreadListItemActionDataAttribute,\n) {\n return forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(function ThreadListItemAction(\n { onClick, ...props },\n ref,\n ) {\n const threadList = useThreadList();\n const { thread } = useThreadListItem();\n const actionHandler = threadList[action];\n const disabled = props.disabled ?? actionHandler === undefined;\n\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n focusAfterThreadItemRemoval(event.currentTarget);\n void actionHandler?.(thread.id);\n },\n [actionHandler, disabled, onClick, thread.id],\n );\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? defaultLabel,\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n [dataAttribute]: \"\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n });\n}\n\nconst ThreadListItemArchive = createThreadListItemAction(\n \"archiveThread\",\n \"Archive\",\n \"data-anvia-thread-list-archive\",\n);\nconst ThreadListItemUnarchive = createThreadListItemAction(\n \"unarchiveThread\",\n \"Unarchive\",\n \"data-anvia-thread-list-unarchive\",\n);\nconst ThreadListItemDelete = createThreadListItemAction(\n \"deleteThread\",\n \"Delete\",\n \"data-anvia-thread-list-delete\",\n);\n\nfunction DefaultThreadItem(): ReactNode {\n return (\n <ThreadListItemRoot>\n <ThreadListItemTrigger />\n </ThreadListItemRoot>\n );\n}\n\nfunction nextTriggerIndex(key: string, currentIndex: number, triggerCount: number): number {\n if (key === \"Home\") {\n return 0;\n }\n if (key === \"End\") {\n return triggerCount - 1;\n }\n if (currentIndex === -1) {\n return key === \"ArrowUp\" ? triggerCount - 1 : 0;\n }\n if (key === \"ArrowUp\") {\n return (currentIndex - 1 + triggerCount) % triggerCount;\n }\n return (currentIndex + 1) % triggerCount;\n}\n\nfunction focusAfterThreadItemRemoval(actionButton: HTMLButtonElement): void {\n const root = actionButton.closest<HTMLElement>(\"[data-anvia-thread-list]\");\n const currentItem = actionButton.closest<HTMLElement>(\"[data-anvia-thread-list-item]\");\n if (\n root === null ||\n currentItem === null ||\n !currentItem.contains(root.ownerDocument.activeElement)\n ) {\n return;\n }\n\n const triggers = Array.from(\n root.querySelectorAll<HTMLButtonElement>(\"[data-anvia-thread-list-trigger]:not(:disabled)\"),\n );\n const currentTrigger = currentItem.querySelector<HTMLButtonElement>(\n \"[data-anvia-thread-list-trigger]\",\n );\n const currentIndex = currentTrigger === null ? -1 : triggers.indexOf(currentTrigger);\n const remainingTriggers = triggers.filter((trigger) => !currentItem.contains(trigger));\n const fallback = root.querySelector<HTMLButtonElement>(\n \"[data-anvia-thread-list-new]:not(:disabled)\",\n );\n const focusTarget =\n remainingTriggers[Math.min(Math.max(currentIndex, 0), remainingTriggers.length - 1)] ??\n fallback ??\n root;\n\n if (focusTarget === root && !root.hasAttribute(\"tabindex\")) {\n root.tabIndex = -1;\n }\n focusTarget.focus();\n}\n\nexport {\n ThreadListEmpty,\n ThreadListItemArchive,\n ThreadListItemDelete,\n ThreadListItemRoot,\n ThreadListItems,\n ThreadListItemTitle,\n ThreadListItemTrigger,\n ThreadListItemUnarchive,\n ThreadListNew,\n ThreadListRoot,\n};\n","import {\n ThreadListEmpty,\n ThreadListItemArchive,\n ThreadListItemDelete,\n ThreadListItemRoot,\n ThreadListItems,\n ThreadListItemTitle,\n ThreadListItemTrigger,\n ThreadListItemUnarchive,\n ThreadListNew,\n ThreadListRoot,\n} from \"./parts\";\n\nexport const ThreadList = {\n Root: ThreadListRoot,\n New: ThreadListNew,\n Items: ThreadListItems,\n Empty: ThreadListEmpty,\n} as const;\n\nexport const ThreadListItem = {\n Root: ThreadListItemRoot,\n Trigger: ThreadListItemTrigger,\n Title: ThreadListItemTitle,\n Archive: ThreadListItemArchive,\n Unarchive: ThreadListItemUnarchive,\n Delete: ThreadListItemDelete,\n} as const;\n\nexport type {\n ThreadListController,\n ThreadListItemContextValue,\n ThreadListProviderProps,\n ThreadListRecord,\n} from \"../contexts\";\nexport { ThreadListProvider, useThreadList, useThreadListItem } from \"../contexts\";\n"],"mappings":";;;;;;;;;;AAAA;AAAA,EACE;AAAA,EAIA;AAAA,OACK;AAgHqE;AApG5E,IAAM,iBAAiB,WAAgD,SAASA,gBAC9E,EAAE,WAAW,GAAG,MAAM,GACtB,KACA;AACA,QAAM,aAAa,cAAc;AAEjC,QAAM,gBAAgB;AAAA,IACpB,CAAC,UAAyC;AACxC,kBAAY,KAAK;AACjB,UAAI,MAAM,oBAAoB,CAAC,CAAC,aAAa,WAAW,QAAQ,KAAK,EAAE,SAAS,MAAM,GAAG,GAAG;AAC1F;AAAA,MACF;AACA,YAAM,WAAW,MAAM;AAAA,QACrB,MAAM,cAAc;AAAA,UAClB;AAAA,QACF;AAAA,MACF;AACA,UAAI,SAAS,WAAW,GAAG;AACzB;AAAA,MACF;AACA,YAAM,eAAe;AACrB,YAAM,gBAAgB,SAAS;AAC/B,YAAM,eACJ,yBAAyB,oBAAoB,SAAS,QAAQ,aAAa,IAAI;AACjF,YAAM,YAAY,iBAAiB,MAAM,KAAK,cAAc,SAAS,MAAM;AAC3E,eAAS,SAAS,GAAG,MAAM;AAAA,IAC7B;AAAA,IACA,CAAC,SAAS;AAAA,EAC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AAC,GAAG,kBAAkB,SAAS,CAAC,CAAC,KACnF,YACA;AAEF,MAAI,gBAAgB,QAAQ,CAAC,KAAK,aAAa,UAAU,GAAG;AAC1D,SAAK,WAAW;AAAA,EAClB;AACA,cAAY,MAAM;AACpB;;;AC7UO,IAAM,aAAa;AAAA,EACxB,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO;AACT;AAEO,IAAM,iBAAiB;AAAA,EAC5B,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AACV;","names":["ThreadListRoot","ThreadListNew","ThreadListItems","ThreadListEmpty","ThreadListItemRoot","ThreadListItemTrigger","ThreadListItemTitle"]}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import {
|
|
2
|
+
renderPrimitive
|
|
3
|
+
} from "./chunk-T3ZFZ3NP.js";
|
|
4
|
+
import {
|
|
5
|
+
InternalSelectionToolbarProvider,
|
|
6
|
+
useSelectionToolbar
|
|
7
|
+
} from "./chunk-5IHC7D4U.js";
|
|
8
|
+
|
|
9
|
+
// src/selection-toolbar/parts.tsx
|
|
10
|
+
import {
|
|
11
|
+
forwardRef,
|
|
12
|
+
useCallback,
|
|
13
|
+
useEffect,
|
|
14
|
+
useMemo,
|
|
15
|
+
useState
|
|
16
|
+
} from "react";
|
|
17
|
+
import { createPortal } from "react-dom";
|
|
18
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
var SelectionToolbarRoot = forwardRef(
|
|
20
|
+
function SelectionToolbarRoot2({ children, container, onQuote, onSelectionChange, style, ...props }, ref) {
|
|
21
|
+
const [selection, setSelectionState] = useState();
|
|
22
|
+
const portalContainer = container ?? globalThis.document?.body;
|
|
23
|
+
const setSelection = useCallback(
|
|
24
|
+
(nextSelection) => {
|
|
25
|
+
setSelectionState((currentSelection) => {
|
|
26
|
+
if (sameSelection(currentSelection, nextSelection)) {
|
|
27
|
+
return currentSelection;
|
|
28
|
+
}
|
|
29
|
+
onSelectionChange?.(nextSelection);
|
|
30
|
+
return nextSelection;
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
[onSelectionChange]
|
|
34
|
+
);
|
|
35
|
+
const clear = useCallback(() => {
|
|
36
|
+
globalThis.document?.getSelection()?.removeAllRanges();
|
|
37
|
+
setSelection(void 0);
|
|
38
|
+
}, [setSelection]);
|
|
39
|
+
const copy = useCallback(async () => {
|
|
40
|
+
if (selection === void 0) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
await globalThis.navigator?.clipboard?.writeText(selection.text);
|
|
44
|
+
clear();
|
|
45
|
+
}, [clear, selection]);
|
|
46
|
+
const quote = useCallback(() => {
|
|
47
|
+
if (selection === void 0) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
onQuote?.(selection);
|
|
51
|
+
clear();
|
|
52
|
+
}, [clear, onQuote, selection]);
|
|
53
|
+
const value = useMemo(
|
|
54
|
+
() => ({
|
|
55
|
+
...selection === void 0 ? {} : { selection },
|
|
56
|
+
quote,
|
|
57
|
+
copy,
|
|
58
|
+
clear
|
|
59
|
+
}),
|
|
60
|
+
[clear, copy, quote, selection]
|
|
61
|
+
);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
const document = globalThis.document;
|
|
64
|
+
if (document === void 0) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const handleSelectionChange = () => {
|
|
68
|
+
setSelection(selectionFromDocument(document));
|
|
69
|
+
};
|
|
70
|
+
document.addEventListener("selectionchange", handleSelectionChange);
|
|
71
|
+
document.addEventListener("mouseup", handleSelectionChange);
|
|
72
|
+
document.addEventListener("keyup", handleSelectionChange);
|
|
73
|
+
document.addEventListener("scroll", handleSelectionChange, true);
|
|
74
|
+
return () => {
|
|
75
|
+
document.removeEventListener("selectionchange", handleSelectionChange);
|
|
76
|
+
document.removeEventListener("mouseup", handleSelectionChange);
|
|
77
|
+
document.removeEventListener("keyup", handleSelectionChange);
|
|
78
|
+
document.removeEventListener("scroll", handleSelectionChange, true);
|
|
79
|
+
};
|
|
80
|
+
}, [setSelection]);
|
|
81
|
+
if (selection === void 0 || portalContainer === void 0) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const toolbarStyle = {
|
|
85
|
+
position: "fixed",
|
|
86
|
+
top: selection.rect.top,
|
|
87
|
+
left: selection.rect.left + selection.rect.width / 2,
|
|
88
|
+
transform: "translate(-50%, calc(-100% - 8px))",
|
|
89
|
+
...style
|
|
90
|
+
};
|
|
91
|
+
const toolbar = /* @__PURE__ */ jsx(InternalSelectionToolbarProvider, { value, children: renderPrimitive(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
...props,
|
|
95
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
96
|
+
/* @__PURE__ */ jsx(SelectionToolbarQuote, {}),
|
|
97
|
+
/* @__PURE__ */ jsx(SelectionToolbarCopy, {})
|
|
98
|
+
] }),
|
|
99
|
+
style: toolbarStyle,
|
|
100
|
+
"data-anvia-selection-toolbar": "",
|
|
101
|
+
"data-message-id": selection.messageId,
|
|
102
|
+
role: props.role ?? "toolbar"
|
|
103
|
+
},
|
|
104
|
+
ref
|
|
105
|
+
) });
|
|
106
|
+
return createPortal(toolbar, portalContainer);
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
var SelectionToolbarQuote = forwardRef(
|
|
110
|
+
function SelectionToolbarQuote2({ onClick, ...props }, ref) {
|
|
111
|
+
const { disabled, handleClick } = useSelectionToolbarAction("quote", props.disabled, onClick);
|
|
112
|
+
return renderPrimitive(
|
|
113
|
+
"button",
|
|
114
|
+
{
|
|
115
|
+
...props,
|
|
116
|
+
children: props.children ?? "Quote",
|
|
117
|
+
disabled,
|
|
118
|
+
onClick: handleClick,
|
|
119
|
+
type: props.type ?? "button",
|
|
120
|
+
"data-anvia-selection-quote": "",
|
|
121
|
+
"data-state": disabled ? "disabled" : "enabled"
|
|
122
|
+
},
|
|
123
|
+
ref
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
);
|
|
127
|
+
var SelectionToolbarCopy = forwardRef(
|
|
128
|
+
function SelectionToolbarCopy2({ onClick, ...props }, ref) {
|
|
129
|
+
const { disabled, handleClick } = useSelectionToolbarAction("copy", props.disabled, onClick);
|
|
130
|
+
return renderPrimitive(
|
|
131
|
+
"button",
|
|
132
|
+
{
|
|
133
|
+
...props,
|
|
134
|
+
children: props.children ?? "Copy",
|
|
135
|
+
disabled,
|
|
136
|
+
onClick: handleClick,
|
|
137
|
+
type: props.type ?? "button",
|
|
138
|
+
"data-anvia-selection-copy": "",
|
|
139
|
+
"data-state": disabled ? "disabled" : "enabled"
|
|
140
|
+
},
|
|
141
|
+
ref
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
function useSelectionToolbarAction(actionName, disabledProp, onClick) {
|
|
146
|
+
const toolbar = useSelectionToolbar();
|
|
147
|
+
const disabled = disabledProp ?? toolbar.selection === void 0;
|
|
148
|
+
const action = toolbar[actionName];
|
|
149
|
+
const handleClick = useCallback(
|
|
150
|
+
(event) => {
|
|
151
|
+
onClick?.(event);
|
|
152
|
+
if (event.defaultPrevented || disabled) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
void action();
|
|
156
|
+
},
|
|
157
|
+
[action, disabled, onClick]
|
|
158
|
+
);
|
|
159
|
+
return { disabled, handleClick };
|
|
160
|
+
}
|
|
161
|
+
function selectionFromDocument(document) {
|
|
162
|
+
const selection = document.getSelection();
|
|
163
|
+
if (selection === null || selection.rangeCount === 0) {
|
|
164
|
+
return void 0;
|
|
165
|
+
}
|
|
166
|
+
const text = selection.toString();
|
|
167
|
+
if (text.trim().length === 0) {
|
|
168
|
+
return void 0;
|
|
169
|
+
}
|
|
170
|
+
const anchorMessage = messageElementFromNode(selection.anchorNode);
|
|
171
|
+
const focusMessage = messageElementFromNode(selection.focusNode);
|
|
172
|
+
if (anchorMessage === void 0 || focusMessage === void 0 || anchorMessage !== focusMessage) {
|
|
173
|
+
return void 0;
|
|
174
|
+
}
|
|
175
|
+
const messageId = anchorMessage.getAttribute("data-anvia-message-id");
|
|
176
|
+
if (messageId === null || messageId.length === 0) {
|
|
177
|
+
return void 0;
|
|
178
|
+
}
|
|
179
|
+
const range = selection.getRangeAt(0);
|
|
180
|
+
return {
|
|
181
|
+
text,
|
|
182
|
+
messageId,
|
|
183
|
+
rect: selectionRect(range)
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
function messageElementFromNode(node) {
|
|
187
|
+
if (node === null) {
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
const element = node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
|
|
191
|
+
return element?.closest("[data-anvia-message-id]") ?? void 0;
|
|
192
|
+
}
|
|
193
|
+
function selectionRect(range) {
|
|
194
|
+
const rangeWithRect = range;
|
|
195
|
+
const rect = rangeWithRect.getBoundingClientRect?.();
|
|
196
|
+
if (rect !== void 0 && (rect.width > 0 || rect.height > 0)) {
|
|
197
|
+
return rect;
|
|
198
|
+
}
|
|
199
|
+
const firstRect = range.getClientRects().item(0);
|
|
200
|
+
if (firstRect !== null) {
|
|
201
|
+
return firstRect;
|
|
202
|
+
}
|
|
203
|
+
const DOMRectConstructor = globalThis.DOMRect;
|
|
204
|
+
if (DOMRectConstructor !== void 0) {
|
|
205
|
+
return new DOMRectConstructor(0, 0, 0, 0);
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
bottom: 0,
|
|
209
|
+
height: 0,
|
|
210
|
+
left: 0,
|
|
211
|
+
right: 0,
|
|
212
|
+
top: 0,
|
|
213
|
+
width: 0,
|
|
214
|
+
x: 0,
|
|
215
|
+
y: 0,
|
|
216
|
+
toJSON: () => ({})
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function sameSelection(currentSelection, nextSelection) {
|
|
220
|
+
if (currentSelection === void 0 || nextSelection === void 0) {
|
|
221
|
+
return currentSelection === nextSelection;
|
|
222
|
+
}
|
|
223
|
+
return currentSelection.text === nextSelection.text && currentSelection.messageId === nextSelection.messageId && currentSelection.rect.left === nextSelection.rect.left && currentSelection.rect.top === nextSelection.rect.top && currentSelection.rect.width === nextSelection.rect.width && currentSelection.rect.height === nextSelection.rect.height;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/selection-toolbar/index.ts
|
|
227
|
+
var SelectionToolbar = {
|
|
228
|
+
Root: SelectionToolbarRoot,
|
|
229
|
+
Quote: SelectionToolbarQuote,
|
|
230
|
+
Copy: SelectionToolbarCopy
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export {
|
|
234
|
+
SelectionToolbar
|
|
235
|
+
};
|
|
236
|
+
//# sourceMappingURL=chunk-OKTDYMSA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/selection-toolbar/parts.tsx","../src/selection-toolbar/index.ts"],"sourcesContent":["import {\n type CSSProperties,\n forwardRef,\n type MouseEvent,\n type ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport {\n InternalSelectionToolbarProvider,\n type SelectionToolbarContextValue,\n type SelectionToolbarSelection,\n useSelectionToolbar,\n} from \"../contexts\";\nimport { type PrimitiveProps, renderPrimitive } from \"../primitives\";\n\ntype SelectionToolbarRootProps = Omit<PrimitiveProps<\"div\">, \"children\"> & {\n children?: ReactNode;\n container?: Element | DocumentFragment;\n onQuote?: (selection: SelectionToolbarSelection) => void;\n onSelectionChange?: (selection: SelectionToolbarSelection | undefined) => void;\n};\n\nconst SelectionToolbarRoot = forwardRef<HTMLDivElement, SelectionToolbarRootProps>(\n function SelectionToolbarRoot(\n { children, container, onQuote, onSelectionChange, style, ...props },\n ref,\n ) {\n const [selection, setSelectionState] = useState<SelectionToolbarSelection | undefined>();\n const portalContainer = container ?? globalThis.document?.body;\n\n const setSelection = useCallback(\n (nextSelection: SelectionToolbarSelection | undefined) => {\n setSelectionState((currentSelection) => {\n if (sameSelection(currentSelection, nextSelection)) {\n return currentSelection;\n }\n onSelectionChange?.(nextSelection);\n return nextSelection;\n });\n },\n [onSelectionChange],\n );\n\n const clear = useCallback(() => {\n globalThis.document?.getSelection()?.removeAllRanges();\n setSelection(undefined);\n }, [setSelection]);\n\n const copy = useCallback(async () => {\n if (selection === undefined) {\n return;\n }\n await globalThis.navigator?.clipboard?.writeText(selection.text);\n clear();\n }, [clear, selection]);\n\n const quote = useCallback(() => {\n if (selection === undefined) {\n return;\n }\n onQuote?.(selection);\n clear();\n }, [clear, onQuote, selection]);\n\n const value = useMemo<SelectionToolbarContextValue>(\n () => ({\n ...(selection === undefined ? {} : { selection }),\n quote,\n copy,\n clear,\n }),\n [clear, copy, quote, selection],\n );\n\n useEffect(() => {\n const document = globalThis.document;\n if (document === undefined) {\n return;\n }\n\n const handleSelectionChange = () => {\n setSelection(selectionFromDocument(document));\n };\n\n document.addEventListener(\"selectionchange\", handleSelectionChange);\n document.addEventListener(\"mouseup\", handleSelectionChange);\n document.addEventListener(\"keyup\", handleSelectionChange);\n document.addEventListener(\"scroll\", handleSelectionChange, true);\n return () => {\n document.removeEventListener(\"selectionchange\", handleSelectionChange);\n document.removeEventListener(\"mouseup\", handleSelectionChange);\n document.removeEventListener(\"keyup\", handleSelectionChange);\n document.removeEventListener(\"scroll\", handleSelectionChange, true);\n };\n }, [setSelection]);\n\n if (selection === undefined || portalContainer === undefined) {\n return null;\n }\n\n const toolbarStyle: CSSProperties = {\n position: \"fixed\",\n top: selection.rect.top,\n left: selection.rect.left + selection.rect.width / 2,\n transform: \"translate(-50%, calc(-100% - 8px))\",\n ...style,\n };\n\n const toolbar = (\n <InternalSelectionToolbarProvider value={value}>\n {renderPrimitive(\n \"div\",\n {\n ...props,\n children: children ?? (\n <>\n <SelectionToolbarQuote />\n <SelectionToolbarCopy />\n </>\n ),\n style: toolbarStyle,\n \"data-anvia-selection-toolbar\": \"\",\n \"data-message-id\": selection.messageId,\n role: props.role ?? \"toolbar\",\n } as PrimitiveProps<\"div\">,\n ref,\n )}\n </InternalSelectionToolbarProvider>\n );\n\n return createPortal(toolbar, portalContainer);\n },\n);\n\nconst SelectionToolbarQuote = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function SelectionToolbarQuote({ onClick, ...props }, ref) {\n const { disabled, handleClick } = useSelectionToolbarAction(\"quote\", props.disabled, onClick);\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Quote\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-selection-quote\": \"\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\nconst SelectionToolbarCopy = forwardRef<HTMLButtonElement, PrimitiveProps<\"button\">>(\n function SelectionToolbarCopy({ onClick, ...props }, ref) {\n const { disabled, handleClick } = useSelectionToolbarAction(\"copy\", props.disabled, onClick);\n\n return renderPrimitive(\n \"button\",\n {\n ...props,\n children: props.children ?? \"Copy\",\n disabled,\n onClick: handleClick,\n type: props.type ?? \"button\",\n \"data-anvia-selection-copy\": \"\",\n \"data-state\": disabled ? \"disabled\" : \"enabled\",\n } as PrimitiveProps<\"button\">,\n ref,\n );\n },\n);\n\ntype SelectionToolbarAction = \"copy\" | \"quote\";\n\nfunction useSelectionToolbarAction(\n actionName: SelectionToolbarAction,\n disabledProp: boolean | undefined,\n onClick: ((event: MouseEvent<HTMLButtonElement>) => void) | undefined,\n): {\n disabled: boolean;\n handleClick(event: MouseEvent<HTMLButtonElement>): void;\n} {\n const toolbar = useSelectionToolbar();\n const disabled = disabledProp ?? toolbar.selection === undefined;\n const action = toolbar[actionName];\n const handleClick = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled) {\n return;\n }\n void action();\n },\n [action, disabled, onClick],\n );\n return { disabled, handleClick };\n}\n\nfunction selectionFromDocument(document: Document): SelectionToolbarSelection | undefined {\n const selection = document.getSelection();\n if (selection === null || selection.rangeCount === 0) {\n return undefined;\n }\n const text = selection.toString();\n if (text.trim().length === 0) {\n return undefined;\n }\n\n const anchorMessage = messageElementFromNode(selection.anchorNode);\n const focusMessage = messageElementFromNode(selection.focusNode);\n if (anchorMessage === undefined || focusMessage === undefined || anchorMessage !== focusMessage) {\n return undefined;\n }\n\n const messageId = anchorMessage.getAttribute(\"data-anvia-message-id\");\n if (messageId === null || messageId.length === 0) {\n return undefined;\n }\n\n const range = selection.getRangeAt(0);\n return {\n text,\n messageId,\n rect: selectionRect(range),\n };\n}\n\nfunction messageElementFromNode(node: Node | null): HTMLElement | undefined {\n if (node === null) {\n return undefined;\n }\n const element = node.nodeType === Node.ELEMENT_NODE ? (node as Element) : node.parentElement;\n return element?.closest<HTMLElement>(\"[data-anvia-message-id]\") ?? undefined;\n}\n\nfunction selectionRect(range: Range): DOMRect {\n const rangeWithRect = range as Range & {\n getBoundingClientRect?: () => DOMRect;\n };\n const rect = rangeWithRect.getBoundingClientRect?.();\n if (rect !== undefined && (rect.width > 0 || rect.height > 0)) {\n return rect;\n }\n const firstRect = range.getClientRects().item(0);\n if (firstRect !== null) {\n return firstRect;\n }\n const DOMRectConstructor = globalThis.DOMRect;\n if (DOMRectConstructor !== undefined) {\n return new DOMRectConstructor(0, 0, 0, 0);\n }\n return {\n bottom: 0,\n height: 0,\n left: 0,\n right: 0,\n top: 0,\n width: 0,\n x: 0,\n y: 0,\n toJSON: () => ({}),\n } as DOMRect;\n}\n\nfunction sameSelection(\n currentSelection: SelectionToolbarSelection | undefined,\n nextSelection: SelectionToolbarSelection | undefined,\n): boolean {\n if (currentSelection === undefined || nextSelection === undefined) {\n return currentSelection === nextSelection;\n }\n return (\n currentSelection.text === nextSelection.text &&\n currentSelection.messageId === nextSelection.messageId &&\n currentSelection.rect.left === nextSelection.rect.left &&\n currentSelection.rect.top === nextSelection.rect.top &&\n currentSelection.rect.width === nextSelection.rect.width &&\n currentSelection.rect.height === nextSelection.rect.height\n );\n}\n\nexport { SelectionToolbarCopy, SelectionToolbarQuote, SelectionToolbarRoot };\n","import { SelectionToolbarCopy, SelectionToolbarQuote, SelectionToolbarRoot } from \"./parts\";\n\nexport const SelectionToolbar = {\n Root: SelectionToolbarRoot,\n Quote: SelectionToolbarQuote,\n Copy: SelectionToolbarCopy,\n} as const;\n\nexport type { SelectionToolbarContextValue, SelectionToolbarSelection } from \"../contexts\";\nexport { useSelectionToolbar } from \"../contexts\";\n"],"mappings":";;;;;;;;;AAAA;AAAA,EAEE;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,oBAAoB;AA8Gf,mBACE,KADF;AA7Fd,IAAM,uBAAuB;AAAA,EAC3B,SAASA,sBACP,EAAE,UAAU,WAAW,SAAS,mBAAmB,OAAO,GAAG,MAAM,GACnE,KACA;AACA,UAAM,CAAC,WAAW,iBAAiB,IAAI,SAAgD;AACvF,UAAM,kBAAkB,aAAa,WAAW,UAAU;AAE1D,UAAM,eAAe;AAAA,MACnB,CAAC,kBAAyD;AACxD,0BAAkB,CAAC,qBAAqB;AACtC,cAAI,cAAc,kBAAkB,aAAa,GAAG;AAClD,mBAAO;AAAA,UACT;AACA,8BAAoB,aAAa;AACjC,iBAAO;AAAA,QACT,CAAC;AAAA,MACH;AAAA,MACA,CAAC,iBAAiB;AAAA,IACpB;AAEA,UAAM,QAAQ,YAAY,MAAM;AAC9B,iBAAW,UAAU,aAAa,GAAG,gBAAgB;AACrD,mBAAa,MAAS;AAAA,IACxB,GAAG,CAAC,YAAY,CAAC;AAEjB,UAAM,OAAO,YAAY,YAAY;AACnC,UAAI,cAAc,QAAW;AAC3B;AAAA,MACF;AACA,YAAM,WAAW,WAAW,WAAW,UAAU,UAAU,IAAI;AAC/D,YAAM;AAAA,IACR,GAAG,CAAC,OAAO,SAAS,C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C,WAAO,IAAI,mBAAmB,GAAG,GAAG,GAAG,CAAC;AAAA,EAC1C;AACA,SAAO;AAAA,IACL,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL,OAAO;AAAA,IACP,GAAG;AAAA,IACH,GAAG;AAAA,IACH,QAAQ,OAAO,CAAC;AAAA,EAClB;AACF;AAEA,SAAS,cACP,kBACA,eACS;AACT,MAAI,qBAAqB,UAAa,kBAAkB,QAAW;AACjE,WAAO,qBAAqB;AAAA,EAC9B;AACA,SACE,iBAAiB,SAAS,cAAc,QACxC,iBAAiB,cAAc,cAAc,aAC7C,iBAAiB,KAAK,SAAS,cAAc,KAAK,QAClD,iBAAiB,KAAK,QAAQ,cAAc,KAAK,OACjD,iBAAiB,KAAK,UAAU,cAAc,KAAK,SACnD,iBAAiB,KAAK,WAAW,cAAc,KAAK;AAExD;;;AC5RO,IAAM,mBAAmB;AAAA,EAC9B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM;AACR;","names":["SelectionToolbarRoot","SelectionToolbarQuote","SelectionToolbarCopy"]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-T3ZFZ3NP.js";
|
|
4
4
|
import {
|
|
5
5
|
useAttachment
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5IHC7D4U.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-QHP4GSRG.js.map
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
useHumanInput,
|
|
11
11
|
useQuestion,
|
|
12
12
|
useQuestionPrompt
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-5IHC7D4U.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-YDMDLFU4.js.map
|
package/dist/completion/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Completion
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-4Z7LULAM.js";
|
|
4
4
|
import "../chunk-T3ZFZ3NP.js";
|
|
5
5
|
import {
|
|
6
6
|
CompletionProvider,
|
|
7
7
|
useCompletionContext,
|
|
8
8
|
useCompletionInput
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-5IHC7D4U.js";
|
|
10
10
|
export {
|
|
11
11
|
Completion,
|
|
12
12
|
CompletionProvider,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HumanInput
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-YDMDLFU4.js";
|
|
4
4
|
import "../chunk-T3ZFZ3NP.js";
|
|
5
5
|
import {
|
|
6
6
|
useApproval,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useHumanInput,
|
|
9
9
|
useQuestion,
|
|
10
10
|
useQuestionPrompt
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-5IHC7D4U.js";
|
|
12
12
|
export {
|
|
13
13
|
HumanInput,
|
|
14
14
|
useApproval,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import * as _anvia_react from '@anvia/react';
|
|
3
|
+
import { I as ImageContextValue } from '../image-DanUxcl2.js';
|
|
4
|
+
export { u as useImage } from '../image-DanUxcl2.js';
|
|
5
|
+
import { P as PrimitiveProps } from '../render-CRKWam2v.js';
|
|
6
|
+
|
|
7
|
+
declare const Image: {
|
|
8
|
+
readonly Root: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"figure">, "children"> & {
|
|
9
|
+
attachment?: _anvia_react.UIAttachment;
|
|
10
|
+
children?: react.ReactNode | ((image: ImageContextValue) => react.ReactNode);
|
|
11
|
+
renderWhen?: "image" | "always";
|
|
12
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
13
|
+
readonly Preview: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
|
|
14
|
+
alt?: string;
|
|
15
|
+
errorFallback?: react.ReactNode;
|
|
16
|
+
loadingFallback?: react.ReactNode;
|
|
17
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
18
|
+
readonly Name: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, "asChild"> & {
|
|
19
|
+
asChild?: boolean;
|
|
20
|
+
} & react.RefAttributes<HTMLElement>>;
|
|
21
|
+
readonly Actions: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, "asChild"> & {
|
|
22
|
+
asChild?: boolean;
|
|
23
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
24
|
+
readonly Copy: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
25
|
+
asChild?: boolean;
|
|
26
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
|
27
|
+
readonly Download: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
28
|
+
asChild?: boolean;
|
|
29
|
+
} & {
|
|
30
|
+
filename?: string;
|
|
31
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
|
32
|
+
readonly ZoomTrigger: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
33
|
+
asChild?: boolean;
|
|
34
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
|
35
|
+
readonly ZoomOverlay: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
|
|
36
|
+
container?: Element | DocumentFragment;
|
|
37
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { Image, ImageContextValue };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UIAttachment } from '@anvia/react';
|
|
2
|
+
|
|
3
|
+
type ImageContextValue = {
|
|
4
|
+
attachment: UIAttachment;
|
|
5
|
+
src?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
mediaType?: string;
|
|
8
|
+
isImage: boolean;
|
|
9
|
+
zoomOpen: boolean;
|
|
10
|
+
setZoomOpen(open: boolean): void;
|
|
11
|
+
};
|
|
12
|
+
declare function useImage(): ImageContextValue;
|
|
13
|
+
|
|
14
|
+
export { type ImageContextValue as I, useImage as u };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,20 @@ export { Attachment } from './attachment/index.js';
|
|
|
2
2
|
export { A as AttachmentContextValue, u as useAttachment } from './attachment-BP597fV3.js';
|
|
3
3
|
export { C as ChatController, a as ChatProvider, b as ChatProviderProps, u as useChatContext, c as useHumanInput } from './chat-B3kucz1w.js';
|
|
4
4
|
export { C as CompletionController, a as CompletionInputContextValue, b as CompletionProvider, c as CompletionProviderProps, u as useCompletionContext, d as useCompletionInput } from './completion-input-WjK6kUyG.js';
|
|
5
|
-
export { C as ComposerAttachmentInput, a as ComposerAttachmentsUpdate, b as ComposerContextValue, T as ThreadContextValue, u as useComposer,
|
|
5
|
+
export { C as ComposerAttachmentInput, a as ComposerAttachmentsUpdate, b as ComposerContextValue, c as ComposerQuote, T as ThreadContextValue, u as useComposer, d as useThread } from './thread-DYPvlsJa.js';
|
|
6
6
|
export { A as ApprovalContextValue, Q as QuestionContextValue, a as QuestionPromptContextValue, u as useApproval, b as useQuestion, c as useQuestionPrompt } from './human-input-CydeYm_7.js';
|
|
7
|
+
export { I as ImageContextValue, u as useImage } from './image-DanUxcl2.js';
|
|
7
8
|
export { M as MessageContextValue, a as MessagePartContextValue, u as useMessage, b as useMessagePart } from './message-Beb4ZLNU.js';
|
|
9
|
+
export { S as SelectionToolbarContextValue, a as SelectionToolbarSelection, u as useSelectionToolbar } from './selection-toolbar-Cwjbuv5S.js';
|
|
10
|
+
export { T as ThreadListController, a as ThreadListItemContextValue, b as ThreadListProvider, c as ThreadListProviderProps, d as ThreadListRecord, u as useThreadList, e as useThreadListItem } from './thread-list-On8db4XL.js';
|
|
8
11
|
export { Composer, ComposerSubmitMessage, ComposerSubmitMessageArgs, Thread } from './chat/index.js';
|
|
9
12
|
export { Completion } from './completion/index.js';
|
|
10
13
|
export { HumanInput } from './human-input/index.js';
|
|
14
|
+
export { Image } from './image/index.js';
|
|
11
15
|
export { Message, MessageAttachmentPart, MessagePartsFilter, MessageToolPart, MessageToolRenderWhen } from './message/index.js';
|
|
16
|
+
export { SelectionToolbar } from './selection-toolbar/index.js';
|
|
12
17
|
export { P as PrimitiveProps, a as PrimitiveRef } from './render-CRKWam2v.js';
|
|
18
|
+
export { ThreadList, ThreadListItem } from './thread-list/index.js';
|
|
13
19
|
import '@anvia/react';
|
|
14
20
|
import 'react';
|
|
15
21
|
import 'react-markdown';
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SelectionToolbar
|
|
3
|
+
} from "./chunk-OKTDYMSA.js";
|
|
4
|
+
import {
|
|
5
|
+
ThreadList,
|
|
6
|
+
ThreadListItem
|
|
7
|
+
} from "./chunk-MXYHYD3O.js";
|
|
1
8
|
import {
|
|
2
9
|
Composer,
|
|
3
10
|
Thread
|
|
4
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LRAQW3ZK.js";
|
|
5
12
|
import {
|
|
6
13
|
Completion
|
|
7
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-4Z7LULAM.js";
|
|
8
15
|
import {
|
|
9
16
|
HumanInput
|
|
10
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-YDMDLFU4.js";
|
|
18
|
+
import {
|
|
19
|
+
Image
|
|
20
|
+
} from "./chunk-IHRCKGRS.js";
|
|
11
21
|
import {
|
|
12
22
|
Message
|
|
13
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-5Z2IWZ5O.js";
|
|
14
24
|
import {
|
|
15
25
|
Attachment
|
|
16
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-QHP4GSRG.js";
|
|
17
27
|
import "./chunk-T3ZFZ3NP.js";
|
|
18
28
|
import {
|
|
19
29
|
ChatProvider,
|
|
20
30
|
CompletionProvider,
|
|
31
|
+
ThreadListProvider,
|
|
21
32
|
useApproval,
|
|
22
33
|
useAttachment,
|
|
23
34
|
useChatContext,
|
|
@@ -25,12 +36,16 @@ import {
|
|
|
25
36
|
useCompletionInput,
|
|
26
37
|
useComposer,
|
|
27
38
|
useHumanInput,
|
|
39
|
+
useImage,
|
|
28
40
|
useMessage,
|
|
29
41
|
useMessagePart,
|
|
30
42
|
useQuestion,
|
|
31
43
|
useQuestionPrompt,
|
|
32
|
-
|
|
33
|
-
|
|
44
|
+
useSelectionToolbar,
|
|
45
|
+
useThread,
|
|
46
|
+
useThreadList,
|
|
47
|
+
useThreadListItem
|
|
48
|
+
} from "./chunk-5IHC7D4U.js";
|
|
34
49
|
export {
|
|
35
50
|
Attachment,
|
|
36
51
|
ChatProvider,
|
|
@@ -38,8 +53,13 @@ export {
|
|
|
38
53
|
CompletionProvider,
|
|
39
54
|
Composer,
|
|
40
55
|
HumanInput,
|
|
56
|
+
Image,
|
|
41
57
|
Message,
|
|
58
|
+
SelectionToolbar,
|
|
42
59
|
Thread,
|
|
60
|
+
ThreadList,
|
|
61
|
+
ThreadListItem,
|
|
62
|
+
ThreadListProvider,
|
|
43
63
|
useApproval,
|
|
44
64
|
useAttachment,
|
|
45
65
|
useChatContext,
|
|
@@ -47,10 +67,14 @@ export {
|
|
|
47
67
|
useCompletionInput,
|
|
48
68
|
useComposer,
|
|
49
69
|
useHumanInput,
|
|
70
|
+
useImage,
|
|
50
71
|
useMessage,
|
|
51
72
|
useMessagePart,
|
|
52
73
|
useQuestion,
|
|
53
74
|
useQuestionPrompt,
|
|
54
|
-
|
|
75
|
+
useSelectionToolbar,
|
|
76
|
+
useThread,
|
|
77
|
+
useThreadList,
|
|
78
|
+
useThreadListItem
|
|
55
79
|
};
|
|
56
80
|
//# sourceMappingURL=index.js.map
|
package/dist/message/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Message
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-5Z2IWZ5O.js";
|
|
4
|
+
import "../chunk-QHP4GSRG.js";
|
|
5
5
|
import "../chunk-T3ZFZ3NP.js";
|
|
6
6
|
import {
|
|
7
7
|
useChatContext,
|
|
8
8
|
useMessage,
|
|
9
9
|
useMessagePart
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-5IHC7D4U.js";
|
|
11
11
|
export {
|
|
12
12
|
Message,
|
|
13
13
|
useChatContext,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { a as SelectionToolbarSelection } from '../selection-toolbar-Cwjbuv5S.js';
|
|
3
|
+
export { S as SelectionToolbarContextValue, u as useSelectionToolbar } from '../selection-toolbar-Cwjbuv5S.js';
|
|
4
|
+
import { P as PrimitiveProps } from '../render-CRKWam2v.js';
|
|
5
|
+
|
|
6
|
+
declare const SelectionToolbar: {
|
|
7
|
+
readonly Root: react.ForwardRefExoticComponent<Omit<PrimitiveProps<"div">, "children"> & {
|
|
8
|
+
children?: react.ReactNode;
|
|
9
|
+
container?: Element | DocumentFragment;
|
|
10
|
+
onQuote?: (selection: SelectionToolbarSelection) => void;
|
|
11
|
+
onSelectionChange?: (selection: SelectionToolbarSelection | undefined) => void;
|
|
12
|
+
} & react.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
readonly Quote: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
|
16
|
+
readonly Copy: react.ForwardRefExoticComponent<Omit<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "asChild"> & {
|
|
17
|
+
asChild?: boolean;
|
|
18
|
+
} & react.RefAttributes<HTMLButtonElement>>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { SelectionToolbar, SelectionToolbarSelection };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type SelectionToolbarSelection = {
|
|
2
|
+
text: string;
|
|
3
|
+
messageId: string;
|
|
4
|
+
rect: DOMRect;
|
|
5
|
+
};
|
|
6
|
+
type SelectionToolbarContextValue = {
|
|
7
|
+
selection?: SelectionToolbarSelection;
|
|
8
|
+
quote(): void;
|
|
9
|
+
copy(): Promise<void>;
|
|
10
|
+
clear(): void;
|
|
11
|
+
};
|
|
12
|
+
declare function useSelectionToolbar(): SelectionToolbarContextValue;
|
|
13
|
+
|
|
14
|
+
export { type SelectionToolbarContextValue as S, type SelectionToolbarSelection as a, useSelectionToolbar as u };
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
export { A as AttachmentContextValue, u as useAttachment } from './attachment-BP597fV3.js';
|
|
2
2
|
export { C as ChatController, a as ChatProvider, b as ChatProviderProps, u as useChatContext, c as useHumanInput } from './chat-B3kucz1w.js';
|
|
3
3
|
export { C as CompletionController, a as CompletionInputContextValue, b as CompletionProvider, c as CompletionProviderProps, u as useCompletionContext, d as useCompletionInput } from './completion-input-WjK6kUyG.js';
|
|
4
|
-
export { C as ComposerAttachmentInput, a as ComposerAttachmentsUpdate, b as ComposerContextValue, T as ThreadContextValue, u as useComposer,
|
|
4
|
+
export { C as ComposerAttachmentInput, a as ComposerAttachmentsUpdate, b as ComposerContextValue, c as ComposerQuote, T as ThreadContextValue, u as useComposer, d as useThread } from './thread-DYPvlsJa.js';
|
|
5
5
|
export { A as ApprovalContextValue, Q as QuestionContextValue, a as QuestionPromptContextValue, u as useApproval, b as useQuestion, c as useQuestionPrompt } from './human-input-CydeYm_7.js';
|
|
6
|
+
export { I as ImageContextValue, u as useImage } from './image-DanUxcl2.js';
|
|
6
7
|
export { M as MessageContextValue, a as MessagePartContextValue, u as useMessage, b as useMessagePart } from './message-Beb4ZLNU.js';
|
|
8
|
+
export { S as SelectionToolbarContextValue, a as SelectionToolbarSelection, u as useSelectionToolbar } from './selection-toolbar-Cwjbuv5S.js';
|
|
9
|
+
export { T as ThreadListController, a as ThreadListItemContextValue, b as ThreadListProvider, c as ThreadListProviderProps, d as ThreadListRecord, u as useThreadList, e as useThreadListItem } from './thread-list-On8db4XL.js';
|
|
7
10
|
export { P as PrimitiveProps, a as PrimitiveRef } from './render-CRKWam2v.js';
|
|
8
11
|
import '@anvia/react';
|
|
9
12
|
import 'react';
|