react-dropzone 14.3.2 → 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 +13 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/src/__snapshots__/index.spec.js.snap +1 -1
- package/src/index.js +14 -1
- package/src/index.spec.js +11 -2
package/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`useDropzone() hook behavior renders the root and input nodes with the necessary props 1`] = `"<div role=\\"presentation\\" tabindex=\\"0\\"><input multiple=\\"\\" type=\\"file\\" style=\\"
|
|
3
|
+
exports[`useDropzone() hook behavior renders the root and input nodes with the necessary props 1`] = `"<div role=\\"presentation\\" tabindex=\\"0\\"><input multiple=\\"\\" type=\\"file\\" style=\\"border: 0px; clip: rect(0px, 0px, 0px, 0px); clip-path: inset(50%); height: 1px; margin: 0px -1px -1px 0px; overflow: hidden; padding: 0px; position: absolute; width: 1px; white-space: nowrap;\\" tabindex=\\"-1\\"></div>"`;
|
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
|
|
|
@@ -946,7 +947,18 @@ export function useDropzone(props = {}) {
|
|
|
946
947
|
accept: acceptAttr,
|
|
947
948
|
multiple,
|
|
948
949
|
type: "file",
|
|
949
|
-
style: {
|
|
950
|
+
style: {
|
|
951
|
+
border: 0,
|
|
952
|
+
clip: "rect(0, 0, 0, 0)",
|
|
953
|
+
clipPath: "inset(50%)",
|
|
954
|
+
height: "1px",
|
|
955
|
+
margin: "0 -1px -1px 0",
|
|
956
|
+
overflow: "hidden",
|
|
957
|
+
padding: 0,
|
|
958
|
+
position: "absolute",
|
|
959
|
+
width: "1px",
|
|
960
|
+
whiteSpace: "nowrap",
|
|
961
|
+
},
|
|
950
962
|
onChange: composeHandler(composeEventHandlers(onChange, onDropCb)),
|
|
951
963
|
onClick: composeHandler(
|
|
952
964
|
composeEventHandlers(onClick, onInputElementClick)
|
|
@@ -1014,6 +1026,7 @@ function reducer(state, action) {
|
|
|
1014
1026
|
...state,
|
|
1015
1027
|
acceptedFiles: action.acceptedFiles,
|
|
1016
1028
|
fileRejections: action.fileRejections,
|
|
1029
|
+
isDragReject: action.isDragReject,
|
|
1017
1030
|
};
|
|
1018
1031
|
case "reset":
|
|
1019
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 () => {
|