-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add attachments option to text input (#1608)
Closes #854
- Loading branch information
1 parent
80da7af
commit 6db0464
Showing
88 changed files
with
2,958 additions
and
734 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
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
41 changes: 32 additions & 9 deletions
41
apps/builder/src/features/blocks/inputs/textInput/components/TextInputNodeContent.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 |
---|---|---|
@@ -1,25 +1,48 @@ | ||
import React from 'react' | ||
import { Text } from '@chakra-ui/react' | ||
import { Stack, Text } from '@chakra-ui/react' | ||
import { WithVariableContent } from '@/features/graph/components/nodes/block/WithVariableContent' | ||
import { TextInputBlock } from '@typebot.io/schemas' | ||
import { defaultTextInputOptions } from '@typebot.io/schemas/features/blocks/inputs/text/constants' | ||
import { useTypebot } from '@/features/editor/providers/TypebotProvider' | ||
import { SetVariableLabel } from '@/components/SetVariableLabel' | ||
|
||
type Props = { | ||
options: TextInputBlock['options'] | ||
} | ||
|
||
export const TextInputNodeContent = ({ options }: Props) => { | ||
const { typebot } = useTypebot() | ||
const attachmentVariableId = | ||
typebot && | ||
options?.attachments?.isEnabled && | ||
options?.attachments.saveVariableId | ||
if (options?.variableId) | ||
return ( | ||
<WithVariableContent | ||
variableId={options?.variableId} | ||
h={options.isLong ? '100px' : 'auto'} | ||
/> | ||
<Stack w="calc(100% - 25px)"> | ||
<WithVariableContent | ||
variableId={options?.variableId} | ||
h={options.isLong ? '100px' : 'auto'} | ||
/> | ||
{attachmentVariableId && ( | ||
<SetVariableLabel | ||
variables={typebot.variables} | ||
variableId={attachmentVariableId} | ||
/> | ||
)} | ||
</Stack> | ||
) | ||
return ( | ||
<Text color={'gray.500'} h={options?.isLong ? '100px' : 'auto'}> | ||
{options?.labels?.placeholder ?? | ||
defaultTextInputOptions.labels.placeholder} | ||
</Text> | ||
<Stack> | ||
<Text color={'gray.500'} h={options?.isLong ? '100px' : 'auto'}> | ||
{options?.labels?.placeholder ?? | ||
defaultTextInputOptions.labels.placeholder} | ||
</Text> | ||
{attachmentVariableId && ( | ||
<SetVariableLabel | ||
variables={typebot.variables} | ||
variableId={attachmentVariableId} | ||
/> | ||
)} | ||
</Stack> | ||
) | ||
} |
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
Oops, something went wrong.