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