2
0
Files
bot/packages/models/src/features/blocks/inputs/number.ts

33 lines
851 B
TypeScript
Raw Normal View History

import { z } from 'zod'
import {
defaultButtonLabel,
2022-06-11 07:27:38 +02:00
InputBlockType,
optionBaseSchema,
2022-06-11 07:27:38 +02:00
blockBaseSchema,
} from '../shared'
import { textInputOptionsBaseSchema } from './text'
export const numberInputOptionsSchema = optionBaseSchema
.and(textInputOptionsBaseSchema)
.and(
z.object({
min: z.number().optional(),
max: z.number().optional(),
step: z.number().optional(),
})
)
2022-06-11 07:27:38 +02:00
export const numberInputSchema = blockBaseSchema.and(
z.object({
2022-06-11 07:27:38 +02:00
type: z.enum([InputBlockType.NUMBER]),
options: numberInputOptionsSchema,
})
)
export const defaultNumberInputOptions: NumberInputOptions = {
labels: { button: defaultButtonLabel, placeholder: 'Type a number...' },
}
2022-06-11 07:27:38 +02:00
export type NumberInputBlock = z.infer<typeof numberInputSchema>
export type NumberInputOptions = z.infer<typeof numberInputOptionsSchema>