@gram-ai/elements 1.20.1 → 1.20.2

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.
@@ -0,0 +1,8 @@
1
+ import { Meta, StoryFn } from '@storybook/react-vite';
2
+ import { Chat } from '..';
3
+ declare const meta: Meta<typeof Chat>;
4
+ export default meta;
5
+ type Story = StoryFn<typeof Chat>;
6
+ export declare const Modal: Story;
7
+ export declare const Standalone: Story;
8
+ export declare const Sidecar: Story;
@@ -0,0 +1,28 @@
1
+ import { Component, ErrorInfo, ReactNode } from 'react';
2
+ interface ErrorBoundaryProps {
3
+ children: ReactNode;
4
+ fallback?: ReactNode;
5
+ onError?: (error: Error, errorInfo: ErrorInfo) => void;
6
+ onReset?: () => void;
7
+ }
8
+ interface ErrorBoundaryState {
9
+ hasError: boolean;
10
+ error: Error | null;
11
+ resetKey: number;
12
+ }
13
+ /**
14
+ * Global error boundary for the Elements library. Catches unexpected errors and renders a fallback UI.
15
+ * We wrap the assistant-modal, assistant-sidecar, and chat components with this error boundary.
16
+ * Each variant needs to have the error boundary rendered at the appropriate level e.g if using
17
+ * the widget variant, then the error screen must be rendered within the widget modal.
18
+ * TODO: We should add more granular error boundaries (e.g wrapping AssistantMessage, ThreadWelcome, etc.)
19
+ * TODO: We should also wrap ChatHistory, which may yield its own errors.
20
+ */
21
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
22
+ constructor(props: ErrorBoundaryProps);
23
+ static getDerivedStateFromError(error: Error): Partial<ErrorBoundaryState>;
24
+ componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
25
+ handleRetry: () => void;
26
+ render(): ReactNode;
27
+ }
28
+ export {};