@springbrand/message-panel 0.2.0-alpha.45 → 0.2.0-alpha.46

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.
@@ -22,7 +22,10 @@ import {
22
22
  useRef,
23
23
  useState,
24
24
  type ComponentType,
25
+ type ReactNode,
25
26
  } from "react";
27
+ import { PhotoProvider, PhotoView } from "react-photo-view";
28
+ import "react-photo-view/dist/react-photo-view.css";
26
29
  import {
27
30
  PRODUCT_PRESETS,
28
31
  productTypeForMediaType,
@@ -238,6 +241,10 @@ function ProductFileView({
238
241
  >
239
242
  {content}
240
243
  </button>
244
+ ) : image ? (
245
+ <ImagePreview src={file.url!} label={label} placement={placement}>
246
+ {content}
247
+ </ImagePreview>
241
248
  ) : file.url && !video ? (
242
249
  <a
243
250
  href={file.url}
@@ -263,6 +270,35 @@ function ProductFileView({
263
270
  );
264
271
  }
265
272
 
273
+ function ImagePreview({
274
+ src,
275
+ label,
276
+ placement,
277
+ children,
278
+ }: {
279
+ src: string;
280
+ label: string;
281
+ placement: Exclude<FileViewPlacement, "composer">;
282
+ children: ReactNode;
283
+ }) {
284
+ return (
285
+ <PhotoProvider>
286
+ <PhotoView src={src}>
287
+ <button
288
+ type="button"
289
+ aria-label={`Preview ${label}`}
290
+ data-image-preview=""
291
+ data-placement={placement}
292
+ data-file-variant="product"
293
+ className="inline-block max-w-full cursor-zoom-in rounded-2xl text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-kumo-brand/40"
294
+ >
295
+ {children}
296
+ </button>
297
+ </PhotoView>
298
+ </PhotoProvider>
299
+ );
300
+ }
301
+
266
302
  /**
267
303
  * Cloud OS 的默认文件视图。宿主可通过 `renderFile` 在同一 seam 替换它。
268
304
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@springbrand/message-panel",
3
- "version": "0.2.0-alpha.45",
3
+ "version": "0.2.0-alpha.46",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src",
@@ -36,6 +36,7 @@
36
36
  "lucide-react": "^1.24.0",
37
37
  "motion": "^13.1.0",
38
38
  "radix-ui": "^1.6.7",
39
+ "react-photo-view": "^1.2.7",
39
40
  "streamdown": "^2.5.0",
40
41
  "thinking-orbs": "0.2.0",
41
42
  "use-stick-to-bottom": "^1.1.6"