'use client'; import {cloneElement, Component, createElement, isValidElement, ReactNode} from 'react'; import {Content, Heading, InlineAlert} from '@react-spectrum/s2'; import {style} from '@react-spectrum/s2/style' with {type: 'macro'}; interface ExampleOutputProps { component?: any; props?: Record; align?: 'start' | 'center' | 'end'; orientation?: 'horizontal' | 'vertical'; } export function ExampleOutput({ component, props = {}, align = 'center', orientation = 'horizontal' }: ExampleOutputProps) { return (
{isValidElement(component) ? cloneElement(component, props) : createElement(component, props)}
); } function getBackgroundColor(staticColor: 'black' | 'white' | undefined) { if (staticColor === 'black') { return 'linear-gradient(to right,#ddd6fe,#fbcfe8)'; } else if (staticColor === 'white') { return 'linear-gradient(to right,#0f172a,#334155)'; } return undefined; } class ErrorBoundary extends Component<{children: ReactNode}, {error: string | null}> { constructor(props) { super(props); this.state = {error: null}; } static getDerivedStateFromError(e: Error) { return {error: e.message}; } render() { if (this.state.error) { return ( Error {this.state.error} ); } return this.props.children; } }