@theoremjs/react 0.3.4-next.423.g9c79ac8 → 0.3.4-next.425.gd676bc4
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/package.json +3 -3
- package/ui/ChatComposerBar.js +23 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/react",
|
|
3
|
-
"version": "0.3.4-next.
|
|
3
|
+
"version": "0.3.4-next.425.gd676bc4",
|
|
4
4
|
"description": "React bindings for Theorem: headless hooks + transport, an Astryx chat UI, and a Web-standard server handler.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"@stylexjs/stylex": "0.19.0",
|
|
61
61
|
"react": "^19.0.0",
|
|
62
62
|
"react-dom": "^19.0.0",
|
|
63
|
-
"@theoremjs/agents": "^0.3.4-next.
|
|
64
|
-
"@theoremjs/web": "^0.3.4-next.
|
|
63
|
+
"@theoremjs/agents": "^0.3.4-next.425.gd676bc4",
|
|
64
|
+
"@theoremjs/web": "^0.3.4-next.425.gd676bc4"
|
|
65
65
|
},
|
|
66
66
|
"peerDependenciesMeta": {
|
|
67
67
|
"@astryxdesign/core": {
|
package/ui/ChatComposerBar.js
CHANGED
|
@@ -29,15 +29,23 @@ const NO_FOCUS_RING = { '--focus-outline-width': '0px' };
|
|
|
29
29
|
export const EFFORT_ICON = IconBrain;
|
|
30
30
|
const isImage = (file) => file.type.startsWith('image/');
|
|
31
31
|
const anyFile = () => true;
|
|
32
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Object URLs for the files `keep` (a module-level predicate) accepts, revoked when the files change.
|
|
34
|
+
* why: Each URL is made in the effect that revokes it, so a remount (strict mode, a moved subtree)
|
|
35
|
+
* makes fresh ones instead of keeping revoked ones; until the effect runs the files have none.
|
|
36
|
+
*/
|
|
33
37
|
function useObjectUrls(files, keep) {
|
|
34
|
-
const
|
|
35
|
-
useEffect(() =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const [made, setMade] = useState();
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const urls = files.map((file) => (keep(file) ? URL.createObjectURL(file) : undefined));
|
|
41
|
+
setMade({ files, urls });
|
|
42
|
+
return () => {
|
|
43
|
+
for (const url of urls)
|
|
44
|
+
if (url)
|
|
45
|
+
URL.revokeObjectURL(url);
|
|
46
|
+
};
|
|
47
|
+
}, [files, keep]);
|
|
48
|
+
return made?.files === files ? made.urls : [];
|
|
41
49
|
}
|
|
42
50
|
/** Each way to send, by the same icon in the send menu and on a waiting message. */
|
|
43
51
|
const SEND_ICON = {
|
|
@@ -111,7 +119,11 @@ function composerStatus(args) {
|
|
|
111
119
|
/** Pending messages, then two uniform rows: 64px tiles (images, voice notes), then file tokens. */
|
|
112
120
|
function PendingDrawer(props) {
|
|
113
121
|
const t = useLabels();
|
|
114
|
-
return (_jsx(ChatComposerDrawer, { count: props.summary.count, label: composerDrawerLabel(t, props.summary), children: _jsxs(VStack, { gap: 2, width: "100%", children: [props.messages.map((message) => (_jsx(PendingRow, { message: message, ...props.pendingActions }, message.id))), props.imageFiles.length + props.voiceFiles.length > 0 ? (_jsxs(HStack, { gap: 2, wrap: "wrap", vAlign: "center", children: [props.imageFiles.map(({ file, index, preview }) => (_jsx(Thumbnail, { src: preview, alt: file.name, label: file.name, onRemove: () => props.onAttachmentRemove(index) }, `${file.name}:${String(index)}`))), props.voiceFiles.map((file, index) =>
|
|
122
|
+
return (_jsx(ChatComposerDrawer, { count: props.summary.count, label: composerDrawerLabel(t, props.summary), children: _jsxs(VStack, { gap: 2, width: "100%", children: [props.messages.map((message) => (_jsx(PendingRow, { message: message, ...props.pendingActions }, message.id))), props.imageFiles.length + props.voiceFiles.length > 0 ? (_jsxs(HStack, { gap: 2, wrap: "wrap", vAlign: "center", children: [props.imageFiles.map(({ file, index, preview }) => (_jsx(Thumbnail, { src: preview, alt: file.name, label: file.name, onRemove: () => props.onAttachmentRemove(index) }, `${file.name}:${String(index)}`))), props.voiceFiles.map((file, index) => {
|
|
123
|
+
const src = props.voiceUrls[index];
|
|
124
|
+
// why: An empty src makes the browser fetch the page again; a note draws once it has its URL.
|
|
125
|
+
return src === undefined ? null : (_jsx(VoiceNote, { src: src, mimeType: file.type || undefined, onRemove: props.onVoiceRemove }, `voice:${file.name}`));
|
|
126
|
+
})] })) : null, props.otherFiles.length > 0 ? (_jsx(HStack, { gap: 2, wrap: "wrap", children: props.otherFiles.map(({ file, index }) => (_jsx(Token, { label: file.name, onRemove: () => props.onAttachmentRemove(index) }, `${file.name}:${String(index)}`))) })) : null] }) }));
|
|
115
127
|
}
|
|
116
128
|
/** A hidden file input behind the paperclip button. */
|
|
117
129
|
function AttachFilesButton({ accept, onFiles, }) {
|
|
@@ -168,8 +180,8 @@ function useStagedFiles(pendingFiles, pendingVoice) {
|
|
|
168
180
|
preview: previews[index],
|
|
169
181
|
}));
|
|
170
182
|
return {
|
|
171
|
-
imageFiles: staged.filter((entry) => entry.
|
|
172
|
-
otherFiles: staged.filter((entry) => entry.
|
|
183
|
+
imageFiles: staged.filter((entry) => isImage(entry.file)),
|
|
184
|
+
otherFiles: staged.filter((entry) => !isImage(entry.file)),
|
|
173
185
|
voiceUrls,
|
|
174
186
|
};
|
|
175
187
|
}
|