react-dropzone 14.3.3 → 14.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/index.js +3 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/index.js +2 -0
- package/src/index.spec.js +11 -2
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -703,6 +703,7 @@ export function useDropzone(props = {}) {
|
|
|
703
703
|
dispatch({
|
|
704
704
|
acceptedFiles,
|
|
705
705
|
fileRejections,
|
|
706
|
+
isDragReject: fileRejections.length > 0,
|
|
706
707
|
type: "setFiles",
|
|
707
708
|
});
|
|
708
709
|
|
|
@@ -1025,6 +1026,7 @@ function reducer(state, action) {
|
|
|
1025
1026
|
...state,
|
|
1026
1027
|
acceptedFiles: action.acceptedFiles,
|
|
1027
1028
|
fileRejections: action.fileRejections,
|
|
1029
|
+
isDragReject: action.isDragReject,
|
|
1028
1030
|
};
|
|
1029
1031
|
case "reset":
|
|
1030
1032
|
return {
|
package/src/index.spec.js
CHANGED
|
@@ -2510,7 +2510,7 @@ describe("useDropzone() hook", () => {
|
|
|
2510
2510
|
expect(onDropSpy).toHaveBeenCalledWith(files, [], expect.anything());
|
|
2511
2511
|
});
|
|
2512
2512
|
|
|
2513
|
-
it("sets {acceptedFiles, fileRejections}", async () => {
|
|
2513
|
+
it("sets {acceptedFiles, fileRejections, isDragReject}", async () => {
|
|
2514
2514
|
const FileList = ({ files = [] }) => (
|
|
2515
2515
|
<ul>
|
|
2516
2516
|
{files.map((file) => (
|
|
@@ -2558,11 +2558,18 @@ describe("useDropzone() hook", () => {
|
|
|
2558
2558
|
"image/*": [],
|
|
2559
2559
|
}}
|
|
2560
2560
|
>
|
|
2561
|
-
{({
|
|
2561
|
+
{({
|
|
2562
|
+
getRootProps,
|
|
2563
|
+
getInputProps,
|
|
2564
|
+
acceptedFiles,
|
|
2565
|
+
fileRejections,
|
|
2566
|
+
isDragReject,
|
|
2567
|
+
}) => (
|
|
2562
2568
|
<div {...getRootProps()}>
|
|
2563
2569
|
<input {...getInputProps()} />
|
|
2564
2570
|
<FileList files={acceptedFiles} />
|
|
2565
2571
|
<RejectedFileList fileRejections={fileRejections} />
|
|
2572
|
+
{isDragReject && "dragReject"}
|
|
2566
2573
|
</div>
|
|
2567
2574
|
)}
|
|
2568
2575
|
</Dropzone>
|
|
@@ -2574,6 +2581,7 @@ describe("useDropzone() hook", () => {
|
|
|
2574
2581
|
const acceptedFileList = getAcceptedFiles(dropzone);
|
|
2575
2582
|
expect(acceptedFileList).toHaveLength(images.length);
|
|
2576
2583
|
expect(matchToFiles(acceptedFileList, images)).toBe(true);
|
|
2584
|
+
expect(dropzone).not.toHaveTextContent("dragReject");
|
|
2577
2585
|
|
|
2578
2586
|
await act(() => fireEvent.drop(dropzone, createDtWithFiles(files)));
|
|
2579
2587
|
|
|
@@ -2585,6 +2593,7 @@ describe("useDropzone() hook", () => {
|
|
|
2585
2593
|
expect(matchToErrorCode(rejectedFileErrorList, "file-invalid-type")).toBe(
|
|
2586
2594
|
true
|
|
2587
2595
|
);
|
|
2596
|
+
expect(dropzone).toHaveTextContent("dragReject");
|
|
2588
2597
|
});
|
|
2589
2598
|
|
|
2590
2599
|
it("resets {isDragActive, isDragAccept, isDragReject}", async () => {
|