vue-grid-layout-headless 4.3.1 → 4.3.3

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.
@@ -1,31 +1,22 @@
1
- //#region src/models/GridCell.d.ts
2
1
  interface GridCell {
3
2
  h: number;
4
3
  w: number;
5
4
  x: number;
6
5
  y: number;
7
6
  }
8
- //#endregion
9
- //#region src/models/GridItem.d.ts
10
7
  interface GridItem extends GridCell {
11
8
  id: string;
12
9
  isAutoHeight?: boolean;
13
10
  }
14
- //#endregion
15
- //#region src/models/CompactType.d.ts
16
11
  declare enum CompactType {
17
12
  Horizontal = "Horizontal",
18
13
  None = "None",
19
14
  Vertical = "Vertical"
20
15
  }
21
- //#endregion
22
- //#region src/models/GridSpacing.d.ts
23
16
  interface GridSpacing {
24
17
  gap: number;
25
18
  padding: number;
26
19
  }
27
- //#endregion
28
- //#region src/models/ResizeEdge.d.ts
29
20
  declare enum ResizeEdge {
30
21
  East = "East",
31
22
  North = "North",
@@ -36,21 +27,15 @@ declare enum ResizeEdge {
36
27
  SouthWest = "SouthWest",
37
28
  West = "West"
38
29
  }
39
- //#endregion
40
- //#region src/models/CollisionMode.d.ts
41
30
  declare enum CollisionMode {
42
31
  Prevent = "Prevent",
43
32
  Push = "Push",
44
33
  Swap = "Swap"
45
34
  }
46
- //#endregion
47
- //#region src/models/GridCommit.d.ts
48
35
  interface GridCommit {
49
36
  changes: GridItem[];
50
37
  removed: string[];
51
38
  }
52
- //#endregion
53
- //#region src/models/GridLayoutOptions.d.ts
54
39
  interface GridLayoutOptions<T extends GridItem = GridItem> {
55
40
  collision: CollisionMode;
56
41
  columnNumber: number;
@@ -62,5 +47,4 @@ interface GridLayoutOptions<T extends GridItem = GridItem> {
62
47
  rowHeight: number;
63
48
  spacing: GridSpacing;
64
49
  }
65
- //#endregion
66
50
  export { GridSpacing as a, GridCell as c, ResizeEdge as i, GridCommit as n, CompactType as o, CollisionMode as r, GridItem as s, GridLayoutOptions as t };
package/dist/index.d.ts CHANGED
@@ -1,28 +1,21 @@
1
- import { a as GridSpacing, c as GridCell, i as ResizeEdge, n as GridCommit, o as CompactType, r as CollisionMode, s as GridItem, t as GridLayoutOptions } from "./GridLayoutOptions-BT3wVbSx.js";
1
+ import { a as GridSpacing, c as GridCell, i as ResizeEdge, n as GridCommit, o as CompactType, r as CollisionMode, s as GridItem, t as GridLayoutOptions } from "./GridLayoutOptions-D0ot9xMz.js";
2
2
  import { ComputedRef, MaybeRefOrGetter, ShallowRef } from "vue";
3
- //#region src/models/GridGeometry.d.ts
4
3
  interface GridGeometry {
5
4
  height: number;
6
5
  left: number;
7
6
  top: number;
8
7
  width: number;
9
8
  }
10
- //#endregion
11
- //#region src/models/GridPoint.d.ts
12
9
  interface GridPoint {
13
10
  x: number;
14
11
  y: number;
15
12
  }
16
- //#endregion
17
- //#region src/models/GridTile.d.ts
18
13
  interface GridTile<T extends GridItem = GridItem> {
19
14
  geometry: GridGeometry;
20
15
  isDragged: boolean;
21
16
  item: T;
22
17
  offset: GridPoint;
23
18
  }
24
- //#endregion
25
- //#region src/models/GridLayout.d.ts
26
19
  interface GridLayout<T extends GridItem = GridItem> {
27
20
  gridHeight: ComputedRef<number>;
28
21
  placeholder: ComputedRef<GridGeometry | undefined>;
@@ -30,11 +23,7 @@ interface GridLayout<T extends GridItem = GridItem> {
30
23
  startGesture: (event: PointerEvent, item: T, edge?: ResizeEdge) => void;
31
24
  tiles: ComputedRef<GridTile<T>[]>;
32
25
  }
33
- //#endregion
34
- //#region src/composables/useGridLayout.d.ts
35
26
  export declare const useGridLayout: <T extends GridItem>(root: Readonly<ShallowRef<HTMLElement | null>>, options: MaybeRefOrGetter<GridLayoutOptions<T>>) => GridLayout<T>;
36
- //#endregion
37
- //#region src/models/GridGesture.d.ts
38
27
  interface GridGesture<T extends GridItem = GridItem> {
39
28
  cell?: GridItem;
40
29
  edge?: ResizeEdge;
@@ -45,8 +34,5 @@ interface GridGesture<T extends GridItem = GridItem> {
45
34
  pointerId: number;
46
35
  start: GridPoint;
47
36
  }
48
- //#endregion
49
- //#region src/services/startExternalDrag.d.ts
50
37
  export declare const startExternalDrag: (event: PointerEvent, item: Pick<GridItem, "h" | "id" | "w">) => void;
51
- //#endregion
52
38
  export { CollisionMode, CompactType, type GridCell, type GridCommit, type GridGeometry, type GridGesture, type GridItem, type GridLayout, type GridLayoutOptions, type GridPoint, type GridSpacing, type GridTile, ResizeEdge };
package/dist/index.js CHANGED
@@ -1,24 +1,21 @@
1
- import { _ as CollisionMode, a as getGestureCell, c as getCellSpan, d as fitLayout, f as correctBounds, g as checkIsColliding, h as checkIsSameCell, i as getLayoutBottom, l as getCellSize, m as CompactType, o as ResizeEdge, p as compactLayout, s as getColumnPitch, t as placeMove, u as getCellPosition } from "./placeMove-DxcB1xac.js";
1
+ import { _ as CollisionMode, a as getGestureCell, c as getCellSpan, d as fitLayout, f as correctBounds, g as checkIsColliding, h as checkIsSameCell, i as getLayoutBottom, l as getCellSize, m as CompactType, o as ResizeEdge, p as compactLayout, s as getColumnPitch, t as placeMove, u as getCellPosition } from "./placeMove-BPQPi70h.js";
2
2
  import { checkIsNestedControl, takeOne } from "@esposter/shared";
3
3
  import { computed, onMounted, onUnmounted, ref, shallowRef, toValue, watch } from "vue";
4
- //#region src/services/mountedGrids.ts
4
+ // src/services/mountedGrids.ts
5
5
  const mountedGrids = /* @__PURE__ */ new Map();
6
- //#endregion
7
- //#region src/services/findGridRoot.ts
6
+ // src/services/findGridRoot.ts
8
7
  const findGridRoot = (element) => {
9
8
  let current = element;
10
9
  while (current && !mountedGrids.has(current)) current = current.parentElement;
11
10
  return current ?? void 0;
12
11
  };
13
- //#endregion
14
- //#region src/services/findGridAt.ts
12
+ // src/services/findGridAt.ts
15
13
  const findGridAt = (point, element) => {
16
14
  const hit = window.document.elementsFromPoint(point.x, point.y).find((candidate) => !element.contains(candidate));
17
15
  const root = findGridRoot(hit ?? null);
18
16
  return root ? mountedGrids.get(root) : void 0;
19
17
  };
20
- //#endregion
21
- //#region src/composables/useGridLayout.ts
18
+ // src/composables/useGridLayout.ts
22
19
  const useGridLayout = (root, options) => {
23
20
  const getOptions = () => toValue(options);
24
21
  const width = ref(0);
@@ -240,8 +237,7 @@ const useGridLayout = (root, options) => {
240
237
  tiles
241
238
  };
242
239
  };
243
- //#endregion
244
- //#region src/services/startExternalDrag.ts
240
+ // src/services/startExternalDrag.ts
245
241
  const startExternalDrag = (event, item) => {
246
242
  if (event.button !== 0) return;
247
243
  if (!(event.currentTarget instanceof HTMLElement)) return;
@@ -263,5 +259,4 @@ const startExternalDrag = (event, item) => {
263
259
  if (cancelEvent.pointerId === pointerId) controller.abort();
264
260
  }, { signal });
265
261
  };
266
- //#endregion
267
262
  export { CollisionMode, CompactType, ResizeEdge, startExternalDrag, useGridLayout };
@@ -1,26 +1,22 @@
1
- //#region src/models/CollisionMode.ts
1
+ // src/models/CollisionMode.ts
2
2
  let CollisionMode = /* @__PURE__ */ function(CollisionMode) {
3
3
  CollisionMode["Prevent"] = "Prevent";
4
4
  CollisionMode["Push"] = "Push";
5
5
  CollisionMode["Swap"] = "Swap";
6
6
  return CollisionMode;
7
7
  }({});
8
- //#endregion
9
- //#region src/placement/checkIsColliding.ts
8
+ // src/placement/checkIsColliding.ts
10
9
  const checkIsColliding = (item, other) => item.id !== other.id && item.x < other.x + other.w && item.x + item.w > other.x && item.y < other.y + other.h && item.y + item.h > other.y;
11
- //#endregion
12
- //#region src/placement/checkIsSameCell.ts
10
+ // src/placement/checkIsSameCell.ts
13
11
  const checkIsSameCell = (cell, other) => cell.h === other.h && cell.w === other.w && cell.x === other.x && cell.y === other.y;
14
- //#endregion
15
- //#region src/models/CompactType.ts
12
+ // src/models/CompactType.ts
16
13
  let CompactType = /* @__PURE__ */ function(CompactType) {
17
14
  CompactType["Horizontal"] = "Horizontal";
18
15
  CompactType["None"] = "None";
19
16
  CompactType["Vertical"] = "Vertical";
20
17
  return CompactType;
21
18
  }({});
22
- //#endregion
23
- //#region src/placement/compactLayout.ts
19
+ // src/placement/compactLayout.ts
24
20
  const compactLayout = (layout, columnNumber, compactType) => {
25
21
  const copies = layout.map((item) => ({ ...item }));
26
22
  const isHorizontal = compactType === "Horizontal";
@@ -49,8 +45,7 @@ const compactLayout = (layout, columnNumber, compactType) => {
49
45
  }
50
46
  return placedItems;
51
47
  };
52
- //#endregion
53
- //#region src/placement/correctBounds.ts
48
+ // src/placement/correctBounds.ts
54
49
  const correctBounds = (layout, columnNumber) => layout.map((item) => {
55
50
  const h = Math.max(1, item.h);
56
51
  const w = Math.max(1, Math.min(item.w, columnNumber));
@@ -62,23 +57,17 @@ const correctBounds = (layout, columnNumber) => layout.map((item) => {
62
57
  x
63
58
  };
64
59
  });
65
- //#endregion
66
- //#region src/placement/fitLayout.ts
60
+ // src/placement/fitLayout.ts
67
61
  const fitLayout = (layout, columnNumber, compactType) => compactLayout(correctBounds(layout, columnNumber), columnNumber, compactType);
68
- //#endregion
69
- //#region src/placement/getCellPosition.ts
62
+ // src/placement/getCellPosition.ts
70
63
  const getCellPosition = (index, pitch, padding) => Math.round(index * pitch + padding);
71
- //#endregion
72
- //#region src/placement/getCellSize.ts
64
+ // src/placement/getCellSize.ts
73
65
  const getCellSize = (span, pitch, gap) => span * pitch - gap;
74
- //#endregion
75
- //#region src/placement/getCellSpan.ts
66
+ // src/placement/getCellSpan.ts
76
67
  const getCellSpan = (size, pitch, gap) => Math.max(1, Math.ceil((size + gap) / pitch));
77
- //#endregion
78
- //#region src/placement/getColumnPitch.ts
68
+ // src/placement/getColumnPitch.ts
79
69
  const getColumnPitch = (width, columnNumber, { gap, padding }) => (width - 2 * padding + gap) / columnNumber;
80
- //#endregion
81
- //#region src/models/ResizeEdge.ts
70
+ // src/models/ResizeEdge.ts
82
71
  let ResizeEdge = /* @__PURE__ */ function(ResizeEdge) {
83
72
  ResizeEdge["East"] = "East";
84
73
  ResizeEdge["North"] = "North";
@@ -90,8 +79,7 @@ let ResizeEdge = /* @__PURE__ */ function(ResizeEdge) {
90
79
  ResizeEdge["West"] = "West";
91
80
  return ResizeEdge;
92
81
  }({});
93
- //#endregion
94
- //#region src/placement/getGestureCell.ts
82
+ // src/placement/getGestureCell.ts
95
83
  const ResizeEdgeSidesMap = {
96
84
  ["East"]: {
97
85
  isEast: true,
@@ -176,11 +164,9 @@ const getGestureCell = ({ columnNumber, columnPitch, edge, offset, origin, rowPi
176
164
  y
177
165
  };
178
166
  };
179
- //#endregion
180
- //#region src/placement/getLayoutBottom.ts
167
+ // src/placement/getLayoutBottom.ts
181
168
  const getLayoutBottom = (layout) => Math.max(0, ...layout.map((item) => item.y + item.h));
182
- //#endregion
183
- //#region src/placement/moveItem.ts
169
+ // src/placement/moveItem.ts
184
170
  const moveItem = (layout, target) => {
185
171
  const movedLayout = layout.map((item) => item.id === target.id ? {
186
172
  ...item,
@@ -200,8 +186,7 @@ const moveItem = (layout, target) => {
200
186
  if (movedItem) pushBelow(movedItem);
201
187
  return movedLayout;
202
188
  };
203
- //#endregion
204
- //#region src/placement/resolveMove.ts
189
+ // src/placement/resolveMove.ts
205
190
  const resolveMove = (layout, target, collision) => {
206
191
  const landedItems = layout.filter((item) => item.id !== target.id && checkIsColliding(target, item));
207
192
  const [landedItem] = landedItems;
@@ -222,8 +207,6 @@ const resolveMove = (layout, target, collision) => {
222
207
  }
223
208
  return moveItem(layout, target);
224
209
  };
225
- //#endregion
226
- //#region src/placement/placeMove.ts
210
+ // src/placement/placeMove.ts
227
211
  const placeMove = (layout, target, { collision, columnNumber, compactType }) => compactLayout(resolveMove(layout, target, collision), columnNumber, compactType);
228
- //#endregion
229
212
  export { CollisionMode as _, getGestureCell as a, getCellSpan as c, fitLayout as d, correctBounds as f, checkIsColliding as g, checkIsSameCell as h, getLayoutBottom as i, getCellSize as l, CompactType as m, resolveMove as n, ResizeEdge as o, compactLayout as p, moveItem as r, getColumnPitch as s, placeMove as t, getCellPosition as u };
@@ -1,32 +1,13 @@
1
- import { a as GridSpacing, c as GridCell, i as ResizeEdge, o as CompactType, r as CollisionMode, s as GridItem, t as GridLayoutOptions } from "./GridLayoutOptions-BT3wVbSx.js";
2
- //#region src/placement/checkIsColliding.d.ts
1
+ import { a as GridSpacing, c as GridCell, i as ResizeEdge, o as CompactType, r as CollisionMode, s as GridItem, t as GridLayoutOptions } from "./GridLayoutOptions-D0ot9xMz.js";
3
2
  export declare const checkIsColliding: (item: GridItem, other: GridItem) => boolean;
4
- //#endregion
5
- //#region src/placement/checkIsSameCell.d.ts
6
3
  export declare const checkIsSameCell: (cell: GridCell, other: GridCell) => boolean;
7
- //#endregion
8
- //#region src/placement/compactLayout.d.ts
9
4
  export declare const compactLayout: <T extends GridItem>(layout: T[], columnNumber: number, compactType: CompactType) => T[];
10
- //#endregion
11
- //#region src/placement/correctBounds.d.ts
12
5
  export declare const correctBounds: <T extends GridItem>(layout: T[], columnNumber: number) => T[];
13
- //#endregion
14
- //#region src/placement/fitLayout.d.ts
15
6
  export declare const fitLayout: <T extends GridItem>(layout: T[], columnNumber: number, compactType: CompactType) => T[];
16
- //#endregion
17
- //#region src/placement/getCellPosition.d.ts
18
7
  export declare const getCellPosition: (index: number, pitch: number, padding: number) => number;
19
- //#endregion
20
- //#region src/placement/getCellSize.d.ts
21
8
  export declare const getCellSize: (span: number, pitch: number, gap: number) => number;
22
- //#endregion
23
- //#region src/placement/getCellSpan.d.ts
24
9
  export declare const getCellSpan: (size: number, pitch: number, gap: number) => number;
25
- //#endregion
26
- //#region src/placement/getColumnPitch.d.ts
27
10
  export declare const getColumnPitch: (width: number, columnNumber: number, { gap, padding }: GridSpacing) => number;
28
- //#endregion
29
- //#region src/placement/getGestureCell.d.ts
30
11
  export declare const getGestureCell: ({ columnNumber, columnPitch, edge, offset, origin, rowPitch }: {
31
12
  columnNumber: number;
32
13
  columnPitch: number;
@@ -38,16 +19,7 @@ export declare const getGestureCell: ({ columnNumber, columnPitch, edge, offset,
38
19
  origin: GridItem;
39
20
  rowPitch: number;
40
21
  }) => GridItem;
41
- //#endregion
42
- //#region src/placement/getLayoutBottom.d.ts
43
22
  export declare const getLayoutBottom: (layout: GridItem[]) => number;
44
- //#endregion
45
- //#region src/placement/moveItem.d.ts
46
23
  export declare const moveItem: <T extends GridItem>(layout: T[], target: GridItem) => T[];
47
- //#endregion
48
- //#region src/placement/placeMove.d.ts
49
24
  export declare const placeMove: <T extends GridItem>(layout: T[], target: GridItem, { collision, columnNumber, compactType }: Pick<GridLayoutOptions, "collision" | "columnNumber" | "compactType">) => T[];
50
- //#endregion
51
- //#region src/placement/resolveMove.d.ts
52
- export declare const resolveMove: <T extends GridItem>(layout: T[], target: GridItem, collision: CollisionMode) => T[];
53
- //#endregion
25
+ export declare const resolveMove: <T extends GridItem>(layout: T[], target: GridItem, collision: CollisionMode) => T[];
package/dist/placement.js CHANGED
@@ -1 +1 @@
1
- export { g as checkIsColliding, h as checkIsSameCell, p as compactLayout, f as correctBounds, d as fitLayout, u as getCellPosition, l as getCellSize, c as getCellSpan, s as getColumnPitch, a as getGestureCell, i as getLayoutBottom, r as moveItem, t as placeMove, n as resolveMove } from "./placeMove-DxcB1xac.js";
1
+ export { g as checkIsColliding, h as checkIsSameCell, p as compactLayout, f as correctBounds, d as fitLayout, u as getCellPosition, l as getCellSize, c as getCellSpan, s as getColumnPitch, a as getGestureCell, i as getLayoutBottom, r as moveItem, t as placeMove, n as resolveMove } from "./placeMove-BPQPi70h.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-grid-layout-headless",
3
- "version": "4.3.1",
3
+ "version": "4.3.3",
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",
@@ -45,10 +45,10 @@
45
45
  "typecheck": "tsc"
46
46
  },
47
47
  "dependencies": {
48
- "@esposter/shared": "4.3.1"
48
+ "@esposter/shared": "4.3.3"
49
49
  },
50
50
  "devDependencies": {
51
- "@esposter/configuration": "4.3.1",
51
+ "@esposter/configuration": "4.3.3",
52
52
  "@vue/test-utils": "^2.5.1",
53
53
  "happy-dom": "^21.0.4",
54
54
  "tsdown": "^0.23.1"
@@ -56,5 +56,5 @@
56
56
  "peerDependencies": {
57
57
  "vue": "^3.5.44"
58
58
  },
59
- "gitHead": "777a39636b789c13af33ed13370246ccf6dbaf31"
59
+ "gitHead": "955bbc130ad9b28877fd4ae8efc73a045141ce01"
60
60
  }