gridstack 5.1.1 → 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 +49 -38
  2. package/dist/{h5/dd-base-impl.d.ts → dd-base-impl.d.ts} +1 -1
  3. package/dist/{h5/dd-base-impl.js → dd-base-impl.js} +1 -3
  4. package/dist/dd-base-impl.js.map +1 -0
  5. package/dist/{es5/h5/dd-draggable.d.ts → dd-draggable.d.ts} +6 -7
  6. package/dist/dd-draggable.js +313 -0
  7. package/dist/dd-draggable.js.map +1 -0
  8. package/dist/{h5/dd-droppable.d.ts → dd-droppable.d.ts} +3 -2
  9. package/dist/dd-droppable.js +149 -0
  10. package/dist/dd-droppable.js.map +1 -0
  11. package/dist/{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} +1 -1
  21. package/dist/{h5/dd-resizable-handle.js → dd-resizable-handle.js} +32 -8
  22. package/dist/dd-resizable-handle.js.map +1 -0
  23. package/dist/{es5/h5/dd-resizable.d.ts → dd-resizable.d.ts} +2 -2
  24. package/dist/{h5/dd-resizable.js → dd-resizable.js} +28 -27
  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} +1 -1
  30. package/dist/es5/{h5/dd-base-impl.js → dd-base-impl.js} +1 -3
  31. package/dist/es5/dd-base-impl.js.map +1 -0
  32. package/dist/{h5 → es5}/dd-draggable.d.ts +6 -7
  33. package/dist/es5/dd-draggable.js +335 -0
  34. package/dist/es5/dd-draggable.js.map +1 -0
  35. package/dist/es5/{h5/dd-droppable.d.ts → dd-droppable.d.ts} +3 -2
  36. package/dist/es5/dd-droppable.js +180 -0
  37. package/dist/es5/dd-droppable.js.map +1 -0
  38. package/dist/es5/{h5/dd-element.d.ts → 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 +1 -1
  48. package/dist/es5/{h5/dd-resizable-handle.js → dd-resizable-handle.js} +32 -8
  49. package/dist/es5/dd-resizable-handle.js.map +1 -0
  50. package/dist/{h5 → es5}/dd-resizable.d.ts +2 -2
  51. package/dist/es5/{h5/dd-resizable.js → dd-resizable.js} +28 -27
  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} +1 -1
  58. package/dist/es5/gridstack-all.js.map +1 -0
  59. package/dist/es5/gridstack-engine.d.ts +2 -3
  60. package/dist/es5/gridstack-engine.js +18 -18
  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 +8 -9
  64. package/dist/es5/gridstack.js +47 -35
  65. package/dist/es5/gridstack.js.map +1 -1
  66. package/dist/es5/types.d.ts +12 -16
  67. package/dist/es5/types.js +1 -1
  68. package/dist/es5/types.js.map +1 -1
  69. package/dist/es5/utils.d.ts +11 -1
  70. package/dist/es5/utils.js +67 -6
  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} +1 -1
  74. package/dist/gridstack-all.js.map +1 -0
  75. package/dist/gridstack-engine.d.ts +2 -3
  76. package/dist/gridstack-engine.js +17 -18
  77. package/dist/gridstack-engine.js.map +1 -1
  78. package/dist/gridstack.css +21 -9
  79. package/dist/gridstack.d.ts +8 -9
  80. package/dist/gridstack.js +45 -35
  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 +12 -16
  85. package/dist/types.js +1 -1
  86. package/dist/types.js.map +1 -1
  87. package/dist/utils.d.ts +11 -1
  88. package/dist/utils.js +64 -6
  89. package/dist/utils.js.map +1 -1
  90. package/doc/CHANGES.md +7 -0
  91. package/doc/README.md +17 -18
  92. package/package.json +2 -2
  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 -326
  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 -302
  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
package/README.md CHANGED
@@ -15,9 +15,9 @@ If you find this lib useful, please donate [PayPal](https://www.paypal.me/alaind
15
15
  [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/alaind831)
16
16
  [![Donate](https://img.shields.io/badge/Donate-Venmo-g.svg)](https://www.venmo.com/adumesny)
17
17
 
18
- Join us on Slack: https://gridstackjs.troolee.com
18
+ Join us on Slack: https://gridstackjs.slack.com
19
19
 
20
- [![Slack Status](https://gridstackjs.troolee.com/badge.svg)](https://gridstackjs.troolee.com)
20
+ [![Slack Status](https://gridstackjs.troolee.com/badge.svg)](https://gridstackjs.slack.com)
21
21
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
22
22
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
23
23
  **Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*
@@ -42,6 +42,7 @@ Join us on Slack: https://gridstackjs.troolee.com
42
42
  - [Migrating to v3](#migrating-to-v3)
43
43
  - [Migrating to v4](#migrating-to-v4)
44
44
  - [Migrating to v5](#migrating-to-v5)
45
+ - [Migrating to v6](#migrating-to-v6)
45
46
  - [jQuery Application](#jquery-application)
46
47
  - [Changes](#changes)
47
48
  - [The Team](#the-team)
@@ -71,44 +72,21 @@ ES6 or Typescript
71
72
  ```js
72
73
  import 'gridstack/dist/gridstack.min.css';
73
74
  import { GridStack } from 'gridstack';
74
- // THEN to get HTML5 drag&drop
75
- import 'gridstack/dist/h5/gridstack-dd-native';
76
- // OR to get legacy jquery-ui drag&drop (support Mobile touch devices, h5 does not yet)
77
- import 'gridstack/dist/jq/gridstack-dd-jqueryui';
78
- // OR nothing to get static grids (API driven, no user drag&drop)
79
75
  ```
80
76
 
81
- **Note**: `jquery` & `jquery-ui` are imported by name, so you will have to specify their location in your webpack (or equivalent) config file,
82
- which means you can possibly bring your own version
83
- ```js
84
- alias: {
85
- 'jquery': 'gridstack/dist/jq/jquery.js',
86
- 'jquery-ui': 'gridstack/dist/jq/jquery-ui.js',
87
- 'jquery.ui': 'gridstack/dist/jq/jquery-ui.js',
88
- 'jquery.ui.touch-punch': 'gridstack/dist/jq/jquery.ui.touch-punch.js',
89
- },
90
- ```
91
-
92
- Alternatively (single combined file) in html
77
+ Alternatively (single combined file, notice the -all.js) in html
93
78
 
94
79
  ```html
95
80
  <link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
96
- <!-- HTML5 drag&drop (70k) -->
97
- <script src="node_modules/gridstack/dist/gridstack-h5.js"></script>
98
- <!-- OR jquery-ui drag&drop (195k) -->
99
- <script src="node_modules/gridstack/dist/gridstack-jq.js"></script>
100
- <!-- OR static grid (40k) -->
101
- <script src="node_modules/gridstack/dist/gridstack-static.js"></script>
81
+ <script src="node_modules/gridstack/dist/gridstack-all.js"></script>
102
82
  ```
103
83
 
104
- **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)
105
-
106
- **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).
84
+ **Note**: 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 likely will break again in the future).
107
85
  You can use the es5 files and polyfill (larger) for older browser instead. For example:
108
86
  ```html
109
87
  <link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
110
88
  <script src="node_modules/gridstack/dist/es5/gridstack-poly.js"></script>
111
- <script src="node_modules/gridstack/dist/es5/gridstack-jq.js"></script>
89
+ <script src="node_modules/gridstack/dist/es5/gridstack-all.js"></script>
112
90
  ```
113
91
 
114
92
 
@@ -161,7 +139,7 @@ see [jsfiddle sample](https://jsfiddle.net/adumesny/jqhkry7g) as running example
161
139
 
162
140
  ## Requirements
163
141
 
164
- GridStack no longer requires external dependencies as of v1.0.0 (lodash was removed in v0.5.0 and jquery API in v1.0.0). v3.0.0 is a complete HTML5 re-write which removes all jquery dependency (still available for legacy apps). All you need to include now is `gridstack-h5.js` and `gridstack.min.css` (layouts are done using CSS column based %).
142
+ GridStack no longer requires external dependencies as of v1.0.0 (lodash was removed in v0.5.0 and jquery API in v1.0.0). v3 is a complete HTML5 re-write removing need for jquery (still available for legacy apps). v6 is native mouse and touch event for mobile support, and no longer have jquery-ui version. All you need to include now is `gridstack-all.js` and `gridstack.min.css` (layouts are done using CSS column based %).
165
143
 
166
144
  ## Extend Library
167
145
 
@@ -295,21 +273,19 @@ GridStack.init({
295
273
 
296
274
  ## Touch devices support
297
275
 
298
- gridstack v3.2 jq version compiles touch support (html5 version does not yet support `touchmove` events. This will be added in a future release), so it works out of the box, no need for anything.
299
- You **used** to need [jQuery UI Touch Punch](https://github.com/RWAP/jquery-ui-touch-punch) to make jQuery UI Draggable/Resizable
300
- work on touch-based devices (now distributed as `dist/jq/jquery.ui.touch-punch.js` for reference).
276
+ gridstack v6+ now support mobile out of the box, with the addition of native touch event (along with mouse event) for drag&drop and resize.
277
+ Older versions (3.2+) required the jq version with added touch punch, but doesn't work well with nested grids.
301
278
 
302
-
303
- This option will be useful:
279
+ This option is now the default:
304
280
 
305
281
  ```js
306
282
  let options = {
307
- alwaysShowResizeHandle: /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
283
+ alwaysShowResizeHandle: 'mobile' // which defaults to /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
308
284
  };
309
285
  GridStack.init(options);
310
286
  ```
311
287
 
312
- See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html). If you're still experiencing issues on touch devices please check [#444](https://github.com/gridstack/gridstack.js/issues/444)
288
+ See [example](http://gridstack.github.io/gridstack.js/demo/mobile.html).
313
289
 
314
290
  # gridstack.js for specific frameworks
315
291
 
@@ -457,9 +433,44 @@ make sure to read v4 migration first!
457
433
  v5 does not have any breaking changes from v4, but a focus on nested grids in h5 mode:
458
434
  You can now drag in/out of parent into nested child, with new API parameters values. See the release notes.
459
435
 
436
+ ## Migrating to v6
437
+
438
+ the API did not really change from v5, but a complete re-write of Drag&Drop to use native mouseevent (instead of HTML draggable=true which is buggy on Mac Safari, and doesn't work on mobile devices) and touchevent (mobile), and we no longer have jquery ui option (wasn't working well for nested grids, didn't want to maintain legacy lib).
439
+
440
+ The main difference is you only need to include gridstack.js and get D&D (desktop and mobile) out of the box for the same size as h5 version.
441
+
460
442
  # jQuery Application
461
443
 
462
- We now have a native HTML5 drag'n'drop through the plugin system (default), but the jquery-ui version can be used instead. It will bundle `jquery` (3.5.1) + `jquery-ui` (1.13.1 minimal drag|drop|resize) + `jquery-ui-touch-punch` (1.0.8 for mobile support) in `gridstack-jq.js`.
444
+ This is **old and no longer apply to v6+**. You'll need to use v5.1.1 and before
445
+
446
+ ```js
447
+ import 'gridstack/dist/gridstack.min.css';
448
+ import { GridStack } from 'gridstack';
449
+ import 'gridstack/dist/jq/gridstack-dd-jqueryui';
450
+ ```
451
+ **Note**: `jquery` & `jquery-ui` are imported by name, so you will have to specify their location in your webpack (or equivalent) config file,
452
+ which means you can possibly bring your own version
453
+ ```js
454
+ alias: {
455
+ 'jquery': 'gridstack/dist/jq/jquery.js',
456
+ 'jquery-ui': 'gridstack/dist/jq/jquery-ui.js',
457
+ 'jquery.ui': 'gridstack/dist/jq/jquery-ui.js',
458
+ 'jquery.ui.touch-punch': 'gridstack/dist/jq/jquery.ui.touch-punch.js',
459
+ },
460
+ ```
461
+ Alternatively (single combined file) in html
462
+
463
+ ```html
464
+ <link href="node_modules/gridstack/dist/gridstack.min.css" rel="stylesheet"/>
465
+ <!-- HTML5 drag&drop (70k) -->
466
+ <script src="node_modules/gridstack/dist/gridstack-h5.js"></script>
467
+ <!-- OR jquery-ui drag&drop (195k) -->
468
+ <script src="node_modules/gridstack/dist/gridstack-jq.js"></script>
469
+ <!-- OR static grid (40k) -->
470
+ <script src="node_modules/gridstack/dist/gridstack-static.js"></script>
471
+ ```
472
+
473
+ We have a native HTML5 drag'n'drop through the plugin system (default), but the jquery-ui version can be used instead. It will bundle `jquery` (3.5.1) + `jquery-ui` (1.13.1 minimal drag|drop|resize) + `jquery-ui-touch-punch` (1.0.8 for mobile support) in `gridstack-jq.js`.
463
474
 
464
475
  **NOTE: in v4, v3**: we ES6 module import jquery & jquery-ui by name, so you need to specify location of those .js files, which means you might be able to bring your own version as well. See the include instructions.
465
476
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * dd-base-impl.ts 5.1.1
2
+ * dd-base-impl.ts 6.0.0
3
3
  * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
4
4
  */
5
5
  export declare type EventCallback = (event: Event) => boolean | void;
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
  /**
3
- * dd-base-impl.ts 5.1.1
3
+ * dd-base-impl.ts 6.0.0
4
4
  * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.DDBaseImplement = void 0;
8
8
  class DDBaseImplement {
9
9
  constructor() {
10
- /** @internal */
11
- this._disabled = false;
12
10
  /** @internal */
13
11
  this._eventRegister = {};
14
12
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-base-impl.js","sourceRoot":"","sources":["../src/dd-base-impl.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,MAAsB,eAAe;IAArC;QAME,gBAAgB;QACN,mBAAc,GAEpB,EAAE,CAAC;IA0BT,CAAC;IAlCC,mHAAmH;IACnH,IAAW,QAAQ,KAAgB,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IASpD,EAAE,CAAC,KAAa,EAAE,QAAuB;QAC9C,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC;IACxC,CAAC;IAEM,GAAG,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAEM,MAAM;QACX,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAEM,YAAY,CAAC,SAAiB,EAAE,KAAY;QACjD,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC;YACzE,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC;IACjD,CAAC;CACF;AAnCD,0CAmCC","sourcesContent":["/**\n * dd-base-impl.ts 6.0.0\n * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license\n */\n\nexport type EventCallback = (event: Event) => boolean|void;\nexport abstract class DDBaseImplement {\n /** returns the enable state, but you have to call enable()/disable() to change (as other things need to happen) */\n public get disabled(): boolean { return this._disabled; }\n\n /** @internal */\n protected _disabled: boolean; // initial state to differentiate from false\n /** @internal */\n protected _eventRegister: {\n [eventName: string]: EventCallback;\n } = {};\n\n public on(event: string, callback: EventCallback): void {\n this._eventRegister[event] = callback;\n }\n\n public off(event: string): void {\n delete this._eventRegister[event];\n }\n\n public enable(): void {\n this._disabled = false;\n }\n\n public disable(): void {\n this._disabled = true;\n }\n\n public destroy(): void {\n delete this._eventRegister;\n }\n\n public triggerEvent(eventName: string, event: Event): boolean|void {\n if (!this.disabled && this._eventRegister && this._eventRegister[eventName])\n return this._eventRegister[eventName](event);\n }\n}\n\nexport interface HTMLElementExtendOpt<T> {\n el: HTMLElement;\n option: T;\n updateOption(T): DDBaseImplement;\n}\n"]}
@@ -1,29 +1,28 @@
1
1
  /**
2
- * dd-draggable.ts 5.1.1
2
+ * dd-draggable.ts 6.0.0
3
3
  * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
4
4
  */
5
5
  import { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';
6
- import { DDUIData } from '../types';
6
+ import { DDUIData } from './types';
7
7
  export interface DDDraggableOpt {
8
8
  appendTo?: string | HTMLElement;
9
- containment?: string | HTMLElement;
10
9
  handle?: string;
11
- revert?: string | boolean | unknown;
12
- scroll?: boolean;
13
10
  helper?: string | HTMLElement | ((event: Event) => HTMLElement);
14
11
  start?: (event: Event, ui: DDUIData) => void;
15
12
  stop?: (event: Event) => void;
16
13
  drag?: (event: Event, ui: DDUIData) => void;
17
14
  }
15
+ declare type DDDragEvent = 'drag' | 'dragstart' | 'dragstop';
18
16
  export declare class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt<DDDraggableOpt> {
19
17
  el: HTMLElement;
20
18
  option: DDDraggableOpt;
21
19
  helper: HTMLElement;
22
20
  constructor(el: HTMLElement, option?: DDDraggableOpt);
23
- on(event: 'drag' | 'dragstart' | 'dragstop', callback: (event: DragEvent) => void): void;
24
- off(event: 'drag' | 'dragstart' | 'dragstop'): void;
21
+ on(event: DDDragEvent, callback: (event: DragEvent) => void): void;
22
+ off(event: DDDragEvent): void;
25
23
  enable(): void;
26
24
  disable(forDestroy?: boolean): void;
27
25
  destroy(): void;
28
26
  updateOption(opts: DDDraggableOpt): DDDraggable;
29
27
  }
28
+ export {};
@@ -0,0 +1,313 @@
1
+ "use strict";
2
+ /**
3
+ * dd-draggable.ts 6.0.0
4
+ * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.DDDraggable = void 0;
8
+ const dd_manager_1 = require("./dd-manager");
9
+ const utils_1 = require("./utils");
10
+ const dd_base_impl_1 = require("./dd-base-impl");
11
+ const dd_touch_1 = require("./dd-touch");
12
+ // let count = 0; // TEST
13
+ class DDDraggable extends dd_base_impl_1.DDBaseImplement {
14
+ constructor(el, option = {}) {
15
+ super();
16
+ this.el = el;
17
+ this.option = option;
18
+ // get the element that is actually supposed to be dragged by
19
+ let className = option.handle.substring(1);
20
+ this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;
21
+ // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
22
+ this._mouseDown = this._mouseDown.bind(this);
23
+ this._mouseMove = this._mouseMove.bind(this);
24
+ this._mouseUp = this._mouseUp.bind(this);
25
+ this.enable();
26
+ }
27
+ on(event, callback) {
28
+ super.on(event, callback);
29
+ }
30
+ off(event) {
31
+ super.off(event);
32
+ }
33
+ enable() {
34
+ if (this.disabled === false)
35
+ return;
36
+ super.enable();
37
+ this.dragEl.addEventListener('mousedown', this._mouseDown);
38
+ if (dd_touch_1.isTouch) {
39
+ this.dragEl.addEventListener('touchstart', dd_touch_1.touchstart);
40
+ this.dragEl.addEventListener('pointerdown', dd_touch_1.pointerdown);
41
+ // this.dragEl.style.touchAction = 'none'; // not needed unlike pointerdown doc comment
42
+ }
43
+ this.el.classList.remove('ui-draggable-disabled');
44
+ this.el.classList.add('ui-draggable');
45
+ }
46
+ disable(forDestroy = false) {
47
+ if (this.disabled === true)
48
+ return;
49
+ super.disable();
50
+ this.dragEl.removeEventListener('mousedown', this._mouseDown);
51
+ if (dd_touch_1.isTouch) {
52
+ this.dragEl.removeEventListener('touchstart', dd_touch_1.touchstart);
53
+ this.dragEl.removeEventListener('pointerdown', dd_touch_1.pointerdown);
54
+ }
55
+ this.el.classList.remove('ui-draggable');
56
+ if (!forDestroy)
57
+ this.el.classList.add('ui-draggable-disabled');
58
+ }
59
+ destroy() {
60
+ if (this.dragging)
61
+ this._mouseUp(this.mouseDownEvent);
62
+ this.disable(true);
63
+ delete this.el;
64
+ delete this.helper;
65
+ delete this.option;
66
+ super.destroy();
67
+ }
68
+ updateOption(opts) {
69
+ Object.keys(opts).forEach(key => this.option[key] = opts[key]);
70
+ return this;
71
+ }
72
+ /** @internal call when mouse goes down before a dragstart happens */
73
+ _mouseDown(e) {
74
+ // don't let more than one widget handle mouseStart
75
+ if (dd_manager_1.DDManager.mouseHandled)
76
+ return;
77
+ if (e.button !== 0)
78
+ return true; // only left click
79
+ // make sure we are clicking on a drag handle or child of it...
80
+ // Note: we don't need to check that's handle is an immediate child, as mouseHandled will prevent parents from also handling it (lowest wins)
81
+ let className = this.option.handle.substring(1);
82
+ let el = e.target;
83
+ while (el && !el.classList.contains(className)) {
84
+ el = el.parentElement;
85
+ }
86
+ if (!el)
87
+ return;
88
+ this.mouseDownEvent = e;
89
+ delete this.dragging;
90
+ delete dd_manager_1.DDManager.dragElement;
91
+ delete dd_manager_1.DDManager.dropElement;
92
+ // document handler so we can continue receiving moves as the item is 'fixed' position, and capture=true so WE get a first crack
93
+ document.addEventListener('mousemove', this._mouseMove, true); // true=capture, not bubble
94
+ document.addEventListener('mouseup', this._mouseUp, true);
95
+ if (dd_touch_1.isTouch) {
96
+ this.dragEl.addEventListener('touchmove', dd_touch_1.touchmove);
97
+ this.dragEl.addEventListener('touchend', dd_touch_1.touchend);
98
+ }
99
+ e.preventDefault();
100
+ dd_manager_1.DDManager.mouseHandled = true;
101
+ return true;
102
+ }
103
+ /** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */
104
+ _mouseMove(e) {
105
+ var _a;
106
+ // console.log(`${count++} move ${e.x},${e.y}`)
107
+ let s = this.mouseDownEvent;
108
+ if (this.dragging) {
109
+ this._dragFollow(e);
110
+ const ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'drag' });
111
+ if (this.option.drag) {
112
+ this.option.drag(ev, this.ui());
113
+ }
114
+ this.triggerEvent('drag', ev);
115
+ }
116
+ else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 3) {
117
+ /**
118
+ * don't start unless we've moved at least 3 pixels
119
+ */
120
+ this.dragging = true;
121
+ dd_manager_1.DDManager.dragElement = this;
122
+ // if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)
123
+ let grid = (_a = this.el.gridstackNode) === null || _a === void 0 ? void 0 : _a.grid;
124
+ if (grid) {
125
+ dd_manager_1.DDManager.dropElement = grid.el.ddElement.ddDroppable;
126
+ }
127
+ else {
128
+ delete dd_manager_1.DDManager.dropElement;
129
+ }
130
+ this.helper = this._createHelper(e);
131
+ this._setupHelperContainmentStyle();
132
+ this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment);
133
+ const ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'dragstart' });
134
+ this._setupHelperStyle(e);
135
+ if (this.option.start) {
136
+ this.option.start(ev, this.ui());
137
+ }
138
+ this.triggerEvent('dragstart', ev);
139
+ }
140
+ e.preventDefault();
141
+ return true;
142
+ }
143
+ /** @internal call when the mouse gets released to drop the item at current location */
144
+ _mouseUp(e) {
145
+ var _a;
146
+ document.removeEventListener('mousemove', this._mouseMove, true);
147
+ document.removeEventListener('mouseup', this._mouseUp, true);
148
+ if (dd_touch_1.isTouch) {
149
+ this.dragEl.removeEventListener('touchmove', dd_touch_1.touchmove, true);
150
+ this.dragEl.removeEventListener('touchend', dd_touch_1.touchend, true);
151
+ }
152
+ if (this.dragging) {
153
+ delete this.dragging;
154
+ // reset the drop target if dragging over ourself (already parented, just moving during stop callback below)
155
+ if (((_a = dd_manager_1.DDManager.dropElement) === null || _a === void 0 ? void 0 : _a.el) === this.el.parentElement) {
156
+ delete dd_manager_1.DDManager.dropElement;
157
+ }
158
+ this.helperContainment.style.position = this.parentOriginStylePosition || null;
159
+ if (this.helper === this.el) {
160
+ this._removeHelperStyle();
161
+ }
162
+ else {
163
+ this.helper.remove();
164
+ }
165
+ const ev = utils_1.Utils.initEvent(e, { target: this.el, type: 'dragstop' });
166
+ if (this.option.stop) {
167
+ this.option.stop(ev); // NOTE: destroy() will be called when removing item, so expect NULL ptr after!
168
+ }
169
+ this.triggerEvent('dragstop', ev);
170
+ // call the droppable method to receive the item
171
+ if (dd_manager_1.DDManager.dropElement) {
172
+ dd_manager_1.DDManager.dropElement.drop(e);
173
+ }
174
+ }
175
+ delete this.helper;
176
+ delete this.mouseDownEvent;
177
+ delete dd_manager_1.DDManager.dragElement;
178
+ delete dd_manager_1.DDManager.dropElement;
179
+ delete dd_manager_1.DDManager.mouseHandled;
180
+ e.preventDefault();
181
+ }
182
+ /** @internal create a clone copy (or user defined method) of the original drag item if set */
183
+ _createHelper(event) {
184
+ let helper = this.el;
185
+ if (typeof this.option.helper === 'function') {
186
+ helper = this.option.helper(event);
187
+ }
188
+ else if (this.option.helper === 'clone') {
189
+ helper = utils_1.Utils.cloneNode(this.el);
190
+ }
191
+ if (!document.body.contains(helper)) {
192
+ utils_1.Utils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentNode : this.option.appendTo);
193
+ }
194
+ if (helper === this.el) {
195
+ this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);
196
+ }
197
+ return helper;
198
+ }
199
+ /** @internal set the fix position of the dragged item */
200
+ _setupHelperStyle(e) {
201
+ this.helper.classList.add('ui-draggable-dragging');
202
+ // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593
203
+ const style = this.helper.style;
204
+ style.pointerEvents = 'none'; // needed for over items to get enter/leave
205
+ // style.cursor = 'move'; // TODO: can't set with pointerEvents=none ! (done in CSS as well)
206
+ style['min-width'] = 0; // since we no longer relative to our parent and we don't resize anyway (normally 100/#column %)
207
+ style.width = this.dragOffset.width + 'px';
208
+ style.height = this.dragOffset.height + 'px';
209
+ style.willChange = 'left, top';
210
+ style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'
211
+ this._dragFollow(e); // now position it
212
+ style.transition = 'none'; // show up instantly
213
+ setTimeout(() => {
214
+ if (this.helper) {
215
+ style.transition = null; // recover animation
216
+ }
217
+ }, 0);
218
+ return this;
219
+ }
220
+ /** @internal restore back the original style before dragging */
221
+ _removeHelperStyle() {
222
+ var _a;
223
+ this.helper.classList.remove('ui-draggable-dragging');
224
+ let node = (_a = this.helper) === null || _a === void 0 ? void 0 : _a.gridstackNode;
225
+ // don't bother restoring styles if we're gonna remove anyway...
226
+ if (this.dragElementOriginStyle && (!node || !node._isAboutToRemove)) {
227
+ let helper = this.helper;
228
+ // don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'
229
+ let transition = this.dragElementOriginStyle['transition'] || null;
230
+ helper.style.transition = this.dragElementOriginStyle['transition'] = 'none';
231
+ DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);
232
+ setTimeout(() => helper.style.transition = transition, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)
233
+ }
234
+ delete this.dragElementOriginStyle;
235
+ return this;
236
+ }
237
+ /** @internal updates the top/left position to follow the mouse */
238
+ _dragFollow(e) {
239
+ let containmentRect = { left: 0, top: 0 };
240
+ // if (this.helper.style.position === 'absolute') { // we use 'fixed'
241
+ // const { left, top } = this.helperContainment.getBoundingClientRect();
242
+ // containmentRect = { left, top };
243
+ // }
244
+ const style = this.helper.style;
245
+ const offset = this.dragOffset;
246
+ style.left = e.clientX + offset.offsetLeft - containmentRect.left + 'px';
247
+ style.top = e.clientY + offset.offsetTop - containmentRect.top + 'px';
248
+ }
249
+ /** @internal */
250
+ _setupHelperContainmentStyle() {
251
+ this.helperContainment = this.helper.parentElement;
252
+ if (this.helper.style.position !== 'fixed') {
253
+ this.parentOriginStylePosition = this.helperContainment.style.position;
254
+ if (window.getComputedStyle(this.helperContainment).position.match(/static/)) {
255
+ this.helperContainment.style.position = 'relative';
256
+ }
257
+ }
258
+ return this;
259
+ }
260
+ /** @internal */
261
+ _getDragOffset(event, el, parent) {
262
+ // in case ancestor has transform/perspective css properties that change the viewpoint
263
+ let xformOffsetX = 0;
264
+ let xformOffsetY = 0;
265
+ if (parent) {
266
+ const testEl = document.createElement('div');
267
+ utils_1.Utils.addElStyles(testEl, {
268
+ opacity: '0',
269
+ position: 'fixed',
270
+ top: 0 + 'px',
271
+ left: 0 + 'px',
272
+ width: '1px',
273
+ height: '1px',
274
+ zIndex: '-999999',
275
+ });
276
+ parent.appendChild(testEl);
277
+ const testElPosition = testEl.getBoundingClientRect();
278
+ parent.removeChild(testEl);
279
+ xformOffsetX = testElPosition.left;
280
+ xformOffsetY = testElPosition.top;
281
+ // TODO: scale ?
282
+ }
283
+ const targetOffset = el.getBoundingClientRect();
284
+ return {
285
+ left: targetOffset.left,
286
+ top: targetOffset.top,
287
+ offsetLeft: -event.clientX + targetOffset.left - xformOffsetX,
288
+ offsetTop: -event.clientY + targetOffset.top - xformOffsetY,
289
+ width: targetOffset.width,
290
+ height: targetOffset.height
291
+ };
292
+ }
293
+ /** @internal TODO: set to public as called by DDDroppable! */
294
+ ui() {
295
+ const containmentEl = this.el.parentElement;
296
+ const containmentRect = containmentEl.getBoundingClientRect();
297
+ const offset = this.helper.getBoundingClientRect();
298
+ return {
299
+ position: {
300
+ top: offset.top - containmentRect.top,
301
+ left: offset.left - containmentRect.left
302
+ }
303
+ /* not used by GridStack for now...
304
+ helper: [this.helper], //The object arr representing the helper that's being dragged.
305
+ offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.
306
+ */
307
+ };
308
+ }
309
+ }
310
+ exports.DDDraggable = DDDraggable;
311
+ /** @internal properties we change during dragging, and restore back */
312
+ DDDraggable.originStyleProp = ['transition', 'pointerEvents', 'position', 'left', 'top'];
313
+ //# sourceMappingURL=dd-draggable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dd-draggable.js","sourceRoot":"","sources":["../src/dd-draggable.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6CAAyC;AACzC,mCAAgC;AAChC,iDAAuE;AAGvE,yCAAmF;AA0BnF,yBAAyB;AAEzB,MAAa,WAAY,SAAQ,8BAAe;IAsB9C,YAAY,EAAe,EAAE,SAAyB,EAAE;QACtD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,6DAA6D;QAC7D,IAAI,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC5F,+GAA+G;QAC/G,IAAI,CAAC,UAAU,G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,CAAC,IAAI,CAAC;YACnC,YAAY,GAAG,cAAc,CAAC,GAAG,CAAC;YAClC,gBAAgB;SACjB;QAED,MAAM,YAAY,GAAG,EAAE,CAAC,qBAAqB,EAAE,CAAC;QAChD,OAAO;YACL,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,GAAG,EAAE,YAAY,CAAC,GAAG;YACrB,UAAU,EAAE,CAAE,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,IAAI,GAAG,YAAY;YAC9D,SAAS,EAAE,CAAE,KAAK,CAAC,OAAO,GAAG,YAAY,CAAC,GAAG,GAAG,YAAY;YAC5D,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,MAAM,EAAE,YAAY,CAAC,MAAM;SAC5B,CAAC;IACJ,CAAC;IAED,8DAA8D;IACvD,EAAE;QACP,MAAM,aAAa,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC;QAC5C,MAAM,eAAe,GAAG,aAAa,CAAC,qBAAqB,EAAE,CAAC;QAC9D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAC;QACnD,OAAO;YACL,QAAQ,EAAE;gBACR,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,eAAe,CAAC,GAAG;gBACrC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG,eAAe,CAAC,IAAI;aACzC;YACD;;;cAGE;SACH,CAAC;IACJ,CAAC;;AArUH,kCAsUC;AAnTC,uEAAuE;AACtD,2BAAe,GAAG,CAAC,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC","sourcesContent":["/**\n * dd-draggable.ts 6.0.0\n * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license\n */\n\nimport { DDManager } from './dd-manager';\nimport { Utils } from './utils';\nimport { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';\nimport { GridItemHTMLElement, DDUIData } from './types';\nimport { DDElementHost } from './dd-element';\nimport { isTouch, touchend, touchmove, touchstart, pointerdown } from './dd-touch';\n\n// TODO: merge with DDDragOpt ?\nexport interface DDDraggableOpt {\n appendTo?: string | HTMLElement;\n handle?: string;\n helper?: string | HTMLElement | ((event: Event) => HTMLElement);\n // containment?: string | HTMLElement; // TODO: not implemented yet\n // revert?: string | boolean | unknown; // TODO: not implemented yet\n // scroll?: boolean; // native support by HTML5 drag drop, can't be switch to off actually\n start?: (event: Event, ui: DDUIData) => void;\n stop?: (event: Event) => void;\n drag?: (event: Event, ui: DDUIData) => void;\n}\n\ninterface DragOffset {\n left: number;\n top: number;\n width: number;\n height: number;\n offsetLeft: number;\n offsetTop: number;\n}\n\ntype DDDragEvent = 'drag' | 'dragstart' | 'dragstop';\n\n// let count = 0; // TEST\n\nexport class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt<DDDraggableOpt> {\n public el: HTMLElement;\n public option: DDDraggableOpt;\n public helper: HTMLElement; // used by GridStackDDNative\n\n /** @internal */\n protected mouseDownEvent: MouseEvent;\n /** @internal */\n protected dragOffset: DragOffset;\n /** @internal */\n protected dragElementOriginStyle: Array<string>;\n /** @internal */\n protected dragEl: HTMLElement;\n /** @internal true while we are dragging an item around */\n protected dragging: boolean;\n /** @internal */\n protected parentOriginStylePosition: string;\n /** @internal */\n protected helperContainment: HTMLElement;\n /** @internal properties we change during dragging, and restore back */\n protected static originStyleProp = ['transition', 'pointerEvents', 'position', 'left', 'top'];\n\n constructor(el: HTMLElement, option: DDDraggableOpt = {}) {\n super();\n this.el = el;\n this.option = option;\n // get the element that is actually supposed to be dragged by\n let className = option.handle.substring(1);\n this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;\n // create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)\n this._mouseDown = this._mouseDown.bind(this);\n this._mouseMove = this._mouseMove.bind(this);\n this._mouseUp = this._mouseUp.bind(this);\n this.enable();\n }\n\n public on(event: DDDragEvent, callback: (event: DragEvent) => void): void {\n super.on(event, callback);\n }\n\n public off(event: DDDragEvent): void {\n super.off(event);\n }\n\n public enable(): void {\n if (this.disabled === false) return;\n super.enable();\n this.dragEl.addEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n this.dragEl.addEventListener('touchstart', touchstart);\n this.dragEl.addEventListener('pointerdown', pointerdown);\n // this.dragEl.style.touchAction = 'none'; // not needed unlike pointerdown doc comment\n }\n this.el.classList.remove('ui-draggable-disabled');\n this.el.classList.add('ui-draggable');\n }\n\n public disable(forDestroy = false): void {\n if (this.disabled === true) return;\n super.disable();\n this.dragEl.removeEventListener('mousedown', this._mouseDown);\n if (isTouch) {\n this.dragEl.removeEventListener('touchstart', touchstart);\n this.dragEl.removeEventListener('pointerdown', pointerdown);\n }\n this.el.classList.remove('ui-draggable');\n if (!forDestroy) this.el.classList.add('ui-draggable-disabled');\n }\n\n public destroy(): void {\n if (this.dragging) this._mouseUp(this.mouseDownEvent);\n this.disable(true);\n delete this.el;\n delete this.helper;\n delete this.option;\n super.destroy();\n }\n\n public updateOption(opts: DDDraggableOpt): DDDraggable {\n Object.keys(opts).forEach(key => this.option[key] = opts[key]);\n return this;\n }\n\n /** @internal call when mouse goes down before a dragstart happens */\n protected _mouseDown(e: MouseEvent): boolean {\n // don't let more than one widget handle mouseStart\n if (DDManager.mouseHandled) return;\n if (e.button !== 0) return true; // only left click\n\n // make sure we are clicking on a drag handle or child of it...\n // Note: we don't need to check that's handle is an immediate child, as mouseHandled will prevent parents from also handling it (lowest wins)\n let className = this.option.handle.substring(1);\n let el = e.target as HTMLElement;\n while (el && !el.classList.contains(className)) { el = el.parentElement; }\n if (!el) return;\n this.mouseDownEvent = e;\n delete this.dragging;\n delete DDManager.dragElement;\n delete DDManager.dropElement;\n // document handler so we can continue receiving moves as the item is 'fixed' position, and capture=true so WE get a first crack\n document.addEventListener('mousemove', this._mouseMove, true); // true=capture, not bubble\n document.addEventListener('mouseup', this._mouseUp, true);\n if (isTouch) {\n this.dragEl.addEventListener('touchmove', touchmove);\n this.dragEl.addEventListener('touchend', touchend);\n }\n\n e.preventDefault();\n DDManager.mouseHandled = true;\n return true;\n }\n\n /** @internal called when the main page (after successful mousedown) receives a move event to drag the item around the screen */\n protected _mouseMove(e: DragEvent): boolean {\n // console.log(`${count++} move ${e.x},${e.y}`)\n let s = this.mouseDownEvent;\n\n if (this.dragging) {\n this._dragFollow(e);\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'drag' });\n if (this.option.drag) {\n this.option.drag(ev, this.ui());\n }\n this.triggerEvent('drag', ev);\n } else if (Math.abs(e.x - s.x) + Math.abs(e.y - s.y) > 3) {\n /**\n * don't start unless we've moved at least 3 pixels\n */\n this.dragging = true;\n DDManager.dragElement = this;\n // if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)\n let grid = (this.el as GridItemHTMLElement).gridstackNode?.grid;\n if (grid) {\n DDManager.dropElement = (grid.el as DDElementHost).ddElement.ddDroppable;\n } else {\n delete DDManager.dropElement;\n }\n this.helper = this._createHelper(e);\n this._setupHelperContainmentStyle();\n this.dragOffset = this._getDragOffset(e, this.el, this.helperContainment);\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstart' });\n\n this._setupHelperStyle(e);\n if (this.option.start) {\n this.option.start(ev, this.ui());\n }\n this.triggerEvent('dragstart', ev);\n }\n e.preventDefault();\n return true;\n }\n\n /** @internal call when the mouse gets released to drop the item at current location */\n protected _mouseUp(e: MouseEvent): void {\n document.removeEventListener('mousemove', this._mouseMove, true);\n document.removeEventListener('mouseup', this._mouseUp, true);\n if (isTouch) {\n this.dragEl.removeEventListener('touchmove', touchmove, true);\n this.dragEl.removeEventListener('touchend', touchend, true);\n }\n if (this.dragging) {\n delete this.dragging;\n\n // reset the drop target if dragging over ourself (already parented, just moving during stop callback below)\n if (DDManager.dropElement?.el === this.el.parentElement) {\n delete DDManager.dropElement;\n }\n\n this.helperContainment.style.position = this.parentOriginStylePosition || null;\n if (this.helper === this.el) {\n this._removeHelperStyle();\n } else {\n this.helper.remove();\n }\n const ev = Utils.initEvent<DragEvent>(e, { target: this.el, type: 'dragstop' });\n if (this.option.stop) {\n this.option.stop(ev); // NOTE: destroy() will be called when removing item, so expect NULL ptr after!\n }\n this.triggerEvent('dragstop', ev);\n\n // call the droppable method to receive the item\n if (DDManager.dropElement) {\n DDManager.dropElement.drop(e);\n }\n }\n delete this.helper;\n delete this.mouseDownEvent;\n delete DDManager.dragElement;\n delete DDManager.dropElement;\n delete DDManager.mouseHandled;\n e.preventDefault();\n }\n\n /** @internal create a clone copy (or user defined method) of the original drag item if set */\n protected _createHelper(event: DragEvent): HTMLElement {\n let helper = this.el;\n if (typeof this.option.helper === 'function') {\n helper = this.option.helper(event);\n } else if (this.option.helper === 'clone') {\n helper = Utils.cloneNode(this.el);\n }\n if (!document.body.contains(helper)) {\n Utils.appendTo(helper, this.option.appendTo === 'parent' ? this.el.parentNode : this.option.appendTo);\n }\n if (helper === this.el) {\n this.dragElementOriginStyle = DDDraggable.originStyleProp.map(prop => this.el.style[prop]);\n }\n return helper;\n }\n\n /** @internal set the fix position of the dragged item */\n protected _setupHelperStyle(e: DragEvent): DDDraggable {\n this.helper.classList.add('ui-draggable-dragging');\n // TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593\n const style = this.helper.style;\n style.pointerEvents = 'none'; // needed for over items to get enter/leave\n // style.cursor = 'move'; // TODO: can't set with pointerEvents=none ! (done in CSS as well)\n style['min-width'] = 0; // since we no longer relative to our parent and we don't resize anyway (normally 100/#column %)\n style.width = this.dragOffset.width + 'px';\n style.height = this.dragOffset.height + 'px';\n style.willChange = 'left, top';\n style.position = 'fixed'; // let us drag between grids by not clipping as parent .grid-stack is position: 'relative'\n this._dragFollow(e); // now position it\n style.transition = 'none'; // show up instantly\n setTimeout(() => {\n if (this.helper) {\n style.transition = null; // recover animation\n }\n }, 0);\n return this;\n }\n\n /** @internal restore back the original style before dragging */\n protected _removeHelperStyle(): DDDraggable {\n this.helper.classList.remove('ui-draggable-dragging');\n let node = (this.helper as GridItemHTMLElement)?.gridstackNode;\n // don't bother restoring styles if we're gonna remove anyway...\n if (this.dragElementOriginStyle && (!node || !node._isAboutToRemove)) {\n let helper = this.helper;\n // don't animate, otherwise we animate offseted when switching back to 'absolute' from 'fixed'\n let transition = this.dragElementOriginStyle['transition'] || null;\n helper.style.transition = this.dragElementOriginStyle['transition'] = 'none';\n DDDraggable.originStyleProp.forEach(prop => helper.style[prop] = this.dragElementOriginStyle[prop] || null);\n setTimeout(() => helper.style.transition = transition, 50); // recover animation from saved vars after a pause (0 isn't enough #1973)\n }\n delete this.dragElementOriginStyle;\n return this;\n }\n\n /** @internal updates the top/left position to follow the mouse */\n protected _dragFollow(e: DragEvent): void {\n let containmentRect = { left: 0, top: 0 };\n // if (this.helper.style.position === 'absolute') { // we use 'fixed'\n // const { left, top } = this.helperContainment.getBoundingClientRect();\n // containmentRect = { left, top };\n // }\n const style = this.helper.style;\n const offset = this.dragOffset;\n style.left = e.clientX + offset.offsetLeft - containmentRect.left + 'px';\n style.top = e.clientY + offset.offsetTop - containmentRect.top + 'px';\n }\n\n /** @internal */\n protected _setupHelperContainmentStyle(): DDDraggable {\n this.helperContainment = this.helper.parentElement;\n if (this.helper.style.position !== 'fixed') {\n this.parentOriginStylePosition = this.helperContainment.style.position;\n if (window.getComputedStyle(this.helperContainment).position.match(/static/)) {\n this.helperContainment.style.position = 'relative';\n }\n }\n return this;\n }\n\n /** @internal */\n protected _getDragOffset(event: DragEvent, el: HTMLElement, parent: HTMLElement): DragOffset {\n\n // in case ancestor has transform/perspective css properties that change the viewpoint\n let xformOffsetX = 0;\n let xformOffsetY = 0;\n if (parent) {\n const testEl = document.createElement('div');\n Utils.addElStyles(testEl, {\n opacity: '0',\n position: 'fixed',\n top: 0 + 'px',\n left: 0 + 'px',\n width: '1px',\n height: '1px',\n zIndex: '-999999',\n });\n parent.appendChild(testEl);\n const testElPosition = testEl.getBoundingClientRect();\n parent.removeChild(testEl);\n xformOffsetX = testElPosition.left;\n xformOffsetY = testElPosition.top;\n // TODO: scale ?\n }\n\n const targetOffset = el.getBoundingClientRect();\n return {\n left: targetOffset.left,\n top: targetOffset.top,\n offsetLeft: - event.clientX + targetOffset.left - xformOffsetX,\n offsetTop: - event.clientY + targetOffset.top - xformOffsetY,\n width: targetOffset.width,\n height: targetOffset.height\n };\n }\n\n /** @internal TODO: set to public as called by DDDroppable! */\n public ui(): DDUIData {\n const containmentEl = this.el.parentElement;\n const containmentRect = containmentEl.getBoundingClientRect();\n const offset = this.helper.getBoundingClientRect();\n return {\n position: { //Current CSS position of the helper as { top, left } object\n top: offset.top - containmentRect.top,\n left: offset.left - containmentRect.left\n }\n /* not used by GridStack for now...\n helper: [this.helper], //The object arr representing the helper that's being dragged.\n offset: { top: offset.top, left: offset.left } // Current offset position of the helper as { top, left } object.\n */\n };\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * dd-droppable.ts 5.1.1
2
+ * dd-droppable.ts 6.0.0
3
3
  * Copyright (c) 2021-2022 Alain Dumesny - see GridStack root license
4
4
  */
5
5
  import { DDBaseImplement, HTMLElementExtendOpt } from './dd-base-impl';
@@ -13,7 +13,6 @@ export declare class DDDroppable extends DDBaseImplement implements HTMLElementE
13
13
  accept: (el: HTMLElement) => boolean;
14
14
  el: HTMLElement;
15
15
  option: DDDroppableOpt;
16
- protected static lastActive: DDDroppable;
17
16
  constructor(el: HTMLElement, opts?: DDDroppableOpt);
18
17
  on(event: 'drop' | 'dropover' | 'dropout', callback: (event: DragEvent) => void): void;
19
18
  off(event: 'drop' | 'dropover' | 'dropout'): void;
@@ -21,4 +20,6 @@ export declare class DDDroppable extends DDBaseImplement implements HTMLElementE
21
20
  disable(forDestroy?: boolean): void;
22
21
  destroy(): void;
23
22
  updateOption(opts: DDDroppableOpt): DDDroppable;
23
+ /** item is being dropped on us - called by the drag mouseup handler - this calls the client drop event */
24
+ drop(e: MouseEvent): void;
24
25
  }