React original examples are shown above, but upcoming and better TS based /react folder (working to make that official and ship it) should be looked at instead.
Old v5.1.1 Jquery Demos
Note: those are no longer supported, and use an old version of the lib to compare functionality.
From 300408aca1cb05c1f0f70457683c93948e2a71be Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Tue, 18 Feb 2025 16:07:53 -0800
Subject: [PATCH 04/78] readme update
---
README.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 52408362..fd269e09 100644
--- a/README.md
+++ b/README.md
@@ -472,10 +472,10 @@ breaking change:
**Breaking change:**
-* if you code relies on `GridStackWidget.content` with real HTML (like a few demos) it is up to you to do this:
+* if your code relies on `GridStackWidget.content` with real HTML (like a few demos) it is up to you to do this:
```ts
// NOTE: REAL apps would sanitize-html or DOMPurify before blinding setting innerHTML. see #2736
-GridStack.renderCB = function(el, w) {
+GridStack.renderCB = function(el: HTMLElement, w: GridStackNode) {
el.innerHTML = w.content;
};
```
@@ -485,7 +485,7 @@ GridStack.renderCB = function(el, w) {
**Potential breaking change:**
* BIG overall to how sidepanel helper drag&drop is done:
-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.
+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.
2. use any class/structure you want for side panel items (see two.html)
3. `GridStack.setupDragIn()` now support associating a `GridStackWidget` for each sidepanel that will be used to define what to create on drop!
4. if no `GridStackWidget` is defined, the helper will now be inserted as is, and NOT original sidepanel item.
From 8830a87ed97dc7b96c546aab4adecefe7343859d Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Sun, 23 Feb 2025 19:38:10 +0000
Subject: [PATCH 05/78] Bump serialize-javascript from 6.0.1 to 6.0.2
Bumps [serialize-javascript](https://github.com/yahoo/serialize-javascript) from 6.0.1 to 6.0.2.
- [Release notes](https://github.com/yahoo/serialize-javascript/releases)
- [Commits](https://github.com/yahoo/serialize-javascript/compare/v6.0.1...v6.0.2)
---
updated-dependencies:
- dependency-name: serialize-javascript
dependency-type: indirect
...
Signed-off-by: dependabot[bot]
---
yarn.lock | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/yarn.lock b/yarn.lock
index d676b6df..92c31705 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -4930,9 +4930,9 @@ send@0.18.0:
statuses "2.0.1"
serialize-javascript@^6.0.1:
- version "6.0.1"
- resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.1.tgz#b206efb27c3da0b0ab6b52f48d170b7996458e5c"
- integrity sha512-owoXEFjWRllis8/M1Q+Cw5k8ZH40e3zhp/ovX+Xr/vi1qj6QesbyXXViFbpNvWvPNAD62SutwEXavefrLJWj7w==
+ version "6.0.2"
+ resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2"
+ integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==
dependencies:
randombytes "^2.1.0"
From 4ed0e3c1113d3ee9a4fcaafa371fb2b4ac7d7b11 Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Sun, 23 Feb 2025 18:41:38 -0800
Subject: [PATCH 06/78] Update issue templates
---
.github/ISSUE_TEMPLATE/bug_report.md | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 00000000..a5be9528
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,23 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+## Subject of the issue
+Describe your issue here.
+If unsure if lib bug, use slack channel instead: https://join.slack.com/t/gridstackjs/shared_invite/zt-2qa21lnxz-vw29RdTFet3N6~ABqT9kwA
+
+## Your environment
+* version of gridstack.js - DON'T SAY LATEST as that doesn't mean anything a month/year from now.
+* which browser/OS
+
+## Steps to reproduce
+You **MUST** provide a working demo - keep it simple and avoid frameworks as that could have issues - you can use
+https://jsfiddle.net/adumesny/jqhkry7g
+
+## Expected behavior
+Tell us what should happen. If hard to describe, attach a video as well.
From faa87a75e0107b3e6721b6e28cacf02fdfa9f3f2 Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Sun, 23 Feb 2025 18:43:50 -0800
Subject: [PATCH 07/78] Update issue templates
---
.github/ISSUE_TEMPLATE/custom.md | 23 +++++++++++++++++++++++
.github/ISSUE_TEMPLATE/feature_request.md | 23 +++++++++++++++++++++++
2 files changed, 46 insertions(+)
create mode 100644 .github/ISSUE_TEMPLATE/custom.md
create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md
diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md
new file mode 100644
index 00000000..75a465c5
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/custom.md
@@ -0,0 +1,23 @@
+---
+name: Custom issue template
+about: Describe this issue template's purpose here.
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+## Subject of the issue
+Describe your issue here.
+If unsure if lib bug, use slack channel instead: https://join.slack.com/t/gridstackjs/shared_invite/zt-2qa21lnxz-vw29RdTFet3N6~ABqT9kwA
+
+## Your environment
+* version of gridstack.js - DON'T SAY LATEST as that doesn't mean anything a month/year from now.
+* which browser/OS
+
+## Steps to reproduce
+You **MUST** provide a working demo - keep it simple and avoid frameworks as that could have issues - you can use
+https://jsfiddle.net/adumesny/jqhkry7g
+
+## Expected behavior
+Tell us what should happen. If hard to describe, attach a video as well.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 00000000..200ff669
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,23 @@
+---
+name: Feature request
+about: Suggest an idea for this project
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+## Subject of the issue
+Describe your issue here.
+If unsure if lib bug, use slack channel instead: https://join.slack.com/t/gridstackjs/shared_invite/zt-2qa21lnxz-vw29RdTFet3N6~ABqT9kwA
+
+## Your environment
+* version of gridstack.js - DON'T SAY LATEST as that doesn't mean anything a month/year from now.
+* which browser/OS
+
+## Steps to reproduce
+You **MUST** provide a working demo - keep it simple and avoid frameworks as that could have issues - you can use
+https://jsfiddle.net/adumesny/jqhkry7g
+
+## Expected behavior
+Tell us what should happen. If hard to describe, attach a video as well.
From 7fddf378c83e2a3f5726ac3a629aa5a840b6268c Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Sun, 23 Feb 2025 18:46:05 -0800
Subject: [PATCH 08/78] Update issue templates
---
.github/ISSUE_TEMPLATE/bug_report.md | 23 -----------------------
.github/ISSUE_TEMPLATE/custom.md | 23 -----------------------
.github/ISSUE_TEMPLATE/feature_request.md | 23 -----------------------
3 files changed, 69 deletions(-)
delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
delete mode 100644 .github/ISSUE_TEMPLATE/custom.md
delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index a5be9528..00000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,23 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-title: ''
-labels: ''
-assignees: ''
-
----
-
-## Subject of the issue
-Describe your issue here.
-If unsure if lib bug, use slack channel instead: https://join.slack.com/t/gridstackjs/shared_invite/zt-2qa21lnxz-vw29RdTFet3N6~ABqT9kwA
-
-## Your environment
-* version of gridstack.js - DON'T SAY LATEST as that doesn't mean anything a month/year from now.
-* which browser/OS
-
-## Steps to reproduce
-You **MUST** provide a working demo - keep it simple and avoid frameworks as that could have issues - you can use
-https://jsfiddle.net/adumesny/jqhkry7g
-
-## Expected behavior
-Tell us what should happen. If hard to describe, attach a video as well.
diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md
deleted file mode 100644
index 75a465c5..00000000
--- a/.github/ISSUE_TEMPLATE/custom.md
+++ /dev/null
@@ -1,23 +0,0 @@
----
-name: Custom issue template
-about: Describe this issue template's purpose here.
-title: ''
-labels: ''
-assignees: ''
-
----
-
-## Subject of the issue
-Describe your issue here.
-If unsure if lib bug, use slack channel instead: https://join.slack.com/t/gridstackjs/shared_invite/zt-2qa21lnxz-vw29RdTFet3N6~ABqT9kwA
-
-## Your environment
-* version of gridstack.js - DON'T SAY LATEST as that doesn't mean anything a month/year from now.
-* which browser/OS
-
-## Steps to reproduce
-You **MUST** provide a working demo - keep it simple and avoid frameworks as that could have issues - you can use
-https://jsfiddle.net/adumesny/jqhkry7g
-
-## Expected behavior
-Tell us what should happen. If hard to describe, attach a video as well.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index 200ff669..00000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,23 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-title: ''
-labels: ''
-assignees: ''
-
----
-
-## Subject of the issue
-Describe your issue here.
-If unsure if lib bug, use slack channel instead: https://join.slack.com/t/gridstackjs/shared_invite/zt-2qa21lnxz-vw29RdTFet3N6~ABqT9kwA
-
-## Your environment
-* version of gridstack.js - DON'T SAY LATEST as that doesn't mean anything a month/year from now.
-* which browser/OS
-
-## Steps to reproduce
-You **MUST** provide a working demo - keep it simple and avoid frameworks as that could have issues - you can use
-https://jsfiddle.net/adumesny/jqhkry7g
-
-## Expected behavior
-Tell us what should happen. If hard to describe, attach a video as well.
From 810f7148e0d9b2620fffb357483a4ce7bb73f4e8 Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Sun, 23 Feb 2025 18:48:19 -0800
Subject: [PATCH 09/78] Update issue templates
---
.github/ISSUE_TEMPLATE/bug_report.md | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 00000000..f82c629d
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,23 @@
+---
+name: Bug report
+about: bug report
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+## Subject of the issue
+Describe your issue here.
+If unsure if lib bug, use slack channel instead: https://join.slack.com/t/gridstackjs/shared_invite/zt-2qa21lnxz-vw29RdTFet3N6~ABqT9kwA
+
+## Your environment
+* version of gridstack.js - DON'T SAY LATEST as that doesn't mean anything a month/year from now.
+* which browser/OS
+
+## Steps to reproduce
+You **MUST** provide a working demo - keep it simple and avoid frameworks as that could have issues - you can use
+https://jsfiddle.net/adumesny/jqhkry7g
+
+## Expected behavior
+Tell us what should happen. If hard to describe, attach a video as well.
From 0a93e08b726ec2ebd9b3b21e4f77089d3997fb23 Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Sun, 23 Feb 2025 18:52:50 -0800
Subject: [PATCH 10/78] github bug template change
* looks like this isn't used anymore... set in config.
---
ISSUE_TEMPLATE.md | 14 --------------
1 file changed, 14 deletions(-)
delete mode 100644 ISSUE_TEMPLATE.md
diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md
deleted file mode 100644
index 7c1b1b7d..00000000
--- a/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,14 +0,0 @@
-## Subject of the issue
-Describe your issue here.
-If unsure if lib bug, use slack channel instead: https://join.slack.com/t/gridstackjs/shared_invite/zt-2qa21lnxz-vw29RdTFet3N6~ABqT9kwA
-
-## Your environment
-* version of gridstack.js - DON'T SAY LATEST as that doesn't mean anything a month/year from now.
-* which browser/OS
-
-## Steps to reproduce
-You **MUST** provide a working demo - keep it simple and avoid frameworks as that could have issues - you can use
-https://jsfiddle.net/adumesny/jqhkry7g
-
-## Expected behavior
-Tell us what should happen. If hard to describe, attach a video as well.
From cae38a14b3a9ffa79acf1001fd0d82eefeb2858f Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Mon, 24 Feb 2025 17:48:07 -0800
Subject: [PATCH 11/78] fix /angular circular dependencies
* fix #2955
* moves ng types into it's own plain file, fix order of include/export to reflect heirachy
Note: gridComp depends on gridItem but not other way around
---
angular/projects/lib/src/index.ts | 3 ++-
angular/projects/lib/src/lib/base-widget.ts | 2 +-
.../lib/src/lib/gridstack.component.ts | 22 ++-------------
.../projects/lib/src/lib/gridstack.module.ts | 6 ++---
angular/projects/lib/src/lib/types.ts | 27 +++++++++++++++++++
doc/CHANGES.md | 1 +
6 files changed, 36 insertions(+), 25 deletions(-)
create mode 100644 angular/projects/lib/src/lib/types.ts
diff --git a/angular/projects/lib/src/index.ts b/angular/projects/lib/src/index.ts
index 6aae285e..a9f98c28 100644
--- a/angular/projects/lib/src/index.ts
+++ b/angular/projects/lib/src/index.ts
@@ -2,7 +2,8 @@
* Public API Surface of gridstack-angular
*/
+export * from './lib/types';
+export * from './lib/base-widget';
export * from './lib/gridstack-item.component';
export * from './lib/gridstack.component';
-export * from './lib/base-widget';
export * from './lib/gridstack.module';
diff --git a/angular/projects/lib/src/lib/base-widget.ts b/angular/projects/lib/src/lib/base-widget.ts
index 5d0c7773..2511847d 100644
--- a/angular/projects/lib/src/lib/base-widget.ts
+++ b/angular/projects/lib/src/lib/base-widget.ts
@@ -8,7 +8,7 @@
*/
import { Injectable } from '@angular/core';
-import { NgCompInputs, NgGridStackWidget } from './gridstack.component';
+import { NgCompInputs, NgGridStackWidget } from './types';
@Injectable()
export abstract class BaseWidget {
diff --git a/angular/projects/lib/src/lib/gridstack.component.ts b/angular/projects/lib/src/lib/gridstack.component.ts
index 3881c571..efe44abd 100644
--- a/angular/projects/lib/src/lib/gridstack.component.ts
+++ b/angular/projects/lib/src/lib/gridstack.component.ts
@@ -9,8 +9,9 @@ import { NgIf } from '@angular/common';
import { Subscription } from 'rxjs';
import { GridHTMLElement, GridItemHTMLElement, GridStack, GridStackNode, GridStackOptions, GridStackWidget } from 'gridstack';
-import { GridItemCompHTMLElement, GridstackItemComponent } from './gridstack-item.component';
+import { NgGridStackNode, NgGridStackWidget } from './types';
import { BaseWidget } from './base-widget';
+import { GridItemCompHTMLElement, GridstackItemComponent } from './gridstack-item.component';
/** events handlers emitters signature for different events */
export type eventCB = {event: Event};
@@ -18,25 +19,6 @@ export type elementCB = {event: Event, el: GridItemHTMLElement};
export type nodesCB = {event: Event, nodes: GridStackNode[]};
export type droppedCB = {event: Event, previousNode: GridStackNode, newNode: GridStackNode};
-export type NgCompInputs = {[key: string]: any};
-
-/** extends to store Ng Component selector, instead/inAddition to content */
-export interface NgGridStackWidget extends GridStackWidget {
- /** Angular tag selector for this component to create at runtime */
- selector?: string;
- /** serialized data for the component input fields */
- input?: NgCompInputs;
- /** nested grid options */
- subGridOpts?: NgGridStackOptions;
-}
-export interface NgGridStackNode extends GridStackNode {
- selector?: string; // component type to create as content
-}
-export interface NgGridStackOptions extends GridStackOptions {
- children?: NgGridStackWidget[];
- subGridOpts?: NgGridStackOptions;
-}
-
/** store element to Ng Class pointer back */
export interface GridCompHTMLElement extends GridHTMLElement {
_gridComp?: GridstackComponent;
diff --git a/angular/projects/lib/src/lib/gridstack.module.ts b/angular/projects/lib/src/lib/gridstack.module.ts
index ce1ca3db..bd1508c8 100644
--- a/angular/projects/lib/src/lib/gridstack.module.ts
+++ b/angular/projects/lib/src/lib/gridstack.module.ts
@@ -5,18 +5,18 @@
import { NgModule } from "@angular/core";
-import { GridstackComponent } from "./gridstack.component";
import { GridstackItemComponent } from "./gridstack-item.component";
+import { GridstackComponent } from "./gridstack.component";
// @deprecated use GridstackComponent and GridstackItemComponent as standalone components
@NgModule({
imports: [
- GridstackComponent,
GridstackItemComponent,
+ GridstackComponent,
],
exports: [
- GridstackComponent,
GridstackItemComponent,
+ GridstackComponent,
],
})
export class GridstackModule {}
diff --git a/angular/projects/lib/src/lib/types.ts b/angular/projects/lib/src/lib/types.ts
new file mode 100644
index 00000000..ccd3d1cd
--- /dev/null
+++ b/angular/projects/lib/src/lib/types.ts
@@ -0,0 +1,27 @@
+/**
+ * gridstack-item.component.ts 11.3.0-dev
+ * Copyright (c) 2025 Alain Dumesny - see GridStack root license
+ */
+
+import { GridStackNode, GridStackOptions, GridStackWidget } from "gridstack";
+
+/** extends to store Ng Component selector, instead/inAddition to content */
+export interface NgGridStackWidget extends GridStackWidget {
+ /** Angular tag selector for this component to create at runtime */
+ selector?: string;
+ /** serialized data for the component input fields */
+ input?: NgCompInputs;
+ /** nested grid options */
+ subGridOpts?: NgGridStackOptions;
+}
+
+export interface NgGridStackNode extends GridStackNode {
+ selector?: string; // component type to create as content
+}
+
+export interface NgGridStackOptions extends GridStackOptions {
+ children?: NgGridStackWidget[];
+ subGridOpts?: NgGridStackOptions;
+}
+
+export type NgCompInputs = {[key: string]: any};
diff --git a/doc/CHANGES.md b/doc/CHANGES.md
index c8179d13..a80e5b78 100644
--- a/doc/CHANGES.md
+++ b/doc/CHANGES.md
@@ -124,6 +124,7 @@ Change log
## 11.3.0-dev (TBD)
* fix: [#2921](https://github.com/gridstack/gridstack.js/pull/2921) replace initMouseEvent with MouseEvent constructor and added composed: true
* fix: [#2939](https://github.com/gridstack/gridstack.js/issues/2939) custom drag handle not working with LazyLoad
+* fix: [#2955](https://github.com/gridstack/gridstack.js/issues/2955) angular circular dependency
## 11.3.0 (2025-01-26)
* feat: added `isIgnoreChangeCB()` if changeCB should be ignored due to column change, sizeToContent, loading, etc...
From 51c383d1f5e3b69cb73d3a1aa9deed5b301a29c0 Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Mon, 24 Feb 2025 18:09:01 -0800
Subject: [PATCH 12/78] shadow DOM drag re-append fix
* fix #2951
* check for helper not having a parent before re-appending (rather than search though entire dom + shadow)
* added example test
---
doc/CHANGES.md | 1 +
spec/e2e/html/2951_shadow_dom.html | 71 ++++++++++++++++++++++++++++++
src/dd-draggable.ts | 2 +-
3 files changed, 73 insertions(+), 1 deletion(-)
create mode 100644 spec/e2e/html/2951_shadow_dom.html
diff --git a/doc/CHANGES.md b/doc/CHANGES.md
index a80e5b78..370f1546 100644
--- a/doc/CHANGES.md
+++ b/doc/CHANGES.md
@@ -125,6 +125,7 @@ Change log
* fix: [#2921](https://github.com/gridstack/gridstack.js/pull/2921) replace initMouseEvent with MouseEvent constructor and added composed: true
* fix: [#2939](https://github.com/gridstack/gridstack.js/issues/2939) custom drag handle not working with LazyLoad
* fix: [#2955](https://github.com/gridstack/gridstack.js/issues/2955) angular circular dependency
+* fix: [#2951](https://github.com/gridstack/gridstack.js/issues/2951) shadow DOM dragging re-appending fix
## 11.3.0 (2025-01-26)
* feat: added `isIgnoreChangeCB()` if changeCB should be ignored due to column change, sizeToContent, loading, etc...
diff --git a/spec/e2e/html/2951_shadow_dom.html b/spec/e2e/html/2951_shadow_dom.html
new file mode 100644
index 00000000..65b226ee
--- /dev/null
+++ b/spec/e2e/html/2951_shadow_dom.html
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+ Codestin Search App
+
+
+
+
Inside Custom Element with Shadow DOM
+
+
+
+
diff --git a/src/dd-draggable.ts b/src/dd-draggable.ts
index caf86601..51c753f7 100644
--- a/src/dd-draggable.ts
+++ b/src/dd-draggable.ts
@@ -299,7 +299,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
} else if (this.option.helper === 'clone') {
helper = Utils.cloneNode(this.el);
}
- if (!document.body.contains(helper)) {
+ if (!helper.parentElement) {
Utils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentElement : this.option.appendTo);
}
this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);
From 21ff397e9ae597d3acf1fd532b9f5a1e62e87972 Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Wed, 26 Feb 2025 11:20:29 -0800
Subject: [PATCH 13/78] minW larger than column fix
* make sure minW is still applied before we constrain to current column count
---
doc/CHANGES.md | 1 +
src/gridstack-engine.ts | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/doc/CHANGES.md b/doc/CHANGES.md
index 370f1546..f6d49365 100644
--- a/doc/CHANGES.md
+++ b/doc/CHANGES.md
@@ -126,6 +126,7 @@ Change log
* fix: [#2939](https://github.com/gridstack/gridstack.js/issues/2939) custom drag handle not working with LazyLoad
* fix: [#2955](https://github.com/gridstack/gridstack.js/issues/2955) angular circular dependency
* fix: [#2951](https://github.com/gridstack/gridstack.js/issues/2951) shadow DOM dragging re-appending fix
+* fix: [#2964](https://github.com/gridstack/gridstack.js/pull/2964) minW larger than column fix
## 11.3.0 (2025-01-26)
* feat: added `isIgnoreChangeCB()` if changeCB should be ignored due to column change, sizeToContent, loading, etc...
diff --git a/src/gridstack-engine.ts b/src/gridstack-engine.ts
index fd3fd93b..bc48e2dd 100644
--- a/src/gridstack-engine.ts
+++ b/src/gridstack-engine.ts
@@ -408,10 +408,10 @@ export class GridStackEngine {
const before = node._orig || Utils.copyPos({}, node);
- if (node.maxW && node.w) { node.w = Math.min(node.w, node.maxW); }
- if (node.maxH && node.h) { node.h = Math.min(node.h, node.maxH); }
- if (node.minW && node.w && node.minW <= this.column) { node.w = Math.max(node.w, node.minW); }
- if (node.minH && node.h) { node.h = Math.max(node.h, node.minH); }
+ if (node.maxW) { node.w = Math.min(node.w || 1, node.maxW); }
+ if (node.maxH) { node.h = Math.min(node.h || 1, node.maxH); }
+ if (node.minW) { node.w = Math.max(node.w || 1, node.minW); }
+ if (node.minH) { node.h = Math.max(node.h || 1, node.minH); }
// if user loaded a larger than allowed widget for current # of columns,
// remember it's position & width so we can restore back (1 -> 12 column) #1655 #1985
From a2e65b067823f6d02a897a0511aa86a2d5932d4b Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Wed, 26 Feb 2025 18:50:58 -0800
Subject: [PATCH 14/78] new public prepareDragDrop(el)
* 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 griditem divs are always created for content)
---
doc/CHANGES.md | 1 +
src/gridstack.ts | 22 +++++++++++-----------
src/types.ts | 2 +-
src/utils.ts | 3 +--
4 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/doc/CHANGES.md b/doc/CHANGES.md
index f6d49365..7c82e3ee 100644
--- a/doc/CHANGES.md
+++ b/doc/CHANGES.md
@@ -127,6 +127,7 @@ Change log
* fix: [#2955](https://github.com/gridstack/gridstack.js/issues/2955) angular circular dependency
* fix: [#2951](https://github.com/gridstack/gridstack.js/issues/2951) shadow DOM dragging re-appending fix
* fix: [#2964](https://github.com/gridstack/gridstack.js/pull/2964) minW larger than column fix
+* 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 griditem divs are always created for content)
## 11.3.0 (2025-01-26)
* feat: added `isIgnoreChangeCB()` if changeCB should be ignored due to column change, sizeToContent, loading, etc...
diff --git a/src/gridstack.ts b/src/gridstack.ts
index acb2ca90..4ab40b04 100644
--- a/src/gridstack.ts
+++ b/src/gridstack.ts
@@ -551,7 +551,7 @@ export class GridStack {
newItem.appendChild(content);
content = Utils.createDiv(['grid-stack-item-content'], node.el);
}
- this._prepareDragDropByNode(node); // ... and restore original D&D
+ this.prepareDragDrop(node.el); // ... and restore original D&D
}
// if we're adding an additional item, make the container large enough to have them both
@@ -1278,7 +1278,7 @@ export class GridStack {
this._setupRemoveDrop();
this._setupAcceptWidget();
this.engine.nodes.forEach(n => {
- this._prepareDragDropByNode(n); // either delete or init Drag&drop
+ this.prepareDragDrop(n.el); // either delete or init Drag&drop
if (n.subGrid && recurse) n.subGrid.setStatic(val, updateClass, recurse);
});
if (updateClass) { this._setStaticClass(); }
@@ -1367,7 +1367,7 @@ export class GridStack {
this._writeAttr(el, n);
}
if (ddChanged) {
- this._prepareDragDropByNode(n);
+ this.prepareDragDrop(n.el);
}
});
@@ -1697,7 +1697,7 @@ export class GridStack {
sizeToContent ? el.classList.add('size-to-content') : el.classList.remove('size-to-content');
if (sizeToContent) this.resizeToContentCheck(false, node);
- if (!Utils.lazyLoad(node)) this._prepareDragDropByNode(node);
+ if (!Utils.lazyLoad(node)) this.prepareDragDrop(node.el);
return this;
}
@@ -1994,7 +1994,7 @@ export class GridStack {
const n = el.gridstackNode;
if (!n) return;
val ? delete n.noMove : n.noMove = true;
- this._prepareDragDropByNode(n); // init DD if need be, and adjust
+ this.prepareDragDrop(n.el); // init DD if need be, and adjust
});
return this;
}
@@ -2010,7 +2010,7 @@ export class GridStack {
const n = el.gridstackNode;
if (!n) return;
val ? delete n.noResize : n.noResize = true;
- this._prepareDragDropByNode(n); // init DD if need be, and adjust
+ this.prepareDragDrop(n.el); // init DD if need be, and adjust
});
return this;
}
@@ -2057,7 +2057,7 @@ export class GridStack {
if (this.opts.staticGrid) return this; // can't move a static grid!
doEnable ? delete this.opts.disableDrag : this.opts.disableDrag = true; // FIRST before we update children as grid overrides #1658
this.engine.nodes.forEach(n => {
- this._prepareDragDropByNode(n);
+ this.prepareDragDrop(n.el);
if (n.subGrid && recurse) n.subGrid.enableMove(doEnable, recurse);
});
return this;
@@ -2071,7 +2071,7 @@ export class GridStack {
if (this.opts.staticGrid) return this; // can't size a static grid!
doEnable ? delete this.opts.disableResize : this.opts.disableResize = true; // FIRST before we update children as grid overrides #1658
this.engine.nodes.forEach(n => {
- this._prepareDragDropByNode(n);
+ this.prepareDragDrop(n.el);
if (n.subGrid && recurse) n.subGrid.enableResize(doEnable, recurse);
});
return this;
@@ -2399,9 +2399,9 @@ export class GridStack {
return this;
}
- /** @internal prepares the element for drag&drop */
- protected _prepareDragDropByNode(node: GridStackNode): GridStack {
- const el = node.el;
+ /** prepares the element for drag&drop - this is normally called by makeWiget() unless are are delay loading */
+ public prepareDragDrop(el: GridItemHTMLElement): GridStack {
+ const node = el.gridstackNode;
const noMove = node.noMove || this.opts.disableDrag;
const noResize = node.noResize || this.opts.disableResize;
diff --git a/src/types.ts b/src/types.ts
index 7709c012..dbb017f4 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -153,7 +153,7 @@ export interface GridStackOptions {
/** number of columns (default?: 12). Note: IF you change this, CSS also have to change. See https://github.com/gridstack/gridstack.js#change-grid-columns.
* Note: for nested grids, it is recommended to use 'auto' which will always match the container grid-item current width (in column) to keep inside and outside
- * items always to same. flag is not supported for regular non-nested grids.
+ * items always the same. flag is NOT supported for regular non-nested grids.
*/
column?: number | 'auto';
diff --git a/src/utils.ts b/src/utils.ts
index 50c2e794..1d13535c 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -126,8 +126,7 @@ export class Utils {
n.visibleObservable?.disconnect();
delete n.visibleObservable;
GridStack.renderCB(cont, n);
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- (n.grid as any)?._prepareDragDropByNode(n); // access protected method. TODO: do we expose that for React to call too (after dom is ready)
+ n.grid?.prepareDragDrop(n.el);
}});
window.setTimeout(() => n.visibleObservable?.observe(el)); // wait until callee sets position attributes
}
From 80a1182b9e5013480119ac8a8c06b1c7dc5a5863 Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Thu, 27 Feb 2025 07:02:21 -0800
Subject: [PATCH 15/78] Util to GridStack.createWidgetDivs() move
* fix #2959
* `Util.createWidgetDivs()` has moved to `GridStack.createWidgetDivs()` to remove circular dependencies
---
README.md | 2 +-
demo/sizeToContent.html | 2 +-
demo/two.html | 2 +-
doc/CHANGES.md | 3 ++-
src/gridstack.ts | 22 +++++++++++++++++++++-
src/utils.ts | 21 ---------------------
6 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/README.md b/README.md
index fd269e09..315a825c 100644
--- a/README.md
+++ b/README.md
@@ -480,7 +480,7 @@ GridStack.renderCB = function(el: HTMLElement, w: GridStackNode) {
};
```
* 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.
-* `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.
+* `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.
**Potential breaking change:**
diff --git a/demo/sizeToContent.html b/demo/sizeToContent.html
index 77a71066..e29a52fa 100644
--- a/demo/sizeToContent.html
+++ b/demo/sizeToContent.html
@@ -109,7 +109,7 @@
sizeToContent options demo
grid.addWidget({content: `
New: ${text}
`});
}
function makeWidget() {
- let el = GridStack.Utils.createWidgetDivs(undefined, {content: `
New Make: ${text}
`}, grid.el)
+ let el = GridStack.createWidgetDivs(undefined, {content: `
// clone the sidepanel item so we drag a copy, and in some case ('manual') create the final widget, else sidebarContent will be used.
function myClone(el) {
if (el.getAttribute('gs-id') === 'manual') {
- return GridStack.Utils.createWidgetDivs(undefined, {w:2, content:'manual'}); // RenderCB() will be called
+ return GridStack.createWidgetDivs(undefined, {w:2, content:'manual'}); // RenderCB() will be called
}
el = el.cloneNode(true);
// el.setAttribute('gs-id', 'foo'); // help debug #2231
diff --git a/doc/CHANGES.md b/doc/CHANGES.md
index 7c82e3ee..aa9e3e49 100644
--- a/doc/CHANGES.md
+++ b/doc/CHANGES.md
@@ -127,7 +127,8 @@ Change log
* fix: [#2955](https://github.com/gridstack/gridstack.js/issues/2955) angular circular dependency
* fix: [#2951](https://github.com/gridstack/gridstack.js/issues/2951) shadow DOM dragging re-appending fix
* fix: [#2964](https://github.com/gridstack/gridstack.js/pull/2964) minW larger than column fix
-* 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 griditem divs are always created for content)
+* 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)
+* break: [#2959](https://github.com/gridstack/gridstack.js/issues/2959) `Util.createWidgetDivs()` has moved to `GridStack.createWidgetDivs()` to remove circular dependencies
## 11.3.0 (2025-01-26)
* feat: added `isIgnoreChangeCB()` if changeCB should be ignored due to column change, sizeToContent, loading, etc...
diff --git a/src/gridstack.ts b/src/gridstack.ts
index 4ab40b04..1a0076de 100644
--- a/src/gridstack.ts
+++ b/src/gridstack.ts
@@ -173,6 +173,26 @@ export class GridStack {
return grid;
}
+ /** create the default grid item divs, and content possibly lazy loaded calling GridStack.renderCB */
+ static createWidgetDivs(itemClass: string, n: GridStackNode): HTMLElement {
+ const el = Utils.createDiv(['grid-stack-item', itemClass]);
+ const cont = Utils.createDiv(['grid-stack-item-content'], el);
+
+ if (Utils.lazyLoad(n)) {
+ if (!n.visibleObservable) {
+ n.visibleObservable = new IntersectionObserver(([entry]) => { if (entry.isIntersecting) {
+ n.visibleObservable?.disconnect();
+ delete n.visibleObservable;
+ GridStack.renderCB(cont, n);
+ n.grid?.prepareDragDrop(n.el);
+ }});
+ window.setTimeout(() => n.visibleObservable?.observe(el)); // wait until callee sets position attributes
+ }
+ } else GridStack.renderCB(cont, n);
+
+ return el;
+ }
+
/** call this method to register your engine instead of the default one.
* See instead `GridStackOptions.engineClass` if you only need to
* replace just one instance.
@@ -467,7 +487,7 @@ export class GridStack {
} else if (GridStack.addRemoveCB) {
el = GridStack.addRemoveCB(this.el, w, true, false);
} else {
- el = Utils.createWidgetDivs(this.opts.itemClass, node);
+ el = GridStack.createWidgetDivs(this.opts.itemClass, node);
}
if (!el) return;
diff --git a/src/utils.ts b/src/utils.ts
index 1d13535c..48ed7fc2 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -3,7 +3,6 @@
* Copyright (c) 2021-2024 Alain Dumesny - see GridStack root license
*/
-import { GridStack } from './gridstack';
import { GridStackElement, GridStackNode, GridStackOptions, numberOrString, GridStackPosition, GridStackWidget } from './types';
export interface HeightData {
@@ -115,26 +114,6 @@ export class Utils {
return n.lazyLoad || n.grid?.opts?.lazyLoad && n.lazyLoad !== false;
}
- /** create the default grid item divs, and content possibly lazy loaded calling GridStack.renderCB */
- static createWidgetDivs(itemClass: string, n: GridStackNode): HTMLElement {
- const el = Utils.createDiv(['grid-stack-item', itemClass]);
- const cont = Utils.createDiv(['grid-stack-item-content'], el);
-
- if (Utils.lazyLoad(n)) {
- if (!n.visibleObservable) {
- n.visibleObservable = new IntersectionObserver(([entry]) => { if (entry.isIntersecting) {
- n.visibleObservable?.disconnect();
- delete n.visibleObservable;
- GridStack.renderCB(cont, n);
- n.grid?.prepareDragDrop(n.el);
- }});
- window.setTimeout(() => n.visibleObservable?.observe(el)); // wait until callee sets position attributes
- }
- } else GridStack.renderCB(cont, n);
-
- return el;
- }
-
/** create a div with the given classes */
static createDiv(classes: string[], parent?: HTMLElement): HTMLElement {
const el = document.createElement('div');
From 271efcc279b6d90ba57ceedf1e11ed61ff3f4592 Mon Sep 17 00:00:00 2001
From: Alain Dumesny
Date: Thu, 27 Feb 2025 07:19:39 -0800
Subject: [PATCH 16/78] this.createWidgetDivs() since it needs
this.opts.itemClass anyway, instead of static method.
* more fix #2959
---
demo/sizeToContent.html | 2 +-
demo/two.html | 2 +-
src/gridstack.ts | 42 ++++++++++++++++++++---------------------
3 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/demo/sizeToContent.html b/demo/sizeToContent.html
index e29a52fa..be607e0c 100644
--- a/demo/sizeToContent.html
+++ b/demo/sizeToContent.html
@@ -109,7 +109,7 @@
sizeToContent options demo
grid.addWidget({content: `
New: ${text}
`});
}
function makeWidget() {
- let el = GridStack.createWidgetDivs(undefined, {content: `
New Make: ${text}
`}, grid.el)
+ let el = grid.createWidgetDivs({content: `