@react-aria/dnd 3.0.0-alpha.0 → 3.0.0-alpha.11
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/main.js +2725 -1839
- package/dist/main.js.map +1 -1
- package/dist/module.js +2717 -1783
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +34 -30
- package/dist/types.d.ts.map +1 -1
- package/package.json +15 -14
- package/src/DragManager.ts +91 -43
- package/src/DragPreview.tsx +54 -0
- package/src/constants.ts +3 -1
- package/src/index.ts +17 -7
- package/src/useClipboard.ts +5 -5
- package/src/useDrag.ts +40 -39
- package/src/useDraggableItem.ts +9 -11
- package/src/useDrop.ts +9 -4
- package/src/useDropIndicator.ts +10 -10
- package/src/useDroppableCollection.ts +170 -31
- package/src/useDroppableItem.ts +2 -2
- package/src/useVirtualDrop.ts +5 -5
- package/src/utils.ts +6 -24
package/src/useVirtualDrop.ts
CHANGED
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
import {DOMAttributes} from '@react-types/shared';
|
|
13
14
|
import * as DragManager from './DragManager';
|
|
14
|
-
import {HTMLAttributes} from 'react';
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
import intlMessages from '../intl/*.json';
|
|
17
17
|
import {useDescription} from '@react-aria/utils';
|
|
18
18
|
import {useDragModality} from './utils';
|
|
19
|
-
import {
|
|
19
|
+
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
20
20
|
|
|
21
21
|
interface VirtualDropResult {
|
|
22
|
-
dropProps:
|
|
22
|
+
dropProps: DOMAttributes
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const MESSAGES = {
|
|
@@ -29,10 +29,10 @@ const MESSAGES = {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
export function useVirtualDrop(): VirtualDropResult {
|
|
32
|
-
let
|
|
32
|
+
let stringFormatter = useLocalizedStringFormatter(intlMessages);
|
|
33
33
|
let modality = useDragModality();
|
|
34
34
|
let dragSession = DragManager.useDragSession();
|
|
35
|
-
let descriptionProps = useDescription(dragSession ?
|
|
35
|
+
let descriptionProps = useDescription(dragSession ? stringFormatter.format(MESSAGES[modality]) : '');
|
|
36
36
|
|
|
37
37
|
return {
|
|
38
38
|
dropProps: {
|
package/src/utils.ts
CHANGED
|
@@ -154,7 +154,7 @@ export class DragTypes implements IDragTypes {
|
|
|
154
154
|
|
|
155
155
|
// In Safari, when dragging files, the dataTransfer.items list is empty, but dataTransfer.types contains "Files".
|
|
156
156
|
// Unfortunately, this doesn't tell us what types of files the user is dragging, so we need to assume that any
|
|
157
|
-
// type the user checks for is included.
|
|
157
|
+
// type the user checks for is included. See https://bugs.webkit.org/show_bug.cgi?id=223517.
|
|
158
158
|
this.includesUnknownTypes = !hasFiles && dataTransfer.types.includes('Files');
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -208,10 +208,11 @@ export function readFromDataTransfer(dataTransfer: DataTransfer) {
|
|
|
208
208
|
if (typeof item.webkitGetAsEntry === 'function') {
|
|
209
209
|
let entry: FileSystemEntry = item.webkitGetAsEntry();
|
|
210
210
|
if (!entry) {
|
|
211
|
-
// For some reason,
|
|
212
|
-
// and pasting any file or directory (no matter the type), but
|
|
211
|
+
// For some reason, Firefox includes an item with type image/png when copy
|
|
212
|
+
// and pasting any file or directory (no matter the type), but returns `null` for both
|
|
213
213
|
// item.getAsFile() and item.webkitGetAsEntry(). Safari works as expected. Ignore this
|
|
214
|
-
// item if this happens.
|
|
214
|
+
// item if this happens. See https://bugzilla.mozilla.org/show_bug.cgi?id=1699743.
|
|
215
|
+
// This was recently fixed in Chrome Canary: https://bugs.chromium.org/p/chromium/issues/detail?id=1175483.
|
|
215
216
|
continue;
|
|
216
217
|
}
|
|
217
218
|
|
|
@@ -276,25 +277,6 @@ function createDirectoryItem(entry: any): DirectoryItem {
|
|
|
276
277
|
};
|
|
277
278
|
}
|
|
278
279
|
|
|
279
|
-
interface FileSystemFileEntry {
|
|
280
|
-
isFile: true,
|
|
281
|
-
isDirectory: false,
|
|
282
|
-
name: string,
|
|
283
|
-
file(successCallback: (file: File) => void, errorCallback?: (error: Error) => void): void
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
interface FileSystemDirectoryEntry {
|
|
287
|
-
isDirectory: true,
|
|
288
|
-
isFile: false,
|
|
289
|
-
name: string,
|
|
290
|
-
createReader(): FileSystemDirectoryReader
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
type FileSystemEntry = FileSystemFileEntry | FileSystemDirectoryEntry;
|
|
294
|
-
interface FileSystemDirectoryReader {
|
|
295
|
-
readEntries(successCallback: (entries: FileSystemEntry[]) => void, errorCallback?: (error: Error) => void): void
|
|
296
|
-
}
|
|
297
|
-
|
|
298
280
|
async function *getEntries(item: FileSystemDirectoryEntry): AsyncIterable<FileItem | DirectoryItem> {
|
|
299
281
|
let reader = item.createReader();
|
|
300
282
|
|
|
@@ -308,7 +290,7 @@ async function *getEntries(item: FileSystemDirectoryEntry): AsyncIterable<FileIt
|
|
|
308
290
|
|
|
309
291
|
for (let entry of entries) {
|
|
310
292
|
if (entry.isFile) {
|
|
311
|
-
let file = await getEntryFile(entry);
|
|
293
|
+
let file = await getEntryFile(entry as FileSystemFileEntry);
|
|
312
294
|
yield createFileItem(file);
|
|
313
295
|
} else if (entry.isDirectory) {
|
|
314
296
|
yield createDirectoryItem(entry);
|