@assistant-ui/vue 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +90 -2
  3. package/dist/AuiIf.d.ts +27 -0
  4. package/dist/AuiIf.d.ts.map +1 -0
  5. package/dist/AuiIf.js +30 -0
  6. package/dist/AuiIf.js.map +1 -0
  7. package/dist/AuiProvider.d.ts +41 -0
  8. package/dist/AuiProvider.d.ts.map +1 -0
  9. package/dist/AuiProvider.js +61 -0
  10. package/dist/AuiProvider.js.map +1 -0
  11. package/dist/context.d.ts +10 -0
  12. package/dist/context.d.ts.map +1 -0
  13. package/dist/context.js +17 -0
  14. package/dist/context.js.map +1 -0
  15. package/dist/index.d.ts +34 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +35 -0
  18. package/dist/primitives/AttachmentByIndexProvider.d.ts +30 -0
  19. package/dist/primitives/AttachmentByIndexProvider.d.ts.map +1 -0
  20. package/dist/primitives/AttachmentByIndexProvider.js +63 -0
  21. package/dist/primitives/AttachmentByIndexProvider.js.map +1 -0
  22. package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.d.ts +11 -0
  23. package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.d.ts.map +1 -0
  24. package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.js +31 -0
  25. package/dist/primitives/ChainOfThoughtPrimitiveAccordionTrigger.js.map +1 -0
  26. package/dist/primitives/ChainOfThoughtPrimitiveParts.d.ts +19 -0
  27. package/dist/primitives/ChainOfThoughtPrimitiveParts.d.ts.map +1 -0
  28. package/dist/primitives/ChainOfThoughtPrimitiveParts.js +85 -0
  29. package/dist/primitives/ChainOfThoughtPrimitiveParts.js.map +1 -0
  30. package/dist/primitives/ComposerPrimitiveCancel.d.ts +12 -0
  31. package/dist/primitives/ComposerPrimitiveCancel.d.ts.map +1 -0
  32. package/dist/primitives/ComposerPrimitiveCancel.js +33 -0
  33. package/dist/primitives/ComposerPrimitiveCancel.js.map +1 -0
  34. package/dist/primitives/ComposerPrimitiveInput.d.ts +26 -0
  35. package/dist/primitives/ComposerPrimitiveInput.d.ts.map +1 -0
  36. package/dist/primitives/ComposerPrimitiveInput.js +57 -0
  37. package/dist/primitives/ComposerPrimitiveInput.js.map +1 -0
  38. package/dist/primitives/ComposerPrimitiveSend.d.ts +13 -0
  39. package/dist/primitives/ComposerPrimitiveSend.d.ts.map +1 -0
  40. package/dist/primitives/ComposerPrimitiveSend.js +31 -0
  41. package/dist/primitives/ComposerPrimitiveSend.js.map +1 -0
  42. package/dist/primitives/MessageByIdProvider.d.ts +23 -0
  43. package/dist/primitives/MessageByIdProvider.d.ts.map +1 -0
  44. package/dist/primitives/MessageByIdProvider.js +70 -0
  45. package/dist/primitives/MessageByIdProvider.js.map +1 -0
  46. package/dist/primitives/MessagePrimitiveParts.d.ts +50 -0
  47. package/dist/primitives/MessagePrimitiveParts.d.ts.map +1 -0
  48. package/dist/primitives/MessagePrimitiveParts.js +93 -0
  49. package/dist/primitives/MessagePrimitiveParts.js.map +1 -0
  50. package/dist/primitives/PartByIndexProvider.d.ts +21 -0
  51. package/dist/primitives/PartByIndexProvider.d.ts.map +1 -0
  52. package/dist/primitives/PartByIndexProvider.js +50 -0
  53. package/dist/primitives/PartByIndexProvider.js.map +1 -0
  54. package/dist/primitives/ThreadListItemPrimitiveRoot.d.ts +7 -0
  55. package/dist/primitives/ThreadListItemPrimitiveRoot.d.ts.map +1 -0
  56. package/dist/primitives/ThreadListItemPrimitiveRoot.js +36 -0
  57. package/dist/primitives/ThreadListItemPrimitiveRoot.js.map +1 -0
  58. package/dist/primitives/ThreadListItemPrimitiveTrigger.d.ts +14 -0
  59. package/dist/primitives/ThreadListItemPrimitiveTrigger.d.ts.map +1 -0
  60. package/dist/primitives/ThreadListItemPrimitiveTrigger.js +58 -0
  61. package/dist/primitives/ThreadListItemPrimitiveTrigger.js.map +1 -0
  62. package/dist/primitives/ThreadListPrimitiveRoot.d.ts +7 -0
  63. package/dist/primitives/ThreadListPrimitiveRoot.d.ts.map +1 -0
  64. package/dist/primitives/ThreadListPrimitiveRoot.js +16 -0
  65. package/dist/primitives/ThreadListPrimitiveRoot.js.map +1 -0
  66. package/dist/primitives/ThreadPrimitiveMessages.d.ts +23 -0
  67. package/dist/primitives/ThreadPrimitiveMessages.d.ts.map +1 -0
  68. package/dist/primitives/ThreadPrimitiveMessages.js +37 -0
  69. package/dist/primitives/ThreadPrimitiveMessages.js.map +1 -0
  70. package/dist/primitives/ThreadPrimitiveScrollToBottom.d.ts +25 -0
  71. package/dist/primitives/ThreadPrimitiveScrollToBottom.d.ts.map +1 -0
  72. package/dist/primitives/ThreadPrimitiveScrollToBottom.js +43 -0
  73. package/dist/primitives/ThreadPrimitiveScrollToBottom.js.map +1 -0
  74. package/dist/primitives/ThreadPrimitiveViewport.d.ts +57 -0
  75. package/dist/primitives/ThreadPrimitiveViewport.d.ts.map +1 -0
  76. package/dist/primitives/ThreadPrimitiveViewport.js +174 -0
  77. package/dist/primitives/ThreadPrimitiveViewport.js.map +1 -0
  78. package/dist/primitives/ThreadPrimitiveViewportFooter.d.ts +13 -0
  79. package/dist/primitives/ThreadPrimitiveViewportFooter.d.ts.map +1 -0
  80. package/dist/primitives/ThreadPrimitiveViewportFooter.js +46 -0
  81. package/dist/primitives/ThreadPrimitiveViewportFooter.js.map +1 -0
  82. package/dist/primitives/actionBar.d.ts +41 -0
  83. package/dist/primitives/actionBar.d.ts.map +1 -0
  84. package/dist/primitives/actionBar.js +110 -0
  85. package/dist/primitives/actionBar.js.map +1 -0
  86. package/dist/primitives/attachment.d.ts +27 -0
  87. package/dist/primitives/attachment.d.ts.map +1 -0
  88. package/dist/primitives/attachment.js +63 -0
  89. package/dist/primitives/attachment.js.map +1 -0
  90. package/dist/primitives/attrDisabled.d.ts +2 -0
  91. package/dist/primitives/attrDisabled.d.ts.map +1 -0
  92. package/dist/primitives/attrDisabled.js +6 -0
  93. package/dist/primitives/attrDisabled.js.map +1 -0
  94. package/dist/primitives/branchPicker.d.ts +18 -0
  95. package/dist/primitives/branchPicker.d.ts.map +1 -0
  96. package/dist/primitives/branchPicker.js +48 -0
  97. package/dist/primitives/branchPicker.js.map +1 -0
  98. package/dist/primitives/composerAttachments.d.ts +57 -0
  99. package/dist/primitives/composerAttachments.d.ts.map +1 -0
  100. package/dist/primitives/composerAttachments.js +132 -0
  101. package/dist/primitives/composerAttachments.js.map +1 -0
  102. package/dist/primitives/error.d.ts +15 -0
  103. package/dist/primitives/error.d.ts.map +1 -0
  104. package/dist/primitives/error.js +29 -0
  105. package/dist/primitives/error.js.map +1 -0
  106. package/dist/primitives/lastValidCache.d.ts +6 -0
  107. package/dist/primitives/lastValidCache.d.ts.map +1 -0
  108. package/dist/primitives/lastValidCache.js +9 -0
  109. package/dist/primitives/lastValidCache.js.map +1 -0
  110. package/dist/primitives/message.d.ts +12 -0
  111. package/dist/primitives/message.d.ts.map +1 -0
  112. package/dist/primitives/message.js +44 -0
  113. package/dist/primitives/message.js.map +1 -0
  114. package/dist/primitives/messageAttachments.d.ts +12 -0
  115. package/dist/primitives/messageAttachments.d.ts.map +1 -0
  116. package/dist/primitives/messageAttachments.js +27 -0
  117. package/dist/primitives/messageAttachments.js.map +1 -0
  118. package/dist/primitives/stableKeys.d.ts +5 -0
  119. package/dist/primitives/stableKeys.d.ts.map +1 -0
  120. package/dist/primitives/stableKeys.js +14 -0
  121. package/dist/primitives/stableKeys.js.map +1 -0
  122. package/dist/primitives/suggestions.d.ts +66 -0
  123. package/dist/primitives/suggestions.d.ts.map +1 -0
  124. package/dist/primitives/suggestions.js +137 -0
  125. package/dist/primitives/suggestions.js.map +1 -0
  126. package/dist/primitives/thread.d.ts +11 -0
  127. package/dist/primitives/thread.d.ts.map +1 -0
  128. package/dist/primitives/thread.js +37 -0
  129. package/dist/primitives/thread.js.map +1 -0
  130. package/dist/primitives/threadList.d.ts +82 -0
  131. package/dist/primitives/threadList.d.ts.map +1 -0
  132. package/dist/primitives/threadList.js +128 -0
  133. package/dist/primitives/threadList.js.map +1 -0
  134. package/dist/primitives/threadListFocusGroup.d.ts +14 -0
  135. package/dist/primitives/threadListFocusGroup.d.ts.map +1 -0
  136. package/dist/primitives/threadListFocusGroup.js +32 -0
  137. package/dist/primitives/threadListFocusGroup.js.map +1 -0
  138. package/dist/primitives/threadListStructural.d.ts +29 -0
  139. package/dist/primitives/threadListStructural.d.ts.map +1 -0
  140. package/dist/primitives/threadListStructural.js +55 -0
  141. package/dist/primitives/threadListStructural.js.map +1 -0
  142. package/dist/primitives/useComposerSendState.d.ts +6 -0
  143. package/dist/primitives/useComposerSendState.d.ts.map +1 -0
  144. package/dist/primitives/useComposerSendState.js +15 -0
  145. package/dist/primitives/useComposerSendState.js.map +1 -0
  146. package/dist/primitives/viewportContext.d.ts +12 -0
  147. package/dist/primitives/viewportContext.d.ts.map +1 -0
  148. package/dist/primitives/viewportContext.js +6 -0
  149. package/dist/primitives/viewportContext.js.map +1 -0
  150. package/dist/useAui.d.ts +15 -0
  151. package/dist/useAui.d.ts.map +1 -0
  152. package/dist/useAui.js +21 -0
  153. package/dist/useAui.js.map +1 -0
  154. package/dist/useAuiEvent.d.ts +17 -0
  155. package/dist/useAuiEvent.d.ts.map +1 -0
  156. package/dist/useAuiEvent.js +52 -0
  157. package/dist/useAuiEvent.js.map +1 -0
  158. package/dist/useAuiState.d.ts +23 -0
  159. package/dist/useAuiState.d.ts.map +1 -0
  160. package/dist/useAuiState.js +42 -0
  161. package/dist/useAuiState.js.map +1 -0
  162. package/dist/useScrollLock.d.ts +3 -0
  163. package/dist/useScrollLock.d.ts.map +1 -0
  164. package/dist/useScrollLock.js +53 -0
  165. package/dist/useScrollLock.js.map +1 -0
  166. package/package.json +57 -6
  167. package/src/AuiIf.ts +34 -0
  168. package/src/AuiProvider.ts +90 -0
  169. package/src/__tests__/AuiIf.test.ts +54 -0
  170. package/src/__tests__/AuiProvider.test.ts +266 -0
  171. package/src/__tests__/byindex-shrink-race.test.ts +411 -0
  172. package/src/__tests__/dist-graph.test.ts +49 -0
  173. package/src/__tests__/fixtures.ts +51 -0
  174. package/src/__tests__/primitives-actionbar.test.ts +469 -0
  175. package/src/__tests__/primitives-attachment.test.ts +493 -0
  176. package/src/__tests__/primitives-content.test.ts +749 -0
  177. package/src/__tests__/primitives-keyed-items.test.ts +270 -0
  178. package/src/__tests__/primitives-keyed-messages.test.ts +264 -0
  179. package/src/__tests__/primitives-structural.test.ts +573 -0
  180. package/src/__tests__/primitives-suggestions.test.ts +374 -0
  181. package/src/__tests__/primitives-threadlist.test.ts +443 -0
  182. package/src/__tests__/primitives-tool-ui.test.ts +579 -0
  183. package/src/__tests__/primitives.test.ts +361 -0
  184. package/src/__tests__/useAuiEvent.test.ts +159 -0
  185. package/src/__tests__/useAuiState.test.ts +124 -0
  186. package/src/context.ts +31 -0
  187. package/src/index.ts +87 -0
  188. package/src/primitives/AttachmentByIndexProvider.ts +88 -0
  189. package/src/primitives/ChainOfThoughtPrimitiveAccordionTrigger.test.ts +105 -0
  190. package/src/primitives/ChainOfThoughtPrimitiveAccordionTrigger.ts +38 -0
  191. package/src/primitives/ChainOfThoughtPrimitiveParts.test.ts +254 -0
  192. package/src/primitives/ChainOfThoughtPrimitiveParts.ts +112 -0
  193. package/src/primitives/ComposerPrimitiveCancel.ts +41 -0
  194. package/src/primitives/ComposerPrimitiveInput.ts +64 -0
  195. package/src/primitives/ComposerPrimitiveSend.ts +39 -0
  196. package/src/primitives/MessageByIdProvider.ts +89 -0
  197. package/src/primitives/MessagePrimitiveParts.tool-interaction.test.ts +88 -0
  198. package/src/primitives/MessagePrimitiveParts.ts +166 -0
  199. package/src/primitives/PartByIndexProvider.ts +62 -0
  200. package/src/primitives/ThreadListItemPrimitiveRoot.ts +57 -0
  201. package/src/primitives/ThreadListItemPrimitiveTrigger.ts +74 -0
  202. package/src/primitives/ThreadListKeyboardNav.test.ts +298 -0
  203. package/src/primitives/ThreadListPrimitiveRoot.ts +18 -0
  204. package/src/primitives/ThreadPrimitiveMessages.ts +40 -0
  205. package/src/primitives/ThreadPrimitiveScrollToBottom.ts +65 -0
  206. package/src/primitives/ThreadPrimitiveViewport.ts +233 -0
  207. package/src/primitives/ThreadPrimitiveViewportFooter.test.ts +305 -0
  208. package/src/primitives/ThreadPrimitiveViewportFooter.ts +60 -0
  209. package/src/primitives/actionBar.ts +159 -0
  210. package/src/primitives/attachment.ts +76 -0
  211. package/src/primitives/attrDisabled.ts +6 -0
  212. package/src/primitives/branchPicker.ts +77 -0
  213. package/src/primitives/composerAttachments.ts +181 -0
  214. package/src/primitives/error.ts +36 -0
  215. package/src/primitives/lastValidCache.ts +12 -0
  216. package/src/primitives/message.ts +54 -0
  217. package/src/primitives/messageAttachments.ts +32 -0
  218. package/src/primitives/stableKeys.test.ts +19 -0
  219. package/src/primitives/stableKeys.ts +21 -0
  220. package/src/primitives/suggestions.ts +179 -0
  221. package/src/primitives/thread.ts +46 -0
  222. package/src/primitives/threadList.ts +163 -0
  223. package/src/primitives/threadListFocusGroup.ts +56 -0
  224. package/src/primitives/threadListStructural.ts +86 -0
  225. package/src/primitives/useComposerSendState.ts +13 -0
  226. package/src/primitives/viewportContext.ts +16 -0
  227. package/src/useAui.ts +18 -0
  228. package/src/useAuiEvent.ts +64 -0
  229. package/src/useAuiState.ts +55 -0
  230. package/src/useScrollLock.test.ts +207 -0
  231. package/src/useScrollLock.ts +79 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreadPrimitiveViewport.js","names":[],"sources":["../../src/primitives/ThreadPrimitiveViewport.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n onMounted,\n onScopeDispose,\n provide,\n shallowRef,\n watch,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport type {} from \"@assistant-ui/core/store\";\nimport { useAuiEvent } from \"../useAuiEvent\";\nimport { useAuiState } from \"../useAuiState\";\nimport {\n isUserScrollUp,\n isViewportAtBottom,\n observeContentResize,\n viewportOverflows,\n} from \"@assistant-ui/store/client\";\nimport { viewportInjectionKey } from \"./viewportContext\";\n\n/**\n * A scrollable container that keeps the thread pinned to the bottom: content\n * growth scrolls back down while the user sits at the bottom, a run start\n * scrolls down, and scrolling up unpins until the user returns to the bottom.\n * The four options mirror the React hook and are independent: `autoScroll`\n * covers follow-on-content-growth, and the other three gate the\n * first-messages, run-start, and thread-switch scrolls. Provides the\n * scroll-to-bottom channel that {@link ThreadPrimitiveScrollToBottom} drives;\n * the React viewport's top-anchor system stays in the React viewport store\n * and is not ported.\n */\nexport const ThreadPrimitiveViewport = defineComponent({\n name: \"ThreadPrimitiveViewport\",\n props: {\n autoScroll: {\n type: Boolean,\n default: true,\n },\n scrollToBottomOnInitialize: {\n type: Boolean,\n default: true,\n },\n scrollToBottomOnRunStart: {\n type: Boolean,\n default: true,\n },\n scrollToBottomOnThreadSwitch: {\n type: Boolean,\n default: true,\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { slots }) {\n const divRef = shallowRef<HTMLElement | null>(null);\n const contentInset = shallowRef(0);\n const contentInsetEntries = new Map<symbol, number>();\n let intent: ScrollBehavior | null = null;\n const isAtBottom = shallowRef(true);\n let lastScrollTop = 0;\n let lastScrollHeight = 0;\n let lastObservedScrollHeight = 0;\n let lastObservedClientHeight = 0;\n let frame: number | null = null;\n\n const scrollToBottom = (behavior: ScrollBehavior) => {\n const div = divRef.value;\n if (!div) return;\n intent = behavior;\n div.scrollTo?.({ top: div.scrollHeight, behavior });\n };\n\n const scheduleScrollToBottom = (behavior: ScrollBehavior) => {\n intent = behavior;\n // The immediate watch below runs synchronously during SSR, where no\n // frame scheduler exists.\n if (typeof requestAnimationFrame === \"undefined\") return;\n if (frame !== null) cancelAnimationFrame(frame);\n frame = requestAnimationFrame(() => {\n frame = null;\n scrollToBottom(behavior);\n });\n };\n\n const handleScroll = () => {\n const div = divRef.value;\n if (!div) return;\n\n const newIsAtBottom = isViewportAtBottom(div, contentInset.value);\n const inFlightDownward = !newIsAtBottom && lastScrollTop < div.scrollTop;\n if (!inFlightDownward) {\n if (newIsAtBottom) {\n // At-bottom is ambiguous while the viewport does not overflow; keep\n // the intent alive until content can actually scroll.\n if (viewportOverflows(div, contentInset.value)) intent = null;\n } else if (\n isUserScrollUp(\n { scrollTop: lastScrollTop, scrollHeight: lastScrollHeight },\n div,\n )\n ) {\n intent = null;\n }\n if (newIsAtBottom || intent === null) isAtBottom.value = newIsAtBottom;\n }\n\n lastScrollTop = div.scrollTop;\n lastScrollHeight = div.scrollHeight;\n };\n\n const updateContentInset = () => {\n let total = 0;\n for (const height of contentInsetEntries.values()) total += height;\n if (contentInset.value === total) return;\n const grew = total > contentInset.value;\n contentInset.value = total;\n // A growing inset obscures content a pinned viewport was showing, so it\n // follows like a content resize; a shrinking inset reveals content and\n // must not move the viewport.\n if (grew) {\n if (intent) {\n scrollToBottom(intent);\n } else if (props.autoScroll && isAtBottom.value) {\n scrollToBottom(\"instant\");\n }\n }\n handleScroll();\n };\n\n const registerContentInset = () => {\n const id = Symbol();\n contentInsetEntries.set(id, 0);\n\n return {\n setHeight: (height: number) => {\n if (contentInsetEntries.get(id) === height) return;\n contentInsetEntries.set(id, height);\n updateContentInset();\n },\n unregister: () => {\n if (!contentInsetEntries.delete(id)) return;\n updateContentInset();\n },\n };\n };\n\n const onContentResize = () => {\n const div = divRef.value;\n if (!div) return;\n const { scrollHeight, clientHeight } = div;\n if (\n scrollHeight === lastObservedScrollHeight &&\n clientHeight === lastObservedClientHeight\n ) {\n return;\n }\n lastObservedScrollHeight = scrollHeight;\n lastObservedClientHeight = clientHeight;\n\n if (intent) {\n scrollToBottom(intent);\n } else if (props.autoScroll && isAtBottom.value) {\n scrollToBottom(\"instant\");\n }\n handleScroll();\n };\n\n // A pointer gesture invalidates pending bottom-scroll intent; otherwise an\n // intent kept alive by a non-overflowing thread hijacks the next content\n // growth. Unlike the React hook, an already scheduled frame is cancelled\n // too, so the gesture also wins the race against a just-planted intent.\n const onPointerdown = () => {\n intent = null;\n if (frame !== null) {\n cancelAnimationFrame(frame);\n frame = null;\n }\n };\n\n let disconnect: (() => void) | undefined;\n onMounted(() => {\n const div = divRef.value;\n if (!div) return;\n disconnect = observeContentResize(div, onContentResize);\n });\n onScopeDispose(() => {\n disconnect?.();\n if (frame !== null) cancelAnimationFrame(frame);\n });\n\n const hasMessages = useAuiState((s) => s.thread.messages.length > 0);\n let initialized = false;\n watch(\n [hasMessages, () => props.scrollToBottomOnInitialize],\n ([has, enabled]) => {\n if (!has) {\n initialized = false;\n return;\n }\n if (!enabled || initialized) return;\n initialized = true;\n if (intent !== null) return;\n scheduleScrollToBottom(\"instant\");\n },\n { immediate: true },\n );\n\n useAuiEvent(\"thread.runStart\", () => {\n if (!props.scrollToBottomOnRunStart) return;\n scheduleScrollToBottom(\"auto\");\n });\n\n useAuiEvent(\"threads.selectionChanged\", () => {\n if (!props.scrollToBottomOnThreadSwitch) return;\n scheduleScrollToBottom(\"instant\");\n });\n\n provide(viewportInjectionKey, {\n isAtBottom,\n scrollToBottom: (behavior: ScrollBehavior = \"auto\") =>\n scrollToBottom(behavior),\n registerContentInset,\n });\n\n return () =>\n h(\n \"div\",\n { ref: divRef, onScroll: handleScroll, onPointerdown },\n slots.default?.(),\n );\n },\n});\n"],"mappings":"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"}
@@ -0,0 +1,13 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /**
3
+ * A footer container that measures its height into the viewport's content
4
+ * inset. Positions within the summed inset of the native bottom count as at
5
+ * bottom, and a growing inset re-follows a pinned viewport. Multiple footers
6
+ * sum. Typically used with `class="sticky bottom-0"`.
7
+ */
8
+ export declare const ThreadPrimitiveViewportFooter: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
9
+ [key: string]: any;
10
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
11
+ default?: () => VNodeChild[];
12
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
13
+ //# sourceMappingURL=ThreadPrimitiveViewportFooter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreadPrimitiveViewportFooter.d.ts","sourceRoot":"","sources":["../../src/primitives/ThreadPrimitiveViewportFooter.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAGb;;;;;GAKG;AACH,eAAO,MAAM,6BAA6B;;;cAGD,MAAM,UAAU,EAAE;yEAqCzD,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { viewportInjectionKey } from "./viewportContext.js";
2
+ import { defineComponent, h, inject, mergeProps, onMounted, onScopeDispose, shallowRef } from "vue";
3
+ //#region src/primitives/ThreadPrimitiveViewportFooter.ts
4
+ /**
5
+ * A footer container that measures its height into the viewport's content
6
+ * inset. Positions within the summed inset of the native bottom count as at
7
+ * bottom, and a growing inset re-follows a pinned viewport. Multiple footers
8
+ * sum. Typically used with `class="sticky bottom-0"`.
9
+ */
10
+ const ThreadPrimitiveViewportFooter = defineComponent({
11
+ name: "ThreadPrimitiveViewportFooter",
12
+ inheritAttrs: false,
13
+ slots: Object,
14
+ setup(_, { attrs, slots }) {
15
+ const viewport = inject(viewportInjectionKey, null);
16
+ const divRef = shallowRef(null);
17
+ let dispose;
18
+ onMounted(() => {
19
+ const div = divRef.value;
20
+ if (!div || !viewport) return;
21
+ const contentInset = viewport.registerContentInset();
22
+ const updateHeight = () => {
23
+ const marginTop = Number.parseFloat(getComputedStyle(div).marginTop) || 0;
24
+ contentInset.setHeight(div.offsetHeight + marginTop);
25
+ };
26
+ updateHeight();
27
+ let resizeObserver;
28
+ if (typeof ResizeObserver !== "undefined") {
29
+ resizeObserver = new ResizeObserver(updateHeight);
30
+ resizeObserver.observe(div);
31
+ }
32
+ dispose = () => {
33
+ resizeObserver?.disconnect();
34
+ contentInset.unregister();
35
+ };
36
+ });
37
+ onScopeDispose(() => {
38
+ dispose?.();
39
+ });
40
+ return () => h("div", mergeProps(attrs, { ref: divRef }), slots.default?.());
41
+ }
42
+ });
43
+ //#endregion
44
+ export { ThreadPrimitiveViewportFooter };
45
+
46
+ //# sourceMappingURL=ThreadPrimitiveViewportFooter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThreadPrimitiveViewportFooter.js","names":[],"sources":["../../src/primitives/ThreadPrimitiveViewportFooter.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n inject,\n mergeProps,\n onMounted,\n onScopeDispose,\n shallowRef,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { viewportInjectionKey } from \"./viewportContext\";\n\n/**\n * A footer container that measures its height into the viewport's content\n * inset. Positions within the summed inset of the native bottom count as at\n * bottom, and a growing inset re-follows a pinned viewport. Multiple footers\n * sum. Typically used with `class=\"sticky bottom-0\"`.\n */\nexport const ThreadPrimitiveViewportFooter = defineComponent({\n name: \"ThreadPrimitiveViewportFooter\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const viewport = inject(viewportInjectionKey, null);\n const divRef = shallowRef<HTMLElement | null>(null);\n let dispose: (() => void) | undefined;\n\n onMounted(() => {\n const div = divRef.value;\n if (!div || !viewport) return;\n\n const contentInset = viewport.registerContentInset();\n const updateHeight = () => {\n const marginTop =\n Number.parseFloat(getComputedStyle(div).marginTop) || 0;\n contentInset.setHeight(div.offsetHeight + marginTop);\n };\n updateHeight();\n\n let resizeObserver: ResizeObserver | undefined;\n if (typeof ResizeObserver !== \"undefined\") {\n resizeObserver = new ResizeObserver(updateHeight);\n resizeObserver.observe(div);\n }\n\n dispose = () => {\n resizeObserver?.disconnect();\n contentInset.unregister();\n };\n });\n\n onScopeDispose(() => {\n dispose?.();\n });\n\n return () =>\n h(\"div\", mergeProps(attrs, { ref: divRef }), slots.default?.());\n },\n});\n"],"mappings":";;;;;;;;;AAmBA,MAAa,gCAAgC,gBAAgB;CAC3D,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,MAAM,WAAW,OAAO,sBAAsB,IAAI;EAClD,MAAM,SAAS,WAA+B,IAAI;EAClD,IAAI;EAEJ,gBAAgB;GACd,MAAM,MAAM,OAAO;GACnB,IAAI,CAAC,OAAO,CAAC,UAAU;GAEvB,MAAM,eAAe,SAAS,qBAAqB;GACnD,MAAM,qBAAqB;IACzB,MAAM,YACJ,OAAO,WAAW,iBAAiB,GAAG,CAAC,CAAC,SAAS,KAAK;IACxD,aAAa,UAAU,IAAI,eAAe,SAAS;GACrD;GACA,aAAa;GAEb,IAAI;GACJ,IAAI,OAAO,mBAAmB,aAAa;IACzC,iBAAiB,IAAI,eAAe,YAAY;IAChD,eAAe,QAAQ,GAAG;GAC5B;GAEA,gBAAgB;IACd,gBAAgB,WAAW;IAC3B,aAAa,WAAW;GAC1B;EACF,CAAC;EAED,qBAAqB;GACnB,UAAU;EACZ,CAAC;EAED,aACE,EAAE,OAAO,WAAW,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,MAAM,UAAU,CAAC;CAClE;AACF,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /** A button that begins editing the current message. Disabled while editing. */
3
+ export declare const ActionBarPrimitiveEdit: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
4
+ [key: string]: any;
5
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
6
+ default?: () => VNodeChild[];
7
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
+ /**
9
+ * A button that regenerates the current assistant message. Disabled while a
10
+ * run is in flight, the thread is disabled, or the message is not an
11
+ * assistant message.
12
+ */
13
+ export declare const ActionBarPrimitiveReload: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
14
+ [key: string]: any;
15
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
16
+ default?: () => VNodeChild[];
17
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
18
+ /**
19
+ * A button that copies the current message (or, while editing, the edit
20
+ * composer text). `data-copied` is present for `copiedDuration` milliseconds
21
+ * after a successful copy. Disabled while an assistant message is still
22
+ * running or the message has no text.
23
+ */
24
+ export declare const ActionBarPrimitiveCopy: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
25
+ copiedDuration: {
26
+ type: NumberConstructor;
27
+ default: number;
28
+ };
29
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
30
+ [key: string]: any;
31
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
32
+ copiedDuration: {
33
+ type: NumberConstructor;
34
+ default: number;
35
+ };
36
+ }>> & Readonly<{}>, {
37
+ copiedDuration: number;
38
+ }, SlotsType<{
39
+ default?: () => VNodeChild[];
40
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
41
+ //# sourceMappingURL=actionBar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionBar.d.ts","sourceRoot":"","sources":["../../src/primitives/actionBar.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAWb,gFAAgF;AAChF,eAAO,MAAM,sBAAsB;;;cAGM,MAAM,UAAU,EAAE;yEAoBzD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,wBAAwB;;;cAGI,MAAM,UAAU,EAAE;yEAoBzD,CAAC;AASH;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;cASM,MAAM,UAAU,EAAE;yEA8DzD,CAAC"}
@@ -0,0 +1,110 @@
1
+ import { useAuiState } from "../useAuiState.js";
2
+ import { useAui } from "../useAui.js";
3
+ import { isAttrDisabled } from "./attrDisabled.js";
4
+ import { defineComponent, h, mergeProps, onScopeDispose } from "vue";
5
+ import { actionBarCopyDisabled, actionBarEditDisabled, actionBarReloadDisabled } from "@assistant-ui/core/store/internal";
6
+ import { flushTapSync } from "@assistant-ui/tap";
7
+ //#region src/primitives/actionBar.ts
8
+ /** A button that begins editing the current message. Disabled while editing. */
9
+ const ActionBarPrimitiveEdit = defineComponent({
10
+ name: "ActionBarPrimitiveEdit",
11
+ inheritAttrs: false,
12
+ slots: Object,
13
+ setup(_, { attrs, slots }) {
14
+ const aui = useAui();
15
+ const disabled = useAuiState(actionBarEditDisabled);
16
+ const onClick = (event) => {
17
+ if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs)) return;
18
+ aui.composer.beginEdit();
19
+ };
20
+ return () => h("button", mergeProps(attrs, {
21
+ type: "button",
22
+ disabled: disabled.value || isAttrDisabled(attrs),
23
+ onClick
24
+ }), slots.default?.());
25
+ }
26
+ });
27
+ /**
28
+ * A button that regenerates the current assistant message. Disabled while a
29
+ * run is in flight, the thread is disabled, or the message is not an
30
+ * assistant message.
31
+ */
32
+ const ActionBarPrimitiveReload = defineComponent({
33
+ name: "ActionBarPrimitiveReload",
34
+ inheritAttrs: false,
35
+ slots: Object,
36
+ setup(_, { attrs, slots }) {
37
+ const aui = useAui();
38
+ const disabled = useAuiState(actionBarReloadDisabled);
39
+ const onClick = (event) => {
40
+ if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs)) return;
41
+ aui.message.reload();
42
+ };
43
+ return () => h("button", mergeProps(attrs, {
44
+ type: "button",
45
+ disabled: disabled.value || isAttrDisabled(attrs),
46
+ onClick
47
+ }), slots.default?.());
48
+ }
49
+ });
50
+ const defaultCopyToClipboard = (text) => {
51
+ if (typeof navigator === "undefined" || !navigator.clipboard) return Promise.reject(/* @__PURE__ */ new Error("Clipboard API is not available."));
52
+ return navigator.clipboard.writeText(text);
53
+ };
54
+ /**
55
+ * A button that copies the current message (or, while editing, the edit
56
+ * composer text). `data-copied` is present for `copiedDuration` milliseconds
57
+ * after a successful copy. Disabled while an assistant message is still
58
+ * running or the message has no text.
59
+ */
60
+ const ActionBarPrimitiveCopy = defineComponent({
61
+ name: "ActionBarPrimitiveCopy",
62
+ inheritAttrs: false,
63
+ props: { copiedDuration: {
64
+ type: Number,
65
+ default: 3e3
66
+ } },
67
+ slots: Object,
68
+ setup(props, { attrs, slots }) {
69
+ const aui = useAui();
70
+ const disabled = useAuiState(actionBarCopyDisabled);
71
+ const isCopied = useAuiState((s) => s.message.isCopied);
72
+ const isEditing = useAuiState((s) => s.composer.isEditing);
73
+ const composerText = useAuiState((s) => s.composer.text);
74
+ let copiedTimer;
75
+ let disposed = false;
76
+ onScopeDispose(() => {
77
+ disposed = true;
78
+ if (copiedTimer === void 0) return;
79
+ clearTimeout(copiedTimer);
80
+ copiedTimer = void 0;
81
+ aui.message.setIsCopied(false);
82
+ });
83
+ const onClick = (event) => {
84
+ if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs)) return;
85
+ const value = isEditing.value ? composerText.value : aui.message.getCopyText();
86
+ if (!value) return;
87
+ const copiedMessageId = aui.message.getState().id;
88
+ const stillCopiedMessage = () => !disposed && aui.message.getState().id === copiedMessageId;
89
+ Promise.resolve(defaultCopyToClipboard(value)).then(() => {
90
+ if (!stillCopiedMessage()) return;
91
+ if (copiedTimer !== void 0) clearTimeout(copiedTimer);
92
+ flushTapSync(() => aui.message.setIsCopied(true));
93
+ copiedTimer = setTimeout(() => {
94
+ copiedTimer = void 0;
95
+ if (stillCopiedMessage()) flushTapSync(() => aui.message.setIsCopied(false));
96
+ }, props.copiedDuration);
97
+ }, () => {});
98
+ };
99
+ return () => h("button", mergeProps(attrs, {
100
+ type: "button",
101
+ disabled: disabled.value || isAttrDisabled(attrs),
102
+ ...isCopied.value && { "data-copied": "" },
103
+ onClick
104
+ }), slots.default?.());
105
+ }
106
+ });
107
+ //#endregion
108
+ export { ActionBarPrimitiveCopy, ActionBarPrimitiveEdit, ActionBarPrimitiveReload };
109
+
110
+ //# sourceMappingURL=actionBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionBar.js","names":[],"sources":["../../src/primitives/actionBar.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n mergeProps,\n onScopeDispose,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { flushTapSync } from \"@assistant-ui/tap\";\nimport {\n actionBarCopyDisabled,\n actionBarEditDisabled,\n actionBarReloadDisabled,\n} from \"@assistant-ui/core/store/internal\";\nimport { isAttrDisabled } from \"./attrDisabled\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\n\n/** A button that begins editing the current message. Disabled while editing. */\nexport const ActionBarPrimitiveEdit = defineComponent({\n name: \"ActionBarPrimitiveEdit\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const aui = useAui();\n const disabled = useAuiState(actionBarEditDisabled);\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs))\n return;\n aui.composer.beginEdit();\n };\n return () =>\n h(\n \"button\",\n mergeProps(attrs, {\n type: \"button\",\n disabled: disabled.value || isAttrDisabled(attrs),\n onClick,\n }),\n slots.default?.(),\n );\n },\n});\n\n/**\n * A button that regenerates the current assistant message. Disabled while a\n * run is in flight, the thread is disabled, or the message is not an\n * assistant message.\n */\nexport const ActionBarPrimitiveReload = defineComponent({\n name: \"ActionBarPrimitiveReload\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const aui = useAui();\n const disabled = useAuiState(actionBarReloadDisabled);\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs))\n return;\n aui.message.reload();\n };\n return () =>\n h(\n \"button\",\n mergeProps(attrs, {\n type: \"button\",\n disabled: disabled.value || isAttrDisabled(attrs),\n onClick,\n }),\n slots.default?.(),\n );\n },\n});\n\nconst defaultCopyToClipboard = (text: string) => {\n if (typeof navigator === \"undefined\" || !navigator.clipboard) {\n return Promise.reject(new Error(\"Clipboard API is not available.\"));\n }\n return navigator.clipboard.writeText(text);\n};\n\n/**\n * A button that copies the current message (or, while editing, the edit\n * composer text). `data-copied` is present for `copiedDuration` milliseconds\n * after a successful copy. Disabled while an assistant message is still\n * running or the message has no text.\n */\nexport const ActionBarPrimitiveCopy = defineComponent({\n name: \"ActionBarPrimitiveCopy\",\n inheritAttrs: false,\n props: {\n copiedDuration: {\n type: Number,\n default: 3000,\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { attrs, slots }) {\n const aui = useAui();\n const disabled = useAuiState(actionBarCopyDisabled);\n const isCopied = useAuiState((s) => s.message.isCopied);\n const isEditing = useAuiState((s) => s.composer.isEditing);\n const composerText = useAuiState((s) => s.composer.text);\n\n let copiedTimer: ReturnType<typeof setTimeout> | undefined;\n let disposed = false;\n onScopeDispose(() => {\n disposed = true;\n if (copiedTimer === undefined) return;\n clearTimeout(copiedTimer);\n copiedTimer = undefined;\n aui.message.setIsCopied(false);\n });\n\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs))\n return;\n const value = isEditing.value\n ? composerText.value\n : aui.message.getCopyText();\n if (!value) return;\n // A by-index scope follows whatever message occupies the slot, so late\n // completions and timers re-check the copied message's id before\n // touching state.\n const copiedMessageId = aui.message.getState().id;\n const stillCopiedMessage = () =>\n !disposed && aui.message.getState().id === copiedMessageId;\n // The rejection handler swallows clipboard write failures (permission\n // denied, API unavailable) so they don't surface as unhandled promise\n // rejections.\n Promise.resolve(defaultCopyToClipboard(value)).then(\n () => {\n if (!stillCopiedMessage()) return;\n if (copiedTimer !== undefined) clearTimeout(copiedTimer);\n flushTapSync(() => aui.message.setIsCopied(true));\n copiedTimer = setTimeout(() => {\n copiedTimer = undefined;\n if (stillCopiedMessage()) {\n flushTapSync(() => aui.message.setIsCopied(false));\n }\n }, props.copiedDuration);\n },\n () => {},\n );\n };\n\n return () =>\n h(\n \"button\",\n mergeProps(attrs, {\n type: \"button\",\n disabled: disabled.value || isAttrDisabled(attrs),\n ...(isCopied.value && { \"data-copied\": \"\" }),\n onClick,\n }),\n slots.default?.(),\n );\n },\n});\n"],"mappings":"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"}
@@ -0,0 +1,27 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /** A wrapper element scoped to the current attachment. */
3
+ export declare const AttachmentPrimitiveRoot: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
4
+ [key: string]: any;
5
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
6
+ default?: () => VNodeChild[];
7
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
+ /** Renders the current attachment's file name as raw text. */
9
+ export declare const AttachmentPrimitiveName: import("vue").DefineComponent<{}, () => string | VNodeChild[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
10
+ default?: () => VNodeChild[];
11
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
12
+ /**
13
+ * Renders a short label for the current attachment: the file extension when
14
+ * the name has one, otherwise the attachment type.
15
+ */
16
+ export declare const AttachmentPrimitiveThumb: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
17
+ [key: string]: any;
18
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
19
+ default?: () => VNodeChild[];
20
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
21
+ /** A button that removes the current attachment. */
22
+ export declare const AttachmentPrimitiveRemove: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
23
+ [key: string]: any;
24
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
25
+ default?: () => VNodeChild[];
26
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
27
+ //# sourceMappingURL=attachment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment.d.ts","sourceRoot":"","sources":["../../src/primitives/attachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAKb,0DAA0D;AAC1D,eAAO,MAAM,uBAAuB;;;cAGK,MAAM,UAAU,EAAE;yEAIzD,CAAC;AAEH,8DAA8D;AAC9D,eAAO,MAAM,uBAAuB;cAEK,MAAM,UAAU,EAAE;yEAKzD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;cAGI,MAAM,UAAU,EAAE;yEAazD,CAAC;AAEH,oDAAoD;AACpD,eAAO,MAAM,yBAAyB;;;cAGG,MAAM,UAAU,EAAE;yEAkBzD,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { useAuiState } from "../useAuiState.js";
2
+ import { useAui } from "../useAui.js";
3
+ import { isAttrDisabled } from "./attrDisabled.js";
4
+ import { defineComponent, h, mergeProps } from "vue";
5
+ //#region src/primitives/attachment.ts
6
+ /** A wrapper element scoped to the current attachment. */
7
+ const AttachmentPrimitiveRoot = defineComponent({
8
+ name: "AttachmentPrimitiveRoot",
9
+ inheritAttrs: false,
10
+ slots: Object,
11
+ setup(_, { attrs, slots }) {
12
+ return () => h("div", mergeProps(attrs, {}), slots.default?.());
13
+ }
14
+ });
15
+ /** Renders the current attachment's file name as raw text. */
16
+ const AttachmentPrimitiveName = defineComponent({
17
+ name: "AttachmentPrimitiveName",
18
+ slots: Object,
19
+ setup(_, { slots }) {
20
+ const name = useAuiState((s) => s.attachment.name);
21
+ return () => slots.default?.() ?? name.value;
22
+ }
23
+ });
24
+ /**
25
+ * Renders a short label for the current attachment: the file extension when
26
+ * the name has one, otherwise the attachment type.
27
+ */
28
+ const AttachmentPrimitiveThumb = defineComponent({
29
+ name: "AttachmentPrimitiveThumb",
30
+ inheritAttrs: false,
31
+ slots: Object,
32
+ setup(_, { attrs, slots }) {
33
+ const label = useAuiState((s) => {
34
+ const name = s.attachment.name;
35
+ const dot = name.lastIndexOf(".");
36
+ if (dot > 0 && dot < name.length - 1) return `.${name.slice(dot + 1)}`;
37
+ return s.attachment.type;
38
+ });
39
+ return () => h("div", mergeProps(attrs, {}), slots.default?.() ?? label.value);
40
+ }
41
+ });
42
+ /** A button that removes the current attachment. */
43
+ const AttachmentPrimitiveRemove = defineComponent({
44
+ name: "AttachmentPrimitiveRemove",
45
+ inheritAttrs: false,
46
+ slots: Object,
47
+ setup(_, { attrs, slots }) {
48
+ const aui = useAui();
49
+ const onClick = (event) => {
50
+ if (event.defaultPrevented || isAttrDisabled(attrs)) return;
51
+ aui.attachment.remove();
52
+ };
53
+ return () => h("button", mergeProps(attrs, {
54
+ type: "button",
55
+ disabled: isAttrDisabled(attrs),
56
+ onClick
57
+ }), slots.default?.());
58
+ }
59
+ });
60
+ //#endregion
61
+ export { AttachmentPrimitiveName, AttachmentPrimitiveRemove, AttachmentPrimitiveRoot, AttachmentPrimitiveThumb };
62
+
63
+ //# sourceMappingURL=attachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attachment.js","names":[],"sources":["../../src/primitives/attachment.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n mergeProps,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { isAttrDisabled } from \"./attrDisabled\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\n\n/** A wrapper element scoped to the current attachment. */\nexport const AttachmentPrimitiveRoot = defineComponent({\n name: \"AttachmentPrimitiveRoot\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n return () => h(\"div\", mergeProps(attrs, {}), slots.default?.());\n },\n});\n\n/** Renders the current attachment's file name as raw text. */\nexport const AttachmentPrimitiveName = defineComponent({\n name: \"AttachmentPrimitiveName\",\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { slots }) {\n const name = useAuiState((s) => s.attachment.name);\n return () => slots.default?.() ?? name.value;\n },\n});\n\n/**\n * Renders a short label for the current attachment: the file extension when\n * the name has one, otherwise the attachment type.\n */\nexport const AttachmentPrimitiveThumb = defineComponent({\n name: \"AttachmentPrimitiveThumb\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const label = useAuiState((s) => {\n const name = s.attachment.name;\n const dot = name.lastIndexOf(\".\");\n if (dot > 0 && dot < name.length - 1) {\n return `.${name.slice(dot + 1)}`;\n }\n return s.attachment.type;\n });\n return () =>\n h(\"div\", mergeProps(attrs, {}), slots.default?.() ?? label.value);\n },\n});\n\n/** A button that removes the current attachment. */\nexport const AttachmentPrimitiveRemove = defineComponent({\n name: \"AttachmentPrimitiveRemove\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const aui = useAui();\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || isAttrDisabled(attrs)) return;\n void aui.attachment.remove();\n };\n return () =>\n h(\n \"button\",\n mergeProps(attrs, {\n type: \"button\",\n disabled: isAttrDisabled(attrs),\n onClick,\n }),\n slots.default?.(),\n );\n },\n});\n"],"mappings":";;;;;;AAYA,MAAa,0BAA0B,gBAAgB;CACrD,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,aAAa,EAAE,OAAO,WAAW,OAAO,CAAC,CAAC,GAAG,MAAM,UAAU,CAAC;CAChE;AACF,CAAC;;AAGD,MAAa,0BAA0B,gBAAgB;CACrD,MAAM;CACN,OAAO;CACP,MAAM,GAAG,EAAE,SAAS;EAClB,MAAM,OAAO,aAAa,MAAM,EAAE,WAAW,IAAI;EACjD,aAAa,MAAM,UAAU,KAAK,KAAK;CACzC;AACF,CAAC;;;;;AAMD,MAAa,2BAA2B,gBAAgB;CACtD,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,MAAM,QAAQ,aAAa,MAAM;GAC/B,MAAM,OAAO,EAAE,WAAW;GAC1B,MAAM,MAAM,KAAK,YAAY,GAAG;GAChC,IAAI,MAAM,KAAK,MAAM,KAAK,SAAS,GACjC,OAAO,IAAI,KAAK,MAAM,MAAM,CAAC;GAE/B,OAAO,EAAE,WAAW;EACtB,CAAC;EACD,aACE,EAAE,OAAO,WAAW,OAAO,CAAC,CAAC,GAAG,MAAM,UAAU,KAAK,MAAM,KAAK;CACpE;AACF,CAAC;;AAGD,MAAa,4BAA4B,gBAAgB;CACvD,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,MAAM,MAAM,OAAO;EACnB,MAAM,WAAW,UAAsB;GACrC,IAAI,MAAM,oBAAoB,eAAe,KAAK,GAAG;GACrD,IAAS,WAAW,OAAO;EAC7B;EACA,aACE,EACE,UACA,WAAW,OAAO;GAChB,MAAM;GACN,UAAU,eAAe,KAAK;GAC9B;EACF,CAAC,GACD,MAAM,UAAU,CAClB;CACJ;AACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const isAttrDisabled: (attrs: Record<string, unknown>) => boolean;
2
+ //# sourceMappingURL=attrDisabled.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attrDisabled.d.ts","sourceRoot":"","sources":["../../src/primitives/attrDisabled.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,OAGpC,CAAC"}
@@ -0,0 +1,6 @@
1
+ //#region src/primitives/attrDisabled.ts
2
+ const isAttrDisabled = (attrs) => attrs.disabled != null && attrs.disabled !== false && attrs.disabled !== "false";
3
+ //#endregion
4
+ export { isAttrDisabled };
5
+
6
+ //# sourceMappingURL=attrDisabled.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attrDisabled.js","names":[],"sources":["../../src/primitives/attrDisabled.ts"],"sourcesContent":["// A bare `disabled` template attribute arrives as \"\", which Boolean() would\n// drop; mirror Vue's boolean-attribute semantics instead.\nexport const isAttrDisabled = (attrs: Record<string, unknown>): boolean =>\n attrs.disabled != null &&\n attrs.disabled !== false &&\n attrs.disabled !== \"false\";\n"],"mappings":";AAEA,MAAa,kBAAkB,UAC7B,MAAM,YAAY,QAClB,MAAM,aAAa,SACnB,MAAM,aAAa"}
@@ -0,0 +1,18 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /** A button that switches the current message to its previous branch. */
3
+ export declare const BranchPickerPrimitivePrevious: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
4
+ [key: string]: any;
5
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
6
+ default?: () => VNodeChild[];
7
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
+ /** A button that switches the current message to its next branch. */
9
+ export declare const BranchPickerPrimitiveNext: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
10
+ [key: string]: any;
11
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
12
+ default?: () => VNodeChild[];
13
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
14
+ /** Renders the current message's 1-based branch number as text. */
15
+ export declare const BranchPickerPrimitiveNumber: import("vue").DefineComponent<{}, () => string, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
16
+ /** Renders the current message's branch count as text. */
17
+ export declare const BranchPickerPrimitiveCount: import("vue").DefineComponent<{}, () => string, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
18
+ //# sourceMappingURL=branchPicker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branchPicker.d.ts","sourceRoot":"","sources":["../../src/primitives/branchPicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAuCb,yEAAyE;AACzE,eAAO,MAAM,6BAA6B;;;cAvBC,MAAM,UAAU,EAAE;yEA2B5D,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,yBAAyB;;;cA9BK,MAAM,UAAU,EAAE;yEAkC5D,CAAC;AAEF,mEAAmE;AACnE,eAAO,MAAM,2BAA2B,yRAMtC,CAAC;AAEH,0DAA0D;AAC1D,eAAO,MAAM,0BAA0B,yRAMrC,CAAC"}
@@ -0,0 +1,48 @@
1
+ import { useAuiState } from "../useAuiState.js";
2
+ import { useAui } from "../useAui.js";
3
+ import { isAttrDisabled } from "./attrDisabled.js";
4
+ import { defineComponent, h, mergeProps } from "vue";
5
+ import { branchPickerNextDisabled, branchPickerPreviousDisabled } from "@assistant-ui/core/store/internal";
6
+ //#region src/primitives/branchPicker.ts
7
+ const branchButton = (name, useDisabled, position) => defineComponent({
8
+ name,
9
+ inheritAttrs: false,
10
+ slots: Object,
11
+ setup(_, { attrs, slots }) {
12
+ const aui = useAui();
13
+ const disabled = useDisabled();
14
+ const onClick = (event) => {
15
+ if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs)) return;
16
+ aui.message.switchToBranch({ position });
17
+ };
18
+ return () => h("button", mergeProps(attrs, {
19
+ type: "button",
20
+ disabled: disabled.value || isAttrDisabled(attrs),
21
+ onClick
22
+ }), slots.default?.());
23
+ }
24
+ });
25
+ /** A button that switches the current message to its previous branch. */
26
+ const BranchPickerPrimitivePrevious = branchButton("BranchPickerPrimitivePrevious", () => useAuiState(branchPickerPreviousDisabled), "previous");
27
+ /** A button that switches the current message to its next branch. */
28
+ const BranchPickerPrimitiveNext = branchButton("BranchPickerPrimitiveNext", () => useAuiState(branchPickerNextDisabled), "next");
29
+ /** Renders the current message's 1-based branch number as text. */
30
+ const BranchPickerPrimitiveNumber = defineComponent({
31
+ name: "BranchPickerPrimitiveNumber",
32
+ setup() {
33
+ const branchNumber = useAuiState((s) => s.message.branchNumber);
34
+ return () => String(branchNumber.value);
35
+ }
36
+ });
37
+ /** Renders the current message's branch count as text. */
38
+ const BranchPickerPrimitiveCount = defineComponent({
39
+ name: "BranchPickerPrimitiveCount",
40
+ setup() {
41
+ const branchCount = useAuiState((s) => s.message.branchCount);
42
+ return () => String(branchCount.value);
43
+ }
44
+ });
45
+ //#endregion
46
+ export { BranchPickerPrimitiveCount, BranchPickerPrimitiveNext, BranchPickerPrimitiveNumber, BranchPickerPrimitivePrevious };
47
+
48
+ //# sourceMappingURL=branchPicker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branchPicker.js","names":[],"sources":["../../src/primitives/branchPicker.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n mergeProps,\n type ComputedRef,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport {\n branchPickerNextDisabled,\n branchPickerPreviousDisabled,\n} from \"@assistant-ui/core/store/internal\";\nimport { isAttrDisabled } from \"./attrDisabled\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\n\nconst branchButton = (\n name: string,\n useDisabled: () => ComputedRef<boolean>,\n position: \"previous\" | \"next\",\n) =>\n defineComponent({\n name,\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const aui = useAui();\n const disabled = useDisabled();\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs))\n return;\n aui.message.switchToBranch({ position });\n };\n return () =>\n h(\n \"button\",\n mergeProps(attrs, {\n type: \"button\",\n disabled: disabled.value || isAttrDisabled(attrs),\n onClick,\n }),\n slots.default?.(),\n );\n },\n });\n\n/** A button that switches the current message to its previous branch. */\nexport const BranchPickerPrimitivePrevious = branchButton(\n \"BranchPickerPrimitivePrevious\",\n () => useAuiState(branchPickerPreviousDisabled),\n \"previous\",\n);\n\n/** A button that switches the current message to its next branch. */\nexport const BranchPickerPrimitiveNext = branchButton(\n \"BranchPickerPrimitiveNext\",\n () => useAuiState(branchPickerNextDisabled),\n \"next\",\n);\n\n/** Renders the current message's 1-based branch number as text. */\nexport const BranchPickerPrimitiveNumber = defineComponent({\n name: \"BranchPickerPrimitiveNumber\",\n setup() {\n const branchNumber = useAuiState((s) => s.message.branchNumber);\n return () => String(branchNumber.value);\n },\n});\n\n/** Renders the current message's branch count as text. */\nexport const BranchPickerPrimitiveCount = defineComponent({\n name: \"BranchPickerPrimitiveCount\",\n setup() {\n const branchCount = useAuiState((s) => s.message.branchCount);\n return () => String(branchCount.value);\n },\n});\n"],"mappings":";;;;;;AAgBA,MAAM,gBACJ,MACA,aACA,aAEA,gBAAgB;CACd;CACA,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,MAAM,MAAM,OAAO;EACnB,MAAM,WAAW,YAAY;EAC7B,MAAM,WAAW,UAAsB;GACrC,IAAI,MAAM,oBAAoB,SAAS,SAAS,eAAe,KAAK,GAClE;GACF,IAAI,QAAQ,eAAe,EAAE,SAAS,CAAC;EACzC;EACA,aACE,EACE,UACA,WAAW,OAAO;GAChB,MAAM;GACN,UAAU,SAAS,SAAS,eAAe,KAAK;GAChD;EACF,CAAC,GACD,MAAM,UAAU,CAClB;CACJ;AACF,CAAC;;AAGH,MAAa,gCAAgC,aAC3C,uCACM,YAAY,4BAA4B,GAC9C,UACF;;AAGA,MAAa,4BAA4B,aACvC,mCACM,YAAY,wBAAwB,GAC1C,MACF;;AAGA,MAAa,8BAA8B,gBAAgB;CACzD,MAAM;CACN,QAAQ;EACN,MAAM,eAAe,aAAa,MAAM,EAAE,QAAQ,YAAY;EAC9D,aAAa,OAAO,aAAa,KAAK;CACxC;AACF,CAAC;;AAGD,MAAa,6BAA6B,gBAAgB;CACxD,MAAM;CACN,QAAQ;EACN,MAAM,cAAc,aAAa,MAAM,EAAE,QAAQ,WAAW;EAC5D,aAAa,OAAO,YAAY,KAAK;CACvC;AACF,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /**
3
+ * Renders the composer's pending attachments in order, each scoped through
4
+ * {@link AttachmentByIndexProvider}; the `default` slot renders each
5
+ * attachment.
6
+ */
7
+ export declare const ComposerPrimitiveAttachments: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
8
+ [key: string]: any;
9
+ }>[], {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
10
+ default?: () => VNodeChild[];
11
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
12
+ /**
13
+ * A button that opens a file picker and adds the selected files to the
14
+ * composer. Disabled while the composer is not editable. The picker's accept
15
+ * filter follows the composer's `attachmentAccept`.
16
+ */
17
+ export declare const ComposerPrimitiveAddAttachment: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
18
+ multiple: {
19
+ type: BooleanConstructor;
20
+ default: boolean;
21
+ };
22
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
23
+ [key: string]: any;
24
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
25
+ multiple: {
26
+ type: BooleanConstructor;
27
+ default: boolean;
28
+ };
29
+ }>> & Readonly<{}>, {
30
+ multiple: boolean;
31
+ }, SlotsType<{
32
+ default?: () => VNodeChild[];
33
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
34
+ /**
35
+ * A drop target that adds dropped files to the composer. `data-dragging` is
36
+ * present while a file drag hovers the element. File drags are claimed via
37
+ * `preventDefault` even when the runtime does not support attachments, since
38
+ * an unprevented file drop navigates the tab to the file.
39
+ */
40
+ export declare const ComposerPrimitiveAttachmentDropzone: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
41
+ disabled: {
42
+ type: BooleanConstructor;
43
+ default: boolean;
44
+ };
45
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
46
+ [key: string]: any;
47
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
48
+ disabled: {
49
+ type: BooleanConstructor;
50
+ default: boolean;
51
+ };
52
+ }>> & Readonly<{}>, {
53
+ disabled: boolean;
54
+ }, SlotsType<{
55
+ default?: () => VNodeChild[];
56
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
57
+ //# sourceMappingURL=composerAttachments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composerAttachments.d.ts","sourceRoot":"","sources":["../../src/primitives/composerAttachments.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAOb;;;;GAIG;AACH,eAAO,MAAM,4BAA4B;;;cAEA,MAAM,UAAU,EAAE;yEAezD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;cASF,MAAM,UAAU,EAAE;yEA4CzD,CAAC;AAEH;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;cASP,MAAM,UAAU,EAAE;yEAkEzD,CAAC"}