12
packages/schemas/features/blocks/inputs/date/constants.ts
Normal file
12
packages/schemas/features/blocks/inputs/date/constants.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { defaultButtonLabel } from '../constants'
|
||||
import { DateInputBlock } from './schema'
|
||||
|
||||
export const defaultDateInputOptions = {
|
||||
hasTime: false,
|
||||
isRange: false,
|
||||
labels: { button: defaultButtonLabel, from: 'From:', to: 'To:' },
|
||||
format: 'dd/MM/yyyy',
|
||||
formatWithTime: 'dd/MM/yyyy HH:mm',
|
||||
} as const satisfies DateInputBlock['options'] & {
|
||||
formatWithTime: string
|
||||
}
|
1
packages/schemas/features/blocks/inputs/date/index.ts
Normal file
1
packages/schemas/features/blocks/inputs/date/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './schema'
|
29
packages/schemas/features/blocks/inputs/date/schema.ts
Normal file
29
packages/schemas/features/blocks/inputs/date/schema.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { z } from 'zod'
|
||||
import { optionBaseSchema, blockBaseSchema } from '../../shared'
|
||||
import { InputBlockType } from '../constants'
|
||||
|
||||
export const dateInputOptionsSchema = optionBaseSchema.merge(
|
||||
z.object({
|
||||
labels: z
|
||||
.object({
|
||||
button: z.string().optional(),
|
||||
from: z.string().optional(),
|
||||
to: z.string().optional(),
|
||||
})
|
||||
.optional(),
|
||||
hasTime: z.boolean().optional(),
|
||||
isRange: z.boolean().optional(),
|
||||
format: z.string().optional(),
|
||||
min: z.string().optional(),
|
||||
max: z.string().optional(),
|
||||
})
|
||||
)
|
||||
|
||||
export const dateInputSchema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([InputBlockType.DATE]),
|
||||
options: dateInputOptionsSchema.optional(),
|
||||
})
|
||||
)
|
||||
|
||||
export type DateInputBlock = z.infer<typeof dateInputSchema>
|
Reference in New Issue
Block a user