import React from "react"; import { resolvePropertyEnum } from "../../util"; import { EnumValuesChip } from "../components/EnumValuesChip"; import { PreviewType } from "../../types"; import { UrlComponentPreview } from "../components/UrlComponentPreview"; import { PropertyPreviewProps } from "../PropertyPreviewProps"; import { ErrorBoundary } from "../../components"; import { Chip, cn, getColorSchemeForSeed } from "@firecms/ui"; /** * @group Preview components */ export function StringPropertyPreview({ propertyKey, value, property, size }: PropertyPreviewProps): React.ReactElement { if (property.enumValues) { const enumKey = value; const resolvedProperty = resolvePropertyEnum(property); return ; } else if (property.previewAsTag) { const colorScheme = getColorSchemeForSeed(propertyKey ?? ""); return ( {value} ); } else if (property.url) { return ( ); } else { if (!value) return <>; const lines = value.split("\n"); return value && value.includes("\n") ?
{lines.map((str, index) => {str} {index !== lines.length - 1 &&
}
)}
: (size === "tiny" ? {value} : <>{value} ); } }