2
0

feat(inputs): Add URL input

This commit is contained in:
Baptiste Arnaud
2022-01-09 07:36:29 +01:00
parent 8391bcce5e
commit ce1b23a0e7
10 changed files with 146 additions and 9 deletions

View File

@ -54,6 +54,7 @@ const InputChatStep = ({
case InputStepType.TEXT:
case InputStepType.NUMBER:
case InputStepType.EMAIL:
case InputStepType.URL:
return <TextForm step={step} onSubmit={handleSubmit} />
}
}

View File

@ -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
}

View File

@ -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"
/>
)
}
}
}