diff --git a/src/TypeBuilder.php b/src/TypeBuilder.php index 4a286e3..46c6a49 100644 --- a/src/TypeBuilder.php +++ b/src/TypeBuilder.php @@ -63,6 +63,14 @@ final class TypeBuilder self::EMBED, ]; + public const SLICE_DISPLAY_LIST = 'list'; + public const SLICE_DISPLAY_GRID = 'grid'; + + private const SLICE_DISPLAY = [ + self::SLICE_DISPLAY_GRID, + self::SLICE_DISPLAY_LIST, + ]; + /** @return array */ public static function uid(string $label, ?string $placeholder = null): array { @@ -388,13 +396,17 @@ public static function slice( ?string $description = null, array $nonRepeatFields = [], array $repeatFields = [], - ?string $icon = null + ?string $icon = null, + ?string $displayFormat = null ): array { + Assert::nullOrInArray($displayFormat, self::SLICE_DISPLAY); + return array_filter([ 'type' => self::TYPE_SLICE, 'fieldset' => $label, 'description' => $description, 'icon' => $icon, + 'display' => $displayFormat, 'non-repeat' => $nonRepeatFields === [] ? null : $nonRepeatFields, 'repeat' => $repeatFields === [] ? null : $repeatFields, ]);