import React from "react"; import { ResolvedStringProperty } from "../../types"; import { resolveArrayProperty } from "../../util"; import { PropertyPreviewProps, StringPropertyPreview } from "../../preview"; import { useCustomizationController } from "../../hooks"; import { ErrorBoundary } from "../../components"; /** * @group Preview components */ export function ArrayOfStringsPreview({ propertyKey, value, property: inputProperty, // entity, size }: PropertyPreviewProps) { const customizationController = useCustomizationController(); const property = resolveArrayProperty({ propertyKey, property: inputProperty, fields: customizationController.propertyConfigs }); if (Array.isArray(property.of)) { throw Error("Using array properties instead of single one in `of` in ArrayProperty"); } if (!property.of || property.dataType !== "array" || property.of.dataType !== "string") throw Error("Picked wrong preview component ArrayOfStringsPreview"); if (value && !Array.isArray(value)) { return
{`Unexpected value: ${value}`}
; } const stringProperty = property.of as ResolvedStringProperty; return (
{value && value.map((v, index) =>
)}
); }