2022-06-07 08:49:12 +02:00
|
|
|
import { z } from 'zod'
|
2023-11-08 15:34:16 +01:00
|
|
|
import { variableStringSchema } from '../../../utils'
|
|
|
|
import { optionBaseSchema, blockBaseSchema } from '../../shared'
|
|
|
|
import { InputBlockType } from '../constants'
|
|
|
|
import { textInputOptionsBaseSchema } from '../text'
|
2022-06-07 08:49:12 +02:00
|
|
|
|
|
|
|
export const numberInputOptionsSchema = optionBaseSchema
|
2023-03-14 16:42:12 +01:00
|
|
|
.merge(textInputOptionsBaseSchema)
|
|
|
|
.merge(
|
2022-06-07 08:49:12 +02:00
|
|
|
z.object({
|
2023-06-15 15:20:46 +02:00
|
|
|
min: z.number().or(variableStringSchema).optional(),
|
|
|
|
max: z.number().or(variableStringSchema).optional(),
|
|
|
|
step: z.number().or(variableStringSchema).optional(),
|
2022-06-07 08:49:12 +02:00
|
|
|
})
|
|
|
|
)
|
|
|
|
|
2023-03-14 16:42:12 +01:00
|
|
|
export const numberInputSchema = blockBaseSchema.merge(
|
2022-06-07 08:49:12 +02:00
|
|
|
z.object({
|
2022-06-11 07:27:38 +02:00
|
|
|
type: z.enum([InputBlockType.NUMBER]),
|
2023-11-08 15:34:16 +01:00
|
|
|
options: numberInputOptionsSchema.optional(),
|
2022-06-07 08:49:12 +02:00
|
|
|
})
|
|
|
|
)
|
|
|
|
|
2022-06-11 07:27:38 +02:00
|
|
|
export type NumberInputBlock = z.infer<typeof numberInputSchema>
|