gridstack 12.3.3 → 12.4.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.
Files changed (142) hide show
  1. package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
  2. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
  3. package/dist/angular/esm2020/lib/gridstack.component.mjs +4 -2
  4. package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
  5. package/dist/angular/esm2020/lib/types.mjs +2 -2
  6. package/dist/angular/fesm2015/gridstack-angular.mjs +6 -4
  7. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  8. package/dist/angular/fesm2020/gridstack-angular.mjs +7 -5
  9. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  10. package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
  11. package/dist/angular/lib/gridstack.component.d.ts +4 -4
  12. package/dist/angular/lib/types.d.ts +1 -1
  13. package/dist/angular/package.json +1 -1
  14. package/dist/angular/projects/lib/src/index.d.ts +5 -0
  15. package/dist/angular/projects/lib/src/index.js +9 -0
  16. package/dist/angular/projects/lib/src/index.js.map +1 -0
  17. package/dist/angular/projects/lib/src/lib/base-widget.d.ts +56 -0
  18. package/dist/angular/projects/lib/src/lib/base-widget.js +94 -0
  19. package/dist/angular/projects/lib/src/lib/base-widget.js.map +1 -0
  20. package/dist/angular/projects/lib/src/lib/gridstack-item.component.d.ts +76 -0
  21. package/dist/angular/projects/lib/src/lib/gridstack-item.component.js +112 -0
  22. package/dist/angular/projects/lib/src/lib/gridstack-item.component.js.map +1 -0
  23. package/dist/angular/projects/lib/src/lib/gridstack.component.d.ts +233 -0
  24. package/dist/angular/projects/lib/src/lib/gridstack.component.js +457 -0
  25. package/dist/angular/projects/lib/src/lib/gridstack.component.js.map +1 -0
  26. package/dist/angular/projects/lib/src/lib/gridstack.module.d.ts +29 -0
  27. package/dist/angular/projects/lib/src/lib/gridstack.module.js +52 -0
  28. package/dist/angular/projects/lib/src/lib/gridstack.module.js.map +1 -0
  29. package/dist/angular/projects/lib/src/lib/types.d.ts +51 -0
  30. package/dist/angular/projects/lib/src/lib/types.js +6 -0
  31. package/dist/angular/projects/lib/src/lib/types.js.map +1 -0
  32. package/dist/angular/src/base-widget.ts +13 -13
  33. package/dist/angular/src/gridstack-item.component.ts +5 -5
  34. package/dist/angular/src/gridstack.component.ts +34 -32
  35. package/dist/angular/src/gridstack.module.ts +4 -4
  36. package/dist/angular/src/types.ts +3 -2
  37. package/dist/gridstack-all.js +1 -1
  38. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  39. package/dist/gridstack-all.js.map +1 -1
  40. package/dist/gridstack.css +1 -1
  41. package/dist/src/dd-base-impl.d.ts +1 -1
  42. package/dist/src/dd-base-impl.js +1 -1
  43. package/dist/src/dd-base-impl.js.map +1 -1
  44. package/dist/src/dd-draggable.d.ts +1 -1
  45. package/dist/src/dd-draggable.js +1 -1
  46. package/dist/src/dd-draggable.js.map +1 -1
  47. package/dist/src/dd-droppable.d.ts +1 -1
  48. package/dist/src/dd-droppable.js +7 -1
  49. package/dist/src/dd-droppable.js.map +1 -1
  50. package/dist/src/dd-element.d.ts +1 -1
  51. package/dist/src/dd-element.js +1 -1
  52. package/dist/src/dd-element.js.map +1 -1
  53. package/dist/src/dd-gridstack.d.ts +1 -1
  54. package/dist/src/dd-gridstack.js +1 -1
  55. package/dist/src/dd-gridstack.js.map +1 -1
  56. package/dist/src/dd-manager.d.ts +1 -1
  57. package/dist/src/dd-manager.js +1 -1
  58. package/dist/src/dd-manager.js.map +1 -1
  59. package/dist/src/dd-resizable-handle.d.ts +5 -4
  60. package/dist/src/dd-resizable-handle.js +23 -8
  61. package/dist/src/dd-resizable-handle.js.map +1 -1
  62. package/dist/src/dd-resizable.d.ts +3 -5
  63. package/dist/src/dd-resizable.js +5 -10
  64. package/dist/src/dd-resizable.js.map +1 -1
  65. package/dist/src/dd-touch.d.ts +1 -1
  66. package/dist/src/dd-touch.js +1 -1
  67. package/dist/src/dd-touch.js.map +1 -1
  68. package/dist/src/gridstack-engine.d.ts +1 -1
  69. package/dist/src/gridstack-engine.js +7 -1
  70. package/dist/src/gridstack-engine.js.map +1 -1
  71. package/dist/src/gridstack.d.ts +1 -2
  72. package/dist/src/gridstack.js +9 -18
  73. package/dist/src/gridstack.js.map +1 -1
  74. package/dist/src/gridstack.scss +1 -1
  75. package/dist/src/types.d.ts +11 -6
  76. package/dist/src/types.js +1 -1
  77. package/dist/src/types.js.map +1 -1
  78. package/dist/src/utils.d.ts +1 -270
  79. package/dist/src/utils.js +37 -31
  80. package/dist/src/utils.js.map +1 -1
  81. package/doc/API.md +166 -165
  82. package/package.json +5 -5
  83. package/dist/dd-base-impl.d.ts +0 -69
  84. package/dist/dd-base-impl.js +0 -70
  85. package/dist/dd-base-impl.js.map +0 -1
  86. package/dist/dd-draggable.d.ts +0 -20
  87. package/dist/dd-draggable.js +0 -364
  88. package/dist/dd-draggable.js.map +0 -1
  89. package/dist/dd-droppable.d.ts +0 -26
  90. package/dist/dd-droppable.js +0 -149
  91. package/dist/dd-droppable.js.map +0 -1
  92. package/dist/dd-element.d.ts +0 -27
  93. package/dist/dd-element.js +0 -91
  94. package/dist/dd-element.js.map +0 -1
  95. package/dist/dd-gridstack.d.ts +0 -82
  96. package/dist/dd-gridstack.js +0 -165
  97. package/dist/dd-gridstack.js.map +0 -1
  98. package/dist/dd-manager.d.ts +0 -43
  99. package/dist/dd-manager.js +0 -14
  100. package/dist/dd-manager.js.map +0 -1
  101. package/dist/dd-resizable-handle.d.ts +0 -18
  102. package/dist/dd-resizable-handle.js +0 -113
  103. package/dist/dd-resizable-handle.js.map +0 -1
  104. package/dist/dd-resizable.d.ts +0 -30
  105. package/dist/dd-resizable.js +0 -304
  106. package/dist/dd-resizable.js.map +0 -1
  107. package/dist/dd-touch.d.ts +0 -33
  108. package/dist/dd-touch.js +0 -145
  109. package/dist/dd-touch.js.map +0 -1
  110. package/dist/gridstack-engine.d.ts +0 -321
  111. package/dist/gridstack-engine.js +0 -1272
  112. package/dist/gridstack-engine.js.map +0 -1
  113. package/dist/gridstack.d.ts +0 -802
  114. package/dist/gridstack.js +0 -2872
  115. package/dist/gridstack.js.map +0 -1
  116. package/dist/spec/gridstack-engine-spec.d.ts +0 -1
  117. package/dist/spec/gridstack-engine-spec.js +0 -358
  118. package/dist/spec/gridstack-engine-spec.js.map +0 -1
  119. package/dist/spec/gridstack-spec.d.ts +0 -1
  120. package/dist/spec/gridstack-spec.js +0 -1780
  121. package/dist/spec/gridstack-spec.js.map +0 -1
  122. package/dist/spec/integration/gridstack-integration.spec.d.ts +0 -1
  123. package/dist/spec/integration/gridstack-integration.spec.js +0 -171
  124. package/dist/spec/integration/gridstack-integration.spec.js.map +0 -1
  125. package/dist/spec/regression-spec.d.ts +0 -1
  126. package/dist/spec/regression-spec.js +0 -100
  127. package/dist/spec/regression-spec.js.map +0 -1
  128. package/dist/spec/utils-spec.d.ts +0 -1
  129. package/dist/spec/utils-spec.js +0 -243
  130. package/dist/spec/utils-spec.js.map +0 -1
  131. package/dist/types.d.ts +0 -427
  132. package/dist/types.js +0 -38
  133. package/dist/types.js.map +0 -1
  134. package/dist/utils.d.ts +0 -283
  135. package/dist/utils.js +0 -787
  136. package/dist/utils.js.map +0 -1
  137. package/dist/vitest.config.d.ts +0 -2
  138. package/dist/vitest.config.js +0 -74
  139. package/dist/vitest.config.js.map +0 -1
  140. package/dist/vitest.setup.d.ts +0 -1
  141. package/dist/vitest.setup.js +0 -90
  142. package/dist/vitest.setup.js.map +0 -1
package/dist/utils.d.ts DELETED
@@ -1,283 +0,0 @@
1
- /**
2
- * utils.ts 12.3.2
3
- * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
4
- */
5
- import { GridStackElement, GridStackNode, numberOrString, GridStackPosition, GridStackWidget } from './types';
6
- export interface HeightData {
7
- h: number;
8
- unit: string;
9
- }
10
- export interface DragTransform {
11
- xScale: number;
12
- yScale: number;
13
- xOffset: number;
14
- yOffset: number;
15
- }
16
- /**
17
- * Collection of utility methods used throughout GridStack.
18
- * These are general-purpose helper functions for DOM manipulation,
19
- * positioning calculations, object operations, and more.
20
- */
21
- export declare class Utils {
22
- /**
23
- * Convert a potential selector into an actual list of HTML elements.
24
- * Supports CSS selectors, element references, and special ID handling.
25
- *
26
- * @param els selector string, HTMLElement, or array of elements
27
- * @param root optional root element to search within (defaults to document, useful for shadow DOM)
28
- * @returns array of HTML elements matching the selector
29
- *
30
- * @example
31
- * const elements = Utils.getElements('.grid-item');
32
- * const byId = Utils.getElements('#myWidget');
33
- * const fromShadow = Utils.getElements('.item', shadowRoot);
34
- */
35
- static getElements(els: GridStackElement, root?: HTMLElement | Document): HTMLElement[];
36
- /**
37
- * Convert a potential selector into a single HTML element.
38
- * Similar to getElements() but returns only the first match.
39
- *
40
- * @param els selector string or HTMLElement
41
- * @param root optional root element to search within (defaults to document)
42
- * @returns the first HTML element matching the selector, or null if not found
43
- *
44
- * @example
45
- * const element = Utils.getElement('#myWidget');
46
- * const first = Utils.getElement('.grid-item');
47
- */
48
- static getElement(els: GridStackElement, root?: HTMLElement | Document): HTMLElement;
49
- /**
50
- * Check if a widget should be lazy loaded based on node or grid settings.
51
- *
52
- * @param n the grid node to check
53
- * @returns true if the item should be lazy loaded
54
- *
55
- * @example
56
- * if (Utils.lazyLoad(node)) {
57
- * // Set up intersection observer for lazy loading
58
- * }
59
- */
60
- static lazyLoad(n: GridStackNode): boolean;
61
- /**
62
- * Create a div element with the specified CSS classes.
63
- *
64
- * @param classes array of CSS class names to add
65
- * @param parent optional parent element to append the div to
66
- * @returns the created div element
67
- *
68
- * @example
69
- * const div = Utils.createDiv(['grid-item', 'draggable']);
70
- * const nested = Utils.createDiv(['content'], parentDiv);
71
- */
72
- static createDiv(classes: string[], parent?: HTMLElement): HTMLElement;
73
- /**
74
- * Check if a widget should resize to fit its content.
75
- *
76
- * @param n the grid node to check (can be undefined)
77
- * @param strict if true, only returns true for explicit sizeToContent:true (not numbers)
78
- * @returns true if the widget should resize to content
79
- *
80
- * @example
81
- * if (Utils.shouldSizeToContent(node)) {
82
- * // Trigger content-based resizing
83
- * }
84
- */
85
- static shouldSizeToContent(n: GridStackNode | undefined, strict?: boolean): boolean;
86
- /**
87
- * Check if two grid positions overlap/intersect.
88
- *
89
- * @param a first position with x, y, w, h properties
90
- * @param b second position with x, y, w, h properties
91
- * @returns true if the positions overlap
92
- *
93
- * @example
94
- * const overlaps = Utils.isIntercepted(
95
- * {x: 0, y: 0, w: 2, h: 1},
96
- * {x: 1, y: 0, w: 2, h: 1}
97
- * ); // true - they overlap
98
- */
99
- static isIntercepted(a: GridStackPosition, b: GridStackPosition): boolean;
100
- /**
101
- * Check if two grid positions are touching (edges or corners).
102
- *
103
- * @param a first position
104
- * @param b second position
105
- * @returns true if the positions are touching
106
- *
107
- * @example
108
- * const touching = Utils.isTouching(
109
- * {x: 0, y: 0, w: 2, h: 1},
110
- * {x: 2, y: 0, w: 1, h: 1}
111
- * ); // true - they share an edge
112
- */
113
- static isTouching(a: GridStackPosition, b: GridStackPosition): boolean;
114
- /**
115
- * Calculate the overlapping area between two grid positions.
116
- *
117
- * @param a first position
118
- * @param b second position
119
- * @returns the area of overlap (0 if no overlap)
120
- *
121
- * @example
122
- * const overlap = Utils.areaIntercept(
123
- * {x: 0, y: 0, w: 3, h: 2},
124
- * {x: 1, y: 0, w: 3, h: 2}
125
- * ); // returns 4 (2x2 overlap)
126
- */
127
- static areaIntercept(a: GridStackPosition, b: GridStackPosition): number;
128
- /**
129
- * Calculate the total area of a grid position.
130
- *
131
- * @param a position with width and height
132
- * @returns the total area (width * height)
133
- *
134
- * @example
135
- * const area = Utils.area({x: 0, y: 0, w: 3, h: 2}); // returns 6
136
- */
137
- static area(a: GridStackPosition): number;
138
- /**
139
- * Sort an array of grid nodes by position (y first, then x).
140
- *
141
- * @param nodes array of nodes to sort
142
- * @param dir sort direction: 1 for ascending (top-left first), -1 for descending
143
- * @returns the sorted array (modifies original)
144
- *
145
- * @example
146
- * const sorted = Utils.sort(nodes); // Sort top-left to bottom-right
147
- * const reverse = Utils.sort(nodes, -1); // Sort bottom-right to top-left
148
- */
149
- static sort(nodes: GridStackNode[], dir?: 1 | -1): GridStackNode[];
150
- /**
151
- * Find a grid node by its ID.
152
- *
153
- * @param nodes array of nodes to search
154
- * @param id the ID to search for
155
- * @returns the node with matching ID, or undefined if not found
156
- *
157
- * @example
158
- * const node = Utils.find(nodes, 'widget-1');
159
- * if (node) console.log('Found node at:', node.x, node.y);
160
- */
161
- static find(nodes: GridStackNode[], id: string): GridStackNode | undefined;
162
- /**
163
- * Convert various value types to boolean.
164
- * Handles strings like 'false', 'no', '0' as false.
165
- *
166
- * @param v value to convert
167
- * @returns boolean representation
168
- *
169
- * @example
170
- * Utils.toBool('true'); // true
171
- * Utils.toBool('false'); // false
172
- * Utils.toBool('no'); // false
173
- * Utils.toBool('1'); // true
174
- */
175
- static toBool(v: unknown): boolean;
176
- /**
177
- * Convert a string value to a number, handling null and empty strings.
178
- *
179
- * @param value string or null value to convert
180
- * @returns number value, or undefined for null/empty strings
181
- *
182
- * @example
183
- * Utils.toNumber('42'); // 42
184
- * Utils.toNumber(''); // undefined
185
- * Utils.toNumber(null); // undefined
186
- */
187
- static toNumber(value: null | string): number;
188
- /**
189
- * Parse a height value with units into numeric value and unit string.
190
- * Supports px, em, rem, vh, vw, %, cm, mm units.
191
- *
192
- * @param val height value as number or string with units
193
- * @returns object with h (height) and unit properties
194
- *
195
- * @example
196
- * Utils.parseHeight('100px'); // {h: 100, unit: 'px'}
197
- * Utils.parseHeight('2rem'); // {h: 2, unit: 'rem'}
198
- * Utils.parseHeight(50); // {h: 50, unit: 'px'}
199
- */
200
- static parseHeight(val: numberOrString): HeightData;
201
- /**
202
- * Copy unset fields from source objects to target object (shallow merge with defaults).
203
- * Similar to Object.assign but only sets undefined/null fields.
204
- *
205
- * @param target the object to copy defaults into
206
- * @param sources one or more source objects to copy defaults from
207
- * @returns the modified target object
208
- *
209
- * @example
210
- * const config = { width: 100 };
211
- * Utils.defaults(config, { width: 200, height: 50 });
212
- * // config is now { width: 100, height: 50 }
213
- */
214
- static defaults(target: any, ...sources: any[]): {};
215
- /**
216
- * Compare two objects for equality (shallow comparison).
217
- * Checks if objects have the same fields and values at one level deep.
218
- *
219
- * @param a first object to compare
220
- * @param b second object to compare
221
- * @returns true if objects have the same values
222
- *
223
- * @example
224
- * Utils.same({x: 1, y: 2}, {x: 1, y: 2}); // true
225
- * Utils.same({x: 1}, {x: 1, y: 2}); // false
226
- */
227
- static same(a: unknown, b: unknown): boolean;
228
- /**
229
- * Copy position and size properties from one widget to another.
230
- * Copies x, y, w, h and optionally min/max constraints.
231
- *
232
- * @param a target widget to copy to
233
- * @param b source widget to copy from
234
- * @param doMinMax if true, also copy min/max width/height constraints
235
- * @returns the target widget (a)
236
- *
237
- * @example
238
- * Utils.copyPos(widget1, widget2); // Copy position/size
239
- * Utils.copyPos(widget1, widget2, true); // Also copy constraints
240
- */
241
- static copyPos(a: GridStackWidget, b: GridStackWidget, doMinMax?: boolean): GridStackWidget;
242
- /** true if a and b has same size & position */
243
- static samePos(a: GridStackPosition, b: GridStackPosition): boolean;
244
- /** given a node, makes sure it's min/max are valid */
245
- static sanitizeMinMax(node: GridStackNode): void;
246
- /** removes field from the first object if same as the second objects (like diffing) and internal '_' for saving */
247
- static removeInternalAndSame(a: unknown, b: unknown): void;
248
- /** removes internal fields '_' and default values for saving */
249
- static removeInternalForSave(n: GridStackNode, removeEl?: boolean): void;
250
- /** return the closest parent (or itself) matching the given class */
251
- /** delay calling the given function for given delay, preventing new calls from happening while waiting */
252
- static throttle(func: () => void, delay: number): () => void;
253
- static removePositioningStyles(el: HTMLElement): void;
254
- /** single level clone, returning a new object with same top fields. This will share sub objects and arrays */
255
- static clone<T>(obj: T): T;
256
- /**
257
- * Recursive clone version that returns a full copy, checking for nested objects and arrays ONLY.
258
- * Note: this will use as-is any key starting with double __ (and not copy inside) some lib have circular dependencies.
259
- */
260
- static cloneDeep<T>(obj: T): T;
261
- /** deep clone the given HTML node, removing teh unique id field */
262
- static cloneNode(el: HTMLElement): HTMLElement;
263
- static appendTo(el: HTMLElement, parent: string | HTMLElement): void;
264
- static addElStyles(el: HTMLElement, styles: {
265
- [prop: string]: string | string[];
266
- }): void;
267
- static initEvent<T>(e: DragEvent | MouseEvent, info: {
268
- type: string;
269
- target?: EventTarget;
270
- }): T;
271
- /** copies the MouseEvent (or convert Touch) properties and sends it as another event to the given target */
272
- static simulateMouseEvent(e: MouseEvent | Touch, simulatedType: string, target?: EventTarget): void;
273
- /**
274
- * defines an element that is used to get the offset and scale from grid transforms
275
- * returns the scale and offsets from said element
276
- */
277
- static getValuesFromTransformedElement(parent: HTMLElement): DragTransform;
278
- /** swap the given object 2 field values */
279
- static swap(o: unknown, a: string, b: string): void;
280
- /** returns true if event is inside the given element rectangle */
281
- /** true if the item can be rotated (checking for prop, not space available) */
282
- static canBeRotated(n: GridStackNode): boolean;
283
- }