@marktiderman/genesis-chat 0.7.0 → 0.8.0
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/README.md +132 -3
- package/dist/{chunk-GBJ3YI4E.js → chunk-5XYDVUPS.js} +6 -3
- package/dist/chunk-5XYDVUPS.js.map +1 -0
- package/dist/{chunk-XQ2ULNHV.js → chunk-D4RPOYB7.js} +4 -4
- package/dist/chunk-D4RPOYB7.js.map +1 -0
- package/dist/{chunk-RYD6WJE5.js → chunk-O2QSBRSH.js} +3 -3
- package/dist/{chunk-RYD6WJE5.js.map → chunk-O2QSBRSH.js.map} +1 -1
- package/dist/{chunk-A4YJX7KT.js → chunk-ZQFREERR.js} +3 -3
- package/dist/{chunk-A4YJX7KT.js.map → chunk-ZQFREERR.js.map} +1 -1
- package/dist/{client-DUIG1hum.d.ts → client-DP7rhJ1U.d.ts} +17 -6
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/native.d.ts +31 -15
- package/dist/native.js +74 -328
- package/dist/native.js.map +1 -1
- package/dist/{outbox-B9NAWQ58.d.ts → outbox-C4LnqpKT.d.ts} +1 -1
- package/dist/push.d.ts +2 -2
- package/dist/react.d.ts +4 -8
- package/dist/react.js +3 -3
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/{thread-oPra7pkW.d.ts → thread-CSzdqNR_.d.ts} +1 -1
- package/dist/web.d.ts +201 -7
- package/dist/web.js +580 -56
- package/dist/web.js.map +1 -1
- package/migrations/0004_genesis_chat_tenants.sql +716 -0
- package/migrations/tests/0001_genesis_chat.test.sql +10 -2
- package/migrations/tests/0002_genesis_chat_coaching.test.sql +8 -0
- package/migrations/tests/0003_genesis_chat_search_threads.test.sql +8 -0
- package/migrations/tests/0004_genesis_chat_tenants.test.sql +259 -0
- package/package.json +18 -7
- package/src/__tests__/core.test.ts +12 -0
- package/src/__tests__/web-dock.test.tsx +465 -0
- package/src/__tests__/web-photo-viewer.test.tsx +43 -0
- package/src/__tests__/web.test.tsx +26 -0
- package/src/core/client.ts +5 -1
- package/src/core/types.ts +16 -0
- package/src/native/__tests__/photo-viewer.test.tsx +24 -5
- package/src/native/photo-viewer.tsx +109 -422
- package/src/native/thread-screen.tsx +14 -5
- package/src/native/use-jump.ts +3 -0
- package/src/react/index.tsx +2 -1
- package/src/web/attachments.tsx +39 -55
- package/src/web/composer.tsx +5 -0
- package/src/web/dock.tsx +889 -0
- package/src/web/inbox.tsx +5 -0
- package/src/web/index.ts +23 -0
- package/src/web/memory-client.ts +1 -1
- package/src/web/thread.tsx +42 -3
- package/dist/chunk-GBJ3YI4E.js.map +0 -1
- package/dist/chunk-XQ2ULNHV.js.map +0 -1
package/src/web/attachments.tsx
CHANGED
|
@@ -5,18 +5,9 @@
|
|
|
5
5
|
* form, a lesson) through the `attachment` slot, a generic card by default.
|
|
6
6
|
* Pending uploads draw from their local previews with a spinner.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
Button,
|
|
12
|
-
Dialog,
|
|
13
|
-
DialogContent,
|
|
14
|
-
DialogDescription,
|
|
15
|
-
DialogTitle,
|
|
16
|
-
Spinner,
|
|
17
|
-
VisuallyHidden,
|
|
18
|
-
cn,
|
|
19
|
-
} from "@marktiderman/genesis-ui";
|
|
8
|
+
import { useMemo, useState, type ComponentType } from "react";
|
|
9
|
+
import { Download, FileText, Link2, Paperclip } from "lucide-react";
|
|
10
|
+
import { Button, Lightbox as GenesisLightbox, Spinner, cn, type GalleryItem } from "@marktiderman/genesis-ui";
|
|
20
11
|
import type { ChatAttachment, ChatMessage } from "../core/types";
|
|
21
12
|
import type { ChatAttachmentKind, ChatCardContext } from "../react/index";
|
|
22
13
|
import { ChatAttachmentCard, type ChatAttachmentCardProps } from "./cards";
|
|
@@ -156,7 +147,7 @@ export function ImageGrid({ images, className }: ImageGridProps) {
|
|
|
156
147
|
);
|
|
157
148
|
})}
|
|
158
149
|
</div>
|
|
159
|
-
<
|
|
150
|
+
<ChatLightbox images={images} index={open} onIndexChange={setOpen} />
|
|
160
151
|
</>
|
|
161
152
|
);
|
|
162
153
|
}
|
|
@@ -168,53 +159,46 @@ export interface LightboxProps {
|
|
|
168
159
|
onIndexChange: (index: number | null) => void;
|
|
169
160
|
}
|
|
170
161
|
|
|
171
|
-
/** A
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
162
|
+
/** A message's photos full size: genesis-ui's `Lightbox` (arrow keys, a counter, focus kept on the arrows), fed chat's attachments. */
|
|
163
|
+
function ChatLightbox({ images, index, onIndexChange }: LightboxProps) {
|
|
164
|
+
// Only photos with a link open: one still uploading has nothing to show full size. `at` maps
|
|
165
|
+
// between the viewer's positions and `images`' indexes.
|
|
166
|
+
const at = useMemo(() => images.flatMap((img, i) => (img.url ? [i] : [])), [images]);
|
|
167
|
+
const items = useMemo<GalleryItem[]>(
|
|
168
|
+
() =>
|
|
169
|
+
at.map((i) => {
|
|
170
|
+
const img = images[i]!;
|
|
171
|
+
return {
|
|
172
|
+
id: img.key,
|
|
173
|
+
src: img.url!,
|
|
174
|
+
alt: img.name ?? "Photo",
|
|
175
|
+
...(img.width ? { width: img.width } : {}),
|
|
176
|
+
...(img.height ? { height: img.height } : {}),
|
|
177
|
+
};
|
|
178
|
+
}),
|
|
179
|
+
[images, at],
|
|
180
180
|
);
|
|
181
|
-
const
|
|
182
|
-
if (e.key === "ArrowRight") {
|
|
183
|
-
e.preventDefault();
|
|
184
|
-
go(1);
|
|
185
|
-
} else if (e.key === "ArrowLeft") {
|
|
186
|
-
e.preventDefault();
|
|
187
|
-
go(-1);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
181
|
+
const shown = index === null ? -1 : at.indexOf(index);
|
|
190
182
|
return (
|
|
191
|
-
<
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
{images.length > 1 ? (
|
|
201
|
-
<div className="flex items-center justify-between gap-2">
|
|
202
|
-
<Button type="button" variant="ghost" size="icon" onClick={() => go(-1)} aria-label="Previous photo">
|
|
203
|
-
<ChevronLeft />
|
|
204
|
-
</Button>
|
|
205
|
-
<span className="text-sm tabular-nums text-muted-foreground">
|
|
206
|
-
{(index ?? 0) + 1} / {images.length}
|
|
207
|
-
</span>
|
|
208
|
-
<Button type="button" variant="ghost" size="icon" onClick={() => go(1)} aria-label="Next photo">
|
|
209
|
-
<ChevronRight />
|
|
210
|
-
</Button>
|
|
211
|
-
</div>
|
|
212
|
-
) : null}
|
|
213
|
-
</DialogContent>
|
|
214
|
-
</Dialog>
|
|
183
|
+
<GenesisLightbox
|
|
184
|
+
open={shown !== -1}
|
|
185
|
+
onOpenChange={(open) => !open && onIndexChange(null)}
|
|
186
|
+
items={items}
|
|
187
|
+
index={Math.max(0, shown)}
|
|
188
|
+
onIndexChange={(i) => onIndexChange(at[i] ?? null)}
|
|
189
|
+
labels={{ previous: "Previous photo", next: "Next photo", photo: (n, count) => `Photo ${n} of ${count}` }}
|
|
190
|
+
className="genesis-chat-lightbox"
|
|
191
|
+
/>
|
|
215
192
|
);
|
|
216
193
|
}
|
|
217
194
|
|
|
195
|
+
/**
|
|
196
|
+
* @deprecated Chat's photo grid opens its photos itself. To show photos full size elsewhere, render
|
|
197
|
+
* `Lightbox` from `@marktiderman/genesis-ui` with `GalleryItem`s. This adapter is removed in a
|
|
198
|
+
* later minor.
|
|
199
|
+
*/
|
|
200
|
+
export const Lightbox = ChatLightbox;
|
|
201
|
+
|
|
218
202
|
/** A video: a hosted one (Mux) streams once ready and says "Processing…" until then; a file plays from storage. */
|
|
219
203
|
export function VideoAttachment({ view }: { view: AttachmentView }) {
|
|
220
204
|
const a = view.attachment;
|
package/src/web/composer.tsx
CHANGED
|
@@ -6,6 +6,11 @@
|
|
|
6
6
|
* internal notes for observers, voice notes recorded in place, videos from the
|
|
7
7
|
* camera, emoji, and scheduled send (the arrow beside Send). Where you may not
|
|
8
8
|
* post it says why instead; when who you are couldn't load, it offers a retry.
|
|
9
|
+
*
|
|
10
|
+
* Moving onto genesis-ui (feature `inbox-thread`): its scrolling, list and composer are the same
|
|
11
|
+
* behaviour as genesis-ui's `ComposerBar`, which were promoted from here. This screen keeps its data
|
|
12
|
+
* wiring (the chat client, realtime, read state) and moves its rendering onto `ComposerBar` with chat's
|
|
13
|
+
* builder; until then fix behaviour in both places.
|
|
9
14
|
*/
|
|
10
15
|
import {
|
|
11
16
|
useCallback,
|