2022-06-07 08:49:12 +02:00
|
|
|
import { z } from 'zod'
|
2023-01-25 11:27:47 +01:00
|
|
|
import { optionBaseSchema, blockBaseSchema } from '../baseSchemas'
|
|
|
|
import { defaultButtonLabel } from './constants'
|
|
|
|
import { InputBlockType } from './enums'
|
2022-06-07 08:49:12 +02:00
|
|
|
import { textInputOptionsBaseSchema } from './text'
|
|
|
|
|
|
|
|
export const urlInputOptionsSchema = optionBaseSchema
|
2023-03-14 16:42:12 +01:00
|
|
|
.merge(textInputOptionsBaseSchema)
|
|
|
|
.merge(
|
2022-06-07 08:49:12 +02:00
|
|
|
z.object({
|
|
|
|
retryMessageContent: z.string(),
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
2023-03-14 16:42:12 +01:00
|
|
|
export const urlInputSchema = blockBaseSchema.merge(
|
2022-06-07 08:49:12 +02:00
|
|
|
z.object({
|
2022-06-11 07:27:38 +02:00
|
|
|
type: z.enum([InputBlockType.URL]),
|
2022-06-07 08:49:12 +02:00
|
|
|
options: urlInputOptionsSchema,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
export const defaultUrlInputOptions: UrlInputOptions = {
|
|
|
|
labels: {
|
|
|
|
button: defaultButtonLabel,
|
|
|
|
placeholder: 'Type a URL...',
|
|
|
|
},
|
|
|
|
retryMessageContent:
|
|
|
|
"This URL doesn't seem to be valid. Can you type it again?",
|
|
|
|
}
|
|
|
|
|
2022-06-11 07:27:38 +02:00
|
|
|
export type UrlInputBlock = z.infer<typeof urlInputSchema>
|
2022-06-07 08:49:12 +02:00
|
|
|
export type UrlInputOptions = z.infer<typeof urlInputOptionsSchema>
|