4
4
*/
5
5
6
6
import {
7
- AfterContentInit , Component , ContentChildren , ElementRef , EventEmitter , Input ,
8
- OnDestroy , OnInit , Output , QueryList , Type , ViewChild , ViewContainerRef , reflectComponentType , ComponentRef
7
+ AfterContentInit , Component , ContentChildren , ElementRef , EventEmitter , Input ,
8
+ OnDestroy , OnInit , Output , QueryList , Type , ViewChild , ViewContainerRef , reflectComponentType , ComponentRef
9
9
} from '@angular/core' ;
10
10
import { NgIf } from '@angular/common' ;
11
11
import { Subscription } from 'rxjs' ;
@@ -45,19 +45,19 @@ export interface GridCompHTMLElement extends GridHTMLElement {
45
45
* Mapping of selector strings to Angular component types.
46
46
* Used for dynamic component creation based on widget selectors.
47
47
*/
48
- export type SelectorToType = { [ key : string ] : Type < Object > } ;
48
+ export type SelectorToType = { [ key : string ] : Type < object > } ;
49
49
50
50
/**
51
51
* Angular component wrapper for GridStack.
52
- *
52
+ *
53
53
* This component provides Angular integration for GridStack grids, handling:
54
54
* - Grid initialization and lifecycle
55
55
* - Dynamic component creation and management
56
56
* - Event binding and emission
57
57
* - Integration with Angular change detection
58
- *
58
+ *
59
59
* Use in combination with GridstackItemComponent for individual grid items.
60
- *
60
+ *
61
61
* @example
62
62
* ```html
63
63
* <gridstack [options]="gridOptions" (change)="onGridChange($event)">
@@ -99,7 +99,7 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
99
99
/**
100
100
* Grid configuration options.
101
101
* Can be set before grid initialization or updated after grid is created.
102
- *
102
+ *
103
103
* @example
104
104
* ```typescript
105
105
* gridOptions: GridStackOptions = {
@@ -122,7 +122,7 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
122
122
/**
123
123
* Controls whether empty content should be displayed.
124
124
* Set to true to show ng-content with 'empty-content' selector when grid has no items.
125
- *
125
+ *
126
126
* @example
127
127
* ```html
128
128
* <gridstack [isEmpty]="gridItems.length === 0">
@@ -134,52 +134,52 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
134
134
135
135
/**
136
136
* GridStack event emitters for Angular integration.
137
- *
137
+ *
138
138
* These provide Angular-style event handling for GridStack events.
139
139
* Alternatively, use `this.grid.on('event1 event2', callback)` for multiple events.
140
- *
140
+ *
141
141
* Note: 'CB' suffix prevents conflicts with native DOM events.
142
- *
142
+ *
143
143
* @example
144
144
* ```html
145
145
* <gridstack (changeCB)="onGridChange($event)" (droppedCB)="onItemDropped($event)">
146
146
* </gridstack>
147
147
* ```
148
148
*/
149
-
149
+
150
150
/** Emitted when widgets are added to the grid */
151
151
@Output ( ) public addedCB = new EventEmitter < nodesCB > ( ) ;
152
-
152
+
153
153
/** Emitted when grid layout changes */
154
154
@Output ( ) public changeCB = new EventEmitter < nodesCB > ( ) ;
155
-
155
+
156
156
/** Emitted when grid is disabled */
157
157
@Output ( ) public disableCB = new EventEmitter < eventCB > ( ) ;
158
-
158
+
159
159
/** Emitted during widget drag operations */
160
160
@Output ( ) public dragCB = new EventEmitter < elementCB > ( ) ;
161
-
161
+
162
162
/** Emitted when widget drag starts */
163
163
@Output ( ) public dragStartCB = new EventEmitter < elementCB > ( ) ;
164
-
164
+
165
165
/** Emitted when widget drag stops */
166
166
@Output ( ) public dragStopCB = new EventEmitter < elementCB > ( ) ;
167
-
167
+
168
168
/** Emitted when widget is dropped */
169
169
@Output ( ) public droppedCB = new EventEmitter < droppedCB > ( ) ;
170
-
170
+
171
171
/** Emitted when grid is enabled */
172
172
@Output ( ) public enableCB = new EventEmitter < eventCB > ( ) ;
173
-
173
+
174
174
/** Emitted when widgets are removed from the grid */
175
175
@Output ( ) public removedCB = new EventEmitter < nodesCB > ( ) ;
176
-
176
+
177
177
/** Emitted during widget resize operations */
178
178
@Output ( ) public resizeCB = new EventEmitter < elementCB > ( ) ;
179
-
179
+
180
180
/** Emitted when widget resize starts */
181
181
@Output ( ) public resizeStartCB = new EventEmitter < elementCB > ( ) ;
182
-
182
+
183
183
/** Emitted when widget resize stops */
184
184
@Output ( ) public resizeStopCB = new EventEmitter < elementCB > ( ) ;
185
185
@@ -192,7 +192,7 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
192
192
/**
193
193
* Get the underlying GridStack instance.
194
194
* Use this to access GridStack API methods directly.
195
- *
195
+ *
196
196
* @example
197
197
* ```typescript
198
198
* this.gridComponent.grid.addWidget({x: 0, y: 0, w: 2, h: 1});
@@ -208,10 +208,10 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
208
208
209
209
/**
210
210
* Mapping of component selectors to their types for dynamic creation.
211
- *
211
+ *
212
212
* This enables dynamic component instantiation from string selectors.
213
213
* Angular doesn't provide public access to this mapping, so we maintain our own.
214
- *
214
+ *
215
215
* @example
216
216
* ```typescript
217
217
* GridstackComponent.addComponentToSelectorType([MyWidgetComponent]);
@@ -220,9 +220,9 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
220
220
public static selectorToType : SelectorToType = { } ;
221
221
/**
222
222
* Register a list of Angular components for dynamic creation.
223
- *
223
+ *
224
224
* @param typeList Array of component types to register
225
- *
225
+ *
226
226
* @example
227
227
* ```typescript
228
228
* GridstackComponent.addComponentToSelectorType([
@@ -231,16 +231,17 @@ export class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
231
231
* ]);
232
232
* ```
233
233
*/
234
- public static addComponentToSelectorType ( typeList : Array < Type < Object > > ) {
234
+ public static addComponentToSelectorType ( typeList : Array < Type < object > > ) {
235
235
typeList . forEach ( type => GridstackComponent . selectorToType [ GridstackComponent . getSelector ( type ) ] = type ) ;
236
236
}
237
237
/**
238
238
* Extract the selector string from an Angular component type.
239
- *
239
+ *
240
240
* @param type The component type to get selector from
241
241
* @returns The component's selector string
242
242
*/
243
- public static getSelector ( type : Type < Object > ) : string {
243
+ public static getSelector ( type : Type < object > ) : string {
244
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
244
245
return reflectComponentType ( type ) ! . selector ;
245
246
}
246
247
@@ -367,6 +368,7 @@ export function gsCreateNgComponents(host: GridCompHTMLElement | HTMLElement, n:
367
368
const gridItemComp = ( host . parentElement as GridItemCompHTMLElement ) ?. _gridItemComp ;
368
369
if ( ! gridItemComp ) return ;
369
370
// check if gridItem has a child component with 'container' exposed to create under..
371
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
370
372
const container = ( gridItemComp . childWidget as any ) ?. container || gridItemComp . container ;
371
373
const gridRef = container ?. createComponent ( GridstackComponent ) ;
372
374
const grid = gridRef ?. instance ;
0 commit comments