feat(engine): ✨ Add Rating input
This commit is contained in:
@ -7,3 +7,4 @@ export * from './date'
|
||||
export * from './choice'
|
||||
export * from './payment'
|
||||
export * from './phone'
|
||||
export * from './rating'
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
phoneNumberInputOptionsSchema,
|
||||
phoneNumberInputStepSchema,
|
||||
} from './phone'
|
||||
import { ratingInputOptionsSchema, ratingInputStepSchema } from './rating'
|
||||
import { textInputOptionsSchema, textInputSchema } from './text'
|
||||
import { urlInputOptionsSchema, urlInputSchema } from './url'
|
||||
|
||||
@ -22,6 +23,7 @@ export const inputStepOptionsSchema = textInputOptionsSchema
|
||||
.or(phoneNumberInputOptionsSchema)
|
||||
.or(dateInputOptionsSchema)
|
||||
.or(paymentInputOptionsSchema)
|
||||
.or(ratingInputOptionsSchema)
|
||||
|
||||
export const inputStepSchema = textInputSchema
|
||||
.or(numberInputSchema)
|
||||
@ -31,6 +33,7 @@ export const inputStepSchema = textInputSchema
|
||||
.or(phoneNumberInputStepSchema)
|
||||
.or(choiceInputSchema)
|
||||
.or(paymentInputSchema)
|
||||
.or(ratingInputStepSchema)
|
||||
|
||||
export type InputStep = z.infer<typeof inputStepSchema>
|
||||
export type InputStepOptions = z.infer<typeof inputStepOptionsSchema>
|
||||
|
41
packages/models/src/typebot/steps/input/rating.ts
Normal file
41
packages/models/src/typebot/steps/input/rating.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { z } from 'zod'
|
||||
import {
|
||||
defaultButtonLabel,
|
||||
InputStepType,
|
||||
optionBaseSchema,
|
||||
stepBaseSchema,
|
||||
} from '../shared'
|
||||
|
||||
export const defaultRatingInputOptions: RatingInputOptions = {
|
||||
buttonType: 'Numbers',
|
||||
length: 10,
|
||||
labels: { button: defaultButtonLabel },
|
||||
customIcon: { isEnabled: false },
|
||||
}
|
||||
|
||||
export const ratingInputOptionsSchema = optionBaseSchema.and(
|
||||
z.object({
|
||||
buttonType: z.literal('Icons').or(z.literal('Numbers')),
|
||||
length: z.number(),
|
||||
labels: z.object({
|
||||
left: z.string().optional(),
|
||||
right: z.string().optional(),
|
||||
middle: z.string().optional(),
|
||||
button: z.string(),
|
||||
}),
|
||||
customIcon: z.object({
|
||||
isEnabled: z.boolean(),
|
||||
svg: z.string().optional(),
|
||||
}),
|
||||
})
|
||||
)
|
||||
|
||||
export const ratingInputStepSchema = stepBaseSchema.and(
|
||||
z.object({
|
||||
type: z.literal(InputStepType.RATING),
|
||||
options: ratingInputOptionsSchema,
|
||||
})
|
||||
)
|
||||
|
||||
export type RatingInputStep = z.infer<typeof ratingInputStepSchema>
|
||||
export type RatingInputOptions = z.infer<typeof ratingInputOptionsSchema>
|
@ -39,6 +39,7 @@ export enum InputStepType {
|
||||
PHONE = 'phone number input',
|
||||
CHOICE = 'choice input',
|
||||
PAYMENT = 'payment input',
|
||||
RATING = 'rating input',
|
||||
}
|
||||
|
||||
export enum LogicStepType {
|
||||
|
Reference in New Issue
Block a user