@assistant-ui/vue 0.0.0 → 0.0.2

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 +51 -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 +21 -0
  67. package/dist/primitives/ThreadPrimitiveMessages.d.ts.map +1 -0
  68. package/dist/primitives/ThreadPrimitiveMessages.js +35 -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 +99 -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 +829 -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 +408 -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 +70 -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 +167 -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 +38 -0
  205. package/src/primitives/ThreadPrimitiveScrollToBottom.ts +65 -0
  206. package/src/primitives/ThreadPrimitiveViewport.ts +120 -0
  207. package/src/primitives/ThreadPrimitiveViewportFooter.test.ts +400 -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":"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"}
@@ -0,0 +1,132 @@
1
+ import { useAuiState } from "../useAuiState.js";
2
+ import { useAui } from "../useAui.js";
3
+ import { getAttachmentKeys, useStableKeys } from "./stableKeys.js";
4
+ import { isAttrDisabled } from "./attrDisabled.js";
5
+ import { AttachmentByIndexProvider } from "./AttachmentByIndexProvider.js";
6
+ import { defineComponent, h, mergeProps, ref, watch } from "vue";
7
+ //#region src/primitives/composerAttachments.ts
8
+ /**
9
+ * Renders the composer's pending attachments in order, each scoped through
10
+ * {@link AttachmentByIndexProvider}; the `default` slot renders each
11
+ * attachment.
12
+ */
13
+ const ComposerPrimitiveAttachments = defineComponent({
14
+ name: "ComposerPrimitiveAttachments",
15
+ slots: Object,
16
+ setup(_, { slots }) {
17
+ const attachments = useAuiState((s) => s.composer.attachments);
18
+ const attachmentKeys = useStableKeys(() => getAttachmentKeys(attachments.value));
19
+ return () => attachmentKeys.value.map((key, index) => h(AttachmentByIndexProvider, {
20
+ source: "composer",
21
+ index,
22
+ key
23
+ }, { default: () => slots.default?.() }));
24
+ }
25
+ });
26
+ /**
27
+ * A button that opens a file picker and adds the selected files to the
28
+ * composer. Disabled while the composer is not editable. The picker's accept
29
+ * filter follows the composer's `attachmentAccept`.
30
+ */
31
+ const ComposerPrimitiveAddAttachment = defineComponent({
32
+ name: "ComposerPrimitiveAddAttachment",
33
+ inheritAttrs: false,
34
+ props: { multiple: {
35
+ type: Boolean,
36
+ default: true
37
+ } },
38
+ slots: Object,
39
+ setup(props, { attrs, slots }) {
40
+ const aui = useAui();
41
+ const disabled = useAuiState((s) => !s.composer.isEditing);
42
+ const onClick = (event) => {
43
+ if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs)) return;
44
+ const input = document.createElement("input");
45
+ input.type = "file";
46
+ input.multiple = props.multiple;
47
+ input.hidden = true;
48
+ const attachmentAccept = aui.composer.getState().attachmentAccept;
49
+ if (attachmentAccept !== "*") input.accept = attachmentAccept;
50
+ document.body.appendChild(input);
51
+ input.onchange = (e) => {
52
+ const fileList = e.target.files;
53
+ if (fileList) for (const file of Array.from(fileList)) aui.composer.addAttachment(file).catch(() => {});
54
+ input.remove();
55
+ };
56
+ input.oncancel = () => input.remove();
57
+ input.click();
58
+ };
59
+ return () => h("button", mergeProps(attrs, {
60
+ type: "button",
61
+ disabled: disabled.value || isAttrDisabled(attrs),
62
+ onClick
63
+ }), slots.default?.());
64
+ }
65
+ });
66
+ /**
67
+ * A drop target that adds dropped files to the composer. `data-dragging` is
68
+ * present while a file drag hovers the element. File drags are claimed via
69
+ * `preventDefault` even when the runtime does not support attachments, since
70
+ * an unprevented file drop navigates the tab to the file.
71
+ */
72
+ const ComposerPrimitiveAttachmentDropzone = defineComponent({
73
+ name: "ComposerPrimitiveAttachmentDropzone",
74
+ inheritAttrs: false,
75
+ props: { disabled: {
76
+ type: Boolean,
77
+ default: false
78
+ } },
79
+ slots: Object,
80
+ setup(props, { attrs, slots }) {
81
+ const aui = useAui();
82
+ const isDragging = ref(false);
83
+ watch(() => props.disabled, (disabled) => {
84
+ if (disabled) isDragging.value = false;
85
+ });
86
+ const isFileDrag = (event) => event.dataTransfer?.types.includes("Files") === true;
87
+ const onDragenterCapture = (event) => {
88
+ if (props.disabled || !isFileDrag(event)) return;
89
+ event.preventDefault();
90
+ if (!aui.thread.getState().capabilities.attachments) {
91
+ event.dataTransfer.dropEffect = "none";
92
+ return;
93
+ }
94
+ isDragging.value = true;
95
+ };
96
+ const onDragoverCapture = (event) => {
97
+ if (props.disabled || !isFileDrag(event)) return;
98
+ event.preventDefault();
99
+ if (!aui.thread.getState().capabilities.attachments) {
100
+ event.dataTransfer.dropEffect = "none";
101
+ return;
102
+ }
103
+ if (!isDragging.value) isDragging.value = true;
104
+ };
105
+ const onDragleaveCapture = (event) => {
106
+ if (props.disabled || !isFileDrag(event)) return;
107
+ const related = event.relatedTarget;
108
+ if (related && event.currentTarget.contains(related)) return;
109
+ isDragging.value = false;
110
+ };
111
+ const onDropCapture = (event) => {
112
+ if (props.disabled) return;
113
+ isDragging.value = false;
114
+ if (!isFileDrag(event)) return;
115
+ event.preventDefault();
116
+ const files = Array.from(event.dataTransfer?.files ?? []);
117
+ if (!aui.thread.getState().capabilities.attachments || files.length === 0) return;
118
+ for (const file of files) aui.composer.addAttachment(file).catch(() => {});
119
+ };
120
+ return () => h("div", mergeProps(attrs, {
121
+ ...!props.disabled && isDragging.value && { "data-dragging": "true" },
122
+ onDragenterCapture,
123
+ onDragoverCapture,
124
+ onDragleaveCapture,
125
+ onDropCapture
126
+ }), slots.default?.());
127
+ }
128
+ });
129
+ //#endregion
130
+ export { ComposerPrimitiveAddAttachment, ComposerPrimitiveAttachmentDropzone, ComposerPrimitiveAttachments };
131
+
132
+ //# sourceMappingURL=composerAttachments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composerAttachments.js","names":[],"sources":["../../src/primitives/composerAttachments.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n mergeProps,\n ref,\n watch,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { isAttrDisabled } from \"./attrDisabled\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\nimport { AttachmentByIndexProvider } from \"./AttachmentByIndexProvider\";\nimport { getAttachmentKeys, useStableKeys } from \"./stableKeys\";\n\n/**\n * Renders the composer's pending attachments in order, each scoped through\n * {@link AttachmentByIndexProvider}; the `default` slot renders each\n * attachment.\n */\nexport const ComposerPrimitiveAttachments = defineComponent({\n name: \"ComposerPrimitiveAttachments\",\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { slots }) {\n const attachments = useAuiState((s) => s.composer.attachments);\n const attachmentKeys = useStableKeys(() =>\n getAttachmentKeys(attachments.value),\n );\n return () =>\n attachmentKeys.value.map((key, index) =>\n h(\n AttachmentByIndexProvider,\n { source: \"composer\", index, key },\n { default: () => slots.default?.() },\n ),\n );\n },\n});\n\n/**\n * A button that opens a file picker and adds the selected files to the\n * composer. Disabled while the composer is not editable. The picker's accept\n * filter follows the composer's `attachmentAccept`.\n */\nexport const ComposerPrimitiveAddAttachment = defineComponent({\n name: \"ComposerPrimitiveAddAttachment\",\n inheritAttrs: false,\n props: {\n multiple: {\n type: Boolean,\n default: true,\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { attrs, slots }) {\n const aui = useAui();\n const disabled = useAuiState((s) => !s.composer.isEditing);\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs))\n return;\n\n const input = document.createElement(\"input\");\n input.type = \"file\";\n input.multiple = props.multiple;\n input.hidden = true;\n\n const attachmentAccept = aui.composer.getState().attachmentAccept;\n if (attachmentAccept !== \"*\") {\n input.accept = attachmentAccept;\n }\n\n document.body.appendChild(input);\n\n input.onchange = (e) => {\n const fileList = (e.target as HTMLInputElement).files;\n if (fileList) {\n for (const file of Array.from(fileList)) {\n aui.composer.addAttachment(file).catch(() => {});\n }\n }\n input.remove();\n };\n input.oncancel = () => input.remove();\n\n input.click();\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 drop target that adds dropped files to the composer. `data-dragging` is\n * present while a file drag hovers the element. File drags are claimed via\n * `preventDefault` even when the runtime does not support attachments, since\n * an unprevented file drop navigates the tab to the file.\n */\nexport const ComposerPrimitiveAttachmentDropzone = defineComponent({\n name: \"ComposerPrimitiveAttachmentDropzone\",\n inheritAttrs: false,\n props: {\n disabled: {\n type: Boolean,\n default: false,\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { attrs, slots }) {\n const aui = useAui();\n const isDragging = ref(false);\n\n watch(\n () => props.disabled,\n (disabled) => {\n if (disabled) isDragging.value = false;\n },\n );\n\n const isFileDrag = (event: DragEvent) =>\n event.dataTransfer?.types.includes(\"Files\") === true;\n\n const onDragenterCapture = (event: DragEvent) => {\n if (props.disabled || !isFileDrag(event)) return;\n event.preventDefault();\n if (!aui.thread.getState().capabilities.attachments) {\n event.dataTransfer!.dropEffect = \"none\";\n return;\n }\n isDragging.value = true;\n };\n const onDragoverCapture = (event: DragEvent) => {\n if (props.disabled || !isFileDrag(event)) return;\n event.preventDefault();\n if (!aui.thread.getState().capabilities.attachments) {\n event.dataTransfer!.dropEffect = \"none\";\n return;\n }\n if (!isDragging.value) isDragging.value = true;\n };\n const onDragleaveCapture = (event: DragEvent) => {\n if (props.disabled || !isFileDrag(event)) return;\n const related = event.relatedTarget as Node | null;\n if (related && (event.currentTarget as Node).contains(related)) return;\n isDragging.value = false;\n };\n const onDropCapture = (event: DragEvent) => {\n if (props.disabled) return;\n isDragging.value = false;\n if (!isFileDrag(event)) return;\n event.preventDefault();\n const files = Array.from(event.dataTransfer?.files ?? []);\n if (!aui.thread.getState().capabilities.attachments || files.length === 0)\n return;\n for (const file of files) {\n aui.composer.addAttachment(file).catch(() => {});\n }\n };\n\n return () =>\n h(\n \"div\",\n mergeProps(attrs, {\n ...(!props.disabled &&\n isDragging.value && { \"data-dragging\": \"true\" }),\n onDragenterCapture,\n onDragoverCapture,\n onDragleaveCapture,\n onDropCapture,\n }),\n slots.default?.(),\n );\n },\n});\n"],"mappings":";;;;;;;;;;;;AAoBA,MAAa,+BAA+B,gBAAgB;CAC1D,MAAM;CACN,OAAO;CACP,MAAM,GAAG,EAAE,SAAS;EAClB,MAAM,cAAc,aAAa,MAAM,EAAE,SAAS,WAAW;EAC7D,MAAM,iBAAiB,oBACrB,kBAAkB,YAAY,KAAK,CACrC;EACA,aACE,eAAe,MAAM,KAAK,KAAK,UAC7B,EACE,2BACA;GAAE,QAAQ;GAAY;GAAO;EAAI,GACjC,EAAE,eAAe,MAAM,UAAU,EAAE,CACrC,CACF;CACJ;AACF,CAAC;;;;;;AAOD,MAAa,iCAAiC,gBAAgB;CAC5D,MAAM;CACN,cAAc;CACd,OAAO,EACL,UAAU;EACR,MAAM;EACN,SAAS;CACX,EACF;CACA,OAAO;CACP,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,MAAM,OAAO;EACnB,MAAM,WAAW,aAAa,MAAM,CAAC,EAAE,SAAS,SAAS;EACzD,MAAM,WAAW,UAAsB;GACrC,IAAI,MAAM,oBAAoB,SAAS,SAAS,eAAe,KAAK,GAClE;GAEF,MAAM,QAAQ,SAAS,cAAc,OAAO;GAC5C,MAAM,OAAO;GACb,MAAM,WAAW,MAAM;GACvB,MAAM,SAAS;GAEf,MAAM,mBAAmB,IAAI,SAAS,SAAS,CAAC,CAAC;GACjD,IAAI,qBAAqB,KACvB,MAAM,SAAS;GAGjB,SAAS,KAAK,YAAY,KAAK;GAE/B,MAAM,YAAY,MAAM;IACtB,MAAM,WAAY,EAAE,OAA4B;IAChD,IAAI,UACF,KAAK,MAAM,QAAQ,MAAM,KAAK,QAAQ,GACpC,IAAI,SAAS,cAAc,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;IAGnD,MAAM,OAAO;GACf;GACA,MAAM,iBAAiB,MAAM,OAAO;GAEpC,MAAM,MAAM;EACd;EACA,aACE,EACE,UACA,WAAW,OAAO;GAChB,MAAM;GACN,UAAU,SAAS,SAAS,eAAe,KAAK;GAChD;EACF,CAAC,GACD,MAAM,UAAU,CAClB;CACJ;AACF,CAAC;;;;;;;AAQD,MAAa,sCAAsC,gBAAgB;CACjE,MAAM;CACN,cAAc;CACd,OAAO,EACL,UAAU;EACR,MAAM;EACN,SAAS;CACX,EACF;CACA,OAAO;CACP,MAAM,OAAO,EAAE,OAAO,SAAS;EAC7B,MAAM,MAAM,OAAO;EACnB,MAAM,aAAa,IAAI,KAAK;EAE5B,YACQ,MAAM,WACX,aAAa;GACZ,IAAI,UAAU,WAAW,QAAQ;EACnC,CACF;EAEA,MAAM,cAAc,UAClB,MAAM,cAAc,MAAM,SAAS,OAAO,MAAM;EAElD,MAAM,sBAAsB,UAAqB;GAC/C,IAAI,MAAM,YAAY,CAAC,WAAW,KAAK,GAAG;GAC1C,MAAM,eAAe;GACrB,IAAI,CAAC,IAAI,OAAO,SAAS,CAAC,CAAC,aAAa,aAAa;IACnD,MAAM,aAAc,aAAa;IACjC;GACF;GACA,WAAW,QAAQ;EACrB;EACA,MAAM,qBAAqB,UAAqB;GAC9C,IAAI,MAAM,YAAY,CAAC,WAAW,KAAK,GAAG;GAC1C,MAAM,eAAe;GACrB,IAAI,CAAC,IAAI,OAAO,SAAS,CAAC,CAAC,aAAa,aAAa;IACnD,MAAM,aAAc,aAAa;IACjC;GACF;GACA,IAAI,CAAC,WAAW,OAAO,WAAW,QAAQ;EAC5C;EACA,MAAM,sBAAsB,UAAqB;GAC/C,IAAI,MAAM,YAAY,CAAC,WAAW,KAAK,GAAG;GAC1C,MAAM,UAAU,MAAM;GACtB,IAAI,WAAY,MAAM,cAAuB,SAAS,OAAO,GAAG;GAChE,WAAW,QAAQ;EACrB;EACA,MAAM,iBAAiB,UAAqB;GAC1C,IAAI,MAAM,UAAU;GACpB,WAAW,QAAQ;GACnB,IAAI,CAAC,WAAW,KAAK,GAAG;GACxB,MAAM,eAAe;GACrB,MAAM,QAAQ,MAAM,KAAK,MAAM,cAAc,SAAS,CAAC,CAAC;GACxD,IAAI,CAAC,IAAI,OAAO,SAAS,CAAC,CAAC,aAAa,eAAe,MAAM,WAAW,GACtE;GACF,KAAK,MAAM,QAAQ,OACjB,IAAI,SAAS,cAAc,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;EAEnD;EAEA,aACE,EACE,OACA,WAAW,OAAO;GAChB,GAAI,CAAC,MAAM,YACT,WAAW,SAAS,EAAE,iBAAiB,OAAO;GAChD;GACA;GACA;GACA;EACF,CAAC,GACD,MAAM,UAAU,CAClB;CACJ;AACF,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /** A wrapper element for the current message's error state. */
3
+ export declare const ErrorPrimitiveRoot: 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
+ * Renders the current assistant message's error text (raw text, slot
10
+ * override supported); renders nothing while the message has no error.
11
+ */
12
+ export declare const ErrorPrimitiveMessage: import("vue").DefineComponent<{}, () => string | VNodeChild[] | null, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
13
+ default?: () => VNodeChild[];
14
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
15
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/primitives/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAIb,+DAA+D;AAC/D,eAAO,MAAM,kBAAkB;;;cAGU,MAAM,UAAU,EAAE;yEAKzD,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,qBAAqB;cAEO,MAAM,UAAU,EAAE;yEAQzD,CAAC"}