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
|
import { AfterContentInit, ElementRef, EventEmitter, OnDestroy, OnInit, QueryList, Type, ViewContainerRef, ComponentRef } from '@angular/core';
|
|
@@ -8,79 +8,194 @@ import { GridHTMLElement, GridItemHTMLElement, GridStack, GridStackNode, GridSta
|
|
|
8
8
|
import { NgGridStackNode, NgGridStackWidget } from './types';
|
|
9
9
|
import { GridstackItemComponent } from './gridstack-item.component';
|
|
10
10
|
import * as i0 from "@angular/core";
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Event handler callback signatures for different GridStack events.
|
|
13
|
+
* These types define the structure of data passed to Angular event emitters.
|
|
14
|
+
*/
|
|
15
|
+
/** Callback for general events (enable, disable, etc.) */
|
|
12
16
|
export declare type eventCB = {
|
|
13
17
|
event: Event;
|
|
14
18
|
};
|
|
19
|
+
/** Callback for element-specific events (resize, drag, etc.) */
|
|
15
20
|
export declare type elementCB = {
|
|
16
21
|
event: Event;
|
|
17
22
|
el: GridItemHTMLElement;
|
|
18
23
|
};
|
|
24
|
+
/** Callback for events affecting multiple nodes (change, etc.) */
|
|
19
25
|
export declare type nodesCB = {
|
|
20
26
|
event: Event;
|
|
21
27
|
nodes: GridStackNode[];
|
|
22
28
|
};
|
|
29
|
+
/** Callback for drop events with before/after node state */
|
|
23
30
|
export declare type droppedCB = {
|
|
24
31
|
event: Event;
|
|
25
32
|
previousNode: GridStackNode;
|
|
26
33
|
newNode: GridStackNode;
|
|
27
34
|
};
|
|
28
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Extended HTMLElement interface for the grid container.
|
|
37
|
+
* Stores a back-reference to the Angular component for integration purposes.
|
|
38
|
+
*/
|
|
29
39
|
export interface GridCompHTMLElement extends GridHTMLElement {
|
|
40
|
+
/** Back-reference to the Angular GridStack component */
|
|
30
41
|
_gridComp?: GridstackComponent;
|
|
31
42
|
}
|
|
32
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Mapping of selector strings to Angular component types.
|
|
45
|
+
* Used for dynamic component creation based on widget selectors.
|
|
46
|
+
*/
|
|
33
47
|
export declare type SelectorToType = {
|
|
34
48
|
[key: string]: Type<Object>;
|
|
35
49
|
};
|
|
36
50
|
/**
|
|
37
|
-
*
|
|
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
|
+
* ```
|
|
38
67
|
*/
|
|
39
68
|
export declare class GridstackComponent implements OnInit, AfterContentInit, OnDestroy {
|
|
40
69
|
protected readonly elementRef: ElementRef<GridCompHTMLElement>;
|
|
41
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* List of template-based grid items (not recommended approach).
|
|
72
|
+
* Used to sync between DOM and GridStack internals when items are defined in templates.
|
|
73
|
+
* Prefer dynamic component creation instead.
|
|
74
|
+
*/
|
|
42
75
|
gridstackItems?: QueryList<GridstackItemComponent>;
|
|
43
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Container for dynamic component creation (recommended approach).
|
|
78
|
+
* Used to append grid items programmatically at runtime.
|
|
79
|
+
*/
|
|
44
80
|
container?: ViewContainerRef;
|
|
45
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Grid configuration options.
|
|
83
|
+
* Can be set before grid initialization or updated after grid is created.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* gridOptions: GridStackOptions = {
|
|
88
|
+
* column: 12,
|
|
89
|
+
* cellHeight: 'auto',
|
|
90
|
+
* animate: true
|
|
91
|
+
* };
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
46
94
|
set options(o: GridStackOptions);
|
|
47
|
-
/**
|
|
95
|
+
/** Get the current running grid options */
|
|
48
96
|
get options(): GridStackOptions;
|
|
49
|
-
/**
|
|
97
|
+
/**
|
|
98
|
+
* Controls whether empty content should be displayed.
|
|
99
|
+
* Set to true to show ng-content with 'empty-content' selector when grid has no items.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```html
|
|
103
|
+
* <gridstack [isEmpty]="gridItems.length === 0">
|
|
104
|
+
* <div empty-content>Drag widgets here to get started</div>
|
|
105
|
+
* </gridstack>
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
50
108
|
isEmpty?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
109
|
+
/**
|
|
110
|
+
* GridStack event emitters for Angular integration.
|
|
111
|
+
*
|
|
112
|
+
* These provide Angular-style event handling for GridStack events.
|
|
113
|
+
* Alternatively, use `this.grid.on('event1 event2', callback)` for multiple events.
|
|
54
114
|
*
|
|
55
|
-
* Note:
|
|
56
|
-
*
|
|
115
|
+
* Note: 'CB' suffix prevents conflicts with native DOM events.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```html
|
|
119
|
+
* <gridstack (changeCB)="onGridChange($event)" (droppedCB)="onItemDropped($event)">
|
|
120
|
+
* </gridstack>
|
|
121
|
+
* ```
|
|
57
122
|
*/
|
|
123
|
+
/** Emitted when widgets are added to the grid */
|
|
58
124
|
addedCB: EventEmitter<nodesCB>;
|
|
125
|
+
/** Emitted when grid layout changes */
|
|
59
126
|
changeCB: EventEmitter<nodesCB>;
|
|
127
|
+
/** Emitted when grid is disabled */
|
|
60
128
|
disableCB: EventEmitter<eventCB>;
|
|
129
|
+
/** Emitted during widget drag operations */
|
|
61
130
|
dragCB: EventEmitter<elementCB>;
|
|
131
|
+
/** Emitted when widget drag starts */
|
|
62
132
|
dragStartCB: EventEmitter<elementCB>;
|
|
133
|
+
/** Emitted when widget drag stops */
|
|
63
134
|
dragStopCB: EventEmitter<elementCB>;
|
|
135
|
+
/** Emitted when widget is dropped */
|
|
64
136
|
droppedCB: EventEmitter<droppedCB>;
|
|
137
|
+
/** Emitted when grid is enabled */
|
|
65
138
|
enableCB: EventEmitter<eventCB>;
|
|
139
|
+
/** Emitted when widgets are removed from the grid */
|
|
66
140
|
removedCB: EventEmitter<nodesCB>;
|
|
141
|
+
/** Emitted during widget resize operations */
|
|
67
142
|
resizeCB: EventEmitter<elementCB>;
|
|
143
|
+
/** Emitted when widget resize starts */
|
|
68
144
|
resizeStartCB: EventEmitter<elementCB>;
|
|
145
|
+
/** Emitted when widget resize stops */
|
|
69
146
|
resizeStopCB: EventEmitter<elementCB>;
|
|
70
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Get the native DOM element that contains grid-specific fields.
|
|
149
|
+
* This element has GridStack properties attached to it.
|
|
150
|
+
*/
|
|
71
151
|
get el(): GridCompHTMLElement;
|
|
72
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* Get the underlying GridStack instance.
|
|
154
|
+
* Use this to access GridStack API methods directly.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* this.gridComponent.grid.addWidget({x: 0, y: 0, w: 2, h: 1});
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
73
161
|
get grid(): GridStack | undefined;
|
|
74
|
-
/**
|
|
162
|
+
/**
|
|
163
|
+
* Component reference for dynamic component removal.
|
|
164
|
+
* Used internally when this component is created dynamically.
|
|
165
|
+
*/
|
|
75
166
|
ref: ComponentRef<GridstackComponent> | undefined;
|
|
76
167
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
168
|
+
* Mapping of component selectors to their types for dynamic creation.
|
|
169
|
+
*
|
|
170
|
+
* This enables dynamic component instantiation from string selectors.
|
|
171
|
+
* Angular doesn't provide public access to this mapping, so we maintain our own.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* GridstackComponent.addComponentToSelectorType([MyWidgetComponent]);
|
|
176
|
+
* ```
|
|
79
177
|
*/
|
|
80
178
|
static selectorToType: SelectorToType;
|
|
81
|
-
/**
|
|
179
|
+
/**
|
|
180
|
+
* Register a list of Angular components for dynamic creation.
|
|
181
|
+
*
|
|
182
|
+
* @param typeList Array of component types to register
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```typescript
|
|
186
|
+
* GridstackComponent.addComponentToSelectorType([
|
|
187
|
+
* MyWidgetComponent,
|
|
188
|
+
* AnotherWidgetComponent
|
|
189
|
+
* ]);
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
82
192
|
static addComponentToSelectorType(typeList: Array<Type<Object>>): void;
|
|
83
|
-
/**
|
|
193
|
+
/**
|
|
194
|
+
* Extract the selector string from an Angular component type.
|
|
195
|
+
*
|
|
196
|
+
* @param type The component type to get selector from
|
|
197
|
+
* @returns The component's selector string
|
|
198
|
+
*/
|
|
84
199
|
static getSelector(type: Type<Object>): string;
|
|
85
200
|
protected _options?: GridStackOptions;
|
|
86
201
|
protected _grid?: GridStack;
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
2
|
import * as i1 from "./gridstack-item.component";
|
|
3
3
|
import * as i2 from "./gridstack.component";
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Use GridstackComponent and GridstackItemComponent as standalone components instead.
|
|
6
|
+
*
|
|
7
|
+
* This NgModule is provided for backward compatibility but is no longer the recommended approach.
|
|
8
|
+
* Import components directly in your standalone components or use the new Angular module structure.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* // Preferred approach - standalone components
|
|
13
|
+
* @Component({
|
|
14
|
+
* selector: 'my-app',
|
|
15
|
+
* imports: [GridstackComponent, GridstackItemComponent],
|
|
16
|
+
* template: '<gridstack></gridstack>'
|
|
17
|
+
* })
|
|
18
|
+
* export class AppComponent {}
|
|
19
|
+
*
|
|
20
|
+
* // Legacy approach (deprecated)
|
|
21
|
+
* @NgModule({
|
|
22
|
+
* imports: [GridstackModule]
|
|
23
|
+
* })
|
|
24
|
+
* export class AppModule {}
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
4
27
|
export declare class GridstackModule {
|
|
5
28
|
static ɵfac: i0.ɵɵFactoryDeclaration<GridstackModule, never>;
|
|
6
29
|
static ɵmod: i0.ɵɵNgModuleDeclaration<GridstackModule, never, [typeof i1.GridstackItemComponent, typeof i2.GridstackComponent], [typeof i1.GridstackItemComponent, typeof i2.GridstackComponent]>;
|
|
@@ -1,24 +1,51 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* gridstack-item.component.ts 12.
|
|
2
|
+
* gridstack-item.component.ts 12.3.0
|
|
3
3
|
* Copyright (c) 2025 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
import { GridStackNode, GridStackOptions, GridStackWidget } from "gridstack";
|
|
6
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Extended GridStackWidget interface for Angular integration.
|
|
8
|
+
* Adds Angular-specific properties for dynamic component creation.
|
|
9
|
+
*/
|
|
7
10
|
export interface NgGridStackWidget extends GridStackWidget {
|
|
8
|
-
/** Angular
|
|
11
|
+
/** Angular component selector for dynamic creation (e.g., 'my-widget') */
|
|
9
12
|
selector?: string;
|
|
10
|
-
/**
|
|
13
|
+
/** Serialized data for component @Input() properties */
|
|
11
14
|
input?: NgCompInputs;
|
|
12
|
-
/** nested
|
|
15
|
+
/** Configuration for nested sub-grids */
|
|
13
16
|
subGridOpts?: NgGridStackOptions;
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Extended GridStackNode interface for Angular integration.
|
|
20
|
+
* Adds component selector for dynamic content creation.
|
|
21
|
+
*/
|
|
15
22
|
export interface NgGridStackNode extends GridStackNode {
|
|
23
|
+
/** Angular component selector for this node's content */
|
|
16
24
|
selector?: string;
|
|
17
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Extended GridStackOptions interface for Angular integration.
|
|
28
|
+
* Supports Angular-specific widget definitions and nested grids.
|
|
29
|
+
*/
|
|
18
30
|
export interface NgGridStackOptions extends GridStackOptions {
|
|
31
|
+
/** Array of Angular widget definitions for initial grid setup */
|
|
19
32
|
children?: NgGridStackWidget[];
|
|
33
|
+
/** Configuration for nested sub-grids (Angular-aware) */
|
|
20
34
|
subGridOpts?: NgGridStackOptions;
|
|
21
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Type for component input data serialization.
|
|
38
|
+
* Maps @Input() property names to their values for widget persistence.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const inputs: NgCompInputs = {
|
|
43
|
+
* title: 'My Widget',
|
|
44
|
+
* value: 42,
|
|
45
|
+
* config: { enabled: true }
|
|
46
|
+
* };
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
22
49
|
export declare type NgCompInputs = {
|
|
23
50
|
[key: string]: any;
|
|
24
51
|
};
|
|
@@ -1,30 +1,89 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* gridstack-item.component.ts 12.
|
|
2
|
+
* gridstack-item.component.ts 12.3.0
|
|
3
3
|
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Abstract base class that all custom widgets should extend.
|
|
8
|
+
*
|
|
9
|
+
* This class provides the interface needed for GridstackItemComponent to:
|
|
10
|
+
* - Serialize/deserialize widget data
|
|
11
|
+
* - Save/restore widget state
|
|
12
|
+
* - Integrate with Angular lifecycle
|
|
13
|
+
*
|
|
14
|
+
* Extend this class when creating custom widgets for dynamic grids.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* @Component({
|
|
19
|
+
* selector: 'my-custom-widget',
|
|
20
|
+
* template: '<div>{{data}}</div>'
|
|
21
|
+
* })
|
|
22
|
+
* export class MyCustomWidget extends BaseWidget {
|
|
23
|
+
* @Input() data: string = '';
|
|
24
|
+
*
|
|
25
|
+
* serialize() {
|
|
26
|
+
* return { data: this.data };
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
8
30
|
*/
|
|
9
31
|
|
|
10
32
|
import { Injectable } from '@angular/core';
|
|
11
33
|
import { NgCompInputs, NgGridStackWidget } from './types';
|
|
12
34
|
|
|
13
|
-
|
|
14
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Base widget class for GridStack Angular integration.
|
|
37
|
+
*/
|
|
38
|
+
@Injectable()
|
|
39
|
+
export abstract class BaseWidget {
|
|
15
40
|
|
|
16
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Complete widget definition including position, size, and Angular-specific data.
|
|
43
|
+
* Populated automatically when the widget is loaded or saved.
|
|
44
|
+
*/
|
|
17
45
|
public widgetItem?: NgGridStackWidget;
|
|
18
46
|
|
|
19
47
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
48
|
+
* Override this method to return serializable data for this widget.
|
|
49
|
+
*
|
|
50
|
+
* Return an object with properties that map to your component's @Input() fields.
|
|
51
|
+
* The selector is handled automatically, so only include component-specific data.
|
|
52
|
+
*
|
|
53
|
+
* @returns Object containing serializable component data
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* serialize() {
|
|
58
|
+
* return {
|
|
59
|
+
* title: this.title,
|
|
60
|
+
* value: this.value,
|
|
61
|
+
* settings: this.settings
|
|
62
|
+
* };
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
22
65
|
*/
|
|
23
66
|
public serialize(): NgCompInputs | undefined { return; }
|
|
24
67
|
|
|
25
68
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
69
|
+
* Override this method to handle widget restoration from saved data.
|
|
70
|
+
*
|
|
71
|
+
* Use this for complex initialization that goes beyond simple @Input() mapping.
|
|
72
|
+
* The default implementation automatically assigns input data to component properties.
|
|
73
|
+
*
|
|
74
|
+
* @param w The saved widget data including input properties
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* deserialize(w: NgGridStackWidget) {
|
|
79
|
+
* super.deserialize(w); // Call parent for basic setup
|
|
80
|
+
*
|
|
81
|
+
* // Custom initialization logic
|
|
82
|
+
* if (w.input?.complexData) {
|
|
83
|
+
* this.processComplexData(w.input.complexData);
|
|
84
|
+
* }
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
28
87
|
*/
|
|
29
88
|
public deserialize(w: NgGridStackWidget) {
|
|
30
89
|
// save full description for meta data
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* gridstack-item.component.ts 12.
|
|
2
|
+
* gridstack-item.component.ts 12.3.0
|
|
3
3
|
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -7,13 +7,34 @@ import { Component, ElementRef, Input, ViewChild, ViewContainerRef, OnDestroy, C
|
|
|
7
7
|
import { GridItemHTMLElement, GridStackNode } from 'gridstack';
|
|
8
8
|
import { BaseWidget } from './base-widget';
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Extended HTMLElement interface for grid items.
|
|
12
|
+
* Stores a back-reference to the Angular component for integration.
|
|
13
|
+
*/
|
|
11
14
|
export interface GridItemCompHTMLElement extends GridItemHTMLElement {
|
|
15
|
+
/** Back-reference to the Angular GridStackItem component */
|
|
12
16
|
_gridItemComp?: GridstackItemComponent;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
19
|
/**
|
|
16
|
-
*
|
|
20
|
+
* Angular component wrapper for individual GridStack items.
|
|
21
|
+
*
|
|
22
|
+
* This component represents a single grid item and handles:
|
|
23
|
+
* - Dynamic content creation and management
|
|
24
|
+
* - Integration with parent GridStack component
|
|
25
|
+
* - Component lifecycle and cleanup
|
|
26
|
+
* - Widget options and configuration
|
|
27
|
+
*
|
|
28
|
+
* Use in combination with GridstackComponent for the parent grid.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```html
|
|
32
|
+
* <gridstack>
|
|
33
|
+
* <gridstack-item [options]="{x: 0, y: 0, w: 2, h: 1}">
|
|
34
|
+
* <my-widget-component></my-widget-component>
|
|
35
|
+
* </gridstack-item>
|
|
36
|
+
* </gridstack>
|
|
37
|
+
* ```
|
|
17
38
|
*/
|
|
18
39
|
@Component({
|
|
19
40
|
selector: 'gridstack-item',
|
|
@@ -34,16 +55,37 @@ export interface GridItemCompHTMLElement extends GridItemHTMLElement {
|
|
|
34
55
|
})
|
|
35
56
|
export class GridstackItemComponent implements OnDestroy {
|
|
36
57
|
|
|
37
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Container for dynamic component creation within this grid item.
|
|
60
|
+
* Used to append child components programmatically.
|
|
61
|
+
*/
|
|
38
62
|
@ViewChild('container', { read: ViewContainerRef, static: true}) public container?: ViewContainerRef;
|
|
39
63
|
|
|
40
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Component reference for dynamic component removal.
|
|
66
|
+
* Used internally when this component is created dynamically.
|
|
67
|
+
*/
|
|
41
68
|
public ref: ComponentRef<GridstackItemComponent> | undefined;
|
|
42
69
|
|
|
43
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Reference to child widget component for serialization.
|
|
72
|
+
* Used to save/restore additional data along with grid position.
|
|
73
|
+
*/
|
|
44
74
|
public childWidget: BaseWidget | undefined;
|
|
45
75
|
|
|
46
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* Grid item configuration options.
|
|
78
|
+
* Defines position, size, and behavior of this grid item.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* itemOptions: GridStackNode = {
|
|
83
|
+
* x: 0, y: 0, w: 2, h: 1,
|
|
84
|
+
* noResize: true,
|
|
85
|
+
* content: 'Item content'
|
|
86
|
+
* };
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
47
89
|
@Input() public set options(val: GridStackNode) {
|
|
48
90
|
const grid = this.el.gridstackNode?.grid;
|
|
49
91
|
if (grid) {
|