@ttt-productions/ui-core 0.11.31 → 0.11.32

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.
@@ -1 +1 @@
1
- {"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../../../src/react/components/toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAkDlE,QAAA,MAAM,aAAa,8CAA2B,CAAC;AAE/C,QAAA,MAAM,aAAa,kKAajB,CAAC;AAaH,QAAA,MAAM,KAAK;;;IARP,4CAA4C;eACjC,MAAM;IACjB,oBAAoB;kBACN,OAAO;IACrB,oDAAoD;iBACvC,OAAO;uCAmEvB,CAAC;AAGF,QAAA,MAAM,WAAW,kKAKf,CAAC;AAGH,QAAA,MAAM,UAAU,iKAcd,CAAC;AAGH,QAAA,MAAM,UAAU,2JAKd,CAAC;AAGH,QAAA,MAAM,gBAAgB,iKAKpB,CAAC;AAGH,mCAAmC;AACnC,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,wBAAwB,CAAC,OAAO,KAAK,CAAC,CAAC;AACtE,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,WAAW,CAAC,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"toast.d.ts","sourceRoot":"","sources":["../../../src/react/components/toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAkDlE,QAAA,MAAM,aAAa,8CAA2B,CAAC;AAE/C,QAAA,MAAM,aAAa,kKAajB,CAAC;AAaH,QAAA,MAAM,KAAK;;;IARP,4CAA4C;eACjC,MAAM;IACjB,oBAAoB;kBACN,OAAO;IACrB,oDAAoD;iBACvC,OAAO;uCAwEvB,CAAC;AAGF,QAAA,MAAM,WAAW,kKAKf,CAAC;AAGH,QAAA,MAAM,UAAU,iKAcd,CAAC;AAGH,QAAA,MAAM,UAAU,2JAKd,CAAC;AAGH,QAAA,MAAM,gBAAgB,iKAKpB,CAAC;AAGH,mCAAmC;AACnC,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,wBAAwB,CAAC,OAAO,KAAK,CAAC,CAAC;AACtE,MAAM,MAAM,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,WAAW,CAAC,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC"}
@@ -56,11 +56,17 @@ const Toast = React.forwardRef(({ className, variant, duration, dismissible = tr
56
56
  // focus, and window-blur — but this CSS bar does not. When the bar
57
57
  // empties we must dismiss regardless of Radix's paused timer, so the
58
58
  // toast never lingers after the countdown visibly reaches zero.
59
- // Radix's `duration` above remains a motion-independent backstop
60
- // (e.g. under prefers-reduced-motion where this event may not fire).
59
+ // Only a bar that ran its course counts as empty: a reduced-motion
60
+ // stylesheet that collapses every animation to near zero ends this one
61
+ // at once, and closing then would hide the toast before anyone reads
62
+ // it. Radix's `duration` above is the motion-independent timer that
63
+ // closes the toast in that case.
61
64
  onAnimationEnd: (e) => {
62
- if (e.animationName === "toast-progress")
63
- onOpenChange?.(false);
65
+ if (e.animationName !== "toast-progress")
66
+ return;
67
+ if (e.elapsedTime * 1000 < effectiveDuration / 2)
68
+ return;
69
+ onOpenChange?.(false);
64
70
  } })) : null, dismissible ? (_jsx(ToastPrimitives.Close, { className: cn("absolute right-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-md", "text-foreground/60 hover:text-foreground", "focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background"), "aria-label": "Dismiss toast", children: _jsx(X, { className: "h-4 w-4" }) })) : null] }));
65
71
  });
66
72
  Toast.displayName = ToastPrimitives.Root.displayName;
@@ -1 +1 @@
1
- {"version":3,"file":"toast.js","sourceRoot":"","sources":["../../../src/react/components/toast.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEjC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC;;;;;GAKG;AACH,SAAS,cAAc;IACrB,oEAAoE;IACpE,OAAO,CACL,gBACE,uBAAuB,EAAE;YACvB,MAAM,EAAE,6EAA6E;SACtF,GACD,CACH,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG,GAAG,CACvB,EAAE;AACA,OAAO;AACP,gLAAgL;AAChL,wBAAwB;AACxB,8DAA8D,EAC9D,8DAA8D,EAC9D,oFAAoF,EACpF,iEAAiE,EACjE,6FAA6F,EAC7F,uEAAuE,CACxE,EACD;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,qIAAqI;YAClJ,OAAO,EAAE,yHAAyH;YAClI,OAAO,EAAE,yHAAyH;YAClI,KAAK,EAAE,qIAAqI;SAC7I;KACF;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;KACnB;CACF,CACF,CAAC;AAEF,MAAM,aAAa,GAAG,eAAe,CAAC,QAAQ,CAAC;AAE/C,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAGpC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,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,EAAE,CACX,mFAAmF,EACnF,0CAA0C,EAC1C,oGAAoG,EACpG,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC,CAAC;AACH,UAAU,CAAC,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC;AAE3D,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAGjC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAClC,KAAC,eAAe,CAAC,KAAK,IAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CACxF,CAAC,CAAC;AACH,UAAU,CAAC,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC;AAE3D,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAGvC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAClC,KAAC,eAAe,CAAC,WAAW,IAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CAC9F,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC,WAAW,CAAC;AAMvE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import * as React from \"react\";\nimport * as ToastPrimitives from \"@radix-ui/react-toast\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils.js\";\n\n/**\n * ui-core Toasts are consumed by multiple apps.\n *\n * Do NOT rely on app-level CSS (@apply) for critical positioning/visibility.\n * Keep all required styling inline as Tailwind utility classes.\n */\nfunction ToastKeyframes() {\n // Inject a tiny global keyframe used by the optional countdown bar.\n return (\n <style\n dangerouslySetInnerHTML={{\n __html: `@keyframes toast-progress{from{transform:scaleX(1)}to{transform:scaleX(0)}}`,\n }}\n />\n );\n}\n\nconst toastVariants = cva(\n cn(\n // base\n \"pointer-events-auto relative flex w-full items-start justify-between gap-2 overflow-hidden rounded-md border bg-background p-4 text-foreground elevation-raised transition-all\",\n // radix state/animation\n \"data-[state=open]:animate-in data-[state=closed]:animate-out\",\n \"data-[state=closed]:fade-out-80 data-[state=open]:fade-in-80\",\n \"data-[state=closed]:slide-out-to-top-full data-[state=open]:slide-in-from-top-full\",\n \"data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)]\",\n \"data-[swipe=cancel]:translate-x-0 data-[swipe=cancel]:transition-[transform_200ms_ease-out]\",\n \"data-[swipe=end]:animate-out data-[swipe=end]:slide-out-to-right-full\"\n ),\n {\n variants: {\n variant: {\n default: \"\",\n destructive: \"border-[color:var(--toast-destructive-border)] bg-[color:var(--toast-destructive)] text-[color:var(--toast-destructive-foreground)]\",\n success: \"border-[color:var(--toast-success-border)] bg-[color:var(--toast-success)] text-[color:var(--toast-success-foreground)]\",\n warning: \"border-[color:var(--toast-warning-border)] bg-[color:var(--toast-warning)] text-[color:var(--toast-warning-foreground)]\",\n error: \"border-[color:var(--toast-destructive-border)] bg-[color:var(--toast-destructive)] text-[color:var(--toast-destructive-foreground)]\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n);\n\nconst ToastProvider = ToastPrimitives.Provider;\n\nconst ToastViewport = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Viewport>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Viewport\n ref={ref}\n className={cn(\n \"fixed top-0 left-1/2 -translate-x-1/2 z-[100] flex max-h-screen w-full flex-col gap-2 p-4\",\n \"sm:max-w-[480px] md:max-w-[600px]\",\n className\n )}\n {...props}\n />\n));\nToastViewport.displayName = ToastPrimitives.Viewport.displayName;\n\ntype ToastRootProps = React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &\n VariantProps<typeof toastVariants> & {\n /** ms; ignored when `persistent` is true */\n duration?: number;\n /** show X button */\n dismissible?: boolean;\n /** When true: no auto-dismiss, no countdown bar. */\n persistent?: boolean;\n };\n\nconst Toast = React.forwardRef<React.ElementRef<typeof ToastPrimitives.Root>, ToastRootProps>(\n ({ className, variant, duration, dismissible = true, persistent = false, style, children, onOpenChange, ...props }, ref) => {\n // Caller is the source of truth for duration. Persistent toasts disable\n // the auto-dismiss entirely by passing `Infinity` to Radix.\n const effectiveDuration = persistent ? Infinity : (duration ?? 5000);\n // pass duration to Radix AND to CSS countdown bar\n const mergedStyle: React.CSSProperties = {\n ...(style as React.CSSProperties),\n [\"--toast-duration\" as any]: `${effectiveDuration}ms`,\n };\n\n return (\n <ToastPrimitives.Root\n ref={ref}\n duration={effectiveDuration}\n data-variant={variant}\n data-persistent={persistent ? \"\" : undefined}\n className={cn(toastVariants({ variant }), className)}\n style={mergedStyle}\n onOpenChange={onOpenChange}\n {...props}\n >\n <ToastKeyframes />\n {children}\n\n {/* countdown bar — hidden entirely for persistent toasts */}\n {!persistent ? (\n <div\n aria-hidden\n className={cn(\"absolute bottom-0 left-0 h-1 w-full bg-foreground/30\", \"origin-left\")}\n style={{\n animationName: \"toast-progress\",\n animationDuration: `${effectiveDuration}ms`,\n animationTimingFunction: \"linear\",\n animationFillMode: \"forwards\",\n }}\n // Radix's own auto-close timer PAUSES on pointer-over the viewport,\n // focus, and window-blur — but this CSS bar does not. When the bar\n // empties we must dismiss regardless of Radix's paused timer, so the\n // toast never lingers after the countdown visibly reaches zero.\n // Radix's `duration` above remains a motion-independent backstop\n // (e.g. under prefers-reduced-motion where this event may not fire).\n onAnimationEnd={(e) => {\n if (e.animationName === \"toast-progress\") onOpenChange?.(false);\n }}\n />\n ) : null}\n\n {/* dismiss button */}\n {dismissible ? (\n <ToastPrimitives.Close\n className={cn(\n \"absolute right-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-md\",\n \"text-foreground/60 hover:text-foreground\",\n \"focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background\"\n )}\n aria-label=\"Dismiss toast\"\n >\n <X className=\"h-4 w-4\" />\n </ToastPrimitives.Close>\n ) : null}\n </ToastPrimitives.Root>\n );\n }\n);\nToast.displayName = ToastPrimitives.Root.displayName;\n\nconst ToastAction = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Action>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Action ref={ref} className={cn(className)} {...props} />\n));\nToastAction.displayName = ToastPrimitives.Action.displayName;\n\nconst ToastClose = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Close>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Close\n ref={ref}\n className={cn(\n \"absolute right-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-md\",\n \"text-foreground/60 hover:text-foreground\",\n \"focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background\",\n className\n )}\n {...props}\n />\n));\nToastClose.displayName = ToastPrimitives.Close.displayName;\n\nconst ToastTitle = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Title>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Title ref={ref} className={cn(\"break-words\", className)} {...props} />\n));\nToastTitle.displayName = ToastPrimitives.Title.displayName;\n\nconst ToastDescription = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Description>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Description ref={ref} className={cn(\"break-words\", className)} {...props} />\n));\nToastDescription.displayName = ToastPrimitives.Description.displayName;\n\n/** Exported types for consumers */\nexport type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;\nexport type ToastActionElement = React.ReactElement<typeof ToastAction>;\n\nexport { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastClose, ToastAction };\n"]}
1
+ {"version":3,"file":"toast.js","sourceRoot":"","sources":["../../../src/react/components/toast.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEjC,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC;;;;;GAKG;AACH,SAAS,cAAc;IACrB,oEAAoE;IACpE,OAAO,CACL,gBACE,uBAAuB,EAAE;YACvB,MAAM,EAAE,6EAA6E;SACtF,GACD,CACH,CAAC;AACJ,CAAC;AAED,MAAM,aAAa,GAAG,GAAG,CACvB,EAAE;AACA,OAAO;AACP,gLAAgL;AAChL,wBAAwB;AACxB,8DAA8D,EAC9D,8DAA8D,EAC9D,oFAAoF,EACpF,iEAAiE,EACjE,6FAA6F,EAC7F,uEAAuE,CACxE,EACD;IACE,QAAQ,EAAE;QACR,OAAO,EAAE;YACP,OAAO,EAAE,EAAE;YACX,WAAW,EAAE,qIAAqI;YAClJ,OAAO,EAAE,yHAAyH;YAClI,OAAO,EAAE,yHAAyH;YAClI,KAAK,EAAE,qIAAqI;SAC7I;KACF;IACD,eAAe,EAAE;QACf,OAAO,EAAE,SAAS;KACnB;CACF,CACF,CAAC;AAEF,MAAM,aAAa,GAAG,eAAe,CAAC,QAAQ,CAAC;AAE/C,MAAM,aAAa,GAAG,KAAK,CAAC,UAAU,CAGpC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAClC,KAAC,eAAe,CAAC,QAAQ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,EAAE,CAAC,CAClC,KAAC,eAAe,CAAC,KAAK,IACpB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CACX,mFAAmF,EACnF,0CAA0C,EAC1C,oGAAoG,EACpG,SAAS,CACV,KACG,KAAK,GACT,CACH,CAAC,CAAC;AACH,UAAU,CAAC,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC;AAE3D,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAGjC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAClC,KAAC,eAAe,CAAC,KAAK,IAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CACxF,CAAC,CAAC;AACH,UAAU,CAAC,WAAW,GAAG,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC;AAE3D,MAAM,gBAAgB,GAAG,KAAK,CAAC,UAAU,CAGvC,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAClC,KAAC,eAAe,CAAC,WAAW,IAAC,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,CAAC,KAAM,KAAK,GAAI,CAC9F,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC,WAAW,CAAC;AAMvE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC","sourcesContent":["import * as React from \"react\";\nimport * as ToastPrimitives from \"@radix-ui/react-toast\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { X } from \"lucide-react\";\n\nimport { cn } from \"../../lib/utils.js\";\n\n/**\n * ui-core Toasts are consumed by multiple apps.\n *\n * Do NOT rely on app-level CSS (@apply) for critical positioning/visibility.\n * Keep all required styling inline as Tailwind utility classes.\n */\nfunction ToastKeyframes() {\n // Inject a tiny global keyframe used by the optional countdown bar.\n return (\n <style\n dangerouslySetInnerHTML={{\n __html: `@keyframes toast-progress{from{transform:scaleX(1)}to{transform:scaleX(0)}}`,\n }}\n />\n );\n}\n\nconst toastVariants = cva(\n cn(\n // base\n \"pointer-events-auto relative flex w-full items-start justify-between gap-2 overflow-hidden rounded-md border bg-background p-4 text-foreground elevation-raised transition-all\",\n // radix state/animation\n \"data-[state=open]:animate-in data-[state=closed]:animate-out\",\n \"data-[state=closed]:fade-out-80 data-[state=open]:fade-in-80\",\n \"data-[state=closed]:slide-out-to-top-full data-[state=open]:slide-in-from-top-full\",\n \"data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)]\",\n \"data-[swipe=cancel]:translate-x-0 data-[swipe=cancel]:transition-[transform_200ms_ease-out]\",\n \"data-[swipe=end]:animate-out data-[swipe=end]:slide-out-to-right-full\"\n ),\n {\n variants: {\n variant: {\n default: \"\",\n destructive: \"border-[color:var(--toast-destructive-border)] bg-[color:var(--toast-destructive)] text-[color:var(--toast-destructive-foreground)]\",\n success: \"border-[color:var(--toast-success-border)] bg-[color:var(--toast-success)] text-[color:var(--toast-success-foreground)]\",\n warning: \"border-[color:var(--toast-warning-border)] bg-[color:var(--toast-warning)] text-[color:var(--toast-warning-foreground)]\",\n error: \"border-[color:var(--toast-destructive-border)] bg-[color:var(--toast-destructive)] text-[color:var(--toast-destructive-foreground)]\",\n },\n },\n defaultVariants: {\n variant: \"default\",\n },\n }\n);\n\nconst ToastProvider = ToastPrimitives.Provider;\n\nconst ToastViewport = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Viewport>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Viewport>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Viewport\n ref={ref}\n className={cn(\n \"fixed top-0 left-1/2 -translate-x-1/2 z-[100] flex max-h-screen w-full flex-col gap-2 p-4\",\n \"sm:max-w-[480px] md:max-w-[600px]\",\n className\n )}\n {...props}\n />\n));\nToastViewport.displayName = ToastPrimitives.Viewport.displayName;\n\ntype ToastRootProps = React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &\n VariantProps<typeof toastVariants> & {\n /** ms; ignored when `persistent` is true */\n duration?: number;\n /** show X button */\n dismissible?: boolean;\n /** When true: no auto-dismiss, no countdown bar. */\n persistent?: boolean;\n };\n\nconst Toast = React.forwardRef<React.ElementRef<typeof ToastPrimitives.Root>, ToastRootProps>(\n ({ className, variant, duration, dismissible = true, persistent = false, style, children, onOpenChange, ...props }, ref) => {\n // Caller is the source of truth for duration. Persistent toasts disable\n // the auto-dismiss entirely by passing `Infinity` to Radix.\n const effectiveDuration = persistent ? Infinity : (duration ?? 5000);\n // pass duration to Radix AND to CSS countdown bar\n const mergedStyle: React.CSSProperties = {\n ...(style as React.CSSProperties),\n [\"--toast-duration\" as any]: `${effectiveDuration}ms`,\n };\n\n return (\n <ToastPrimitives.Root\n ref={ref}\n duration={effectiveDuration}\n data-variant={variant}\n data-persistent={persistent ? \"\" : undefined}\n className={cn(toastVariants({ variant }), className)}\n style={mergedStyle}\n onOpenChange={onOpenChange}\n {...props}\n >\n <ToastKeyframes />\n {children}\n\n {/* countdown bar — hidden entirely for persistent toasts */}\n {!persistent ? (\n <div\n aria-hidden\n className={cn(\"absolute bottom-0 left-0 h-1 w-full bg-foreground/30\", \"origin-left\")}\n style={{\n animationName: \"toast-progress\",\n animationDuration: `${effectiveDuration}ms`,\n animationTimingFunction: \"linear\",\n animationFillMode: \"forwards\",\n }}\n // Radix's own auto-close timer PAUSES on pointer-over the viewport,\n // focus, and window-blur — but this CSS bar does not. When the bar\n // empties we must dismiss regardless of Radix's paused timer, so the\n // toast never lingers after the countdown visibly reaches zero.\n // Only a bar that ran its course counts as empty: a reduced-motion\n // stylesheet that collapses every animation to near zero ends this one\n // at once, and closing then would hide the toast before anyone reads\n // it. Radix's `duration` above is the motion-independent timer that\n // closes the toast in that case.\n onAnimationEnd={(e) => {\n if (e.animationName !== \"toast-progress\") return;\n if (e.elapsedTime * 1000 < effectiveDuration / 2) return;\n onOpenChange?.(false);\n }}\n />\n ) : null}\n\n {/* dismiss button */}\n {dismissible ? (\n <ToastPrimitives.Close\n className={cn(\n \"absolute right-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-md\",\n \"text-foreground/60 hover:text-foreground\",\n \"focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background\"\n )}\n aria-label=\"Dismiss toast\"\n >\n <X className=\"h-4 w-4\" />\n </ToastPrimitives.Close>\n ) : null}\n </ToastPrimitives.Root>\n );\n }\n);\nToast.displayName = ToastPrimitives.Root.displayName;\n\nconst ToastAction = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Action>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Action>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Action ref={ref} className={cn(className)} {...props} />\n));\nToastAction.displayName = ToastPrimitives.Action.displayName;\n\nconst ToastClose = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Close>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Close>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Close\n ref={ref}\n className={cn(\n \"absolute right-2 top-2 inline-flex h-7 w-7 items-center justify-center rounded-md\",\n \"text-foreground/60 hover:text-foreground\",\n \"focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background\",\n className\n )}\n {...props}\n />\n));\nToastClose.displayName = ToastPrimitives.Close.displayName;\n\nconst ToastTitle = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Title>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Title>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Title ref={ref} className={cn(\"break-words\", className)} {...props} />\n));\nToastTitle.displayName = ToastPrimitives.Title.displayName;\n\nconst ToastDescription = React.forwardRef<\n React.ElementRef<typeof ToastPrimitives.Description>,\n React.ComponentPropsWithoutRef<typeof ToastPrimitives.Description>\n>(({ className, ...props }, ref) => (\n <ToastPrimitives.Description ref={ref} className={cn(\"break-words\", className)} {...props} />\n));\nToastDescription.displayName = ToastPrimitives.Description.displayName;\n\n/** Exported types for consumers */\nexport type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;\nexport type ToastActionElement = React.ReactElement<typeof ToastAction>;\n\nexport { ToastProvider, ToastViewport, Toast, ToastTitle, ToastDescription, ToastClose, ToastAction };\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttt-productions/ui-core",
3
- "version": "0.11.31",
3
+ "version": "0.11.32",
4
4
  "description": "Shared UI components for TTT Productions projects",
5
5
  "repository": {
6
6
  "type": "git",