import React from "react"; import { resolveArrayProperty } from "../../util"; import { ResolvedProperty } from "../../types"; import { useCustomizationController } from "../../hooks"; import { PreviewSize, PropertyPreviewProps } from "../PropertyPreviewProps"; import { PropertyPreview } from "../PropertyPreview"; import { ErrorBoundary } from "../../components"; /** * @group Preview components */ export function ArrayOfStorageComponentsPreview({ propertyKey, // entity, 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 !== "string") throw Error("Picked wrong preview component ArrayOfStorageComponentsPreview"); const childSize: PreviewSize = size === "medium" ? "small" : "tiny"; return (
{value && value.map((v, index) => } size={childSize}/> )}
); }