Merge pull request #16472 from bretto36/3.x

Allow pasteable() for FileUpload after fixing underlying JS Package problem in filepond
This commit is contained in:
Dan Harrin
2025-06-12 11:29:35 +01:00
committed by GitHub
8 changed files with 41 additions and 14 deletions
+4 -4
View File
@@ -25,7 +25,7 @@
"easymde": "^2.18.0",
"esbuild": "^0.25.0",
"esbuild-postcss": "^0.0.4",
"filepond": "^4.31.1",
"filepond": "^4.32.8",
"filepond-plugin-file-validate-size": "^2.2.4",
"filepond-plugin-file-validate-type": "^1.2.6",
"filepond-plugin-image-crop": "^2.0.6",
@@ -5520,9 +5520,9 @@
}
},
"node_modules/filepond": {
"version": "4.32.7",
"resolved": "https://registry.npmjs.org/filepond/-/filepond-4.32.7.tgz",
"integrity": "sha512-L2idUfC31Qb2ZuFn8yAjX+Km6Ouq0kQn6JHcwhqrl5Ee9cB7xctLa0nkbbAeCML2+a1/cUsd0TqBgVcxYW08GA==",
"version": "4.32.8",
"resolved": "https://registry.npmjs.org/filepond/-/filepond-4.32.8.tgz",
"integrity": "sha512-svcz5lh4YKrV92zogqpOKzVEOXbD/zT7RAHso5Lqp0GujP+kxF2PSl9Tb6AdYVzfMRtoPsExcphJPpBLoo8eYg==",
"dev": true
},
"node_modules/filepond-plugin-file-validate-size": {
+1 -1
View File
@@ -35,7 +35,7 @@
"easymde": "^2.18.0",
"esbuild": "^0.25.0",
"esbuild-postcss": "^0.0.4",
"filepond": "^4.31.1",
"filepond": "^4.32.8",
"filepond-plugin-file-validate-size": "^2.2.4",
"filepond-plugin-file-validate-type": "^1.2.6",
"filepond-plugin-image-crop": "^2.0.6",
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -13,7 +13,7 @@ cropperjs/dist/cropper.min.css:
filepond/dist/filepond.min.css:
(*!
* FilePond 4.32.7
* FilePond 4.32.8
* Licensed under MIT, https://opensource.org/licenses/MIT/
* Please visit https://pqina.nl/filepond/ for details.
*)
@@ -412,6 +412,17 @@ FileUpload::make('attachment')
->deletable(false)
```
## Preventing pasting files
You can disable the ability to paste files via the clipboard using the `pasteable(false)` method:
```php
use Filament\Forms\Components\FileUpload;
FileUpload::make('attachment')
->pasteable(false)
```
## Prevent file information fetching
While the form is loaded, it will automatically detect whether the files exist, what size they are, and what type of files they are. This is all done on the backend. When using remote storage with many files, this can be time-consuming. You can use the `fetchFileInformation(false)` method to disable this feature:
@@ -49,6 +49,7 @@ export default function fileUploadFormComponent({
isDownloadable,
isMultiple,
isOpenable,
isPasteable,
isPreviewable,
isReorderable,
itemPanelAspectRatio,
@@ -103,7 +104,7 @@ export default function fileUploadFormComponent({
this.pond = FilePond.create(this.$refs.input, {
acceptedFileTypes,
allowImageExifOrientation: shouldOrientImageFromExif,
allowPaste: false,
allowPaste: isPasteable,
allowRemove: isDeletable,
allowReorder: isReorderable,
allowImagePreview: isPreviewable,
@@ -60,6 +60,7 @@
isDownloadable: @js($isDownloadable()),
isMultiple: @js($isMultiple()),
isOpenable: @js($isOpenable()),
isPasteable: @js($isPasteable()),
isPreviewable: @js($isPreviewable()),
isReorderable: @js($isReorderable()),
itemPanelAspectRatio: @js($getItemPanelAspectRatio()),
@@ -32,6 +32,8 @@ class BaseFileUpload extends Field implements Contracts\HasNestedRecursiveValida
protected bool | Closure $isOpenable = false;
protected bool | Closure $isPasteable = true;
protected bool | Closure $isPreviewable = true;
protected bool | Closure $isReorderable = false;
@@ -284,6 +286,13 @@ class BaseFileUpload extends Field implements Contracts\HasNestedRecursiveValida
return $this;
}
public function pasteable(bool | Closure $condition = true): static
{
$this->isPasteable = $condition;
return $this;
}
public function previewable(bool | Closure $condition = true): static
{
$this->isPreviewable = $condition;
@@ -490,6 +499,11 @@ class BaseFileUpload extends Field implements Contracts\HasNestedRecursiveValida
return (bool) $this->evaluate($this->isOpenable);
}
public function isPasteable(): bool
{
return (bool) $this->evaluate($this->isPasteable);
}
public function isPreviewable(): bool
{
return (bool) $this->evaluate($this->isPreviewable);