gridstack 12.2.2 → 12.3.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.
Files changed (71) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -3
  3. package/dist/angular/README.md +2 -0
  4. package/dist/angular/esm2020/lib/base-widget.mjs +63 -7
  5. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +33 -4
  6. package/dist/angular/esm2020/lib/gridstack.component.mjs +97 -16
  7. package/dist/angular/esm2020/lib/gridstack.module.mjs +25 -3
  8. package/dist/angular/esm2020/lib/types.mjs +2 -2
  9. package/dist/angular/fesm2015/gridstack-angular.mjs +191 -25
  10. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
  11. package/dist/angular/fesm2020/gridstack-angular.mjs +192 -26
  12. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
  13. package/dist/angular/lib/base-widget.d.ts +42 -5
  14. package/dist/angular/lib/gridstack-item.component.d.ts +49 -7
  15. package/dist/angular/lib/gridstack.component.d.ts +137 -22
  16. package/dist/angular/lib/gridstack.module.d.ts +23 -0
  17. package/dist/angular/lib/types.d.ts +32 -5
  18. package/dist/angular/package.json +1 -1
  19. package/dist/angular/src/base-widget.ts +68 -9
  20. package/dist/angular/src/gridstack-item.component.ts +49 -7
  21. package/dist/angular/src/gridstack.component.ts +154 -23
  22. package/dist/angular/src/gridstack.module.ts +24 -2
  23. package/dist/angular/src/types.ts +54 -0
  24. package/dist/dd-base-impl.d.ts +52 -3
  25. package/dist/dd-base-impl.js +41 -3
  26. package/dist/dd-base-impl.js.map +1 -1
  27. package/dist/dd-draggable.d.ts +2 -2
  28. package/dist/dd-draggable.js +4 -2
  29. package/dist/dd-draggable.js.map +1 -1
  30. package/dist/dd-droppable.d.ts +2 -2
  31. package/dist/dd-droppable.js +2 -2
  32. package/dist/dd-droppable.js.map +1 -1
  33. package/dist/dd-element.d.ts +2 -2
  34. package/dist/dd-element.js +2 -2
  35. package/dist/dd-element.js.map +1 -1
  36. package/dist/dd-gridstack.d.ts +54 -6
  37. package/dist/dd-gridstack.js +32 -2
  38. package/dist/dd-gridstack.js.map +1 -1
  39. package/dist/dd-manager.d.ts +29 -8
  40. package/dist/dd-manager.js +7 -3
  41. package/dist/dd-manager.js.map +1 -1
  42. package/dist/dd-resizable-handle.d.ts +2 -2
  43. package/dist/dd-resizable-handle.js +2 -2
  44. package/dist/dd-resizable-handle.js.map +1 -1
  45. package/dist/dd-resizable.d.ts +2 -2
  46. package/dist/dd-resizable.js +2 -2
  47. package/dist/dd-resizable.js.map +1 -1
  48. package/dist/dd-touch.d.ts +2 -2
  49. package/dist/dd-touch.js +2 -2
  50. package/dist/dd-touch.js.map +1 -1
  51. package/dist/gridstack-all.js +1 -1
  52. package/dist/gridstack-all.js.LICENSE.txt +2 -2
  53. package/dist/gridstack-all.js.map +1 -1
  54. package/dist/gridstack-engine.d.ts +241 -28
  55. package/dist/gridstack-engine.js +283 -32
  56. package/dist/gridstack-engine.js.map +1 -1
  57. package/dist/gridstack.css +2 -2
  58. package/dist/gridstack.d.ts +428 -83
  59. package/dist/gridstack.js +416 -81
  60. package/dist/gridstack.js.map +1 -1
  61. package/dist/src/gridstack.scss +2 -2
  62. package/dist/types.d.ts +130 -29
  63. package/dist/types.js +6 -3
  64. package/dist/types.js.map +1 -1
  65. package/dist/utils.d.ts +208 -29
  66. package/dist/utils.js +278 -65
  67. package/dist/utils.js.map +1 -1
  68. package/doc/API.md +6198 -0
  69. package/package.json +10 -3
  70. package/doc/CHANGES.md +0 -962
  71. package/doc/README.md +0 -642
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * GridStack 12.2.2
2
+ * GridStack 12.3.1
3
3
  * https://gridstackjs.com/
4
4
  *
5
- * Copyright (c) 2021-2024 Alain Dumesny
5
+ * Copyright (c) 2021-2025 Alain Dumesny
6
6
  * see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
7
7
  */
8
8
  import { GridStackEngine } from './gridstack-engine';
@@ -13,6 +13,13 @@ export * from './types';
13
13
  export * from './utils';
14
14
  export * from './gridstack-engine';
15
15
  export * from './dd-gridstack';
16
+ export * from './dd-manager';
17
+ export * from './dd-element';
18
+ export * from './dd-draggable';
19
+ export * from './dd-droppable';
20
+ export * from './dd-resizable';
21
+ export * from './dd-resizable-handle';
22
+ export * from './dd-base-impl';
16
23
  export interface GridHTMLElement extends HTMLElement {
17
24
  gridstack?: GridStack;
18
25
  }
@@ -137,7 +144,15 @@ export declare class GridStack {
137
144
  * @param w GridStackWidget definition. used MakeWidget(el) if you have dom element instead.
138
145
  */
139
146
  addWidget(w: GridStackWidget): GridItemHTMLElement;
140
- /** create the default grid item divs, and content (possibly lazy loaded) by using GridStack.renderCB() */
147
+ /**
148
+ * Create the default grid item divs and content (possibly lazy loaded) by using GridStack.renderCB().
149
+ *
150
+ * @param n GridStackNode definition containing widget configuration
151
+ * @returns the created HTML element with proper grid item structure
152
+ *
153
+ * @example
154
+ * const element = grid.createWidgetDivs({ w: 2, h: 1, content: 'Hello World' });
155
+ */
141
156
  createWidgetDivs(n: GridStackNode): HTMLElement;
142
157
  /**
143
158
  * Convert an existing gridItem element into a sub-grid with the given (optional) options, else inherit them
@@ -161,18 +176,46 @@ export declare class GridStack {
161
176
  * @param saveGridOpt if true (default false), save the grid options itself, so you can call the new GridStack.addGrid()
162
177
  * to recreate everything from scratch. GridStackOptions.children would then contain the widget list instead.
163
178
  * @param saveCB callback for each node -> widget, so application can insert additional data to be saved into the widget data structure.
179
+ * @param columnSize if provided, the grid will be saved for the given column size (IFF we have matching internal saved layout, or current layout).
180
+ * Otherwise it will use the largest possible layout (say 12 even if rendering at 1 column) so we can restore to all layouts.
181
+ * Note: nested grids will ALWAYS save the container size to match overall layouts (parent + child) to be consistent.
164
182
  * @returns list of widgets or full grid option, including .children list of widgets
165
183
  */
166
- save(saveContent?: boolean, saveGridOpt?: boolean, saveCB?: SaveFcn): GridStackWidget[] | GridStackOptions;
184
+ save(saveContent?: boolean, saveGridOpt?: boolean, saveCB?: SaveFcn, columnSize?: number): GridStackWidget[] | GridStackOptions;
167
185
  /**
168
- * load the widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.
186
+ * Load widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.
187
+ * Used to restore a grid layout for a saved layout list (see `save()`).
169
188
  *
170
189
  * @param items list of widgets definition to update/create
171
190
  * @param addRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving
172
191
  * the user control of insertion.
192
+ * @returns the grid instance for chaining
173
193
  *
174
194
  * @example
175
- * see http://gridstackjs.com/demo/serialization.html
195
+ * // Basic usage with saved layout
196
+ * const savedLayout = grid.save(); // Save current layout
197
+ * // ... later restore it
198
+ * grid.load(savedLayout);
199
+ *
200
+ * // Load with custom add/remove callback
201
+ * grid.load(layout, (items, grid, add) => {
202
+ * if (add) {
203
+ * // Custom logic for adding new widgets
204
+ * items.forEach(item => {
205
+ * const el = document.createElement('div');
206
+ * el.innerHTML = item.content || '';
207
+ * grid.addWidget(el, item);
208
+ * });
209
+ * } else {
210
+ * // Custom logic for removing widgets
211
+ * items.forEach(item => grid.removeWidget(item.el));
212
+ * }
213
+ * });
214
+ *
215
+ * // Load without adding/removing missing widgets
216
+ * grid.load(layout, false);
217
+ *
218
+ * @see {@link http://gridstackjs.com/demo/serialization.html} for complete example
176
219
  */
177
220
  load(items: GridStackWidget[], addRemove?: boolean | AddRemoveFcn): GridStack;
178
221
  /**
@@ -181,52 +224,140 @@ export declare class GridStack {
181
224
  */
182
225
  batchUpdate(flag?: boolean): GridStack;
183
226
  /**
184
- * Gets current cell height.
227
+ * Gets the current cell height in pixels. This takes into account the unit type and converts to pixels if necessary.
228
+ *
229
+ * @param forcePixel if true, forces conversion to pixels even when cellHeight is specified in other units
230
+ * @returns the cell height in pixels
231
+ *
232
+ * @example
233
+ * const height = grid.getCellHeight();
234
+ * console.log('Cell height:', height, 'px');
235
+ *
236
+ * // Force pixel conversion
237
+ * const pixelHeight = grid.getCellHeight(true);
185
238
  */
186
239
  getCellHeight(forcePixel?: boolean): number;
187
240
  /**
188
- * Update current cell height - see `GridStackOptions.cellHeight` for format.
189
- * This method rebuilds an internal CSS style sheet.
190
- * Note: You can expect performance issues if call this method too often.
241
+ * Update current cell height - see `GridStackOptions.cellHeight` for format by updating eh Browser CSS variable.
191
242
  *
192
- * @param val the cell height. If not passed (undefined), cells content will be made square (match width minus margin),
193
- * if pass 0 the CSS will be generated by the application instead.
243
+ * @param val the cell height. Options:
244
+ * - `undefined`: cells content will be made square (match width minus margin)
245
+ * - `0`: the CSS will be generated by the application instead
246
+ * - number: height in pixels
247
+ * - string: height with units (e.g., '70px', '5rem', '2em')
248
+ * @returns the grid instance for chaining
194
249
  *
195
250
  * @example
196
- * grid.cellHeight(100); // same as 100px
197
- * grid.cellHeight('70px');
198
- * grid.cellHeight(grid.cellWidth() * 1.2);
251
+ * grid.cellHeight(100); // 100px height
252
+ * grid.cellHeight('70px'); // explicit pixel height
253
+ * grid.cellHeight('5rem'); // relative to root font size
254
+ * grid.cellHeight(grid.cellWidth() * 1.2); // aspect ratio
255
+ * grid.cellHeight('auto'); // auto-size based on content
199
256
  */
200
257
  cellHeight(val?: numberOrString): GridStack;
201
258
  /** Gets current cell width. */
259
+ /**
260
+ * Gets the current cell width in pixels. This is calculated based on the grid container width divided by the number of columns.
261
+ *
262
+ * @returns the cell width in pixels
263
+ *
264
+ * @example
265
+ * const width = grid.cellWidth();
266
+ * console.log('Cell width:', width, 'px');
267
+ *
268
+ * // Use cell width to calculate widget dimensions
269
+ * const widgetWidth = width * 3; // For a 3-column wide widget
270
+ */
202
271
  cellWidth(): number;
203
272
  /** return our expected width (or parent) , and optionally of window for dynamic column check */
204
273
  protected _widthOrContainer(forBreakpoint?: boolean): number;
205
274
  /** checks for dynamic column count for our current size, returning true if changed */
206
275
  protected checkDynamicColumn(): boolean;
207
276
  /**
208
- * re-layout grid items to reclaim any empty space. Options are:
209
- * 'list' keep the widget left->right order the same, even if that means leaving an empty slot if things don't fit
210
- * 'compact' might re-order items to fill any empty space
277
+ * Re-layout grid items to reclaim any empty space. This is useful after removing widgets
278
+ * or when you want to optimize the layout.
279
+ *
280
+ * @param layout layout type. Options:
281
+ * - 'compact' (default): might re-order items to fill any empty space
282
+ * - 'list': keep the widget left->right order the same, even if that means leaving an empty slot if things don't fit
283
+ * @param doSort re-sort items first based on x,y position. Set to false to do your own sorting ahead (default: true)
284
+ * @returns the grid instance for chaining
285
+ *
286
+ * @example
287
+ * // Compact layout after removing widgets
288
+ * grid.removeWidget('.widget-to-remove');
289
+ * grid.compact();
290
+ *
291
+ * // Use list layout (preserve order)
292
+ * grid.compact('list');
211
293
  *
212
- * doSort - 'false' to let you do your own sorting ahead in case you need to control a different order. (default to sort)
294
+ * // Compact without sorting first
295
+ * grid.compact('compact', false);
213
296
  */
214
297
  compact(layout?: CompactOptions, doSort?: boolean): GridStack;
215
298
  /**
216
- * set the number of columns in the grid. Will update existing widgets to conform to new number of columns,
299
+ * Set the number of columns in the grid. Will update existing widgets to conform to new number of columns,
217
300
  * as well as cache the original layout so you can revert back to previous positions without loss.
218
- * @param column - Integer > 0 (default 12).
219
- * @param layout specify the type of re-layout that will happen (position, size, etc...).
220
- * Note: items will never be outside of the current column boundaries. default ('moveScale'). Ignored for 1 column
301
+ *
302
+ * Requires `gridstack-extra.css` or `gridstack-extra.min.css` for [2-11] columns,
303
+ * else you will need to generate correct CSS.
304
+ * See: https://github.com/gridstack/gridstack.js#change-grid-columns
305
+ *
306
+ * @param column Integer > 0 (default 12)
307
+ * @param layout specify the type of re-layout that will happen. Options:
308
+ * - 'moveScale' (default): scale widget positions and sizes
309
+ * - 'move': keep widget sizes, only move positions
310
+ * - 'scale': keep widget positions, only scale sizes
311
+ * - 'none': don't change widget positions or sizes
312
+ * Note: items will never be outside of the current column boundaries.
313
+ * Ignored for `column=1` as we always want to vertically stack.
314
+ * @returns the grid instance for chaining
315
+ *
316
+ * @example
317
+ * // Change to 6 columns with default scaling
318
+ * grid.column(6);
319
+ *
320
+ * // Change to 4 columns, only move positions
321
+ * grid.column(4, 'move');
322
+ *
323
+ * // Single column layout (vertical stack)
324
+ * grid.column(1);
221
325
  */
222
326
  column(column: number, layout?: ColumnOptions): GridStack;
223
327
  /**
224
- * get the number of columns in the grid (default 12)
328
+ * Get the number of columns in the grid (default 12).
329
+ *
330
+ * @returns the current number of columns in the grid
331
+ *
332
+ * @example
333
+ * const columnCount = grid.getColumn(); // returns 12 by default
225
334
  */
226
335
  getColumn(): number;
227
- /** returns an array of grid HTML elements (no placeholder) - used to iterate through our children in DOM order */
336
+ /**
337
+ * Returns an array of grid HTML elements (no placeholder) - used to iterate through our children in DOM order.
338
+ * This method excludes placeholder elements and returns only actual grid items.
339
+ *
340
+ * @returns array of GridItemHTMLElement instances representing all grid items
341
+ *
342
+ * @example
343
+ * const items = grid.getGridItems();
344
+ * items.forEach(item => {
345
+ * console.log('Item ID:', item.gridstackNode.id);
346
+ * });
347
+ */
228
348
  getGridItems(): GridItemHTMLElement[];
229
- /** true if changeCB should be ignored due to column change, sizeToContent, loading, etc... which caller can ignore for dirty flag case */
349
+ /**
350
+ * Returns true if change callbacks should be ignored due to column change, sizeToContent, loading, etc.
351
+ * This is useful for callers who want to implement dirty flag functionality.
352
+ *
353
+ * @returns true if change callbacks are currently being ignored
354
+ *
355
+ * @example
356
+ * if (!grid.isIgnoreChangeCB()) {
357
+ * // Process the change event
358
+ * console.log('Grid layout changed');
359
+ * }
360
+ */
230
361
  isIgnoreChangeCB(): boolean;
231
362
  /**
232
363
  * Destroys a grid instance. DO NOT CALL any methods or access any vars after this as it will free up members.
@@ -234,11 +365,25 @@ export declare class GridStack {
234
365
  */
235
366
  destroy(removeDOM?: boolean): GridStack;
236
367
  /**
237
- * enable/disable floating widgets (default: `false`) See [example](http://gridstackjs.com/demo/float.html)
368
+ * Enable/disable floating widgets (default: `false`). When enabled, widgets can float up to fill empty spaces.
369
+ * See [example](http://gridstackjs.com/demo/float.html)
370
+ *
371
+ * @param val true to enable floating, false to disable
372
+ * @returns the grid instance for chaining
373
+ *
374
+ * @example
375
+ * grid.float(true); // Enable floating
376
+ * grid.float(false); // Disable floating (default)
238
377
  */
239
378
  float(val: boolean): GridStack;
240
379
  /**
241
- * get the current float mode
380
+ * Get the current float mode setting.
381
+ *
382
+ * @returns true if floating is enabled, false otherwise
383
+ *
384
+ * @example
385
+ * const isFloating = grid.getFloat();
386
+ * console.log('Floating enabled:', isFloating);
242
387
  */
243
388
  getFloat(): boolean;
244
389
  /**
@@ -251,45 +396,89 @@ export declare class GridStack {
251
396
  * Returns an object with properties `x` and `y` i.e. the column and row in the grid.
252
397
  */
253
398
  getCellFromPixel(position: MousePosition, useDocRelative?: boolean): CellPosition;
254
- /** returns the current number of rows, which will be at least `minRow` if set */
399
+ /**
400
+ * Returns the current number of rows, which will be at least `minRow` if set.
401
+ * The row count is based on the highest positioned widget in the grid.
402
+ *
403
+ * @returns the current number of rows in the grid
404
+ *
405
+ * @example
406
+ * const rowCount = grid.getRow();
407
+ * console.log('Grid has', rowCount, 'rows');
408
+ */
255
409
  getRow(): number;
256
410
  /**
257
- * Checks if specified area is empty.
258
- * @param x the position x.
259
- * @param y the position y.
260
- * @param w the width of to check
261
- * @param h the height of to check
411
+ * Checks if the specified rectangular area is empty (no widgets occupy any part of it).
412
+ *
413
+ * @param x the x coordinate (column) of the area to check
414
+ * @param y the y coordinate (row) of the area to check
415
+ * @param w the width in columns of the area to check
416
+ * @param h the height in rows of the area to check
417
+ * @returns true if the area is completely empty, false if any widget overlaps
418
+ *
419
+ * @example
420
+ * // Check if a 2x2 area at position (1,1) is empty
421
+ * if (grid.isAreaEmpty(1, 1, 2, 2)) {
422
+ * console.log('Area is available for placement');
423
+ * }
262
424
  */
263
425
  isAreaEmpty(x: number, y: number, w: number, h: number): boolean;
264
426
  /**
265
427
  * If you add elements to your grid by hand (or have some framework creating DOM), you have to tell gridstack afterwards to make them widgets.
266
428
  * If you want gridstack to add the elements for you, use `addWidget()` instead.
267
429
  * Makes the given element a widget and returns it.
430
+ *
268
431
  * @param els widget or single selector to convert.
269
432
  * @param options widget definition to use instead of reading attributes or using default sizing values
433
+ * @returns the converted GridItemHTMLElement
270
434
  *
271
435
  * @example
272
436
  * const grid = GridStack.init();
273
- * grid.el.innerHtml = '<div id="1" gs-w="3"></div><div id="2"></div>';
274
- * grid.makeWidget('1');
275
- * grid.makeWidget('2', {w:2, content: 'hello'});
437
+ *
438
+ * // Create HTML content manually, possibly looking like:
439
+ * // <div id="item-1" gs-x="0" gs-y="0" gs-w="3" gs-h="2"></div>
440
+ * grid.el.innerHTML = '<div id="item-1" gs-w="3"></div><div id="item-2"></div>';
441
+ *
442
+ * // Convert existing elements to widgets
443
+ * grid.makeWidget('#item-1'); // Uses gs-* attributes from DOM
444
+ * grid.makeWidget('#item-2', {w: 2, h: 1, content: 'Hello World'});
445
+ *
446
+ * // Or pass DOM element directly
447
+ * const element = document.getElementById('item-3');
448
+ * grid.makeWidget(element, {x: 0, y: 1, w: 4, h: 2});
276
449
  */
277
450
  makeWidget(els: GridStackElement, options?: GridStackWidget): GridItemHTMLElement;
278
451
  /**
279
- * Event handler that extracts our CustomEvent data out automatically for receiving custom
280
- * notifications (see doc for supported events)
281
- * @param name of the event (see possible values) or list of names space separated
282
- * @param callback function called with event and optional second/third param
283
- * (see README documentation for each signature).
452
+ * Register event handler for grid events. You can call this on a single event name, or space separated list.
284
453
  *
285
- * @example
286
- * grid.on('added', function(e, items) { log('added ', items)} );
287
- * or
288
- * grid.on('added removed change', function(e, items) { log(e.type, items)} );
454
+ * Supported events:
455
+ * - `added`: Called when widgets are being added to a grid
456
+ * - `change`: Occurs when widgets change their position/size due to constraints or direct changes
457
+ * - `disable`: Called when grid becomes disabled
458
+ * - `dragstart`: Called when grid item starts being dragged
459
+ * - `drag`: Called while grid item is being dragged (for each new row/column value)
460
+ * - `dragstop`: Called after user is done moving the item, with updated DOM attributes
461
+ * - `dropped`: Called when an item has been dropped and accepted over a grid
462
+ * - `enable`: Called when grid becomes enabled
463
+ * - `removed`: Called when items are being removed from the grid
464
+ * - `resizestart`: Called before user starts resizing an item
465
+ * - `resize`: Called while grid item is being resized (for each new row/column value)
466
+ * - `resizestop`: Called after user is done resizing the item, with updated DOM attributes
289
467
  *
290
- * Note: in some cases it is the same as calling native handler and parsing the event.
291
- * grid.el.addEventListener('added', function(event) { log('added ', event.detail)} );
468
+ * @param name event name(s) to listen for (space separated for multiple)
469
+ * @param callback function to call when event occurs
470
+ * @returns the grid instance for chaining
292
471
  *
472
+ * @example
473
+ * // Listen to multiple events at once
474
+ * grid.on('added removed change', (event, items) => {
475
+ * items.forEach(item => console.log('Item changed:', item));
476
+ * });
477
+ *
478
+ * // Listen to individual events
479
+ * grid.on('added', (event, items) => {
480
+ * items.forEach(item => console.log('Added item:', item));
481
+ * });
293
482
  */
294
483
  on(name: 'dropped', callback: GridStackDroppedHandler): GridStack;
295
484
  on(name: 'enable' | 'disable', callback: GridStackEventHandler): GridStack;
@@ -301,7 +490,14 @@ export declare class GridStack {
301
490
  * @param name of the event (see possible values) or list of names space separated
302
491
  */
303
492
  off(name: GridStackEvent | string): GridStack;
304
- /** remove all event handlers */
493
+ /**
494
+ * Remove all event handlers from the grid. This is useful for cleanup when destroying a grid.
495
+ *
496
+ * @returns the grid instance for chaining
497
+ *
498
+ * @example
499
+ * grid.offAll(); // Remove all event listeners
500
+ */
305
501
  offAll(): GridStack;
306
502
  /**
307
503
  * Removes widget from the grid.
@@ -337,32 +533,100 @@ export declare class GridStack {
337
533
  */
338
534
  updateOptions(o: GridStackOptions): GridStack;
339
535
  /**
340
- * Updates widget position/size and other info. Note: if you need to call this on all nodes, use load() instead which will update what changed.
341
- * @param els widget or selector of objects to modify (note: setting the same x,y for multiple items will be indeterministic and likely unwanted)
342
- * @param opt new widget options (x,y,w,h, etc..). Only those set will be updated.
536
+ * Updates widget position/size and other info. This is used to change widget properties after creation.
537
+ * Can update position, size, content, and other widget properties.
538
+ *
539
+ * Note: If you need to call this on all nodes, use load() instead which will update what changed.
540
+ * Setting the same x,y for multiple items will be indeterministic and likely unwanted.
541
+ *
542
+ * @param els widget element(s) or selector to modify
543
+ * @param opt new widget options (x,y,w,h, etc.). Only those set will be updated.
544
+ * @returns the grid instance for chaining
545
+ *
546
+ * @example
547
+ * // Update widget size and position
548
+ * grid.update('.my-widget', { x: 2, y: 1, w: 3, h: 2 });
549
+ *
550
+ * // Update widget content
551
+ * grid.update(widget, { content: '<p>New content</p>' });
552
+ *
553
+ * // Update multiple properties
554
+ * grid.update('#my-widget', {
555
+ * w: 4,
556
+ * h: 3,
557
+ * noResize: true,
558
+ * locked: true
559
+ * });
343
560
  */
344
561
  update(els: GridStackElement, opt: GridStackWidget): GridStack;
345
562
  private moveNode;
346
563
  /**
347
- * Updates widget height to match the content height to avoid v-scrollbar or dead space.
348
- * Note: this assumes only 1 child under resizeToContentParent='.grid-stack-item-content' (sized to gridItem minus padding) that is at the entire content size wanted.
349
- * @param el grid item element
350
- * @param useNodeH set to true if GridStackNode.h should be used instead of actual container height when we don't need to wait for animation to finish to get actual DOM heights
564
+ * Updates widget height to match the content height to avoid vertical scrollbars or dead space.
565
+ * This automatically adjusts the widget height based on its content size.
566
+ *
567
+ * Note: This assumes only 1 child under resizeToContentParent='.grid-stack-item-content'
568
+ * (sized to gridItem minus padding) that represents the entire content size.
569
+ *
570
+ * @param el the grid item element to resize
571
+ *
572
+ * @example
573
+ * // Resize a widget to fit its content
574
+ * const widget = document.querySelector('.grid-stack-item');
575
+ * grid.resizeToContent(widget);
576
+ *
577
+ * // This is commonly used with dynamic content:
578
+ * widget.querySelector('.content').innerHTML = 'New longer content...';
579
+ * grid.resizeToContent(widget);
351
580
  */
352
581
  resizeToContent(el: GridItemHTMLElement): void;
353
582
  /** call the user resize (so they can do extra work) else our build in version */
354
583
  private resizeToContentCBCheck;
355
- /** rotate (by swapping w & h) the passed in node - called when user press 'r' during dragging
356
- * @param els widget or selector of objects to modify
357
- * @param relative optional pixel coord relative to upper/left corner to rotate around (will keep that cell under cursor)
584
+ /**
585
+ * Rotate widgets by swapping their width and height. This is typically called when the user presses 'r' during dragging.
586
+ * The rotation swaps the w/h dimensions and adjusts min/max constraints accordingly.
587
+ *
588
+ * @param els widget element(s) or selector to rotate
589
+ * @param relative optional pixel coordinate relative to upper/left corner to rotate around (keeps that cell under cursor)
590
+ * @returns the grid instance for chaining
591
+ *
592
+ * @example
593
+ * // Rotate a specific widget
594
+ * grid.rotate('.my-widget');
595
+ *
596
+ * // Rotate with relative positioning during drag
597
+ * grid.rotate(widget, { left: 50, top: 30 });
358
598
  */
359
599
  rotate(els: GridStackElement, relative?: Position): GridStack;
360
600
  /**
361
- * Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options (CSS string format of 1,2,4 values or single number).
362
- * @param value margin value
601
+ * Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options.
602
+ * Supports CSS string format of 1, 2, or 4 values or a single number.
603
+ *
604
+ * @param value margin value - can be:
605
+ * - Single number: `10` (applies to all sides)
606
+ * - Two values: `'10px 20px'` (top/bottom, left/right)
607
+ * - Four values: `'10px 20px 5px 15px'` (top, right, bottom, left)
608
+ * @returns the grid instance for chaining
609
+ *
610
+ * @example
611
+ * grid.margin(10); // 10px all sides
612
+ * grid.margin('10px 20px'); // 10px top/bottom, 20px left/right
613
+ * grid.margin('5px 10px 15px 20px'); // Different for each side
363
614
  */
364
615
  margin(value: numberOrString): GridStack;
365
- /** returns current margin number value (undefined if 4 sides don't match) */
616
+ /**
617
+ * Returns the current margin value as a number (undefined if the 4 sides don't match).
618
+ * This only returns a number if all sides have the same margin value.
619
+ *
620
+ * @returns the margin value in pixels, or undefined if sides have different values
621
+ *
622
+ * @example
623
+ * const margin = grid.getMargin();
624
+ * if (margin !== undefined) {
625
+ * console.log('Uniform margin:', margin, 'px');
626
+ * } else {
627
+ * console.log('Margins are different on different sides');
628
+ * }
629
+ */
366
630
  getMargin(): number;
367
631
  /**
368
632
  * Returns true if the height of the grid will be less than the vertical
@@ -387,8 +651,16 @@ export declare class GridStack {
387
651
  private resizeToContentCheck;
388
652
  /** add or remove the grid element size event handler */
389
653
  protected _updateResizeEvent(forceRemove?: boolean): GridStack;
390
- static GDRev: string;
391
- /** get the global (but static to this code) DD implementation */
654
+ /**
655
+ * Get the global drag & drop implementation instance.
656
+ * This provides access to the underlying drag & drop functionality.
657
+ *
658
+ * @returns the DDGridStack instance used for drag & drop operations
659
+ *
660
+ * @example
661
+ * const dd = GridStack.getDD();
662
+ * // Access drag & drop functionality
663
+ */
392
664
  static getDD(): DDGridStack;
393
665
  /**
394
666
  * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.
@@ -401,47 +673,120 @@ export declare class GridStack {
401
673
  */
402
674
  static setupDragIn(dragIn?: string | HTMLElement[], dragInOptions?: DDDragOpt, widgets?: GridStackWidget[], root?: HTMLElement | Document): void;
403
675
  /**
404
- * Enables/Disables dragging by the user of specific grid element. If you want all items, and have it affect future items, use enableMove() instead. No-op for static grids.
405
- * IF you are looking to prevent an item from moving (due to being pushed around by another during collision) use locked property instead.
406
- * @param els widget or selector to modify.
407
- * @param val if true widget will be draggable, assuming the parent grid isn't noMove or static.
676
+ * Enables/Disables dragging by the user for specific grid elements.
677
+ * For all items and future items, use enableMove() instead. No-op for static grids.
678
+ *
679
+ * Note: If you want to prevent an item from moving due to being pushed around by another
680
+ * during collision, use the 'locked' property instead.
681
+ *
682
+ * @param els widget element(s) or selector to modify
683
+ * @param val if true widget will be draggable, assuming the parent grid isn't noMove or static
684
+ * @returns the grid instance for chaining
685
+ *
686
+ * @example
687
+ * // Make specific widgets draggable
688
+ * grid.movable('.my-widget', true);
689
+ *
690
+ * // Disable dragging for specific widgets
691
+ * grid.movable('#fixed-widget', false);
408
692
  */
409
693
  movable(els: GridStackElement, val: boolean): GridStack;
410
694
  /**
411
- * Enables/Disables user resizing of specific grid element. If you want all items, and have it affect future items, use enableResize() instead. No-op for static grids.
412
- * @param els widget or selector to modify
413
- * @param val if true widget will be resizable, assuming the parent grid isn't noResize or static.
695
+ * Enables/Disables user resizing for specific grid elements.
696
+ * For all items and future items, use enableResize() instead. No-op for static grids.
697
+ *
698
+ * @param els widget element(s) or selector to modify
699
+ * @param val if true widget will be resizable, assuming the parent grid isn't noResize or static
700
+ * @returns the grid instance for chaining
701
+ *
702
+ * @example
703
+ * // Make specific widgets resizable
704
+ * grid.resizable('.my-widget', true);
705
+ *
706
+ * // Disable resizing for specific widgets
707
+ * grid.resizable('#fixed-size-widget', false);
414
708
  */
415
709
  resizable(els: GridStackElement, val: boolean): GridStack;
416
710
  /**
417
711
  * Temporarily disables widgets moving/resizing.
418
712
  * If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.
419
- * Note: no-op for static grid
713
+ *
714
+ * Note: This is a no-op for static grids.
715
+ *
420
716
  * This is a shortcut for:
717
+ * ```typescript
718
+ * grid.enableMove(false);
719
+ * grid.enableResize(false);
720
+ * ```
721
+ *
722
+ * @param recurse if true (default), sub-grids also get updated
723
+ * @returns the grid instance for chaining
724
+ *
421
725
  * @example
422
- * grid.enableMove(false);
423
- * grid.enableResize(false);
424
- * @param recurse true (default) if sub-grids also get updated
726
+ * // Disable all interactions
727
+ * grid.disable();
728
+ *
729
+ * // Disable only this grid, not sub-grids
730
+ * grid.disable(false);
425
731
  */
426
732
  disable(recurse?: boolean): GridStack;
427
733
  /**
428
734
  * Re-enables widgets moving/resizing - see disable().
429
- * Note: no-op for static grid.
735
+ * Note: This is a no-op for static grids.
736
+ *
430
737
  * This is a shortcut for:
738
+ * ```typescript
739
+ * grid.enableMove(true);
740
+ * grid.enableResize(true);
741
+ * ```
742
+ *
743
+ * @param recurse if true (default), sub-grids also get updated
744
+ * @returns the grid instance for chaining
745
+ *
431
746
  * @example
432
- * grid.enableMove(true);
433
- * grid.enableResize(true);
434
- * @param recurse true (default) if sub-grids also get updated
747
+ * // Re-enable all interactions
748
+ * grid.enable();
749
+ *
750
+ * // Enable only this grid, not sub-grids
751
+ * grid.enable(false);
435
752
  */
436
753
  enable(recurse?: boolean): GridStack;
437
754
  /**
438
- * Enables/disables widget moving. No-op for static grids, and locally defined items still overrule
439
- * @param recurse true (default) if sub-grids also get updated
755
+ * Enables/disables widget moving for all widgets. No-op for static grids.
756
+ * Note: locally defined items (with noMove property) still override this setting.
757
+ *
758
+ * @param doEnable if true widgets will be movable, if false moving is disabled
759
+ * @param recurse if true (default), sub-grids also get updated
760
+ * @returns the grid instance for chaining
761
+ *
762
+ * @example
763
+ * // Enable moving for all widgets
764
+ * grid.enableMove(true);
765
+ *
766
+ * // Disable moving for all widgets
767
+ * grid.enableMove(false);
768
+ *
769
+ * // Enable only this grid, not sub-grids
770
+ * grid.enableMove(true, false);
440
771
  */
441
772
  enableMove(doEnable: boolean, recurse?: boolean): GridStack;
442
773
  /**
443
- * Enables/disables widget resizing. No-op for static grids.
444
- * @param recurse true (default) if sub-grids also get updated
774
+ * Enables/disables widget resizing for all widgets. No-op for static grids.
775
+ * Note: locally defined items (with noResize property) still override this setting.
776
+ *
777
+ * @param doEnable if true widgets will be resizable, if false resizing is disabled
778
+ * @param recurse if true (default), sub-grids also get updated
779
+ * @returns the grid instance for chaining
780
+ *
781
+ * @example
782
+ * // Enable resizing for all widgets
783
+ * grid.enableResize(true);
784
+ *
785
+ * // Disable resizing for all widgets
786
+ * grid.enableResize(false);
787
+ *
788
+ * // Enable only this grid, not sub-grids
789
+ * grid.enableResize(true, false);
445
790
  */
446
791
  enableResize(doEnable: boolean, recurse?: boolean): GridStack;
447
792
  /**