import { ResolvedReferenceProperty } from "../../types"; import { resolveArrayProperty } from "../../util"; import { useCustomizationController } from "../../hooks"; import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps"; import { ReferencePreview } from "../components/ReferencePreview"; /** * @group Preview components */ export function ArrayOfReferencesPreview({ propertyKey, value, property: inputProperty, 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?.dataType !== "array" || !property.of || property.of.dataType !== "reference") throw Error("Picked wrong preview component ArrayOfReferencesPreview"); const childSize: PreviewSize = size === "medium" ? "small" : "tiny"; return (
{value && value.map((reference, index) => { const ofProperty = property.of as ResolvedReferenceProperty; return
; } )}
); }