@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,128 @@
1
+ import { useAuiState } from "../useAuiState.js";
2
+ import { AuiProvider } from "../AuiProvider.js";
3
+ import { useAui } from "../useAui.js";
4
+ import { createLastValidCache as createLastValidCache$1, createStaleReporter } from "./lastValidCache.js";
5
+ import { isAttrDisabled } from "./attrDisabled.js";
6
+ import { ThreadListItemPrimitiveTrigger } from "./ThreadListItemPrimitiveTrigger.js";
7
+ import { computed, defineComponent, h, mergeProps, onScopeDispose } from "vue";
8
+ import { AuiConfig, Derived } from "@assistant-ui/store/client";
9
+ //#region src/primitives/threadList.ts
10
+ /**
11
+ * Scopes the subtree to the thread-list item at `index`: descendants read it
12
+ * through `s.threadListItem`.
13
+ */
14
+ const ThreadListItemByIndexProvider = defineComponent({
15
+ name: "ThreadListItemByIndexProvider",
16
+ props: {
17
+ index: {
18
+ type: Number,
19
+ required: true
20
+ },
21
+ archived: {
22
+ type: Boolean,
23
+ default: false
24
+ }
25
+ },
26
+ slots: Object,
27
+ setup(props, { slots }) {
28
+ const aui = useAui();
29
+ let disposed = false;
30
+ onScopeDispose(() => {
31
+ disposed = true;
32
+ });
33
+ const config = computed(() => {
34
+ const index = props.index;
35
+ const archived = props.archived;
36
+ const idsOf = (state) => archived ? state.archivedThreadIds : state.threadIds;
37
+ const cache = createLastValidCache$1(createStaleReporter({
38
+ name: "ThreadListItemByIndexProvider",
39
+ index,
40
+ isCurrent: () => !disposed && index === props.index && archived === props.archived,
41
+ isValid: () => index < idsOf(aui.threads.getState()).length
42
+ }));
43
+ return AuiConfig({ threadListItem: Derived({
44
+ source: "threads",
45
+ query: {
46
+ type: "index",
47
+ index,
48
+ archived
49
+ },
50
+ get: (aui) => cache.resolve(index < idsOf(aui.threads.getState()).length, () => aui.threads.item({
51
+ index,
52
+ archived
53
+ }))
54
+ }) });
55
+ });
56
+ return () => h(AuiProvider, {
57
+ config: config.value,
58
+ extends: aui
59
+ }, { default: () => slots.default?.() });
60
+ }
61
+ });
62
+ /**
63
+ * Renders the default slot once per thread in the list (or per archived
64
+ * thread with `archived`), each instance scoped through
65
+ * {@link ThreadListItemByIndexProvider}.
66
+ */
67
+ const ThreadListPrimitiveItems = defineComponent({
68
+ name: "ThreadListPrimitiveItems",
69
+ props: { archived: {
70
+ type: Boolean,
71
+ default: false
72
+ } },
73
+ slots: Object,
74
+ setup(props, { slots }) {
75
+ const threadIds = useAuiState((s) => props.archived ? s.threads.archivedThreadIds : s.threads.threadIds);
76
+ return () => threadIds.value.map((threadId, index) => h(ThreadListItemByIndexProvider, {
77
+ index,
78
+ archived: props.archived,
79
+ key: threadId
80
+ }, { default: () => slots.default?.() }));
81
+ }
82
+ });
83
+ /**
84
+ * A button that switches to a new thread. Carries `data-active` and
85
+ * `aria-current` while the new thread is the main one.
86
+ */
87
+ const ThreadListPrimitiveNew = defineComponent({
88
+ name: "ThreadListPrimitiveNew",
89
+ inheritAttrs: false,
90
+ slots: Object,
91
+ setup(_, { attrs, slots }) {
92
+ const aui = useAui();
93
+ const active = useAuiState((s) => s.threads.newThreadId === s.threads.mainThreadId);
94
+ const onClick = (event) => {
95
+ if (event.defaultPrevented || isAttrDisabled(attrs)) return;
96
+ aui.threads.switchToNewThread();
97
+ };
98
+ return () => h("button", mergeProps(attrs, {
99
+ type: "button",
100
+ disabled: isAttrDisabled(attrs),
101
+ ...active.value && {
102
+ "data-active": "true",
103
+ "aria-current": "true"
104
+ },
105
+ onClick
106
+ }), slots.default?.());
107
+ }
108
+ });
109
+ /**
110
+ * Renders the current thread-list item's title. When the title is empty,
111
+ * renders the default slot, or the `fallback` string.
112
+ */
113
+ const ThreadListItemPrimitiveTitle = defineComponent({
114
+ name: "ThreadListItemPrimitiveTitle",
115
+ props: { fallback: {
116
+ type: String,
117
+ default: ""
118
+ } },
119
+ slots: Object,
120
+ setup(props, { slots }) {
121
+ const title = useAuiState((s) => s.threadListItem.title);
122
+ return () => title.value || (slots.default ? slots.default() : props.fallback);
123
+ }
124
+ });
125
+ //#endregion
126
+ export { ThreadListItemByIndexProvider, ThreadListItemPrimitiveTitle, ThreadListItemPrimitiveTrigger, ThreadListPrimitiveItems, ThreadListPrimitiveNew };
127
+
128
+ //# sourceMappingURL=threadList.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threadList.js","names":["createLastValidCache"],"sources":["../../src/primitives/threadList.ts"],"sourcesContent":["import {\n computed,\n defineComponent,\n h,\n mergeProps,\n onScopeDispose,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport { AuiConfig, Derived } from \"@assistant-ui/store/client\";\nimport type { ThreadListItemMethods } from \"@assistant-ui/core/store\";\nimport { AuiProvider } from \"../AuiProvider\";\nimport { isAttrDisabled } from \"./attrDisabled\";\nimport { createLastValidCache, createStaleReporter } from \"./lastValidCache\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\nexport { ThreadListItemPrimitiveTrigger } from \"./ThreadListItemPrimitiveTrigger\";\n\n/**\n * Scopes the subtree to the thread-list item at `index`: descendants read it\n * through `s.threadListItem`.\n */\nexport const ThreadListItemByIndexProvider = defineComponent({\n name: \"ThreadListItemByIndexProvider\",\n props: {\n index: {\n type: Number,\n required: true,\n },\n archived: {\n type: Boolean,\n default: false,\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { slots }) {\n const aui = useAui();\n let disposed = false;\n onScopeDispose(() => {\n disposed = true;\n });\n const config = computed(() => {\n const index = props.index;\n const archived = props.archived;\n const idsOf = (state: {\n archivedThreadIds: readonly string[];\n threadIds: readonly string[];\n }) => (archived ? state.archivedThreadIds : state.threadIds);\n const cache = createLastValidCache<ThreadListItemMethods>(\n createStaleReporter({\n name: \"ThreadListItemByIndexProvider\",\n index,\n isCurrent: () =>\n !disposed && index === props.index && archived === props.archived,\n isValid: () => index < idsOf(aui.threads.getState()).length,\n }),\n );\n return AuiConfig({\n threadListItem: Derived({\n source: \"threads\",\n query: {\n type: \"index\",\n index,\n archived,\n },\n get: (aui) =>\n cache.resolve(index < idsOf(aui.threads.getState()).length, () =>\n aui.threads.item({ index, archived }),\n ),\n }),\n });\n });\n return () =>\n h(\n AuiProvider,\n { config: config.value, extends: aui },\n { default: () => slots.default?.() },\n );\n },\n});\n\n/**\n * Renders the default slot once per thread in the list (or per archived\n * thread with `archived`), each instance scoped through\n * {@link ThreadListItemByIndexProvider}.\n */\nexport const ThreadListPrimitiveItems = defineComponent({\n name: \"ThreadListPrimitiveItems\",\n props: {\n archived: {\n type: Boolean,\n default: false,\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { slots }) {\n const threadIds = useAuiState((s) =>\n props.archived ? s.threads.archivedThreadIds : s.threads.threadIds,\n );\n return () =>\n threadIds.value.map((threadId, index) =>\n h(\n ThreadListItemByIndexProvider,\n { index, archived: props.archived, key: threadId },\n { default: () => slots.default?.() },\n ),\n );\n },\n});\n\n/**\n * A button that switches to a new thread. Carries `data-active` and\n * `aria-current` while the new thread is the main one.\n */\nexport const ThreadListPrimitiveNew = defineComponent({\n name: \"ThreadListPrimitiveNew\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const aui = useAui();\n const active = useAuiState(\n (s) => s.threads.newThreadId === s.threads.mainThreadId,\n );\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || isAttrDisabled(attrs)) return;\n aui.threads.switchToNewThread();\n };\n return () =>\n h(\n \"button\",\n mergeProps(attrs, {\n type: \"button\",\n disabled: isAttrDisabled(attrs),\n ...(active.value && {\n \"data-active\": \"true\",\n \"aria-current\": \"true\",\n }),\n onClick,\n }),\n slots.default?.(),\n );\n },\n});\n\n/**\n * Renders the current thread-list item's title. When the title is empty,\n * renders the default slot, or the `fallback` string.\n */\nexport const ThreadListItemPrimitiveTitle = defineComponent({\n name: \"ThreadListItemPrimitiveTitle\",\n props: {\n fallback: {\n type: String,\n default: \"\",\n },\n },\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(props, { slots }) {\n const title = useAuiState((s) => s.threadListItem.title);\n return () =>\n title.value || (slots.default ? slots.default() : props.fallback);\n },\n});\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,gCAAgC,gBAAgB;CAC3D,MAAM;CACN,OAAO;EACL,OAAO;GACL,MAAM;GACN,UAAU;EACZ;EACA,UAAU;GACR,MAAM;GACN,SAAS;EACX;CACF;CACA,OAAO;CACP,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,MAAM,OAAO;EACnB,IAAI,WAAW;EACf,qBAAqB;GACnB,WAAW;EACb,CAAC;EACD,MAAM,SAAS,eAAe;GAC5B,MAAM,QAAQ,MAAM;GACpB,MAAM,WAAW,MAAM;GACvB,MAAM,SAAS,UAGR,WAAW,MAAM,oBAAoB,MAAM;GAClD,MAAM,QAAQA,uBACZ,oBAAoB;IAClB,MAAM;IACN;IACA,iBACE,CAAC,YAAY,UAAU,MAAM,SAAS,aAAa,MAAM;IAC3D,eAAe,QAAQ,MAAM,IAAI,QAAQ,SAAS,CAAC,CAAC,CAAC;GACvD,CAAC,CACH;GACA,OAAO,UAAU,EACf,gBAAgB,QAAQ;IACtB,QAAQ;IACR,OAAO;KACL,MAAM;KACN;KACA;IACF;IACA,MAAM,QACJ,MAAM,QAAQ,QAAQ,MAAM,IAAI,QAAQ,SAAS,CAAC,CAAC,CAAC,cAClD,IAAI,QAAQ,KAAK;KAAE;KAAO;IAAS,CAAC,CACtC;GACJ,CAAC,EACH,CAAC;EACH,CAAC;EACD,aACE,EACE,aACA;GAAE,QAAQ,OAAO;GAAO,SAAS;EAAI,GACrC,EAAE,eAAe,MAAM,UAAU,EAAE,CACrC;CACJ;AACF,CAAC;;;;;;AAOD,MAAa,2BAA2B,gBAAgB;CACtD,MAAM;CACN,OAAO,EACL,UAAU;EACR,MAAM;EACN,SAAS;CACX,EACF;CACA,OAAO;CACP,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,YAAY,aAAa,MAC7B,MAAM,WAAW,EAAE,QAAQ,oBAAoB,EAAE,QAAQ,SAC3D;EACA,aACE,UAAU,MAAM,KAAK,UAAU,UAC7B,EACE,+BACA;GAAE;GAAO,UAAU,MAAM;GAAU,KAAK;EAAS,GACjD,EAAE,eAAe,MAAM,UAAU,EAAE,CACrC,CACF;CACJ;AACF,CAAC;;;;;AAMD,MAAa,yBAAyB,gBAAgB;CACpD,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,MAAM,MAAM,OAAO;EACnB,MAAM,SAAS,aACZ,MAAM,EAAE,QAAQ,gBAAgB,EAAE,QAAQ,YAC7C;EACA,MAAM,WAAW,UAAsB;GACrC,IAAI,MAAM,oBAAoB,eAAe,KAAK,GAAG;GACrD,IAAI,QAAQ,kBAAkB;EAChC;EACA,aACE,EACE,UACA,WAAW,OAAO;GAChB,MAAM;GACN,UAAU,eAAe,KAAK;GAC9B,GAAI,OAAO,SAAS;IAClB,eAAe;IACf,gBAAgB;GAClB;GACA;EACF,CAAC,GACD,MAAM,UAAU,CAClB;CACJ;AACF,CAAC;;;;;AAMD,MAAa,+BAA+B,gBAAgB;CAC1D,MAAM;CACN,OAAO,EACL,UAAU;EACR,MAAM;EACN,SAAS;CACX,EACF;CACA,OAAO;CACP,MAAM,OAAO,EAAE,SAAS;EACtB,MAAM,QAAQ,aAAa,MAAM,EAAE,eAAe,KAAK;EACvD,aACE,MAAM,UAAU,MAAM,UAAU,MAAM,QAAQ,IAAI,MAAM;CAC5D;AACF,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type ShallowRef } from "vue";
2
+ type ThreadListCollection = {
3
+ registerTrigger: (key: symbol, trigger: HTMLButtonElement) => () => void;
4
+ getTriggers: () => HTMLButtonElement[];
5
+ };
6
+ type ThreadListItemFocus = {
7
+ trigger: ShallowRef<HTMLButtonElement | null>;
8
+ };
9
+ export declare const provideThreadListCollection: () => void;
10
+ export declare const useThreadListCollection: () => ThreadListCollection | null;
11
+ export declare const provideThreadListItemFocus: () => ThreadListItemFocus;
12
+ export declare const useThreadListItemFocus: () => ThreadListItemFocus | null;
13
+ export {};
14
+ //# sourceMappingURL=threadListFocusGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threadListFocusGroup.d.ts","sourceRoot":"","sources":["../../src/primitives/threadListFocusGroup.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAEb,KAAK,oBAAoB,GAAG;IAC1B,eAAe,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,KAAK,MAAM,IAAI,CAAC;IACzE,WAAW,EAAE,MAAM,iBAAiB,EAAE,CAAC;CACxC,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,OAAO,EAAE,UAAU,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;CAC/C,CAAC;AAUF,eAAO,MAAM,2BAA2B,YAkBvC,CAAC;AAEF,eAAO,MAAM,uBAAuB,mCACG,CAAC;AAExC,eAAO,MAAM,0BAA0B,QAAO,mBAI7C,CAAC;AAEF,eAAO,MAAM,sBAAsB,kCACG,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { inject, provide, shallowRef } from "vue";
2
+ //#region src/primitives/threadListFocusGroup.ts
3
+ const threadListCollectionKey = Symbol("assistant-ui.vue.thread-list-collection");
4
+ const threadListItemFocusKey = Symbol("assistant-ui.vue.thread-list-item-focus");
5
+ const provideThreadListCollection = () => {
6
+ const triggers = /* @__PURE__ */ new Map();
7
+ provide(threadListCollectionKey, {
8
+ registerTrigger: (key, trigger) => {
9
+ triggers.set(key, trigger);
10
+ return () => {
11
+ if (triggers.get(key) === trigger) triggers.delete(key);
12
+ };
13
+ },
14
+ getTriggers: () => [...triggers.values()].sort((first, second) => {
15
+ const position = first.compareDocumentPosition(second);
16
+ if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
17
+ if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;
18
+ return 0;
19
+ })
20
+ });
21
+ };
22
+ const useThreadListCollection = () => inject(threadListCollectionKey, null);
23
+ const provideThreadListItemFocus = () => {
24
+ const focus = { trigger: shallowRef(null) };
25
+ provide(threadListItemFocusKey, focus);
26
+ return focus;
27
+ };
28
+ const useThreadListItemFocus = () => inject(threadListItemFocusKey, null);
29
+ //#endregion
30
+ export { provideThreadListCollection, provideThreadListItemFocus, useThreadListCollection, useThreadListItemFocus };
31
+
32
+ //# sourceMappingURL=threadListFocusGroup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threadListFocusGroup.js","names":[],"sources":["../../src/primitives/threadListFocusGroup.ts"],"sourcesContent":["import {\n inject,\n provide,\n shallowRef,\n type InjectionKey,\n type ShallowRef,\n} from \"vue\";\n\ntype ThreadListCollection = {\n registerTrigger: (key: symbol, trigger: HTMLButtonElement) => () => void;\n getTriggers: () => HTMLButtonElement[];\n};\n\ntype ThreadListItemFocus = {\n trigger: ShallowRef<HTMLButtonElement | null>;\n};\n\nconst threadListCollectionKey: InjectionKey<ThreadListCollection> = Symbol(\n \"assistant-ui.vue.thread-list-collection\",\n);\n\nconst threadListItemFocusKey: InjectionKey<ThreadListItemFocus> = Symbol(\n \"assistant-ui.vue.thread-list-item-focus\",\n);\n\nexport const provideThreadListCollection = () => {\n const triggers = new Map<symbol, HTMLButtonElement>();\n const collection: ThreadListCollection = {\n registerTrigger: (key, trigger) => {\n triggers.set(key, trigger);\n return () => {\n if (triggers.get(key) === trigger) triggers.delete(key);\n };\n },\n getTriggers: () =>\n [...triggers.values()].sort((first, second) => {\n const position = first.compareDocumentPosition(second);\n if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;\n if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;\n return 0;\n }),\n };\n provide(threadListCollectionKey, collection);\n};\n\nexport const useThreadListCollection = () =>\n inject(threadListCollectionKey, null);\n\nexport const provideThreadListItemFocus = (): ThreadListItemFocus => {\n const focus = { trigger: shallowRef<HTMLButtonElement | null>(null) };\n provide(threadListItemFocusKey, focus);\n return focus;\n};\n\nexport const useThreadListItemFocus = () =>\n inject(threadListItemFocusKey, null);\n"],"mappings":";;AAiBA,MAAM,0BAA8D,OAClE,yCACF;AAEA,MAAM,yBAA4D,OAChE,yCACF;AAEA,MAAa,oCAAoC;CAC/C,MAAM,2BAAW,IAAI,IAA+B;CAgBpD,QAAQ,yBAAyB;EAd/B,kBAAkB,KAAK,YAAY;GACjC,SAAS,IAAI,KAAK,OAAO;GACzB,aAAa;IACX,IAAI,SAAS,IAAI,GAAG,MAAM,SAAS,SAAS,OAAO,GAAG;GACxD;EACF;EACA,mBACE,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,CAAC,MAAM,OAAO,WAAW;GAC7C,MAAM,WAAW,MAAM,wBAAwB,MAAM;GACrD,IAAI,WAAW,KAAK,6BAA6B,OAAO;GACxD,IAAI,WAAW,KAAK,6BAA6B,OAAO;GACxD,OAAO;EACT,CAAC;CAEqC,CAAC;AAC7C;AAEA,MAAa,gCACX,OAAO,yBAAyB,IAAI;AAEtC,MAAa,mCAAwD;CACnE,MAAM,QAAQ,EAAE,SAAS,WAAqC,IAAI,EAAE;CACpE,QAAQ,wBAAwB,KAAK;CACrC,OAAO;AACT;AAEA,MAAa,+BACX,OAAO,wBAAwB,IAAI"}
@@ -0,0 +1,29 @@
1
+ import { type SlotsType, type VNodeChild } from "vue";
2
+ /**
3
+ * A button that loads more threads. Stays mounted and disabled while no
4
+ * more threads are available or a load is in flight.
5
+ */
6
+ export declare const ThreadListPrimitiveLoadMore: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
7
+ [key: string]: any;
8
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
9
+ default?: () => VNodeChild[];
10
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
11
+ /** A button that archives the current thread list item. */
12
+ export declare const ThreadListItemPrimitiveArchive: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
13
+ [key: string]: any;
14
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
15
+ default?: () => VNodeChild[];
16
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
17
+ /** A button that unarchives the current thread list item. */
18
+ export declare const ThreadListItemPrimitiveUnarchive: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
19
+ [key: string]: any;
20
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
21
+ default?: () => VNodeChild[];
22
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
23
+ /** A button that deletes the current thread list item. */
24
+ export declare const ThreadListItemPrimitiveDelete: import("vue").DefineComponent<{}, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
25
+ [key: string]: any;
26
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, SlotsType<{
27
+ default?: () => VNodeChild[];
28
+ }>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
29
+ //# sourceMappingURL=threadListStructural.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threadListStructural.d.ts","sourceRoot":"","sources":["../../src/primitives/threadListStructural.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,KAAK,CAAC;AAOb;;;GAGG;AACH,eAAO,MAAM,2BAA2B;;;cAGC,MAAM,UAAU,EAAE;yEAoBzD,CAAC;AA6BH,2DAA2D;AAC3D,eAAO,MAAM,8BAA8B;;;cArBA,MAAM,UAAU,EAAE;yEAwB5D,CAAC;AAEF,6DAA6D;AAC7D,eAAO,MAAM,gCAAgC;;;cA3BF,MAAM,UAAU,EAAE;yEA8B5D,CAAC;AAEF,0DAA0D;AAC1D,eAAO,MAAM,6BAA6B;;;cAjCC,MAAM,UAAU,EAAE;yEAoC5D,CAAC"}
@@ -0,0 +1,55 @@
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 { threadListLoadMoreDisabled } from "@assistant-ui/core/store/internal";
6
+ //#region src/primitives/threadListStructural.ts
7
+ /**
8
+ * A button that loads more threads. Stays mounted and disabled while no
9
+ * more threads are available or a load is in flight.
10
+ */
11
+ const ThreadListPrimitiveLoadMore = defineComponent({
12
+ name: "ThreadListPrimitiveLoadMore",
13
+ inheritAttrs: false,
14
+ slots: Object,
15
+ setup(_, { attrs, slots }) {
16
+ const aui = useAui();
17
+ const disabled = useAuiState(threadListLoadMoreDisabled);
18
+ const onClick = (event) => {
19
+ if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs)) return;
20
+ aui.threads.loadMore();
21
+ };
22
+ return () => h("button", mergeProps(attrs, {
23
+ type: "button",
24
+ disabled: disabled.value || isAttrDisabled(attrs),
25
+ onClick
26
+ }), slots.default?.());
27
+ }
28
+ });
29
+ const threadListItemAction = (name, action) => defineComponent({
30
+ name,
31
+ inheritAttrs: false,
32
+ slots: Object,
33
+ setup(_, { attrs, slots }) {
34
+ const aui = useAui();
35
+ const onClick = (event) => {
36
+ if (event.defaultPrevented || isAttrDisabled(attrs)) return;
37
+ action(aui);
38
+ };
39
+ return () => h("button", mergeProps(attrs, {
40
+ type: "button",
41
+ disabled: isAttrDisabled(attrs),
42
+ onClick
43
+ }), slots.default?.());
44
+ }
45
+ });
46
+ /** A button that archives the current thread list item. */
47
+ const ThreadListItemPrimitiveArchive = threadListItemAction("ThreadListItemPrimitiveArchive", (aui) => aui.threadListItem.archive());
48
+ /** A button that unarchives the current thread list item. */
49
+ const ThreadListItemPrimitiveUnarchive = threadListItemAction("ThreadListItemPrimitiveUnarchive", (aui) => aui.threadListItem.unarchive());
50
+ /** A button that deletes the current thread list item. */
51
+ const ThreadListItemPrimitiveDelete = threadListItemAction("ThreadListItemPrimitiveDelete", (aui) => aui.threadListItem.delete());
52
+ //#endregion
53
+ export { ThreadListItemPrimitiveArchive, ThreadListItemPrimitiveDelete, ThreadListItemPrimitiveUnarchive, ThreadListPrimitiveLoadMore };
54
+
55
+ //# sourceMappingURL=threadListStructural.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"threadListStructural.js","names":[],"sources":["../../src/primitives/threadListStructural.ts"],"sourcesContent":["import {\n defineComponent,\n h,\n mergeProps,\n type SlotsType,\n type VNodeChild,\n} from \"vue\";\nimport type { AssistantClient } from \"@assistant-ui/store/client\";\nimport { threadListLoadMoreDisabled } from \"@assistant-ui/core/store/internal\";\nimport { isAttrDisabled } from \"./attrDisabled\";\nimport { useAui } from \"../useAui\";\nimport { useAuiState } from \"../useAuiState\";\n\n/**\n * A button that loads more threads. Stays mounted and disabled while no\n * more threads are available or a load is in flight.\n */\nexport const ThreadListPrimitiveLoadMore = defineComponent({\n name: \"ThreadListPrimitiveLoadMore\",\n inheritAttrs: false,\n slots: Object as SlotsType<{ default?: () => VNodeChild[] }>,\n setup(_, { attrs, slots }) {\n const aui = useAui();\n const disabled = useAuiState(threadListLoadMoreDisabled);\n const onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || disabled.value || isAttrDisabled(attrs))\n return;\n void aui.threads.loadMore();\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 threadListItemAction = (\n name: string,\n action: (aui: AssistantClient) => void,\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 onClick = (event: MouseEvent) => {\n if (event.defaultPrevented || isAttrDisabled(attrs)) return;\n action(aui);\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\n/** A button that archives the current thread list item. */\nexport const ThreadListItemPrimitiveArchive = threadListItemAction(\n \"ThreadListItemPrimitiveArchive\",\n (aui) => aui.threadListItem.archive(),\n);\n\n/** A button that unarchives the current thread list item. */\nexport const ThreadListItemPrimitiveUnarchive = threadListItemAction(\n \"ThreadListItemPrimitiveUnarchive\",\n (aui) => aui.threadListItem.unarchive(),\n);\n\n/** A button that deletes the current thread list item. */\nexport const ThreadListItemPrimitiveDelete = threadListItemAction(\n \"ThreadListItemPrimitiveDelete\",\n (aui) => aui.threadListItem.delete(),\n);\n"],"mappings":";;;;;;;;;;AAiBA,MAAa,8BAA8B,gBAAgB;CACzD,MAAM;CACN,cAAc;CACd,OAAO;CACP,MAAM,GAAG,EAAE,OAAO,SAAS;EACzB,MAAM,MAAM,OAAO;EACnB,MAAM,WAAW,YAAY,0BAA0B;EACvD,MAAM,WAAW,UAAsB;GACrC,IAAI,MAAM,oBAAoB,SAAS,SAAS,eAAe,KAAK,GAClE;GACF,IAAS,QAAQ,SAAS;EAC5B;EACA,aACE,EACE,UACA,WAAW,OAAO;GAChB,MAAM;GACN,UAAU,SAAS,SAAS,eAAe,KAAK;GAChD;EACF,CAAC,GACD,MAAM,UAAU,CAClB;CACJ;AACF,CAAC;AAED,MAAM,wBACJ,MACA,WAEA,gBAAgB;CACd;CACA,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,OAAO,GAAG;EACZ;EACA,aACE,EACE,UACA,WAAW,OAAO;GAChB,MAAM;GACN,UAAU,eAAe,KAAK;GAC9B;EACF,CAAC,GACD,MAAM,UAAU,CAClB;CACJ;AACF,CAAC;;AAGH,MAAa,iCAAiC,qBAC5C,mCACC,QAAQ,IAAI,eAAe,QAAQ,CACtC;;AAGA,MAAa,mCAAmC,qBAC9C,qCACC,QAAQ,IAAI,eAAe,UAAU,CACxC;;AAGA,MAAa,gCAAgC,qBAC3C,kCACC,QAAQ,IAAI,eAAe,OAAO,CACrC"}
@@ -0,0 +1,6 @@
1
+ import type { ComputedRef } from "vue";
2
+ export declare const useComposerSendState: () => {
3
+ disabled: ComputedRef<boolean>;
4
+ send: () => void;
5
+ };
6
+ //# sourceMappingURL=useComposerSendState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComposerSendState.d.ts","sourceRoot":"","sources":["../../src/primitives/useComposerSendState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAKvC,eAAO,MAAM,oBAAoB,QAAO;IACtC,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/B,IAAI,EAAE,MAAM,IAAI,CAAC;CAKlB,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { useAuiState } from "../useAuiState.js";
2
+ import { useAui } from "../useAui.js";
3
+ import { composerSendDisabled } from "@assistant-ui/core/store/internal";
4
+ //#region src/primitives/useComposerSendState.ts
5
+ const useComposerSendState = () => {
6
+ const aui = useAui();
7
+ return {
8
+ disabled: useAuiState(composerSendDisabled),
9
+ send: () => aui.composer.send()
10
+ };
11
+ };
12
+ //#endregion
13
+ export { useComposerSendState };
14
+
15
+ //# sourceMappingURL=useComposerSendState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useComposerSendState.js","names":[],"sources":["../../src/primitives/useComposerSendState.ts"],"sourcesContent":["import type { ComputedRef } from \"vue\";\nimport { useAui } from \"../useAui\";\nimport { composerSendDisabled } from \"@assistant-ui/core/store/internal\";\nimport { useAuiState } from \"../useAuiState\";\n\nexport const useComposerSendState = (): {\n disabled: ComputedRef<boolean>;\n send: () => void;\n} => {\n const aui = useAui();\n const disabled = useAuiState(composerSendDisabled);\n return { disabled, send: () => aui.composer.send() };\n};\n"],"mappings":";;;;AAKA,MAAa,6BAGR;CACH,MAAM,MAAM,OAAO;CAEnB,OAAO;EAAE,UADQ,YAAY,oBACb;EAAG,YAAY,IAAI,SAAS,KAAK;CAAE;AACrD"}
@@ -0,0 +1,12 @@
1
+ import type { InjectionKey, ShallowRef } from "vue";
2
+ export type ViewportContentInsetHandle = {
3
+ setHeight: (height: number) => void;
4
+ unregister: () => void;
5
+ };
6
+ export type ViewportContext = {
7
+ isAtBottom: ShallowRef<boolean>;
8
+ scrollToBottom: (behavior?: ScrollBehavior) => void;
9
+ registerContentInset: () => ViewportContentInsetHandle;
10
+ };
11
+ export declare const viewportInjectionKey: InjectionKey<ViewportContext>;
12
+ //# sourceMappingURL=viewportContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewportContext.d.ts","sourceRoot":"","sources":["../../src/primitives/viewportContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEpD,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,UAAU,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IAChC,cAAc,EAAE,CAAC,QAAQ,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IACpD,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;CACxD,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,YAAY,CAAC,eAAe,CAE9D,CAAC"}
@@ -0,0 +1,6 @@
1
+ //#region src/primitives/viewportContext.ts
2
+ const viewportInjectionKey = Symbol("assistant-ui.vue.viewport");
3
+ //#endregion
4
+ export { viewportInjectionKey };
5
+
6
+ //# sourceMappingURL=viewportContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewportContext.js","names":[],"sources":["../../src/primitives/viewportContext.ts"],"sourcesContent":["import type { InjectionKey, ShallowRef } from \"vue\";\n\nexport type ViewportContentInsetHandle = {\n setHeight: (height: number) => void;\n unregister: () => void;\n};\n\nexport type ViewportContext = {\n isAtBottom: ShallowRef<boolean>;\n scrollToBottom: (behavior?: ScrollBehavior) => void;\n registerContentInset: () => ViewportContentInsetHandle;\n};\n\nexport const viewportInjectionKey: InjectionKey<ViewportContext> = Symbol(\n \"assistant-ui.vue.viewport\",\n);\n"],"mappings":";AAaA,MAAa,uBAAsD,OACjE,2BACF"}
@@ -0,0 +1,15 @@
1
+ import type { AssistantClient } from "@assistant-ui/store/client";
2
+ /**
3
+ * Returns the `AssistantClient` provided by the nearest {@link AuiProvider}.
4
+ *
5
+ * The returned object is stable for the lifetime of the provider and always
6
+ * forwards to the provider's current client, so it can be captured once and
7
+ * used in event handlers: `aui.composer.send()`, `aui.thread.cancelRun()`.
8
+ * Pair with {@link useAuiState} to read reactive state and
9
+ * {@link useAuiEvent} to subscribe to events.
10
+ *
11
+ * Called outside a provider, the returned client's scope accessors throw a
12
+ * descriptive error whenever they are used.
13
+ */
14
+ export declare const useAui: () => AssistantClient;
15
+ //# sourceMappingURL=useAui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAui.d.ts","sourceRoot":"","sources":["../src/useAui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,MAAM,QAAO,eAEzB,CAAC"}
package/dist/useAui.js ADDED
@@ -0,0 +1,21 @@
1
+ import { useAuiContext } from "./context.js";
2
+ //#region src/useAui.ts
3
+ /**
4
+ * Returns the `AssistantClient` provided by the nearest {@link AuiProvider}.
5
+ *
6
+ * The returned object is stable for the lifetime of the provider and always
7
+ * forwards to the provider's current client, so it can be captured once and
8
+ * used in event handlers: `aui.composer.send()`, `aui.thread.cancelRun()`.
9
+ * Pair with {@link useAuiState} to read reactive state and
10
+ * {@link useAuiEvent} to subscribe to events.
11
+ *
12
+ * Called outside a provider, the returned client's scope accessors throw a
13
+ * descriptive error whenever they are used.
14
+ */
15
+ const useAui = () => {
16
+ return useAuiContext().aui;
17
+ };
18
+ //#endregion
19
+ export { useAui };
20
+
21
+ //# sourceMappingURL=useAui.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAui.js","names":[],"sources":["../src/useAui.ts"],"sourcesContent":["import type { AssistantClient } from \"@assistant-ui/store/client\";\nimport { useAuiContext } from \"./context\";\n\n/**\n * Returns the `AssistantClient` provided by the nearest {@link AuiProvider}.\n *\n * The returned object is stable for the lifetime of the provider and always\n * forwards to the provider's current client, so it can be captured once and\n * used in event handlers: `aui.composer.send()`, `aui.thread.cancelRun()`.\n * Pair with {@link useAuiState} to read reactive state and\n * {@link useAuiEvent} to subscribe to events.\n *\n * Called outside a provider, the returned client's scope accessors throw a\n * descriptive error whenever they are used.\n */\nexport const useAui = (): AssistantClient => {\n return useAuiContext().aui;\n};\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAa,eAAgC;CAC3C,OAAO,cAAc,CAAC,CAAC;AACzB"}
@@ -0,0 +1,17 @@
1
+ import { type AssistantEventCallback, type AssistantEventName, type AssistantEventSelector } from "@assistant-ui/store/client";
2
+ /**
3
+ * Subscribes to an assistant event for the lifetime of the current effect
4
+ * scope.
5
+ *
6
+ * The subscription follows the provider's current client across structural
7
+ * changes. Use `scope: "*"` to receive emissions from any descendant scope.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * useAuiEvent("thread.modelContextUpdate", ({ threadId }) => {
12
+ * analytics.track("model_context_update", { threadId });
13
+ * });
14
+ * ```
15
+ */
16
+ export declare const useAuiEvent: <TEvent extends AssistantEventName>(selector: AssistantEventSelector<TEvent>, callback: AssistantEventCallback<TEvent>) => void;
17
+ //# sourceMappingURL=useAuiEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuiEvent.d.ts","sourceRoot":"","sources":["../src/useAuiEvent.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAE5B,MAAM,4BAA4B,CAAC;AAGpC;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GAAI,MAAM,SAAS,kBAAkB,EAC3D,UAAU,sBAAsB,CAAC,MAAM,CAAC,EACxC,UAAU,sBAAsB,CAAC,MAAM,CAAC,KACvC,IAkCF,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { useAuiContext } from "./context.js";
2
+ import { onScopeDispose } from "vue";
3
+ import { normalizeEventSelector } from "@assistant-ui/store/client";
4
+ import { isDevelopment } from "@assistant-ui/core/store/internal";
5
+ //#region src/useAuiEvent.ts
6
+ /**
7
+ * Subscribes to an assistant event for the lifetime of the current effect
8
+ * scope.
9
+ *
10
+ * The subscription follows the provider's current client across structural
11
+ * changes. Use `scope: "*"` to receive emissions from any descendant scope.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * useAuiEvent("thread.modelContextUpdate", ({ threadId }) => {
16
+ * analytics.track("model_context_update", { threadId });
17
+ * });
18
+ * ```
19
+ */
20
+ const useAuiEvent = (selector, callback) => {
21
+ const { source } = useAuiContext();
22
+ const { scope, event } = normalizeEventSelector(selector);
23
+ let bound;
24
+ let off;
25
+ const bind = () => {
26
+ const client = source.getClient();
27
+ if (client === bound) return;
28
+ let next;
29
+ try {
30
+ next = client.on({
31
+ scope,
32
+ event
33
+ }, callback);
34
+ } catch (error) {
35
+ if (isDevelopment) console.warn(error);
36
+ return;
37
+ }
38
+ off?.();
39
+ bound = client;
40
+ off = next;
41
+ };
42
+ bind();
43
+ const unsubscribe = source.subscribe(bind);
44
+ onScopeDispose(() => {
45
+ unsubscribe();
46
+ off?.();
47
+ });
48
+ };
49
+ //#endregion
50
+ export { useAuiEvent };
51
+
52
+ //# sourceMappingURL=useAuiEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuiEvent.js","names":[],"sources":["../src/useAuiEvent.ts"],"sourcesContent":["import { onScopeDispose } from \"vue\";\nimport { isDevelopment } from \"@assistant-ui/core/store/internal\";\nimport {\n normalizeEventSelector,\n type AssistantClient,\n type AssistantEventCallback,\n type AssistantEventName,\n type AssistantEventSelector,\n type Unsubscribe,\n} from \"@assistant-ui/store/client\";\nimport { useAuiContext } from \"./context\";\n\n/**\n * Subscribes to an assistant event for the lifetime of the current effect\n * scope.\n *\n * The subscription follows the provider's current client across structural\n * changes. Use `scope: \"*\"` to receive emissions from any descendant scope.\n *\n * @example\n * ```ts\n * useAuiEvent(\"thread.modelContextUpdate\", ({ threadId }) => {\n * analytics.track(\"model_context_update\", { threadId });\n * });\n * ```\n */\nexport const useAuiEvent = <TEvent extends AssistantEventName>(\n selector: AssistantEventSelector<TEvent>,\n callback: AssistantEventCallback<TEvent>,\n): void => {\n const { source } = useAuiContext();\n const { scope, event } = normalizeEventSelector(selector);\n\n let bound: AssistantClient | undefined;\n let off: Unsubscribe | undefined;\n\n const bind = () => {\n const client = source.getClient();\n if (client === bound) return;\n let next: Unsubscribe;\n try {\n next = client.on(\n { scope, event } as AssistantEventSelector<TEvent>,\n callback,\n );\n } catch (error) {\n // A live config may drop the selected scope; keep the current binding and\n // retry once a later structural change makes the scope available again. A\n // selector that never resolves (a typo'd scope) surfaces here in dev.\n if (isDevelopment) console.warn(error);\n return;\n }\n off?.();\n bound = client;\n off = next;\n };\n\n bind();\n const unsubscribe = source.subscribe(bind);\n onScopeDispose(() => {\n unsubscribe();\n off?.();\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,MAAa,eACX,UACA,aACS;CACT,MAAM,EAAE,WAAW,cAAc;CACjC,MAAM,EAAE,OAAO,UAAU,uBAAuB,QAAQ;CAExD,IAAI;CACJ,IAAI;CAEJ,MAAM,aAAa;EACjB,MAAM,SAAS,OAAO,UAAU;EAChC,IAAI,WAAW,OAAO;EACtB,IAAI;EACJ,IAAI;GACF,OAAO,OAAO,GACZ;IAAE;IAAO;GAAM,GACf,QACF;EACF,SAAS,OAAO;GAId,IAAI,eAAe,QAAQ,KAAK,KAAK;GACrC;EACF;EACA,MAAM;EACN,QAAQ;EACR,MAAM;CACR;CAEA,KAAK;CACL,MAAM,cAAc,OAAO,UAAU,IAAI;CACzC,qBAAqB;EACnB,YAAY;EACZ,MAAM;CACR,CAAC;AACH"}
@@ -0,0 +1,23 @@
1
+ import { type ComputedRef } from "vue";
2
+ import { type AssistantState } from "@assistant-ui/store/client";
3
+ /**
4
+ * Subscribes to a slice of `AssistantState` and returns it as a computed ref.
5
+ *
6
+ * The `selector` runs on every store update; dependents re-run only when the
7
+ * selected slice changes by `Object.is`. Returning the entire state object is
8
+ * not supported and throws — select a specific field instead, or compose
9
+ * multiple `useAuiState` calls. Returning a fresh object or array literal
10
+ * re-triggers dependents on every update; select primitives or a memoized
11
+ * reference.
12
+ *
13
+ * Scopes that may be unavailable can be read via `s.optional.<scope>`, which
14
+ * resolves to `undefined` instead of throwing.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const isRunning = useAuiState((s) => s.thread.isRunning);
19
+ * // template: <button :disabled="isRunning">…</button>
20
+ * ```
21
+ */
22
+ export declare const useAuiState: <T>(selector: (state: AssistantState) => T) => ComputedRef<T>;
23
+ //# sourceMappingURL=useAuiState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuiState.d.ts","sourceRoot":"","sources":["../src/useAuiState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAC7E,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,4BAA4B,CAAC;AAGpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAC3B,UAAU,CAAC,KAAK,EAAE,cAAc,KAAK,CAAC,KACrC,WAAW,CAAC,CAAC,CA0Bf,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { useAuiContext } from "./context.js";
2
+ import { computed, onScopeDispose, shallowRef } from "vue";
3
+ import { getProxiedAssistantState } from "@assistant-ui/store/client";
4
+ //#region src/useAuiState.ts
5
+ /**
6
+ * Subscribes to a slice of `AssistantState` and returns it as a computed ref.
7
+ *
8
+ * The `selector` runs on every store update; dependents re-run only when the
9
+ * selected slice changes by `Object.is`. Returning the entire state object is
10
+ * not supported and throws — select a specific field instead, or compose
11
+ * multiple `useAuiState` calls. Returning a fresh object or array literal
12
+ * re-triggers dependents on every update; select primitives or a memoized
13
+ * reference.
14
+ *
15
+ * Scopes that may be unavailable can be read via `s.optional.<scope>`, which
16
+ * resolves to `undefined` instead of throwing.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const isRunning = useAuiState((s) => s.thread.isRunning);
21
+ * // template: <button :disabled="isRunning">…</button>
22
+ * ```
23
+ */
24
+ const useAuiState = (selector) => {
25
+ const { source } = useAuiContext();
26
+ const version = shallowRef(0);
27
+ const unsubscribe = source.subscribe(() => {
28
+ version.value++;
29
+ });
30
+ onScopeDispose(unsubscribe);
31
+ return computed(() => {
32
+ version.value;
33
+ const state = getProxiedAssistantState(source.getClient());
34
+ const slice = selector(state);
35
+ if (typeof slice === "object" && slice !== null && (slice === state || slice === state.optional)) throw new Error("You tried to return the entire AssistantState. This is not supported due to technical limitations.");
36
+ return slice;
37
+ });
38
+ };
39
+ //#endregion
40
+ export { useAuiState };
41
+
42
+ //# sourceMappingURL=useAuiState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuiState.js","names":[],"sources":["../src/useAuiState.ts"],"sourcesContent":["import { computed, onScopeDispose, shallowRef, type ComputedRef } from \"vue\";\nimport {\n getProxiedAssistantState,\n type AssistantState,\n} from \"@assistant-ui/store/client\";\nimport { useAuiContext } from \"./context\";\n\n/**\n * Subscribes to a slice of `AssistantState` and returns it as a computed ref.\n *\n * The `selector` runs on every store update; dependents re-run only when the\n * selected slice changes by `Object.is`. Returning the entire state object is\n * not supported and throws — select a specific field instead, or compose\n * multiple `useAuiState` calls. Returning a fresh object or array literal\n * re-triggers dependents on every update; select primitives or a memoized\n * reference.\n *\n * Scopes that may be unavailable can be read via `s.optional.<scope>`, which\n * resolves to `undefined` instead of throwing.\n *\n * @example\n * ```ts\n * const isRunning = useAuiState((s) => s.thread.isRunning);\n * // template: <button :disabled=\"isRunning\">…</button>\n * ```\n */\nexport const useAuiState = <T>(\n selector: (state: AssistantState) => T,\n): ComputedRef<T> => {\n const { source } = useAuiContext();\n\n const version = shallowRef(0);\n const unsubscribe = source.subscribe(() => {\n version.value++;\n });\n onScopeDispose(unsubscribe);\n\n return computed(() => {\n void version.value;\n const state = getProxiedAssistantState(source.getClient());\n const slice = selector(state);\n\n if (\n typeof slice === \"object\" &&\n slice !== null &&\n ((slice as unknown) === state || (slice as unknown) === state.optional)\n ) {\n throw new Error(\n \"You tried to return the entire AssistantState. This is not supported due to technical limitations.\",\n );\n }\n\n return slice;\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,eACX,aACmB;CACnB,MAAM,EAAE,WAAW,cAAc;CAEjC,MAAM,UAAU,WAAW,CAAC;CAC5B,MAAM,cAAc,OAAO,gBAAgB;EACzC,QAAQ;CACV,CAAC;CACD,eAAe,WAAW;CAE1B,OAAO,eAAe;EACpB,QAAa;EACb,MAAM,QAAQ,yBAAyB,OAAO,UAAU,CAAC;EACzD,MAAM,QAAQ,SAAS,KAAK;EAE5B,IACE,OAAO,UAAU,YACjB,UAAU,SACR,UAAsB,SAAU,UAAsB,MAAM,WAE9D,MAAM,IAAI,MACR,oGACF;EAGF,OAAO;CACT,CAAC;AACH"}
@@ -0,0 +1,3 @@
1
+ import { type Ref } from "vue";
2
+ export declare const useScrollLock: (target: Ref<HTMLElement | null | undefined>, animationDuration: number) => () => void;
3
+ //# sourceMappingURL=useScrollLock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollLock.d.ts","sourceRoot":"","sources":["../src/useScrollLock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,GAAG,EAAE,MAAM,KAAK,CAAC;AAY/C,eAAO,MAAM,aAAa,GACxB,QAAQ,GAAG,CAAC,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC,EAC3C,mBAAmB,MAAM,eAgE1B,CAAC"}