@marimo-team/islands 0.23.15-dev35 → 0.23.15-dev37

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.23.15-dev35",
3
+ "version": "0.23.15-dev37",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -34,7 +34,7 @@ const VARIANT_CLASSES = {
34
34
  type ToastVariant = keyof typeof VARIANT_CLASSES;
35
35
 
36
36
  const toastVariants = cva(
37
- "data-[swipe=move]:transition-none group relative pointer-events-auto flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full data-[state=closed]:slide-out-to-right-full",
37
+ "data-[swipe=move]:transition-none group relative pointer-events-auto flex w-full items-start justify-between gap-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full data-[state=closed]:slide-out-to-right-full",
38
38
  {
39
39
  variants: {
40
40
  variant: VARIANT_CLASSES,
@@ -117,10 +117,18 @@ ToastTitle.displayName = ToastPrimitives.Title.displayName;
117
117
  const ToastDescription = React.forwardRef<
118
118
  React.ElementRef<typeof ToastPrimitives.Description>,
119
119
  React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>
120
- >(({ className, ...props }, ref) => (
120
+ >(({ className, onPointerDown, ...props }, ref) => (
121
121
  <ToastPrimitives.Description
122
122
  ref={ref}
123
- className={cn("text-sm opacity-90", className)}
123
+ className={cn(
124
+ "max-h-48 overflow-auto text-sm opacity-90 whitespace-pre-wrap wrap-break-word select-text cursor-text",
125
+ className,
126
+ )}
127
+ // Keep swipe-to-dismiss from fighting text selection / scroll.
128
+ onPointerDown={(event) => {
129
+ event.stopPropagation();
130
+ onPointerDown?.(event);
131
+ }}
124
132
  {...props}
125
133
  />
126
134
  ));
@@ -1,5 +1,9 @@
1
1
  /* Copyright 2026 Marimo. All rights reserved. */
2
+ import type { ComponentPropsWithoutRef, ReactElement, ReactNode } from "react";
3
+ import { useRef } from "react";
4
+ import { CopyClipboardIcon } from "@/components/icons/copy-icon";
2
5
  import { useToast } from "@/components/ui/use-toast";
6
+ import { cn } from "@/utils/cn";
3
7
  import {
4
8
  Toast,
5
9
  ToastClose,
@@ -14,17 +18,69 @@ export const Toaster = () => {
14
18
 
15
19
  return (
16
20
  <ToastProvider>
17
- {toasts.map(({ id, title, description, action, ...props }) => (
18
- <Toast key={id} {...props}>
19
- <div className="grid gap-1">
20
- {title && <ToastTitle>{title}</ToastTitle>}
21
- {description && <ToastDescription>{description}</ToastDescription>}
22
- </div>
23
- {action}
24
- <ToastClose />
25
- </Toast>
21
+ {toasts.map(({ id, title, description, action, variant, ...props }) => (
22
+ <ToastItem
23
+ key={id}
24
+ toastTitle={title}
25
+ toastDescription={description}
26
+ action={action}
27
+ variant={variant}
28
+ {...props}
29
+ />
26
30
  ))}
27
31
  <ToastViewport />
28
32
  </ToastProvider>
29
33
  );
30
34
  };
35
+
36
+ type ToastItemProps = Omit<
37
+ ComponentPropsWithoutRef<typeof Toast>,
38
+ "title" | "children"
39
+ > & {
40
+ toastTitle?: ReactNode;
41
+ toastDescription?: ReactNode;
42
+ action?: ReactElement;
43
+ };
44
+
45
+ const ToastItem = ({
46
+ toastTitle,
47
+ toastDescription,
48
+ action,
49
+ variant,
50
+ ...props
51
+ }: ToastItemProps) => {
52
+ const descriptionRef = useRef<HTMLDivElement>(null);
53
+ // Show copy button for danger toasts without action, typically used for errors.
54
+ const showCopy = Boolean(toastDescription) && !action && variant === "danger";
55
+
56
+ return (
57
+ <Toast variant={variant} {...props}>
58
+ <div className="grid min-w-0 flex-1 gap-1">
59
+ {toastTitle && <ToastTitle>{toastTitle}</ToastTitle>}
60
+ {toastDescription && (
61
+ <ToastDescription ref={descriptionRef}>
62
+ {toastDescription}
63
+ </ToastDescription>
64
+ )}
65
+ </div>
66
+ {action}
67
+ {showCopy && (
68
+ <CopyClipboardIcon
69
+ tooltip="Copy error"
70
+ ariaLabel="Copy error"
71
+ className="h-4 w-4"
72
+ buttonClassName={cn(
73
+ "absolute right-8 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity",
74
+ "hover:text-foreground focus:opacity-100 focus:outline-hidden group-hover:opacity-100",
75
+ "group-[.destructive]:text-red-300 hover:group-[.destructive]:text-red-500 focus:group-[.destructive]:ring-red-400 focus:group-[.destructive]:ring-offset-red-600",
76
+ )}
77
+ value={() =>
78
+ descriptionRef.current?.innerText ??
79
+ (typeof toastDescription === "string" ? toastDescription : "")
80
+ }
81
+ />
82
+ )}
83
+ <ToastClose />
84
+ </Toast>
85
+ );
86
+ };