gridstack 12.1.2 → 12.2.1
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/README.md +5 -2
- package/dist/angular/esm2020/gridstack-angular.mjs +4 -4
- package/dist/angular/esm2020/index.mjs +8 -8
- package/dist/angular/esm2020/lib/base-widget.mjs +34 -34
- package/dist/angular/esm2020/lib/gridstack-item.component.mjs +56 -56
- package/dist/angular/esm2020/lib/gridstack.component.mjs +319 -307
- package/dist/angular/esm2020/lib/gridstack.module.mjs +31 -31
- package/dist/angular/esm2020/lib/types.mjs +6 -6
- package/dist/angular/fesm2015/gridstack-angular.mjs +433 -420
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -1
- package/dist/angular/fesm2020/gridstack-angular.mjs +424 -412
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -1
- package/dist/angular/index.d.ts +5 -5
- package/dist/angular/lib/base-widget.d.ts +18 -18
- package/dist/angular/lib/gridstack-item.component.d.ts +37 -37
- package/dist/angular/lib/gridstack.component.d.ts +121 -117
- package/dist/angular/lib/gridstack.module.d.ts +8 -8
- package/dist/angular/lib/types.d.ts +24 -24
- 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 +13 -1
- package/dist/angular/src/gridstack.module.ts +1 -1
- package/dist/dd-base-impl.d.ts +1 -1
- package/dist/dd-base-impl.js +1 -1
- package/dist/dd-base-impl.js.map +1 -1
- package/dist/dd-draggable.d.ts +1 -1
- package/dist/dd-draggable.js +1 -1
- package/dist/dd-draggable.js.map +1 -1
- package/dist/dd-droppable.d.ts +1 -1
- package/dist/dd-droppable.js +1 -1
- package/dist/dd-droppable.js.map +1 -1
- package/dist/dd-element.d.ts +1 -1
- package/dist/dd-element.js +1 -1
- package/dist/dd-element.js.map +1 -1
- package/dist/dd-gridstack.d.ts +1 -1
- package/dist/dd-gridstack.js +1 -1
- package/dist/dd-gridstack.js.map +1 -1
- package/dist/dd-manager.d.ts +1 -1
- package/dist/dd-manager.js +1 -1
- package/dist/dd-manager.js.map +1 -1
- package/dist/dd-resizable-handle.d.ts +1 -1
- package/dist/dd-resizable-handle.js +1 -1
- package/dist/dd-resizable-handle.js.map +1 -1
- package/dist/dd-resizable.d.ts +1 -1
- package/dist/dd-resizable.js +1 -1
- package/dist/dd-resizable.js.map +1 -1
- package/dist/dd-touch.d.ts +1 -1
- package/dist/dd-touch.js +1 -1
- package/dist/dd-touch.js.map +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-engine.d.ts +1 -1
- package/dist/gridstack-engine.js +1 -1
- package/dist/gridstack-engine.js.map +1 -1
- package/dist/gridstack.css +1 -1
- package/dist/gridstack.d.ts +3 -1
- package/dist/gridstack.js +4 -2
- package/dist/gridstack.js.map +1 -1
- package/dist/src/gridstack.scss +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +1 -1
- package/doc/CHANGES.md +8 -0
- package/package.json +1 -1
|
@@ -3,79 +3,79 @@ import { Injectable, ViewContainerRef, Component, ViewChild, Input, EventEmitter
|
|
|
3
3
|
import { NgIf } from '@angular/common';
|
|
4
4
|
import { GridStack } from 'gridstack';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* gridstack-item.component.ts 12.1
|
|
8
|
-
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
9
|
-
*/
|
|
10
|
-
class BaseWidget {
|
|
11
|
-
/**
|
|
12
|
-
* REDEFINE to return an object representing the data needed to re-create yourself, other than `selector` already handled.
|
|
13
|
-
* This should map directly to the @Input() fields of this objects on create, so a simple apply can be used on read
|
|
14
|
-
*/
|
|
15
|
-
serialize() { return; }
|
|
16
|
-
/**
|
|
17
|
-
* REDEFINE this if your widget needs to read from saved data and transform it to create itself - you do this for
|
|
18
|
-
* things that are not mapped directly into @Input() fields for example.
|
|
19
|
-
*/
|
|
20
|
-
deserialize(w) {
|
|
21
|
-
// save full description for meta data
|
|
22
|
-
this.widgetItem = w;
|
|
23
|
-
if (!w)
|
|
24
|
-
return;
|
|
25
|
-
if (w.input)
|
|
26
|
-
Object.assign(this, w.input);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
BaseWidget.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BaseWidget, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
30
|
-
BaseWidget.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BaseWidget });
|
|
31
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BaseWidget, decorators: [{
|
|
32
|
-
type: Injectable
|
|
6
|
+
/**
|
|
7
|
+
* gridstack-item.component.ts 12.2.1
|
|
8
|
+
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
9
|
+
*/
|
|
10
|
+
class BaseWidget {
|
|
11
|
+
/**
|
|
12
|
+
* REDEFINE to return an object representing the data needed to re-create yourself, other than `selector` already handled.
|
|
13
|
+
* This should map directly to the @Input() fields of this objects on create, so a simple apply can be used on read
|
|
14
|
+
*/
|
|
15
|
+
serialize() { return; }
|
|
16
|
+
/**
|
|
17
|
+
* REDEFINE this if your widget needs to read from saved data and transform it to create itself - you do this for
|
|
18
|
+
* things that are not mapped directly into @Input() fields for example.
|
|
19
|
+
*/
|
|
20
|
+
deserialize(w) {
|
|
21
|
+
// save full description for meta data
|
|
22
|
+
this.widgetItem = w;
|
|
23
|
+
if (!w)
|
|
24
|
+
return;
|
|
25
|
+
if (w.input)
|
|
26
|
+
Object.assign(this, w.input);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
BaseWidget.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BaseWidget, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
30
|
+
BaseWidget.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BaseWidget });
|
|
31
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: BaseWidget, decorators: [{
|
|
32
|
+
type: Injectable
|
|
33
33
|
}] });
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* gridstack-item.component.ts 12.1
|
|
37
|
-
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* HTML Component Wrapper for gridstack items, in combination with GridstackComponent for parent grid
|
|
41
|
-
*/
|
|
42
|
-
class GridstackItemComponent {
|
|
43
|
-
constructor(elementRef) {
|
|
44
|
-
this.elementRef = elementRef;
|
|
45
|
-
this.el._gridItemComp = this;
|
|
46
|
-
}
|
|
47
|
-
/** list of options for creating/updating this item */
|
|
48
|
-
set options(val) {
|
|
49
|
-
var _a;
|
|
50
|
-
const grid = (_a = this.el.gridstackNode) === null || _a === void 0 ? void 0 : _a.grid;
|
|
51
|
-
if (grid) {
|
|
52
|
-
// already built, do an update...
|
|
53
|
-
grid.update(this.el, val);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
// store our custom element in options so we can update it and not re-create a generic div!
|
|
57
|
-
this._options = Object.assign(Object.assign({}, val), { el: this.el });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/** return the latest grid options (from GS once built, otherwise initial values) */
|
|
61
|
-
get options() {
|
|
62
|
-
return this.el.gridstackNode || this._options || { el: this.el };
|
|
63
|
-
}
|
|
64
|
-
/** return the native element that contains grid specific fields as well */
|
|
65
|
-
get el() { return this.elementRef.nativeElement; }
|
|
66
|
-
/** clears the initial options now that we've built */
|
|
67
|
-
clearOptions() {
|
|
68
|
-
delete this._options;
|
|
69
|
-
}
|
|
70
|
-
ngOnDestroy() {
|
|
71
|
-
this.clearOptions();
|
|
72
|
-
delete this.childWidget;
|
|
73
|
-
delete this.el._gridItemComp;
|
|
74
|
-
delete this.container;
|
|
75
|
-
delete this.ref;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
GridstackItemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackItemComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
35
|
+
/**
|
|
36
|
+
* gridstack-item.component.ts 12.2.1
|
|
37
|
+
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
38
|
+
*/
|
|
39
|
+
/**
|
|
40
|
+
* HTML Component Wrapper for gridstack items, in combination with GridstackComponent for parent grid
|
|
41
|
+
*/
|
|
42
|
+
class GridstackItemComponent {
|
|
43
|
+
constructor(elementRef) {
|
|
44
|
+
this.elementRef = elementRef;
|
|
45
|
+
this.el._gridItemComp = this;
|
|
46
|
+
}
|
|
47
|
+
/** list of options for creating/updating this item */
|
|
48
|
+
set options(val) {
|
|
49
|
+
var _a;
|
|
50
|
+
const grid = (_a = this.el.gridstackNode) === null || _a === void 0 ? void 0 : _a.grid;
|
|
51
|
+
if (grid) {
|
|
52
|
+
// already built, do an update...
|
|
53
|
+
grid.update(this.el, val);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
// store our custom element in options so we can update it and not re-create a generic div!
|
|
57
|
+
this._options = Object.assign(Object.assign({}, val), { el: this.el });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** return the latest grid options (from GS once built, otherwise initial values) */
|
|
61
|
+
get options() {
|
|
62
|
+
return this.el.gridstackNode || this._options || { el: this.el };
|
|
63
|
+
}
|
|
64
|
+
/** return the native element that contains grid specific fields as well */
|
|
65
|
+
get el() { return this.elementRef.nativeElement; }
|
|
66
|
+
/** clears the initial options now that we've built */
|
|
67
|
+
clearOptions() {
|
|
68
|
+
delete this._options;
|
|
69
|
+
}
|
|
70
|
+
ngOnDestroy() {
|
|
71
|
+
this.clearOptions();
|
|
72
|
+
delete this.childWidget;
|
|
73
|
+
delete this.el._gridItemComp;
|
|
74
|
+
delete this.container;
|
|
75
|
+
delete this.ref;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
GridstackItemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackItemComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
79
79
|
GridstackItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: GridstackItemComponent, isStandalone: true, selector: "gridstack-item", inputs: { options: "options" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: `
|
|
80
80
|
<div class="grid-stack-item-content">
|
|
81
81
|
<!-- where dynamic items go based on component selector (recommended way), or sub-grids, etc...) -->
|
|
@@ -84,9 +84,9 @@ GridstackItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0",
|
|
|
84
84
|
<ng-content></ng-content>
|
|
85
85
|
<!-- fallback HTML content from GridStackWidget.content if used instead (not recommended) -->
|
|
86
86
|
{{options.content}}
|
|
87
|
-
</div>`, isInline: true, styles: [":host{display:block}\n"] });
|
|
88
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackItemComponent, decorators: [{
|
|
89
|
-
type: Component,
|
|
87
|
+
</div>`, isInline: true, styles: [":host{display:block}\n"] });
|
|
88
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackItemComponent, decorators: [{
|
|
89
|
+
type: Component,
|
|
90
90
|
args: [{ selector: 'gridstack-item', template: `
|
|
91
91
|
<div class="grid-stack-item-content">
|
|
92
92
|
<!-- where dynamic items go based on component selector (recommended way), or sub-grids, etc...) -->
|
|
@@ -95,170 +95,173 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
95
95
|
<ng-content></ng-content>
|
|
96
96
|
<!-- fallback HTML content from GridStackWidget.content if used instead (not recommended) -->
|
|
97
97
|
{{options.content}}
|
|
98
|
-
</div>`, standalone: true, styles: [":host{display:block}\n"] }]
|
|
99
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { container: [{
|
|
100
|
-
type: ViewChild,
|
|
101
|
-
args: ['container', { read: ViewContainerRef, static: true }]
|
|
102
|
-
}], options: [{
|
|
103
|
-
type: Input
|
|
98
|
+
</div>`, standalone: true, styles: [":host{display:block}\n"] }]
|
|
99
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { container: [{
|
|
100
|
+
type: ViewChild,
|
|
101
|
+
args: ['container', { read: ViewContainerRef, static: true }]
|
|
102
|
+
}], options: [{
|
|
103
|
+
type: Input
|
|
104
104
|
}] } });
|
|
105
105
|
|
|
106
|
-
/**
|
|
107
|
-
* gridstack.component.ts 12.1
|
|
108
|
-
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
109
|
-
*/
|
|
110
|
-
/**
|
|
111
|
-
* HTML Component Wrapper for gridstack, in combination with GridstackItemComponent for the items
|
|
112
|
-
*/
|
|
113
|
-
class GridstackComponent {
|
|
114
|
-
constructor(elementRef) {
|
|
115
|
-
this.elementRef = elementRef;
|
|
116
|
-
/** individual list of GridStackEvent callbacks handlers as output
|
|
117
|
-
* otherwise use this.grid.on('name1 name2 name3', callback) to handle multiple at once
|
|
118
|
-
* see https://github.com/gridstack/gridstack.js/blob/master/demo/events.js#L4
|
|
119
|
-
*
|
|
120
|
-
* Note: camel casing and 'CB' added at the end to prevent @angular-eslint/no-output-native
|
|
121
|
-
* eg: 'change' would trigger the raw CustomEvent so use different name.
|
|
122
|
-
*/
|
|
123
|
-
this.addedCB = new EventEmitter();
|
|
124
|
-
this.changeCB = new EventEmitter();
|
|
125
|
-
this.disableCB = new EventEmitter();
|
|
126
|
-
this.dragCB = new EventEmitter();
|
|
127
|
-
this.dragStartCB = new EventEmitter();
|
|
128
|
-
this.dragStopCB = new EventEmitter();
|
|
129
|
-
this.droppedCB = new EventEmitter();
|
|
130
|
-
this.enableCB = new EventEmitter();
|
|
131
|
-
this.removedCB = new EventEmitter();
|
|
132
|
-
this.resizeCB = new EventEmitter();
|
|
133
|
-
this.resizeStartCB = new EventEmitter();
|
|
134
|
-
this.resizeStopCB = new EventEmitter();
|
|
135
|
-
// set globally our method to create the right widget type
|
|
136
|
-
if (!GridStack.addRemoveCB) {
|
|
137
|
-
GridStack.addRemoveCB = gsCreateNgComponents;
|
|
138
|
-
}
|
|
139
|
-
if (!GridStack.saveCB) {
|
|
140
|
-
GridStack.saveCB = gsSaveAdditionalNgInfo;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
this.
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
this
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
delete this.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if (grid
|
|
222
|
-
return;
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
.
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
.on('
|
|
234
|
-
.on('
|
|
235
|
-
.on('
|
|
236
|
-
.on('
|
|
237
|
-
.on('
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
if (grid
|
|
252
|
-
return;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
106
|
+
/**
|
|
107
|
+
* gridstack.component.ts 12.2.1
|
|
108
|
+
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
109
|
+
*/
|
|
110
|
+
/**
|
|
111
|
+
* HTML Component Wrapper for gridstack, in combination with GridstackItemComponent for the items
|
|
112
|
+
*/
|
|
113
|
+
class GridstackComponent {
|
|
114
|
+
constructor(elementRef) {
|
|
115
|
+
this.elementRef = elementRef;
|
|
116
|
+
/** individual list of GridStackEvent callbacks handlers as output
|
|
117
|
+
* otherwise use this.grid.on('name1 name2 name3', callback) to handle multiple at once
|
|
118
|
+
* see https://github.com/gridstack/gridstack.js/blob/master/demo/events.js#L4
|
|
119
|
+
*
|
|
120
|
+
* Note: camel casing and 'CB' added at the end to prevent @angular-eslint/no-output-native
|
|
121
|
+
* eg: 'change' would trigger the raw CustomEvent so use different name.
|
|
122
|
+
*/
|
|
123
|
+
this.addedCB = new EventEmitter();
|
|
124
|
+
this.changeCB = new EventEmitter();
|
|
125
|
+
this.disableCB = new EventEmitter();
|
|
126
|
+
this.dragCB = new EventEmitter();
|
|
127
|
+
this.dragStartCB = new EventEmitter();
|
|
128
|
+
this.dragStopCB = new EventEmitter();
|
|
129
|
+
this.droppedCB = new EventEmitter();
|
|
130
|
+
this.enableCB = new EventEmitter();
|
|
131
|
+
this.removedCB = new EventEmitter();
|
|
132
|
+
this.resizeCB = new EventEmitter();
|
|
133
|
+
this.resizeStartCB = new EventEmitter();
|
|
134
|
+
this.resizeStopCB = new EventEmitter();
|
|
135
|
+
// set globally our method to create the right widget type
|
|
136
|
+
if (!GridStack.addRemoveCB) {
|
|
137
|
+
GridStack.addRemoveCB = gsCreateNgComponents;
|
|
138
|
+
}
|
|
139
|
+
if (!GridStack.saveCB) {
|
|
140
|
+
GridStack.saveCB = gsSaveAdditionalNgInfo;
|
|
141
|
+
}
|
|
142
|
+
if (!GridStack.updateCB) {
|
|
143
|
+
GridStack.updateCB = gsUpdateNgComponents;
|
|
144
|
+
}
|
|
145
|
+
this.el._gridComp = this;
|
|
146
|
+
}
|
|
147
|
+
/** initial options for creation of the grid */
|
|
148
|
+
set options(o) {
|
|
149
|
+
if (this._grid) {
|
|
150
|
+
this._grid.updateOptions(o);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
this._options = o;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** return the current running options */
|
|
157
|
+
get options() { var _a; return ((_a = this._grid) === null || _a === void 0 ? void 0 : _a.opts) || this._options || {}; }
|
|
158
|
+
/** return the native element that contains grid specific fields as well */
|
|
159
|
+
get el() { return this.elementRef.nativeElement; }
|
|
160
|
+
/** return the GridStack class */
|
|
161
|
+
get grid() { return this._grid; }
|
|
162
|
+
/** add a list of ng Component to be mapped to selector */
|
|
163
|
+
static addComponentToSelectorType(typeList) {
|
|
164
|
+
typeList.forEach(type => GridstackComponent.selectorToType[GridstackComponent.getSelector(type)] = type);
|
|
165
|
+
}
|
|
166
|
+
/** return the ng Component selector */
|
|
167
|
+
static getSelector(type) {
|
|
168
|
+
return reflectComponentType(type).selector;
|
|
169
|
+
}
|
|
170
|
+
ngOnInit() {
|
|
171
|
+
var _a, _b;
|
|
172
|
+
// init ourself before any template children are created since we track them below anyway - no need to double create+update widgets
|
|
173
|
+
this.loaded = !!((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.children) === null || _b === void 0 ? void 0 : _b.length);
|
|
174
|
+
this._grid = GridStack.init(this._options, this.el);
|
|
175
|
+
delete this._options; // GS has it now
|
|
176
|
+
this.checkEmpty();
|
|
177
|
+
}
|
|
178
|
+
/** wait until after all DOM is ready to init gridstack children (after angular ngFor and sub-components run first) */
|
|
179
|
+
ngAfterContentInit() {
|
|
180
|
+
var _a;
|
|
181
|
+
// track whenever the children list changes and update the layout...
|
|
182
|
+
this._sub = (_a = this.gridstackItems) === null || _a === void 0 ? void 0 : _a.changes.subscribe(() => this.updateAll());
|
|
183
|
+
// ...and do this once at least unless we loaded children already
|
|
184
|
+
if (!this.loaded)
|
|
185
|
+
this.updateAll();
|
|
186
|
+
this.hookEvents(this.grid);
|
|
187
|
+
}
|
|
188
|
+
ngOnDestroy() {
|
|
189
|
+
var _a, _b;
|
|
190
|
+
this.unhookEvents(this._grid);
|
|
191
|
+
(_a = this._sub) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
192
|
+
(_b = this._grid) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
193
|
+
delete this._grid;
|
|
194
|
+
delete this.el._gridComp;
|
|
195
|
+
delete this.container;
|
|
196
|
+
delete this.ref;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* called when the TEMPLATE (not recommended) list of items changes - get a list of nodes and
|
|
200
|
+
* update the layout accordingly (which will take care of adding/removing items changed by Angular)
|
|
201
|
+
*/
|
|
202
|
+
updateAll() {
|
|
203
|
+
var _a;
|
|
204
|
+
if (!this.grid)
|
|
205
|
+
return;
|
|
206
|
+
const layout = [];
|
|
207
|
+
(_a = this.gridstackItems) === null || _a === void 0 ? void 0 : _a.forEach(item => {
|
|
208
|
+
layout.push(item.options);
|
|
209
|
+
item.clearOptions();
|
|
210
|
+
});
|
|
211
|
+
this.grid.load(layout); // efficient that does diffs only
|
|
212
|
+
}
|
|
213
|
+
/** check if the grid is empty, if so show alternative content */
|
|
214
|
+
checkEmpty() {
|
|
215
|
+
if (!this.grid)
|
|
216
|
+
return;
|
|
217
|
+
this.isEmpty = !this.grid.engine.nodes.length;
|
|
218
|
+
}
|
|
219
|
+
/** get all known events as easy to use Outputs for convenience */
|
|
220
|
+
hookEvents(grid) {
|
|
221
|
+
if (!grid)
|
|
222
|
+
return;
|
|
223
|
+
// nested grids don't have events in v12.1+ so skip
|
|
224
|
+
if (grid.parentGridNode)
|
|
225
|
+
return;
|
|
226
|
+
grid
|
|
227
|
+
.on('added', (event, nodes) => {
|
|
228
|
+
var _a;
|
|
229
|
+
const gridComp = ((_a = nodes[0].grid) === null || _a === void 0 ? void 0 : _a.el._gridComp) || this;
|
|
230
|
+
gridComp.checkEmpty();
|
|
231
|
+
this.addedCB.emit({ event, nodes });
|
|
232
|
+
})
|
|
233
|
+
.on('change', (event, nodes) => this.changeCB.emit({ event, nodes }))
|
|
234
|
+
.on('disable', (event) => this.disableCB.emit({ event }))
|
|
235
|
+
.on('drag', (event, el) => this.dragCB.emit({ event, el }))
|
|
236
|
+
.on('dragstart', (event, el) => this.dragStartCB.emit({ event, el }))
|
|
237
|
+
.on('dragstop', (event, el) => this.dragStopCB.emit({ event, el }))
|
|
238
|
+
.on('dropped', (event, previousNode, newNode) => this.droppedCB.emit({ event, previousNode, newNode }))
|
|
239
|
+
.on('enable', (event) => this.enableCB.emit({ event }))
|
|
240
|
+
.on('removed', (event, nodes) => {
|
|
241
|
+
var _a;
|
|
242
|
+
const gridComp = ((_a = nodes[0].grid) === null || _a === void 0 ? void 0 : _a.el._gridComp) || this;
|
|
243
|
+
gridComp.checkEmpty();
|
|
244
|
+
this.removedCB.emit({ event, nodes });
|
|
245
|
+
})
|
|
246
|
+
.on('resize', (event, el) => this.resizeCB.emit({ event, el }))
|
|
247
|
+
.on('resizestart', (event, el) => this.resizeStartCB.emit({ event, el }))
|
|
248
|
+
.on('resizestop', (event, el) => this.resizeStopCB.emit({ event, el }));
|
|
249
|
+
}
|
|
250
|
+
unhookEvents(grid) {
|
|
251
|
+
if (!grid)
|
|
252
|
+
return;
|
|
253
|
+
// nested grids don't have events in v12.1+ so skip
|
|
254
|
+
if (grid.parentGridNode)
|
|
255
|
+
return;
|
|
256
|
+
grid.off('added change disable drag dragstart dragstop dropped enable removed resize resizestart resizestop');
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* stores the selector -> Type mapping, so we can create items dynamically from a string.
|
|
261
|
+
* Unfortunately Ng doesn't provide public access to that mapping.
|
|
262
|
+
*/
|
|
263
|
+
GridstackComponent.selectorToType = {};
|
|
264
|
+
GridstackComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
262
265
|
GridstackComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: GridstackComponent, isStandalone: true, selector: "gridstack", inputs: { options: "options", isEmpty: "isEmpty" }, outputs: { addedCB: "addedCB", changeCB: "changeCB", disableCB: "disableCB", dragCB: "dragCB", dragStartCB: "dragStartCB", dragStopCB: "dragStopCB", droppedCB: "droppedCB", enableCB: "enableCB", removedCB: "removedCB", resizeCB: "resizeCB", resizeStartCB: "resizeStartCB", resizeStopCB: "resizeStopCB" }, queries: [{ propertyName: "gridstackItems", predicate: GridstackItemComponent }], viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef, static: true }], ngImport: i0, template: `
|
|
263
266
|
<!-- content to show when when grid is empty, like instructions on how to add widgets -->
|
|
264
267
|
<ng-content select="[empty-content]" *ngIf="isEmpty"></ng-content>
|
|
@@ -266,9 +269,9 @@ GridstackComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", ver
|
|
|
266
269
|
<ng-template #container></ng-template>
|
|
267
270
|
<!-- where template items go -->
|
|
268
271
|
<ng-content></ng-content>
|
|
269
|
-
`, isInline: true, styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
270
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackComponent, decorators: [{
|
|
271
|
-
type: Component,
|
|
272
|
+
`, isInline: true, styles: [":host{display:block}\n"], dependencies: [{ kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
|
|
273
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackComponent, decorators: [{
|
|
274
|
+
type: Component,
|
|
272
275
|
args: [{ selector: 'gridstack', template: `
|
|
273
276
|
<!-- content to show when when grid is empty, like instructions on how to add widgets -->
|
|
274
277
|
<ng-content select="[empty-content]" *ngIf="isEmpty"></ng-content>
|
|
@@ -276,193 +279,203 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
276
279
|
<ng-template #container></ng-template>
|
|
277
280
|
<!-- where template items go -->
|
|
278
281
|
<ng-content></ng-content>
|
|
279
|
-
`, standalone: true, imports: [NgIf], styles: [":host{display:block}\n"] }]
|
|
280
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { gridstackItems: [{
|
|
281
|
-
type: ContentChildren,
|
|
282
|
-
args: [GridstackItemComponent]
|
|
283
|
-
}], container: [{
|
|
284
|
-
type: ViewChild,
|
|
285
|
-
args: ['container', { read: ViewContainerRef, static: true }]
|
|
286
|
-
}], options: [{
|
|
287
|
-
type: Input
|
|
288
|
-
}], isEmpty: [{
|
|
289
|
-
type: Input
|
|
290
|
-
}], addedCB: [{
|
|
291
|
-
type: Output
|
|
292
|
-
}], changeCB: [{
|
|
293
|
-
type: Output
|
|
294
|
-
}], disableCB: [{
|
|
295
|
-
type: Output
|
|
296
|
-
}], dragCB: [{
|
|
297
|
-
type: Output
|
|
298
|
-
}], dragStartCB: [{
|
|
299
|
-
type: Output
|
|
300
|
-
}], dragStopCB: [{
|
|
301
|
-
type: Output
|
|
302
|
-
}], droppedCB: [{
|
|
303
|
-
type: Output
|
|
304
|
-
}], enableCB: [{
|
|
305
|
-
type: Output
|
|
306
|
-
}], removedCB: [{
|
|
307
|
-
type: Output
|
|
308
|
-
}], resizeCB: [{
|
|
309
|
-
type: Output
|
|
310
|
-
}], resizeStartCB: [{
|
|
311
|
-
type: Output
|
|
312
|
-
}], resizeStopCB: [{
|
|
313
|
-
type: Output
|
|
314
|
-
}] } });
|
|
315
|
-
/**
|
|
316
|
-
* can be used when a new item needs to be created, which we do as a Angular component, or deleted (skip)
|
|
317
|
-
**/
|
|
318
|
-
function gsCreateNgComponents(host, n, add, isGrid) {
|
|
319
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
320
|
-
if (add) {
|
|
321
|
-
//
|
|
322
|
-
// create the component dynamically - see https://angular.io/docs/ts/latest/cookbook/dynamic-component-loader.html
|
|
323
|
-
//
|
|
324
|
-
if (!host)
|
|
325
|
-
return;
|
|
326
|
-
if (isGrid) {
|
|
327
|
-
// TODO: figure out how to create ng component inside regular Div. need to access app injectors...
|
|
328
|
-
// if (!container) {
|
|
329
|
-
// const hostElement: Element = host;
|
|
330
|
-
// const environmentInjector: EnvironmentInjector;
|
|
331
|
-
// grid = createComponent(GridstackComponent, {environmentInjector, hostElement})?.instance;
|
|
332
|
-
// }
|
|
333
|
-
const gridItemComp = (_a = host.parentElement) === null || _a === void 0 ? void 0 : _a._gridItemComp;
|
|
334
|
-
if (!gridItemComp)
|
|
335
|
-
return;
|
|
336
|
-
// check if gridItem has a child component with 'container' exposed to create under..
|
|
337
|
-
const container = ((_b = gridItemComp.childWidget) === null || _b === void 0 ? void 0 : _b.container) || gridItemComp.container;
|
|
338
|
-
const gridRef = container === null || container === void 0 ? void 0 : container.createComponent(GridstackComponent);
|
|
339
|
-
const grid = gridRef === null || gridRef === void 0 ? void 0 : gridRef.instance;
|
|
340
|
-
if (!grid)
|
|
341
|
-
return;
|
|
342
|
-
grid.ref = gridRef;
|
|
343
|
-
grid.options = n;
|
|
344
|
-
return grid.el;
|
|
345
|
-
}
|
|
346
|
-
else {
|
|
347
|
-
const gridComp = host._gridComp;
|
|
348
|
-
const gridItemRef = (_c = gridComp === null || gridComp === void 0 ? void 0 : gridComp.container) === null || _c === void 0 ? void 0 : _c.createComponent(GridstackItemComponent);
|
|
349
|
-
const gridItem = gridItemRef === null || gridItemRef === void 0 ? void 0 : gridItemRef.instance;
|
|
350
|
-
if (!gridItem)
|
|
351
|
-
return;
|
|
352
|
-
gridItem.ref = gridItemRef;
|
|
353
|
-
// define what type of component to create as child, OR you can do it GridstackItemComponent template, but this is more generic
|
|
354
|
-
const selector = n.selector;
|
|
355
|
-
const type = selector ? GridstackComponent.selectorToType[selector] : undefined;
|
|
356
|
-
if (type) {
|
|
357
|
-
// shared code to create our selector component
|
|
358
|
-
const createComp = () => {
|
|
359
|
-
var _a, _b;
|
|
360
|
-
const childWidget = (_b = (_a = gridItem.container) === null || _a === void 0 ? void 0 : _a.createComponent(type)) === null || _b === void 0 ? void 0 : _b.instance;
|
|
361
|
-
// if proper BaseWidget subclass, save it and load additional data
|
|
362
|
-
if (childWidget && typeof childWidget.serialize === 'function' && typeof childWidget.deserialize === 'function') {
|
|
363
|
-
gridItem.childWidget = childWidget;
|
|
364
|
-
childWidget.deserialize(n);
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
const lazyLoad = n.lazyLoad || ((_e = (_d = n.grid) === null || _d === void 0 ? void 0 : _d.opts) === null || _e === void 0 ? void 0 : _e.lazyLoad) && n.lazyLoad !== false;
|
|
368
|
-
if (lazyLoad) {
|
|
369
|
-
if (!n.visibleObservable) {
|
|
370
|
-
n.visibleObservable = new IntersectionObserver(([entry]) => {
|
|
371
|
-
var _a;
|
|
372
|
-
if (entry.isIntersecting) {
|
|
373
|
-
(_a = n.visibleObservable) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
374
|
-
delete n.visibleObservable;
|
|
375
|
-
createComp();
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
window.setTimeout(() => { var _a; return (_a = n.visibleObservable) === null || _a === void 0 ? void 0 : _a.observe(gridItem.el); }); // wait until callee sets position attributes
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
else
|
|
382
|
-
createComp();
|
|
383
|
-
}
|
|
384
|
-
return gridItem.el;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
//
|
|
389
|
-
// REMOVE - have to call ComponentRef:destroy() for dynamic objects to correctly remove themselves
|
|
390
|
-
// Note: this will destroy all children dynamic components as well: gridItem -> childWidget
|
|
391
|
-
//
|
|
392
|
-
if (isGrid) {
|
|
393
|
-
const grid = (_f = n.el) === null || _f === void 0 ? void 0 : _f._gridComp;
|
|
394
|
-
if (grid === null || grid === void 0 ? void 0 : grid.ref)
|
|
395
|
-
grid.ref.destroy();
|
|
396
|
-
else
|
|
397
|
-
grid === null || grid === void 0 ? void 0 : grid.ngOnDestroy();
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
const gridItem = (_g = n.el) === null || _g === void 0 ? void 0 : _g._gridItemComp;
|
|
401
|
-
if (gridItem === null || gridItem === void 0 ? void 0 : gridItem.ref)
|
|
402
|
-
gridItem.ref.destroy();
|
|
403
|
-
else
|
|
404
|
-
gridItem === null || gridItem === void 0 ? void 0 : gridItem.ngOnDestroy();
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
/**
|
|
410
|
-
* called for each item in the grid - check if additional information needs to be saved.
|
|
411
|
-
* Note: since this is options minus gridstack protected members using Utils.removeInternalForSave(),
|
|
412
|
-
* this typically doesn't need to do anything. However your custom Component @Input() are now supported
|
|
413
|
-
* using BaseWidget.serialize()
|
|
414
|
-
*/
|
|
415
|
-
function gsSaveAdditionalNgInfo(n, w) {
|
|
416
|
-
var _a, _b, _c;
|
|
417
|
-
const gridItem = (_a = n.el) === null || _a === void 0 ? void 0 : _a._gridItemComp;
|
|
418
|
-
if (gridItem) {
|
|
419
|
-
const input = (_b = gridItem.childWidget) === null || _b === void 0 ? void 0 : _b.serialize();
|
|
420
|
-
if (input) {
|
|
421
|
-
w.input = input;
|
|
422
|
-
}
|
|
423
|
-
return;
|
|
424
|
-
}
|
|
425
|
-
// else check if Grid
|
|
426
|
-
const grid = (_c = n.el) === null || _c === void 0 ? void 0 : _c._gridComp;
|
|
427
|
-
if (grid) {
|
|
428
|
-
//.... save any custom data
|
|
429
|
-
}
|
|
282
|
+
`, standalone: true, imports: [NgIf], styles: [":host{display:block}\n"] }]
|
|
283
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { gridstackItems: [{
|
|
284
|
+
type: ContentChildren,
|
|
285
|
+
args: [GridstackItemComponent]
|
|
286
|
+
}], container: [{
|
|
287
|
+
type: ViewChild,
|
|
288
|
+
args: ['container', { read: ViewContainerRef, static: true }]
|
|
289
|
+
}], options: [{
|
|
290
|
+
type: Input
|
|
291
|
+
}], isEmpty: [{
|
|
292
|
+
type: Input
|
|
293
|
+
}], addedCB: [{
|
|
294
|
+
type: Output
|
|
295
|
+
}], changeCB: [{
|
|
296
|
+
type: Output
|
|
297
|
+
}], disableCB: [{
|
|
298
|
+
type: Output
|
|
299
|
+
}], dragCB: [{
|
|
300
|
+
type: Output
|
|
301
|
+
}], dragStartCB: [{
|
|
302
|
+
type: Output
|
|
303
|
+
}], dragStopCB: [{
|
|
304
|
+
type: Output
|
|
305
|
+
}], droppedCB: [{
|
|
306
|
+
type: Output
|
|
307
|
+
}], enableCB: [{
|
|
308
|
+
type: Output
|
|
309
|
+
}], removedCB: [{
|
|
310
|
+
type: Output
|
|
311
|
+
}], resizeCB: [{
|
|
312
|
+
type: Output
|
|
313
|
+
}], resizeStartCB: [{
|
|
314
|
+
type: Output
|
|
315
|
+
}], resizeStopCB: [{
|
|
316
|
+
type: Output
|
|
317
|
+
}] } });
|
|
318
|
+
/**
|
|
319
|
+
* can be used when a new item needs to be created, which we do as a Angular component, or deleted (skip)
|
|
320
|
+
**/
|
|
321
|
+
function gsCreateNgComponents(host, n, add, isGrid) {
|
|
322
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
323
|
+
if (add) {
|
|
324
|
+
//
|
|
325
|
+
// create the component dynamically - see https://angular.io/docs/ts/latest/cookbook/dynamic-component-loader.html
|
|
326
|
+
//
|
|
327
|
+
if (!host)
|
|
328
|
+
return;
|
|
329
|
+
if (isGrid) {
|
|
330
|
+
// TODO: figure out how to create ng component inside regular Div. need to access app injectors...
|
|
331
|
+
// if (!container) {
|
|
332
|
+
// const hostElement: Element = host;
|
|
333
|
+
// const environmentInjector: EnvironmentInjector;
|
|
334
|
+
// grid = createComponent(GridstackComponent, {environmentInjector, hostElement})?.instance;
|
|
335
|
+
// }
|
|
336
|
+
const gridItemComp = (_a = host.parentElement) === null || _a === void 0 ? void 0 : _a._gridItemComp;
|
|
337
|
+
if (!gridItemComp)
|
|
338
|
+
return;
|
|
339
|
+
// check if gridItem has a child component with 'container' exposed to create under..
|
|
340
|
+
const container = ((_b = gridItemComp.childWidget) === null || _b === void 0 ? void 0 : _b.container) || gridItemComp.container;
|
|
341
|
+
const gridRef = container === null || container === void 0 ? void 0 : container.createComponent(GridstackComponent);
|
|
342
|
+
const grid = gridRef === null || gridRef === void 0 ? void 0 : gridRef.instance;
|
|
343
|
+
if (!grid)
|
|
344
|
+
return;
|
|
345
|
+
grid.ref = gridRef;
|
|
346
|
+
grid.options = n;
|
|
347
|
+
return grid.el;
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
const gridComp = host._gridComp;
|
|
351
|
+
const gridItemRef = (_c = gridComp === null || gridComp === void 0 ? void 0 : gridComp.container) === null || _c === void 0 ? void 0 : _c.createComponent(GridstackItemComponent);
|
|
352
|
+
const gridItem = gridItemRef === null || gridItemRef === void 0 ? void 0 : gridItemRef.instance;
|
|
353
|
+
if (!gridItem)
|
|
354
|
+
return;
|
|
355
|
+
gridItem.ref = gridItemRef;
|
|
356
|
+
// define what type of component to create as child, OR you can do it GridstackItemComponent template, but this is more generic
|
|
357
|
+
const selector = n.selector;
|
|
358
|
+
const type = selector ? GridstackComponent.selectorToType[selector] : undefined;
|
|
359
|
+
if (type) {
|
|
360
|
+
// shared code to create our selector component
|
|
361
|
+
const createComp = () => {
|
|
362
|
+
var _a, _b;
|
|
363
|
+
const childWidget = (_b = (_a = gridItem.container) === null || _a === void 0 ? void 0 : _a.createComponent(type)) === null || _b === void 0 ? void 0 : _b.instance;
|
|
364
|
+
// if proper BaseWidget subclass, save it and load additional data
|
|
365
|
+
if (childWidget && typeof childWidget.serialize === 'function' && typeof childWidget.deserialize === 'function') {
|
|
366
|
+
gridItem.childWidget = childWidget;
|
|
367
|
+
childWidget.deserialize(n);
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
const lazyLoad = n.lazyLoad || ((_e = (_d = n.grid) === null || _d === void 0 ? void 0 : _d.opts) === null || _e === void 0 ? void 0 : _e.lazyLoad) && n.lazyLoad !== false;
|
|
371
|
+
if (lazyLoad) {
|
|
372
|
+
if (!n.visibleObservable) {
|
|
373
|
+
n.visibleObservable = new IntersectionObserver(([entry]) => {
|
|
374
|
+
var _a;
|
|
375
|
+
if (entry.isIntersecting) {
|
|
376
|
+
(_a = n.visibleObservable) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
377
|
+
delete n.visibleObservable;
|
|
378
|
+
createComp();
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
window.setTimeout(() => { var _a; return (_a = n.visibleObservable) === null || _a === void 0 ? void 0 : _a.observe(gridItem.el); }); // wait until callee sets position attributes
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
else
|
|
385
|
+
createComp();
|
|
386
|
+
}
|
|
387
|
+
return gridItem.el;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
//
|
|
392
|
+
// REMOVE - have to call ComponentRef:destroy() for dynamic objects to correctly remove themselves
|
|
393
|
+
// Note: this will destroy all children dynamic components as well: gridItem -> childWidget
|
|
394
|
+
//
|
|
395
|
+
if (isGrid) {
|
|
396
|
+
const grid = (_f = n.el) === null || _f === void 0 ? void 0 : _f._gridComp;
|
|
397
|
+
if (grid === null || grid === void 0 ? void 0 : grid.ref)
|
|
398
|
+
grid.ref.destroy();
|
|
399
|
+
else
|
|
400
|
+
grid === null || grid === void 0 ? void 0 : grid.ngOnDestroy();
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
const gridItem = (_g = n.el) === null || _g === void 0 ? void 0 : _g._gridItemComp;
|
|
404
|
+
if (gridItem === null || gridItem === void 0 ? void 0 : gridItem.ref)
|
|
405
|
+
gridItem.ref.destroy();
|
|
406
|
+
else
|
|
407
|
+
gridItem === null || gridItem === void 0 ? void 0 : gridItem.ngOnDestroy();
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* called for each item in the grid - check if additional information needs to be saved.
|
|
414
|
+
* Note: since this is options minus gridstack protected members using Utils.removeInternalForSave(),
|
|
415
|
+
* this typically doesn't need to do anything. However your custom Component @Input() are now supported
|
|
416
|
+
* using BaseWidget.serialize()
|
|
417
|
+
*/
|
|
418
|
+
function gsSaveAdditionalNgInfo(n, w) {
|
|
419
|
+
var _a, _b, _c;
|
|
420
|
+
const gridItem = (_a = n.el) === null || _a === void 0 ? void 0 : _a._gridItemComp;
|
|
421
|
+
if (gridItem) {
|
|
422
|
+
const input = (_b = gridItem.childWidget) === null || _b === void 0 ? void 0 : _b.serialize();
|
|
423
|
+
if (input) {
|
|
424
|
+
w.input = input;
|
|
425
|
+
}
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
// else check if Grid
|
|
429
|
+
const grid = (_c = n.el) === null || _c === void 0 ? void 0 : _c._gridComp;
|
|
430
|
+
if (grid) {
|
|
431
|
+
//.... save any custom data
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* track when widgeta re updated (rather than created) to make sure we de-serialize them as well
|
|
436
|
+
*/
|
|
437
|
+
function gsUpdateNgComponents(n) {
|
|
438
|
+
var _a;
|
|
439
|
+
const w = n;
|
|
440
|
+
const gridItem = (_a = n.el) === null || _a === void 0 ? void 0 : _a._gridItemComp;
|
|
441
|
+
if ((gridItem === null || gridItem === void 0 ? void 0 : gridItem.childWidget) && w.input)
|
|
442
|
+
gridItem.childWidget.deserialize(w);
|
|
430
443
|
}
|
|
431
444
|
|
|
432
|
-
/**
|
|
433
|
-
* gridstack.component.ts 12.1
|
|
434
|
-
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
435
|
-
*/
|
|
436
|
-
// @deprecated use GridstackComponent and GridstackItemComponent as standalone components
|
|
437
|
-
class GridstackModule {
|
|
438
|
-
}
|
|
439
|
-
GridstackModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
440
|
-
GridstackModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: GridstackModule, imports: [GridstackItemComponent,
|
|
441
|
-
GridstackComponent], exports: [GridstackItemComponent,
|
|
442
|
-
GridstackComponent] });
|
|
443
|
-
GridstackModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackModule, imports: [GridstackItemComponent,
|
|
444
|
-
GridstackComponent] });
|
|
445
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackModule, decorators: [{
|
|
446
|
-
type: NgModule,
|
|
447
|
-
args: [{
|
|
448
|
-
imports: [
|
|
449
|
-
GridstackItemComponent,
|
|
450
|
-
GridstackComponent,
|
|
451
|
-
],
|
|
452
|
-
exports: [
|
|
453
|
-
GridstackItemComponent,
|
|
454
|
-
GridstackComponent,
|
|
455
|
-
],
|
|
456
|
-
}]
|
|
445
|
+
/**
|
|
446
|
+
* gridstack.component.ts 12.2.1
|
|
447
|
+
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
|
|
448
|
+
*/
|
|
449
|
+
// @deprecated use GridstackComponent and GridstackItemComponent as standalone components
|
|
450
|
+
class GridstackModule {
|
|
451
|
+
}
|
|
452
|
+
GridstackModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
453
|
+
GridstackModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: GridstackModule, imports: [GridstackItemComponent,
|
|
454
|
+
GridstackComponent], exports: [GridstackItemComponent,
|
|
455
|
+
GridstackComponent] });
|
|
456
|
+
GridstackModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackModule, imports: [GridstackItemComponent,
|
|
457
|
+
GridstackComponent] });
|
|
458
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: GridstackModule, decorators: [{
|
|
459
|
+
type: NgModule,
|
|
460
|
+
args: [{
|
|
461
|
+
imports: [
|
|
462
|
+
GridstackItemComponent,
|
|
463
|
+
GridstackComponent,
|
|
464
|
+
],
|
|
465
|
+
exports: [
|
|
466
|
+
GridstackItemComponent,
|
|
467
|
+
GridstackComponent,
|
|
468
|
+
],
|
|
469
|
+
}]
|
|
457
470
|
}] });
|
|
458
471
|
|
|
459
|
-
/*
|
|
460
|
-
* Public API Surface of gridstack-angular
|
|
472
|
+
/*
|
|
473
|
+
* Public API Surface of gridstack-angular
|
|
461
474
|
*/
|
|
462
475
|
|
|
463
|
-
/**
|
|
464
|
-
* Generated bundle index. Do not edit.
|
|
476
|
+
/**
|
|
477
|
+
* Generated bundle index. Do not edit.
|
|
465
478
|
*/
|
|
466
479
|
|
|
467
|
-
export { BaseWidget, GridstackComponent, GridstackItemComponent, GridstackModule, gsCreateNgComponents, gsSaveAdditionalNgInfo };
|
|
480
|
+
export { BaseWidget, GridstackComponent, GridstackItemComponent, GridstackModule, gsCreateNgComponents, gsSaveAdditionalNgInfo, gsUpdateNgComponents };
|
|
468
481
|
//# sourceMappingURL=gridstack-angular.mjs.map
|