gridstack 8.1.1 → 8.2.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/README.md +12 -11
- package/angular/.editorconfig +16 -0
- package/angular/.vscode/extensions.json +4 -0
- package/angular/.vscode/launch.json +20 -0
- package/angular/.vscode/tasks.json +42 -0
- package/{dist/ng → angular}/README.md +170 -154
- package/angular/README_build.md +27 -0
- package/angular/angular.json +132 -0
- package/angular/package.json +40 -0
- package/angular/projects/demo/.browserslistrc +16 -0
- package/angular/projects/demo/src/app/app.component.css +11 -0
- package/angular/projects/demo/src/app/app.component.html +78 -0
- package/angular/projects/demo/src/app/app.component.spec.ts +25 -0
- package/angular/projects/demo/src/app/app.component.ts +208 -0
- package/angular/projects/demo/src/app/app.module.ts +39 -0
- package/angular/projects/demo/src/app/dummy.component.ts +35 -0
- package/angular/projects/demo/src/app/ngFor.ts +131 -0
- package/angular/projects/demo/src/app/ngFor_cmd.ts +106 -0
- package/angular/projects/demo/src/app/simple.ts +46 -0
- package/angular/projects/demo/src/assets/.gitkeep +0 -0
- package/angular/projects/demo/src/environments/environment.prod.ts +3 -0
- package/angular/projects/demo/src/environments/environment.ts +16 -0
- package/angular/projects/demo/src/favicon.ico +0 -0
- package/angular/projects/demo/src/index.html +13 -0
- package/angular/projects/demo/src/main.ts +12 -0
- package/angular/projects/demo/src/polyfills.ts +53 -0
- package/angular/projects/demo/src/styles.css +4 -0
- package/angular/projects/demo/src/test.ts +26 -0
- package/angular/projects/demo/tsconfig.app.json +15 -0
- package/angular/projects/demo/tsconfig.spec.json +18 -0
- package/angular/projects/lib/README.md +24 -0
- package/angular/projects/lib/ng-package.json +7 -0
- package/angular/projects/lib/package.json +11 -0
- package/angular/projects/lib/src/lib/base-widget.ts +28 -0
- package/angular/projects/lib/src/lib/gridstack-item.component.ts +78 -0
- package/angular/projects/lib/src/lib/gridstack.component.ts +287 -0
- package/angular/projects/lib/src/lib/gridstack.module.ts +32 -0
- package/angular/projects/lib/src/public-api.ts +8 -0
- package/angular/projects/lib/src/test.ts +27 -0
- package/angular/projects/lib/tsconfig.lib.json +15 -0
- package/angular/projects/lib/tsconfig.lib.prod.json +10 -0
- package/angular/projects/lib/tsconfig.spec.json +17 -0
- package/dist/angular/README.md +170 -0
- package/dist/angular/esm2020/gridstack-angular.mjs +5 -0
- package/dist/angular/esm2020/lib/base-widget.mjs +30 -0
- package/dist/angular/esm2020/lib/gridstack-item.component.mjs +68 -0
- package/dist/angular/esm2020/lib/gridstack.component.mjs +278 -0
- package/dist/angular/esm2020/lib/gridstack.module.mjs +39 -0
- package/dist/angular/esm2020/public-api.mjs +8 -0
- package/dist/angular/fesm2015/gridstack-angular.mjs +418 -0
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -0
- package/dist/angular/fesm2020/gridstack-angular.mjs +413 -0
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -0
- package/dist/angular/index.d.ts +5 -0
- package/dist/angular/lib/base-widget.d.ts +16 -0
- package/dist/{ng → angular/lib}/gridstack-item.component.d.ts +37 -29
- package/dist/{ng → angular/lib}/gridstack.component.d.ts +129 -118
- package/dist/angular/lib/gridstack.module.d.ts +10 -0
- package/dist/angular/package.json +31 -0
- package/dist/angular/public-api.d.ts +4 -0
- package/dist/angular/src/base-widget.ts +28 -0
- package/dist/angular/src/gridstack-item.component.ts +78 -0
- package/dist/angular/src/gridstack.component.ts +287 -0
- package/dist/angular/src/gridstack.module.ts +32 -0
- 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/es5/dd-base-impl.d.ts +1 -1
- package/dist/es5/dd-base-impl.js +1 -1
- package/dist/es5/dd-base-impl.js.map +1 -1
- package/dist/es5/dd-draggable.d.ts +1 -1
- package/dist/es5/dd-draggable.js +1 -1
- package/dist/es5/dd-draggable.js.map +1 -1
- package/dist/es5/dd-droppable.d.ts +1 -1
- package/dist/es5/dd-droppable.js +1 -1
- package/dist/es5/dd-droppable.js.map +1 -1
- package/dist/es5/dd-element.d.ts +1 -1
- package/dist/es5/dd-element.js +1 -1
- package/dist/es5/dd-element.js.map +1 -1
- package/dist/es5/dd-gridstack.d.ts +1 -1
- package/dist/es5/dd-gridstack.js +1 -1
- package/dist/es5/dd-gridstack.js.map +1 -1
- package/dist/es5/dd-manager.d.ts +1 -1
- package/dist/es5/dd-manager.js +1 -1
- package/dist/es5/dd-manager.js.map +1 -1
- package/dist/es5/dd-resizable-handle.d.ts +1 -1
- package/dist/es5/dd-resizable-handle.js +1 -1
- package/dist/es5/dd-resizable-handle.js.map +1 -1
- package/dist/es5/dd-resizable.d.ts +1 -1
- package/dist/es5/dd-resizable.js +1 -1
- package/dist/es5/dd-resizable.js.map +1 -1
- package/dist/es5/dd-touch.d.ts +1 -1
- package/dist/es5/dd-touch.js +1 -1
- package/dist/es5/dd-touch.js.map +1 -1
- package/dist/es5/gridstack-all.js +1 -1
- package/dist/es5/gridstack-all.js.LICENSE.txt +1 -1
- package/dist/es5/gridstack-all.js.map +1 -1
- package/dist/es5/gridstack-engine.d.ts +1 -1
- package/dist/es5/gridstack-engine.js +1 -1
- package/dist/es5/gridstack-engine.js.map +1 -1
- package/dist/es5/gridstack-poly.js +1 -1
- package/dist/es5/gridstack.d.ts +8 -5
- package/dist/es5/gridstack.js +13 -7
- package/dist/es5/gridstack.js.map +1 -1
- package/dist/es5/types.d.ts +1 -1
- package/dist/es5/types.js +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/es5/utils.d.ts +1 -1
- package/dist/es5/utils.js +1 -1
- package/dist/es5/utils.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 +8 -5
- package/dist/gridstack.js +13 -7
- package/dist/gridstack.js.map +1 -1
- package/dist/src/gridstack-extra.scss +3 -3
- 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 +11 -1
- package/package.json +3 -3
- package/dist/ng/gridstack-item.component.js +0 -65
- package/dist/ng/gridstack-item.component.js.map +0 -1
- package/dist/ng/gridstack.component.js +0 -245
- package/dist/ng/gridstack.component.js.map +0 -1
package/README.md
CHANGED
|
@@ -147,7 +147,7 @@ GridStack no longer requires external dependencies as of v1.0.0 (lodash was remo
|
|
|
147
147
|
|
|
148
148
|
search for ['gridstack' under NPM](https://www.npmjs.com/search?q=gridstack&ranking=popularity) for latest, more to come...
|
|
149
149
|
|
|
150
|
-
- **Angular**: we now ship out of the box with Angular wrapper components - see <a href="https://github.com/gridstack/gridstack.js/tree/master/
|
|
150
|
+
- **Angular**: we now ship out of the box with Angular wrapper components - see <a href="https://github.com/gridstack/gridstack.js/tree/master/angular" target="_blank">Angular Component</a>.
|
|
151
151
|
- **Angular9**: [lb-gridstack](https://github.com/pfms84/lb-gridstack) Note: very old v0.3 gridstack instance so recommend for **concept ONLY if you wish to use directive instead**. teh code has been vented as I use components.
|
|
152
152
|
- **AngularJS**: [gridstack-angular](https://github.com/kdietrich/gridstack-angular)
|
|
153
153
|
- **Ember**: [ember-gridstack](https://github.com/yahoo/ember-gridstack)
|
|
@@ -219,7 +219,7 @@ See example: [2 grids demo](http://gridstack.github.io/gridstack.js/demo/two.htm
|
|
|
219
219
|
|
|
220
220
|
If you need > 12 columns or want to generate the CSS manually you will need to generate CSS rules for `.grid-stack-item[gs-w="X"]` and `.grid-stack-item[gs-x="X"]`.
|
|
221
221
|
|
|
222
|
-
For instance for 4-column grid you need
|
|
222
|
+
For instance for 4-column grid you need CSS to be:
|
|
223
223
|
|
|
224
224
|
```css
|
|
225
225
|
.gs-4 > .grid-stack-item[gs-x="1"] { left: 25% }
|
|
@@ -232,30 +232,31 @@ For instance for 4-column grid you need to write CSS to be:
|
|
|
232
232
|
.gs-4 > .grid-stack-item[gs-w="4"] { width: 100% }
|
|
233
233
|
```
|
|
234
234
|
|
|
235
|
-
Better yet, here is a
|
|
235
|
+
Better yet, here is a SCSS code snippet, you can use sites like [sassmeister.com](https://www.sassmeister.com/) to generate the CSS for you instead:
|
|
236
236
|
|
|
237
|
-
```
|
|
237
|
+
```scss
|
|
238
238
|
$columns: 20;
|
|
239
239
|
@function fixed($float) {
|
|
240
|
-
@return
|
|
240
|
+
@return round($float * 1000) / 1000; // total 2+3 digits being %
|
|
241
241
|
}
|
|
242
242
|
.gs-#{$columns} > .grid-stack-item {
|
|
243
243
|
|
|
244
|
-
width: fixed(
|
|
244
|
+
width: fixed(100% / $columns);
|
|
245
245
|
|
|
246
246
|
@for $i from 1 through $columns - 1 {
|
|
247
|
-
&[gs-x='#{$i}'] { left: fixed(
|
|
248
|
-
&[gs-w='#{$i+1}'] { width: fixed(
|
|
247
|
+
&[gs-x='#{$i}'] { left: fixed((100% / $columns) * $i); }
|
|
248
|
+
&[gs-w='#{$i+1}'] { width: fixed((100% / $columns) * ($i+1)); }
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
```
|
|
252
252
|
|
|
253
|
-
you can also use the
|
|
253
|
+
you can also use the SCSS [src/gridstack-extra.scss](https://github.com/gridstack/gridstack.js/tree/master/src/gridstack-extra.scss) included in NPM package and modify to add more columns.
|
|
254
254
|
|
|
255
255
|
Sample gulp command for 30 columns:
|
|
256
256
|
```js
|
|
257
257
|
gulp.src('node_modules/gridstack/dist/src/gridstack-extra.scss')
|
|
258
|
-
.pipe(replace('$
|
|
258
|
+
.pipe(replace('$start: 2 !default;','$start: 30;'))
|
|
259
|
+
.pipe(replace('$end: 11 !default;','$end: 30;'))
|
|
259
260
|
.pipe(sass({outputStyle: 'compressed'}))
|
|
260
261
|
.pipe(rename({extname: '.min.css'}))
|
|
261
262
|
.pipe(gulp.dest('dist/css'))
|
|
@@ -440,7 +441,7 @@ Possible breaking change if you use nested grid JSON format, or original Angular
|
|
|
440
441
|
* `GridStackOptions.addRemoveCB` -> `GridStack.addRemoveCB` is now global instead of grid option
|
|
441
442
|
* removed `GridStackOptions.dragInOptions` since `GridStack.setupDragIn()` has it replaced since 4.0
|
|
442
443
|
* remove `GridStackOptions.minWidth` obsolete since 5.1, use `oneColumnSize` instead
|
|
443
|
-
* CSS rules removed `.grid-stack` prefix for anything already gs based, 12 column (default) now uses `.
|
|
444
|
+
* CSS rules removed `.grid-stack` prefix for anything already gs based, 12 column (default) now uses `.gs-12`, extra.css is less than 1/4th it original size!, `gs-min|max_w|h` attribute no longer written (but read)
|
|
444
445
|
|
|
445
446
|
# jQuery Application
|
|
446
447
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Editor configuration, see https://editorconfig.org
|
|
2
|
+
root = true
|
|
3
|
+
|
|
4
|
+
[*]
|
|
5
|
+
charset = utf-8
|
|
6
|
+
indent_style = space
|
|
7
|
+
indent_size = 2
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.ts]
|
|
12
|
+
quote_type = single
|
|
13
|
+
|
|
14
|
+
[*.md]
|
|
15
|
+
max_line_length = off
|
|
16
|
+
trim_trailing_whitespace = false
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"configurations": [
|
|
5
|
+
{
|
|
6
|
+
"name": "ng serve",
|
|
7
|
+
"type": "pwa-chrome",
|
|
8
|
+
"request": "launch",
|
|
9
|
+
"preLaunchTask": "npm: start",
|
|
10
|
+
"url": "http://localhost:4200/"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "ng test",
|
|
14
|
+
"type": "chrome",
|
|
15
|
+
"request": "launch",
|
|
16
|
+
"preLaunchTask": "npm: test",
|
|
17
|
+
"url": "http://localhost:9876/debug.html"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"tasks": [
|
|
5
|
+
{
|
|
6
|
+
"type": "npm",
|
|
7
|
+
"script": "start",
|
|
8
|
+
"isBackground": true,
|
|
9
|
+
"problemMatcher": {
|
|
10
|
+
"owner": "typescript",
|
|
11
|
+
"pattern": "$tsc",
|
|
12
|
+
"background": {
|
|
13
|
+
"activeOnStart": true,
|
|
14
|
+
"beginsPattern": {
|
|
15
|
+
"regexp": "(.*?)"
|
|
16
|
+
},
|
|
17
|
+
"endsPattern": {
|
|
18
|
+
"regexp": "bundle generation complete"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"type": "npm",
|
|
25
|
+
"script": "test",
|
|
26
|
+
"isBackground": true,
|
|
27
|
+
"problemMatcher": {
|
|
28
|
+
"owner": "typescript",
|
|
29
|
+
"pattern": "$tsc",
|
|
30
|
+
"background": {
|
|
31
|
+
"activeOnStart": true,
|
|
32
|
+
"beginsPattern": {
|
|
33
|
+
"regexp": "(.*?)"
|
|
34
|
+
},
|
|
35
|
+
"endsPattern": {
|
|
36
|
+
"regexp": "bundle generation complete"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -1,154 +1,170 @@
|
|
|
1
|
-
# Angular wrapper
|
|
2
|
-
|
|
3
|
-
The Angular [wrapper component](
|
|
4
|
-
|
|
5
|
-
# Dynamic grid items
|
|
6
|
-
this is the recommended way if you are going to have multiple grids (alow drag&drop between) or drag from toolbar to create items, or drag to remove items, etc...
|
|
7
|
-
|
|
8
|
-
I.E. don't use Angular templating to create grid items as that is harder to sync when gridstack will also add/remove items.
|
|
9
|
-
|
|
10
|
-
HTML
|
|
11
|
-
```html
|
|
12
|
-
<gridstack [options]="gridOptions">
|
|
13
|
-
</gridstack>
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
1
|
+
# Angular wrapper
|
|
2
|
+
|
|
3
|
+
The Angular [wrapper component](projects/lib/src/lib/gridstack.component.ts) <gridstack> is a better way to use Gridstack, but alternative raw [ngFor](projects/demo/src/app/ngFor.ts) or [simple](projects/demo/src/app/simple.ts) demos are also given.
|
|
4
|
+
|
|
5
|
+
# Dynamic grid items
|
|
6
|
+
this is the recommended way if you are going to have multiple grids (alow drag&drop between) or drag from toolbar to create items, or drag to remove items, etc...
|
|
7
|
+
|
|
8
|
+
I.E. don't use Angular templating to create grid items as that is harder to sync when gridstack will also add/remove items.
|
|
9
|
+
|
|
10
|
+
HTML
|
|
11
|
+
```html
|
|
12
|
+
<gridstack [options]="gridOptions">
|
|
13
|
+
</gridstack>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
CSS
|
|
17
|
+
```css
|
|
18
|
+
@import "gridstack/dist/gridstack.min.css";
|
|
19
|
+
|
|
20
|
+
.grid-stack {
|
|
21
|
+
background: #FAFAD2;
|
|
22
|
+
}
|
|
23
|
+
.grid-stack-item-content {
|
|
24
|
+
text-align: center;
|
|
25
|
+
background-color: #18bc9c;
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
in your module Code
|
|
30
|
+
```ts
|
|
31
|
+
import { GridstackModule } from 'gridstack/dist/angular';
|
|
32
|
+
|
|
33
|
+
@NgModule({
|
|
34
|
+
imports: [GridstackModule, ...]
|
|
35
|
+
...
|
|
36
|
+
bootstrap: [AppComponent]
|
|
37
|
+
})
|
|
38
|
+
export class AppModule { }
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Component Code
|
|
42
|
+
```ts
|
|
43
|
+
import { GridStackOptions } from 'gridstack';
|
|
44
|
+
|
|
45
|
+
// sample grid options + items to load...
|
|
46
|
+
public gridOptions: GridStackOptions = {
|
|
47
|
+
margin: 5,
|
|
48
|
+
float: true,
|
|
49
|
+
children: [ // or call load()/addWidget() with same data
|
|
50
|
+
{x:0, y:0, minW:2, content:'Item 1'},
|
|
51
|
+
{x:1, y:1, content:'Item 2'},
|
|
52
|
+
{x:2, y:2, content:'Item 3'},
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
# More Complete example
|
|
58
|
+
In this example (build on previous one) will use your actual custom angular components inside each grid item (instead of dummy html content)
|
|
59
|
+
|
|
60
|
+
HTML
|
|
61
|
+
```html
|
|
62
|
+
<gridstack [options]="gridOptions" (changeCB)="onChange($event)">
|
|
63
|
+
<div empty-content>message when grid is empty</div>
|
|
64
|
+
</gridstack>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Code
|
|
68
|
+
```ts
|
|
69
|
+
import { Component } from '@angular/core';
|
|
70
|
+
import { GridStack, GridStackOptions } from 'gridstack';
|
|
71
|
+
import { GridstackComponent, gsCreateNgComponents, NgGridStackWidget, nodesCB } from 'gridstack/dist/angular';
|
|
72
|
+
|
|
73
|
+
// some custom components
|
|
74
|
+
@Component({
|
|
75
|
+
selector: 'app-a',
|
|
76
|
+
template: 'Comp A', // your real ng content goes in each component instead...
|
|
77
|
+
})
|
|
78
|
+
export class AComponent {
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Component({
|
|
82
|
+
selector: 'app-b',
|
|
83
|
+
template: 'Comp B',
|
|
84
|
+
})
|
|
85
|
+
export class BComponent {
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// .... in your module for example
|
|
89
|
+
constructor() {
|
|
90
|
+
// register all our dynamic components types created by the grid
|
|
91
|
+
GridstackComponent.addComponentToSelectorType([AComponent, BComponent]);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// now our content will use Components instead of dummy html content
|
|
95
|
+
public gridOptions: NgGridStackOptions = {
|
|
96
|
+
margin: 5,
|
|
97
|
+
float: true,
|
|
98
|
+
minRow: 1, // make space for empty message
|
|
99
|
+
children: [ // or call load()/addWidget() with same data
|
|
100
|
+
{x:0, y:0, minW:2, type:'app-a'},
|
|
101
|
+
{x:1, y:1, type:'app-b'},
|
|
102
|
+
{x:2, y:2, content:'plain html content'},
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// called whenever items change size/position/etc.. see other events
|
|
107
|
+
public onChange(data: nodesCB) {
|
|
108
|
+
console.log('change ', data.nodes.length > 1 ? data.nodes : data.nodes[0]);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
# ngFor with wrapper
|
|
113
|
+
For simple case where you control the children creation (gridstack doesn't do create or re-parenting)
|
|
114
|
+
|
|
115
|
+
HTML
|
|
116
|
+
```html
|
|
117
|
+
<gridstack [options]="gridOptions" (changeCB)="onChange($event)">
|
|
118
|
+
<gridstack-item *ngFor="let n of items; trackBy: identify" [options]="n">
|
|
119
|
+
Item {{n.id}}
|
|
120
|
+
</gridstack-item>
|
|
121
|
+
</gridstack>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Code
|
|
125
|
+
```javascript
|
|
126
|
+
import { GridStackOptions, GridStackWidget } from 'gridstack';
|
|
127
|
+
import { nodesCB } from 'gridstack/dist/angular';
|
|
128
|
+
|
|
129
|
+
/** sample grid options and items to load... */
|
|
130
|
+
public gridOptions: GridStackOptions = {
|
|
131
|
+
margin: 5,
|
|
132
|
+
float: true,
|
|
133
|
+
}
|
|
134
|
+
public items: GridStackWidget[] = [
|
|
135
|
+
{x:0, y:0, minW:2, id:'1'}, // must have unique id used for trackBy
|
|
136
|
+
{x:1, y:1, id:'2'},
|
|
137
|
+
{x:2, y:2, id:'3'},
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
// called whenever items change size/position/etc..
|
|
141
|
+
public onChange(data: nodesCB) {
|
|
142
|
+
console.log('change ', data.nodes.length > 1 ? data.nodes : data.nodes[0]);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ngFor unique node id to have correct match between our items used and GS
|
|
146
|
+
public identify(index: number, w: GridStackWidget) {
|
|
147
|
+
return w.id; // or use index if no id is set and you only modify at the end...
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Demo
|
|
152
|
+
You can see a fuller example at [app.component.ts](src/app/app.component.ts)
|
|
153
|
+
|
|
154
|
+
to build the demo, go to angular/projects/demo and run `yarn` + `yarn start` and navigate to `http://localhost:4200/`
|
|
155
|
+
|
|
156
|
+
Code now shipped starting with v8.1.2+ in `dist/angular` for people to use directly! (source code under `dist/angular/src`)
|
|
157
|
+
## Caveats
|
|
158
|
+
|
|
159
|
+
- This wrapper needs:
|
|
160
|
+
- gridstack v8 to run as it needs the latest changes (use older version that matches GS versions)
|
|
161
|
+
- Angular 13+ for dynamic createComponent() API
|
|
162
|
+
|
|
163
|
+
## *ngFor Caveats
|
|
164
|
+
- This wrapper handles well ngFor loops, but if you're using a trackBy function (as I would recommend) and no element id change after an update,
|
|
165
|
+
you must manually update the `GridstackItemComponent.option` directly - see [modifyNgFor()](src/app/app.component.ts#L174) example.
|
|
166
|
+
- The original client list of items is not updated to match **content** changes made by gridstack (TBD later), but adding new item or removing (as shown in demo) will update those new items. Client could use change/added/removed events to sync that list if they wish to do so.
|
|
167
|
+
|
|
168
|
+
Would appreciate getting help doing the same for React and Vue (2 other popular frameworks)
|
|
169
|
+
|
|
170
|
+
-Alain
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# GridstackLib
|
|
2
|
+
|
|
3
|
+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.2.10.
|
|
4
|
+
|
|
5
|
+
## Development server
|
|
6
|
+
|
|
7
|
+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
|
|
8
|
+
|
|
9
|
+
## Code scaffolding
|
|
10
|
+
|
|
11
|
+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
|
12
|
+
|
|
13
|
+
## Build
|
|
14
|
+
|
|
15
|
+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
|
|
16
|
+
|
|
17
|
+
## Running unit tests
|
|
18
|
+
|
|
19
|
+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
|
20
|
+
|
|
21
|
+
## Running end-to-end tests
|
|
22
|
+
|
|
23
|
+
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
|
|
24
|
+
|
|
25
|
+
## Further help
|
|
26
|
+
|
|
27
|
+
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,132 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
|
3
|
+
"version": 1,
|
|
4
|
+
"newProjectRoot": "projects",
|
|
5
|
+
"projects": {
|
|
6
|
+
"lib": {
|
|
7
|
+
"projectType": "library",
|
|
8
|
+
"root": "projects/lib",
|
|
9
|
+
"sourceRoot": "projects/lib/src",
|
|
10
|
+
"prefix": "lib",
|
|
11
|
+
"architect": {
|
|
12
|
+
"build": {
|
|
13
|
+
"builder": "@angular-devkit/build-angular:ng-packagr",
|
|
14
|
+
"options": {
|
|
15
|
+
"project": "projects/lib/ng-package.json"
|
|
16
|
+
},
|
|
17
|
+
"configurations": {
|
|
18
|
+
"production": {
|
|
19
|
+
"tsConfig": "projects/lib/tsconfig.lib.prod.json"
|
|
20
|
+
},
|
|
21
|
+
"development": {
|
|
22
|
+
"tsConfig": "projects/lib/tsconfig.lib.json"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"defaultConfiguration": "production"
|
|
26
|
+
},
|
|
27
|
+
"test": {
|
|
28
|
+
"builder": "@angular-devkit/build-angular:karma",
|
|
29
|
+
"options": {
|
|
30
|
+
"main": "projects/lib/src/test.ts",
|
|
31
|
+
"tsConfig": "projects/lib/tsconfig.spec.json",
|
|
32
|
+
"karmaConfig": "projects/lib/karma.conf.js"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"demo": {
|
|
38
|
+
"projectType": "application",
|
|
39
|
+
"schematics": {},
|
|
40
|
+
"root": "projects/demo",
|
|
41
|
+
"sourceRoot": "projects/demo/src",
|
|
42
|
+
"prefix": "app",
|
|
43
|
+
"architect": {
|
|
44
|
+
"build": {
|
|
45
|
+
"builder": "@angular-devkit/build-angular:browser",
|
|
46
|
+
"options": {
|
|
47
|
+
"outputPath": "dist/demo",
|
|
48
|
+
"index": "projects/demo/src/index.html",
|
|
49
|
+
"main": "projects/demo/src/main.ts",
|
|
50
|
+
"polyfills": "projects/demo/src/polyfills.ts",
|
|
51
|
+
"tsConfig": "projects/demo/tsconfig.app.json",
|
|
52
|
+
"assets": [
|
|
53
|
+
"projects/demo/src/favicon.ico",
|
|
54
|
+
"projects/demo/src/assets"
|
|
55
|
+
],
|
|
56
|
+
"styles": [
|
|
57
|
+
"projects/demo/src/styles.css"
|
|
58
|
+
],
|
|
59
|
+
"scripts": []
|
|
60
|
+
},
|
|
61
|
+
"configurations": {
|
|
62
|
+
"production": {
|
|
63
|
+
"budgets": [
|
|
64
|
+
{
|
|
65
|
+
"type": "initial",
|
|
66
|
+
"maximumWarning": "500kb",
|
|
67
|
+
"maximumError": "1mb"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"type": "anyComponentStyle",
|
|
71
|
+
"maximumWarning": "2kb",
|
|
72
|
+
"maximumError": "4kb"
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
"fileReplacements": [
|
|
76
|
+
{
|
|
77
|
+
"replace": "projects/demo/src/environments/environment.ts",
|
|
78
|
+
"with": "projects/demo/src/environments/environment.prod.ts"
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"outputHashing": "all"
|
|
82
|
+
},
|
|
83
|
+
"development": {
|
|
84
|
+
"buildOptimizer": false,
|
|
85
|
+
"optimization": false,
|
|
86
|
+
"vendorChunk": true,
|
|
87
|
+
"extractLicenses": false,
|
|
88
|
+
"sourceMap": true,
|
|
89
|
+
"namedChunks": true
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"defaultConfiguration": "production"
|
|
93
|
+
},
|
|
94
|
+
"serve": {
|
|
95
|
+
"builder": "@angular-devkit/build-angular:dev-server",
|
|
96
|
+
"configurations": {
|
|
97
|
+
"production": {
|
|
98
|
+
"browserTarget": "demo:build:production"
|
|
99
|
+
},
|
|
100
|
+
"development": {
|
|
101
|
+
"browserTarget": "demo:build:development"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"defaultConfiguration": "development"
|
|
105
|
+
},
|
|
106
|
+
"extract-i18n": {
|
|
107
|
+
"builder": "@angular-devkit/build-angular:extract-i18n",
|
|
108
|
+
"options": {
|
|
109
|
+
"browserTarget": "demo:build"
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"test": {
|
|
113
|
+
"builder": "@angular-devkit/build-angular:karma",
|
|
114
|
+
"options": {
|
|
115
|
+
"main": "projects/demo/src/test.ts",
|
|
116
|
+
"polyfills": "projects/demo/src/polyfills.ts",
|
|
117
|
+
"tsConfig": "projects/demo/tsconfig.spec.json",
|
|
118
|
+
"karmaConfig": "projects/demo/karma.conf.js",
|
|
119
|
+
"assets": [
|
|
120
|
+
"projects/demo/src/favicon.ico",
|
|
121
|
+
"projects/demo/src/assets"
|
|
122
|
+
],
|
|
123
|
+
"styles": [
|
|
124
|
+
"projects/demo/src/styles.css"
|
|
125
|
+
],
|
|
126
|
+
"scripts": []
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|