gridstack 5.0.0 → 6.0.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.
Files changed (168) hide show
  1. package/README.md +78 -53
  2. package/dist/{h5/dd-base-impl.d.ts → dd-base-impl.d.ts} +2 -2
  3. package/dist/{h5/dd-base-impl.js → dd-base-impl.js} +2 -4
  4. package/dist/dd-base-impl.js.map +1 -0
  5. package/dist/{es5/h5/dd-draggable.d.ts → dd-draggable.d.ts} +7 -8
  6. package/dist/dd-draggable.js +313 -0
  7. package/dist/dd-draggable.js.map +1 -0
  8. package/dist/{es5/h5/dd-droppable.d.ts → dd-droppable.d.ts} +4 -3
  9. package/dist/dd-droppable.js +149 -0
  10. package/dist/dd-droppable.js.map +1 -0
  11. package/dist/{es5/h5/dd-element.d.ts → dd-element.d.ts} +2 -2
  12. package/dist/{h5/dd-element.js → dd-element.js} +1 -1
  13. package/dist/dd-element.js.map +1 -0
  14. package/dist/dd-gridstack.d.ts +36 -0
  15. package/dist/{gridstack-dd.js → dd-gridstack.js} +154 -52
  16. package/dist/dd-gridstack.js.map +1 -0
  17. package/dist/dd-manager.d.ts +17 -0
  18. package/dist/{h5/dd-manager.js → dd-manager.js} +4 -1
  19. package/dist/dd-manager.js.map +1 -0
  20. package/dist/{es5/h5/dd-resizable-handle.d.ts → dd-resizable-handle.d.ts} +2 -2
  21. package/dist/{h5/dd-resizable-handle.js → dd-resizable-handle.js} +33 -9
  22. package/dist/dd-resizable-handle.js.map +1 -0
  23. package/dist/{h5/dd-resizable.d.ts → dd-resizable.d.ts} +3 -3
  24. package/dist/{h5/dd-resizable.js → dd-resizable.js} +29 -28
  25. package/dist/dd-resizable.js.map +1 -0
  26. package/dist/dd-touch.d.ts +33 -0
  27. package/dist/dd-touch.js +179 -0
  28. package/dist/dd-touch.js.map +1 -0
  29. package/dist/es5/{h5/dd-base-impl.d.ts → dd-base-impl.d.ts} +2 -2
  30. package/dist/es5/{h5/dd-base-impl.js → dd-base-impl.js} +2 -4
  31. package/dist/es5/dd-base-impl.js.map +1 -0
  32. package/dist/{h5 → es5}/dd-draggable.d.ts +7 -8
  33. package/dist/es5/dd-draggable.js +335 -0
  34. package/dist/es5/dd-draggable.js.map +1 -0
  35. package/dist/{h5 → es5}/dd-droppable.d.ts +4 -3
  36. package/dist/es5/dd-droppable.js +180 -0
  37. package/dist/es5/dd-droppable.js.map +1 -0
  38. package/dist/{h5 → es5}/dd-element.d.ts +2 -2
  39. package/dist/es5/{h5/dd-element.js → dd-element.js} +1 -1
  40. package/dist/es5/dd-element.js.map +1 -0
  41. package/dist/es5/dd-gridstack.d.ts +36 -0
  42. package/dist/es5/{gridstack-dd.js → dd-gridstack.js} +164 -71
  43. package/dist/es5/dd-gridstack.js.map +1 -0
  44. package/dist/es5/dd-manager.d.ts +17 -0
  45. package/dist/es5/{h5/dd-manager.js → dd-manager.js} +4 -1
  46. package/dist/es5/dd-manager.js.map +1 -0
  47. package/dist/{h5 → es5}/dd-resizable-handle.d.ts +2 -2
  48. package/dist/es5/{h5/dd-resizable-handle.js → dd-resizable-handle.js} +33 -9
  49. package/dist/es5/dd-resizable-handle.js.map +1 -0
  50. package/dist/es5/{h5/dd-resizable.d.ts → dd-resizable.d.ts} +3 -3
  51. package/dist/es5/{h5/dd-resizable.js → dd-resizable.js} +29 -28
  52. package/dist/es5/dd-resizable.js.map +1 -0
  53. package/dist/es5/dd-touch.d.ts +33 -0
  54. package/dist/es5/dd-touch.js +182 -0
  55. package/dist/es5/dd-touch.js.map +1 -0
  56. package/dist/es5/gridstack-all.js +3 -0
  57. package/dist/{gridstack-static.js.LICENSE.txt → es5/gridstack-all.js.LICENSE.txt} +2 -2
  58. package/dist/es5/gridstack-all.js.map +1 -0
  59. package/dist/es5/gridstack-engine.d.ts +12 -9
  60. package/dist/es5/gridstack-engine.js +45 -55
  61. package/dist/es5/gridstack-engine.js.map +1 -1
  62. package/dist/es5/gridstack-poly.js +1 -1
  63. package/dist/es5/gridstack.d.ts +17 -12
  64. package/dist/es5/gridstack.js +70 -43
  65. package/dist/es5/gridstack.js.map +1 -1
  66. package/dist/es5/types.d.ts +19 -20
  67. package/dist/es5/types.js +1 -1
  68. package/dist/es5/types.js.map +1 -1
  69. package/dist/es5/utils.d.ts +12 -2
  70. package/dist/es5/utils.js +79 -18
  71. package/dist/es5/utils.js.map +1 -1
  72. package/dist/gridstack-all.js +3 -0
  73. package/dist/{es5/gridstack-h5.js.LICENSE.txt → gridstack-all.js.LICENSE.txt} +2 -2
  74. package/dist/gridstack-all.js.map +1 -0
  75. package/dist/gridstack-engine.d.ts +12 -9
  76. package/dist/gridstack-engine.js +44 -54
  77. package/dist/gridstack-engine.js.map +1 -1
  78. package/dist/gridstack.css +21 -9
  79. package/dist/gridstack.d.ts +17 -12
  80. package/dist/gridstack.js +68 -43
  81. package/dist/gridstack.js.map +1 -1
  82. package/dist/gridstack.min.css +1 -1
  83. package/dist/src/gridstack.scss +19 -12
  84. package/dist/types.d.ts +19 -20
  85. package/dist/types.js +1 -1
  86. package/dist/types.js.map +1 -1
  87. package/dist/utils.d.ts +12 -2
  88. package/dist/utils.js +75 -17
  89. package/dist/utils.js.map +1 -1
  90. package/doc/CHANGES.md +21 -2
  91. package/doc/README.md +29 -24
  92. package/package.json +5 -5
  93. package/dist/es5/gridstack-dd.d.ts +0 -35
  94. package/dist/es5/gridstack-dd.js.map +0 -1
  95. package/dist/es5/gridstack-ddi.d.ts +0 -17
  96. package/dist/es5/gridstack-ddi.js +0 -31
  97. package/dist/es5/gridstack-ddi.js.map +0 -1
  98. package/dist/es5/gridstack-h5.d.ts +0 -10
  99. package/dist/es5/gridstack-h5.js +0 -3
  100. package/dist/es5/gridstack-h5.js.map +0 -1
  101. package/dist/es5/gridstack-jq.d.ts +0 -10
  102. package/dist/es5/gridstack-jq.js +0 -3
  103. package/dist/es5/gridstack-jq.js.LICENSE.txt +0 -99
  104. package/dist/es5/gridstack-jq.js.map +0 -1
  105. package/dist/es5/gridstack-static.d.ts +0 -9
  106. package/dist/es5/gridstack-static.js +0 -3
  107. package/dist/es5/gridstack-static.js.LICENSE.txt +0 -7
  108. package/dist/es5/gridstack-static.js.map +0 -1
  109. package/dist/es5/h5/dd-base-impl.js.map +0 -1
  110. package/dist/es5/h5/dd-draggable.js +0 -329
  111. package/dist/es5/h5/dd-draggable.js.map +0 -1
  112. package/dist/es5/h5/dd-droppable.js +0 -199
  113. package/dist/es5/h5/dd-droppable.js.map +0 -1
  114. package/dist/es5/h5/dd-element.js.map +0 -1
  115. package/dist/es5/h5/dd-manager.d.ts +0 -8
  116. package/dist/es5/h5/dd-manager.js.map +0 -1
  117. package/dist/es5/h5/dd-resizable-handle.js.map +0 -1
  118. package/dist/es5/h5/dd-resizable.js.map +0 -1
  119. package/dist/es5/h5/dd-utils.d.ts +0 -19
  120. package/dist/es5/h5/dd-utils.js +0 -111
  121. package/dist/es5/h5/dd-utils.js.map +0 -1
  122. package/dist/es5/h5/gridstack-dd-native.d.ts +0 -26
  123. package/dist/es5/h5/gridstack-dd-native.js +0 -175
  124. package/dist/es5/h5/gridstack-dd-native.js.map +0 -1
  125. package/dist/es5/jq/gridstack-dd-jqueryui.d.ts +0 -22
  126. package/dist/es5/jq/gridstack-dd-jqueryui.js +0 -162
  127. package/dist/es5/jq/gridstack-dd-jqueryui.js.map +0 -1
  128. package/dist/gridstack-dd.d.ts +0 -35
  129. package/dist/gridstack-dd.js.map +0 -1
  130. package/dist/gridstack-ddi.d.ts +0 -17
  131. package/dist/gridstack-ddi.js +0 -28
  132. package/dist/gridstack-ddi.js.map +0 -1
  133. package/dist/gridstack-h5.d.ts +0 -10
  134. package/dist/gridstack-h5.js +0 -3
  135. package/dist/gridstack-h5.js.LICENSE.txt +0 -7
  136. package/dist/gridstack-h5.js.map +0 -1
  137. package/dist/gridstack-jq.d.ts +0 -10
  138. package/dist/gridstack-jq.js +0 -3
  139. package/dist/gridstack-jq.js.LICENSE.txt +0 -99
  140. package/dist/gridstack-jq.js.map +0 -1
  141. package/dist/gridstack-static.d.ts +0 -9
  142. package/dist/gridstack-static.js +0 -3
  143. package/dist/gridstack-static.js.map +0 -1
  144. package/dist/h5/dd-base-impl.js.map +0 -1
  145. package/dist/h5/dd-draggable.js +0 -305
  146. package/dist/h5/dd-draggable.js.map +0 -1
  147. package/dist/h5/dd-droppable.js +0 -168
  148. package/dist/h5/dd-droppable.js.map +0 -1
  149. package/dist/h5/dd-element.js.map +0 -1
  150. package/dist/h5/dd-manager.d.ts +0 -8
  151. package/dist/h5/dd-manager.js.map +0 -1
  152. package/dist/h5/dd-resizable-handle.js.map +0 -1
  153. package/dist/h5/dd-resizable.js.map +0 -1
  154. package/dist/h5/dd-utils.d.ts +0 -19
  155. package/dist/h5/dd-utils.js +0 -94
  156. package/dist/h5/dd-utils.js.map +0 -1
  157. package/dist/h5/gridstack-dd-native.d.ts +0 -26
  158. package/dist/h5/gridstack-dd-native.js +0 -140
  159. package/dist/h5/gridstack-dd-native.js.map +0 -1
  160. package/dist/jq/gridstack-dd-jqueryui.d.ts +0 -22
  161. package/dist/jq/gridstack-dd-jqueryui.js +0 -133
  162. package/dist/jq/gridstack-dd-jqueryui.js.map +0 -1
  163. package/dist/jq/jquery-ui.js +0 -2
  164. package/dist/jq/jquery-ui.js.map +0 -1
  165. package/dist/jq/jquery.js +0 -2
  166. package/dist/jq/jquery.js.map +0 -1
  167. package/dist/jq/jquery.ui.touch-punch.js +0 -2
  168. package/dist/jq/jquery.ui.touch-punch.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * gridstack SASS styles 5.0
2
+ * gridstack SASS styles 6.0.0
3
3
  * Copyright (c) 2021 Alain Dumesny - see GridStack root license
4
4
  */
5
5
  :root .grid-stack-item > .ui-resizable-handle {
@@ -16,7 +16,7 @@
16
16
  direction: rtl;
17
17
  }
18
18
  .grid-stack .grid-stack-placeholder > .placeholder-content {
19
- border: 1px dashed lightgray;
19
+ background-color: rgba(0, 0, 0, 0.1);
20
20
  margin: 0;
21
21
  position: absolute;
22
22
  width: auto;
@@ -45,13 +45,6 @@
45
45
  .grid-stack > .grid-stack-item.ui-resizable-disabled > .ui-resizable-handle, .grid-stack > .grid-stack-item.ui-resizable-autohide > .ui-resizable-handle {
46
46
  display: none;
47
47
  }
48
- .grid-stack > .grid-stack-item.ui-draggable-dragging, .grid-stack > .grid-stack-item.ui-resizable-resizing {
49
- z-index: 100;
50
- }
51
- .grid-stack > .grid-stack-item.ui-draggable-dragging > .grid-stack-item-content, .grid-stack > .grid-stack-item.ui-resizable-resizing > .grid-stack-item-content {
52
- box-shadow: 1px 4px 6px rgba(0, 0, 0, 0.2);
53
- opacity: 0.8;
54
- }
55
48
  .grid-stack > .grid-stack-item > .ui-resizable-se,
56
49
  .grid-stack > .grid-stack-item > .ui-resizable-sw {
57
50
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTYuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjE2cHgiIGhlaWdodD0iMTZweCIgdmlld0JveD0iMCAwIDUxMS42MjYgNTExLjYyNyIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNTExLjYyNiA1MTEuNjI3OyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+CjxnPgoJPHBhdGggZD0iTTMyOC45MDYsNDAxLjk5NGgtMzYuNTUzVjEwOS42MzZoMzYuNTUzYzQuOTQ4LDAsOS4yMzYtMS44MDksMTIuODQ3LTUuNDI2YzMuNjEzLTMuNjE1LDUuNDIxLTcuODk4LDUuNDIxLTEyLjg0NSAgIGMwLTQuOTQ5LTEuODAxLTkuMjMxLTUuNDI4LTEyLjg1MWwtNzMuMDg3LTczLjA5QzI2NS4wNDQsMS44MDksMjYwLjc2LDAsMjU1LjgxMywwYy00Ljk0OCwwLTkuMjI5LDEuODA5LTEyLjg0Nyw1LjQyNCAgIGwtNzMuMDg4LDczLjA5Yy0zLjYxOCwzLjYxOS01LjQyNCw3LjkwMi01LjQyNCwxMi44NTFjMCw0Ljk0NiwxLjgwNyw5LjIyOSw1LjQyNCwxMi44NDVjMy42MTksMy42MTcsNy45MDEsNS40MjYsMTIuODUsNS40MjYgICBoMzYuNTQ1djI5Mi4zNThoLTM2LjU0MmMtNC45NTIsMC05LjIzNSwxLjgwOC0xMi44NSw1LjQyMWMtMy42MTcsMy42MjEtNS40MjQsNy45MDUtNS40MjQsMTIuODU0ICAgYzAsNC45NDUsMS44MDcsOS4yMjcsNS40MjQsMTIuODQ3bDczLjA4OSw3My4wODhjMy42MTcsMy42MTcsNy44OTgsNS40MjQsMTIuODQ3LDUuNDI0YzQuOTUsMCw5LjIzNC0xLjgwNywxMi44NDktNS40MjQgICBsNzMuMDg3LTczLjA4OGMzLjYxMy0zLjYyLDUuNDIxLTcuOTAxLDUuNDIxLTEyLjg0N2MwLTQuOTQ4LTEuODA4LTkuMjMyLTUuNDIxLTEyLjg1NCAgIEMzMzguMTQyLDQwMy44MDIsMzMzLjg1Nyw0MDEuOTk0LDMyOC45MDYsNDAxLjk5NHoiIGZpbGw9IiM2NjY2NjYiLz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K);
@@ -305,4 +298,23 @@
305
298
  -ms-transition: left 0s, top 0s, height 0s, width 0s;
306
299
  -o-transition: left 0s, top 0s, height 0s, width 0s;
307
300
  transition: left 0s, top 0s, height 0s, width 0s;
301
+ }
302
+
303
+ .ui-draggable-dragging,
304
+ .ui-resizable-resizing {
305
+ z-index: 100;
306
+ }
307
+ .ui-draggable-dragging > .grid-stack-item-content,
308
+ .ui-resizable-resizing > .grid-stack-item-content {
309
+ box-shadow: 1px 4px 6px rgba(0, 0, 0, 0.2);
310
+ opacity: 0.8;
311
+ }
312
+
313
+ .ui-draggable-dragging {
314
+ will-change: left, top;
315
+ cursor: move;
316
+ }
317
+
318
+ .ui-resizable-resizing {
319
+ will-change: width, height;
308
320
  }
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * GridStack 5.0
2
+ * GridStack 6.0.0
3
3
  * https://gridstackjs.com/
4
4
  *
5
- * Copyright (c) 2021 Alain Dumesny
5
+ * Copyright (c) 2021-2022 Alain Dumesny
6
6
  * see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
7
7
  */
8
8
  import { GridStackEngine } from './gridstack-engine';
@@ -11,7 +11,6 @@ import { ColumnOptions, GridItemHTMLElement, GridStackElement, GridStackEventHan
11
11
  export * from './types';
12
12
  export * from './utils';
13
13
  export * from './gridstack-engine';
14
- export * from './gridstack-ddi';
15
14
  export interface GridHTMLElement extends HTMLElement {
16
15
  gridstack?: GridStack;
17
16
  }
@@ -70,6 +69,11 @@ export declare class GridStack {
70
69
  * @param opt grids options used to initialize the grid, and list of children
71
70
  */
72
71
  static addGrid(parent: HTMLElement, opt?: GridStackOptions): GridStack;
72
+ /** call this method to register your engine instead of the default one.
73
+ * See instead `GridStackOptions.engineClass` if you only need to
74
+ * replace just one instance.
75
+ */
76
+ static registerEngine(engineClass: typeof GridStackEngine): void;
73
77
  /** scoping so users can call GridStack.Utils.sort() for example */
74
78
  static Utils: typeof Utils;
75
79
  /** scoping so users can call new GridStack.Engine(12) for example */
@@ -80,6 +84,7 @@ export declare class GridStack {
80
84
  engine: GridStackEngine;
81
85
  /** grid options - public for classes to access, but use methods to modify! */
82
86
  opts: GridStackOptions;
87
+ protected static engineClass: typeof GridStackEngine;
83
88
  /**
84
89
  * Construct a grid item from the given element and options
85
90
  * @param el
@@ -124,9 +129,10 @@ export declare class GridStack {
124
129
  **/
125
130
  load(layout: GridStackWidget[], addAndRemove?: boolean | ((g: GridStack, w: GridStackWidget, add: boolean) => GridItemHTMLElement)): GridStack;
126
131
  /**
127
- * Initializes batch updates. You will see no changes until `commit()` method is called.
132
+ * use before calling a bunch of `addWidget()` to prevent un-necessary relayouts in between (more efficient)
133
+ * and get a single event callback. You will see no changes until `batchUpdate(false)` is called.
128
134
  */
129
- batchUpdate(): GridStack;
135
+ batchUpdate(flag?: boolean): GridStack;
130
136
  /**
131
137
  * Gets current cell height.
132
138
  */
@@ -149,11 +155,7 @@ export declare class GridStack {
149
155
  /** Gets current cell width. */
150
156
  cellWidth(): number;
151
157
  /** return our expected width (or parent) for 1 column check */
152
- private _widthOrContainer;
153
- /**
154
- * Finishes batch updates. Updates DOM nodes. You must call it after batchUpdate.
155
- */
156
- commit(): GridStack;
158
+ protected _widthOrContainer(): number;
157
159
  /** re-layout grid items to reclaim any empty space */
158
160
  compact(): GridStack;
159
161
  /**
@@ -294,13 +296,14 @@ export declare class GridStack {
294
296
  */
295
297
  onParentResize(): GridStack;
296
298
  /** add or remove the window size event handler */
297
- private _updateWindowResizeEvent;
299
+ protected _updateWindowResizeEvent(forceRemove?: boolean): GridStack;
300
+ static GDRev: string;
298
301
  /**
299
302
  * call to setup dragging in from the outside (say toolbar), by specifying the class selection and options.
300
303
  * Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar
301
304
  * is dynamically create and needs to change later.
302
305
  * @param dragIn string selector (ex: '.sidebar .grid-stack-item')
303
- * @param dragInOptions options - see DDDragInOpt. (default: {revert: 'invalid', handle: '.grid-stack-item-content', scroll: false, appendTo: 'body'}
306
+ * @param dragInOptions options - see DDDragInOpt. (default: {handle: '.grid-stack-item-content', appendTo: 'body'}
304
307
  **/
305
308
  static setupDragIn(dragIn?: string, dragInOptions?: DDDragInOpt): void;
306
309
  /**
@@ -343,4 +346,6 @@ export declare class GridStack {
343
346
  * Enables/disables widget resizing. No-op for static grids.
344
347
  */
345
348
  enableResize(doEnable: boolean): GridStack;
349
+ commit(): GridStack;
346
350
  }
351
+ export * from './dd-gridstack';
package/dist/gridstack.js CHANGED
@@ -12,20 +12,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.GridStack = void 0;
14
14
  /*!
15
- * GridStack 5.0
15
+ * GridStack 6.0.0
16
16
  * https://gridstackjs.com/
17
17
  *
18
- * Copyright (c) 2021 Alain Dumesny
18
+ * Copyright (c) 2021-2022 Alain Dumesny
19
19
  * see root license https://github.com/gridstack/gridstack.js/tree/master/LICENSE
20
20
  */
21
21
  const gridstack_engine_1 = require("./gridstack-engine");
22
22
  const utils_1 = require("./utils");
23
- const gridstack_ddi_1 = require("./gridstack-ddi");
24
23
  // export all dependent file as well to make it easier for users to just import the main file
25
24
  __exportStar(require("./types"), exports);
26
25
  __exportStar(require("./utils"), exports);
27
26
  __exportStar(require("./gridstack-engine"), exports);
28
- __exportStar(require("./gridstack-ddi"), exports);
29
27
  // default values for grid options - used during init and when saving out
30
28
  const GridDefaults = {
31
29
  column: 12,
@@ -41,18 +39,16 @@ const GridDefaults = {
41
39
  cellHeightThrottle: 100,
42
40
  margin: 10,
43
41
  auto: true,
44
- minWidth: 768,
42
+ oneColumnSize: 768,
45
43
  float: false,
46
44
  staticGrid: false,
47
45
  animate: true,
48
- alwaysShowResizeHandle: false,
46
+ alwaysShowResizeHandle: 'mobile',
49
47
  resizable: {
50
- autoHide: true,
51
48
  handles: 'se'
52
49
  },
53
50
  draggable: {
54
51
  handle: '.grid-stack-item-content',
55
- scroll: false,
56
52
  appendTo: 'body'
57
53
  },
58
54
  disableDrag: false,
@@ -65,7 +61,7 @@ const GridDefaults = {
65
61
  marginUnit: 'px',
66
62
  cellHeightUnit: 'px',
67
63
  disableOneColumnMode: false,
68
- oneColumnModeDomSort: false
64
+ oneColumnModeDomSort: false,
69
65
  };
70
66
  /**
71
67
  * Main gridstack class - you will need to call `GridStack.init()` first to initialize your grid.
@@ -100,25 +96,31 @@ class GridStack {
100
96
  if (opts.column === 'auto') {
101
97
  delete opts.column;
102
98
  }
103
- // elements attributes override any passed options (like CSS style) - merge the two together
104
- let defaults = Object.assign(Object.assign({}, utils_1.Utils.cloneDeep(GridDefaults)), { column: utils_1.Utils.toNumber(el.getAttribute('gs-column')) || 12, minRow: rowAttr ? rowAttr : utils_1.Utils.toNumber(el.getAttribute('gs-min-row')) || 0, maxRow: rowAttr ? rowAttr : utils_1.Utils.toNumber(el.getAttribute('gs-max-row')) || 0, staticGrid: utils_1.Utils.toBool(el.getAttribute('gs-static')) || false, _styleSheetClass: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0), alwaysShowResizeHandle: opts.alwaysShowResizeHandle || false, resizable: {
105
- autoHide: !(opts.alwaysShowResizeHandle || false),
106
- handles: 'se'
107
- }, draggable: {
108
- handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || '.grid-stack-item-content',
109
- scroll: false,
110
- appendTo: 'body'
99
+ // 'minWidth' legacy support in 5.1
100
+ /* eslint-disable-next-line @typescript-eslint/no-explicit-any */
101
+ let anyOpts = opts;
102
+ if (anyOpts.minWidth !== undefined) {
103
+ opts.oneColumnSize = opts.oneColumnSize || anyOpts.minWidth;
104
+ delete anyOpts.minWidth;
105
+ }
106
+ // save original setting so we can restore on save
107
+ if (opts.alwaysShowResizeHandle !== undefined) {
108
+ opts._alwaysShowResizeHandle = opts.alwaysShowResizeHandle;
109
+ }
110
+ // elements DOM attributes override any passed options (like CSS style) - merge the two together
111
+ let defaults = Object.assign(Object.assign({}, utils_1.Utils.cloneDeep(GridDefaults)), { column: utils_1.Utils.toNumber(el.getAttribute('gs-column')) || GridDefaults.column, minRow: rowAttr ? rowAttr : utils_1.Utils.toNumber(el.getAttribute('gs-min-row')) || GridDefaults.minRow, maxRow: rowAttr ? rowAttr : utils_1.Utils.toNumber(el.getAttribute('gs-max-row')) || GridDefaults.maxRow, staticGrid: utils_1.Utils.toBool(el.getAttribute('gs-static')) || GridDefaults.staticGrid, _styleSheetClass: 'grid-stack-instance-' + (Math.random() * 10000).toFixed(0), draggable: {
112
+ handle: (opts.handleClass ? '.' + opts.handleClass : (opts.handle ? opts.handle : '')) || GridDefaults.draggable.handle,
111
113
  }, removableOptions: {
112
- accept: '.' + (opts.itemClass || 'grid-stack-item')
114
+ accept: opts.itemClass ? '.' + opts.itemClass : GridDefaults.removableOptions.accept,
113
115
  } });
114
116
  if (el.getAttribute('gs-animate')) { // default to true, but if set to false use that instead
115
117
  defaults.animate = utils_1.Utils.toBool(el.getAttribute('gs-animate'));
116
118
  }
117
119
  this.opts = utils_1.Utils.defaults(opts, defaults);
118
120
  opts = null; // make sure we use this.opts instead
119
- this.initMargin(); // part of settings defaults...
121
+ this._initMargin(); // part of settings defaults...
120
122
  // Now check if we're loading into 1 column mode FIRST so we don't do un-necessary work (like cellHeight = width / 12 then go 1 column)
121
- if (this.opts.column !== 1 && !this.opts.disableOneColumnMode && this._widthOrContainer() <= this.opts.minWidth) {
123
+ if (this.opts.column !== 1 && !this.opts.disableOneColumnMode && this._widthOrContainer() <= this.opts.oneColumnSize) {
122
124
  this._prevColumn = this.getColumn();
123
125
  this.opts.column = 1;
124
126
  }
@@ -149,9 +151,14 @@ class GridStack {
149
151
  }
150
152
  this.cellHeight(this.opts.cellHeight, false);
151
153
  }
154
+ // see if we need to adjust auto-hide
155
+ if (this.opts.alwaysShowResizeHandle === 'mobile') {
156
+ this.opts.alwaysShowResizeHandle = dd_touch_1.isTouch;
157
+ }
152
158
  this.el.classList.add(this.opts._styleSheetClass);
153
159
  this._setStaticClass();
154
- this.engine = new gridstack_engine_1.GridStackEngine({
160
+ let engineClass = this.opts.engineClass || GridStack.engineClass || gridstack_engine_1.GridStackEngine;
161
+ this.engine = new engineClass({
155
162
  column: this.getColumn(),
156
163
  float: this.opts.float,
157
164
  maxRow: this.opts.maxRow,
@@ -187,7 +194,7 @@ class GridStack {
187
194
  });
188
195
  });
189
196
  elements.sort((a, b) => a.i - b.i).forEach(e => this._prepareElement(e.el));
190
- this.commit();
197
+ this.batchUpdate(false);
191
198
  }
192
199
  this.setAnimation(this.opts.animate);
193
200
  this._updateStyles();
@@ -285,6 +292,13 @@ class GridStack {
285
292
  }
286
293
  return grid;
287
294
  }
295
+ /** call this method to register your engine instead of the default one.
296
+ * See instead `GridStackOptions.engineClass` if you only need to
297
+ * replace just one instance.
298
+ */
299
+ static registerEngine(engineClass) {
300
+ GridStack.engineClass = engineClass;
301
+ }
288
302
  /** @internal create placeholder DIV as needed */
289
303
  get placeholder() {
290
304
  if (!this._placeholder) {
@@ -431,6 +445,14 @@ class GridStack {
431
445
  o.column = 'auto';
432
446
  delete o.disableOneColumnMode;
433
447
  }
448
+ const origShow = o._alwaysShowResizeHandle;
449
+ delete o._alwaysShowResizeHandle;
450
+ if (origShow !== undefined) {
451
+ o.alwaysShowResizeHandle = origShow;
452
+ }
453
+ else {
454
+ delete o.alwaysShowResizeHandle;
455
+ }
434
456
  utils_1.Utils.removeInternalAndSame(o, GridDefaults);
435
457
  o.children = list;
436
458
  return o;
@@ -497,17 +519,23 @@ class GridStack {
497
519
  }
498
520
  });
499
521
  this.engine.removedNodes = removed;
500
- this.commit();
522
+ this.batchUpdate(false);
501
523
  // after commit, clear that flag
502
524
  delete this._ignoreLayoutsNodeChange;
503
525
  delete this._insertNotAppend;
504
526
  return this;
505
527
  }
506
528
  /**
507
- * Initializes batch updates. You will see no changes until `commit()` method is called.
529
+ * use before calling a bunch of `addWidget()` to prevent un-necessary relayouts in between (more efficient)
530
+ * and get a single event callback. You will see no changes until `batchUpdate(false)` is called.
508
531
  */
509
- batchUpdate() {
510
- this.engine.batchUpdate();
532
+ batchUpdate(flag = true) {
533
+ this.engine.batchUpdate(flag);
534
+ if (!flag) {
535
+ this._triggerRemoveEvent();
536
+ this._triggerAddEvent();
537
+ this._triggerChangeEvent();
538
+ }
511
539
  return this;
512
540
  }
513
541
  /**
@@ -580,16 +608,6 @@ class GridStack {
580
608
  // https://stackoverflow.com/questions/21064101/understanding-offsetwidth-clientwidth-scrollwidth-and-height-respectively
581
609
  return (this.el.clientWidth || this.el.parentElement.clientWidth || window.innerWidth);
582
610
  }
583
- /**
584
- * Finishes batch updates. Updates DOM nodes. You must call it after batchUpdate.
585
- */
586
- commit() {
587
- this.engine.commit();
588
- this._triggerRemoveEvent();
589
- this._triggerAddEvent();
590
- this._triggerChangeEvent();
591
- return this;
592
- }
593
611
  /** re-layout grid items to reclaim any empty space */
594
612
  compact() {
595
613
  this.engine.compact();
@@ -837,7 +855,7 @@ class GridStack {
837
855
  return;
838
856
  // remove our DOM data (circular link) and drag&drop permanently
839
857
  delete el.gridstackNode;
840
- gridstack_ddi_1.GridStackDDI.get().remove(el);
858
+ this._removeDD(el);
841
859
  this.engine.removeNode(node, removeDOM, triggerEvent);
842
860
  if (removeDOM && el.parentElement) {
843
861
  el.remove(); // in batch mode engine.removeNode doesn't call back to remove DOM
@@ -857,7 +875,7 @@ class GridStack {
857
875
  // always remove our DOM data (circular link) before list gets emptied and drag&drop permanently
858
876
  this.engine.nodes.forEach(n => {
859
877
  delete n.el.gridstackNode;
860
- gridstack_ddi_1.GridStackDDI.get().remove(n.el);
878
+ this._removeDD(n.el);
861
879
  });
862
880
  this.engine.removeAll(removeDOM);
863
881
  this._triggerRemoveEvent();
@@ -978,7 +996,7 @@ class GridStack {
978
996
  // re-use existing margin handling
979
997
  this.opts.margin = value;
980
998
  this.opts.marginTop = this.opts.marginBottom = this.opts.marginLeft = this.opts.marginRight = undefined;
981
- this.initMargin();
999
+ this._initMargin();
982
1000
  this._updateStyles(true); // true = force re-create
983
1001
  return this;
984
1002
  }
@@ -1262,7 +1280,7 @@ class GridStack {
1262
1280
  }
1263
1281
  else {
1264
1282
  // else check for 1 column in/out behavior
1265
- let oneColumn = !this.opts.disableOneColumnMode && this.el.clientWidth <= this.opts.minWidth;
1283
+ let oneColumn = !this.opts.disableOneColumnMode && this.el.clientWidth <= this.opts.oneColumnSize;
1266
1284
  if ((this.opts.column === 1) !== oneColumn) {
1267
1285
  changedColumn = true;
1268
1286
  if (this.opts.animate) {
@@ -1318,7 +1336,7 @@ class GridStack {
1318
1336
  /** @internal */
1319
1337
  static getGridElements(els) { return utils_1.Utils.getElements(els); }
1320
1338
  /** @internal initialize margin top/bottom/left/right and units */
1321
- initMargin() {
1339
+ _initMargin() {
1322
1340
  let data;
1323
1341
  let margin = 0;
1324
1342
  // support passing multiple values like CSS (ex: '5px 10px 0 20px')
@@ -1381,7 +1399,7 @@ class GridStack {
1381
1399
  return this;
1382
1400
  }
1383
1401
  /*
1384
- * drag&drop empty stubs that will be implemented in gridstack-dd.ts for non static grid
1402
+ * drag&drop empty stubs that will be implemented in dd-gridstack.ts for non static grid
1385
1403
  * so we don't incur the load unless needed.
1386
1404
  * NOTE: had to make those methods public in order to define them else as
1387
1405
  * GridStack.prototype._setupAcceptWidget = function()
@@ -1393,7 +1411,7 @@ class GridStack {
1393
1411
  * Called during GridStack.init() as options, but can also be called directly (last param are cached) in case the toolbar
1394
1412
  * is dynamically create and needs to change later.
1395
1413
  * @param dragIn string selector (ex: '.sidebar .grid-stack-item')
1396
- * @param dragInOptions options - see DDDragInOpt. (default: {revert: 'invalid', handle: '.grid-stack-item-content', scroll: false, appendTo: 'body'}
1414
+ * @param dragInOptions options - see DDDragInOpt. (default: {handle: '.grid-stack-item-content', appendTo: 'body'}
1397
1415
  **/
1398
1416
  static setupDragIn(dragIn, dragInOptions) { }
1399
1417
  /**
@@ -1436,6 +1454,8 @@ class GridStack {
1436
1454
  * Enables/disables widget resizing. No-op for static grids.
1437
1455
  */
1438
1456
  enableResize(doEnable) { return this; }
1457
+ /** @internal removes any drag&drop present (called during destroy) */
1458
+ _removeDD(el) { return this; }
1439
1459
  /** @internal called to add drag over support to support widgets */
1440
1460
  _setupAcceptWidget() { return this; }
1441
1461
  /** @internal called to setup a trash drop zone if the user specifies it */
@@ -1448,10 +1468,15 @@ class GridStack {
1448
1468
  _dragOrResize(el, event, ui, node, cellWidth, cellHeight) { return; }
1449
1469
  /** @internal called when a node leaves our area (mouse out or shape outside) **/
1450
1470
  _leave(el, helper) { return; }
1471
+ // legacy method removed
1472
+ commit() { utils_1.obsolete(this, this.batchUpdate(false), 'commit', 'batchUpdate', '5.2'); return this; }
1451
1473
  }
1452
1474
  exports.GridStack = GridStack;
1453
1475
  /** scoping so users can call GridStack.Utils.sort() for example */
1454
1476
  GridStack.Utils = utils_1.Utils;
1455
1477
  /** scoping so users can call new GridStack.Engine(12) for example */
1456
1478
  GridStack.Engine = gridstack_engine_1.GridStackEngine;
1479
+ GridStack.GDRev = '6.0.0';
1480
+ const dd_touch_1 = require("./dd-touch");
1481
+ __exportStar(require("./dd-gridstack"), exports);
1457
1482
  //# sourceMappingURL=gridstack.js.map