-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce1b23a
commit 8cba7ff
Showing
21 changed files
with
305 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...ts/board/graph/BlockNode/StepNode/SettingsPopoverContent/bodies/DateInputSettingsBody.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { FormLabel, Stack } from '@chakra-ui/react' | ||
import { DebouncedInput } from 'components/shared/DebouncedInput' | ||
import { SwitchWithLabel } from 'components/shared/SwitchWithLabel' | ||
import { DateInputOptions } from 'models' | ||
import React from 'react' | ||
|
||
type DateInputSettingsBodyProps = { | ||
options?: DateInputOptions | ||
onOptionsChange: (options: DateInputOptions) => void | ||
} | ||
|
||
export const DateInputSettingsBody = ({ | ||
options, | ||
onOptionsChange, | ||
}: DateInputSettingsBodyProps) => { | ||
const handleFromChange = (from: string) => | ||
onOptionsChange({ ...options, labels: { ...options?.labels, from } }) | ||
const handleToChange = (to: string) => | ||
onOptionsChange({ ...options, labels: { ...options?.labels, to } }) | ||
const handleButtonLabelChange = (button: string) => | ||
onOptionsChange({ ...options, labels: { ...options?.labels, button } }) | ||
const handleIsRangeChange = (isRange: boolean) => | ||
onOptionsChange({ ...options, isRange }) | ||
const handleHasTimeChange = (hasTime: boolean) => | ||
onOptionsChange({ ...options, hasTime }) | ||
|
||
return ( | ||
<Stack spacing={4}> | ||
<SwitchWithLabel | ||
id="is-range" | ||
label={'Is range?'} | ||
initialValue={options?.isRange ?? false} | ||
onCheckChange={handleIsRangeChange} | ||
/> | ||
<SwitchWithLabel | ||
id="with-time" | ||
label={'With time?'} | ||
initialValue={options?.isRange ?? false} | ||
onCheckChange={handleHasTimeChange} | ||
/> | ||
{options?.isRange && ( | ||
<Stack> | ||
<FormLabel mb="0" htmlFor="from"> | ||
From label: | ||
</FormLabel> | ||
<DebouncedInput | ||
id="from" | ||
initialValue={options?.labels?.from ?? 'From:'} | ||
delay={100} | ||
onChange={handleFromChange} | ||
/> | ||
</Stack> | ||
)} | ||
{options?.isRange && ( | ||
<Stack> | ||
<FormLabel mb="0" htmlFor="to"> | ||
To label: | ||
</FormLabel> | ||
<DebouncedInput | ||
id="to" | ||
initialValue={options?.labels?.to ?? 'To:'} | ||
delay={100} | ||
onChange={handleToChange} | ||
/> | ||
</Stack> | ||
)} | ||
<Stack> | ||
<FormLabel mb="0" htmlFor="button"> | ||
Button label: | ||
</FormLabel> | ||
<DebouncedInput | ||
id="button" | ||
initialValue={options?.labels?.button ?? 'Send'} | ||
delay={100} | ||
onChange={handleButtonLabelChange} | ||
/> | ||
</Stack> | ||
</Stack> | ||
) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
.../builder/components/board/graph/BlockNode/StepNode/SettingsPopoverContent/bodies/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './DateInputSettingsBody' | ||
export * from './EmailInputSettingsBody' | ||
export * from './NumberInputSettingsBody' | ||
export * from './TextInputSettingsBody' | ||
export * from './UrlInputSettingsBody' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
packages/bot-engine/src/components/ChatBlock/ChatStep/inputs/DateForm.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { DateInputOptions } from 'models' | ||
import React, { useState } from 'react' | ||
import { SendButton } from './SendButton' | ||
|
||
type DateInputProps = { | ||
onSubmit: (inputValue: `${string} to ${string}` | string) => void | ||
options?: DateInputOptions | ||
} | ||
|
||
export const DateForm = ({ | ||
onSubmit, | ||
options, | ||
}: DateInputProps): JSX.Element => { | ||
const { hasTime, isRange, labels } = options ?? {} | ||
const [inputValues, setInputValues] = useState({ from: '', to: '' }) | ||
return ( | ||
<div className="flex flex-col w-full lg:w-4/6"> | ||
<div className="flex items-center"> | ||
<form | ||
className={ | ||
'flex justify-between rounded-lg typebot-input pr-2 items-end' | ||
} | ||
onSubmit={(e) => { | ||
if (inputValues.from === '' && inputValues.to === '') return | ||
e.preventDefault() | ||
onSubmit( | ||
`${inputValues.from}${isRange ? ` to ${inputValues.to}` : ''}` | ||
) | ||
}} | ||
> | ||
<div className="flex flex-col"> | ||
<div className={'flex items-center p-4 ' + (isRange ? 'pb-0' : '')}> | ||
{isRange && ( | ||
<p className="font-semibold mr-2">{labels?.from ?? 'From:'}</p> | ||
)} | ||
<input | ||
className="focus:outline-none bg-transparent flex-1 w-full comp-input" | ||
type={hasTime ? 'datetime-local' : 'date'} | ||
onChange={(e) => | ||
setInputValues({ ...inputValues, from: e.target.value }) | ||
} | ||
data-testid="from-date" | ||
/> | ||
</div> | ||
{isRange && ( | ||
<div className="flex items-center p-4"> | ||
{isRange && ( | ||
<p className="font-semibold">{labels?.to ?? 'To:'}</p> | ||
)} | ||
<input | ||
className="focus:outline-none bg-transparent flex-1 w-full comp-input ml-2" | ||
type={hasTime ? 'datetime-local' : 'date'} | ||
onChange={(e) => | ||
setInputValues({ ...inputValues, to: e.target.value }) | ||
} | ||
data-testid="to-date" | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
|
||
<SendButton | ||
label={labels?.button ?? 'Send'} | ||
isDisabled={inputValues.to === '' && inputValues.from === ''} | ||
/> | ||
</form> | ||
</div> | ||
</div> | ||
) | ||
} |
57 changes: 0 additions & 57 deletions
57
packages/bot-engine/src/components/ChatBlock/ChatStep/inputs/NumberInput.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.