feat(inputs): ✨ Add URL input
This commit is contained in:
@ -54,6 +54,7 @@ const InputChatStep = ({
|
||||
case InputStepType.TEXT:
|
||||
case InputStepType.NUMBER:
|
||||
case InputStepType.EMAIL:
|
||||
case InputStepType.URL:
|
||||
return <TextForm step={step} onSubmit={handleSubmit} />
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
import { EmailInputStep, NumberInputStep, TextInputStep } from 'models'
|
||||
import {
|
||||
EmailInputStep,
|
||||
NumberInputStep,
|
||||
TextInputStep,
|
||||
UrlInputStep,
|
||||
} from 'models'
|
||||
import React, { FormEvent, useState } from 'react'
|
||||
import { SendIcon } from '../../../../../assets/icons'
|
||||
import { TextInput } from './TextInputContent'
|
||||
|
||||
type TextFormProps = {
|
||||
step: TextInputStep | EmailInputStep | NumberInputStep
|
||||
step: TextInputStep | EmailInputStep | NumberInputStep | UrlInputStep
|
||||
onSubmit: (value: string) => void
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ import {
|
||||
EmailInputStep,
|
||||
NumberInputStep,
|
||||
InputStepType,
|
||||
UrlInputStep,
|
||||
} from 'models'
|
||||
import React, {
|
||||
ChangeEvent,
|
||||
@ -13,7 +14,7 @@ import React, {
|
||||
} from 'react'
|
||||
|
||||
type TextInputProps = {
|
||||
step: TextInputStep | EmailInputStep | NumberInputStep
|
||||
step: TextInputStep | EmailInputStep | NumberInputStep | UrlInputStep
|
||||
onChange: (value: string) => void
|
||||
}
|
||||
|
||||
@ -77,6 +78,16 @@ export const TextInput = ({ step, onChange }: TextInputProps) => {
|
||||
/>
|
||||
)
|
||||
}
|
||||
case InputStepType.URL: {
|
||||
return (
|
||||
<ShortTextInput
|
||||
ref={inputRef}
|
||||
placeholder={step.options?.labels?.placeholder ?? 'Type your URL...'}
|
||||
onChange={handleInputChange}
|
||||
type="url"
|
||||
/>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,11 @@ export type Step = StartStep | BubbleStep | InputStep
|
||||
|
||||
export type BubbleStep = TextStep
|
||||
|
||||
export type InputStep = TextInputStep | NumberInputStep | EmailInputStep
|
||||
export type InputStep =
|
||||
| TextInputStep
|
||||
| NumberInputStep
|
||||
| EmailInputStep
|
||||
| UrlInputStep
|
||||
|
||||
export type StepType = 'start' | BubbleStepType | InputStepType
|
||||
|
||||
@ -14,6 +18,7 @@ export enum InputStepType {
|
||||
TEXT = 'text input',
|
||||
NUMBER = 'number input',
|
||||
EMAIL = 'email input',
|
||||
URL = 'url input',
|
||||
}
|
||||
|
||||
export type StepBase = { id: string; blockId: string; target?: Target }
|
||||
@ -43,8 +48,15 @@ export type EmailInputStep = StepBase & {
|
||||
options?: EmailInputOptions
|
||||
}
|
||||
|
||||
export type UrlInputStep = StepBase & {
|
||||
type: InputStepType.URL
|
||||
options?: UrlInputOptions
|
||||
}
|
||||
|
||||
export type EmailInputOptions = InputOptionsBase
|
||||
|
||||
export type UrlInputOptions = InputOptionsBase
|
||||
|
||||
type InputOptionsBase = {
|
||||
labels?: { placeholder?: string; button?: string }
|
||||
}
|
||||
|
Reference in New Issue
Block a user