@remit/ui 0.0.240 → 0.0.241

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.
@@ -13,6 +13,7 @@ export interface ErrorBannerEntry {
13
13
  title: string;
14
14
  detail?: string;
15
15
  action?: ErrorBannerAction;
16
+ onRetry?: () => void;
16
17
  createdAt: number;
17
18
  }
18
19
  interface ErrorBannerProps {
@@ -21,7 +22,8 @@ interface ErrorBannerProps {
21
22
  title: string;
22
23
  detail?: string;
23
24
  action?: ErrorBannerAction;
25
+ onRetry?: () => void;
24
26
  onDismiss: (id: string) => void;
25
27
  }
26
- export declare const ErrorBanner: ({ id, severity, title, detail, action, onDismiss, }: ErrorBannerProps) => import("react").JSX.Element;
28
+ export declare const ErrorBanner: ({ id, severity, title, detail, action, onRetry, onDismiss, }: ErrorBannerProps) => import("react").JSX.Element;
27
29
  export {};
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { CircleAlert, Info, TriangleAlert, X } from "../icons.js";
3
3
  import { cn } from "../lib/cn.js";
4
+ import { Button } from "./button.js";
4
5
  const SEVERITY_STYLES = {
5
6
  error: {
6
7
  container: "border-danger/50 bg-danger-soft",
@@ -28,12 +29,15 @@ const SEVERITY_LABEL = {
28
29
  warning: "Warning",
29
30
  info: "Information",
30
31
  };
31
- export const ErrorBanner = ({ id, severity, title, detail, action, onDismiss, }) => {
32
+ export const ErrorBanner = ({ id, severity, title, detail, action, onRetry, onDismiss, }) => {
32
33
  const styles = SEVERITY_STYLES[severity];
33
34
  const Icon = SEVERITY_ICONS[severity];
34
35
  return (_jsxs("div", { role: severity === "error" ? "alert" : "status", "aria-live": severity === "error" ? "assertive" : "polite", className: cn(
35
36
  // Opaque, not translucent: a banner overlaps the toolbar and the
36
37
  // message list, and see-through text on top of see-through text is
37
38
  // unreadable (issue #55).
38
- "pointer-events-auto flex items-start gap-3 rounded-md border bg-canvas px-3 py-2 shadow-lg", styles.container), children: [_jsx(Icon, { className: cn("size-5 shrink-0 mt-0.5", styles.icon), "aria-hidden": "true" }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("p", { className: cn("text-sm font-medium", styles.title), children: title }), detail && (_jsx("p", { className: "mt-0.5 text-xs text-fg-muted break-words", children: detail })), action && (_jsx("a", { href: action.href, target: "_blank", rel: "noopener noreferrer", className: "mt-1 inline-block text-xs font-medium text-accent-2 underline underline-offset-2", children: action.label }))] }), _jsx("button", { type: "button", onClick: () => onDismiss(id), className: "shrink-0 rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors", "aria-label": `Dismiss ${SEVERITY_LABEL[severity].toLowerCase()}`, children: _jsx(X, { className: "size-4", "aria-hidden": "true" }) })] }));
39
+ "pointer-events-auto flex items-start gap-3 rounded-md border bg-canvas px-3 py-2 shadow-lg", styles.container), children: [_jsx(Icon, { className: cn("size-5 shrink-0 mt-0.5", styles.icon), "aria-hidden": "true" }), _jsxs("div", { className: "flex-1 min-w-0", children: [_jsx("p", { className: cn("text-sm font-medium", styles.title), children: title }), detail && (_jsx("p", { className: "mt-0.5 text-xs text-fg-muted break-words", children: detail })), (onRetry || action) && (_jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-x-4 gap-y-1", children: [onRetry && (_jsx(Button, { variant: "secondary", size: "sm", onClick: () => {
40
+ onDismiss(id);
41
+ onRetry();
42
+ }, children: "Try again" })), action && (_jsx("a", { href: action.href, target: "_blank", rel: "noopener noreferrer", className: "inline-block text-xs font-medium text-accent-2 underline underline-offset-2", children: action.label }))] }))] }), _jsx("button", { type: "button", onClick: () => onDismiss(id), className: "shrink-0 rounded-md p-1 text-fg-muted hover:bg-surface-raised hover:text-fg transition-colors", "aria-label": `Dismiss ${SEVERITY_LABEL[severity].toLowerCase()}`, children: _jsx(X, { className: "size-4", "aria-hidden": "true" }) })] }));
39
43
  };
@@ -3,5 +3,5 @@ import { ErrorBanner } from "./ErrorBanner.js";
3
3
  export const ErrorBannerStack = ({ errors, onDismiss, }) => {
4
4
  if (errors.length === 0)
5
5
  return null;
6
- return (_jsx("section", { "aria-label": "Notifications", className: "pointer-events-none fixed inset-x-0 top-0 z-[60] flex flex-col items-center gap-2 px-4 pt-[calc(1rem+env(safe-area-inset-top,0px))] sm:items-end sm:pr-6", children: _jsx("div", { className: "flex w-full max-w-md flex-col gap-2", children: errors.map((entry) => (_jsx(ErrorBanner, { id: entry.id, severity: entry.severity, title: entry.title, detail: entry.detail, action: entry.action, onDismiss: onDismiss }, entry.id))) }) }));
6
+ return (_jsx("section", { "aria-label": "Notifications", className: "pointer-events-none fixed inset-x-0 top-0 z-[60] flex flex-col items-center gap-2 px-4 pt-[calc(1rem+env(safe-area-inset-top,0px))] sm:items-end sm:pr-6", children: _jsx("div", { className: "flex w-full max-w-md flex-col gap-2", children: errors.map((entry) => (_jsx(ErrorBanner, { id: entry.id, severity: entry.severity, title: entry.title, detail: entry.detail, action: entry.action, onRetry: entry.onRetry, onDismiss: onDismiss }, entry.id))) }) }));
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.240",
3
+ "version": "0.0.241",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "**/*.css",