gridstack 12.3.2 → 12.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.
- package/dist/angular/esm2020/lib/base-widget.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack-item.component.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack.component.mjs +2 -2
- package/dist/angular/esm2020/lib/gridstack.module.mjs +2 -2
- package/dist/angular/esm2020/lib/types.mjs +2 -2
- package/dist/angular/fesm2015/gridstack-angular.mjs +4 -4
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
- package/dist/angular/fesm2020/gridstack-angular.mjs +5 -5
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
- package/dist/angular/lib/gridstack-item.component.d.ts +1 -1
- package/dist/angular/lib/gridstack.component.d.ts +1 -1
- package/dist/angular/lib/types.d.ts +1 -1
- package/dist/angular/package.json +1 -1
- package/dist/angular/src/base-widget.ts +1 -1
- package/dist/angular/src/gridstack-item.component.ts +1 -1
- package/dist/angular/src/gridstack.component.ts +1 -1
- package/dist/angular/src/gridstack.module.ts +1 -1
- package/dist/angular/src/types.ts +1 -1
- package/dist/gridstack-all.js +1 -1
- package/dist/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/gridstack-all.js.map +1 -1
- package/dist/gridstack.css +1 -1
- package/dist/spec/gridstack-engine-spec.d.ts +1 -0
- package/dist/spec/gridstack-engine-spec.js +358 -0
- package/dist/spec/gridstack-engine-spec.js.map +1 -0
- package/dist/spec/gridstack-spec.d.ts +1 -0
- package/dist/spec/gridstack-spec.js +1780 -0
- package/dist/spec/gridstack-spec.js.map +1 -0
- package/dist/spec/integration/gridstack-integration.spec.d.ts +1 -0
- package/dist/spec/integration/gridstack-integration.spec.js +171 -0
- package/dist/spec/integration/gridstack-integration.spec.js.map +1 -0
- package/dist/spec/regression-spec.d.ts +1 -0
- package/dist/spec/regression-spec.js +100 -0
- package/dist/spec/regression-spec.js.map +1 -0
- package/dist/spec/utils-spec.d.ts +1 -0
- package/dist/spec/utils-spec.js +243 -0
- package/dist/spec/utils-spec.js.map +1 -0
- package/dist/src/dd-base-impl.d.ts +69 -0
- package/dist/src/dd-base-impl.js +70 -0
- package/dist/src/dd-base-impl.js.map +1 -0
- package/dist/src/dd-draggable.d.ts +20 -0
- package/dist/src/dd-draggable.js +364 -0
- package/dist/src/dd-draggable.js.map +1 -0
- package/dist/src/dd-droppable.d.ts +26 -0
- package/dist/src/dd-droppable.js +149 -0
- package/dist/src/dd-droppable.js.map +1 -0
- package/dist/src/dd-element.d.ts +27 -0
- package/dist/src/dd-element.js +91 -0
- package/dist/src/dd-element.js.map +1 -0
- package/dist/src/dd-gridstack.d.ts +82 -0
- package/dist/src/dd-gridstack.js +165 -0
- package/dist/src/dd-gridstack.js.map +1 -0
- package/dist/src/dd-manager.d.ts +43 -0
- package/dist/src/dd-manager.js +14 -0
- package/dist/src/dd-manager.js.map +1 -0
- package/dist/src/dd-resizable-handle.d.ts +18 -0
- package/dist/src/dd-resizable-handle.js +113 -0
- package/dist/src/dd-resizable-handle.js.map +1 -0
- package/dist/src/dd-resizable.d.ts +30 -0
- package/dist/src/dd-resizable.js +304 -0
- package/dist/src/dd-resizable.js.map +1 -0
- package/dist/src/dd-touch.d.ts +33 -0
- package/dist/src/dd-touch.js +145 -0
- package/dist/src/dd-touch.js.map +1 -0
- package/dist/src/gridstack-engine.d.ts +321 -0
- package/dist/src/gridstack-engine.js +1272 -0
- package/dist/src/gridstack-engine.js.map +1 -0
- package/dist/src/gridstack.d.ts +802 -0
- package/dist/src/gridstack.js +2872 -0
- package/dist/src/gridstack.js.map +1 -0
- package/dist/src/gridstack.scss +1 -1
- package/dist/src/types.d.ts +427 -0
- package/dist/src/types.js +38 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +283 -0
- package/dist/src/utils.js +790 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +74 -0
- package/dist/vitest.config.js.map +1 -0
- package/dist/vitest.setup.d.ts +1 -0
- package/dist/vitest.setup.js +90 -0
- package/dist/vitest.setup.js.map +1 -0
- package/doc/API.md +22 -22
- package/package.json +21 -9
|
@@ -0,0 +1,802 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* GridStack 12.3.3
|
|
3
|
+
* https://gridstackjs.com/
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2021-2025 Alain Dumesny
|
|
6
|
+
* see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
|
|
7
|
+
*/
|
|
8
|
+
import { GridStackEngine } from './gridstack-engine';
|
|
9
|
+
import { Utils } from './utils';
|
|
10
|
+
import { ColumnOptions, GridItemHTMLElement, GridStackElement, GridStackEventHandlerCallback, GridStackNode, GridStackWidget, numberOrString, DDDragOpt, GridStackOptions, GridStackEventHandler, GridStackNodesHandler, AddRemoveFcn, SaveFcn, CompactOptions, ResizeToContentFcn, GridStackDroppedHandler, GridStackElementHandler, Position, RenderFcn } from './types';
|
|
11
|
+
import { DDGridStack } from './dd-gridstack';
|
|
12
|
+
export * from './types';
|
|
13
|
+
export * from './utils';
|
|
14
|
+
export * from './gridstack-engine';
|
|
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';
|
|
23
|
+
export interface GridHTMLElement extends HTMLElement {
|
|
24
|
+
gridstack?: GridStack;
|
|
25
|
+
}
|
|
26
|
+
/** list of possible events, or space separated list of them */
|
|
27
|
+
export type GridStackEvent = 'added' | 'change' | 'disable' | 'drag' | 'dragstart' | 'dragstop' | 'dropped' | 'enable' | 'removed' | 'resize' | 'resizestart' | 'resizestop' | 'resizecontent';
|
|
28
|
+
/** Defines the coordinates of an object */
|
|
29
|
+
export interface MousePosition {
|
|
30
|
+
top: number;
|
|
31
|
+
left: number;
|
|
32
|
+
}
|
|
33
|
+
/** Defines the position of a cell inside the grid*/
|
|
34
|
+
export interface CellPosition {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Main gridstack class - you will need to call `GridStack.init()` first to initialize your grid.
|
|
40
|
+
* Note: your grid elements MUST have the following classes for the CSS layout to work:
|
|
41
|
+
* @example
|
|
42
|
+
* <div class="grid-stack">
|
|
43
|
+
* <div class="grid-stack-item">
|
|
44
|
+
* <div class="grid-stack-item-content">Item 1</div>
|
|
45
|
+
* </div>
|
|
46
|
+
* </div>
|
|
47
|
+
*/
|
|
48
|
+
export declare class GridStack {
|
|
49
|
+
el: GridHTMLElement;
|
|
50
|
+
opts: GridStackOptions;
|
|
51
|
+
/**
|
|
52
|
+
* initializing the HTML element, or selector string, into a grid will return the grid. Calling it again will
|
|
53
|
+
* simply return the existing instance (ignore any passed options). There is also an initAll() version that support
|
|
54
|
+
* multiple grids initialization at once. Or you can use addGrid() to create the entire grid from JSON.
|
|
55
|
+
* @param options grid options (optional)
|
|
56
|
+
* @param elOrString element or CSS selector (first one used) to convert to a grid (default to '.grid-stack' class selector)
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* const grid = GridStack.init();
|
|
60
|
+
*
|
|
61
|
+
* Note: the HTMLElement (of type GridHTMLElement) will store a `gridstack: GridStack` value that can be retrieve later
|
|
62
|
+
* const grid = document.querySelector('.grid-stack').gridstack;
|
|
63
|
+
*/
|
|
64
|
+
static init(options?: GridStackOptions, elOrString?: GridStackElement): GridStack;
|
|
65
|
+
/**
|
|
66
|
+
* Will initialize a list of elements (given a selector) and return an array of grids.
|
|
67
|
+
* @param options grid options (optional)
|
|
68
|
+
* @param selector elements selector to convert to grids (default to '.grid-stack' class selector)
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* const grids = GridStack.initAll();
|
|
72
|
+
* grids.forEach(...)
|
|
73
|
+
*/
|
|
74
|
+
static initAll(options?: GridStackOptions, selector?: string): GridStack[];
|
|
75
|
+
/**
|
|
76
|
+
* call to create a grid with the given options, including loading any children from JSON structure. This will call GridStack.init(), then
|
|
77
|
+
* grid.load() on any passed children (recursively). Great alternative to calling init() if you want entire grid to come from
|
|
78
|
+
* JSON serialized data, including options.
|
|
79
|
+
* @param parent HTML element parent to the grid
|
|
80
|
+
* @param opt grids options used to initialize the grid, and list of children
|
|
81
|
+
*/
|
|
82
|
+
static addGrid(parent: HTMLElement, opt?: GridStackOptions): GridStack;
|
|
83
|
+
/** call this method to register your engine instead of the default one.
|
|
84
|
+
* See instead `GridStackOptions.engineClass` if you only need to
|
|
85
|
+
* replace just one instance.
|
|
86
|
+
*/
|
|
87
|
+
static registerEngine(engineClass: typeof GridStackEngine): void;
|
|
88
|
+
/**
|
|
89
|
+
* callback method use when new items|grids needs to be created or deleted, instead of the default
|
|
90
|
+
* item: <div class="grid-stack-item"><div class="grid-stack-item-content">w.content</div></div>
|
|
91
|
+
* grid: <div class="grid-stack">grid content...</div>
|
|
92
|
+
* add = true: the returned DOM element will then be converted to a GridItemHTMLElement using makeWidget()|GridStack:init().
|
|
93
|
+
* add = false: the item will be removed from DOM (if not already done)
|
|
94
|
+
* grid = true|false for grid vs grid-items
|
|
95
|
+
*/
|
|
96
|
+
static addRemoveCB?: AddRemoveFcn;
|
|
97
|
+
/**
|
|
98
|
+
* callback during saving to application can inject extra data for each widget, on top of the grid layout properties
|
|
99
|
+
*/
|
|
100
|
+
static saveCB?: SaveFcn;
|
|
101
|
+
/**
|
|
102
|
+
* callback to create the content of widgets so the app can control how to store and restore it
|
|
103
|
+
* By default this lib will do 'el.textContent = w.content' forcing text only support for avoiding potential XSS issues.
|
|
104
|
+
*/
|
|
105
|
+
static renderCB?: RenderFcn;
|
|
106
|
+
/** called after a widget has been updated (eg: load() into an existing list of children) so application can do extra work */
|
|
107
|
+
static updateCB?: (w: GridStackNode) => void;
|
|
108
|
+
/** callback to use for resizeToContent instead of the built in one */
|
|
109
|
+
static resizeToContentCB?: ResizeToContentFcn;
|
|
110
|
+
/** parent class for sizing content. defaults to '.grid-stack-item-content' */
|
|
111
|
+
static resizeToContentParent: string;
|
|
112
|
+
/** scoping so users can call GridStack.Utils.sort() for example */
|
|
113
|
+
static Utils: typeof Utils;
|
|
114
|
+
/** scoping so users can call new GridStack.Engine(12) for example */
|
|
115
|
+
static Engine: typeof GridStackEngine;
|
|
116
|
+
/** engine used to implement non DOM grid functionality */
|
|
117
|
+
engine: GridStackEngine;
|
|
118
|
+
/** point to a parent grid item if we're nested (inside a grid-item in between 2 Grids) */
|
|
119
|
+
parentGridNode?: GridStackNode;
|
|
120
|
+
/** time to wait for animation (if enabled) to be done so content sizing can happen */
|
|
121
|
+
animationDelay: number;
|
|
122
|
+
protected static engineClass: typeof GridStackEngine;
|
|
123
|
+
protected resizeObserver: ResizeObserver;
|
|
124
|
+
protected responseLayout: ColumnOptions;
|
|
125
|
+
private _skipInitialResize;
|
|
126
|
+
/**
|
|
127
|
+
* Construct a grid item from the given element and options
|
|
128
|
+
* @param el the HTML element tied to this grid after it's been initialized
|
|
129
|
+
* @param opts grid options - public for classes to access, but use methods to modify!
|
|
130
|
+
*/
|
|
131
|
+
constructor(el: GridHTMLElement, opts?: GridStackOptions);
|
|
132
|
+
private _updateColumnVar;
|
|
133
|
+
/**
|
|
134
|
+
* add a new widget and returns it.
|
|
135
|
+
*
|
|
136
|
+
* Widget will be always placed even if result height is more than actual grid height.
|
|
137
|
+
* You need to use `willItFit()` before calling addWidget for additional check.
|
|
138
|
+
* See also `makeWidget(el)` for DOM element.
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* const grid = GridStack.init();
|
|
142
|
+
* grid.addWidget({w: 3, content: 'hello'});
|
|
143
|
+
*
|
|
144
|
+
* @param w GridStackWidget definition. used MakeWidget(el) if you have dom element instead.
|
|
145
|
+
*/
|
|
146
|
+
addWidget(w: GridStackWidget): GridItemHTMLElement;
|
|
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
|
+
*/
|
|
156
|
+
createWidgetDivs(n: GridStackNode): HTMLElement;
|
|
157
|
+
/**
|
|
158
|
+
* Convert an existing gridItem element into a sub-grid with the given (optional) options, else inherit them
|
|
159
|
+
* from the parent's subGrid options.
|
|
160
|
+
* @param el gridItem element to convert
|
|
161
|
+
* @param ops (optional) sub-grid options, else default to node, then parent settings, else defaults
|
|
162
|
+
* @param nodeToAdd (optional) node to add to the newly created sub grid (used when dragging over existing regular item)
|
|
163
|
+
* @param saveContent if true (default) the html inside .grid-stack-content will be saved to child widget
|
|
164
|
+
* @returns newly created grid
|
|
165
|
+
*/
|
|
166
|
+
makeSubGrid(el: GridItemHTMLElement, ops?: GridStackOptions, nodeToAdd?: GridStackNode, saveContent?: boolean): GridStack;
|
|
167
|
+
/**
|
|
168
|
+
* called when an item was converted into a nested grid to accommodate a dragged over item, but then item leaves - return back
|
|
169
|
+
* to the original grid-item. Also called to remove empty sub-grids when last item is dragged out (since re-creating is simple)
|
|
170
|
+
*/
|
|
171
|
+
removeAsSubGrid(nodeThatRemoved?: GridStackNode): void;
|
|
172
|
+
/**
|
|
173
|
+
* saves the current layout returning a list of widgets for serialization which might include any nested grids.
|
|
174
|
+
* @param saveContent if true (default) the latest html inside .grid-stack-content will be saved to GridStackWidget.content field, else it will
|
|
175
|
+
* be removed.
|
|
176
|
+
* @param saveGridOpt if true (default false), save the grid options itself, so you can call the new GridStack.addGrid()
|
|
177
|
+
* to recreate everything from scratch. GridStackOptions.children would then contain the widget list instead.
|
|
178
|
+
* @param saveCB callback for each node -> widget, so application can insert additional data to be saved into the widget data structure.
|
|
179
|
+
* @param column 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: if you want to save to currently display layout, pass this.getColumn() as column.
|
|
182
|
+
* NOTE2: nested grids will ALWAYS save to the container size to be in sync with parent.
|
|
183
|
+
* @returns list of widgets or full grid option, including .children list of widgets
|
|
184
|
+
*/
|
|
185
|
+
save(saveContent?: boolean, saveGridOpt?: boolean, saveCB?: SaveFcn, column?: number): GridStackWidget[] | GridStackOptions;
|
|
186
|
+
/**
|
|
187
|
+
* Load widgets from a list. This will call update() on each (matching by id) or add/remove widgets that are not there.
|
|
188
|
+
* Used to restore a grid layout for a saved layout list (see `save()`).
|
|
189
|
+
*
|
|
190
|
+
* @param items list of widgets definition to update/create
|
|
191
|
+
* @param addRemove boolean (default true) or callback method can be passed to control if and how missing widgets can be added/removed, giving
|
|
192
|
+
* the user control of insertion.
|
|
193
|
+
* @returns the grid instance for chaining
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* // Basic usage with saved layout
|
|
197
|
+
* const savedLayout = grid.save(); // Save current layout
|
|
198
|
+
* // ... later restore it
|
|
199
|
+
* grid.load(savedLayout);
|
|
200
|
+
*
|
|
201
|
+
* // Load with custom add/remove callback
|
|
202
|
+
* grid.load(layout, (items, grid, add) => {
|
|
203
|
+
* if (add) {
|
|
204
|
+
* // Custom logic for adding new widgets
|
|
205
|
+
* items.forEach(item => {
|
|
206
|
+
* const el = document.createElement('div');
|
|
207
|
+
* el.innerHTML = item.content || '';
|
|
208
|
+
* grid.addWidget(el, item);
|
|
209
|
+
* });
|
|
210
|
+
* } else {
|
|
211
|
+
* // Custom logic for removing widgets
|
|
212
|
+
* items.forEach(item => grid.removeWidget(item.el));
|
|
213
|
+
* }
|
|
214
|
+
* });
|
|
215
|
+
*
|
|
216
|
+
* // Load without adding/removing missing widgets
|
|
217
|
+
* grid.load(layout, false);
|
|
218
|
+
*
|
|
219
|
+
* @see {@link http://gridstackjs.com/demo/serialization.html} for complete example
|
|
220
|
+
*/
|
|
221
|
+
load(items: GridStackWidget[], addRemove?: boolean | AddRemoveFcn): GridStack;
|
|
222
|
+
/**
|
|
223
|
+
* use before calling a bunch of `addWidget()` to prevent un-necessary relayouts in between (more efficient)
|
|
224
|
+
* and get a single event callback. You will see no changes until `batchUpdate(false)` is called.
|
|
225
|
+
*/
|
|
226
|
+
batchUpdate(flag?: boolean): GridStack;
|
|
227
|
+
/**
|
|
228
|
+
* Gets the current cell height in pixels. This takes into account the unit type and converts to pixels if necessary.
|
|
229
|
+
*
|
|
230
|
+
* @param forcePixel if true, forces conversion to pixels even when cellHeight is specified in other units
|
|
231
|
+
* @returns the cell height in pixels
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* const height = grid.getCellHeight();
|
|
235
|
+
* console.log('Cell height:', height, 'px');
|
|
236
|
+
*
|
|
237
|
+
* // Force pixel conversion
|
|
238
|
+
* const pixelHeight = grid.getCellHeight(true);
|
|
239
|
+
*/
|
|
240
|
+
getCellHeight(forcePixel?: boolean): number;
|
|
241
|
+
/**
|
|
242
|
+
* Update current cell height - see `GridStackOptions.cellHeight` for format by updating eh Browser CSS variable.
|
|
243
|
+
*
|
|
244
|
+
* @param val the cell height. Options:
|
|
245
|
+
* - `undefined`: cells content will be made square (match width minus margin)
|
|
246
|
+
* - `0`: the CSS will be generated by the application instead
|
|
247
|
+
* - number: height in pixels
|
|
248
|
+
* - string: height with units (e.g., '70px', '5rem', '2em')
|
|
249
|
+
* @returns the grid instance for chaining
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* grid.cellHeight(100); // 100px height
|
|
253
|
+
* grid.cellHeight('70px'); // explicit pixel height
|
|
254
|
+
* grid.cellHeight('5rem'); // relative to root font size
|
|
255
|
+
* grid.cellHeight(grid.cellWidth() * 1.2); // aspect ratio
|
|
256
|
+
* grid.cellHeight('auto'); // auto-size based on content
|
|
257
|
+
*/
|
|
258
|
+
cellHeight(val?: numberOrString): GridStack;
|
|
259
|
+
/** Gets current cell width. */
|
|
260
|
+
/**
|
|
261
|
+
* Gets the current cell width in pixels. This is calculated based on the grid container width divided by the number of columns.
|
|
262
|
+
*
|
|
263
|
+
* @returns the cell width in pixels
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* const width = grid.cellWidth();
|
|
267
|
+
* console.log('Cell width:', width, 'px');
|
|
268
|
+
*
|
|
269
|
+
* // Use cell width to calculate widget dimensions
|
|
270
|
+
* const widgetWidth = width * 3; // For a 3-column wide widget
|
|
271
|
+
*/
|
|
272
|
+
cellWidth(): number;
|
|
273
|
+
/** return our expected width (or parent) , and optionally of window for dynamic column check */
|
|
274
|
+
protected _widthOrContainer(forBreakpoint?: boolean): number;
|
|
275
|
+
/** checks for dynamic column count for our current size, returning true if changed */
|
|
276
|
+
protected checkDynamicColumn(): boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Re-layout grid items to reclaim any empty space. This is useful after removing widgets
|
|
279
|
+
* or when you want to optimize the layout.
|
|
280
|
+
*
|
|
281
|
+
* @param layout layout type. Options:
|
|
282
|
+
* - 'compact' (default): might re-order items to fill any empty space
|
|
283
|
+
* - 'list': keep the widget left->right order the same, even if that means leaving an empty slot if things don't fit
|
|
284
|
+
* @param doSort re-sort items first based on x,y position. Set to false to do your own sorting ahead (default: true)
|
|
285
|
+
* @returns the grid instance for chaining
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* // Compact layout after removing widgets
|
|
289
|
+
* grid.removeWidget('.widget-to-remove');
|
|
290
|
+
* grid.compact();
|
|
291
|
+
*
|
|
292
|
+
* // Use list layout (preserve order)
|
|
293
|
+
* grid.compact('list');
|
|
294
|
+
*
|
|
295
|
+
* // Compact without sorting first
|
|
296
|
+
* grid.compact('compact', false);
|
|
297
|
+
*/
|
|
298
|
+
compact(layout?: CompactOptions, doSort?: boolean): GridStack;
|
|
299
|
+
/**
|
|
300
|
+
* Set the number of columns in the grid. Will update existing widgets to conform to new number of columns,
|
|
301
|
+
* as well as cache the original layout so you can revert back to previous positions without loss.
|
|
302
|
+
*
|
|
303
|
+
* Requires `gridstack-extra.css` or `gridstack-extra.min.css` for [2-11] columns,
|
|
304
|
+
* else you will need to generate correct CSS.
|
|
305
|
+
* See: https://github.com/gridstack/gridstack.js#change-grid-columns
|
|
306
|
+
*
|
|
307
|
+
* @param column Integer > 0 (default 12)
|
|
308
|
+
* @param layout specify the type of re-layout that will happen. Options:
|
|
309
|
+
* - 'moveScale' (default): scale widget positions and sizes
|
|
310
|
+
* - 'move': keep widget sizes, only move positions
|
|
311
|
+
* - 'scale': keep widget positions, only scale sizes
|
|
312
|
+
* - 'none': don't change widget positions or sizes
|
|
313
|
+
* Note: items will never be outside of the current column boundaries.
|
|
314
|
+
* Ignored for `column=1` as we always want to vertically stack.
|
|
315
|
+
* @returns the grid instance for chaining
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* // Change to 6 columns with default scaling
|
|
319
|
+
* grid.column(6);
|
|
320
|
+
*
|
|
321
|
+
* // Change to 4 columns, only move positions
|
|
322
|
+
* grid.column(4, 'move');
|
|
323
|
+
*
|
|
324
|
+
* // Single column layout (vertical stack)
|
|
325
|
+
* grid.column(1);
|
|
326
|
+
*/
|
|
327
|
+
column(column: number, layout?: ColumnOptions): GridStack;
|
|
328
|
+
/**
|
|
329
|
+
* Get the number of columns in the grid (default 12).
|
|
330
|
+
*
|
|
331
|
+
* @returns the current number of columns in the grid
|
|
332
|
+
*
|
|
333
|
+
* @example
|
|
334
|
+
* const columnCount = grid.getColumn(); // returns 12 by default
|
|
335
|
+
*/
|
|
336
|
+
getColumn(): number;
|
|
337
|
+
/**
|
|
338
|
+
* Returns an array of grid HTML elements (no placeholder) - used to iterate through our children in DOM order.
|
|
339
|
+
* This method excludes placeholder elements and returns only actual grid items.
|
|
340
|
+
*
|
|
341
|
+
* @returns array of GridItemHTMLElement instances representing all grid items
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* const items = grid.getGridItems();
|
|
345
|
+
* items.forEach(item => {
|
|
346
|
+
* console.log('Item ID:', item.gridstackNode.id);
|
|
347
|
+
* });
|
|
348
|
+
*/
|
|
349
|
+
getGridItems(): GridItemHTMLElement[];
|
|
350
|
+
/**
|
|
351
|
+
* Returns true if change callbacks should be ignored due to column change, sizeToContent, loading, etc.
|
|
352
|
+
* This is useful for callers who want to implement dirty flag functionality.
|
|
353
|
+
*
|
|
354
|
+
* @returns true if change callbacks are currently being ignored
|
|
355
|
+
*
|
|
356
|
+
* @example
|
|
357
|
+
* if (!grid.isIgnoreChangeCB()) {
|
|
358
|
+
* // Process the change event
|
|
359
|
+
* console.log('Grid layout changed');
|
|
360
|
+
* }
|
|
361
|
+
*/
|
|
362
|
+
isIgnoreChangeCB(): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Destroys a grid instance. DO NOT CALL any methods or access any vars after this as it will free up members.
|
|
365
|
+
* @param removeDOM if `false` grid and items HTML elements will not be removed from the DOM (Optional. Default `true`).
|
|
366
|
+
*/
|
|
367
|
+
destroy(removeDOM?: boolean): GridStack;
|
|
368
|
+
/**
|
|
369
|
+
* Enable/disable floating widgets (default: `false`). When enabled, widgets can float up to fill empty spaces.
|
|
370
|
+
* See [example](http://gridstackjs.com/demo/float.html)
|
|
371
|
+
*
|
|
372
|
+
* @param val true to enable floating, false to disable
|
|
373
|
+
* @returns the grid instance for chaining
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* grid.float(true); // Enable floating
|
|
377
|
+
* grid.float(false); // Disable floating (default)
|
|
378
|
+
*/
|
|
379
|
+
float(val: boolean): GridStack;
|
|
380
|
+
/**
|
|
381
|
+
* Get the current float mode setting.
|
|
382
|
+
*
|
|
383
|
+
* @returns true if floating is enabled, false otherwise
|
|
384
|
+
*
|
|
385
|
+
* @example
|
|
386
|
+
* const isFloating = grid.getFloat();
|
|
387
|
+
* console.log('Floating enabled:', isFloating);
|
|
388
|
+
*/
|
|
389
|
+
getFloat(): boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Get the position of the cell under a pixel on screen.
|
|
392
|
+
* @param position the position of the pixel to resolve in
|
|
393
|
+
* absolute coordinates, as an object with top and left properties
|
|
394
|
+
* @param useDocRelative if true, value will be based on document position vs parent position (Optional. Default false).
|
|
395
|
+
* Useful when grid is within `position: relative` element
|
|
396
|
+
*
|
|
397
|
+
* Returns an object with properties `x` and `y` i.e. the column and row in the grid.
|
|
398
|
+
*/
|
|
399
|
+
getCellFromPixel(position: MousePosition, useDocRelative?: boolean): CellPosition;
|
|
400
|
+
/**
|
|
401
|
+
* Returns the current number of rows, which will be at least `minRow` if set.
|
|
402
|
+
* The row count is based on the highest positioned widget in the grid.
|
|
403
|
+
*
|
|
404
|
+
* @returns the current number of rows in the grid
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* const rowCount = grid.getRow();
|
|
408
|
+
* console.log('Grid has', rowCount, 'rows');
|
|
409
|
+
*/
|
|
410
|
+
getRow(): number;
|
|
411
|
+
/**
|
|
412
|
+
* Checks if the specified rectangular area is empty (no widgets occupy any part of it).
|
|
413
|
+
*
|
|
414
|
+
* @param x the x coordinate (column) of the area to check
|
|
415
|
+
* @param y the y coordinate (row) of the area to check
|
|
416
|
+
* @param w the width in columns of the area to check
|
|
417
|
+
* @param h the height in rows of the area to check
|
|
418
|
+
* @returns true if the area is completely empty, false if any widget overlaps
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* // Check if a 2x2 area at position (1,1) is empty
|
|
422
|
+
* if (grid.isAreaEmpty(1, 1, 2, 2)) {
|
|
423
|
+
* console.log('Area is available for placement');
|
|
424
|
+
* }
|
|
425
|
+
*/
|
|
426
|
+
isAreaEmpty(x: number, y: number, w: number, h: number): boolean;
|
|
427
|
+
/**
|
|
428
|
+
* 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.
|
|
429
|
+
* If you want gridstack to add the elements for you, use `addWidget()` instead.
|
|
430
|
+
* Makes the given element a widget and returns it.
|
|
431
|
+
*
|
|
432
|
+
* @param els widget or single selector to convert.
|
|
433
|
+
* @param options widget definition to use instead of reading attributes or using default sizing values
|
|
434
|
+
* @returns the converted GridItemHTMLElement
|
|
435
|
+
*
|
|
436
|
+
* @example
|
|
437
|
+
* const grid = GridStack.init();
|
|
438
|
+
*
|
|
439
|
+
* // Create HTML content manually, possibly looking like:
|
|
440
|
+
* // <div id="item-1" gs-x="0" gs-y="0" gs-w="3" gs-h="2"></div>
|
|
441
|
+
* grid.el.innerHTML = '<div id="item-1" gs-w="3"></div><div id="item-2"></div>';
|
|
442
|
+
*
|
|
443
|
+
* // Convert existing elements to widgets
|
|
444
|
+
* grid.makeWidget('#item-1'); // Uses gs-* attributes from DOM
|
|
445
|
+
* grid.makeWidget('#item-2', {w: 2, h: 1, content: 'Hello World'});
|
|
446
|
+
*
|
|
447
|
+
* // Or pass DOM element directly
|
|
448
|
+
* const element = document.getElementById('item-3');
|
|
449
|
+
* grid.makeWidget(element, {x: 0, y: 1, w: 4, h: 2});
|
|
450
|
+
*/
|
|
451
|
+
makeWidget(els: GridStackElement, options?: GridStackWidget): GridItemHTMLElement;
|
|
452
|
+
/**
|
|
453
|
+
* Register event handler for grid events. You can call this on a single event name, or space separated list.
|
|
454
|
+
*
|
|
455
|
+
* Supported events:
|
|
456
|
+
* - `added`: Called when widgets are being added to a grid
|
|
457
|
+
* - `change`: Occurs when widgets change their position/size due to constraints or direct changes
|
|
458
|
+
* - `disable`: Called when grid becomes disabled
|
|
459
|
+
* - `dragstart`: Called when grid item starts being dragged
|
|
460
|
+
* - `drag`: Called while grid item is being dragged (for each new row/column value)
|
|
461
|
+
* - `dragstop`: Called after user is done moving the item, with updated DOM attributes
|
|
462
|
+
* - `dropped`: Called when an item has been dropped and accepted over a grid
|
|
463
|
+
* - `enable`: Called when grid becomes enabled
|
|
464
|
+
* - `removed`: Called when items are being removed from the grid
|
|
465
|
+
* - `resizestart`: Called before user starts resizing an item
|
|
466
|
+
* - `resize`: Called while grid item is being resized (for each new row/column value)
|
|
467
|
+
* - `resizestop`: Called after user is done resizing the item, with updated DOM attributes
|
|
468
|
+
*
|
|
469
|
+
* @param name event name(s) to listen for (space separated for multiple)
|
|
470
|
+
* @param callback function to call when event occurs
|
|
471
|
+
* @returns the grid instance for chaining
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* // Listen to multiple events at once
|
|
475
|
+
* grid.on('added removed change', (event, items) => {
|
|
476
|
+
* items.forEach(item => console.log('Item changed:', item));
|
|
477
|
+
* });
|
|
478
|
+
*
|
|
479
|
+
* // Listen to individual events
|
|
480
|
+
* grid.on('added', (event, items) => {
|
|
481
|
+
* items.forEach(item => console.log('Added item:', item));
|
|
482
|
+
* });
|
|
483
|
+
*/
|
|
484
|
+
on(name: 'dropped', callback: GridStackDroppedHandler): GridStack;
|
|
485
|
+
on(name: 'enable' | 'disable', callback: GridStackEventHandler): GridStack;
|
|
486
|
+
on(name: 'change' | 'added' | 'removed' | 'resizecontent', callback: GridStackNodesHandler): GridStack;
|
|
487
|
+
on(name: 'resizestart' | 'resize' | 'resizestop' | 'dragstart' | 'drag' | 'dragstop', callback: GridStackElementHandler): GridStack;
|
|
488
|
+
on(name: string, callback: GridStackEventHandlerCallback): GridStack;
|
|
489
|
+
/**
|
|
490
|
+
* unsubscribe from the 'on' event GridStackEvent
|
|
491
|
+
* @param name of the event (see possible values) or list of names space separated
|
|
492
|
+
*/
|
|
493
|
+
off(name: GridStackEvent | string): GridStack;
|
|
494
|
+
/**
|
|
495
|
+
* Remove all event handlers from the grid. This is useful for cleanup when destroying a grid.
|
|
496
|
+
*
|
|
497
|
+
* @returns the grid instance for chaining
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* grid.offAll(); // Remove all event listeners
|
|
501
|
+
*/
|
|
502
|
+
offAll(): GridStack;
|
|
503
|
+
/**
|
|
504
|
+
* Removes widget from the grid.
|
|
505
|
+
* @param el widget or selector to modify
|
|
506
|
+
* @param removeDOM if `false` DOM element won't be removed from the tree (Default? true).
|
|
507
|
+
* @param triggerEvent if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true).
|
|
508
|
+
*/
|
|
509
|
+
removeWidget(els: GridStackElement, removeDOM?: boolean, triggerEvent?: boolean): GridStack;
|
|
510
|
+
/**
|
|
511
|
+
* Removes all widgets from the grid.
|
|
512
|
+
* @param removeDOM if `false` DOM elements won't be removed from the tree (Default? `true`).
|
|
513
|
+
* @param triggerEvent if `false` (quiet mode) element will not be added to removed list and no 'removed' callbacks will be called (Default? true).
|
|
514
|
+
*/
|
|
515
|
+
removeAll(removeDOM?: boolean, triggerEvent?: boolean): GridStack;
|
|
516
|
+
/**
|
|
517
|
+
* Toggle the grid animation state. Toggles the `grid-stack-animate` class.
|
|
518
|
+
* @param doAnimate if true the grid will animate.
|
|
519
|
+
* @param delay if true setting will be set on next event loop.
|
|
520
|
+
*/
|
|
521
|
+
setAnimation(doAnimate?: boolean, delay?: boolean): GridStack;
|
|
522
|
+
/**
|
|
523
|
+
* Toggle the grid static state, which permanently removes/add Drag&Drop support, unlike disable()/enable() that just turns it off/on.
|
|
524
|
+
* Also toggle the grid-stack-static class.
|
|
525
|
+
* @param val if true the grid become static.
|
|
526
|
+
* @param updateClass true (default) if css class gets updated
|
|
527
|
+
* @param recurse true (default) if sub-grids also get updated
|
|
528
|
+
*/
|
|
529
|
+
setStatic(val: boolean, updateClass?: boolean, recurse?: boolean): GridStack;
|
|
530
|
+
/**
|
|
531
|
+
* Updates the passed in options on the grid (similar to update(widget) for for the grid options).
|
|
532
|
+
* @param options PARTIAL grid options to update - only items specified will be updated.
|
|
533
|
+
* NOTE: not all options updating are currently supported (lot of code, unlikely to change)
|
|
534
|
+
*/
|
|
535
|
+
updateOptions(o: GridStackOptions): GridStack;
|
|
536
|
+
/**
|
|
537
|
+
* Updates widget position/size and other info. This is used to change widget properties after creation.
|
|
538
|
+
* Can update position, size, content, and other widget properties.
|
|
539
|
+
*
|
|
540
|
+
* Note: If you need to call this on all nodes, use load() instead which will update what changed.
|
|
541
|
+
* Setting the same x,y for multiple items will be indeterministic and likely unwanted.
|
|
542
|
+
*
|
|
543
|
+
* @param els widget element(s) or selector to modify
|
|
544
|
+
* @param opt new widget options (x,y,w,h, etc.). Only those set will be updated.
|
|
545
|
+
* @returns the grid instance for chaining
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* // Update widget size and position
|
|
549
|
+
* grid.update('.my-widget', { x: 2, y: 1, w: 3, h: 2 });
|
|
550
|
+
*
|
|
551
|
+
* // Update widget content
|
|
552
|
+
* grid.update(widget, { content: '<p>New content</p>' });
|
|
553
|
+
*
|
|
554
|
+
* // Update multiple properties
|
|
555
|
+
* grid.update('#my-widget', {
|
|
556
|
+
* w: 4,
|
|
557
|
+
* h: 3,
|
|
558
|
+
* noResize: true,
|
|
559
|
+
* locked: true
|
|
560
|
+
* });
|
|
561
|
+
*/
|
|
562
|
+
update(els: GridStackElement, opt: GridStackWidget): GridStack;
|
|
563
|
+
private moveNode;
|
|
564
|
+
/**
|
|
565
|
+
* Updates widget height to match the content height to avoid vertical scrollbars or dead space.
|
|
566
|
+
* This automatically adjusts the widget height based on its content size.
|
|
567
|
+
*
|
|
568
|
+
* Note: This assumes only 1 child under resizeToContentParent='.grid-stack-item-content'
|
|
569
|
+
* (sized to gridItem minus padding) that represents the entire content size.
|
|
570
|
+
*
|
|
571
|
+
* @param el the grid item element to resize
|
|
572
|
+
*
|
|
573
|
+
* @example
|
|
574
|
+
* // Resize a widget to fit its content
|
|
575
|
+
* const widget = document.querySelector('.grid-stack-item');
|
|
576
|
+
* grid.resizeToContent(widget);
|
|
577
|
+
*
|
|
578
|
+
* // This is commonly used with dynamic content:
|
|
579
|
+
* widget.querySelector('.content').innerHTML = 'New longer content...';
|
|
580
|
+
* grid.resizeToContent(widget);
|
|
581
|
+
*/
|
|
582
|
+
resizeToContent(el: GridItemHTMLElement): void;
|
|
583
|
+
/** call the user resize (so they can do extra work) else our build in version */
|
|
584
|
+
private resizeToContentCBCheck;
|
|
585
|
+
/**
|
|
586
|
+
* Rotate widgets by swapping their width and height. This is typically called when the user presses 'r' during dragging.
|
|
587
|
+
* The rotation swaps the w/h dimensions and adjusts min/max constraints accordingly.
|
|
588
|
+
*
|
|
589
|
+
* @param els widget element(s) or selector to rotate
|
|
590
|
+
* @param relative optional pixel coordinate relative to upper/left corner to rotate around (keeps that cell under cursor)
|
|
591
|
+
* @returns the grid instance for chaining
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
* // Rotate a specific widget
|
|
595
|
+
* grid.rotate('.my-widget');
|
|
596
|
+
*
|
|
597
|
+
* // Rotate with relative positioning during drag
|
|
598
|
+
* grid.rotate(widget, { left: 50, top: 30 });
|
|
599
|
+
*/
|
|
600
|
+
rotate(els: GridStackElement, relative?: Position): GridStack;
|
|
601
|
+
/**
|
|
602
|
+
* Updates the margins which will set all 4 sides at once - see `GridStackOptions.margin` for format options.
|
|
603
|
+
* Supports CSS string format of 1, 2, or 4 values or a single number.
|
|
604
|
+
*
|
|
605
|
+
* @param value margin value - can be:
|
|
606
|
+
* - Single number: `10` (applies to all sides)
|
|
607
|
+
* - Two values: `'10px 20px'` (top/bottom, left/right)
|
|
608
|
+
* - Four values: `'10px 20px 5px 15px'` (top, right, bottom, left)
|
|
609
|
+
* @returns the grid instance for chaining
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* grid.margin(10); // 10px all sides
|
|
613
|
+
* grid.margin('10px 20px'); // 10px top/bottom, 20px left/right
|
|
614
|
+
* grid.margin('5px 10px 15px 20px'); // Different for each side
|
|
615
|
+
*/
|
|
616
|
+
margin(value: numberOrString): GridStack;
|
|
617
|
+
/**
|
|
618
|
+
* Returns the current margin value as a number (undefined if the 4 sides don't match).
|
|
619
|
+
* This only returns a number if all sides have the same margin value.
|
|
620
|
+
*
|
|
621
|
+
* @returns the margin value in pixels, or undefined if sides have different values
|
|
622
|
+
*
|
|
623
|
+
* @example
|
|
624
|
+
* const margin = grid.getMargin();
|
|
625
|
+
* if (margin !== undefined) {
|
|
626
|
+
* console.log('Uniform margin:', margin, 'px');
|
|
627
|
+
* } else {
|
|
628
|
+
* console.log('Margins are different on different sides');
|
|
629
|
+
* }
|
|
630
|
+
*/
|
|
631
|
+
getMargin(): number;
|
|
632
|
+
/**
|
|
633
|
+
* Returns true if the height of the grid will be less than the vertical
|
|
634
|
+
* constraint. Always returns true if grid doesn't have height constraint.
|
|
635
|
+
* @param node contains x,y,w,h,auto-position options
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* if (grid.willItFit(newWidget)) {
|
|
639
|
+
* grid.addWidget(newWidget);
|
|
640
|
+
* } else {
|
|
641
|
+
* alert('Not enough free space to place the widget');
|
|
642
|
+
* }
|
|
643
|
+
*/
|
|
644
|
+
willItFit(node: GridStackWidget): boolean;
|
|
645
|
+
/**
|
|
646
|
+
* called when we are being resized - check if the one Column Mode needs to be turned on/off
|
|
647
|
+
* and remember the prev columns we used, or get our count from parent, as well as check for cellHeight==='auto' (square)
|
|
648
|
+
* or `sizeToContent` gridItem options.
|
|
649
|
+
*/
|
|
650
|
+
onResize(clientWidth?: number): GridStack;
|
|
651
|
+
/** resizes content for given node (or all) if shouldSizeToContent() is true */
|
|
652
|
+
private resizeToContentCheck;
|
|
653
|
+
/** add or remove the grid element size event handler */
|
|
654
|
+
protected _updateResizeEvent(forceRemove?: boolean): GridStack;
|
|
655
|
+
/**
|
|
656
|
+
* Get the global drag & drop implementation instance.
|
|
657
|
+
* This provides access to the underlying drag & drop functionality.
|
|
658
|
+
*
|
|
659
|
+
* @returns the DDGridStack instance used for drag & drop operations
|
|
660
|
+
*
|
|
661
|
+
* @example
|
|
662
|
+
* const dd = GridStack.getDD();
|
|
663
|
+
* // Access drag & drop functionality
|
|
664
|
+
*/
|
|
665
|
+
static getDD(): DDGridStack;
|
|
666
|
+
/**
|
|
667
|
+
* call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.
|
|
668
|
+
* Called during GridStack.init() as options, but can also be called directly (last param are used) in case the toolbar
|
|
669
|
+
* is dynamically create and needs to be set later.
|
|
670
|
+
* @param dragIn string selector (ex: '.sidebar-item') or list of dom elements
|
|
671
|
+
* @param dragInOptions options - see DDDragOpt. (default: {handle: '.grid-stack-item-content', appendTo: 'body'}
|
|
672
|
+
* @param widgets GridStackWidget def to assign to each element which defines what to create on drop
|
|
673
|
+
* @param root optional root which defaults to document (for shadow dom pass the parent HTMLDocument)
|
|
674
|
+
*/
|
|
675
|
+
static setupDragIn(dragIn?: string | HTMLElement[], dragInOptions?: DDDragOpt, widgets?: GridStackWidget[], root?: HTMLElement | Document): void;
|
|
676
|
+
/**
|
|
677
|
+
* Enables/Disables dragging by the user for specific grid elements.
|
|
678
|
+
* For all items and future items, use enableMove() instead. No-op for static grids.
|
|
679
|
+
*
|
|
680
|
+
* Note: If you want to prevent an item from moving due to being pushed around by another
|
|
681
|
+
* during collision, use the 'locked' property instead.
|
|
682
|
+
*
|
|
683
|
+
* @param els widget element(s) or selector to modify
|
|
684
|
+
* @param val if true widget will be draggable, assuming the parent grid isn't noMove or static
|
|
685
|
+
* @returns the grid instance for chaining
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* // Make specific widgets draggable
|
|
689
|
+
* grid.movable('.my-widget', true);
|
|
690
|
+
*
|
|
691
|
+
* // Disable dragging for specific widgets
|
|
692
|
+
* grid.movable('#fixed-widget', false);
|
|
693
|
+
*/
|
|
694
|
+
movable(els: GridStackElement, val: boolean): GridStack;
|
|
695
|
+
/**
|
|
696
|
+
* Enables/Disables user resizing for specific grid elements.
|
|
697
|
+
* For all items and future items, use enableResize() instead. No-op for static grids.
|
|
698
|
+
*
|
|
699
|
+
* @param els widget element(s) or selector to modify
|
|
700
|
+
* @param val if true widget will be resizable, assuming the parent grid isn't noResize or static
|
|
701
|
+
* @returns the grid instance for chaining
|
|
702
|
+
*
|
|
703
|
+
* @example
|
|
704
|
+
* // Make specific widgets resizable
|
|
705
|
+
* grid.resizable('.my-widget', true);
|
|
706
|
+
*
|
|
707
|
+
* // Disable resizing for specific widgets
|
|
708
|
+
* grid.resizable('#fixed-size-widget', false);
|
|
709
|
+
*/
|
|
710
|
+
resizable(els: GridStackElement, val: boolean): GridStack;
|
|
711
|
+
/**
|
|
712
|
+
* Temporarily disables widgets moving/resizing.
|
|
713
|
+
* If you want a more permanent way (which freezes up resources) use `setStatic(true)` instead.
|
|
714
|
+
*
|
|
715
|
+
* Note: This is a no-op for static grids.
|
|
716
|
+
*
|
|
717
|
+
* This is a shortcut for:
|
|
718
|
+
* ```typescript
|
|
719
|
+
* grid.enableMove(false);
|
|
720
|
+
* grid.enableResize(false);
|
|
721
|
+
* ```
|
|
722
|
+
*
|
|
723
|
+
* @param recurse if true (default), sub-grids also get updated
|
|
724
|
+
* @returns the grid instance for chaining
|
|
725
|
+
*
|
|
726
|
+
* @example
|
|
727
|
+
* // Disable all interactions
|
|
728
|
+
* grid.disable();
|
|
729
|
+
*
|
|
730
|
+
* // Disable only this grid, not sub-grids
|
|
731
|
+
* grid.disable(false);
|
|
732
|
+
*/
|
|
733
|
+
disable(recurse?: boolean): GridStack;
|
|
734
|
+
/**
|
|
735
|
+
* Re-enables widgets moving/resizing - see disable().
|
|
736
|
+
* Note: This is a no-op for static grids.
|
|
737
|
+
*
|
|
738
|
+
* This is a shortcut for:
|
|
739
|
+
* ```typescript
|
|
740
|
+
* grid.enableMove(true);
|
|
741
|
+
* grid.enableResize(true);
|
|
742
|
+
* ```
|
|
743
|
+
*
|
|
744
|
+
* @param recurse if true (default), sub-grids also get updated
|
|
745
|
+
* @returns the grid instance for chaining
|
|
746
|
+
*
|
|
747
|
+
* @example
|
|
748
|
+
* // Re-enable all interactions
|
|
749
|
+
* grid.enable();
|
|
750
|
+
*
|
|
751
|
+
* // Enable only this grid, not sub-grids
|
|
752
|
+
* grid.enable(false);
|
|
753
|
+
*/
|
|
754
|
+
enable(recurse?: boolean): GridStack;
|
|
755
|
+
/**
|
|
756
|
+
* Enables/disables widget moving for all widgets. No-op for static grids.
|
|
757
|
+
* Note: locally defined items (with noMove property) still override this setting.
|
|
758
|
+
*
|
|
759
|
+
* @param doEnable if true widgets will be movable, if false moving is disabled
|
|
760
|
+
* @param recurse if true (default), sub-grids also get updated
|
|
761
|
+
* @returns the grid instance for chaining
|
|
762
|
+
*
|
|
763
|
+
* @example
|
|
764
|
+
* // Enable moving for all widgets
|
|
765
|
+
* grid.enableMove(true);
|
|
766
|
+
*
|
|
767
|
+
* // Disable moving for all widgets
|
|
768
|
+
* grid.enableMove(false);
|
|
769
|
+
*
|
|
770
|
+
* // Enable only this grid, not sub-grids
|
|
771
|
+
* grid.enableMove(true, false);
|
|
772
|
+
*/
|
|
773
|
+
enableMove(doEnable: boolean, recurse?: boolean): GridStack;
|
|
774
|
+
/**
|
|
775
|
+
* Enables/disables widget resizing for all widgets. No-op for static grids.
|
|
776
|
+
* Note: locally defined items (with noResize property) still override this setting.
|
|
777
|
+
*
|
|
778
|
+
* @param doEnable if true widgets will be resizable, if false resizing is disabled
|
|
779
|
+
* @param recurse if true (default), sub-grids also get updated
|
|
780
|
+
* @returns the grid instance for chaining
|
|
781
|
+
*
|
|
782
|
+
* @example
|
|
783
|
+
* // Enable resizing for all widgets
|
|
784
|
+
* grid.enableResize(true);
|
|
785
|
+
*
|
|
786
|
+
* // Disable resizing for all widgets
|
|
787
|
+
* grid.enableResize(false);
|
|
788
|
+
*
|
|
789
|
+
* // Enable only this grid, not sub-grids
|
|
790
|
+
* grid.enableResize(true, false);
|
|
791
|
+
*/
|
|
792
|
+
enableResize(doEnable: boolean, recurse?: boolean): GridStack;
|
|
793
|
+
/**
|
|
794
|
+
* prepares the element for drag&drop - this is normally called by makeWidget() unless are are delay loading
|
|
795
|
+
* @param el GridItemHTMLElement of the widget
|
|
796
|
+
* @param [force=false]
|
|
797
|
+
* */
|
|
798
|
+
prepareDragDrop(el: GridItemHTMLElement, force?: boolean): GridStack;
|
|
799
|
+
/** call given event callback on our main top-most grid (if we're nested) */
|
|
800
|
+
protected triggerEvent(event: Event, target: GridItemHTMLElement): void;
|
|
801
|
+
commit(): GridStack;
|
|
802
|
+
}
|