gridstack 8.1.0 → 8.1.2

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.
Files changed (157) hide show
  1. package/README.md +26 -38
  2. package/angular/.editorconfig +16 -0
  3. package/angular/.vscode/extensions.json +4 -0
  4. package/angular/.vscode/launch.json +20 -0
  5. package/angular/.vscode/tasks.json +42 -0
  6. package/{dist/ng → angular}/README.md +170 -154
  7. package/angular/README_build.md +27 -0
  8. package/angular/angular.json +132 -0
  9. package/angular/package.json +40 -0
  10. package/angular/projects/demo/.browserslistrc +16 -0
  11. package/angular/projects/demo/src/app/app.component.css +11 -0
  12. package/angular/projects/demo/src/app/app.component.html +78 -0
  13. package/angular/projects/demo/src/app/app.component.spec.ts +25 -0
  14. package/angular/projects/demo/src/app/app.component.ts +208 -0
  15. package/angular/projects/demo/src/app/app.module.ts +38 -0
  16. package/angular/projects/demo/src/app/dummy.component.ts +29 -0
  17. package/angular/projects/demo/src/app/ngFor.ts +131 -0
  18. package/angular/projects/demo/src/app/ngFor_cmd.ts +106 -0
  19. package/angular/projects/demo/src/app/simple.ts +46 -0
  20. package/angular/projects/demo/src/assets/.gitkeep +0 -0
  21. package/angular/projects/demo/src/environments/environment.prod.ts +3 -0
  22. package/angular/projects/demo/src/environments/environment.ts +16 -0
  23. package/angular/projects/demo/src/favicon.ico +0 -0
  24. package/angular/projects/demo/src/index.html +13 -0
  25. package/angular/projects/demo/src/main.ts +12 -0
  26. package/angular/projects/demo/src/polyfills.ts +53 -0
  27. package/angular/projects/demo/src/styles.css +4 -0
  28. package/angular/projects/demo/src/test.ts +26 -0
  29. package/angular/projects/demo/tsconfig.app.json +15 -0
  30. package/angular/projects/demo/tsconfig.spec.json +18 -0
  31. package/angular/projects/lib/README.md +24 -0
  32. package/angular/projects/lib/ng-package.json +7 -0
  33. package/angular/projects/lib/package.json +11 -0
  34. package/angular/projects/lib/src/lib/gridstack-item.component.ts +70 -0
  35. package/angular/projects/lib/src/lib/gridstack.component.ts +240 -0
  36. package/angular/projects/lib/src/lib/gridstack.module.ts +32 -0
  37. package/angular/projects/lib/src/public-api.ts +7 -0
  38. package/angular/projects/lib/src/test.ts +27 -0
  39. package/angular/projects/lib/tsconfig.lib.json +15 -0
  40. package/angular/projects/lib/tsconfig.lib.prod.json +10 -0
  41. package/angular/projects/lib/tsconfig.spec.json +17 -0
  42. package/dist/angular/README.md +170 -0
  43. package/dist/angular/esm2020/gridstack-angular.mjs +5 -0
  44. package/dist/angular/esm2020/lib/gridstack-item.component.mjs +67 -0
  45. package/dist/angular/esm2020/lib/gridstack.component.mjs +233 -0
  46. package/dist/angular/esm2020/lib/gridstack.module.mjs +39 -0
  47. package/dist/angular/esm2020/public-api.mjs +7 -0
  48. package/dist/angular/fesm2015/gridstack-angular.mjs +346 -0
  49. package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -0
  50. package/dist/angular/fesm2020/gridstack-angular.mjs +342 -0
  51. package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -0
  52. package/dist/angular/index.d.ts +5 -0
  53. package/dist/{ng → angular/lib}/gridstack-item.component.d.ts +32 -29
  54. package/dist/{ng → angular/lib}/gridstack.component.d.ts +121 -118
  55. package/dist/angular/lib/gridstack.module.d.ts +10 -0
  56. package/dist/angular/package.json +31 -0
  57. package/dist/angular/public-api.d.ts +3 -0
  58. package/dist/angular/src/gridstack-item.component.ts +70 -0
  59. package/dist/angular/src/gridstack.component.ts +240 -0
  60. package/dist/angular/src/gridstack.module.ts +32 -0
  61. package/dist/dd-base-impl.d.ts +1 -1
  62. package/dist/dd-base-impl.js +1 -1
  63. package/dist/dd-base-impl.js.map +1 -1
  64. package/dist/dd-draggable.d.ts +1 -1
  65. package/dist/dd-draggable.js +1 -1
  66. package/dist/dd-draggable.js.map +1 -1
  67. package/dist/dd-droppable.d.ts +1 -1
  68. package/dist/dd-droppable.js +1 -1
  69. package/dist/dd-droppable.js.map +1 -1
  70. package/dist/dd-element.d.ts +1 -1
  71. package/dist/dd-element.js +1 -1
  72. package/dist/dd-element.js.map +1 -1
  73. package/dist/dd-gridstack.d.ts +1 -1
  74. package/dist/dd-gridstack.js +1 -1
  75. package/dist/dd-gridstack.js.map +1 -1
  76. package/dist/dd-manager.d.ts +1 -1
  77. package/dist/dd-manager.js +1 -1
  78. package/dist/dd-manager.js.map +1 -1
  79. package/dist/dd-resizable-handle.d.ts +1 -1
  80. package/dist/dd-resizable-handle.js +1 -1
  81. package/dist/dd-resizable-handle.js.map +1 -1
  82. package/dist/dd-resizable.d.ts +1 -1
  83. package/dist/dd-resizable.js +1 -1
  84. package/dist/dd-resizable.js.map +1 -1
  85. package/dist/dd-touch.d.ts +1 -1
  86. package/dist/dd-touch.js +1 -1
  87. package/dist/dd-touch.js.map +1 -1
  88. package/dist/es5/dd-base-impl.d.ts +1 -1
  89. package/dist/es5/dd-base-impl.js +1 -1
  90. package/dist/es5/dd-base-impl.js.map +1 -1
  91. package/dist/es5/dd-draggable.d.ts +1 -1
  92. package/dist/es5/dd-draggable.js +1 -1
  93. package/dist/es5/dd-draggable.js.map +1 -1
  94. package/dist/es5/dd-droppable.d.ts +1 -1
  95. package/dist/es5/dd-droppable.js +1 -1
  96. package/dist/es5/dd-droppable.js.map +1 -1
  97. package/dist/es5/dd-element.d.ts +1 -1
  98. package/dist/es5/dd-element.js +1 -1
  99. package/dist/es5/dd-element.js.map +1 -1
  100. package/dist/es5/dd-gridstack.d.ts +1 -1
  101. package/dist/es5/dd-gridstack.js +1 -1
  102. package/dist/es5/dd-gridstack.js.map +1 -1
  103. package/dist/es5/dd-manager.d.ts +1 -1
  104. package/dist/es5/dd-manager.js +1 -1
  105. package/dist/es5/dd-manager.js.map +1 -1
  106. package/dist/es5/dd-resizable-handle.d.ts +1 -1
  107. package/dist/es5/dd-resizable-handle.js +1 -1
  108. package/dist/es5/dd-resizable-handle.js.map +1 -1
  109. package/dist/es5/dd-resizable.d.ts +1 -1
  110. package/dist/es5/dd-resizable.js +1 -1
  111. package/dist/es5/dd-resizable.js.map +1 -1
  112. package/dist/es5/dd-touch.d.ts +1 -1
  113. package/dist/es5/dd-touch.js +1 -1
  114. package/dist/es5/dd-touch.js.map +1 -1
  115. package/dist/es5/gridstack-all.js +1 -1
  116. package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
  117. package/dist/es5/gridstack-all.js.map +1 -1
  118. package/dist/es5/gridstack-engine.d.ts +1 -1
  119. package/dist/es5/gridstack-engine.js +1 -1
  120. package/dist/es5/gridstack-engine.js.map +1 -1
  121. package/dist/es5/gridstack-poly.js +1 -1
  122. package/dist/es5/gridstack.d.ts +1 -1
  123. package/dist/es5/gridstack.js +9 -10
  124. package/dist/es5/gridstack.js.map +1 -1
  125. package/dist/es5/types.d.ts +1 -1
  126. package/dist/es5/types.js +1 -1
  127. package/dist/es5/types.js.map +1 -1
  128. package/dist/es5/utils.d.ts +1 -1
  129. package/dist/es5/utils.js +1 -1
  130. package/dist/es5/utils.js.map +1 -1
  131. package/dist/gridstack-all.js +1 -1
  132. package/dist/gridstack-all.js.LICENSE.txt +1 -1
  133. package/dist/gridstack-all.js.map +1 -1
  134. package/dist/gridstack-engine.d.ts +1 -1
  135. package/dist/gridstack-engine.js +1 -1
  136. package/dist/gridstack-engine.js.map +1 -1
  137. package/dist/gridstack-extra.css +130 -130
  138. package/dist/gridstack-extra.min.css +1 -1
  139. package/dist/gridstack.css +29 -31
  140. package/dist/gridstack.d.ts +1 -1
  141. package/dist/gridstack.js +9 -10
  142. package/dist/gridstack.js.map +1 -1
  143. package/dist/gridstack.min.css +1 -1
  144. package/dist/src/gridstack-extra.scss +5 -5
  145. package/dist/src/gridstack.scss +7 -10
  146. package/dist/types.d.ts +1 -1
  147. package/dist/types.js +1 -1
  148. package/dist/types.js.map +1 -1
  149. package/dist/utils.d.ts +1 -1
  150. package/dist/utils.js +1 -1
  151. package/dist/utils.js.map +1 -1
  152. package/doc/CHANGES.md +10 -2
  153. package/package.json +3 -3
  154. package/dist/ng/gridstack-item.component.js +0 -65
  155. package/dist/ng/gridstack-item.component.js.map +0 -1
  156. package/dist/ng/gridstack.component.js +0 -245
  157. package/dist/ng/gridstack.component.js.map +0 -1
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Example using Angular ngFor to loop through items and create DOM items
3
+ */
4
+
5
+ import { Component, AfterViewInit, Input, ViewChildren, QueryList, ElementRef } from '@angular/core';
6
+ import { GridItemHTMLElement, GridStack, GridStackNode, GridStackWidget, Utils } from 'gridstack';
7
+
8
+ // unique ids sets for each item for correct ngFor updating
9
+ let ids = 1;
10
+
11
+ @Component({
12
+ selector: "angular-ng-for-test",
13
+ template: `
14
+ <p><b>ngFor</b>: Example using Angular ngFor to loop through items and create DOM items. This track changes made to the array of items, waits for DOM rendering, then update GS</p>
15
+ <button (click)="add()">add item</button>
16
+ <button (click)="delete()">remove item</button>
17
+ <button (click)="modify()">modify item</button>
18
+ <button (click)="newLayout()">new layout</button>
19
+ <div class="grid-stack">
20
+ <!-- using angular templating to create DOM, otherwise an easier way is to simply call grid.load(items)
21
+ NOTE: this example is NOT complete as there are many more properties than listed (minW, maxW, etc....)
22
+ -->
23
+ <div *ngFor="let n of items; trackBy: identify"
24
+ class="grid-stack-item"
25
+ [attr.gs-id]="n.id"
26
+ [attr.gs-x]="n.x"
27
+ [attr.gs-y]="n.y"
28
+ [attr.gs-w]="n.w"
29
+ [attr.gs-h]="n.h"
30
+ #gridStackItem
31
+ >
32
+ <div class="grid-stack-item-content">item {{ n.id }}</div>
33
+ </div>
34
+ </div>
35
+ `,
36
+ // gridstack.min.css and other custom styles should be included in global styles.scss or here
37
+ })
38
+ export class AngularNgForTestComponent implements AfterViewInit {
39
+ /** list of HTML items that we track to know when the DOM has been updated to make/remove GS widgets */
40
+ @ViewChildren("gridStackItem") gridstackItems!: QueryList<ElementRef<GridItemHTMLElement>>;
41
+
42
+ /** set the items to display. */
43
+ @Input() public set items(list: GridStackWidget[]) {
44
+ this._items = list || [];
45
+ this._items.forEach(w => w.id = w.id || String(ids++)); // make sure a unique id is generated for correct ngFor loop update
46
+ }
47
+ public get items(): GridStackWidget[] { return this._items}
48
+
49
+ private grid!: GridStack;
50
+ public _items!: GridStackWidget[];
51
+
52
+ constructor() {
53
+ this.items = [
54
+ {x: 0, y: 0},
55
+ {x: 1, y: 1},
56
+ {x: 2, y: 2},
57
+ ];
58
+ }
59
+
60
+ // wait until after DOM is ready to init gridstack - can't be ngOnInit() as angular ngFor needs to run first!
61
+ public ngAfterViewInit() {
62
+ this.grid = GridStack.init({
63
+ margin: 5,
64
+ float: true,
65
+ })
66
+ .on('change added', (event: Event, nodes: GridStackNode[]) => this.onChange(nodes));
67
+
68
+ // sync initial actual valued rendered (in case init() had to merge conflicts)
69
+ this.onChange();
70
+
71
+ /**
72
+ * this is called when the list of items changes - get a list of nodes and
73
+ * update the layout accordingly (which will take care of adding/removing items changed by Angular)
74
+ */
75
+ this.gridstackItems.changes.subscribe(() => {
76
+ const layout: GridStackWidget[] = [];
77
+ this.gridstackItems.forEach(ref => {
78
+ const n = ref.nativeElement.gridstackNode || this.grid.makeWidget(ref.nativeElement).gridstackNode;
79
+ if (n) layout.push(n);
80
+ });
81
+ this.grid.load(layout); // efficient that does diffs only
82
+ })
83
+ }
84
+
85
+ /** Optional: called when given widgets are changed (moved/resized/added) - update our list to match.
86
+ * Note this is not strictly necessary as demo works without this
87
+ */
88
+ public onChange(list = this.grid.engine.nodes) {
89
+ setTimeout(() => // prevent new 'added' items from ExpressionChangedAfterItHasBeenCheckedError. TODO: find cleaner way to sync outside Angular change detection ?
90
+ list.forEach(n => {
91
+ const item = this._items.find(i => i.id === n.id);
92
+ if (item) Utils.copyPos(item, n);
93
+ })
94
+ , 0);
95
+ }
96
+
97
+ /**
98
+ * CRUD operations
99
+ */
100
+ public add() {
101
+ // new array isn't required as Angular seem to detect changes to content
102
+ // this.items = [...this.items, { x:3, y:0, w:3, id:String(ids++) }];
103
+ this.items.push({ x:3, y:0, w:3, id:String(ids++) });
104
+ }
105
+
106
+ public delete() {
107
+ this.items.pop();
108
+ }
109
+
110
+ public modify() {
111
+ // this will only update the DOM attr (from the ngFor loop in our template above)
112
+ // but not trigger gridstackItems.changes for GS to auto-update, so call GS update() instead
113
+ // this.items[0].w = 2;
114
+ const n = this.grid.engine.nodes[0];
115
+ if (n?.el) this.grid.update(n.el, {w:3});
116
+ }
117
+
118
+ public newLayout() {
119
+ this.items = [ // test updating existing and creating new one
120
+ {x:0, y:1, id:'1'},
121
+ {x:1, y:1, id:'2'},
122
+ // {x:2, y:1, id:3}, // delete item
123
+ {x:3, y:0, w:3}, // new item
124
+ ];
125
+ }
126
+
127
+ // ngFor unique node id to have correct match between our items used and GS
128
+ identify(index: number, w: GridStackWidget) {
129
+ return w.id;
130
+ }
131
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Example using Angular ngFor to loop through items and create DOM items - this uses a custom command.
3
+ * NOTE: see the simpler and better (tracks all changes) angular-ng-for-test
4
+ */
5
+
6
+ import { Component, AfterViewInit, Input, ViewChildren, QueryList, ElementRef } from '@angular/core';
7
+ import { Subject, zip } from "rxjs";
8
+
9
+ import { GridItemHTMLElement, GridStack, GridStackWidget } from 'gridstack';
10
+
11
+ @Component({
12
+ selector: "angular-ng-for-cmd-test",
13
+ template: `
14
+ <p><b>ngFor CMD</b>: Example using Angular ngFor to loop through items, but uses an explicity command to let us update GS (see automatic better way)</p>
15
+ <button (click)="add()">add item</button>
16
+ <button (click)="delete()">remove item</button>
17
+ <button (click)="modify()">modify item</button>
18
+ <div class="grid-stack">
19
+ <!-- using angular templating to create DOM, otherwise an easier way is to simply call grid.load(items) -->
20
+ <div
21
+ *ngFor="let n of items; let i = index; trackBy: identify"
22
+ [id]="i"
23
+ class="grid-stack-item"
24
+ [attr.gs-x]="n.x"
25
+ [attr.gs-y]="n.y"
26
+ [attr.gs-w]="n.w"
27
+ [attr.gs-h]="n.h"
28
+ #gridStackItem
29
+ >
30
+ <div class="grid-stack-item-content">item {{ i }}</div>
31
+ </div>
32
+ </div>
33
+ `,
34
+ // gridstack.min.css and other custom styles should be included in global styles.scss or here
35
+ })
36
+ export class AngularNgForCmdTestComponent implements AfterViewInit {
37
+ /** list of HTML items that we track to know when the DOM has been updated to make/remove GS widgets */
38
+ @ViewChildren("gridStackItem") gridstackItems!: QueryList<ElementRef<GridItemHTMLElement>>;
39
+
40
+ /** set the items to display. */
41
+ @Input() public items: GridStackWidget[] = [
42
+ {x: 0, y: 0},
43
+ {x: 1, y: 1},
44
+ {x: 2, y: 2},
45
+ ];
46
+
47
+ private grid!: GridStack;
48
+ private widgetToMake: Subject<{
49
+ action: "add" | "remove" | "update";
50
+ id: number;
51
+ }> = new Subject(); // consider to use a state management like ngrx component store to do this
52
+
53
+ constructor() {}
54
+
55
+ // wait until after DOM is ready to init gridstack - can't be ngOnInit() as angular ngFor needs to run first!
56
+ public ngAfterViewInit() {
57
+ this.grid = GridStack.init({
58
+ margin: 5,
59
+ float: true,
60
+ });
61
+
62
+ // To sync dom manipulation done by Angular and widget manipulation done by gridstack we need to zip the observables
63
+ zip(this.gridstackItems.changes, this.widgetToMake).subscribe(
64
+ ([changedWidget, widgetToMake]) => {
65
+ if (widgetToMake.action === "add") {
66
+ this.grid.makeWidget(`#${widgetToMake.id}`);
67
+ } else if (widgetToMake.action === "remove") {
68
+ const id = String(widgetToMake.id);
69
+ // Note: DOM element has been removed by Angular already so look for it through the engine node list
70
+ const removeEl = this.grid.engine.nodes.find((n) => n.el?.id === id)?.el;
71
+ if (removeEl) this.grid.removeWidget(removeEl);
72
+ }
73
+ }
74
+ );
75
+
76
+ // TODO: the problem with this code is that our items list does NOT reflect changes made by GS (user directly changing,
77
+ // or conflict during initial layout) and believe the other ngFor example (which does track changes) is also cleaner
78
+ // as it doesn't require user creating special action commands nor track 'both' changes using zip().
79
+ // TODO: identify() uses index which is not guaranteed to match between invocations (insert/delete in
80
+ // middle of list instead of end as demo does)
81
+ }
82
+
83
+ /**
84
+ * CRUD operations
85
+ */
86
+ public add() {
87
+ this.items = [...this.items, { x: 3, y: 0, w: 3 }];
88
+ this.widgetToMake.next({ action: "add", id: this.items.length - 1 });
89
+ }
90
+
91
+ public delete() {
92
+ this.items.pop();
93
+ this.widgetToMake.next({ action: "remove", id: this.items.length });
94
+ }
95
+
96
+ // a change of a widget doesn´t change to amount of items in ngFor therefore we don´t need to do it through the zip function above
97
+ public modify() {
98
+ const updateEl = this.grid.getGridItems().find((el) => el.id === `${0}`);
99
+ this.grid.update(updateEl!, { w: 2 });
100
+ }
101
+
102
+ // ngFor lookup indexing
103
+ identify(index: number) {
104
+ return index;
105
+ }
106
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Simplest Angular Example using GridStack API directly
3
+ */
4
+ import { Component, OnInit } from '@angular/core';
5
+
6
+ import { GridStack, GridStackWidget } from 'gridstack';
7
+
8
+ @Component({
9
+ selector: 'angular-simple-test',
10
+ template: `
11
+ <p><b>SIMPLEST</b>: angular example using GridStack API directly, so not really using any angular construct per say other than waiting for DOM rendering</p>
12
+ <button (click)="add()">add item</button>
13
+ <button (click)="delete()">remove item</button>
14
+ <button (click)="change()">modify item</button>
15
+ <div class="grid-stack"></div>
16
+ `,
17
+ // gridstack.min.css and other custom styles should be included in global styles.scss
18
+ })
19
+ export class AngularSimpleComponent implements OnInit {
20
+ public items: GridStackWidget[] = [
21
+ { x: 0, y: 0, w: 9, h: 6, content: '0' },
22
+ { x: 9, y: 0, w: 3, h: 3, content: '1' },
23
+ { x: 9, y: 3, w: 3, h: 3, content: '2' },
24
+ ];
25
+ private grid!: GridStack;
26
+
27
+ constructor() {}
28
+
29
+ // simple div above doesn't require Angular to run, so init gridstack here
30
+ public ngOnInit() {
31
+ this.grid = GridStack.init({
32
+ cellHeight: 70,
33
+ })
34
+ .load(this.items); // and load our content directly (will create DOM)
35
+ }
36
+
37
+ public add() {
38
+ this.grid.addWidget({w: 3, content: 'new content'});
39
+ }
40
+ public delete() {
41
+ this.grid.removeWidget(this.grid.engine.nodes[0].el!);
42
+ }
43
+ public change() {
44
+ this.grid.update(this.grid.engine.nodes[0].el!, {w: 1});
45
+ }
46
+ }
File without changes
@@ -0,0 +1,3 @@
1
+ export const environment = {
2
+ production: true
3
+ };
@@ -0,0 +1,16 @@
1
+ // This file can be replaced during build by using the `fileReplacements` array.
2
+ // `ng build` replaces `environment.ts` with `environment.prod.ts`.
3
+ // The list of file replacements can be found in `angular.json`.
4
+
5
+ export const environment = {
6
+ production: false
7
+ };
8
+
9
+ /*
10
+ * For easier debugging in development mode, you can import the following file
11
+ * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12
+ *
13
+ * This import should be commented out in production mode because it will have a negative impact
14
+ * on performance if an error is thrown.
15
+ */
16
+ // import 'zone.js/plugins/zone-error'; // Included with Angular CLI.
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Demo</title>
6
+ <base href="/">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <link rel="icon" type="image/x-icon" href="favicon.ico">
9
+ </head>
10
+ <body>
11
+ <app-root></app-root>
12
+ </body>
13
+ </html>
@@ -0,0 +1,12 @@
1
+ import { enableProdMode } from '@angular/core';
2
+ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3
+
4
+ import { AppModule } from './app/app.module';
5
+ import { environment } from './environments/environment';
6
+
7
+ if (environment.production) {
8
+ enableProdMode();
9
+ }
10
+
11
+ platformBrowserDynamic().bootstrapModule(AppModule)
12
+ .catch(err => console.error(err));
@@ -0,0 +1,53 @@
1
+ /**
2
+ * This file includes polyfills needed by Angular and is loaded before the app.
3
+ * You can add your own extra polyfills to this file.
4
+ *
5
+ * This file is divided into 2 sections:
6
+ * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7
+ * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8
+ * file.
9
+ *
10
+ * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11
+ * automatically update themselves. This includes recent versions of Safari, Chrome (including
12
+ * Opera), Edge on the desktop, and iOS and Chrome on mobile.
13
+ *
14
+ * Learn more in https://angular.io/guide/browser-support
15
+ */
16
+
17
+ /***************************************************************************************************
18
+ * BROWSER POLYFILLS
19
+ */
20
+
21
+ /**
22
+ * By default, zone.js will patch all possible macroTask and DomEvents
23
+ * user can disable parts of macroTask/DomEvents patch by setting following flags
24
+ * because those flags need to be set before `zone.js` being loaded, and webpack
25
+ * will put import in the top of bundle, so user need to create a separate file
26
+ * in this directory (for example: zone-flags.ts), and put the following flags
27
+ * into that file, and then add the following code before importing zone.js.
28
+ * import './zone-flags';
29
+ *
30
+ * The flags allowed in zone-flags.ts are listed here.
31
+ *
32
+ * The following flags will work for all browsers.
33
+ *
34
+ * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
35
+ * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
36
+ * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
37
+ *
38
+ * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
39
+ * with the following flag, it will bypass `zone.js` patch for IE/Edge
40
+ *
41
+ * (window as any).__Zone_enable_cross_context_check = true;
42
+ *
43
+ */
44
+
45
+ /***************************************************************************************************
46
+ * Zone JS is required by default for Angular itself.
47
+ */
48
+ import 'zone.js'; // Included with Angular CLI.
49
+
50
+
51
+ /***************************************************************************************************
52
+ * APPLICATION IMPORTS
53
+ */
@@ -0,0 +1,4 @@
1
+ /* re-use existing demo css file we already use for the plain demos - that include gridstack.css which is required */
2
+ @import "../../../../demo/demo.css";
3
+ /* required file for gridstack 2-11 column */
4
+ @import "../../../../dist/gridstack-extra.css";
@@ -0,0 +1,26 @@
1
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
+
3
+ import 'zone.js/testing';
4
+ import { getTestBed } from '@angular/core/testing';
5
+ import {
6
+ BrowserDynamicTestingModule,
7
+ platformBrowserDynamicTesting
8
+ } from '@angular/platform-browser-dynamic/testing';
9
+
10
+ declare const require: {
11
+ context(path: string, deep?: boolean, filter?: RegExp): {
12
+ <T>(id: string): T;
13
+ keys(): string[];
14
+ };
15
+ };
16
+
17
+ // First, initialize the Angular testing environment.
18
+ getTestBed().initTestEnvironment(
19
+ BrowserDynamicTestingModule,
20
+ platformBrowserDynamicTesting(),
21
+ );
22
+
23
+ // Then we find all the tests.
24
+ const context = require.context('./', true, /\.spec\.ts$/);
25
+ // And load the modules.
26
+ context.keys().forEach(context);
@@ -0,0 +1,15 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "../../tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "../../out-tsc/app",
6
+ "types": []
7
+ },
8
+ "files": [
9
+ "src/main.ts",
10
+ "src/polyfills.ts"
11
+ ],
12
+ "include": [
13
+ "src/**/*.d.ts"
14
+ ]
15
+ }
@@ -0,0 +1,18 @@
1
+ /* To learn more about this file see: https://angular.io/config/tsconfig. */
2
+ {
3
+ "extends": "../../tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "../../out-tsc/spec",
6
+ "types": [
7
+ "jasmine"
8
+ ]
9
+ },
10
+ "files": [
11
+ "src/test.ts",
12
+ "src/polyfills.ts"
13
+ ],
14
+ "include": [
15
+ "src/**/*.spec.ts",
16
+ "src/**/*.d.ts"
17
+ ]
18
+ }
@@ -0,0 +1,24 @@
1
+ # Gs
2
+
3
+ This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.2.0.
4
+
5
+ ## Code scaffolding
6
+
7
+ Run `ng generate component component-name --project gs` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project gs`.
8
+ > Note: Don't forget to add `--project gs` or else it will be added to the default project in your `angular.json` file.
9
+
10
+ ## Build
11
+
12
+ Run `ng build gs` to build the project. The build artifacts will be stored in the `dist/` directory.
13
+
14
+ ## Publishing
15
+
16
+ After building your library with `ng build gs`, go to the dist folder `cd dist/gs` and run `npm publish`.
17
+
18
+ ## Running unit tests
19
+
20
+ Run `ng test gs` to execute the unit tests via [Karma](https://karma-runner.github.io).
21
+
22
+ ## Further help
23
+
24
+ To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../../dist/angular",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "gridstack-angular",
3
+ "version": "8.1.2",
4
+ "peerDependencies": {
5
+ "@angular/common": "^14.2.0",
6
+ "@angular/core": "^14.2.0"
7
+ },
8
+ "dependencies": {
9
+ "tslib": "^2.3.0"
10
+ }
11
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * gridstack-item.component.ts 8.1.2
3
+ * Copyright (c) 2022 Alain Dumesny - see GridStack root license
4
+ */
5
+
6
+ import { Component, ElementRef, Input, ViewChild, ViewContainerRef, OnDestroy } from '@angular/core';
7
+ import { GridItemHTMLElement, GridStackNode } from 'gridstack';
8
+
9
+ /** store element to Ng Class pointer back */
10
+ export interface GridItemCompHTMLElement extends GridItemHTMLElement {
11
+ _gridItemComp?: GridstackItemComponent;
12
+ }
13
+
14
+ /**
15
+ * HTML Component Wrapper for gridstack items, in combination with GridstackComponent for parent grid
16
+ */
17
+ @Component({
18
+ selector: 'gridstack-item',
19
+ template: `
20
+ <div class="grid-stack-item-content">
21
+ <!-- where dynamic items go based on component types, or sub-grids, etc...) -->
22
+ <ng-template #container></ng-template>
23
+ <!-- any static (defined in dom) content goes here -->
24
+ <ng-content></ng-content>
25
+ <!-- fallback HTML content from GridStackWidget content field if used instead -->
26
+ {{options.content}}
27
+ </div>`,
28
+ styles: [`
29
+ :host { display: block; }
30
+ `],
31
+ // changeDetection: ChangeDetectionStrategy.OnPush, // IFF you want to optimize and control when ChangeDetection needs to happen...
32
+ })
33
+ export class GridstackItemComponent implements OnDestroy {
34
+
35
+ /** container to append items dynamically */
36
+ @ViewChild('container', { read: ViewContainerRef, static: true}) public container?: ViewContainerRef;
37
+
38
+ /** list of options for creating/updating this item */
39
+ @Input() public set options(val: GridStackNode) {
40
+ if (this.el.gridstackNode?.grid) {
41
+ // already built, do an update...
42
+ this.el.gridstackNode.grid.update(this.el, val);
43
+ } else {
44
+ // store our custom element in options so we can update it and not re-create a generic div!
45
+ this._options = {...val, el: this.el};
46
+ }
47
+ }
48
+ /** return the latest grid options (from GS once built, otherwise initial values) */
49
+ public get options(): GridStackNode {
50
+ return this.el.gridstackNode || this._options || {el: this.el};
51
+ }
52
+
53
+ private _options?: GridStackNode;
54
+
55
+ /** return the native element that contains grid specific fields as well */
56
+ public get el(): GridItemCompHTMLElement { return this.elementRef.nativeElement; }
57
+
58
+ /** clears the initial options now that we've built */
59
+ public clearOptions() {
60
+ delete this._options;
61
+ }
62
+
63
+ constructor(private readonly elementRef: ElementRef<GridItemHTMLElement>) {
64
+ this.el._gridItemComp = this;
65
+ }
66
+
67
+ public ngOnDestroy(): void {
68
+ delete this.el._gridItemComp;
69
+ }
70
+ }