Skip to content

Commit 09efe86

Browse files
authored
Merge branch 'gridstack:master' into master
2 parents a5b662e + 90a014d commit 09efe86

40 files changed

+262
-166
lines changed

Diff for: ISSUE_TEMPLATE.md renamed to .github/ISSUE_TEMPLATE/bug_report.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
---
2+
name: Bug report
3+
about: bug report
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
110
## Subject of the issue
211
Describe your issue here.
312
If unsure if lib bug, use slack channel instead: https://join.slack.com/t/gridstackjs/shared_invite/zt-2qa21lnxz-vw29RdTFet3N6~ABqT9kwA

Diff for: README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -472,20 +472,20 @@ breaking change:
472472
473473
**Breaking change:**
474474
475-
* if you code relies on `GridStackWidget.content` with real HTML (like a few demos) it is up to you to do this:
475+
* if your code relies on `GridStackWidget.content` with real HTML (like a few demos) it is up to you to do this:
476476
```ts
477477
// NOTE: REAL apps would sanitize-html or DOMPurify before blinding setting innerHTML. see #2736
478-
GridStack.renderCB = function(el, w) {
478+
GridStack.renderCB = function(el: HTMLElement, w: GridStackNode) {
479479
el.innerHTML = w.content;
480480
};
481481
```
482482
* V11 add new `GridStack.renderCB` that is called for you to create the widget content (entire GridStackWidget is passed so you can use id or some other field as logic) while GS creates the 2 needed parent divs + classes, unlike `GridStack.addRemoveCB` which doesn't create anything for you. Both can be handy for Angular/React/Vue frameworks.
483-
* `addWidget(w: GridStackWidget)` is now the only supported format, no more string content passing. You will need to create content yourself (`Util.createWidgetDivs()` can be used to create parent divs) then call `makeWidget(el)` instead.
483+
* `addWidget(w: GridStackWidget)` is now the only supported format, no more string content passing. You will need to create content yourself (`GridStack.createWidgetDivs()` can be used to create parent divs) then call `makeWidget(el)` instead.
484484
485485
**Potential breaking change:**
486486
487487
* BIG overall to how sidepanel helper drag&drop is done:
488-
1. `clone()` helper is now passed full HTML element dragged, not an event on `grid-stack-item-content` so can clone or set attr at the top.
488+
1. `clone()` helper is now passed full HTML element dragged, not an event on `grid-stack-item-content` so you can clone or set attr at the top.
489489
2. use any class/structure you want for side panel items (see two.html)
490490
3. `GridStack.setupDragIn()` now support associating a `GridStackWidget` for each sidepanel that will be used to define what to create on drop!
491491
4. if no `GridStackWidget` is defined, the helper will now be inserted as is, and NOT original sidepanel item.

Diff for: angular/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ this is the recommended way if you are going to have multiple grids (alow drag&d
88

99
I.E. don't use Angular templating to create grid items as that is harder to sync when gridstack will also add/remove items.
1010

11-
HTML
11+
MyComponent HTML
1212

1313
```html
1414
<gridstack [options]="gridOptions"></gridstack>
1515
```
1616

17-
CSS
17+
MyComponent CSS
1818

1919
```css
2020
@import "gridstack/dist/gridstack.min.css";
@@ -30,7 +30,7 @@ CSS
3030
```
3131

3232

33-
Standalone Component Code
33+
Standalone MyComponent Code
3434

3535
```ts
3636
import { GridStackOptions } from 'gridstack';
@@ -47,7 +47,7 @@ export class MyComponent {
4747
// sample grid options + items to load...
4848
public gridOptions: GridStackOptions = {
4949
margin: 5,
50-
children: [ // or call load()/addWidget() with same data
50+
children: [ // or call load(children) or addWidget(children[0]) with same data
5151
{x:0, y:0, minW:2, content:'Item 1'},
5252
{x:1, y:0, content:'Item 2'},
5353
{x:0, y:1, content:'Item 3'},

Diff for: angular/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@angular/platform-browser": "^14",
1919
"@angular/platform-browser-dynamic": "^14",
2020
"@angular/router": "^14",
21-
"gridstack": "^11.3.0",
21+
"gridstack": "^11.4.0",
2222
"rxjs": "~7.5.0",
2323
"tslib": "^2.3.0",
2424
"zone.js": "~0.11.4"

Diff for: angular/projects/lib/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* Public API Surface of gridstack-angular
33
*/
44

5+
export * from './lib/types';
6+
export * from './lib/base-widget';
57
export * from './lib/gridstack-item.component';
68
export * from './lib/gridstack.component';
7-
export * from './lib/base-widget';
89
export * from './lib/gridstack.module';

Diff for: angular/projects/lib/src/lib/base-widget.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* gridstack-item.component.ts 11.3.0-dev
2+
* gridstack-item.component.ts 11.4.0-dev
33
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
44
*/
55

@@ -8,7 +8,7 @@
88
*/
99

1010
import { Injectable } from '@angular/core';
11-
import { NgCompInputs, NgGridStackWidget } from './gridstack.component';
11+
import { NgCompInputs, NgGridStackWidget } from './types';
1212

1313
@Injectable()
1414
export abstract class BaseWidget {

Diff for: angular/projects/lib/src/lib/gridstack-item.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* gridstack-item.component.ts 11.3.0-dev
2+
* gridstack-item.component.ts 11.4.0-dev
33
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
44
*/
55

Diff for: angular/projects/lib/src/lib/gridstack.component.ts

+3-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* gridstack.component.ts 11.3.0-dev
2+
* gridstack.component.ts 11.4.0-dev
33
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
44
*/
55

@@ -9,34 +9,16 @@ import { NgIf } from '@angular/common';
99
import { Subscription } from 'rxjs';
1010
import { GridHTMLElement, GridItemHTMLElement, GridStack, GridStackNode, GridStackOptions, GridStackWidget } from 'gridstack';
1111

12-
import { GridItemCompHTMLElement, GridstackItemComponent } from './gridstack-item.component';
12+
import { NgGridStackNode, NgGridStackWidget } from './types';
1313
import { BaseWidget } from './base-widget';
14+
import { GridItemCompHTMLElement, GridstackItemComponent } from './gridstack-item.component';
1415

1516
/** events handlers emitters signature for different events */
1617
export type eventCB = {event: Event};
1718
export type elementCB = {event: Event, el: GridItemHTMLElement};
1819
export type nodesCB = {event: Event, nodes: GridStackNode[]};
1920
export type droppedCB = {event: Event, previousNode: GridStackNode, newNode: GridStackNode};
2021

21-
export type NgCompInputs = {[key: string]: any};
22-
23-
/** extends to store Ng Component selector, instead/inAddition to content */
24-
export interface NgGridStackWidget extends GridStackWidget {
25-
/** Angular tag selector for this component to create at runtime */
26-
selector?: string;
27-
/** serialized data for the component input fields */
28-
input?: NgCompInputs;
29-
/** nested grid options */
30-
subGridOpts?: NgGridStackOptions;
31-
}
32-
export interface NgGridStackNode extends GridStackNode {
33-
selector?: string; // component type to create as content
34-
}
35-
export interface NgGridStackOptions extends GridStackOptions {
36-
children?: NgGridStackWidget[];
37-
subGridOpts?: NgGridStackOptions;
38-
}
39-
4022
/** store element to Ng Class pointer back */
4123
export interface GridCompHTMLElement extends GridHTMLElement {
4224
_gridComp?: GridstackComponent;

Diff for: angular/projects/lib/src/lib/gridstack.module.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
/**
2-
* gridstack.component.ts 11.3.0-dev
2+
* gridstack.component.ts 11.4.0-dev
33
* Copyright (c) 2022-2024 Alain Dumesny - see GridStack root license
44
*/
55

66
import { NgModule } from "@angular/core";
77

8-
import { GridstackComponent } from "./gridstack.component";
98
import { GridstackItemComponent } from "./gridstack-item.component";
9+
import { GridstackComponent } from "./gridstack.component";
1010

1111
// @deprecated use GridstackComponent and GridstackItemComponent as standalone components
1212
@NgModule({
1313
imports: [
14-
GridstackComponent,
1514
GridstackItemComponent,
15+
GridstackComponent,
1616
],
1717
exports: [
18-
GridstackComponent,
1918
GridstackItemComponent,
19+
GridstackComponent,
2020
],
2121
})
2222
export class GridstackModule {}

Diff for: angular/projects/lib/src/lib/types.ts

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* gridstack-item.component.ts 11.4.0-dev
3+
* Copyright (c) 2025 Alain Dumesny - see GridStack root license
4+
*/
5+
6+
import { GridStackNode, GridStackOptions, GridStackWidget } from "gridstack";
7+
8+
/** extends to store Ng Component selector, instead/inAddition to content */
9+
export interface NgGridStackWidget extends GridStackWidget {
10+
/** Angular tag selector for this component to create at runtime */
11+
selector?: string;
12+
/** serialized data for the component input fields */
13+
input?: NgCompInputs;
14+
/** nested grid options */
15+
subGridOpts?: NgGridStackOptions;
16+
}
17+
18+
export interface NgGridStackNode extends GridStackNode {
19+
selector?: string; // component type to create as content
20+
}
21+
22+
export interface NgGridStackOptions extends GridStackOptions {
23+
children?: NgGridStackWidget[];
24+
subGridOpts?: NgGridStackOptions;
25+
}
26+
27+
export type NgCompInputs = {[key: string]: any};

Diff for: angular/yarn.lock

+7-7
Original file line numberDiff line numberDiff line change
@@ -3752,10 +3752,10 @@ graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.4,
37523752
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
37533753
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
37543754

3755-
gridstack@^11.3.0:
3756-
version "11.3.0"
3757-
resolved "https://registry.yarnpkg.com/gridstack/-/gridstack-11.3.0.tgz#b110c66bafc64c920fc54933e2c9df4f7b2cfffe"
3758-
integrity sha512-Z0eRovKcZTRTs3zetJwjO6CNwrgIy845WfOeZGk8ybpeMCE8fMA8tScyKU72Y2M6uGHkjgwnjflglvPiv+RcBQ==
3755+
gridstack@^11.4.0:
3756+
version "11.4.0"
3757+
resolved "https://registry.yarnpkg.com/gridstack/-/gridstack-11.4.0.tgz#5d98a471c90a3e8c478382ac71f5a63551eb83c4"
3758+
integrity sha512-V1faqcHZjbXODt/cMg8a0aIN1uqqR4R5lENTls3sP8vbArvHrYAa9UPzzJWR6+RqPMLxmFG/OG2Evnmu/XOE9A==
37593759

37603760
handle-thing@^2.0.0:
37613761
version "2.0.1"
@@ -6143,9 +6143,9 @@ send@0.19.0:
61436143
statuses "2.0.1"
61446144

61456145
serialize-javascript@^6.0.0, serialize-javascript@^6.0.1:
6146-
version "6.0.1"
6147-
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.1.tgz#b206efb27c3da0b0ab6b52f48d170b7996458e5c"
6148-
integrity sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==
6146+
version "6.0.2"
6147+
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2"
6148+
integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==
61496149
dependencies:
61506150
randombytes "^2.1.0"
61516151

Diff for: demo/demo.css

+11
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,17 @@ h1 {
5353
text-align: center;
5454
background-color: #18bc9c;
5555
}
56+
57+
.card-header {
58+
margin: 0;
59+
cursor: move;
60+
min-height: 25px;
61+
background-color: #16af91;
62+
}
63+
.card-header:hover {
64+
background-color: #149b80;
65+
}
66+
5667
.ui-draggable-disabled.ui-resizable-disabled > .grid-stack-item-content {
5768
background-color: #777;
5869
}

Diff for: demo/index.html

+3-8
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,9 @@ <h1>Demos</h1>
4747
</ul>
4848
<h1>Angular wrapper</h1>
4949
<p>We now ship an <a href="https://github.com/gridstack/gridstack.js/tree/master/angular/" target="_blank">Angular Component</a>
50-
to make it supper easy for that framework (Vue and React examples are above)</p>
51-
<p>These are complete Angular projects with multiple options. use `yarn` and `yarn start` in <a href="https://github.com/gridstack/gridstack.js/tree/master/angular/projects/demo" target="_blank">angular demo</a> sub-project to run them</p>
52-
<ol>
53-
<li><a href="../angular/projects/demo/src/app/simple.ts">simple.ts</a></li>
54-
<li><a href="../angular/projects/demo/src/app/ngFor.ts">ngFor.ts</a></li>
55-
<li><a href="../angular/projects/demo/src/app/ngFor_cmd.ts">ngFor with command</a> (not recommended)</li>
56-
<li><a href="../angular/projects/lib/src/lib/gridstack.component.ts">gridstack.component.ts</a> and <a href="../angular/projects/lib/src/lib/gridstack-item.component.ts">gridstack-item.component.ts</a> (BEST)</li>
57-
</ol>
50+
to make it supper easy for that framework</p>
51+
<h1>React wrapper</h1>
52+
<p>React original examples are shown above, but upcoming and better TS based <a href="https://github.com/gridstack/gridstack.js/tree/master/react/" target="_blank">/react</a> folder (working to make that official and ship it) should be looked at instead. </p>
5853
<h1>Old v5.1.1 Jquery Demos</h1>
5954
Note: those are no longer supported, and use an old version of the lib to compare functionality.
6055
<ul>

Diff for: demo/lazy_load.html

+12-4
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,36 @@
88

99
<link rel="stylesheet" href="demo.css"/>
1010
<script src="../dist/gridstack-all.js"></script>
11-
1211
</head>
1312
<body>
1413
<div>
15-
<h1>Lazy loading demo</h1>
14+
<h1>Lazy loading + renderCB demo</h1>
1615
<p>New V11 GridStackWidget.lazyLoad feature. open console and see widget content (or angular components) created as they become visible.</p>
1716
<div style="height: 300px; overflow-y: auto">
1817
<div class="grid-stack"></div>
1918
</div>
2019
</div>
2120
<script type="text/javascript">
22-
// print when widgets are created
21+
// print when widgets are created, verify dragging by newly added content
2322
GridStack.renderCB = function(el, w) {
24-
el.textContent = w.content;
23+
const title = document.createElement('h3');
24+
title.textContent = 'Drag me by title';
25+
title.className = 'card-header';
26+
el.appendChild(title);
27+
const div = document.createElement('div');
28+
div.textContent = w.id;
29+
el.appendChild(div);
2530
console.log('created node id ', w.id);
2631
};
32+
2733
let children = [];
2834
for (let y = 0; y <= 5; y++) children.push({x:0, y, id:String(y), content: String(y)});
35+
2936
let grid = GridStack.init({
3037
cellHeight: 200,
3138
children,
3239
lazyLoad: true, // delay creation until visible
40+
handle: '.card-header',
3341
});
3442
</script>
3543
</body>

Diff for: demo/sizeToContent.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ <h1>sizeToContent options demo</h1>
109109
grid.addWidget({content: `<div>New: ${text}</div>`});
110110
}
111111
function makeWidget() {
112-
let el = GridStack.Utils.createWidgetDivs(undefined, {content: `<div>New Make: ${text}</div>`}, grid.el)
112+
let el = grid.createWidgetDivs({content: `<div>New Make: ${text}</div>`}, grid.el)
113113
grid.makeWidget(el, {w:2});
114114
}
115115
function more() {

Diff for: demo/title_drag.html

-13
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,6 @@
88

99
<link rel="stylesheet" href="demo.css"/>
1010
<script src="../dist/gridstack-all.js"></script>
11-
<style type="text/css">
12-
.card-header {
13-
cursor: move;
14-
min-height: 25px;
15-
}
16-
.card-header:hover {
17-
background-color: rgba(0,0,0,0.1);
18-
}
19-
.card {
20-
text-align: left;
21-
}
22-
</style>
23-
2411
</head>
2512
<body>
2613
<div class="container-fluid">

Diff for: demo/two.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ <h1>Two grids demo</h1>
107107
// clone the sidepanel item so we drag a copy, and in some case ('manual') create the final widget, else sidebarContent will be used.
108108
function myClone(el) {
109109
if (el.getAttribute('gs-id') === 'manual') {
110-
return GridStack.Utils.createWidgetDivs(undefined, {w:2, content:'manual'}); // RenderCB() will be called
110+
return grids[0].createWidgetDivs({w:2, content:'manual'}); // RenderCB() will be called
111111
}
112112
el = el.cloneNode(true);
113113
// el.setAttribute('gs-id', 'foo'); // help debug #2231

Diff for: doc/CHANGES.md

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Change log
55
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
66
**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
77

8+
- [11.4.0 (2025-02-27)](#1140-2025-02-27)
89
- [11.3.0 (2025-01-26)](#1130-2025-01-26)
910
- [11.2.0 (2024-12-29)](#1120-2024-12-29)
1011
- [11.1.2 (2024-12-08)](#1112-2024-12-08)
@@ -120,6 +121,15 @@ Change log
120121

121122
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
122123

124+
## 11.4.0 (2025-02-27)
125+
* fix: [#2921](https://github.com/gridstack/gridstack.js/pull/2921) replace initMouseEvent with MouseEvent constructor and added composed: true
126+
* fix: [#2939](https://github.com/gridstack/gridstack.js/issues/2939) custom drag handle not working with LazyLoad
127+
* fix: [#2955](https://github.com/gridstack/gridstack.js/issues/2955) angular circular dependency
128+
* fix: [#2951](https://github.com/gridstack/gridstack.js/issues/2951) shadow DOM dragging re-appending fix
129+
* fix: [#2964](https://github.com/gridstack/gridstack.js/pull/2964) minW larger than column fix
130+
* feat: [#2965](https://github.com/gridstack/gridstack.js/pull/2965) internal `_prepareDragDropByNode(n)` is now public as `prepareDragDrop(el)` so Angular, React, and others can call once the DOM content elements have been added (the outside grid item divs are always created before content)
131+
* break: [#2959](https://github.com/gridstack/gridstack.js/issues/2959) `Util.createWidgetDivs()` has moved to `GridStack.createWidgetDivs()` to remove circular dependencies
132+
123133
## 11.3.0 (2025-01-26)
124134
* feat: added `isIgnoreChangeCB()` if changeCB should be ignored due to column change, sizeToContent, loading, etc...
125135
* feat: added `responsive_none.html` demo and fixed layout:'none' to bound check the layout (no-op unless it must change)

0 commit comments

Comments
 (0)