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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* gridstack.component.ts 12.
|
|
2
|
+
* gridstack.component.ts 12.3.0
|
|
3
3
|
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -15,22 +15,55 @@ import { NgGridStackNode, NgGridStackWidget } from './types';
|
|
|
15
15
|
import { BaseWidget } from './base-widget';
|
|
16
16
|
import { GridItemCompHTMLElement, GridstackItemComponent } from './gridstack-item.component';
|
|
17
17
|
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Event handler callback signatures for different GridStack events.
|
|
20
|
+
* These types define the structure of data passed to Angular event emitters.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/** Callback for general events (enable, disable, etc.) */
|
|
19
24
|
export type eventCB = {event: Event};
|
|
25
|
+
|
|
26
|
+
/** Callback for element-specific events (resize, drag, etc.) */
|
|
20
27
|
export type elementCB = {event: Event, el: GridItemHTMLElement};
|
|
28
|
+
|
|
29
|
+
/** Callback for events affecting multiple nodes (change, etc.) */
|
|
21
30
|
export type nodesCB = {event: Event, nodes: GridStackNode[]};
|
|
31
|
+
|
|
32
|
+
/** Callback for drop events with before/after node state */
|
|
22
33
|
export type droppedCB = {event: Event, previousNode: GridStackNode, newNode: GridStackNode};
|
|
23
34
|
|
|
24
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Extended HTMLElement interface for the grid container.
|
|
37
|
+
* Stores a back-reference to the Angular component for integration purposes.
|
|
38
|
+
*/
|
|
25
39
|
export interface GridCompHTMLElement extends GridHTMLElement {
|
|
40
|
+
/** Back-reference to the Angular GridStack component */
|
|
26
41
|
_gridComp?: GridstackComponent;
|
|
27
42
|
}
|
|
28
43
|
|
|
29
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* Mapping of selector strings to Angular component types.
|
|
46
|
+
* Used for dynamic component creation based on widget selectors.
|
|
47
|
+
*/
|
|
30
48
|
export type SelectorToType = {[key: string]: Type<Object>};
|
|
31
49
|
|
|
32
50
|
/**
|
|
33
|
-
*
|
|
51
|
+
* Angular component wrapper for GridStack.
|
|
52
|
+
*
|
|
53
|
+
* This component provides Angular integration for GridStack grids, handling:
|
|
54
|
+
* - Grid initialization and lifecycle
|
|
55
|
+
* - Dynamic component creation and management
|
|
56
|
+
* - Event binding and emission
|
|
57
|
+
* - Integration with Angular change detection
|
|
58
|
+
*
|
|
59
|
+
* Use in combination with GridstackItemComponent for individual grid items.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```html
|
|
63
|
+
* <gridstack [options]="gridOptions" (change)="onGridChange($event)">
|
|
64
|
+
* <div empty-content>Drag widgets here</div>
|
|
65
|
+
* </gridstack>
|
|
66
|
+
* ```
|
|
34
67
|
*/
|
|
35
68
|
@Component({
|
|
36
69
|
selector: 'gridstack',
|
|
@@ -51,12 +84,31 @@ export type SelectorToType = {[key: string]: Type<Object>};
|
|
|
51
84
|
})
|
|
52
85
|
export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
|
|
53
86
|
|
|
54
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* List of template-based grid items (not recommended approach).
|
|
89
|
+
* Used to sync between DOM and GridStack internals when items are defined in templates.
|
|
90
|
+
* Prefer dynamic component creation instead.
|
|
91
|
+
*/
|
|
55
92
|
@ContentChildren(GridstackItemComponent) public gridstackItems?: QueryList<GridstackItemComponent>;
|
|
56
|
-
/**
|
|
93
|
+
/**
|
|
94
|
+
* Container for dynamic component creation (recommended approach).
|
|
95
|
+
* Used to append grid items programmatically at runtime.
|
|
96
|
+
*/
|
|
57
97
|
@ViewChild('container', { read: ViewContainerRef, static: true}) public container?: ViewContainerRef;
|
|
58
98
|
|
|
59
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Grid configuration options.
|
|
101
|
+
* Can be set before grid initialization or updated after grid is created.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* gridOptions: GridStackOptions = {
|
|
106
|
+
* column: 12,
|
|
107
|
+
* cellHeight: 'auto',
|
|
108
|
+
* animate: true
|
|
109
|
+
* };
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
60
112
|
@Input() public set options(o: GridStackOptions) {
|
|
61
113
|
if (this._grid) {
|
|
62
114
|
this._grid.updateOptions(o);
|
|
@@ -64,51 +116,130 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
|
|
|
64
116
|
this._options = o;
|
|
65
117
|
}
|
|
66
118
|
}
|
|
67
|
-
/**
|
|
119
|
+
/** Get the current running grid options */
|
|
68
120
|
public get options(): GridStackOptions { return this._grid?.opts || this._options || {}; }
|
|
69
121
|
|
|
70
|
-
/**
|
|
122
|
+
/**
|
|
123
|
+
* Controls whether empty content should be displayed.
|
|
124
|
+
* Set to true to show ng-content with 'empty-content' selector when grid has no items.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```html
|
|
128
|
+
* <gridstack [isEmpty]="gridItems.length === 0">
|
|
129
|
+
* <div empty-content>Drag widgets here to get started</div>
|
|
130
|
+
* </gridstack>
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
71
133
|
@Input() public isEmpty?: boolean;
|
|
72
134
|
|
|
73
|
-
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
135
|
+
/**
|
|
136
|
+
* GridStack event emitters for Angular integration.
|
|
137
|
+
*
|
|
138
|
+
* These provide Angular-style event handling for GridStack events.
|
|
139
|
+
* Alternatively, use `this.grid.on('event1 event2', callback)` for multiple events.
|
|
140
|
+
*
|
|
141
|
+
* Note: 'CB' suffix prevents conflicts with native DOM events.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```html
|
|
145
|
+
* <gridstack (changeCB)="onGridChange($event)" (droppedCB)="onItemDropped($event)">
|
|
146
|
+
* </gridstack>
|
|
147
|
+
* ```
|
|
79
148
|
*/
|
|
149
|
+
|
|
150
|
+
/** Emitted when widgets are added to the grid */
|
|
80
151
|
@Output() public addedCB = new EventEmitter<nodesCB>();
|
|
152
|
+
|
|
153
|
+
/** Emitted when grid layout changes */
|
|
81
154
|
@Output() public changeCB = new EventEmitter<nodesCB>();
|
|
155
|
+
|
|
156
|
+
/** Emitted when grid is disabled */
|
|
82
157
|
@Output() public disableCB = new EventEmitter<eventCB>();
|
|
158
|
+
|
|
159
|
+
/** Emitted during widget drag operations */
|
|
83
160
|
@Output() public dragCB = new EventEmitter<elementCB>();
|
|
161
|
+
|
|
162
|
+
/** Emitted when widget drag starts */
|
|
84
163
|
@Output() public dragStartCB = new EventEmitter<elementCB>();
|
|
164
|
+
|
|
165
|
+
/** Emitted when widget drag stops */
|
|
85
166
|
@Output() public dragStopCB = new EventEmitter<elementCB>();
|
|
167
|
+
|
|
168
|
+
/** Emitted when widget is dropped */
|
|
86
169
|
@Output() public droppedCB = new EventEmitter<droppedCB>();
|
|
170
|
+
|
|
171
|
+
/** Emitted when grid is enabled */
|
|
87
172
|
@Output() public enableCB = new EventEmitter<eventCB>();
|
|
173
|
+
|
|
174
|
+
/** Emitted when widgets are removed from the grid */
|
|
88
175
|
@Output() public removedCB = new EventEmitter<nodesCB>();
|
|
176
|
+
|
|
177
|
+
/** Emitted during widget resize operations */
|
|
89
178
|
@Output() public resizeCB = new EventEmitter<elementCB>();
|
|
179
|
+
|
|
180
|
+
/** Emitted when widget resize starts */
|
|
90
181
|
@Output() public resizeStartCB = new EventEmitter<elementCB>();
|
|
182
|
+
|
|
183
|
+
/** Emitted when widget resize stops */
|
|
91
184
|
@Output() public resizeStopCB = new EventEmitter<elementCB>();
|
|
92
185
|
|
|
93
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* Get the native DOM element that contains grid-specific fields.
|
|
188
|
+
* This element has GridStack properties attached to it.
|
|
189
|
+
*/
|
|
94
190
|
public get el(): GridCompHTMLElement { return this.elementRef.nativeElement; }
|
|
95
191
|
|
|
96
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* Get the underlying GridStack instance.
|
|
194
|
+
* Use this to access GridStack API methods directly.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* this.gridComponent.grid.addWidget({x: 0, y: 0, w: 2, h: 1});
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
97
201
|
public get grid(): GridStack | undefined { return this._grid; }
|
|
98
202
|
|
|
99
|
-
/**
|
|
203
|
+
/**
|
|
204
|
+
* Component reference for dynamic component removal.
|
|
205
|
+
* Used internally when this component is created dynamically.
|
|
206
|
+
*/
|
|
100
207
|
public ref: ComponentRef<GridstackComponent> | undefined;
|
|
101
208
|
|
|
102
209
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
210
|
+
* Mapping of component selectors to their types for dynamic creation.
|
|
211
|
+
*
|
|
212
|
+
* This enables dynamic component instantiation from string selectors.
|
|
213
|
+
* Angular doesn't provide public access to this mapping, so we maintain our own.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* ```typescript
|
|
217
|
+
* GridstackComponent.addComponentToSelectorType([MyWidgetComponent]);
|
|
218
|
+
* ```
|
|
105
219
|
*/
|
|
106
220
|
public static selectorToType: SelectorToType = {};
|
|
107
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Register a list of Angular components for dynamic creation.
|
|
223
|
+
*
|
|
224
|
+
* @param typeList Array of component types to register
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* GridstackComponent.addComponentToSelectorType([
|
|
229
|
+
* MyWidgetComponent,
|
|
230
|
+
* AnotherWidgetComponent
|
|
231
|
+
* ]);
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
108
234
|
public static addComponentToSelectorType(typeList: Array<Type<Object>>) {
|
|
109
235
|
typeList.forEach(type => GridstackComponent.selectorToType[ GridstackComponent.getSelector(type) ] = type);
|
|
110
236
|
}
|
|
111
|
-
/**
|
|
237
|
+
/**
|
|
238
|
+
* Extract the selector string from an Angular component type.
|
|
239
|
+
*
|
|
240
|
+
* @param type The component type to get selector from
|
|
241
|
+
* @returns The component's selector string
|
|
242
|
+
*/
|
|
112
243
|
public static getSelector(type: Type<Object>): string {
|
|
113
244
|
return reflectComponentType(type)!.selector;
|
|
114
245
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* gridstack.component.ts 12.
|
|
2
|
+
* gridstack.component.ts 12.3.0
|
|
3
3
|
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -8,7 +8,29 @@ import { NgModule } from "@angular/core";
|
|
|
8
8
|
import { GridstackItemComponent } from "./gridstack-item.component";
|
|
9
9
|
import { GridstackComponent } from "./gridstack.component";
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use GridstackComponent and GridstackItemComponent as standalone components instead.
|
|
13
|
+
*
|
|
14
|
+
* This NgModule is provided for backward compatibility but is no longer the recommended approach.
|
|
15
|
+
* Import components directly in your standalone components or use the new Angular module structure.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Preferred approach - standalone components
|
|
20
|
+
* @Component({
|
|
21
|
+
* selector: 'my-app',
|
|
22
|
+
* imports: [GridstackComponent, GridstackItemComponent],
|
|
23
|
+
* template: '<gridstack></gridstack>'
|
|
24
|
+
* })
|
|
25
|
+
* export class AppComponent {}
|
|
26
|
+
*
|
|
27
|
+
* // Legacy approach (deprecated)
|
|
28
|
+
* @NgModule({
|
|
29
|
+
* imports: [GridstackModule]
|
|
30
|
+
* })
|
|
31
|
+
* export class AppModule {}
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
12
34
|
@NgModule({
|
|
13
35
|
imports: [
|
|
14
36
|
GridstackItemComponent,
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gridstack-item.component.ts 12.3.0
|
|
3
|
+
* Copyright (c) 2025 Alain Dumesny - see GridStack root license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { GridStackNode, GridStackOptions, GridStackWidget } from "gridstack";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Extended GridStackWidget interface for Angular integration.
|
|
10
|
+
* Adds Angular-specific properties for dynamic component creation.
|
|
11
|
+
*/
|
|
12
|
+
export interface NgGridStackWidget extends GridStackWidget {
|
|
13
|
+
/** Angular component selector for dynamic creation (e.g., 'my-widget') */
|
|
14
|
+
selector?: string;
|
|
15
|
+
/** Serialized data for component @Input() properties */
|
|
16
|
+
input?: NgCompInputs;
|
|
17
|
+
/** Configuration for nested sub-grids */
|
|
18
|
+
subGridOpts?: NgGridStackOptions;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Extended GridStackNode interface for Angular integration.
|
|
23
|
+
* Adds component selector for dynamic content creation.
|
|
24
|
+
*/
|
|
25
|
+
export interface NgGridStackNode extends GridStackNode {
|
|
26
|
+
/** Angular component selector for this node's content */
|
|
27
|
+
selector?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Extended GridStackOptions interface for Angular integration.
|
|
32
|
+
* Supports Angular-specific widget definitions and nested grids.
|
|
33
|
+
*/
|
|
34
|
+
export interface NgGridStackOptions extends GridStackOptions {
|
|
35
|
+
/** Array of Angular widget definitions for initial grid setup */
|
|
36
|
+
children?: NgGridStackWidget[];
|
|
37
|
+
/** Configuration for nested sub-grids (Angular-aware) */
|
|
38
|
+
subGridOpts?: NgGridStackOptions;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Type for component input data serialization.
|
|
43
|
+
* Maps @Input() property names to their values for widget persistence.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* const inputs: NgCompInputs = {
|
|
48
|
+
* title: 'My Widget',
|
|
49
|
+
* value: 42,
|
|
50
|
+
* config: { enabled: true }
|
|
51
|
+
* };
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export type NgCompInputs = {[key: string]: any};
|
package/dist/dd-base-impl.d.ts
CHANGED
|
@@ -1,20 +1,69 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dd-base-impl.ts 12.
|
|
3
|
-
* Copyright (c) 2021-
|
|
2
|
+
* dd-base-impl.ts 12.3.0
|
|
3
|
+
* Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Type for event callback functions used in drag & drop operations.
|
|
7
|
+
* Can return boolean to indicate if the event should continue propagation.
|
|
4
8
|
*/
|
|
5
9
|
export type EventCallback = (event: Event) => boolean | void;
|
|
10
|
+
/**
|
|
11
|
+
* Abstract base class for all drag & drop implementations.
|
|
12
|
+
* Provides common functionality for event handling, enable/disable state,
|
|
13
|
+
* and lifecycle management used by draggable, droppable, and resizable implementations.
|
|
14
|
+
*/
|
|
6
15
|
export declare abstract class DDBaseImplement {
|
|
7
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Returns the current disabled state.
|
|
18
|
+
* Note: Use enable()/disable() methods to change state as other operations need to happen.
|
|
19
|
+
*/
|
|
8
20
|
get disabled(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Register an event callback for the specified event.
|
|
23
|
+
*
|
|
24
|
+
* @param event - Event name to listen for
|
|
25
|
+
* @param callback - Function to call when event occurs
|
|
26
|
+
*/
|
|
9
27
|
on(event: string, callback: EventCallback): void;
|
|
28
|
+
/**
|
|
29
|
+
* Unregister an event callback for the specified event.
|
|
30
|
+
*
|
|
31
|
+
* @param event - Event name to stop listening for
|
|
32
|
+
*/
|
|
10
33
|
off(event: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* Enable this drag & drop implementation.
|
|
36
|
+
* Subclasses should override to perform additional setup.
|
|
37
|
+
*/
|
|
11
38
|
enable(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Disable this drag & drop implementation.
|
|
41
|
+
* Subclasses should override to perform additional cleanup.
|
|
42
|
+
*/
|
|
12
43
|
disable(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Destroy this drag & drop implementation and clean up resources.
|
|
46
|
+
* Removes all event handlers and clears internal state.
|
|
47
|
+
*/
|
|
13
48
|
destroy(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Trigger a registered event callback if one exists and the implementation is enabled.
|
|
51
|
+
*
|
|
52
|
+
* @param eventName - Name of the event to trigger
|
|
53
|
+
* @param event - DOM event object to pass to the callback
|
|
54
|
+
* @returns Result from the callback function, if any
|
|
55
|
+
*/
|
|
14
56
|
triggerEvent(eventName: string, event: Event): boolean | void;
|
|
15
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Interface for HTML elements extended with drag & drop options.
|
|
60
|
+
* Used to associate DD configuration with DOM elements.
|
|
61
|
+
*/
|
|
16
62
|
export interface HTMLElementExtendOpt<T> {
|
|
63
|
+
/** The HTML element being extended */
|
|
17
64
|
el: HTMLElement;
|
|
65
|
+
/** The drag & drop options/configuration */
|
|
18
66
|
option: T;
|
|
67
|
+
/** Method to update the options and return the DD implementation */
|
|
19
68
|
updateOption(T: any): DDBaseImplement;
|
|
20
69
|
}
|
package/dist/dd-base-impl.js
CHANGED
|
@@ -1,29 +1,67 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dd-base-impl.ts 12.
|
|
3
|
-
* Copyright (c) 2021-
|
|
2
|
+
* dd-base-impl.ts 12.3.0
|
|
3
|
+
* Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Abstract base class for all drag & drop implementations.
|
|
7
|
+
* Provides common functionality for event handling, enable/disable state,
|
|
8
|
+
* and lifecycle management used by draggable, droppable, and resizable implementations.
|
|
4
9
|
*/
|
|
5
10
|
export class DDBaseImplement {
|
|
6
11
|
constructor() {
|
|
7
12
|
/** @internal */
|
|
8
13
|
this._eventRegister = {};
|
|
9
14
|
}
|
|
10
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current disabled state.
|
|
17
|
+
* Note: Use enable()/disable() methods to change state as other operations need to happen.
|
|
18
|
+
*/
|
|
11
19
|
get disabled() { return this._disabled; }
|
|
20
|
+
/**
|
|
21
|
+
* Register an event callback for the specified event.
|
|
22
|
+
*
|
|
23
|
+
* @param event - Event name to listen for
|
|
24
|
+
* @param callback - Function to call when event occurs
|
|
25
|
+
*/
|
|
12
26
|
on(event, callback) {
|
|
13
27
|
this._eventRegister[event] = callback;
|
|
14
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Unregister an event callback for the specified event.
|
|
31
|
+
*
|
|
32
|
+
* @param event - Event name to stop listening for
|
|
33
|
+
*/
|
|
15
34
|
off(event) {
|
|
16
35
|
delete this._eventRegister[event];
|
|
17
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Enable this drag & drop implementation.
|
|
39
|
+
* Subclasses should override to perform additional setup.
|
|
40
|
+
*/
|
|
18
41
|
enable() {
|
|
19
42
|
this._disabled = false;
|
|
20
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Disable this drag & drop implementation.
|
|
46
|
+
* Subclasses should override to perform additional cleanup.
|
|
47
|
+
*/
|
|
21
48
|
disable() {
|
|
22
49
|
this._disabled = true;
|
|
23
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Destroy this drag & drop implementation and clean up resources.
|
|
53
|
+
* Removes all event handlers and clears internal state.
|
|
54
|
+
*/
|
|
24
55
|
destroy() {
|
|
25
56
|
delete this._eventRegister;
|
|
26
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Trigger a registered event callback if one exists and the implementation is enabled.
|
|
60
|
+
*
|
|
61
|
+
* @param eventName - Name of the event to trigger
|
|
62
|
+
* @param event - DOM event object to pass to the callback
|
|
63
|
+
* @returns Result from the callback function, if any
|
|
64
|
+
*/
|
|
27
65
|
triggerEvent(eventName, event) {
|
|
28
66
|
if (!this.disabled && this._eventRegister && this._eventRegister[eventName])
|
|
29
67
|
return this._eventRegister[eventName](event);
|
package/dist/dd-base-impl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dd-base-impl.js","sourceRoot":"","sources":["../src/dd-base-impl.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"dd-base-impl.js","sourceRoot":"","sources":["../src/dd-base-impl.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH;;;;GAIG;AACH,MAAM,OAAgB,eAAe;IAArC;QASE,gBAAgB;QACN,mBAAc,GAEpB,EAAE,CAAC;IAwDT,CAAC;IAnEC;;;OAGG;IACH,IAAW,QAAQ,KAAgB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAS3D;;;;;OAKG;IACI,EAAE,CAAC,KAAa,EAAE,QAAuB;QAC9C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACI,GAAG,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,MAAM;QACX,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAED;;;OAGG;IACI,OAAO;QACZ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED;;;OAGG;IACI,OAAO;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED;;;;;;OAMG;IACI,YAAY,CAAC,SAAiB,EAAE,KAAY;QACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;YACzE,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF","sourcesContent":["/**\n * dd-base-impl.ts 12.3.0\n * Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license\n */\n\n/**\n * Type for event callback functions used in drag & drop operations.\n * Can return boolean to indicate if the event should continue propagation.\n */\nexport type EventCallback = (event: Event) => boolean|void;\n\n/**\n * Abstract base class for all drag & drop implementations.\n * Provides common functionality for event handling, enable/disable state,\n * and lifecycle management used by draggable, droppable, and resizable implementations.\n */\nexport abstract class DDBaseImplement {\n /**\n * Returns the current disabled state.\n * Note: Use enable()/disable() methods to change state as other operations need to happen.\n */\n public get disabled(): boolean { return this._disabled; }\n\n /** @internal */\n protected _disabled: boolean; // initial state to differentiate from false\n /** @internal */\n protected _eventRegister: {\n [eventName: string]: EventCallback;\n } = {};\n\n /**\n * Register an event callback for the specified event.\n * \n * @param event - Event name to listen for\n * @param callback - Function to call when event occurs\n */\n public on(event: string, callback: EventCallback): void {\n this._eventRegister[event] = callback;\n }\n\n /**\n * Unregister an event callback for the specified event.\n * \n * @param event - Event name to stop listening for\n */\n public off(event: string): void {\n delete this._eventRegister[event];\n }\n\n /**\n * Enable this drag & drop implementation.\n * Subclasses should override to perform additional setup.\n */\n public enable(): void {\n this._disabled = false;\n }\n\n /**\n * Disable this drag & drop implementation.\n * Subclasses should override to perform additional cleanup.\n */\n public disable(): void {\n this._disabled = true;\n }\n\n /**\n * Destroy this drag & drop implementation and clean up resources.\n * Removes all event handlers and clears internal state.\n */\n public destroy(): void {\n delete this._eventRegister;\n }\n\n /**\n * Trigger a registered event callback if one exists and the implementation is enabled.\n * \n * @param eventName - Name of the event to trigger\n * @param event - DOM event object to pass to the callback\n * @returns Result from the callback function, if any\n */\n public triggerEvent(eventName: string, event: Event): boolean|void {\n if (!this.disabled && this._eventRegister && this._eventRegister[eventName])\n return this._eventRegister[eventName](event);\n }\n}\n\n/**\n * Interface for HTML elements extended with drag & drop options.\n * Used to associate DD configuration with DOM elements.\n */\nexport interface HTMLElementExtendOpt<T> {\n /** The HTML element being extended */\n el: HTMLElement;\n /** The drag & drop options/configuration */\n option: T;\n /** Method to update the options and return the DD implementation */\n updateOption(T): DDBaseImplement;\n}\n"]}
|
package/dist/dd-draggable.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dd-draggable.ts 12.
|
|
3
|
-
* Copyright (c) 2021-
|
|
2
|
+
* dd-draggable.ts 12.3.0
|
|
3
|
+
* Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
import { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';
|
|
6
6
|
import { GridItemHTMLElement, DDDragOpt } from './types';
|
package/dist/dd-draggable.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dd-draggable.ts 12.
|
|
3
|
-
* Copyright (c) 2021-
|
|
2
|
+
* dd-draggable.ts 12.3.0
|
|
3
|
+
* Copyright (c) 2021-2025 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
import { DDManager } from './dd-manager';
|
|
6
6
|
import { Utils } from './utils';
|
|
@@ -260,6 +260,7 @@ class DDDraggable extends DDBaseImplement {
|
|
|
260
260
|
/** @internal set the fix position of the dragged item */
|
|
261
261
|
_setupHelperStyle(e) {
|
|
262
262
|
this.helper.classList.add('ui-draggable-dragging');
|
|
263
|
+
this.el.gridstackNode?.grid?.el.classList.add('grid-stack-dragging');
|
|
263
264
|
// TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593
|
|
264
265
|
const style = this.helper.style;
|
|
265
266
|
style.pointerEvents = 'none'; // needed for over items to get enter/leave
|
|
@@ -280,6 +281,7 @@ class DDDraggable extends DDBaseImplement {
|
|
|
280
281
|
/** @internal restore back the original style before dragging */
|
|
281
282
|
_removeHelperStyle() {
|
|
282
283
|
this.helper.classList.remove('ui-draggable-dragging');
|
|
284
|
+
this.el.gridstackNode?.grid?.el.classList.remove('grid-stack-dragging');
|
|
283
285
|
const node = this.helper?.gridstackNode;
|
|
284
286
|
// don't bother restoring styles if we're gonna remove anyway...
|
|
285
287
|
if (!node?._isAboutToRemove && this.dragElementOriginStyle) {
|