@assistant-ui/react-native 0.1.37 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/primitives/actionBar/ActionBarCopy.js +1 -0
- package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.d.ts +2 -3
- package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarEdit.js +1 -0
- package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +1 -0
- package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +1 -0
- package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.d.ts +2 -3
- package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarReload.js +1 -0
- package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.d.ts +2 -3
- package/dist/primitives/attachment/AttachmentRemove.d.ts.map +1 -1
- package/dist/primitives/attachment/AttachmentRemove.js +1 -0
- package/dist/primitives/attachment/AttachmentRemove.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts +2 -3
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js +1 -0
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts +2 -3
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js +1 -0
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts +2 -3
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts.map +1 -1
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +1 -0
- package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.d.ts +2 -3
- package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +1 -0
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/primitives/composer/ComposerCancel.d.ts +2 -3
- package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerCancel.js +1 -0
- package/dist/primitives/composer/ComposerCancel.js.map +1 -1
- package/dist/primitives/composer/ComposerQueue.d.ts +2 -0
- package/dist/primitives/composer/ComposerQueue.js +2 -0
- package/dist/primitives/composer/ComposerQuote.d.ts +10 -0
- package/dist/primitives/composer/ComposerQuote.d.ts.map +1 -0
- package/dist/primitives/composer/ComposerQuote.js +38 -0
- package/dist/primitives/composer/ComposerQuote.js.map +1 -0
- package/dist/primitives/composer/ComposerQuoteDismiss.d.ts +9 -0
- package/dist/primitives/composer/ComposerQuoteDismiss.d.ts.map +1 -0
- package/dist/primitives/composer/ComposerQuoteDismiss.js +48 -0
- package/dist/primitives/composer/ComposerQuoteDismiss.js.map +1 -0
- package/dist/primitives/composer/ComposerQuoteText.d.ts +10 -0
- package/dist/primitives/composer/ComposerQuoteText.d.ts.map +1 -0
- package/dist/primitives/composer/ComposerQuoteText.js +40 -0
- package/dist/primitives/composer/ComposerQuoteText.js.map +1 -0
- package/dist/primitives/composer/ComposerSend.d.ts +2 -3
- package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerSend.js +1 -0
- package/dist/primitives/composer/ComposerSend.js.map +1 -1
- package/dist/primitives/composer.d.ts +6 -2
- package/dist/primitives/composer.js +9 -1
- package/dist/primitives/composer.js.map +1 -1
- package/dist/primitives/message/MessageIf.d.ts +3 -0
- package/dist/primitives/message/MessageIf.d.ts.map +1 -1
- package/dist/primitives/message/MessageIf.js +3 -0
- package/dist/primitives/message/MessageIf.js.map +1 -1
- package/dist/primitives/queueItem/QueueItemRemove.d.ts +9 -0
- package/dist/primitives/queueItem/QueueItemRemove.d.ts.map +1 -0
- package/dist/primitives/queueItem/QueueItemRemove.js +48 -0
- package/dist/primitives/queueItem/QueueItemRemove.js.map +1 -0
- package/dist/primitives/queueItem/QueueItemSteer.d.ts +9 -0
- package/dist/primitives/queueItem/QueueItemSteer.d.ts.map +1 -0
- package/dist/primitives/queueItem/QueueItemSteer.js +48 -0
- package/dist/primitives/queueItem/QueueItemSteer.js.map +1 -0
- package/dist/primitives/queueItem/QueueItemText.d.ts +10 -0
- package/dist/primitives/queueItem/QueueItemText.d.ts.map +1 -0
- package/dist/primitives/queueItem/QueueItemText.js +45 -0
- package/dist/primitives/queueItem/QueueItemText.js.map +1 -0
- package/dist/primitives/queueItem.d.ts +9 -0
- package/dist/primitives/queueItem.d.ts.map +1 -0
- package/dist/primitives/queueItem.js +14 -0
- package/dist/primitives/queueItem.js.map +1 -0
- package/dist/primitives/suggestion/SuggestionTrigger.d.ts +2 -3
- package/dist/primitives/suggestion/SuggestionTrigger.d.ts.map +1 -1
- package/dist/primitives/suggestion/SuggestionTrigger.js +1 -0
- package/dist/primitives/suggestion/SuggestionTrigger.js.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.d.ts +4 -1
- package/dist/primitives/thread/ThreadEmpty.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadEmpty.js +12 -4
- package/dist/primitives/thread/ThreadEmpty.js.map +1 -1
- package/dist/primitives/thread/ThreadIf.d.ts +3 -0
- package/dist/primitives/thread/ThreadIf.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadIf.js +5 -6
- package/dist/primitives/thread/ThreadIf.js.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.d.ts +2 -3
- package/dist/primitives/thread/ThreadSuggestion.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadSuggestion.js +1 -0
- package/dist/primitives/thread/ThreadSuggestion.js.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.d.ts +6 -4
- package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListNew.js +46 -15
- package/dist/primitives/threadList/ThreadListNew.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts +2 -3
- package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemArchive.js +1 -0
- package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts +2 -3
- package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemDelete.js +1 -0
- package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts +6 -4
- package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js +46 -15
- package/dist/primitives/threadListItem/ThreadListItemTrigger.js.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts +2 -3
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -1
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +1 -0
- package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -1
- package/package.json +5 -5
- package/src/index.ts +2 -0
- package/src/primitives/accessibilityRole.test.tsx +335 -0
- package/src/primitives/actionBar/ActionBarCopy.tsx +1 -0
- package/src/primitives/actionBar/ActionBarEdit.tsx +6 -3
- package/src/primitives/actionBar/ActionBarFeedbackNegative.tsx +1 -1
- package/src/primitives/actionBar/ActionBarFeedbackPositive.tsx +1 -1
- package/src/primitives/actionBar/ActionBarReload.tsx +6 -3
- package/src/primitives/attachment/AttachmentRemove.tsx +11 -4
- package/src/primitives/branchPicker/BranchPickerNext.tsx +6 -3
- package/src/primitives/branchPicker/BranchPickerPrevious.tsx +6 -3
- package/src/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.tsx +4 -4
- package/src/primitives/composer/ComposerAddAttachment.tsx +10 -4
- package/src/primitives/composer/ComposerCancel.tsx +6 -3
- package/src/primitives/composer/ComposerQueue.test.tsx +9 -0
- package/src/primitives/composer/ComposerQueue.tsx +1 -0
- package/src/primitives/composer/ComposerQuote.test.tsx +163 -0
- package/src/primitives/composer/ComposerQuote.tsx +17 -0
- package/src/primitives/composer/ComposerQuoteDismiss.tsx +31 -0
- package/src/primitives/composer/ComposerQuoteText.tsx +17 -0
- package/src/primitives/composer/ComposerSend.test.tsx +26 -0
- package/src/primitives/composer/ComposerSend.tsx +3 -3
- package/src/primitives/composer.ts +13 -0
- package/src/primitives/message/MessageIf.tsx +3 -0
- package/src/primitives/queueItem/QueueItem.test.tsx +132 -0
- package/src/primitives/queueItem/QueueItemRemove.tsx +31 -0
- package/src/primitives/queueItem/QueueItemSteer.tsx +31 -0
- package/src/primitives/queueItem/QueueItemText.tsx +22 -0
- package/src/primitives/queueItem.ts +12 -0
- package/src/primitives/suggestion/SuggestionTrigger.tsx +6 -3
- package/src/primitives/thread/ThreadEmpty.test.tsx +17 -3
- package/src/primitives/thread/ThreadEmpty.tsx +7 -6
- package/src/primitives/thread/ThreadIf.test.tsx +20 -20
- package/src/primitives/thread/ThreadIf.tsx +5 -8
- package/src/primitives/thread/ThreadSuggestion.tsx +6 -3
- package/src/primitives/threadList/ThreadListNew.test.tsx +118 -3
- package/src/primitives/threadList/ThreadListNew.tsx +28 -5
- package/src/primitives/threadListItem/ThreadListItemArchive.tsx +6 -4
- package/src/primitives/threadListItem/ThreadListItemDelete.tsx +10 -4
- package/src/primitives/threadListItem/ThreadListItemTrigger.test.tsx +74 -0
- package/src/primitives/threadListItem/ThreadListItemTrigger.tsx +28 -5
- package/src/primitives/threadListItem/ThreadListItemUnarchive.tsx +10 -4
- package/dist/runtimes/RemoteThreadListHookInstanceManager.d.ts +0 -2
- package/dist/runtimes/RemoteThreadListHookInstanceManager.js +0 -2
- package/dist/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +0 -2
- package/dist/runtimes/RemoteThreadListThreadListRuntimeCore.js +0 -2
- package/src/runtimes/RemoteThreadListHookInstanceManager.tsx +0 -1
- package/src/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +0 -1
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import { act, type ReactNode } from "react";
|
|
2
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
+
|
|
5
|
+
import { ActionBarCopy } from "./actionBar/ActionBarCopy";
|
|
6
|
+
import { ActionBarEdit } from "./actionBar/ActionBarEdit";
|
|
7
|
+
import { ActionBarFeedbackNegative } from "./actionBar/ActionBarFeedbackNegative";
|
|
8
|
+
import { ActionBarFeedbackPositive } from "./actionBar/ActionBarFeedbackPositive";
|
|
9
|
+
import { ActionBarReload } from "./actionBar/ActionBarReload";
|
|
10
|
+
import { AttachmentRemove } from "./attachment/AttachmentRemove";
|
|
11
|
+
import { BranchPickerNext } from "./branchPicker/BranchPickerNext";
|
|
12
|
+
import { BranchPickerPrevious } from "./branchPicker/BranchPickerPrevious";
|
|
13
|
+
import { ChainOfThoughtAccordionTrigger } from "./chainOfThought/ChainOfThoughtAccordionTrigger";
|
|
14
|
+
import { ComposerAddAttachment } from "./composer/ComposerAddAttachment";
|
|
15
|
+
import { ComposerCancel } from "./composer/ComposerCancel";
|
|
16
|
+
import { ComposerQuoteDismiss } from "./composer/ComposerQuoteDismiss";
|
|
17
|
+
import { ComposerSend } from "./composer/ComposerSend";
|
|
18
|
+
import { QueueItemRemove } from "./queueItem/QueueItemRemove";
|
|
19
|
+
import { QueueItemSteer } from "./queueItem/QueueItemSteer";
|
|
20
|
+
import { SuggestionTrigger } from "./suggestion/SuggestionTrigger";
|
|
21
|
+
import { ThreadSuggestion } from "./thread/ThreadSuggestion";
|
|
22
|
+
import { ThreadListNew } from "./threadList/ThreadListNew";
|
|
23
|
+
import { ThreadListItemArchive } from "./threadListItem/ThreadListItemArchive";
|
|
24
|
+
import { ThreadListItemDelete } from "./threadListItem/ThreadListItemDelete";
|
|
25
|
+
import { ThreadListItemTrigger } from "./threadListItem/ThreadListItemTrigger";
|
|
26
|
+
import { ThreadListItemUnarchive } from "./threadListItem/ThreadListItemUnarchive";
|
|
27
|
+
|
|
28
|
+
vi.mock("@assistant-ui/store", () => ({
|
|
29
|
+
useAui: () => ({
|
|
30
|
+
attachment: { remove: vi.fn() },
|
|
31
|
+
chainOfThought: { setCollapsed: vi.fn() },
|
|
32
|
+
composer: { setQuote: vi.fn() },
|
|
33
|
+
queueItem: { remove: vi.fn(), steer: vi.fn() },
|
|
34
|
+
}),
|
|
35
|
+
useAuiState: <T,>(
|
|
36
|
+
selector: (s: {
|
|
37
|
+
suggestion: { prompt: string };
|
|
38
|
+
chainOfThought: { collapsed: boolean };
|
|
39
|
+
threads: { newThreadId: string | null; mainThreadId: string };
|
|
40
|
+
threadListItem: { id: string };
|
|
41
|
+
}) => T,
|
|
42
|
+
) =>
|
|
43
|
+
selector({
|
|
44
|
+
suggestion: { prompt: "p" },
|
|
45
|
+
chainOfThought: { collapsed: false },
|
|
46
|
+
threads: { newThreadId: null, mainThreadId: "main" },
|
|
47
|
+
threadListItem: { id: "thread" },
|
|
48
|
+
}),
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
vi.mock("@assistant-ui/core/react", () => ({
|
|
52
|
+
useActionBarCopy: () => ({
|
|
53
|
+
copy: vi.fn(),
|
|
54
|
+
disabled: false,
|
|
55
|
+
isCopied: false,
|
|
56
|
+
}),
|
|
57
|
+
useActionBarEdit: () => ({ edit: vi.fn(), disabled: false }),
|
|
58
|
+
useActionBarFeedbackNegative: () => ({
|
|
59
|
+
submit: vi.fn(),
|
|
60
|
+
isSubmitted: false,
|
|
61
|
+
}),
|
|
62
|
+
useActionBarFeedbackPositive: () => ({
|
|
63
|
+
submit: vi.fn(),
|
|
64
|
+
isSubmitted: false,
|
|
65
|
+
}),
|
|
66
|
+
useActionBarReload: () => ({ reload: vi.fn(), disabled: false }),
|
|
67
|
+
useBranchPickerNext: () => ({ next: vi.fn(), disabled: false }),
|
|
68
|
+
useBranchPickerPrevious: () => ({ previous: vi.fn(), disabled: false }),
|
|
69
|
+
useComposerAddAttachment: () => ({ disabled: false }),
|
|
70
|
+
useComposerCancel: () => ({ cancel: vi.fn(), disabled: false }),
|
|
71
|
+
useComposerSend: () => ({ send: vi.fn(), disabled: false }),
|
|
72
|
+
useSuggestionTrigger: () => ({ trigger: vi.fn(), disabled: false }),
|
|
73
|
+
useThreadListNew: () => ({ switchToNewThread: vi.fn() }),
|
|
74
|
+
useThreadListItemArchive: () => ({ archive: vi.fn() }),
|
|
75
|
+
useThreadListItemDelete: () => ({ delete: vi.fn() }),
|
|
76
|
+
useThreadListItemTrigger: () => ({ switchTo: vi.fn() }),
|
|
77
|
+
useThreadListItemUnarchive: () => ({ unarchive: vi.fn() }),
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
(globalThis as Record<string, unknown>).IS_REACT_ACT_ENVIRONMENT = true;
|
|
81
|
+
|
|
82
|
+
declare global {
|
|
83
|
+
interface ImportMeta {
|
|
84
|
+
glob(
|
|
85
|
+
pattern: string,
|
|
86
|
+
options: { query: "?raw"; eager: true; import: "default" },
|
|
87
|
+
): Record<string, string>;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
type Extra = { accessibilityRole?: "link" | undefined };
|
|
92
|
+
|
|
93
|
+
const actionable: ReadonlyArray<{
|
|
94
|
+
name: string;
|
|
95
|
+
render: (extra: Extra) => ReactNode;
|
|
96
|
+
}> = [
|
|
97
|
+
{
|
|
98
|
+
name: "ActionBarCopy",
|
|
99
|
+
render: (e) => (
|
|
100
|
+
<ActionBarCopy testID="t" {...e}>
|
|
101
|
+
x
|
|
102
|
+
</ActionBarCopy>
|
|
103
|
+
),
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "ActionBarEdit",
|
|
107
|
+
render: (e) => (
|
|
108
|
+
<ActionBarEdit testID="t" {...e}>
|
|
109
|
+
x
|
|
110
|
+
</ActionBarEdit>
|
|
111
|
+
),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: "ActionBarFeedbackNegative",
|
|
115
|
+
render: (e) => (
|
|
116
|
+
<ActionBarFeedbackNegative testID="t" {...e}>
|
|
117
|
+
x
|
|
118
|
+
</ActionBarFeedbackNegative>
|
|
119
|
+
),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "ActionBarFeedbackPositive",
|
|
123
|
+
render: (e) => (
|
|
124
|
+
<ActionBarFeedbackPositive testID="t" {...e}>
|
|
125
|
+
x
|
|
126
|
+
</ActionBarFeedbackPositive>
|
|
127
|
+
),
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: "ActionBarReload",
|
|
131
|
+
render: (e) => (
|
|
132
|
+
<ActionBarReload testID="t" {...e}>
|
|
133
|
+
x
|
|
134
|
+
</ActionBarReload>
|
|
135
|
+
),
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: "AttachmentRemove",
|
|
139
|
+
render: (e) => (
|
|
140
|
+
<AttachmentRemove testID="t" {...e}>
|
|
141
|
+
x
|
|
142
|
+
</AttachmentRemove>
|
|
143
|
+
),
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: "BranchPickerNext",
|
|
147
|
+
render: (e) => (
|
|
148
|
+
<BranchPickerNext testID="t" {...e}>
|
|
149
|
+
x
|
|
150
|
+
</BranchPickerNext>
|
|
151
|
+
),
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "BranchPickerPrevious",
|
|
155
|
+
render: (e) => (
|
|
156
|
+
<BranchPickerPrevious testID="t" {...e}>
|
|
157
|
+
x
|
|
158
|
+
</BranchPickerPrevious>
|
|
159
|
+
),
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "ChainOfThoughtAccordionTrigger",
|
|
163
|
+
render: (e) => (
|
|
164
|
+
<ChainOfThoughtAccordionTrigger testID="t" {...e}>
|
|
165
|
+
x
|
|
166
|
+
</ChainOfThoughtAccordionTrigger>
|
|
167
|
+
),
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "ComposerAddAttachment",
|
|
171
|
+
render: (e) => (
|
|
172
|
+
<ComposerAddAttachment testID="t" {...e}>
|
|
173
|
+
x
|
|
174
|
+
</ComposerAddAttachment>
|
|
175
|
+
),
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "ComposerCancel",
|
|
179
|
+
render: (e) => (
|
|
180
|
+
<ComposerCancel testID="t" {...e}>
|
|
181
|
+
x
|
|
182
|
+
</ComposerCancel>
|
|
183
|
+
),
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
name: "ComposerSend",
|
|
187
|
+
render: (e) => (
|
|
188
|
+
<ComposerSend testID="t" {...e}>
|
|
189
|
+
x
|
|
190
|
+
</ComposerSend>
|
|
191
|
+
),
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: "ComposerQuoteDismiss",
|
|
195
|
+
render: (e) => (
|
|
196
|
+
<ComposerQuoteDismiss testID="t" {...e}>
|
|
197
|
+
x
|
|
198
|
+
</ComposerQuoteDismiss>
|
|
199
|
+
),
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "QueueItemRemove",
|
|
203
|
+
render: (e) => (
|
|
204
|
+
<QueueItemRemove testID="t" {...e}>
|
|
205
|
+
x
|
|
206
|
+
</QueueItemRemove>
|
|
207
|
+
),
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
name: "QueueItemSteer",
|
|
211
|
+
render: (e) => (
|
|
212
|
+
<QueueItemSteer testID="t" {...e}>
|
|
213
|
+
x
|
|
214
|
+
</QueueItemSteer>
|
|
215
|
+
),
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: "SuggestionTrigger",
|
|
219
|
+
render: (e) => (
|
|
220
|
+
<SuggestionTrigger testID="t" {...e}>
|
|
221
|
+
x
|
|
222
|
+
</SuggestionTrigger>
|
|
223
|
+
),
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
name: "ThreadSuggestion",
|
|
227
|
+
render: (e) => (
|
|
228
|
+
<ThreadSuggestion testID="t" prompt="p" {...e}>
|
|
229
|
+
x
|
|
230
|
+
</ThreadSuggestion>
|
|
231
|
+
),
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
name: "ThreadListNew",
|
|
235
|
+
render: (e) => (
|
|
236
|
+
<ThreadListNew testID="t" {...e}>
|
|
237
|
+
x
|
|
238
|
+
</ThreadListNew>
|
|
239
|
+
),
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: "ThreadListItemArchive",
|
|
243
|
+
render: (e) => (
|
|
244
|
+
<ThreadListItemArchive testID="t" {...e}>
|
|
245
|
+
x
|
|
246
|
+
</ThreadListItemArchive>
|
|
247
|
+
),
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: "ThreadListItemDelete",
|
|
251
|
+
render: (e) => (
|
|
252
|
+
<ThreadListItemDelete testID="t" {...e}>
|
|
253
|
+
x
|
|
254
|
+
</ThreadListItemDelete>
|
|
255
|
+
),
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: "ThreadListItemTrigger",
|
|
259
|
+
render: (e) => (
|
|
260
|
+
<ThreadListItemTrigger testID="t" {...e}>
|
|
261
|
+
x
|
|
262
|
+
</ThreadListItemTrigger>
|
|
263
|
+
),
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
name: "ThreadListItemUnarchive",
|
|
267
|
+
render: (e) => (
|
|
268
|
+
<ThreadListItemUnarchive testID="t" {...e}>
|
|
269
|
+
x
|
|
270
|
+
</ThreadListItemUnarchive>
|
|
271
|
+
),
|
|
272
|
+
},
|
|
273
|
+
];
|
|
274
|
+
|
|
275
|
+
describe("react-native primitive accessibility roles", () => {
|
|
276
|
+
let container: HTMLDivElement;
|
|
277
|
+
let root: Root;
|
|
278
|
+
|
|
279
|
+
beforeEach(() => {
|
|
280
|
+
container = document.createElement("div");
|
|
281
|
+
document.body.appendChild(container);
|
|
282
|
+
root = createRoot(container);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
afterEach(async () => {
|
|
286
|
+
await act(async () => {
|
|
287
|
+
root.unmount();
|
|
288
|
+
});
|
|
289
|
+
container.remove();
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
const mount = async (node: ReactNode) => {
|
|
293
|
+
await act(async () => {
|
|
294
|
+
root.render(node);
|
|
295
|
+
});
|
|
296
|
+
const el = container.querySelector('[data-testid="t"]');
|
|
297
|
+
expect(el).not.toBeNull();
|
|
298
|
+
return el as HTMLElement;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
it("gives every Pressable primitive in the package a button role", () => {
|
|
302
|
+
const wrappers = Object.entries(
|
|
303
|
+
import.meta.glob("./**/*.tsx", {
|
|
304
|
+
query: "?raw",
|
|
305
|
+
eager: true,
|
|
306
|
+
import: "default",
|
|
307
|
+
}),
|
|
308
|
+
).filter(
|
|
309
|
+
([file, source]) =>
|
|
310
|
+
!file.endsWith(".test.tsx") && source.includes("<Pressable"),
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
expect(
|
|
314
|
+
wrappers
|
|
315
|
+
.filter(([, source]) => !source.includes('accessibilityRole="button"'))
|
|
316
|
+
.map(([file]) => file),
|
|
317
|
+
).toEqual([]);
|
|
318
|
+
|
|
319
|
+
expect(
|
|
320
|
+
wrappers.map(([file]) => file.replace(/^.*\/|\.tsx$/g, "")).sort(),
|
|
321
|
+
).toEqual(actionable.map(({ name }) => name).sort());
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
for (const { name, render } of actionable) {
|
|
325
|
+
it(`${name} defaults its accessibilityRole to button`, async () => {
|
|
326
|
+
const el = await mount(render({}));
|
|
327
|
+
expect(el.getAttribute("role")).toBe("button");
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it(`${name} lets the caller override the role`, async () => {
|
|
331
|
+
const el = await mount(render({ accessibilityRole: "link" }));
|
|
332
|
+
expect(el.getAttribute("role")).toBe("link");
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
});
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
1
|
import { Pressable, type PressableProps } from "react-native";
|
|
3
2
|
import { useActionBarEdit } from "@assistant-ui/core/react";
|
|
4
3
|
|
|
5
|
-
export type ActionBarEditProps = Omit<
|
|
6
|
-
|
|
4
|
+
export type ActionBarEditProps = Omit<
|
|
5
|
+
PressableProps,
|
|
6
|
+
"onPress" | "children"
|
|
7
|
+
> & {
|
|
8
|
+
children: PressableProps["children"];
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export const ActionBarEdit = ({
|
|
@@ -17,6 +19,7 @@ export const ActionBarEdit = ({
|
|
|
17
19
|
<Pressable
|
|
18
20
|
onPress={edit}
|
|
19
21
|
disabled={disabledProp ?? disabled}
|
|
22
|
+
accessibilityRole="button"
|
|
20
23
|
{...pressableProps}
|
|
21
24
|
>
|
|
22
25
|
{children}
|
|
@@ -16,7 +16,7 @@ export const ActionBarFeedbackNegative = ({
|
|
|
16
16
|
const { submit, isSubmitted } = useActionBarFeedbackNegative();
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
|
-
<Pressable onPress={submit} {...pressableProps}>
|
|
19
|
+
<Pressable onPress={submit} accessibilityRole="button" {...pressableProps}>
|
|
20
20
|
{typeof children === "function" ? children({ isSubmitted }) : children}
|
|
21
21
|
</Pressable>
|
|
22
22
|
);
|
|
@@ -16,7 +16,7 @@ export const ActionBarFeedbackPositive = ({
|
|
|
16
16
|
const { submit, isSubmitted } = useActionBarFeedbackPositive();
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
|
-
<Pressable onPress={submit} {...pressableProps}>
|
|
19
|
+
<Pressable onPress={submit} accessibilityRole="button" {...pressableProps}>
|
|
20
20
|
{typeof children === "function" ? children({ isSubmitted }) : children}
|
|
21
21
|
</Pressable>
|
|
22
22
|
);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
1
|
import { Pressable, type PressableProps } from "react-native";
|
|
3
2
|
import { useActionBarReload } from "@assistant-ui/core/react";
|
|
4
3
|
|
|
5
|
-
export type ActionBarReloadProps = Omit<
|
|
6
|
-
|
|
4
|
+
export type ActionBarReloadProps = Omit<
|
|
5
|
+
PressableProps,
|
|
6
|
+
"onPress" | "children"
|
|
7
|
+
> & {
|
|
8
|
+
children: PressableProps["children"];
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export const ActionBarReload = ({
|
|
@@ -17,6 +19,7 @@ export const ActionBarReload = ({
|
|
|
17
19
|
<Pressable
|
|
18
20
|
onPress={reload}
|
|
19
21
|
disabled={disabledProp ?? disabled}
|
|
22
|
+
accessibilityRole="button"
|
|
20
23
|
{...pressableProps}
|
|
21
24
|
>
|
|
22
25
|
{children}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCallback } from "react";
|
|
2
2
|
import { Pressable, type PressableProps } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useAui } from "@assistant-ui/store";
|
|
5
5
|
|
|
6
|
-
export type AttachmentRemoveProps = Omit<
|
|
7
|
-
|
|
6
|
+
export type AttachmentRemoveProps = Omit<
|
|
7
|
+
PressableProps,
|
|
8
|
+
"onPress" | "children"
|
|
9
|
+
> & {
|
|
10
|
+
children: PressableProps["children"];
|
|
8
11
|
};
|
|
9
12
|
|
|
10
13
|
export const AttachmentRemove = ({
|
|
@@ -18,7 +21,11 @@ export const AttachmentRemove = ({
|
|
|
18
21
|
}, [aui]);
|
|
19
22
|
|
|
20
23
|
return (
|
|
21
|
-
<Pressable
|
|
24
|
+
<Pressable
|
|
25
|
+
onPress={handleRemove}
|
|
26
|
+
accessibilityRole="button"
|
|
27
|
+
{...pressableProps}
|
|
28
|
+
>
|
|
22
29
|
{children}
|
|
23
30
|
</Pressable>
|
|
24
31
|
);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
1
|
import { Pressable, type PressableProps } from "react-native";
|
|
3
2
|
import { useBranchPickerNext } from "@assistant-ui/core/react";
|
|
4
3
|
|
|
5
|
-
export type BranchPickerNextProps = Omit<
|
|
6
|
-
|
|
4
|
+
export type BranchPickerNextProps = Omit<
|
|
5
|
+
PressableProps,
|
|
6
|
+
"onPress" | "children"
|
|
7
|
+
> & {
|
|
8
|
+
children: PressableProps["children"];
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export const BranchPickerNext = ({
|
|
@@ -17,6 +19,7 @@ export const BranchPickerNext = ({
|
|
|
17
19
|
<Pressable
|
|
18
20
|
onPress={next}
|
|
19
21
|
disabled={disabledProp ?? disabled}
|
|
22
|
+
accessibilityRole="button"
|
|
20
23
|
{...pressableProps}
|
|
21
24
|
>
|
|
22
25
|
{children}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
1
|
import { Pressable, type PressableProps } from "react-native";
|
|
3
2
|
import { useBranchPickerPrevious } from "@assistant-ui/core/react";
|
|
4
3
|
|
|
5
|
-
export type BranchPickerPreviousProps = Omit<
|
|
6
|
-
|
|
4
|
+
export type BranchPickerPreviousProps = Omit<
|
|
5
|
+
PressableProps,
|
|
6
|
+
"onPress" | "children"
|
|
7
|
+
> & {
|
|
8
|
+
children: PressableProps["children"];
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export const BranchPickerPrevious = ({
|
|
@@ -17,6 +19,7 @@ export const BranchPickerPrevious = ({
|
|
|
17
19
|
<Pressable
|
|
18
20
|
onPress={previous}
|
|
19
21
|
disabled={disabledProp ?? disabled}
|
|
22
|
+
accessibilityRole="button"
|
|
20
23
|
{...pressableProps}
|
|
21
24
|
>
|
|
22
25
|
{children}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useCallback
|
|
1
|
+
import { useCallback } from "react";
|
|
2
2
|
import { Pressable, type PressableProps } from "react-native";
|
|
3
3
|
import { useAuiState, useAui } from "@assistant-ui/store";
|
|
4
4
|
|
|
5
5
|
export type ChainOfThoughtAccordionTriggerProps = Omit<
|
|
6
6
|
PressableProps,
|
|
7
|
-
"onPress"
|
|
7
|
+
"onPress" | "children"
|
|
8
8
|
> & {
|
|
9
|
-
children:
|
|
9
|
+
children: PressableProps["children"];
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const ChainOfThoughtAccordionTrigger = ({
|
|
@@ -21,7 +21,7 @@ export const ChainOfThoughtAccordionTrigger = ({
|
|
|
21
21
|
}, [aui, collapsed]);
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
|
-
<Pressable onPress={onPress} {...pressableProps}>
|
|
24
|
+
<Pressable onPress={onPress} accessibilityRole="button" {...pressableProps}>
|
|
25
25
|
{children}
|
|
26
26
|
</Pressable>
|
|
27
27
|
);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
1
|
import { Pressable, type PressableProps } from "react-native";
|
|
3
2
|
import { useComposerAddAttachment } from "@assistant-ui/core/react";
|
|
4
3
|
|
|
5
|
-
export type ComposerAddAttachmentProps = Omit<
|
|
6
|
-
|
|
4
|
+
export type ComposerAddAttachmentProps = Omit<
|
|
5
|
+
PressableProps,
|
|
6
|
+
"onPress" | "children"
|
|
7
|
+
> & {
|
|
8
|
+
children: PressableProps["children"];
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -21,7 +23,11 @@ export const ComposerAddAttachment = ({
|
|
|
21
23
|
const { disabled } = useComposerAddAttachment();
|
|
22
24
|
|
|
23
25
|
return (
|
|
24
|
-
<Pressable
|
|
26
|
+
<Pressable
|
|
27
|
+
disabled={disabledProp ?? disabled}
|
|
28
|
+
accessibilityRole="button"
|
|
29
|
+
{...pressableProps}
|
|
30
|
+
>
|
|
25
31
|
{children}
|
|
26
32
|
</Pressable>
|
|
27
33
|
);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
2
1
|
import { Pressable, type PressableProps } from "react-native";
|
|
3
2
|
import { useComposerCancel } from "@assistant-ui/core/react";
|
|
4
3
|
|
|
5
|
-
export type ComposerCancelProps = Omit<
|
|
6
|
-
|
|
4
|
+
export type ComposerCancelProps = Omit<
|
|
5
|
+
PressableProps,
|
|
6
|
+
"onPress" | "children"
|
|
7
|
+
> & {
|
|
8
|
+
children: PressableProps["children"];
|
|
7
9
|
};
|
|
8
10
|
|
|
9
11
|
export const ComposerCancel = ({
|
|
@@ -17,6 +19,7 @@ export const ComposerCancel = ({
|
|
|
17
19
|
<Pressable
|
|
18
20
|
onPress={cancel}
|
|
19
21
|
disabled={disabled ?? hookDisabled}
|
|
22
|
+
accessibilityRole="button"
|
|
20
23
|
{...pressableProps}
|
|
21
24
|
>
|
|
22
25
|
{children}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { ComposerPrimitiveQueue } from "@assistant-ui/core/react";
|
|
3
|
+
import { ComposerQueue } from "./ComposerQueue";
|
|
4
|
+
|
|
5
|
+
describe("ComposerPrimitive.Queue", () => {
|
|
6
|
+
it("re-exports the shared core queue primitive", () => {
|
|
7
|
+
expect(ComposerQueue).toBe(ComposerPrimitiveQueue);
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ComposerPrimitiveQueue as ComposerQueue } from "@assistant-ui/core/react";
|