vue-grid-layout-headless 4.6.0 → 4.7.0
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/composables/useGridLayout.d.ts +5 -0
- package/dist/composables/useGridLayout.js +312 -0
- package/dist/index.d.ts +23 -119
- package/dist/index.js +7 -598
- package/dist/models/CollisionMode.d.ts +5 -0
- package/dist/models/CollisionMode.js +8 -0
- package/dist/models/CompactType.d.ts +5 -0
- package/dist/models/CompactType.js +8 -0
- package/dist/models/GridBlock.d.ts +4 -0
- package/dist/models/GridCell.d.ts +6 -0
- package/dist/models/GridCommit.d.ts +4 -0
- package/dist/models/GridGeometry.d.ts +6 -0
- package/dist/models/GridGesture.d.ts +15 -0
- package/dist/models/GridItem.d.ts +4 -0
- package/dist/models/GridLayout.d.ts +14 -0
- package/dist/models/GridLayoutOptions.d.ts +21 -0
- package/dist/models/GridPlaceholder.d.ts +5 -0
- package/dist/models/GridPoint.d.ts +4 -0
- package/dist/models/GridRefusal.d.ts +2 -0
- package/dist/models/GridSpacing.d.ts +4 -0
- package/dist/models/GridStep.d.ts +6 -0
- package/dist/models/GridTile.d.ts +9 -0
- package/dist/models/GridTransfer.d.ts +7 -0
- package/dist/models/MountedGrid.d.ts +9 -0
- package/dist/models/ResizeEdge.d.ts +10 -0
- package/dist/models/ResizeEdge.js +13 -0
- package/dist/placement/checkChangesHeight.d.ts +2 -0
- package/dist/placement/checkChangesHeight.js +12 -0
- package/dist/placement/checkIsColliding.js +3 -0
- package/dist/placement/checkIsSameCell.js +3 -0
- package/dist/placement/clampCell.js +14 -0
- package/dist/placement/compactLayout.js +33 -0
- package/dist/placement/fitLayout.js +5 -0
- package/dist/placement/getCellPosition.js +3 -0
- package/dist/placement/getCellSize.js +3 -0
- package/dist/placement/getCellSpan.js +3 -0
- package/dist/placement/getColumnPitch.js +3 -0
- package/dist/placement/getFirstFreeCell.d.ts +6 -0
- package/dist/placement/getFirstFreeCell.js +21 -0
- package/dist/placement/getGestureCell.js +87 -0
- package/dist/placement/getLayoutBottom.js +3 -0
- package/dist/placement/moveItem.js +23 -0
- package/dist/placement/placeMove.js +8 -0
- package/dist/placement/resolveMove.js +27 -0
- package/dist/services/constants.js +3 -0
- package/dist/services/findGridAt.js +9 -0
- package/dist/services/findGridRoot.js +8 -0
- package/dist/services/mountedGrids.js +3 -0
- package/dist/services/startExternalDrag.d.ts +4 -0
- package/dist/services/startExternalDrag.js +44 -0
- package/package.json +4 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GridItem } from "./GridItem.js";
|
|
2
|
+
import { GridPlaceholder } from "./GridPlaceholder.js";
|
|
3
|
+
import { GridStep } from "./GridStep.js";
|
|
4
|
+
import { GridTile } from "./GridTile.js";
|
|
5
|
+
import { ResizeEdge } from "./ResizeEdge.js";
|
|
6
|
+
import { ComputedRef } from "vue";
|
|
7
|
+
export interface GridLayout<T extends GridItem = GridItem> {
|
|
8
|
+
gridHeight: ComputedRef<number>;
|
|
9
|
+
placeholder: ComputedRef<GridPlaceholder | undefined>;
|
|
10
|
+
reportContentHeight: (id: string, contentHeight: number) => void;
|
|
11
|
+
startGesture: (event: PointerEvent, item: T, edge?: ResizeEdge) => void;
|
|
12
|
+
stepItem: (id: string, step: GridStep) => boolean;
|
|
13
|
+
tiles: ComputedRef<GridTile<T>[]>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CollisionMode } from "./CollisionMode.js";
|
|
2
|
+
import { CompactType } from "./CompactType.js";
|
|
3
|
+
import { GridCommit } from "./GridCommit.js";
|
|
4
|
+
import { GridItem } from "./GridItem.js";
|
|
5
|
+
import { GridRefusal } from "./GridRefusal.js";
|
|
6
|
+
import { GridSpacing } from "./GridSpacing.js";
|
|
7
|
+
import { GridTransfer } from "./GridTransfer.js";
|
|
8
|
+
export interface GridLayoutOptions<T extends GridItem = GridItem> {
|
|
9
|
+
checkIsRefused?: GridRefusal;
|
|
10
|
+
checkIsSolid?: (item: T) => boolean;
|
|
11
|
+
collision: CollisionMode;
|
|
12
|
+
columnNumber: number;
|
|
13
|
+
compactType: CompactType;
|
|
14
|
+
dragStartDistance: number;
|
|
15
|
+
isEditable: boolean;
|
|
16
|
+
items: T[];
|
|
17
|
+
onCommit: (commit: GridCommit) => void;
|
|
18
|
+
onTransfer?: (transfer: GridTransfer<T>) => void;
|
|
19
|
+
rowHeight: number;
|
|
20
|
+
spacing: GridSpacing;
|
|
21
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GridGeometry } from "./GridGeometry.js";
|
|
2
|
+
import { GridItem } from "./GridItem.js";
|
|
3
|
+
import { GridPoint } from "./GridPoint.js";
|
|
4
|
+
export interface GridTile<T extends GridItem = GridItem> {
|
|
5
|
+
geometry: GridGeometry;
|
|
6
|
+
isDragged: boolean;
|
|
7
|
+
item: T;
|
|
8
|
+
offset: GridPoint;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GridCell } from "./GridCell.js";
|
|
2
|
+
import { GridItem } from "./GridItem.js";
|
|
3
|
+
import { GridPoint } from "./GridPoint.js";
|
|
4
|
+
export interface MountedGrid {
|
|
5
|
+
accept: (item: GridItem, point: GridPoint) => GridCell | undefined;
|
|
6
|
+
clearPreview: () => void;
|
|
7
|
+
element: HTMLElement;
|
|
8
|
+
preview: (item: GridItem, point: GridPoint) => boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/models/ResizeEdge.ts
|
|
2
|
+
let ResizeEdge = /* @__PURE__ */ function(ResizeEdge) {
|
|
3
|
+
ResizeEdge["East"] = "East";
|
|
4
|
+
ResizeEdge["North"] = "North";
|
|
5
|
+
ResizeEdge["NorthEast"] = "NorthEast";
|
|
6
|
+
ResizeEdge["NorthWest"] = "NorthWest";
|
|
7
|
+
ResizeEdge["South"] = "South";
|
|
8
|
+
ResizeEdge["SouthEast"] = "SouthEast";
|
|
9
|
+
ResizeEdge["SouthWest"] = "SouthWest";
|
|
10
|
+
ResizeEdge["West"] = "West";
|
|
11
|
+
return ResizeEdge;
|
|
12
|
+
}({});
|
|
13
|
+
export { ResizeEdge };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "../models/ResizeEdge.js";
|
|
2
|
+
// src/placement/checkChangesHeight.ts
|
|
3
|
+
const HEIGHT_EDGES = /* @__PURE__ */ new Set([
|
|
4
|
+
"North",
|
|
5
|
+
"NorthEast",
|
|
6
|
+
"NorthWest",
|
|
7
|
+
"South",
|
|
8
|
+
"SouthEast",
|
|
9
|
+
"SouthWest"
|
|
10
|
+
]);
|
|
11
|
+
const checkChangesHeight = (edge) => HEIGHT_EDGES.has(edge);
|
|
12
|
+
export { checkChangesHeight };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// src/placement/clampCell.ts
|
|
2
|
+
const clampCell = (cell, columnNumber) => {
|
|
3
|
+
const h = Math.max(1, cell.h);
|
|
4
|
+
const w = Math.max(1, Math.min(cell.w, columnNumber));
|
|
5
|
+
const x = Math.min(Math.max(cell.x, 0), columnNumber - w);
|
|
6
|
+
return {
|
|
7
|
+
...cell,
|
|
8
|
+
h,
|
|
9
|
+
w,
|
|
10
|
+
x,
|
|
11
|
+
y: Math.max(cell.y, 0)
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export { clampCell };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "../models/CompactType.js";
|
|
2
|
+
import { checkIsColliding } from "./checkIsColliding.js";
|
|
3
|
+
// src/placement/compactLayout.ts
|
|
4
|
+
const compactLayout = (layout, columnNumber, compactType, solidIds = /* @__PURE__ */ new Set()) => {
|
|
5
|
+
const copies = layout.map((item) => ({ ...item }));
|
|
6
|
+
const isHorizontal = compactType === "Horizontal";
|
|
7
|
+
const axis = isHorizontal ? "x" : "y";
|
|
8
|
+
const crossAxis = isHorizontal ? "y" : "x";
|
|
9
|
+
const placedItems = [];
|
|
10
|
+
const checkIsBlocked = (candidate) => placedItems.some((placedItem) => checkIsColliding(candidate, placedItem));
|
|
11
|
+
const riseAlongAxis = (item) => {
|
|
12
|
+
while (item[axis] > 0 && !checkIsBlocked({
|
|
13
|
+
...item,
|
|
14
|
+
[axis]: item[axis] - 1
|
|
15
|
+
})) item[axis] -= 1;
|
|
16
|
+
};
|
|
17
|
+
const pushAlongAxis = (item) => {
|
|
18
|
+
if (isHorizontal && item.x + item.w + 1 > columnNumber) {
|
|
19
|
+
item.x = columnNumber - item.w;
|
|
20
|
+
item.y += 1;
|
|
21
|
+
riseAlongAxis(item);
|
|
22
|
+
} else item[axis] += 1;
|
|
23
|
+
};
|
|
24
|
+
const sortedItems = copies.toSorted((firstItem, secondItem) => firstItem[axis] - secondItem[axis] || firstItem[crossAxis] - secondItem[crossAxis]);
|
|
25
|
+
const placementOrder = [...sortedItems.filter((item) => solidIds.has(item.id)), ...sortedItems.filter((item) => !solidIds.has(item.id))];
|
|
26
|
+
for (const item of placementOrder) {
|
|
27
|
+
if (compactType !== "None" && !solidIds.has(item.id)) riseAlongAxis(item);
|
|
28
|
+
while (checkIsBlocked(item)) pushAlongAxis(item);
|
|
29
|
+
placedItems.push(item);
|
|
30
|
+
}
|
|
31
|
+
return sortedItems;
|
|
32
|
+
};
|
|
33
|
+
export { compactLayout };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { clampCell } from "./clampCell.js";
|
|
2
|
+
import { compactLayout } from "./compactLayout.js";
|
|
3
|
+
// src/placement/fitLayout.ts
|
|
4
|
+
const fitLayout = (layout, columnNumber, compactType, solidIds) => compactLayout(layout.map((item) => clampCell(item, columnNumber)), columnNumber, compactType, solidIds);
|
|
5
|
+
export { fitLayout };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { checkIsColliding } from "./checkIsColliding.js";
|
|
2
|
+
import { clampCell } from "./clampCell.js";
|
|
3
|
+
// src/placement/getFirstFreeCell.ts
|
|
4
|
+
const getFirstFreeCell = (layout, columnNumber, span) => {
|
|
5
|
+
const { h, w } = clampCell({
|
|
6
|
+
h: span.h,
|
|
7
|
+
w: span.w,
|
|
8
|
+
x: 0,
|
|
9
|
+
y: 0
|
|
10
|
+
}, columnNumber);
|
|
11
|
+
for (let y = 0;; y += 1) for (let x = 0; x <= columnNumber - w; x += 1) {
|
|
12
|
+
const cell = {
|
|
13
|
+
h,
|
|
14
|
+
w,
|
|
15
|
+
x,
|
|
16
|
+
y
|
|
17
|
+
};
|
|
18
|
+
if (!layout.some((item) => checkIsColliding(cell, item))) return cell;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export { getFirstFreeCell };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import "../models/ResizeEdge.js";
|
|
2
|
+
// src/placement/getGestureCell.ts
|
|
3
|
+
const ResizeEdgeSidesMap = {
|
|
4
|
+
["East"]: {
|
|
5
|
+
isEast: true,
|
|
6
|
+
isNorth: false,
|
|
7
|
+
isSouth: false,
|
|
8
|
+
isWest: false
|
|
9
|
+
},
|
|
10
|
+
["North"]: {
|
|
11
|
+
isEast: false,
|
|
12
|
+
isNorth: true,
|
|
13
|
+
isSouth: false,
|
|
14
|
+
isWest: false
|
|
15
|
+
},
|
|
16
|
+
["NorthEast"]: {
|
|
17
|
+
isEast: true,
|
|
18
|
+
isNorth: true,
|
|
19
|
+
isSouth: false,
|
|
20
|
+
isWest: false
|
|
21
|
+
},
|
|
22
|
+
["NorthWest"]: {
|
|
23
|
+
isEast: false,
|
|
24
|
+
isNorth: true,
|
|
25
|
+
isSouth: false,
|
|
26
|
+
isWest: true
|
|
27
|
+
},
|
|
28
|
+
["South"]: {
|
|
29
|
+
isEast: false,
|
|
30
|
+
isNorth: false,
|
|
31
|
+
isSouth: true,
|
|
32
|
+
isWest: false
|
|
33
|
+
},
|
|
34
|
+
["SouthEast"]: {
|
|
35
|
+
isEast: true,
|
|
36
|
+
isNorth: false,
|
|
37
|
+
isSouth: true,
|
|
38
|
+
isWest: false
|
|
39
|
+
},
|
|
40
|
+
["SouthWest"]: {
|
|
41
|
+
isEast: false,
|
|
42
|
+
isNorth: false,
|
|
43
|
+
isSouth: true,
|
|
44
|
+
isWest: true
|
|
45
|
+
},
|
|
46
|
+
["West"]: {
|
|
47
|
+
isEast: false,
|
|
48
|
+
isNorth: false,
|
|
49
|
+
isSouth: false,
|
|
50
|
+
isWest: true
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const getGestureCell = ({ columnNumber, columnPitch, edge, offset, origin, rowPitch }) => {
|
|
54
|
+
const columnDelta = Math.round(offset.x / columnPitch);
|
|
55
|
+
const rowDelta = Math.round(offset.y / rowPitch);
|
|
56
|
+
if (!edge) {
|
|
57
|
+
const x = Math.min(Math.max(origin.x + columnDelta, 0), columnNumber - origin.w);
|
|
58
|
+
const y = Math.max(0, origin.y + rowDelta);
|
|
59
|
+
return {
|
|
60
|
+
h: origin.h,
|
|
61
|
+
id: origin.id,
|
|
62
|
+
w: origin.w,
|
|
63
|
+
x,
|
|
64
|
+
y
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const { isEast, isNorth, isSouth, isWest } = ResizeEdgeSidesMap[edge];
|
|
68
|
+
const right = origin.x + origin.w;
|
|
69
|
+
const bottom = origin.y + origin.h;
|
|
70
|
+
const leftX = Math.min(Math.max(origin.x + columnDelta, 0), right - 1);
|
|
71
|
+
const eastWidth = Math.min(Math.max(1, origin.w + columnDelta), columnNumber - origin.x);
|
|
72
|
+
const topY = Math.min(Math.max(origin.y + rowDelta, 0), bottom - 1);
|
|
73
|
+
const southHeight = Math.max(1, origin.h + rowDelta);
|
|
74
|
+
const x = isWest ? leftX : origin.x;
|
|
75
|
+
const widthFromRight = isEast ? eastWidth : origin.w;
|
|
76
|
+
const w = isWest ? right - leftX : widthFromRight;
|
|
77
|
+
const y = isNorth ? topY : origin.y;
|
|
78
|
+
const heightFromBottom = isSouth ? southHeight : origin.h;
|
|
79
|
+
return {
|
|
80
|
+
h: isNorth ? bottom - topY : heightFromBottom,
|
|
81
|
+
id: origin.id,
|
|
82
|
+
w,
|
|
83
|
+
x,
|
|
84
|
+
y
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
export { getGestureCell };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { checkIsColliding } from "./checkIsColliding.js";
|
|
2
|
+
import "../services/constants.js";
|
|
3
|
+
// src/placement/moveItem.ts
|
|
4
|
+
const moveItem = (layout, target) => {
|
|
5
|
+
const movedLayout = layout.map((item) => item.id === target.id ? {
|
|
6
|
+
...item,
|
|
7
|
+
...target
|
|
8
|
+
} : { ...item });
|
|
9
|
+
const pushedIds = /* @__PURE__ */ new Set([target.id]);
|
|
10
|
+
const pushBelow = (pusher) => {
|
|
11
|
+
for (const item of movedLayout) {
|
|
12
|
+
if (pushedIds.has(item.id) || !checkIsColliding(pusher, item)) continue;
|
|
13
|
+
if (item.y < pusher.y && pusher.y - item.y > item.h * .25) continue;
|
|
14
|
+
pushedIds.add(item.id);
|
|
15
|
+
item.y = pusher.y + pusher.h;
|
|
16
|
+
pushBelow(item);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const movedItem = movedLayout.find((item) => item.id === target.id);
|
|
20
|
+
if (movedItem) pushBelow(movedItem);
|
|
21
|
+
return movedLayout;
|
|
22
|
+
};
|
|
23
|
+
export { moveItem };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { compactLayout } from "./compactLayout.js";
|
|
2
|
+
import { resolveMove } from "./resolveMove.js";
|
|
3
|
+
// src/placement/placeMove.ts
|
|
4
|
+
const placeMove = (layout, target, { collision, columnNumber, compactType }, solidIds) => {
|
|
5
|
+
const resolvedLayout = resolveMove(layout, target, collision, columnNumber, solidIds);
|
|
6
|
+
return resolvedLayout && compactLayout(resolvedLayout, columnNumber, compactType, solidIds);
|
|
7
|
+
};
|
|
8
|
+
export { placeMove };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "../models/CollisionMode.js";
|
|
2
|
+
import { checkIsColliding } from "./checkIsColliding.js";
|
|
3
|
+
import { checkIsSameCell } from "./checkIsSameCell.js";
|
|
4
|
+
import { moveItem } from "./moveItem.js";
|
|
5
|
+
// src/placement/resolveMove.ts
|
|
6
|
+
const resolveMove = (layout, target, collision, columnNumber, solidIds = /* @__PURE__ */ new Set()) => {
|
|
7
|
+
const landedItems = layout.filter((item) => item.id !== target.id && checkIsColliding(target, item));
|
|
8
|
+
const [landedItem] = landedItems;
|
|
9
|
+
const movedItem = layout.find((item) => item.id === target.id);
|
|
10
|
+
if (collision === "Prevent" && landedItems.length > 0) return void 0;
|
|
11
|
+
if (landedItems.some((item) => solidIds.has(item.id))) return void 0;
|
|
12
|
+
const isMove = movedItem !== void 0 && movedItem.w === target.w && movedItem.h === target.h;
|
|
13
|
+
const resolvedLayout = collision === "Swap" && isMove && landedItems.length === 1 && landedItem && movedItem && movedItem.x + landedItem.w <= columnNumber && landedItem.x + movedItem.w <= columnNumber ? moveItem(layout.map((item) => item.id === landedItem.id ? {
|
|
14
|
+
...item,
|
|
15
|
+
x: movedItem.x,
|
|
16
|
+
y: movedItem.y
|
|
17
|
+
} : { ...item }), {
|
|
18
|
+
...target,
|
|
19
|
+
x: landedItem.x,
|
|
20
|
+
y: landedItem.y
|
|
21
|
+
}) : moveItem(layout, target);
|
|
22
|
+
return layout.some((item) => {
|
|
23
|
+
const resolvedItem = resolvedLayout.find(({ id }) => id === item.id);
|
|
24
|
+
return solidIds.has(item.id) && item.id !== target.id && resolvedItem !== void 0 && !checkIsSameCell(resolvedItem, item);
|
|
25
|
+
}) ? void 0 : resolvedLayout;
|
|
26
|
+
};
|
|
27
|
+
export { resolveMove };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { findGridRoot } from "./findGridRoot.js";
|
|
2
|
+
import { mountedGrids } from "./mountedGrids.js";
|
|
3
|
+
// src/services/findGridAt.ts
|
|
4
|
+
const findGridAt = (point, element) => {
|
|
5
|
+
const hit = window.document.elementsFromPoint(point.x, point.y).find((candidate) => !element.contains(candidate));
|
|
6
|
+
const root = findGridRoot(hit ?? null);
|
|
7
|
+
return root ? mountedGrids.get(root) : void 0;
|
|
8
|
+
};
|
|
9
|
+
export { findGridAt };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { mountedGrids } from "./mountedGrids.js";
|
|
2
|
+
// src/services/findGridRoot.ts
|
|
3
|
+
const findGridRoot = (element) => {
|
|
4
|
+
let current = element;
|
|
5
|
+
while (current && !mountedGrids.has(current)) current = current.parentElement;
|
|
6
|
+
return current ?? void 0;
|
|
7
|
+
};
|
|
8
|
+
export { findGridRoot };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { GridCell } from "../models/GridCell.js";
|
|
2
|
+
import { GridItem } from "../models/GridItem.js";
|
|
3
|
+
import { GridRefusal } from "../models/GridRefusal.js";
|
|
4
|
+
export declare const startExternalDrag: (event: PointerEvent, item: GridItem, onDrop: (cell: GridCell, target: HTMLElement) => void, checkIsRefused?: GridRefusal) => void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { findGridAt } from "./findGridAt.js";
|
|
2
|
+
// src/services/startExternalDrag.ts
|
|
3
|
+
const startExternalDrag = (event, item, onDrop, checkIsRefused) => {
|
|
4
|
+
if (event.button !== 0) return;
|
|
5
|
+
if (!(event.currentTarget instanceof HTMLElement)) return;
|
|
6
|
+
const element = event.currentTarget;
|
|
7
|
+
const { pointerId } = event;
|
|
8
|
+
const checkIsGridRefused = (grid) => Boolean(checkIsRefused?.(item, grid.element));
|
|
9
|
+
element.setPointerCapture(pointerId);
|
|
10
|
+
const controller = new AbortController();
|
|
11
|
+
const { signal } = controller;
|
|
12
|
+
let lastGrid;
|
|
13
|
+
element.addEventListener("pointermove", (moveEvent) => {
|
|
14
|
+
if (moveEvent.pointerId !== pointerId) return;
|
|
15
|
+
const point = {
|
|
16
|
+
x: moveEvent.clientX,
|
|
17
|
+
y: moveEvent.clientY
|
|
18
|
+
};
|
|
19
|
+
const grid = findGridAt(point, element);
|
|
20
|
+
if (grid !== lastGrid) {
|
|
21
|
+
lastGrid?.clearPreview();
|
|
22
|
+
lastGrid = grid;
|
|
23
|
+
}
|
|
24
|
+
if (grid && !checkIsGridRefused(grid)) grid.preview(item, point);
|
|
25
|
+
}, { signal });
|
|
26
|
+
element.addEventListener("pointerup", (releaseEvent) => {
|
|
27
|
+
if (releaseEvent.pointerId !== pointerId) return;
|
|
28
|
+
controller.abort();
|
|
29
|
+
lastGrid?.clearPreview();
|
|
30
|
+
const point = {
|
|
31
|
+
x: releaseEvent.clientX,
|
|
32
|
+
y: releaseEvent.clientY
|
|
33
|
+
};
|
|
34
|
+
const grid = findGridAt(point, element);
|
|
35
|
+
const cell = grid && !checkIsGridRefused(grid) ? grid.accept(item, point) : void 0;
|
|
36
|
+
if (grid && cell) onDrop(cell, grid.element);
|
|
37
|
+
}, { signal });
|
|
38
|
+
element.addEventListener("pointercancel", (cancelEvent) => {
|
|
39
|
+
if (cancelEvent.pointerId !== pointerId) return;
|
|
40
|
+
controller.abort();
|
|
41
|
+
lastGrid?.clearPreview();
|
|
42
|
+
}, { signal });
|
|
43
|
+
};
|
|
44
|
+
export { startExternalDrag };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-grid-layout-headless",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "A headless grid: the placement of items on a grid of cells, and the pointer gestures that move and resize them, with no styling.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dashboard",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"typecheck": "tsrs --fast"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@esposter/shared": "4.
|
|
47
|
+
"@esposter/shared": "4.7.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@esposter/configuration": "4.
|
|
50
|
+
"@esposter/configuration": "4.7.0",
|
|
51
51
|
"@vue/test-utils": "^2.5.1",
|
|
52
52
|
"happy-dom": "^21.0.4",
|
|
53
53
|
"tsdown": "^0.23.7"
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"vue": "^3.5.45"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "c819fd8f6196452894babddc3df9fb20cb0d6add"
|
|
59
59
|
}
|