@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/js",
|
"name": "@typebot.io/js",
|
||||||
"version": "0.2.51",
|
"version": "0.2.52",
|
||||||
"description": "Javascript library to display typebots on your website",
|
"description": "Javascript library to display typebots on your website",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
@ -39,7 +39,22 @@ export const FileUploadForm = (props: Props) => {
|
|||||||
return setErrorMessage(`A file is larger than ${sizeLimit}MB`)
|
return setErrorMessage(`A file is larger than ${sizeLimit}MB`)
|
||||||
if (!props.block.options?.isMultipleAllowed && files)
|
if (!props.block.options?.isMultipleAllowed && files)
|
||||||
return startSingleFileUpload(newFiles[0])
|
return startSingleFileUpload(newFiles[0])
|
||||||
setSelectedFiles([...selectedFiles(), ...newFiles])
|
if (selectedFiles().length === 0) {
|
||||||
|
setSelectedFiles(newFiles)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const parsedNewFiles = newFiles.map((newFile) => {
|
||||||
|
let fileName = newFile.name
|
||||||
|
let counter = 1
|
||||||
|
while (selectedFiles().some((file) => file.name === fileName)) {
|
||||||
|
const dotIndex = newFile.name.lastIndexOf('.')
|
||||||
|
const extension = dotIndex !== -1 ? newFile.name.slice(dotIndex) : ''
|
||||||
|
fileName = `${newFile.name.slice(0, dotIndex)}(${counter})${extension}`
|
||||||
|
counter++
|
||||||
|
}
|
||||||
|
return new File([newFile], fileName, { type: newFile.type })
|
||||||
|
})
|
||||||
|
setSelectedFiles([...selectedFiles(), ...parsedNewFiles])
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSubmit = async (e: SubmitEvent) => {
|
const handleSubmit = async (e: SubmitEvent) => {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/nextjs",
|
"name": "@typebot.io/nextjs",
|
||||||
"version": "0.2.51",
|
"version": "0.2.52",
|
||||||
"description": "Convenient library to display typebots on your Next.js website",
|
"description": "Convenient library to display typebots on your Next.js website",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@typebot.io/react",
|
"name": "@typebot.io/react",
|
||||||
"version": "0.2.51",
|
"version": "0.2.52",
|
||||||
"description": "Convenient library to display typebots on your React app",
|
"description": "Convenient library to display typebots on your React app",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
Reference in New Issue
Block a user