vue-grid-layout-headless 4.11.0 → 4.12.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/models/CollisionMode.d.ts +6 -5
- package/dist/models/CollisionMode.js +5 -6
- package/dist/models/CompactType.d.ts +6 -5
- package/dist/models/CompactType.js +5 -6
- package/dist/models/GridGesture.d.ts +3 -3
- package/dist/models/GridLayoutOptions.d.ts +3 -3
- package/dist/models/ResizeEdge.d.ts +11 -10
- package/dist/models/ResizeEdge.js +10 -11
- package/dist/placement/checkChangesHeight.js +7 -7
- package/dist/placement/compactLayout.js +3 -3
- package/dist/placement/getGestureCell.js +9 -9
- package/dist/placement/resolveMove.js +3 -3
- package/package.json +5 -5
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
Prevent
|
|
3
|
-
Push
|
|
4
|
-
Swap
|
|
5
|
-
}
|
|
1
|
+
export declare const CollisionMode: {
|
|
2
|
+
readonly Prevent: "Prevent";
|
|
3
|
+
readonly Push: "Push";
|
|
4
|
+
readonly Swap: "Swap";
|
|
5
|
+
};
|
|
6
|
+
export type CollisionMode = (typeof CollisionMode)[keyof typeof CollisionMode];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// src/models/CollisionMode.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}({});
|
|
2
|
+
const CollisionMode = {
|
|
3
|
+
Prevent: "Prevent",
|
|
4
|
+
Push: "Push",
|
|
5
|
+
Swap: "Swap"
|
|
6
|
+
};
|
|
8
7
|
export { CollisionMode };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
Horizontal
|
|
3
|
-
None
|
|
4
|
-
Vertical
|
|
5
|
-
}
|
|
1
|
+
export declare const CompactType: {
|
|
2
|
+
readonly Horizontal: "Horizontal";
|
|
3
|
+
readonly None: "None";
|
|
4
|
+
readonly Vertical: "Vertical";
|
|
5
|
+
};
|
|
6
|
+
export type CompactType = (typeof CompactType)[keyof typeof CompactType];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// src/models/CompactType.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}({});
|
|
2
|
+
const CompactType = {
|
|
3
|
+
Horizontal: "Horizontal",
|
|
4
|
+
None: "None",
|
|
5
|
+
Vertical: "Vertical"
|
|
6
|
+
};
|
|
8
7
|
export { CompactType };
|
|
@@ -3,13 +3,13 @@ import { GridPoint } from "./GridPoint.js";
|
|
|
3
3
|
import { MountedGrid } from "./MountedGrid.js";
|
|
4
4
|
import { ResizeEdge } from "./ResizeEdge.js";
|
|
5
5
|
export interface GridGesture<T extends GridBlock = GridBlock> {
|
|
6
|
-
cell?: GridBlock;
|
|
7
|
-
edge?: ResizeEdge;
|
|
6
|
+
cell?: GridBlock | undefined;
|
|
7
|
+
edge?: ResizeEdge | undefined;
|
|
8
8
|
element: Element;
|
|
9
9
|
isStarted: boolean;
|
|
10
10
|
offset: GridPoint;
|
|
11
11
|
origin: T;
|
|
12
12
|
pointerId: number;
|
|
13
13
|
start: GridPoint;
|
|
14
|
-
transfer?: MountedGrid;
|
|
14
|
+
transfer?: MountedGrid | undefined;
|
|
15
15
|
}
|
|
@@ -6,8 +6,8 @@ import { GridRefusal } from "./GridRefusal.js";
|
|
|
6
6
|
import { GridSpacing } from "./GridSpacing.js";
|
|
7
7
|
import { GridTransfer } from "./GridTransfer.js";
|
|
8
8
|
export interface GridLayoutOptions<T extends GridItem = GridItem> {
|
|
9
|
-
checkIsRefused?: GridRefusal;
|
|
10
|
-
checkIsSolid?: (item: T) => boolean;
|
|
9
|
+
checkIsRefused?: GridRefusal | undefined;
|
|
10
|
+
checkIsSolid?: ((item: T) => boolean) | undefined;
|
|
11
11
|
collision: CollisionMode;
|
|
12
12
|
columnNumber: number;
|
|
13
13
|
compactType: CompactType;
|
|
@@ -15,7 +15,7 @@ export interface GridLayoutOptions<T extends GridItem = GridItem> {
|
|
|
15
15
|
isEditable: boolean;
|
|
16
16
|
items: T[];
|
|
17
17
|
onCommit: (commit: GridCommit) => void;
|
|
18
|
-
onTransfer?: (transfer: GridTransfer<T>) => void;
|
|
18
|
+
onTransfer?: ((transfer: GridTransfer<T>) => void) | undefined;
|
|
19
19
|
rowHeight: number;
|
|
20
20
|
spacing: GridSpacing;
|
|
21
21
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
East
|
|
3
|
-
North
|
|
4
|
-
NorthEast
|
|
5
|
-
NorthWest
|
|
6
|
-
South
|
|
7
|
-
SouthEast
|
|
8
|
-
SouthWest
|
|
9
|
-
West
|
|
10
|
-
}
|
|
1
|
+
export declare const ResizeEdge: {
|
|
2
|
+
readonly East: "East";
|
|
3
|
+
readonly North: "North";
|
|
4
|
+
readonly NorthEast: "NorthEast";
|
|
5
|
+
readonly NorthWest: "NorthWest";
|
|
6
|
+
readonly South: "South";
|
|
7
|
+
readonly SouthEast: "SouthEast";
|
|
8
|
+
readonly SouthWest: "SouthWest";
|
|
9
|
+
readonly West: "West";
|
|
10
|
+
};
|
|
11
|
+
export type ResizeEdge = (typeof ResizeEdge)[keyof typeof ResizeEdge];
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// src/models/ResizeEdge.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}({});
|
|
2
|
+
const ResizeEdge = {
|
|
3
|
+
East: "East",
|
|
4
|
+
North: "North",
|
|
5
|
+
NorthEast: "NorthEast",
|
|
6
|
+
NorthWest: "NorthWest",
|
|
7
|
+
South: "South",
|
|
8
|
+
SouthEast: "SouthEast",
|
|
9
|
+
SouthWest: "SouthWest",
|
|
10
|
+
West: "West"
|
|
11
|
+
};
|
|
13
12
|
export { ResizeEdge };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import "../models/ResizeEdge.js";
|
|
1
|
+
import { ResizeEdge } from "../models/ResizeEdge.js";
|
|
2
2
|
// src/placement/checkChangesHeight.ts
|
|
3
3
|
const HEIGHT_EDGES = /* @__PURE__ */ new Set([
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
ResizeEdge.North,
|
|
5
|
+
ResizeEdge.NorthEast,
|
|
6
|
+
ResizeEdge.NorthWest,
|
|
7
|
+
ResizeEdge.South,
|
|
8
|
+
ResizeEdge.SouthEast,
|
|
9
|
+
ResizeEdge.SouthWest
|
|
10
10
|
]);
|
|
11
11
|
const checkChangesHeight = (edge) => HEIGHT_EDGES.has(edge);
|
|
12
12
|
export { checkChangesHeight };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "../models/CompactType.js";
|
|
1
|
+
import { CompactType } from "../models/CompactType.js";
|
|
2
2
|
import { checkIsColliding } from "./checkIsColliding.js";
|
|
3
3
|
// src/placement/compactLayout.ts
|
|
4
4
|
const compactLayout = (layout, columnNumber, compactType, solidIds = /* @__PURE__ */ new Set()) => {
|
|
5
5
|
const copies = layout.map((item) => ({ ...item }));
|
|
6
|
-
const isHorizontal = compactType ===
|
|
6
|
+
const isHorizontal = compactType === CompactType.Horizontal;
|
|
7
7
|
const axis = isHorizontal ? "x" : "y";
|
|
8
8
|
const crossAxis = isHorizontal ? "y" : "x";
|
|
9
9
|
const placedItems = [];
|
|
@@ -24,7 +24,7 @@ const compactLayout = (layout, columnNumber, compactType, solidIds = /* @__PURE_
|
|
|
24
24
|
const sortedItems = copies.toSorted((firstItem, secondItem) => firstItem[axis] - secondItem[axis] || firstItem[crossAxis] - secondItem[crossAxis]);
|
|
25
25
|
const placementOrder = [...sortedItems.filter((item) => solidIds.has(item.id)), ...sortedItems.filter((item) => !solidIds.has(item.id))];
|
|
26
26
|
for (const item of placementOrder) {
|
|
27
|
-
if (compactType !==
|
|
27
|
+
if (compactType !== CompactType.None && !solidIds.has(item.id)) riseAlongAxis(item);
|
|
28
28
|
while (checkIsBlocked(item)) pushAlongAxis(item);
|
|
29
29
|
placedItems.push(item);
|
|
30
30
|
}
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import "../models/ResizeEdge.js";
|
|
1
|
+
import { ResizeEdge } from "../models/ResizeEdge.js";
|
|
2
2
|
// src/placement/getGestureCell.ts
|
|
3
3
|
const ResizeEdgeSidesMap = {
|
|
4
|
-
[
|
|
4
|
+
[ResizeEdge.East]: {
|
|
5
5
|
isEast: true,
|
|
6
6
|
isNorth: false,
|
|
7
7
|
isSouth: false,
|
|
8
8
|
isWest: false
|
|
9
9
|
},
|
|
10
|
-
[
|
|
10
|
+
[ResizeEdge.North]: {
|
|
11
11
|
isEast: false,
|
|
12
12
|
isNorth: true,
|
|
13
13
|
isSouth: false,
|
|
14
14
|
isWest: false
|
|
15
15
|
},
|
|
16
|
-
[
|
|
16
|
+
[ResizeEdge.NorthEast]: {
|
|
17
17
|
isEast: true,
|
|
18
18
|
isNorth: true,
|
|
19
19
|
isSouth: false,
|
|
20
20
|
isWest: false
|
|
21
21
|
},
|
|
22
|
-
[
|
|
22
|
+
[ResizeEdge.NorthWest]: {
|
|
23
23
|
isEast: false,
|
|
24
24
|
isNorth: true,
|
|
25
25
|
isSouth: false,
|
|
26
26
|
isWest: true
|
|
27
27
|
},
|
|
28
|
-
[
|
|
28
|
+
[ResizeEdge.South]: {
|
|
29
29
|
isEast: false,
|
|
30
30
|
isNorth: false,
|
|
31
31
|
isSouth: true,
|
|
32
32
|
isWest: false
|
|
33
33
|
},
|
|
34
|
-
[
|
|
34
|
+
[ResizeEdge.SouthEast]: {
|
|
35
35
|
isEast: true,
|
|
36
36
|
isNorth: false,
|
|
37
37
|
isSouth: true,
|
|
38
38
|
isWest: false
|
|
39
39
|
},
|
|
40
|
-
[
|
|
40
|
+
[ResizeEdge.SouthWest]: {
|
|
41
41
|
isEast: false,
|
|
42
42
|
isNorth: false,
|
|
43
43
|
isSouth: true,
|
|
44
44
|
isWest: true
|
|
45
45
|
},
|
|
46
|
-
[
|
|
46
|
+
[ResizeEdge.West]: {
|
|
47
47
|
isEast: false,
|
|
48
48
|
isNorth: false,
|
|
49
49
|
isSouth: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "../models/CollisionMode.js";
|
|
1
|
+
import { CollisionMode } from "../models/CollisionMode.js";
|
|
2
2
|
import { checkIsColliding } from "./checkIsColliding.js";
|
|
3
3
|
import { checkIsSameCell } from "./checkIsSameCell.js";
|
|
4
4
|
import { moveItem } from "./moveItem.js";
|
|
@@ -7,10 +7,10 @@ const resolveMove = (layout, target, collision, columnNumber, solidIds = /* @__P
|
|
|
7
7
|
const landedItems = layout.filter((item) => item.id !== target.id && checkIsColliding(target, item));
|
|
8
8
|
const [landedItem] = landedItems;
|
|
9
9
|
const movedItem = layout.find((item) => item.id === target.id);
|
|
10
|
-
if (collision ===
|
|
10
|
+
if (collision === CollisionMode.Prevent && landedItems.length > 0) return void 0;
|
|
11
11
|
if (landedItems.some((item) => solidIds.has(item.id))) return void 0;
|
|
12
12
|
const isMove = movedItem !== void 0 && movedItem.w === target.w && movedItem.h === target.h;
|
|
13
|
-
const resolvedLayout = collision ===
|
|
13
|
+
const resolvedLayout = collision === CollisionMode.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
14
|
...item,
|
|
15
15
|
x: movedItem.x,
|
|
16
16
|
y: movedItem.y
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-grid-layout-headless",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.12.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,16 +44,16 @@
|
|
|
44
44
|
"typecheck": "tsrs --fast"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@esposter/shared": "4.
|
|
47
|
+
"@esposter/shared": "4.12.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@esposter/configuration": "4.
|
|
51
|
-
"@vue/test-utils": "^2.
|
|
50
|
+
"@esposter/configuration": "4.12.0",
|
|
51
|
+
"@vue/test-utils": "^2.6.0",
|
|
52
52
|
"happy-dom": "^21.0.4",
|
|
53
53
|
"tsdown": "^0.23.7"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"vue": "^3.5.45"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "6667a4a1664bf5282bec24f4c7e6d30f2c4789de"
|
|
59
59
|
}
|