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.
- package/README.md +26 -38
- 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 +38 -0
- package/angular/projects/demo/src/app/dummy.component.ts +29 -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/gridstack-item.component.ts +70 -0
- package/angular/projects/lib/src/lib/gridstack.component.ts +240 -0
- package/angular/projects/lib/src/lib/gridstack.module.ts +32 -0
- package/angular/projects/lib/src/public-api.ts +7 -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/gridstack-item.component.mjs +67 -0
- package/dist/angular/esm2020/lib/gridstack.component.mjs +233 -0
- package/dist/angular/esm2020/lib/gridstack.module.mjs +39 -0
- package/dist/angular/esm2020/public-api.mjs +7 -0
- package/dist/angular/fesm2015/gridstack-angular.mjs +346 -0
- package/dist/angular/fesm2015/gridstack-angular.mjs.map +1 -0
- package/dist/angular/fesm2020/gridstack-angular.mjs +342 -0
- package/dist/angular/fesm2020/gridstack-angular.mjs.map +1 -0
- package/dist/angular/index.d.ts +5 -0
- package/dist/{ng → angular/lib}/gridstack-item.component.d.ts +32 -29
- package/dist/{ng → angular/lib}/gridstack.component.d.ts +121 -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 +3 -0
- package/dist/angular/src/gridstack-item.component.ts +70 -0
- package/dist/angular/src/gridstack.component.ts +240 -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 +1 -1
- package/dist/es5/gridstack.js +9 -10
- 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-extra.css +130 -130
- package/dist/gridstack-extra.min.css +1 -1
- package/dist/gridstack.css +29 -31
- package/dist/gridstack.d.ts +1 -1
- package/dist/gridstack.js +9 -10
- package/dist/gridstack.js.map +1 -1
- package/dist/gridstack.min.css +1 -1
- package/dist/src/gridstack-extra.scss +5 -5
- package/dist/src/gridstack.scss +7 -10
- 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 +10 -2
- 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,8 +147,8 @@ 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/
|
|
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**.
|
|
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
|
+
- **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)
|
|
154
154
|
- **knockout**: see [demo](https://gridstackjs.com/demo/knockout.html) using component, but check [custom bindings ticket](https://github.com/gridstack/gridstack.js/issues/465) which is likely better approach.
|
|
@@ -219,56 +219,44 @@ 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
|
|
222
|
+
For instance for 4-column grid you need CSS to be:
|
|
223
223
|
|
|
224
224
|
```css
|
|
225
|
-
.grid-stack-item[gs-
|
|
226
|
-
.grid-stack-item[gs-
|
|
227
|
-
.grid-stack-item[gs-
|
|
228
|
-
|
|
229
|
-
.grid-stack-item
|
|
230
|
-
.grid-stack-item[gs-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
For 4-column grid it should be:
|
|
234
|
-
|
|
235
|
-
```css
|
|
236
|
-
.grid-stack-item[gs-w="4"] { width: 100% }
|
|
237
|
-
.grid-stack-item[gs-w="3"] { width: 75% }
|
|
238
|
-
.grid-stack-item[gs-w="2"] { width: 50% }
|
|
239
|
-
.grid-stack-item[gs-w="1"] { width: 25% }
|
|
240
|
-
|
|
241
|
-
.grid-stack-item[gs-x="3"] { left: 75% }
|
|
242
|
-
.grid-stack-item[gs-x="2"] { left: 50% }
|
|
243
|
-
.grid-stack-item[gs-x="1"] { left: 25% }
|
|
225
|
+
.gs-4 > .grid-stack-item[gs-x="1"] { left: 25% }
|
|
226
|
+
.gs-4 > .grid-stack-item[gs-x="2"] { left: 50% }
|
|
227
|
+
.gs-4 > .grid-stack-item[gs-x="3"] { left: 75% }
|
|
228
|
+
|
|
229
|
+
.gs-4 > .grid-stack-item { width: 25% }
|
|
230
|
+
.gs-4 > .grid-stack-item[gs-w="2"] { width: 50% }
|
|
231
|
+
.gs-4 > .grid-stack-item[gs-w="3"] { width: 75% }
|
|
232
|
+
.gs-4 > .grid-stack-item[gs-w="4"] { width: 100% }
|
|
244
233
|
```
|
|
245
234
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
Better yet, here is a SASS code snippet, you can use sites like [sassmeister.com](https://www.sassmeister.com/) to generate the CSS for you instead:
|
|
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:
|
|
249
236
|
|
|
250
|
-
```
|
|
251
|
-
$columns:
|
|
237
|
+
```scss
|
|
238
|
+
$columns: 20;
|
|
252
239
|
@function fixed($float) {
|
|
253
|
-
@return
|
|
240
|
+
@return round($float * 1000) / 1000; // total 2+3 digits being %
|
|
254
241
|
}
|
|
255
|
-
.
|
|
242
|
+
.gs-#{$columns} > .grid-stack-item {
|
|
256
243
|
|
|
257
|
-
|
|
244
|
+
width: fixed(100% / $columns);
|
|
258
245
|
|
|
259
246
|
@for $i from 1 through $columns - 1 {
|
|
260
|
-
&[gs-x='#{$i}'] { left: fixed(
|
|
261
|
-
&[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)); }
|
|
262
249
|
}
|
|
263
250
|
}
|
|
264
251
|
```
|
|
265
252
|
|
|
266
|
-
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.
|
|
267
254
|
|
|
268
255
|
Sample gulp command for 30 columns:
|
|
269
256
|
```js
|
|
270
257
|
gulp.src('node_modules/gridstack/dist/src/gridstack-extra.scss')
|
|
271
|
-
.pipe(replace('$
|
|
258
|
+
.pipe(replace('$start: 2 !default;','$start: 30;'))
|
|
259
|
+
.pipe(replace('$end: 11 !default;','$end: 30;'))
|
|
272
260
|
.pipe(sass({outputStyle: 'compressed'}))
|
|
273
261
|
.pipe(rename({extname: '.min.css'}))
|
|
274
262
|
.pipe(gulp.dest('dist/css'))
|
|
@@ -449,11 +437,11 @@ New addition, no API breakage per say. See release notes about creating sub-grid
|
|
|
449
437
|
## Migrating to v8
|
|
450
438
|
|
|
451
439
|
Possible breaking change if you use nested grid JSON format, or original Angular wrapper, or relied on specific CSS paths. Also target is now ES2020 (see release notes).
|
|
452
|
-
* `GridStackOptions.subGrid` -> `GridStackOptions.subGridOpts` rename
|
|
453
|
-
* We now have `GridStackWidget.subGridOpts` vs `GridStackNode.subGrid` (was `subGrid` with both types which is error prone)
|
|
440
|
+
* `GridStackOptions.subGrid` -> `GridStackOptions.subGridOpts` rename. We now have `GridStackWidget.subGridOpts` vs `GridStackNode.subGrid` (was both types which is error prone)
|
|
454
441
|
* `GridStackOptions.addRemoveCB` -> `GridStack.addRemoveCB` is now global instead of grid option
|
|
455
|
-
* removed `GridStackOptions.dragInOptions` since `setupDragIn()`has it replaced since 4.0
|
|
442
|
+
* removed `GridStackOptions.dragInOptions` since `GridStack.setupDragIn()` has it replaced since 4.0
|
|
456
443
|
* remove `GridStackOptions.minWidth` obsolete since 5.1, use `oneColumnSize` instead
|
|
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)
|
|
457
445
|
|
|
458
446
|
# jQuery Application
|
|
459
447
|
|
|
@@ -501,4 +489,4 @@ View our change log [here](https://github.com/gridstack/gridstack.js/tree/master
|
|
|
501
489
|
|
|
502
490
|
# The Team
|
|
503
491
|
|
|
504
|
-
gridstack.js is currently maintained by [Alain Dumesny](https://github.com/adumesny)
|
|
492
|
+
gridstack.js is currently maintained by [Alain Dumesny](https://github.com/adumesny), before that [Dylan Weiss](https://github.com/radiolips), originally created by [Pavel Reznikov](https://github.com/troolee). We appreciate [all contributors](https://github.com/gridstack/gridstack.js/graphs/contributors) for help.
|
|
@@ -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.
|