@barqjs/aria 0.2.0-next.0 → 0.2.0-next.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/README.md +24 -13
- package/package.json +127 -37
- package/src/autocomplete.tsx +581 -0
- package/src/breadcrumbs.tsx +21 -20
- package/src/button.tsx +151 -25
- package/src/calendar.tsx +1019 -92
- package/src/checkbox.tsx +214 -52
- package/src/collections.ts +88 -5
- package/src/color.ts +1580 -23
- package/src/colorpicker.tsx +698 -153
- package/src/colorswatchpicker.tsx +240 -0
- package/src/combobox.tsx +635 -113
- package/src/command.tsx +78 -59
- package/src/date.ts +31 -9
- package/src/datefield.tsx +1451 -336
- package/src/datepicker.tsx +465 -114
- package/src/dialog.tsx +302 -115
- package/src/disclosure.tsx +81 -29
- package/src/dnd/clipboard.ts +125 -0
- package/src/dnd/collection.ts +1265 -0
- package/src/dnd/data.ts +409 -0
- package/src/dnd/drag-drop.ts +801 -0
- package/src/dnd/index.ts +133 -0
- package/src/dnd/manager.ts +639 -0
- package/src/dnd/strings.ts +1279 -0
- package/src/dnd/targets.ts +726 -0
- package/src/dnd/types.ts +212 -0
- package/src/dom.ts +3 -6
- package/src/drag-and-drop.tsx +669 -0
- package/src/dropzone.tsx +208 -0
- package/src/file-trigger.tsx +103 -0
- package/src/form.tsx +18 -18
- package/src/gridlist.tsx +912 -121
- package/src/group.tsx +146 -0
- package/src/index.ts +402 -0
- package/src/interactions/focus-events.ts +13 -5
- package/src/interactions/keyboard.ts +195 -2
- package/src/interactions/modality.ts +18 -6
- package/src/interactions/open-link.ts +46 -13
- package/src/interactions/press.ts +35 -18
- package/src/label.ts +18 -6
- package/src/link.tsx +146 -50
- package/src/listbox.tsx +615 -89
- package/src/live.ts +4 -0
- package/src/menu.tsx +182 -89
- package/src/menubar.tsx +21 -17
- package/src/navigation-tree.tsx +357 -0
- package/src/numberfield.tsx +164 -60
- package/src/overlay-arrow.tsx +157 -0
- package/src/overlays.ts +364 -62
- package/src/platform.ts +2 -1
- package/src/preview-trigger.tsx +582 -0
- package/src/progress-bar-context.ts +15 -0
- package/src/questionnaire.tsx +109 -104
- package/src/radio.tsx +101 -27
- package/src/select.tsx +225 -145
- package/src/selection-indicator.tsx +74 -0
- package/src/selection.ts +73 -16
- package/src/shared-element-transition.tsx +316 -0
- package/src/sheet.tsx +1461 -0
- package/src/slider.tsx +139 -44
- package/src/switch.tsx +47 -21
- package/src/table.tsx +0 -0
- package/src/tabs.tsx +198 -89
- package/src/tag.tsx +217 -32
- package/src/textarea.tsx +186 -0
- package/src/textfield.tsx +103 -37
- package/src/toast-components.tsx +589 -0
- package/src/toggle-button-group.tsx +175 -0
- package/src/toggle-input.tsx +38 -0
- package/src/toggle.ts +68 -5
- package/src/tokenfield.tsx +1673 -0
- package/src/toolbar.tsx +15 -10
- package/src/tooltip.tsx +46 -29
- package/src/tree.tsx +2075 -0
- package/src/utils.ts +30 -1
- package/src/validation.ts +79 -22
- package/src/virtualizer.tsx +186 -23
package/src/dnd/data.ts
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a drag carries, and what every collection on the page needs to know
|
|
3
|
+
* about the drag under way.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { Key } from "../collections.ts";
|
|
7
|
+
import type { ElementRef } from "../interactions/press.ts";
|
|
8
|
+
import { access } from "../utils.ts";
|
|
9
|
+
import type {
|
|
10
|
+
DirectoryDropItem,
|
|
11
|
+
DragItem,
|
|
12
|
+
DragType,
|
|
13
|
+
DragTypes,
|
|
14
|
+
DropItem,
|
|
15
|
+
DropOperation,
|
|
16
|
+
FileDropItem,
|
|
17
|
+
TextDropItem,
|
|
18
|
+
} from "./types.ts";
|
|
19
|
+
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Operations
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
export const NONE = 0;
|
|
25
|
+
export const MOVE = 1;
|
|
26
|
+
export const COPY = 2;
|
|
27
|
+
export const LINK = 4;
|
|
28
|
+
export const ALL = MOVE | COPY | LINK;
|
|
29
|
+
|
|
30
|
+
export const OPERATION_BITS: Record<DropOperation, number> = {
|
|
31
|
+
cancel: NONE,
|
|
32
|
+
move: MOVE,
|
|
33
|
+
copy: COPY,
|
|
34
|
+
link: LINK,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type EffectAllowed = DataTransfer["effectAllowed"];
|
|
38
|
+
export type DropEffect = DataTransfer["dropEffect"];
|
|
39
|
+
|
|
40
|
+
export const ALLOWED_BITS: Record<string, number> = {
|
|
41
|
+
none: NONE,
|
|
42
|
+
cancel: NONE,
|
|
43
|
+
move: MOVE,
|
|
44
|
+
copy: COPY,
|
|
45
|
+
link: LINK,
|
|
46
|
+
copyMove: COPY | MOVE,
|
|
47
|
+
copyLink: COPY | LINK,
|
|
48
|
+
linkMove: LINK | MOVE,
|
|
49
|
+
all: ALL,
|
|
50
|
+
uninitialized: ALL,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const EFFECT_ALLOWED: Record<number, EffectAllowed> = {
|
|
54
|
+
[NONE]: "none",
|
|
55
|
+
[MOVE]: "move",
|
|
56
|
+
[COPY]: "copy",
|
|
57
|
+
[COPY | MOVE]: "copyMove",
|
|
58
|
+
[LINK]: "link",
|
|
59
|
+
[LINK | MOVE]: "linkMove",
|
|
60
|
+
[COPY | LINK]: "copyLink",
|
|
61
|
+
[ALL]: "all",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const EFFECT_TO_OPERATION: Record<DropEffect, DropOperation> = {
|
|
65
|
+
none: "cancel",
|
|
66
|
+
link: "link",
|
|
67
|
+
copy: "copy",
|
|
68
|
+
move: "move",
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const OPERATION_TO_EFFECT: Record<DropOperation, DropEffect> = {
|
|
72
|
+
cancel: "none",
|
|
73
|
+
link: "link",
|
|
74
|
+
copy: "copy",
|
|
75
|
+
move: "move",
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const NATIVE_DRAG_TYPES = new Set(["text/plain", "text/uri-list", "text/html"]);
|
|
79
|
+
|
|
80
|
+
/** Every item of a multi-item drag, as JSON, under one type the platform will carry. */
|
|
81
|
+
export const CUSTOM_DRAG_TYPE = "application/vnd.barq.items+json";
|
|
82
|
+
|
|
83
|
+
/** A file whose type the browser could not name, or a directory. */
|
|
84
|
+
export const GENERIC_TYPE = "application/octet-stream";
|
|
85
|
+
|
|
86
|
+
/** Pass in `acceptedDragTypes` to accept dropped directories. */
|
|
87
|
+
export const DIRECTORY_DRAG_TYPE: unique symbol = Symbol("barq.dnd.directory");
|
|
88
|
+
|
|
89
|
+
export function operationsToArray(bits: number): DropOperation[] {
|
|
90
|
+
const operations: DropOperation[] = [];
|
|
91
|
+
if ((bits & MOVE) !== 0) operations.push("move");
|
|
92
|
+
if ((bits & COPY) !== 0) operations.push("copy");
|
|
93
|
+
if ((bits & LINK) !== 0) operations.push("link");
|
|
94
|
+
return operations;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function allowedOperation(allowed: number, operation: DropOperation): DropOperation {
|
|
98
|
+
return (allowed & OPERATION_BITS[operation]) !== 0 ? operation : "cancel";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// The data transfer
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
|
|
105
|
+
/** The types of a keyboard drag's items, answering `has` the way a native drag's do. */
|
|
106
|
+
class ItemDragTypes implements DragTypes {
|
|
107
|
+
#types: Set<string>;
|
|
108
|
+
|
|
109
|
+
constructor(types: Set<string>) {
|
|
110
|
+
this.#types = types;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
has(type: DragType | DragType[]): boolean {
|
|
114
|
+
if (Array.isArray(type)) return type.some((one) => this.has(one));
|
|
115
|
+
if (typeof type !== "string") return false;
|
|
116
|
+
return matchesType(this.#types, type);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function matchesType(types: Set<string>, type: string): boolean {
|
|
121
|
+
if (type === "*/*") return true;
|
|
122
|
+
if (type.endsWith("/*")) {
|
|
123
|
+
const family = type.slice(0, -2);
|
|
124
|
+
for (const key of types) if (key.startsWith(family)) return true;
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return types.has(type);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Every type any of `items` is offered as. */
|
|
131
|
+
export function getTypes(items: DragItem[]): DragTypes {
|
|
132
|
+
const types = new Set<string>();
|
|
133
|
+
for (const item of items) {
|
|
134
|
+
for (const type of Object.keys(item)) types.add(type);
|
|
135
|
+
}
|
|
136
|
+
return new ItemDragTypes(types);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Write `items` to a data transfer.
|
|
141
|
+
*
|
|
142
|
+
* A `DataTransfer` holds one entry per type, and only a few types survive the
|
|
143
|
+
* trip to another application. Several items of one type, or one item in
|
|
144
|
+
* several types, therefore also go out as JSON under {@link CUSTOM_DRAG_TYPE},
|
|
145
|
+
* which a drop inside the page prefers.
|
|
146
|
+
*/
|
|
147
|
+
export function writeToDataTransfer(dataTransfer: DataTransfer, items: DragItem[]): void {
|
|
148
|
+
const byType = new Map<string, string[]>();
|
|
149
|
+
let needsCustomData = false;
|
|
150
|
+
const customData: DragItem[] = [];
|
|
151
|
+
|
|
152
|
+
for (const item of items) {
|
|
153
|
+
const types = Object.keys(item);
|
|
154
|
+
if (types.length > 1) needsCustomData = true;
|
|
155
|
+
|
|
156
|
+
const dataByType: DragItem = {};
|
|
157
|
+
for (const type of types) {
|
|
158
|
+
let typeItems = byType.get(type);
|
|
159
|
+
if (typeItems === undefined) {
|
|
160
|
+
typeItems = [];
|
|
161
|
+
byType.set(type, typeItems);
|
|
162
|
+
} else {
|
|
163
|
+
needsCustomData = true;
|
|
164
|
+
}
|
|
165
|
+
const data = item[type] as string;
|
|
166
|
+
dataByType[type] = data;
|
|
167
|
+
typeItems.push(data);
|
|
168
|
+
}
|
|
169
|
+
customData.push(dataByType);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
for (const [type, typeItems] of byType) {
|
|
173
|
+
if (NATIVE_DRAG_TYPES.has(type)) {
|
|
174
|
+
dataTransfer.items.add(typeItems.join("\n"), type);
|
|
175
|
+
} else {
|
|
176
|
+
dataTransfer.items.add(typeItems[0] as string, type);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (needsCustomData) {
|
|
181
|
+
dataTransfer.items.add(JSON.stringify(customData), CUSTOM_DRAG_TYPE);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** What a native drag carries, read during the drag when only the types are visible. */
|
|
186
|
+
export class DataTransferTypes implements DragTypes {
|
|
187
|
+
#types = new Set<string>();
|
|
188
|
+
#includesUnknownTypes: boolean;
|
|
189
|
+
|
|
190
|
+
constructor(dataTransfer: DataTransfer) {
|
|
191
|
+
let hasFiles = false;
|
|
192
|
+
for (const item of dataTransfer.items) {
|
|
193
|
+
if (item.type === CUSTOM_DRAG_TYPE) continue;
|
|
194
|
+
if (item.kind === "file") hasFiles = true;
|
|
195
|
+
// A file whose type the browser cannot map reports "", and may be a
|
|
196
|
+
// directory: nothing tells the two apart before the drop.
|
|
197
|
+
this.#types.add(item.type === "" ? GENERIC_TYPE : item.type);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Safari exposes no items while files are dragged, only "Files" in
|
|
201
|
+
// `types`, so every type asked about has to be assumed present.
|
|
202
|
+
// https://bugs.webkit.org/show_bug.cgi?id=223517
|
|
203
|
+
this.#includesUnknownTypes = !hasFiles && [...dataTransfer.types].includes("Files");
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
has(type: DragType | DragType[]): boolean {
|
|
207
|
+
if (Array.isArray(type)) return type.some((one) => this.has(one));
|
|
208
|
+
if (this.#includesUnknownTypes) return true;
|
|
209
|
+
if (type === DIRECTORY_DRAG_TYPE) return this.#types.has(GENERIC_TYPE);
|
|
210
|
+
if (typeof type !== "string") return false;
|
|
211
|
+
return matchesType(this.#types, type);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** The items of a drop or a paste. */
|
|
216
|
+
export function readFromDataTransfer(dataTransfer: DataTransfer | null | undefined): DropItem[] {
|
|
217
|
+
const items: DropItem[] = [];
|
|
218
|
+
if (dataTransfer === null || dataTransfer === undefined) return items;
|
|
219
|
+
|
|
220
|
+
let hasCustomType = false;
|
|
221
|
+
if ([...dataTransfer.types].includes(CUSTOM_DRAG_TYPE)) {
|
|
222
|
+
try {
|
|
223
|
+
const parsed = JSON.parse(dataTransfer.getData(CUSTOM_DRAG_TYPE)) as DragItem[];
|
|
224
|
+
for (const item of parsed) {
|
|
225
|
+
items.push({
|
|
226
|
+
kind: "text",
|
|
227
|
+
types: new Set(Object.keys(item)),
|
|
228
|
+
getText: (type) => Promise.resolve(item[type] as string),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
hasCustomType = true;
|
|
232
|
+
} catch {
|
|
233
|
+
// Written by something else under our type; fall back to the native items.
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (hasCustomType) return items;
|
|
238
|
+
|
|
239
|
+
const strings = new Map<string, string>();
|
|
240
|
+
for (const item of dataTransfer.items) {
|
|
241
|
+
if (item.kind === "string") {
|
|
242
|
+
// Read now: the data transfer is emptied once the event handler returns.
|
|
243
|
+
strings.set(item.type === "" ? GENERIC_TYPE : item.type, dataTransfer.getData(item.type));
|
|
244
|
+
} else if (item.kind === "file") {
|
|
245
|
+
if (typeof item.webkitGetAsEntry === "function") {
|
|
246
|
+
const entry = item.webkitGetAsEntry();
|
|
247
|
+
// Firefox lists an image/png item for any pasted file and then answers
|
|
248
|
+
// null for it. https://bugzilla.mozilla.org/show_bug.cgi?id=1699743
|
|
249
|
+
if (entry === null) continue;
|
|
250
|
+
if (entry.isFile) items.push(fileItem(item.getAsFile()));
|
|
251
|
+
else if (entry.isDirectory) items.push(directoryItem(entry as FileSystemDirectoryEntry));
|
|
252
|
+
} else {
|
|
253
|
+
items.push(fileItem(item.getAsFile()));
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Every string entry is a representation of the same one item: the platform
|
|
259
|
+
// cannot carry two text items at once.
|
|
260
|
+
if (strings.size > 0) {
|
|
261
|
+
items.push({
|
|
262
|
+
kind: "text",
|
|
263
|
+
types: new Set(strings.keys()),
|
|
264
|
+
getText: (type) => Promise.resolve(strings.get(type) as string),
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return items;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function blobToString(blob: Blob): Promise<string> {
|
|
272
|
+
if (typeof blob.text === "function") return blob.text();
|
|
273
|
+
return new Promise((resolve, reject) => {
|
|
274
|
+
const reader = new FileReader();
|
|
275
|
+
reader.addEventListener("load", () => resolve(reader.result as string));
|
|
276
|
+
reader.addEventListener("error", () =>
|
|
277
|
+
reject(reader.error ?? new Error("The file could not be read.")),
|
|
278
|
+
);
|
|
279
|
+
reader.readAsText(blob);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function fileItem(file: File | null): FileDropItem {
|
|
284
|
+
if (file === null) throw new Error("No file provided");
|
|
285
|
+
return {
|
|
286
|
+
kind: "file",
|
|
287
|
+
type: file.type === "" ? GENERIC_TYPE : file.type,
|
|
288
|
+
name: file.name,
|
|
289
|
+
getText: () => blobToString(file),
|
|
290
|
+
getFile: () => Promise.resolve(file),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function directoryItem(entry: FileSystemDirectoryEntry): DirectoryDropItem {
|
|
295
|
+
return {
|
|
296
|
+
kind: "directory",
|
|
297
|
+
name: entry.name,
|
|
298
|
+
getEntries: () => directoryEntries(entry),
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
async function* directoryEntries(
|
|
303
|
+
entry: FileSystemDirectoryEntry,
|
|
304
|
+
): AsyncIterable<FileDropItem | DirectoryDropItem> {
|
|
305
|
+
const reader = entry.createReader();
|
|
306
|
+
// A reader returns entries in batches, so it is read until a batch is empty.
|
|
307
|
+
let entries: FileSystemEntry[];
|
|
308
|
+
do {
|
|
309
|
+
entries = await new Promise<FileSystemEntry[]>((resolve, reject) => {
|
|
310
|
+
reader.readEntries(resolve, reject);
|
|
311
|
+
});
|
|
312
|
+
for (const child of entries) {
|
|
313
|
+
if (child.isFile) {
|
|
314
|
+
const file = await new Promise<File>((resolve, reject) => {
|
|
315
|
+
(child as FileSystemFileEntry).file(resolve, reject);
|
|
316
|
+
});
|
|
317
|
+
yield fileItem(file);
|
|
318
|
+
} else if (child.isDirectory) {
|
|
319
|
+
yield directoryItem(child as FileSystemDirectoryEntry);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
} while (entries.length > 0);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export function isTextDropItem(item: DropItem): item is TextDropItem {
|
|
326
|
+
return item.kind === "text";
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
export function isFileDropItem(item: DropItem): item is FileDropItem {
|
|
330
|
+
return item.kind === "file";
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export function isDirectoryDropItem(item: DropItem): item is DirectoryDropItem {
|
|
334
|
+
return item.kind === "directory";
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// ---------------------------------------------------------------------------
|
|
338
|
+
// What every collection on the page needs to know about the current drag
|
|
339
|
+
// ---------------------------------------------------------------------------
|
|
340
|
+
|
|
341
|
+
export interface DnDState {
|
|
342
|
+
draggingCollectionRef?: ElementRef | undefined;
|
|
343
|
+
draggingKeys: Set<Key>;
|
|
344
|
+
dropCollectionRef?: ElementRef | undefined;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
let globalDndState: DnDState = { draggingKeys: new Set() };
|
|
348
|
+
let dropEffect: DropEffect | undefined;
|
|
349
|
+
let allowedDropOperations = NONE;
|
|
350
|
+
|
|
351
|
+
export function dndState(): DnDState {
|
|
352
|
+
return globalDndState;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export function setGlobalDndState(state: DnDState): void {
|
|
356
|
+
globalDndState = state;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** The effect the last drop target settled on, for Chrome on Android's `dragend`. */
|
|
360
|
+
export function globalDropEffect(): DropEffect | undefined {
|
|
361
|
+
return dropEffect;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export function setGlobalDropEffect(effect: DropEffect | undefined): void {
|
|
365
|
+
dropEffect = effect;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** What a drag started on this page really allows, which WebKit misreports. */
|
|
369
|
+
export function globalAllowedDropOperations(): number {
|
|
370
|
+
return allowedDropOperations;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export function setGlobalAllowedDropOperations(operations: number): void {
|
|
374
|
+
allowedDropOperations = operations;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export function refElement(ref: ElementRef | undefined): Element | null {
|
|
378
|
+
return access(ref) ?? null;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
export function setDraggingCollectionRef(ref: ElementRef | undefined): void {
|
|
382
|
+
globalDndState.draggingCollectionRef = ref;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export function setDraggingKeys(keys: Set<Key>): void {
|
|
386
|
+
globalDndState.draggingKeys = keys;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
export function setDropCollectionRef(ref: ElementRef | undefined): void {
|
|
390
|
+
globalDndState.dropCollectionRef = ref;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export function clearGlobalDnDState(): void {
|
|
394
|
+
globalDndState = { draggingKeys: new Set() };
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Whether the drag came from the collection it is being dropped on.
|
|
399
|
+
*
|
|
400
|
+
* A reorder and an insert look the same at the drop; only where the drag
|
|
401
|
+
* started tells them apart.
|
|
402
|
+
*/
|
|
403
|
+
export function isInternalDropOperation(ref?: ElementRef): boolean {
|
|
404
|
+
const dragging = refElement(globalDndState.draggingCollectionRef);
|
|
405
|
+
return (
|
|
406
|
+
dragging !== null &&
|
|
407
|
+
dragging === (refElement(ref) ?? refElement(globalDndState.dropCollectionRef))
|
|
408
|
+
);
|
|
409
|
+
}
|