gridstack 4.2.6 → 4.4.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 (128) hide show
  1. package/README.md +29 -19
  2. package/dist/es5/gridstack-dd.d.ts +35 -0
  3. package/dist/es5/gridstack-dd.js +683 -0
  4. package/dist/es5/gridstack-dd.js.map +1 -0
  5. package/dist/es5/gridstack-ddi.d.ts +17 -0
  6. package/dist/es5/gridstack-ddi.js +31 -0
  7. package/dist/es5/gridstack-ddi.js.map +1 -0
  8. package/dist/es5/gridstack-engine.d.ts +93 -0
  9. package/dist/es5/gridstack-engine.js +955 -0
  10. package/dist/es5/gridstack-engine.js.map +1 -0
  11. package/dist/es5/gridstack-h5.d.ts +10 -0
  12. package/dist/es5/gridstack-h5.js +3 -0
  13. package/dist/es5/gridstack-h5.js.LICENSE.txt +7 -0
  14. package/dist/es5/gridstack-h5.js.map +1 -0
  15. package/dist/es5/gridstack-jq.d.ts +10 -0
  16. package/dist/es5/gridstack-jq.js +3 -0
  17. package/dist/es5/gridstack-jq.js.LICENSE.txt +99 -0
  18. package/dist/es5/gridstack-jq.js.map +1 -0
  19. package/dist/{gridstack-poly.js → es5/gridstack-poly.js} +152 -1
  20. package/dist/es5/gridstack-static.d.ts +9 -0
  21. package/dist/es5/gridstack-static.js +3 -0
  22. package/dist/es5/gridstack-static.js.LICENSE.txt +7 -0
  23. package/dist/es5/gridstack-static.js.map +1 -0
  24. package/dist/es5/gridstack.d.ts +346 -0
  25. package/dist/es5/gridstack.js +1482 -0
  26. package/dist/es5/gridstack.js.map +1 -0
  27. package/dist/es5/h5/dd-base-impl.d.ts +20 -0
  28. package/dist/es5/h5/dd-base-impl.js +43 -0
  29. package/dist/es5/h5/dd-base-impl.js.map +1 -0
  30. package/dist/es5/h5/dd-draggable.d.ts +30 -0
  31. package/dist/es5/h5/dd-draggable.js +319 -0
  32. package/dist/es5/h5/dd-draggable.js.map +1 -0
  33. package/dist/es5/h5/dd-droppable.d.ts +23 -0
  34. package/dist/es5/h5/dd-droppable.js +182 -0
  35. package/dist/es5/h5/dd-droppable.js.map +1 -0
  36. package/dist/es5/h5/dd-element.d.ts +27 -0
  37. package/dist/es5/h5/dd-element.js +96 -0
  38. package/dist/es5/h5/dd-element.js.map +1 -0
  39. package/dist/es5/h5/dd-manager.d.ts +8 -0
  40. package/dist/es5/h5/dd-manager.js +14 -0
  41. package/dist/es5/h5/dd-manager.js.map +1 -0
  42. package/dist/es5/h5/dd-resizable-handle.d.ts +14 -0
  43. package/dist/es5/h5/dd-resizable-handle.js +83 -0
  44. package/dist/es5/h5/dd-resizable-handle.js.map +1 -0
  45. package/dist/es5/h5/dd-resizable.d.ts +29 -0
  46. package/dist/es5/h5/dd-resizable.js +302 -0
  47. package/dist/es5/h5/dd-resizable.js.map +1 -0
  48. package/dist/es5/h5/dd-utils.d.ts +17 -0
  49. package/dist/es5/h5/dd-utils.js +99 -0
  50. package/dist/es5/h5/dd-utils.js.map +1 -0
  51. package/dist/es5/h5/gridstack-dd-native.d.ts +26 -0
  52. package/dist/es5/h5/gridstack-dd-native.js +175 -0
  53. package/dist/es5/h5/gridstack-dd-native.js.map +1 -0
  54. package/dist/es5/jq/gridstack-dd-jqueryui.d.ts +22 -0
  55. package/dist/es5/jq/gridstack-dd-jqueryui.js +162 -0
  56. package/dist/es5/jq/gridstack-dd-jqueryui.js.map +1 -0
  57. package/dist/es5/types.d.ts +258 -0
  58. package/dist/es5/types.js +7 -0
  59. package/dist/es5/types.js.map +1 -0
  60. package/dist/es5/utils.d.ts +73 -0
  61. package/dist/es5/utils.js +444 -0
  62. package/dist/es5/utils.js.map +1 -0
  63. package/dist/gridstack-dd.d.ts +1 -1
  64. package/dist/gridstack-dd.js +16 -8
  65. package/dist/gridstack-dd.js.map +1 -1
  66. package/dist/gridstack-ddi.d.ts +1 -1
  67. package/dist/gridstack-ddi.js +1 -1
  68. package/dist/gridstack-ddi.js.map +1 -1
  69. package/dist/gridstack-engine.d.ts +3 -2
  70. package/dist/gridstack-engine.js +101 -61
  71. package/dist/gridstack-engine.js.map +1 -1
  72. package/dist/gridstack-extra.css +800 -530
  73. package/dist/gridstack-extra.min.css +1 -1
  74. package/dist/gridstack-h5.d.ts +1 -1
  75. package/dist/gridstack-h5.js +1 -1
  76. package/dist/gridstack-h5.js.LICENSE.txt +1 -1
  77. package/dist/gridstack-h5.js.map +1 -1
  78. package/dist/gridstack-jq.d.ts +1 -1
  79. package/dist/gridstack-jq.js +1 -1
  80. package/dist/gridstack-jq.js.LICENSE.txt +1 -1
  81. package/dist/gridstack-jq.js.map +1 -1
  82. package/dist/gridstack-static.d.ts +1 -1
  83. package/dist/gridstack-static.js +1 -1
  84. package/dist/gridstack-static.js.LICENSE.txt +1 -1
  85. package/dist/gridstack-static.js.map +1 -1
  86. package/dist/gridstack.css +305 -228
  87. package/dist/gridstack.d.ts +1 -1
  88. package/dist/gridstack.js +19 -12
  89. package/dist/gridstack.js.map +1 -1
  90. package/dist/gridstack.min.css +1 -1
  91. package/dist/h5/dd-base-impl.d.ts +1 -1
  92. package/dist/h5/dd-base-impl.js +1 -1
  93. package/dist/h5/dd-base-impl.js.map +1 -1
  94. package/dist/h5/dd-draggable.d.ts +1 -1
  95. package/dist/h5/dd-draggable.js +1 -1
  96. package/dist/h5/dd-draggable.js.map +1 -1
  97. package/dist/h5/dd-droppable.d.ts +1 -1
  98. package/dist/h5/dd-droppable.js +1 -1
  99. package/dist/h5/dd-droppable.js.map +1 -1
  100. package/dist/h5/dd-element.d.ts +1 -1
  101. package/dist/h5/dd-element.js +1 -1
  102. package/dist/h5/dd-element.js.map +1 -1
  103. package/dist/h5/dd-manager.d.ts +1 -1
  104. package/dist/h5/dd-manager.js +1 -1
  105. package/dist/h5/dd-manager.js.map +1 -1
  106. package/dist/h5/dd-resizable-handle.d.ts +1 -1
  107. package/dist/h5/dd-resizable-handle.js +1 -1
  108. package/dist/h5/dd-resizable-handle.js.map +1 -1
  109. package/dist/h5/dd-resizable.d.ts +1 -1
  110. package/dist/h5/dd-resizable.js +2 -1
  111. package/dist/h5/dd-resizable.js.map +1 -1
  112. package/dist/h5/dd-utils.d.ts +1 -1
  113. package/dist/h5/dd-utils.js +1 -1
  114. package/dist/h5/dd-utils.js.map +1 -1
  115. package/dist/h5/gridstack-dd-native.d.ts +1 -1
  116. package/dist/h5/gridstack-dd-native.js +1 -1
  117. package/dist/h5/gridstack-dd-native.js.map +1 -1
  118. package/dist/jq/gridstack-dd-jqueryui.js.map +1 -1
  119. package/dist/src/gridstack-extra.scss +7 -5
  120. package/dist/src/gridstack.scss +9 -7
  121. package/dist/types.d.ts +5 -2
  122. package/dist/types.js +1 -1
  123. package/dist/types.js.map +1 -1
  124. package/dist/utils.d.ts +3 -1
  125. package/dist/utils.js +7 -5
  126. package/dist/utils.js.map +1 -1
  127. package/doc/CHANGES.md +26 -0
  128. package/package.json +6 -5
package/README.md CHANGED
@@ -92,19 +92,28 @@ which means you can possibly bring your own version
92
92
  },
93
93
  ```
94
94
 
95
- Alternatively in html
95
+ Alternatively (single combined file) in html
96
96
 
97
97
  ```html
98
98
  <link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
99
- <!-- HTML5 drag&drop (68k) -->
99
+ <!-- HTML5 drag&drop (70k) -->
100
100
  <script src="node_modules/gridstack/dist/gridstack-h5.js"></script>
101
- <!-- OR jquery-ui drag&drop (193k) -->
101
+ <!-- OR jquery-ui drag&drop (195k) -->
102
102
  <script src="node_modules/gridstack/dist/gridstack-jq.js"></script>
103
- <!-- OR static grid (38k) -->
103
+ <!-- OR static grid (40k) -->
104
104
  <script src="node_modules/gridstack/dist/gridstack-static.js"></script>
105
105
  ```
106
106
 
107
- Note: the API is the same, regardless of the plugin (or lack thereof) so you can switch at any time. The Jquery version will export $ that it bundles and currently the only one to support mobile/touch devices through `jquery.ui.touch-punch` (h5 version is planned). Read more at [migrating to v3](#migrating-to-v3)
107
+ **Note**: the API is the same, regardless of the plugin (or lack thereof) so you can switch at any time. The Jquery version will export $ that it bundles and currently the only one to support mobile/touch devices through `jquery.ui.touch-punch` (h5 version is planned). Read more at [migrating to v3](#migrating-to-v3)
108
+
109
+ **Note2**: IE support was dropped in v2, but restored in v4.4 by an external contributor (I have no interest in testing+supporting obsolete browser so this might break in the future).
110
+ You can use the es5 files and polyfill (larger) for older browser instead. For example:
111
+ ```html
112
+ <link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
113
+ <script src="node_modules/gridstack/dist/es5/gridstack-poly.js"></script>
114
+ <script src="node_modules/gridstack/dist/es5/gridstack-jq.js"></script>
115
+ ```
116
+
108
117
 
109
118
  ## Basic usage
110
119
 
@@ -189,10 +198,10 @@ GridStack.init( {column: N} );
189
198
  ```html
190
199
  <link href="node_modules/gridstack/dist/gridstack-extra.css" rel="stylesheet"/>
191
200
 
192
- <div class="grid-stack grid-stack-N">...</div>
201
+ <div class="grid-stack">...</div>
193
202
  ```
194
203
 
195
- Note: class `.grid-stack-N` was added and we include `gridstack-extra.css` which defines CSS for grids with custom [2-11] columns. Anything more and you'll need to generate the SASS/CSS yourself (see next).
204
+ Note: class `.grid-stack-N` will automatically be added and we include `gridstack-extra.css` which defines CSS for grids with custom [2-11] columns. Anything more and you'll need to generate the SASS/CSS yourself (see next).
196
205
 
197
206
  See example: [2 grids demo](http://gridstack.github.io/gridstack.js/demo/two.html) with 6 columns
198
207
 
@@ -204,11 +213,11 @@ For instance for 3-column grid you need to rewrite CSS to be:
204
213
 
205
214
  ```css
206
215
  .grid-stack-item[gs-w="3"] { width: 100% }
207
- .grid-stack-item[gs-w="2"] { width: 66.66666667% }
208
- .grid-stack-item[gs-w="1"] { width: 33.33333333% }
216
+ .grid-stack-item[gs-w="2"] { width: 66.67% }
217
+ .grid-stack-item[gs-w="1"] { width: 33.33% }
209
218
 
210
- .grid-stack-item[gs-x="2"] { left: 66.66666667% }
211
- .grid-stack-item[gs-x="1"] { left: 33.33333333% }
219
+ .grid-stack-item[gs-x="2"] { left: 66.67% }
220
+ .grid-stack-item[gs-x="1"] { left: 33.33% }
212
221
  ```
213
222
 
214
223
  For 4-column grid it should be:
@@ -229,23 +238,23 @@ and so on.
229
238
  Better yet, here is a SASS code snippet which can make life much easier (Thanks to @ascendantofrain, [#81](https://github.com/gridstack/gridstack.js/issues/81) and @StefanM98, [#868](https://github.com/gridstack/gridstack.js/issues/868)) and you can use sites like [sassmeister.com](https://www.sassmeister.com/) to generate the CSS for you instead:
230
239
 
231
240
  ```sass
241
+ @use "sass;math";
232
242
  .grid-stack > .grid-stack-item {
233
243
 
234
244
  $gridstack-columns: 12;
235
245
 
236
- min-width: (100% / $gridstack-columns);
246
+ min-width: math.div(100%, $gridstack-columns);
237
247
 
238
- @for $i from 1 through $gridstack-columns {
239
- &[gs-w='#{$i}'] { width: (100% / $gridstack-columns) * $i; }
240
- &[gs-x='#{$i}'] { left: (100% / $gridstack-columns) * $i; }
241
- &[gs-min-w='#{$i}'] { min-width: (100% / $gridstack-columns) * $i; }
242
- &[gs-max-w='#{$i}'] { max-width: (100% / $gridstack-columns) * $i; }
248
+ @for $i from 0 through $gridstack-columns {
249
+ &[gs-w='#{$i}'] { width: math.div(100%, $gridstack-columns) * $i; }
250
+ &[gs-x='#{$i}'] { left: math.div(100%, $gridstack-columns) * $i; }
251
+ &[gs-min-w='#{$i}'] { min-width: math.div(100%, $gridstack-columns) * $i; }
252
+ &[gs-max-w='#{$i}'] { max-width: math.div(100%, $gridstack-columns) * $i; }
243
253
  }
244
254
  }
245
255
  ```
246
256
 
247
- you can also use the SASS [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
248
- and also have the `.grid-stack-N` prefix to support letting the user change columns dynamically.
257
+ you can also use the SASS [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.
249
258
 
250
259
  Sample gulp command for 30 columns:
251
260
  ```js
@@ -298,6 +307,7 @@ search for ['gridstack' under NPM](https://www.npmjs.com/search?q=gridstack&rank
298
307
  - **Rails**: [gridstack-js-rails](https://github.com/randoum/gridstack-js-rails)
299
308
  - **React**: see [demo](https://gridstackjs.com/demo/react.html) with [src](https://github.com/gridstack/gridstack.js/tree/master/demo/react.html), or [react-gridstack-example](https://github.com/Inder2108/react-gridstack-example/tree/master/src/App.js), or read on what [hooks to use](https://github.com/gridstack/gridstack.js/issues/735#issuecomment-329888796)
300
309
  - **Vue**: see [demo](https://gridstackjs.com/demo/vue3js.html) with [v3 src](https://github.com/gridstack/gridstack.js/tree/master/demo/vue3js.html) or [v2 src](https://github.com/gridstack/gridstack.js/tree/master/demo/vue2js.html)
310
+ - **Aurelia**: [aurelia-gridstack](https://github.com/aurelia-ui-toolkits/aurelia-gridstack), see [demo](https://aurelia-ui-toolkits.github.io/aurelia-gridstack/)
301
311
 
302
312
  # Migrating
303
313
  ## Migrating to v0.6
@@ -0,0 +1,35 @@
1
+ /**
2
+ * gridstack-dd.ts 4.4.0
3
+ * Copyright (c) 2021 Alain Dumesny - see GridStack root license
4
+ */
5
+ import { GridStackDDI } from './gridstack-ddi';
6
+ import { GridItemHTMLElement, GridStackElement, DDDragInOpt } from './types';
7
+ /** Drag&Drop drop options */
8
+ export declare type DDDropOpt = {
9
+ /** function or class type that this grid will accept as dropped items (see GridStackOptions.acceptWidgets) */
10
+ accept?: (el: GridItemHTMLElement) => boolean;
11
+ };
12
+ /** drag&drop options currently called from the main code, but others can be passed in grid options */
13
+ export declare type DDOpts = 'enable' | 'disable' | 'destroy' | 'option' | string | any;
14
+ export declare type DDKey = 'minWidth' | 'minHeight' | 'maxWidth' | 'maxHeight';
15
+ export declare type DDValue = number | string;
16
+ /** drag&drop events callbacks */
17
+ export declare type DDCallback = (event: Event, arg2: GridItemHTMLElement, helper?: GridItemHTMLElement) => void;
18
+ /**
19
+ * Base class implementing common Grid drag'n'drop functionality, with domain specific subclass (h5 vs jq subclasses)
20
+ */
21
+ export declare abstract class GridStackDD extends GridStackDDI {
22
+ /** override to cast to correct type */
23
+ static get(): GridStackDD;
24
+ /** removes any drag&drop present (called during destroy) */
25
+ remove(el: GridItemHTMLElement): GridStackDD;
26
+ abstract resizable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;
27
+ abstract isResizable(el: HTMLElement): boolean;
28
+ abstract draggable(el: GridItemHTMLElement, opts: DDOpts, key?: DDKey, value?: DDValue): GridStackDD;
29
+ abstract dragIn(el: GridStackElement, opts: DDDragInOpt): GridStackDD;
30
+ abstract isDraggable(el: HTMLElement): boolean;
31
+ abstract droppable(el: GridItemHTMLElement, opts: DDOpts | DDDropOpt, key?: DDKey, value?: DDValue): GridStackDD;
32
+ abstract isDroppable(el: HTMLElement): boolean;
33
+ abstract on(el: GridItemHTMLElement, eventName: string, callback: DDCallback): GridStackDD;
34
+ abstract off(el: GridItemHTMLElement, eventName: string): GridStackDD;
35
+ }