@loadsmart/loadsmart-ui 5.5.0 → 5.5.1
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/package.json
CHANGED
|
@@ -97,4 +97,12 @@ describe('<DragDropFile.DropZone />', () => {
|
|
|
97
97
|
|
|
98
98
|
expect(onFilesAdded).toHaveBeenCalledWith(filesMock)
|
|
99
99
|
})
|
|
100
|
+
|
|
101
|
+
it('does not call onFilesAdded when files are dropped in the drop zone and disabled is true', () => {
|
|
102
|
+
setup({ multiple: true, disabled: true })
|
|
103
|
+
|
|
104
|
+
DragDropFileEvent.dropFiles(getInput(), filesMock)
|
|
105
|
+
|
|
106
|
+
expect(onFilesAdded).not.toHaveBeenCalled()
|
|
107
|
+
})
|
|
100
108
|
})
|
|
@@ -39,11 +39,11 @@ const DropZone = ({
|
|
|
39
39
|
|
|
40
40
|
const onKeyPress = useCallback(
|
|
41
41
|
(event: React.KeyboardEvent) => {
|
|
42
|
-
if (inputRef.current && KeyboardKey(event).is('ENTER')) {
|
|
42
|
+
if (!disabled && inputRef.current && KeyboardKey(event).is('ENTER')) {
|
|
43
43
|
inputRef.current.click()
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
[inputRef]
|
|
46
|
+
[disabled, inputRef]
|
|
47
47
|
)
|
|
48
48
|
|
|
49
49
|
const onDrop = useCallback(
|
|
@@ -51,13 +51,15 @@ const DropZone = ({
|
|
|
51
51
|
event.preventDefault()
|
|
52
52
|
event.stopPropagation()
|
|
53
53
|
|
|
54
|
-
if (
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
if (!disabled) {
|
|
55
|
+
if (isDragging) {
|
|
56
|
+
setIsDragging(false)
|
|
57
|
+
}
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
onFilesAdded(Array.from(event.dataTransfer.files || []))
|
|
60
|
+
}
|
|
59
61
|
},
|
|
60
|
-
[isDragging, onFilesAdded]
|
|
62
|
+
[disabled, isDragging, onFilesAdded]
|
|
61
63
|
)
|
|
62
64
|
|
|
63
65
|
const onDragStart = useCallback((event: React.DragEvent<HTMLDivElement>) => {
|
|
@@ -68,11 +70,11 @@ const DropZone = ({
|
|
|
68
70
|
(event: React.DragEvent<HTMLDivElement>) => {
|
|
69
71
|
event.preventDefault()
|
|
70
72
|
|
|
71
|
-
if (!isDragging) {
|
|
73
|
+
if (!disabled && !isDragging) {
|
|
72
74
|
setIsDragging(true)
|
|
73
75
|
}
|
|
74
76
|
},
|
|
75
|
-
[isDragging]
|
|
77
|
+
[disabled, isDragging]
|
|
76
78
|
)
|
|
77
79
|
|
|
78
80
|
const onDragLeave = useCallback(
|