import { z } from "zod/mini" export const FieldContentType = "FieldContent" as const export const SelectFieldType = "Select" as const // Text export const TextContentSchema = z.object({ type: z.literal("Text"), value: z.string().check(z.trim()), __TYPE__: z.literal(FieldContentType), }) // Color export const ColorContentSchema = z.object({ type: z.literal("Color"), value: z.string().check(z.trim()), __TYPE__: z.literal(FieldContentType), }) // Date export const DateContentSchema = z.object({ type: z.literal("Date"), value: z.string().check(z.trim()), __TYPE__: z.literal(FieldContentType), }) // Timestamp export const TimestampContentSchema = z.object({ type: z.literal("Timestamp"), value: z.string().check(z.trim()), __TYPE__: z.literal(FieldContentType), }) // Number export const NumberContentSchema = z.object({ type: z.literal("Number"), value: z.string().check(z.trim()), __TYPE__: z.literal(FieldContentType), }) // Range export const RangeContentSchema = z.object({ type: z.literal("Range"), value: z.string().check(z.trim()), __TYPE__: z.literal(FieldContentType), }) // Select export const SelectContentSchema = z.object({ type: z.literal(SelectFieldType), value: z.string().check(z.trim()), __TYPE__: z.literal(FieldContentType), }) // Fields export const FieldContentSchema = z.discriminatedUnion("type", [ TextContentSchema, ColorContentSchema, DateContentSchema, TimestampContentSchema, NumberContentSchema, RangeContentSchema, SelectContentSchema, ]) export type TextContent = z.infer export type ColorContent = z.infer export type DateContent = z.infer export type TimestampContent = z.infer export type NumberContent = z.infer export type RangeContent = z.infer export type SelectContent = z.infer export type FieldContent = | TextContent | ColorContent | DateContent | TimestampContent | NumberContent | RangeContent | SelectContent