zignal-stencil-library 1.1.159 → 1.1.160

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 (232) hide show
  1. package/dist/cjs/{autocomplete-address_45.cjs.entry.js → autocomplete-address_49.cjs.entry.js} +3777 -386
  2. package/dist/cjs/{dayjs-vAGCjbc8.js → dayjs-CQF3zwgL.js} +3 -3
  3. package/dist/cjs/{dayjs-vAGCjbc8.js.map → dayjs-CQF3zwgL.js.map} +1 -1
  4. package/dist/cjs/{index-Df7QxnG3.js → index-DHj7HVpr.js} +58 -4
  5. package/dist/cjs/{index-Df7QxnG3.js.map → index-DHj7HVpr.js.map} +1 -1
  6. package/dist/cjs/index.cjs.js +1 -1
  7. package/dist/cjs/loader.cjs.js +1 -1
  8. package/dist/cjs/quick-message-app.cjs.entry.js +4 -4
  9. package/dist/cjs/zignal-stencil-library.cjs.js +1 -1
  10. package/dist/collection/api/index.js +68 -0
  11. package/dist/collection/api/index.js.map +1 -1
  12. package/dist/collection/api/type.js.map +1 -1
  13. package/dist/collection/collection-manifest.json +4 -0
  14. package/dist/collection/components/autocomplete-address/autocomplete-address.css +1 -1
  15. package/dist/collection/components/autocomplete-multiple-select/autocomplete-multiple-select.css +1 -1
  16. package/dist/collection/components/autocomplete-select/autocomplete-select.css +1 -1
  17. package/dist/collection/components/channel-box/channel-box.css +1 -1
  18. package/dist/collection/components/chat-app/chat-app.css +1 -1
  19. package/dist/collection/components/chat-header/chat-header.css +1 -1
  20. package/dist/collection/components/chat-input/chat-input.css +1 -1
  21. package/dist/collection/components/checkbox-list/checkbox-list.css +1 -1
  22. package/dist/collection/components/create-master-data-dialog/create-master-data-dialog.css +1 -0
  23. package/dist/collection/components/create-master-data-dialog/create-master-data-dialog.js +288 -0
  24. package/dist/collection/components/create-master-data-dialog/create-master-data-dialog.js.map +1 -0
  25. package/dist/collection/components/dialog-bill-editor/dialog-bill-editor.css +1 -1
  26. package/dist/collection/components/dialog-custom-filter/dialog-custom-filter.css +1 -1
  27. package/dist/collection/components/dialog-editor/dialog-editor.css +1 -1
  28. package/dist/collection/components/dialog-preview-media/dialog-preview-media.css +1 -1
  29. package/dist/collection/components/dialog-search/dialog-search.css +1 -1
  30. package/dist/collection/components/internal-component/icon.js +3 -1
  31. package/dist/collection/components/internal-component/icon.js.map +1 -1
  32. package/dist/collection/components/internal-component/z-input.js +2 -2
  33. package/dist/collection/components/internal-component/z-input.js.map +1 -1
  34. package/dist/collection/components/master-data-item/master-data-item.css +1 -0
  35. package/dist/collection/components/master-data-item/master-data-item.js +284 -0
  36. package/dist/collection/components/master-data-item/master-data-item.js.map +1 -0
  37. package/dist/collection/components/master-status-app/master-status-app.css +1 -0
  38. package/dist/collection/components/master-status-app/master-status-app.js +396 -0
  39. package/dist/collection/components/master-status-app/master-status-app.js.map +1 -0
  40. package/dist/collection/components/master-tag-app/master-tag-app.css +1 -0
  41. package/dist/collection/components/master-tag-app/master-tag-app.js +398 -0
  42. package/dist/collection/components/master-tag-app/master-tag-app.js.map +1 -0
  43. package/dist/collection/components/menu-chat-channel/menu-chat-channel.css +1 -1
  44. package/dist/collection/components/menu-chat-channel/menu-chat-channel.js +2 -2
  45. package/dist/collection/components/menu-chat-type/menu-chat-type.css +1 -1
  46. package/dist/collection/components/menu-chat-type/menu-chat-type.js +2 -2
  47. package/dist/collection/components/menu-list/menu-list.css +1 -1
  48. package/dist/collection/components/menu-list/menu-list.js +2 -2
  49. package/dist/collection/components/message-box/message-box.css +1 -1
  50. package/dist/collection/components/message-box/message-box.js +1 -1
  51. package/dist/collection/components/message-content/message-content.css +1 -1
  52. package/dist/collection/components/message-content/message-content.js +1 -1
  53. package/dist/collection/components/message-item/message-item.css +1 -1
  54. package/dist/collection/components/message-item/message-item.js +1 -1
  55. package/dist/collection/components/message-media/message-media.css +1 -1
  56. package/dist/collection/components/message-media/message-media.js +2 -2
  57. package/dist/collection/components/profile-history/profile-history.css +1 -1
  58. package/dist/collection/components/profile-history/profile-history.js +1 -1
  59. package/dist/collection/components/profile-info/profile-info.css +1 -1
  60. package/dist/collection/components/profile-info/user-info-section.js +4 -4
  61. package/dist/collection/components/profile-media/profile-media.css +1 -1
  62. package/dist/collection/components/profile-media/profile-media.js +1 -1
  63. package/dist/collection/components/profile-tabs/profile-tabs.css +1 -1
  64. package/dist/collection/components/profile-tabs/profile-tabs.js +2 -2
  65. package/dist/collection/components/quick-message-add-template/quick-message-add-template.css +1 -1
  66. package/dist/collection/components/quick-message-add-template/quick-message-add-template.js +3 -3
  67. package/dist/collection/components/quick-message-add-template/quick-message-text-content.js +1 -1
  68. package/dist/collection/components/quick-message-app/quick-message-app.css +1 -1
  69. package/dist/collection/components/quick-message-app/quick-message-app.js +1 -1
  70. package/dist/collection/components/quick-message-file/quick-message-file.css +1 -1
  71. package/dist/collection/components/quick-message-file/quick-message-file.js +1 -1
  72. package/dist/collection/components/quick-message-image/quick-message-image.css +1 -1
  73. package/dist/collection/components/quick-message-image/quick-message-image.js +1 -1
  74. package/dist/collection/components/quick-message-modal/quick-message-modal.css +1 -1
  75. package/dist/collection/components/quick-message-modal/quick-message-modal.js +1 -1
  76. package/dist/collection/components/quick-message-template/quick-message-template.css +1 -1
  77. package/dist/collection/components/quick-message-template/quick-message-template.js +2 -2
  78. package/dist/collection/components/search-box/search-box.css +1 -1
  79. package/dist/collection/components/search-box/search-box.js +5 -5
  80. package/dist/collection/components/status-badge/status-badge.css +1 -1
  81. package/dist/collection/components/status-badge/status-badge.js +2 -2
  82. package/dist/collection/components/tag-list/tag-list.css +1 -1
  83. package/dist/collection/components/tag-list/tag-list.js +1 -1
  84. package/dist/collection/components/tag-or-status-item/tag-or-status-item.css +1 -1
  85. package/dist/collection/components/tag-or-status-item/tag-or-status-item.js +2 -2
  86. package/dist/collection/components/tag-popper/tag-popper.css +1 -1
  87. package/dist/collection/components/tag-popper/tag-popper.js +2 -2
  88. package/dist/collection/components/typography-clamp/typography-clamp.css +1 -1
  89. package/dist/collection/components/typography-clamp/typography-clamp.js +2 -2
  90. package/dist/collection/components/z-avatar/z-avatar.css +1 -1
  91. package/dist/collection/components/z-dialog/z-dialog.css +1 -1
  92. package/dist/collection/components/z-tooltip/z-tooltip.css +1 -1
  93. package/dist/collection/utils/icon-svg.js +1 -0
  94. package/dist/collection/utils/icon-svg.js.map +1 -1
  95. package/dist/components/autocomplete-address2.js +1 -1
  96. package/dist/components/autocomplete-address2.js.map +1 -1
  97. package/dist/components/autocomplete-multiple-select2.js +1 -1
  98. package/dist/components/autocomplete-multiple-select2.js.map +1 -1
  99. package/dist/components/autocomplete-select2.js +1 -1
  100. package/dist/components/autocomplete-select2.js.map +1 -1
  101. package/dist/components/channel-box2.js +1 -1
  102. package/dist/components/channel-box2.js.map +1 -1
  103. package/dist/components/chat-app.js +1 -1
  104. package/dist/components/chat-app.js.map +1 -1
  105. package/dist/components/chat-header2.js +2 -2
  106. package/dist/components/chat-header2.js.map +1 -1
  107. package/dist/components/chat-input2.js +1 -1
  108. package/dist/components/chat-input2.js.map +1 -1
  109. package/dist/components/checkbox-list2.js +1 -1
  110. package/dist/components/checkbox-list2.js.map +1 -1
  111. package/dist/components/create-master-data-dialog.d.ts +11 -0
  112. package/dist/components/create-master-data-dialog.js +9 -0
  113. package/dist/components/create-master-data-dialog.js.map +1 -0
  114. package/dist/components/create-master-data-dialog2.js +162 -0
  115. package/dist/components/create-master-data-dialog2.js.map +1 -0
  116. package/dist/components/dialog-bill-editor2.js +1 -1
  117. package/dist/components/dialog-bill-editor2.js.map +1 -1
  118. package/dist/components/dialog-custom-filter2.js +1 -1
  119. package/dist/components/dialog-custom-filter2.js.map +1 -1
  120. package/dist/components/dialog-editor2.js +1 -1
  121. package/dist/components/dialog-editor2.js.map +1 -1
  122. package/dist/components/dialog-preview-media2.js +1 -1
  123. package/dist/components/dialog-preview-media2.js.map +1 -1
  124. package/dist/components/dialog-search2.js +1 -1
  125. package/dist/components/dialog-search2.js.map +1 -1
  126. package/dist/components/dialog.js +1 -1
  127. package/dist/components/icon-svg.js +2 -1
  128. package/dist/components/icon-svg.js.map +1 -1
  129. package/dist/components/icon.js +35 -0
  130. package/dist/components/icon.js.map +1 -1
  131. package/dist/components/index.js +56 -2
  132. package/dist/components/index.js.map +1 -1
  133. package/dist/components/index3.js +69 -1
  134. package/dist/components/index3.js.map +1 -1
  135. package/dist/components/master-data-item.d.ts +11 -0
  136. package/dist/components/master-data-item.js +9 -0
  137. package/dist/components/master-data-item.js.map +1 -0
  138. package/dist/components/master-data-item2.js +99 -0
  139. package/dist/components/master-data-item2.js.map +1 -0
  140. package/dist/components/master-status-app.d.ts +11 -0
  141. package/dist/components/master-status-app.js +284 -0
  142. package/dist/components/master-status-app.js.map +1 -0
  143. package/dist/components/master-tag-app.d.ts +11 -0
  144. package/dist/components/master-tag-app.js +286 -0
  145. package/dist/components/master-tag-app.js.map +1 -0
  146. package/dist/components/menu-chat-channel2.js +3 -3
  147. package/dist/components/menu-chat-channel2.js.map +1 -1
  148. package/dist/components/menu-chat-type2.js +3 -3
  149. package/dist/components/menu-chat-type2.js.map +1 -1
  150. package/dist/components/menu-list2.js +3 -3
  151. package/dist/components/menu-list2.js.map +1 -1
  152. package/dist/components/message-box2.js +2 -2
  153. package/dist/components/message-box2.js.map +1 -1
  154. package/dist/components/message-content2.js +2 -2
  155. package/dist/components/message-content2.js.map +1 -1
  156. package/dist/components/message-item2.js +2 -2
  157. package/dist/components/message-item2.js.map +1 -1
  158. package/dist/components/message-media2.js +3 -3
  159. package/dist/components/message-media2.js.map +1 -1
  160. package/dist/components/profile-history2.js +2 -2
  161. package/dist/components/profile-history2.js.map +1 -1
  162. package/dist/components/profile-info2.js +2 -2
  163. package/dist/components/profile-info2.js.map +1 -1
  164. package/dist/components/profile-media2.js +2 -2
  165. package/dist/components/profile-media2.js.map +1 -1
  166. package/dist/components/profile-tabs2.js +3 -3
  167. package/dist/components/profile-tabs2.js.map +1 -1
  168. package/dist/components/quick-message-add-template2.js +4 -4
  169. package/dist/components/quick-message-add-template2.js.map +1 -1
  170. package/dist/components/quick-message-app.js +2 -2
  171. package/dist/components/quick-message-file2.js +2 -2
  172. package/dist/components/quick-message-file2.js.map +1 -1
  173. package/dist/components/quick-message-image2.js +2 -2
  174. package/dist/components/quick-message-image2.js.map +1 -1
  175. package/dist/components/quick-message-modal2.js +2 -2
  176. package/dist/components/quick-message-modal2.js.map +1 -1
  177. package/dist/components/quick-message-template2.js +3 -3
  178. package/dist/components/quick-message-template2.js.map +1 -1
  179. package/dist/components/quick-message-text-content2.js +1 -1
  180. package/dist/components/search-box2.js +6 -6
  181. package/dist/components/search-box2.js.map +1 -1
  182. package/dist/components/sortable.esm.js +2667 -0
  183. package/dist/components/sortable.esm.js.map +1 -0
  184. package/dist/components/status-badge2.js +3 -3
  185. package/dist/components/status-badge2.js.map +1 -1
  186. package/dist/components/summarize-message-section2.js +1 -1
  187. package/dist/components/summarize-message-section2.js.map +1 -1
  188. package/dist/components/tag-list2.js +2 -2
  189. package/dist/components/tag-list2.js.map +1 -1
  190. package/dist/components/tag-or-status-item2.js +3 -3
  191. package/dist/components/tag-or-status-item2.js.map +1 -1
  192. package/dist/components/tag-popper2.js +3 -3
  193. package/dist/components/tag-popper2.js.map +1 -1
  194. package/dist/components/typography-clamp2.js +3 -3
  195. package/dist/components/typography-clamp2.js.map +1 -1
  196. package/dist/components/user-info-section2.js +5 -5
  197. package/dist/components/user-info-section2.js.map +1 -1
  198. package/dist/components/z-avatar2.js +1 -1
  199. package/dist/components/z-avatar2.js.map +1 -1
  200. package/dist/components/z-dialog2.js +1 -1
  201. package/dist/components/z-dialog2.js.map +1 -1
  202. package/dist/components/z-input.js +2 -2
  203. package/dist/components/z-input.js.map +1 -1
  204. package/dist/components/z-tooltip2.js +1 -1
  205. package/dist/components/z-tooltip2.js.map +1 -1
  206. package/dist/esm/{autocomplete-address_45.entry.js → autocomplete-address_49.entry.js} +3491 -104
  207. package/dist/esm/{dayjs-0Hz8pJ3k.js → dayjs-73cELD4I.js} +3 -3
  208. package/dist/esm/{dayjs-0Hz8pJ3k.js.map → dayjs-73cELD4I.js.map} +1 -1
  209. package/dist/{zignal-stencil-library/index-DmHiLgob.js → esm/index-Wye5kFrR.js} +58 -4
  210. package/dist/{zignal-stencil-library/index-DmHiLgob.js.map → esm/index-Wye5kFrR.js.map} +1 -1
  211. package/dist/esm/index.js +1 -1
  212. package/dist/esm/loader.js +1 -1
  213. package/dist/esm/quick-message-app.entry.js +4 -4
  214. package/dist/esm/zignal-stencil-library.js +1 -1
  215. package/dist/types/api/index.d.ts +6 -0
  216. package/dist/types/api/type.d.ts +38 -0
  217. package/dist/types/components/create-master-data-dialog/create-master-data-dialog.d.ts +28 -0
  218. package/dist/types/components/internal-component/z-input.d.ts +1 -0
  219. package/dist/types/components/master-data-item/master-data-item.d.ts +29 -0
  220. package/dist/types/components/master-status-app/master-status-app.d.ts +29 -0
  221. package/dist/types/components/master-tag-app/master-tag-app.d.ts +29 -0
  222. package/dist/types/components.d.ts +208 -0
  223. package/dist/types/utils/icon-svg.d.ts +1 -0
  224. package/dist/zignal-stencil-library/{autocomplete-address_45.entry.js → autocomplete-address_49.entry.js} +3491 -104
  225. package/dist/zignal-stencil-library/{dayjs-0Hz8pJ3k.js → dayjs-73cELD4I.js} +3 -3
  226. package/dist/zignal-stencil-library/{dayjs-0Hz8pJ3k.js.map → dayjs-73cELD4I.js.map} +1 -1
  227. package/dist/{esm/index-DmHiLgob.js → zignal-stencil-library/index-Wye5kFrR.js} +58 -4
  228. package/dist/{esm/index-DmHiLgob.js.map → zignal-stencil-library/index-Wye5kFrR.js.map} +1 -1
  229. package/dist/zignal-stencil-library/index.esm.js +1 -1
  230. package/dist/zignal-stencil-library/quick-message-app.entry.js +4 -4
  231. package/dist/zignal-stencil-library/zignal-stencil-library.esm.js +1 -1
  232. package/package.json +3 -1
@@ -0,0 +1,2667 @@
1
+ /**!
2
+ * Sortable 1.15.6
3
+ * @author RubaXa <trash@rubaxa.org>
4
+ * @author owenm <owen23355@gmail.com>
5
+ * @license MIT
6
+ */
7
+ function ownKeys(object, enumerableOnly) {
8
+ var keys = Object.keys(object);
9
+ if (Object.getOwnPropertySymbols) {
10
+ var symbols = Object.getOwnPropertySymbols(object);
11
+ if (enumerableOnly) {
12
+ symbols = symbols.filter(function (sym) {
13
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
14
+ });
15
+ }
16
+ keys.push.apply(keys, symbols);
17
+ }
18
+ return keys;
19
+ }
20
+ function _objectSpread2(target) {
21
+ for (var i = 1; i < arguments.length; i++) {
22
+ var source = arguments[i] != null ? arguments[i] : {};
23
+ if (i % 2) {
24
+ ownKeys(Object(source), true).forEach(function (key) {
25
+ _defineProperty(target, key, source[key]);
26
+ });
27
+ } else if (Object.getOwnPropertyDescriptors) {
28
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
29
+ } else {
30
+ ownKeys(Object(source)).forEach(function (key) {
31
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
32
+ });
33
+ }
34
+ }
35
+ return target;
36
+ }
37
+ function _typeof(obj) {
38
+ "@babel/helpers - typeof";
39
+
40
+ if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
41
+ _typeof = function (obj) {
42
+ return typeof obj;
43
+ };
44
+ } else {
45
+ _typeof = function (obj) {
46
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
47
+ };
48
+ }
49
+ return _typeof(obj);
50
+ }
51
+ function _defineProperty(obj, key, value) {
52
+ if (key in obj) {
53
+ Object.defineProperty(obj, key, {
54
+ value: value,
55
+ enumerable: true,
56
+ configurable: true,
57
+ writable: true
58
+ });
59
+ } else {
60
+ obj[key] = value;
61
+ }
62
+ return obj;
63
+ }
64
+ function _extends() {
65
+ _extends = Object.assign || function (target) {
66
+ for (var i = 1; i < arguments.length; i++) {
67
+ var source = arguments[i];
68
+ for (var key in source) {
69
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
70
+ target[key] = source[key];
71
+ }
72
+ }
73
+ }
74
+ return target;
75
+ };
76
+ return _extends.apply(this, arguments);
77
+ }
78
+ function _objectWithoutPropertiesLoose(source, excluded) {
79
+ if (source == null) return {};
80
+ var target = {};
81
+ var sourceKeys = Object.keys(source);
82
+ var key, i;
83
+ for (i = 0; i < sourceKeys.length; i++) {
84
+ key = sourceKeys[i];
85
+ if (excluded.indexOf(key) >= 0) continue;
86
+ target[key] = source[key];
87
+ }
88
+ return target;
89
+ }
90
+ function _objectWithoutProperties(source, excluded) {
91
+ if (source == null) return {};
92
+ var target = _objectWithoutPropertiesLoose(source, excluded);
93
+ var key, i;
94
+ if (Object.getOwnPropertySymbols) {
95
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
96
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
97
+ key = sourceSymbolKeys[i];
98
+ if (excluded.indexOf(key) >= 0) continue;
99
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
100
+ target[key] = source[key];
101
+ }
102
+ }
103
+ return target;
104
+ }
105
+
106
+ var version = "1.15.6";
107
+
108
+ function userAgent(pattern) {
109
+ if (typeof window !== 'undefined' && window.navigator) {
110
+ return !! /*@__PURE__*/navigator.userAgent.match(pattern);
111
+ }
112
+ }
113
+ var IE11OrLess = userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);
114
+ var Edge = userAgent(/Edge/i);
115
+ var FireFox = userAgent(/firefox/i);
116
+ var Safari = userAgent(/safari/i) && !userAgent(/chrome/i) && !userAgent(/android/i);
117
+ var IOS = userAgent(/iP(ad|od|hone)/i);
118
+ var ChromeForAndroid = userAgent(/chrome/i) && userAgent(/android/i);
119
+
120
+ var captureMode = {
121
+ capture: false,
122
+ passive: false
123
+ };
124
+ function on(el, event, fn) {
125
+ el.addEventListener(event, fn, !IE11OrLess && captureMode);
126
+ }
127
+ function off(el, event, fn) {
128
+ el.removeEventListener(event, fn, !IE11OrLess && captureMode);
129
+ }
130
+ function matches( /**HTMLElement*/el, /**String*/selector) {
131
+ if (!selector) return;
132
+ selector[0] === '>' && (selector = selector.substring(1));
133
+ if (el) {
134
+ try {
135
+ if (el.matches) {
136
+ return el.matches(selector);
137
+ } else if (el.msMatchesSelector) {
138
+ return el.msMatchesSelector(selector);
139
+ } else if (el.webkitMatchesSelector) {
140
+ return el.webkitMatchesSelector(selector);
141
+ }
142
+ } catch (_) {
143
+ return false;
144
+ }
145
+ }
146
+ return false;
147
+ }
148
+ function getParentOrHost(el) {
149
+ return el.host && el !== document && el.host.nodeType ? el.host : el.parentNode;
150
+ }
151
+ function closest( /**HTMLElement*/el, /**String*/selector, /**HTMLElement*/ctx, includeCTX) {
152
+ if (el) {
153
+ ctx = ctx || document;
154
+ do {
155
+ if (selector != null && (selector[0] === '>' ? el.parentNode === ctx && matches(el, selector) : matches(el, selector)) || includeCTX && el === ctx) {
156
+ return el;
157
+ }
158
+ if (el === ctx) break;
159
+ /* jshint boss:true */
160
+ } while (el = getParentOrHost(el));
161
+ }
162
+ return null;
163
+ }
164
+ var R_SPACE = /\s+/g;
165
+ function toggleClass(el, name, state) {
166
+ if (el && name) {
167
+ if (el.classList) {
168
+ el.classList[state ? 'add' : 'remove'](name);
169
+ } else {
170
+ var className = (' ' + el.className + ' ').replace(R_SPACE, ' ').replace(' ' + name + ' ', ' ');
171
+ el.className = (className + (state ? ' ' + name : '')).replace(R_SPACE, ' ');
172
+ }
173
+ }
174
+ }
175
+ function css(el, prop, val) {
176
+ var style = el && el.style;
177
+ if (style) {
178
+ if (val === void 0) {
179
+ if (document.defaultView && document.defaultView.getComputedStyle) {
180
+ val = document.defaultView.getComputedStyle(el, '');
181
+ } else if (el.currentStyle) {
182
+ val = el.currentStyle;
183
+ }
184
+ return prop === void 0 ? val : val[prop];
185
+ } else {
186
+ if (!(prop in style) && prop.indexOf('webkit') === -1) {
187
+ prop = '-webkit-' + prop;
188
+ }
189
+ style[prop] = val + (typeof val === 'string' ? '' : 'px');
190
+ }
191
+ }
192
+ }
193
+ function matrix(el, selfOnly) {
194
+ var appliedTransforms = '';
195
+ if (typeof el === 'string') {
196
+ appliedTransforms = el;
197
+ } else {
198
+ do {
199
+ var transform = css(el, 'transform');
200
+ if (transform && transform !== 'none') {
201
+ appliedTransforms = transform + ' ' + appliedTransforms;
202
+ }
203
+ /* jshint boss:true */
204
+ } while (!selfOnly && (el = el.parentNode));
205
+ }
206
+ var matrixFn = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
207
+ /*jshint -W056 */
208
+ return matrixFn && new matrixFn(appliedTransforms);
209
+ }
210
+ function find(ctx, tagName, iterator) {
211
+ if (ctx) {
212
+ var list = ctx.getElementsByTagName(tagName),
213
+ i = 0,
214
+ n = list.length;
215
+ if (iterator) {
216
+ for (; i < n; i++) {
217
+ iterator(list[i], i);
218
+ }
219
+ }
220
+ return list;
221
+ }
222
+ return [];
223
+ }
224
+ function getWindowScrollingElement() {
225
+ var scrollingElement = document.scrollingElement;
226
+ if (scrollingElement) {
227
+ return scrollingElement;
228
+ } else {
229
+ return document.documentElement;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Returns the "bounding client rect" of given element
235
+ * @param {HTMLElement} el The element whose boundingClientRect is wanted
236
+ * @param {[Boolean]} relativeToContainingBlock Whether the rect should be relative to the containing block of (including) the container
237
+ * @param {[Boolean]} relativeToNonStaticParent Whether the rect should be relative to the relative parent of (including) the contaienr
238
+ * @param {[Boolean]} undoScale Whether the container's scale() should be undone
239
+ * @param {[HTMLElement]} container The parent the element will be placed in
240
+ * @return {Object} The boundingClientRect of el, with specified adjustments
241
+ */
242
+ function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoScale, container) {
243
+ if (!el.getBoundingClientRect && el !== window) return;
244
+ var elRect, top, left, bottom, right, height, width;
245
+ if (el !== window && el.parentNode && el !== getWindowScrollingElement()) {
246
+ elRect = el.getBoundingClientRect();
247
+ top = elRect.top;
248
+ left = elRect.left;
249
+ bottom = elRect.bottom;
250
+ right = elRect.right;
251
+ height = elRect.height;
252
+ width = elRect.width;
253
+ } else {
254
+ top = 0;
255
+ left = 0;
256
+ bottom = window.innerHeight;
257
+ right = window.innerWidth;
258
+ height = window.innerHeight;
259
+ width = window.innerWidth;
260
+ }
261
+ if ((relativeToContainingBlock || relativeToNonStaticParent) && el !== window) {
262
+ // Adjust for translate()
263
+ container = container || el.parentNode;
264
+
265
+ // solves #1123 (see: https://stackoverflow.com/a/37953806/6088312)
266
+ // Not needed on <= IE11
267
+ if (!IE11OrLess) {
268
+ do {
269
+ if (container && container.getBoundingClientRect && (css(container, 'transform') !== 'none' || relativeToNonStaticParent && css(container, 'position') !== 'static')) {
270
+ var containerRect = container.getBoundingClientRect();
271
+
272
+ // Set relative to edges of padding box of container
273
+ top -= containerRect.top + parseInt(css(container, 'border-top-width'));
274
+ left -= containerRect.left + parseInt(css(container, 'border-left-width'));
275
+ bottom = top + elRect.height;
276
+ right = left + elRect.width;
277
+ break;
278
+ }
279
+ /* jshint boss:true */
280
+ } while (container = container.parentNode);
281
+ }
282
+ }
283
+ if (undoScale && el !== window) {
284
+ // Adjust for scale()
285
+ var elMatrix = matrix(container || el),
286
+ scaleX = elMatrix && elMatrix.a,
287
+ scaleY = elMatrix && elMatrix.d;
288
+ if (elMatrix) {
289
+ top /= scaleY;
290
+ left /= scaleX;
291
+ width /= scaleX;
292
+ height /= scaleY;
293
+ bottom = top + height;
294
+ right = left + width;
295
+ }
296
+ }
297
+ return {
298
+ top: top,
299
+ left: left,
300
+ bottom: bottom,
301
+ right: right,
302
+ width: width,
303
+ height: height
304
+ };
305
+ }
306
+
307
+ /**
308
+ * Checks if a side of an element is scrolled past a side of its parents
309
+ * @param {HTMLElement} el The element who's side being scrolled out of view is in question
310
+ * @param {String} elSide Side of the element in question ('top', 'left', 'right', 'bottom')
311
+ * @param {String} parentSide Side of the parent in question ('top', 'left', 'right', 'bottom')
312
+ * @return {HTMLElement} The parent scroll element that the el's side is scrolled past, or null if there is no such element
313
+ */
314
+ function isScrolledPast(el, elSide, parentSide) {
315
+ var parent = getParentAutoScrollElement(el, true),
316
+ elSideVal = getRect(el)[elSide];
317
+
318
+ /* jshint boss:true */
319
+ while (parent) {
320
+ var parentSideVal = getRect(parent)[parentSide],
321
+ visible = void 0;
322
+ {
323
+ visible = elSideVal >= parentSideVal;
324
+ }
325
+ if (!visible) return parent;
326
+ if (parent === getWindowScrollingElement()) break;
327
+ parent = getParentAutoScrollElement(parent, false);
328
+ }
329
+ return false;
330
+ }
331
+
332
+ /**
333
+ * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible)
334
+ * and non-draggable elements
335
+ * @param {HTMLElement} el The parent element
336
+ * @param {Number} childNum The index of the child
337
+ * @param {Object} options Parent Sortable's options
338
+ * @return {HTMLElement} The child at index childNum, or null if not found
339
+ */
340
+ function getChild(el, childNum, options, includeDragEl) {
341
+ var currentChild = 0,
342
+ i = 0,
343
+ children = el.children;
344
+ while (i < children.length) {
345
+ if (children[i].style.display !== 'none' && children[i] !== Sortable.ghost && (includeDragEl || children[i] !== Sortable.dragged) && closest(children[i], options.draggable, el, false)) {
346
+ if (currentChild === childNum) {
347
+ return children[i];
348
+ }
349
+ currentChild++;
350
+ }
351
+ i++;
352
+ }
353
+ return null;
354
+ }
355
+
356
+ /**
357
+ * Gets the last child in the el, ignoring ghostEl or invisible elements (clones)
358
+ * @param {HTMLElement} el Parent element
359
+ * @param {selector} selector Any other elements that should be ignored
360
+ * @return {HTMLElement} The last child, ignoring ghostEl
361
+ */
362
+ function lastChild(el, selector) {
363
+ var last = el.lastElementChild;
364
+ while (last && (last === Sortable.ghost || css(last, 'display') === 'none' || selector && !matches(last, selector))) {
365
+ last = last.previousElementSibling;
366
+ }
367
+ return last || null;
368
+ }
369
+
370
+ /**
371
+ * Returns the index of an element within its parent for a selected set of
372
+ * elements
373
+ * @param {HTMLElement} el
374
+ * @param {selector} selector
375
+ * @return {number}
376
+ */
377
+ function index(el, selector) {
378
+ var index = 0;
379
+ if (!el || !el.parentNode) {
380
+ return -1;
381
+ }
382
+
383
+ /* jshint boss:true */
384
+ while (el = el.previousElementSibling) {
385
+ if (el.nodeName.toUpperCase() !== 'TEMPLATE' && el !== Sortable.clone && (!selector || matches(el, selector))) {
386
+ index++;
387
+ }
388
+ }
389
+ return index;
390
+ }
391
+
392
+ /**
393
+ * Returns the scroll offset of the given element, added with all the scroll offsets of parent elements.
394
+ * The value is returned in real pixels.
395
+ * @param {HTMLElement} el
396
+ * @return {Array} Offsets in the format of [left, top]
397
+ */
398
+ function getRelativeScrollOffset(el) {
399
+ var offsetLeft = 0,
400
+ offsetTop = 0,
401
+ winScroller = getWindowScrollingElement();
402
+ if (el) {
403
+ do {
404
+ var elMatrix = matrix(el),
405
+ scaleX = elMatrix.a,
406
+ scaleY = elMatrix.d;
407
+ offsetLeft += el.scrollLeft * scaleX;
408
+ offsetTop += el.scrollTop * scaleY;
409
+ } while (el !== winScroller && (el = el.parentNode));
410
+ }
411
+ return [offsetLeft, offsetTop];
412
+ }
413
+
414
+ /**
415
+ * Returns the index of the object within the given array
416
+ * @param {Array} arr Array that may or may not hold the object
417
+ * @param {Object} obj An object that has a key-value pair unique to and identical to a key-value pair in the object you want to find
418
+ * @return {Number} The index of the object in the array, or -1
419
+ */
420
+ function indexOfObject(arr, obj) {
421
+ for (var i in arr) {
422
+ if (!arr.hasOwnProperty(i)) continue;
423
+ for (var key in obj) {
424
+ if (obj.hasOwnProperty(key) && obj[key] === arr[i][key]) return Number(i);
425
+ }
426
+ }
427
+ return -1;
428
+ }
429
+ function getParentAutoScrollElement(el, includeSelf) {
430
+ // skip to window
431
+ if (!el || !el.getBoundingClientRect) return getWindowScrollingElement();
432
+ var elem = el;
433
+ var gotSelf = false;
434
+ do {
435
+ // we don't need to get elem css if it isn't even overflowing in the first place (performance)
436
+ if (elem.clientWidth < elem.scrollWidth || elem.clientHeight < elem.scrollHeight) {
437
+ var elemCSS = css(elem);
438
+ if (elem.clientWidth < elem.scrollWidth && (elemCSS.overflowX == 'auto' || elemCSS.overflowX == 'scroll') || elem.clientHeight < elem.scrollHeight && (elemCSS.overflowY == 'auto' || elemCSS.overflowY == 'scroll')) {
439
+ if (!elem.getBoundingClientRect || elem === document.body) return getWindowScrollingElement();
440
+ if (gotSelf || includeSelf) return elem;
441
+ gotSelf = true;
442
+ }
443
+ }
444
+ /* jshint boss:true */
445
+ } while (elem = elem.parentNode);
446
+ return getWindowScrollingElement();
447
+ }
448
+ function extend(dst, src) {
449
+ if (dst && src) {
450
+ for (var key in src) {
451
+ if (src.hasOwnProperty(key)) {
452
+ dst[key] = src[key];
453
+ }
454
+ }
455
+ }
456
+ return dst;
457
+ }
458
+ function isRectEqual(rect1, rect2) {
459
+ return Math.round(rect1.top) === Math.round(rect2.top) && Math.round(rect1.left) === Math.round(rect2.left) && Math.round(rect1.height) === Math.round(rect2.height) && Math.round(rect1.width) === Math.round(rect2.width);
460
+ }
461
+ var _throttleTimeout;
462
+ function throttle(callback, ms) {
463
+ return function () {
464
+ if (!_throttleTimeout) {
465
+ var args = arguments,
466
+ _this = this;
467
+ if (args.length === 1) {
468
+ callback.call(_this, args[0]);
469
+ } else {
470
+ callback.apply(_this, args);
471
+ }
472
+ _throttleTimeout = setTimeout(function () {
473
+ _throttleTimeout = void 0;
474
+ }, ms);
475
+ }
476
+ };
477
+ }
478
+ function cancelThrottle() {
479
+ clearTimeout(_throttleTimeout);
480
+ _throttleTimeout = void 0;
481
+ }
482
+ function scrollBy(el, x, y) {
483
+ el.scrollLeft += x;
484
+ el.scrollTop += y;
485
+ }
486
+ function clone(el) {
487
+ var Polymer = window.Polymer;
488
+ var $ = window.jQuery || window.Zepto;
489
+ if (Polymer && Polymer.dom) {
490
+ return Polymer.dom(el).cloneNode(true);
491
+ } else if ($) {
492
+ return $(el).clone(true)[0];
493
+ } else {
494
+ return el.cloneNode(true);
495
+ }
496
+ }
497
+ function getChildContainingRectFromElement(container, options, ghostEl) {
498
+ var rect = {};
499
+ Array.from(container.children).forEach(function (child) {
500
+ var _rect$left, _rect$top, _rect$right, _rect$bottom;
501
+ if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
502
+ var childRect = getRect(child);
503
+ rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
504
+ rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
505
+ rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
506
+ rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
507
+ });
508
+ rect.width = rect.right - rect.left;
509
+ rect.height = rect.bottom - rect.top;
510
+ rect.x = rect.left;
511
+ rect.y = rect.top;
512
+ return rect;
513
+ }
514
+ var expando = 'Sortable' + new Date().getTime();
515
+
516
+ function AnimationStateManager() {
517
+ var animationStates = [],
518
+ animationCallbackId;
519
+ return {
520
+ captureAnimationState: function captureAnimationState() {
521
+ animationStates = [];
522
+ if (!this.options.animation) return;
523
+ var children = [].slice.call(this.el.children);
524
+ children.forEach(function (child) {
525
+ if (css(child, 'display') === 'none' || child === Sortable.ghost) return;
526
+ animationStates.push({
527
+ target: child,
528
+ rect: getRect(child)
529
+ });
530
+ var fromRect = _objectSpread2({}, animationStates[animationStates.length - 1].rect);
531
+
532
+ // If animating: compensate for current animation
533
+ if (child.thisAnimationDuration) {
534
+ var childMatrix = matrix(child, true);
535
+ if (childMatrix) {
536
+ fromRect.top -= childMatrix.f;
537
+ fromRect.left -= childMatrix.e;
538
+ }
539
+ }
540
+ child.fromRect = fromRect;
541
+ });
542
+ },
543
+ addAnimationState: function addAnimationState(state) {
544
+ animationStates.push(state);
545
+ },
546
+ removeAnimationState: function removeAnimationState(target) {
547
+ animationStates.splice(indexOfObject(animationStates, {
548
+ target: target
549
+ }), 1);
550
+ },
551
+ animateAll: function animateAll(callback) {
552
+ var _this = this;
553
+ if (!this.options.animation) {
554
+ clearTimeout(animationCallbackId);
555
+ if (typeof callback === 'function') callback();
556
+ return;
557
+ }
558
+ var animating = false,
559
+ animationTime = 0;
560
+ animationStates.forEach(function (state) {
561
+ var time = 0,
562
+ target = state.target,
563
+ fromRect = target.fromRect,
564
+ toRect = getRect(target),
565
+ prevFromRect = target.prevFromRect,
566
+ prevToRect = target.prevToRect,
567
+ animatingRect = state.rect,
568
+ targetMatrix = matrix(target, true);
569
+ if (targetMatrix) {
570
+ // Compensate for current animation
571
+ toRect.top -= targetMatrix.f;
572
+ toRect.left -= targetMatrix.e;
573
+ }
574
+ target.toRect = toRect;
575
+ if (target.thisAnimationDuration) {
576
+ // Could also check if animatingRect is between fromRect and toRect
577
+ if (isRectEqual(prevFromRect, toRect) && !isRectEqual(fromRect, toRect) &&
578
+ // Make sure animatingRect is on line between toRect & fromRect
579
+ (animatingRect.top - toRect.top) / (animatingRect.left - toRect.left) === (fromRect.top - toRect.top) / (fromRect.left - toRect.left)) {
580
+ // If returning to same place as started from animation and on same axis
581
+ time = calculateRealTime(animatingRect, prevFromRect, prevToRect, _this.options);
582
+ }
583
+ }
584
+
585
+ // if fromRect != toRect: animate
586
+ if (!isRectEqual(toRect, fromRect)) {
587
+ target.prevFromRect = fromRect;
588
+ target.prevToRect = toRect;
589
+ if (!time) {
590
+ time = _this.options.animation;
591
+ }
592
+ _this.animate(target, animatingRect, toRect, time);
593
+ }
594
+ if (time) {
595
+ animating = true;
596
+ animationTime = Math.max(animationTime, time);
597
+ clearTimeout(target.animationResetTimer);
598
+ target.animationResetTimer = setTimeout(function () {
599
+ target.animationTime = 0;
600
+ target.prevFromRect = null;
601
+ target.fromRect = null;
602
+ target.prevToRect = null;
603
+ target.thisAnimationDuration = null;
604
+ }, time);
605
+ target.thisAnimationDuration = time;
606
+ }
607
+ });
608
+ clearTimeout(animationCallbackId);
609
+ if (!animating) {
610
+ if (typeof callback === 'function') callback();
611
+ } else {
612
+ animationCallbackId = setTimeout(function () {
613
+ if (typeof callback === 'function') callback();
614
+ }, animationTime);
615
+ }
616
+ animationStates = [];
617
+ },
618
+ animate: function animate(target, currentRect, toRect, duration) {
619
+ if (duration) {
620
+ css(target, 'transition', '');
621
+ css(target, 'transform', '');
622
+ var elMatrix = matrix(this.el),
623
+ scaleX = elMatrix && elMatrix.a,
624
+ scaleY = elMatrix && elMatrix.d,
625
+ translateX = (currentRect.left - toRect.left) / (scaleX || 1),
626
+ translateY = (currentRect.top - toRect.top) / (scaleY || 1);
627
+ target.animatingX = !!translateX;
628
+ target.animatingY = !!translateY;
629
+ css(target, 'transform', 'translate3d(' + translateX + 'px,' + translateY + 'px,0)');
630
+ this.forRepaintDummy = repaint(target); // repaint
631
+
632
+ css(target, 'transition', 'transform ' + duration + 'ms' + (this.options.easing ? ' ' + this.options.easing : ''));
633
+ css(target, 'transform', 'translate3d(0,0,0)');
634
+ typeof target.animated === 'number' && clearTimeout(target.animated);
635
+ target.animated = setTimeout(function () {
636
+ css(target, 'transition', '');
637
+ css(target, 'transform', '');
638
+ target.animated = false;
639
+ target.animatingX = false;
640
+ target.animatingY = false;
641
+ }, duration);
642
+ }
643
+ }
644
+ };
645
+ }
646
+ function repaint(target) {
647
+ return target.offsetWidth;
648
+ }
649
+ function calculateRealTime(animatingRect, fromRect, toRect, options) {
650
+ return Math.sqrt(Math.pow(fromRect.top - animatingRect.top, 2) + Math.pow(fromRect.left - animatingRect.left, 2)) / Math.sqrt(Math.pow(fromRect.top - toRect.top, 2) + Math.pow(fromRect.left - toRect.left, 2)) * options.animation;
651
+ }
652
+
653
+ var plugins = [];
654
+ var defaults = {
655
+ initializeByDefault: true
656
+ };
657
+ var PluginManager = {
658
+ mount: function mount(plugin) {
659
+ // Set default static properties
660
+ for (var option in defaults) {
661
+ if (defaults.hasOwnProperty(option) && !(option in plugin)) {
662
+ plugin[option] = defaults[option];
663
+ }
664
+ }
665
+ plugins.forEach(function (p) {
666
+ if (p.pluginName === plugin.pluginName) {
667
+ throw "Sortable: Cannot mount plugin ".concat(plugin.pluginName, " more than once");
668
+ }
669
+ });
670
+ plugins.push(plugin);
671
+ },
672
+ pluginEvent: function pluginEvent(eventName, sortable, evt) {
673
+ var _this = this;
674
+ this.eventCanceled = false;
675
+ evt.cancel = function () {
676
+ _this.eventCanceled = true;
677
+ };
678
+ var eventNameGlobal = eventName + 'Global';
679
+ plugins.forEach(function (plugin) {
680
+ if (!sortable[plugin.pluginName]) return;
681
+ // Fire global events if it exists in this sortable
682
+ if (sortable[plugin.pluginName][eventNameGlobal]) {
683
+ sortable[plugin.pluginName][eventNameGlobal](_objectSpread2({
684
+ sortable: sortable
685
+ }, evt));
686
+ }
687
+
688
+ // Only fire plugin event if plugin is enabled in this sortable,
689
+ // and plugin has event defined
690
+ if (sortable.options[plugin.pluginName] && sortable[plugin.pluginName][eventName]) {
691
+ sortable[plugin.pluginName][eventName](_objectSpread2({
692
+ sortable: sortable
693
+ }, evt));
694
+ }
695
+ });
696
+ },
697
+ initializePlugins: function initializePlugins(sortable, el, defaults, options) {
698
+ plugins.forEach(function (plugin) {
699
+ var pluginName = plugin.pluginName;
700
+ if (!sortable.options[pluginName] && !plugin.initializeByDefault) return;
701
+ var initialized = new plugin(sortable, el, sortable.options);
702
+ initialized.sortable = sortable;
703
+ initialized.options = sortable.options;
704
+ sortable[pluginName] = initialized;
705
+
706
+ // Add default options from plugin
707
+ _extends(defaults, initialized.defaults);
708
+ });
709
+ for (var option in sortable.options) {
710
+ if (!sortable.options.hasOwnProperty(option)) continue;
711
+ var modified = this.modifyOption(sortable, option, sortable.options[option]);
712
+ if (typeof modified !== 'undefined') {
713
+ sortable.options[option] = modified;
714
+ }
715
+ }
716
+ },
717
+ getEventProperties: function getEventProperties(name, sortable) {
718
+ var eventProperties = {};
719
+ plugins.forEach(function (plugin) {
720
+ if (typeof plugin.eventProperties !== 'function') return;
721
+ _extends(eventProperties, plugin.eventProperties.call(sortable[plugin.pluginName], name));
722
+ });
723
+ return eventProperties;
724
+ },
725
+ modifyOption: function modifyOption(sortable, name, value) {
726
+ var modifiedValue;
727
+ plugins.forEach(function (plugin) {
728
+ // Plugin must exist on the Sortable
729
+ if (!sortable[plugin.pluginName]) return;
730
+
731
+ // If static option listener exists for this option, call in the context of the Sortable's instance of this plugin
732
+ if (plugin.optionListeners && typeof plugin.optionListeners[name] === 'function') {
733
+ modifiedValue = plugin.optionListeners[name].call(sortable[plugin.pluginName], value);
734
+ }
735
+ });
736
+ return modifiedValue;
737
+ }
738
+ };
739
+
740
+ function dispatchEvent(_ref) {
741
+ var sortable = _ref.sortable,
742
+ rootEl = _ref.rootEl,
743
+ name = _ref.name,
744
+ targetEl = _ref.targetEl,
745
+ cloneEl = _ref.cloneEl,
746
+ toEl = _ref.toEl,
747
+ fromEl = _ref.fromEl,
748
+ oldIndex = _ref.oldIndex,
749
+ newIndex = _ref.newIndex,
750
+ oldDraggableIndex = _ref.oldDraggableIndex,
751
+ newDraggableIndex = _ref.newDraggableIndex,
752
+ originalEvent = _ref.originalEvent,
753
+ putSortable = _ref.putSortable,
754
+ extraEventProperties = _ref.extraEventProperties;
755
+ sortable = sortable || rootEl && rootEl[expando];
756
+ if (!sortable) return;
757
+ var evt,
758
+ options = sortable.options,
759
+ onName = 'on' + name.charAt(0).toUpperCase() + name.substr(1);
760
+ // Support for new CustomEvent feature
761
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
762
+ evt = new CustomEvent(name, {
763
+ bubbles: true,
764
+ cancelable: true
765
+ });
766
+ } else {
767
+ evt = document.createEvent('Event');
768
+ evt.initEvent(name, true, true);
769
+ }
770
+ evt.to = toEl || rootEl;
771
+ evt.from = fromEl || rootEl;
772
+ evt.item = targetEl || rootEl;
773
+ evt.clone = cloneEl;
774
+ evt.oldIndex = oldIndex;
775
+ evt.newIndex = newIndex;
776
+ evt.oldDraggableIndex = oldDraggableIndex;
777
+ evt.newDraggableIndex = newDraggableIndex;
778
+ evt.originalEvent = originalEvent;
779
+ evt.pullMode = putSortable ? putSortable.lastPutMode : undefined;
780
+ var allEventProperties = _objectSpread2(_objectSpread2({}, extraEventProperties), PluginManager.getEventProperties(name, sortable));
781
+ for (var option in allEventProperties) {
782
+ evt[option] = allEventProperties[option];
783
+ }
784
+ if (rootEl) {
785
+ rootEl.dispatchEvent(evt);
786
+ }
787
+ if (options[onName]) {
788
+ options[onName].call(sortable, evt);
789
+ }
790
+ }
791
+
792
+ var _excluded = ["evt"];
793
+ var pluginEvent = function pluginEvent(eventName, sortable) {
794
+ var _ref = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
795
+ originalEvent = _ref.evt,
796
+ data = _objectWithoutProperties(_ref, _excluded);
797
+ PluginManager.pluginEvent.bind(Sortable)(eventName, sortable, _objectSpread2({
798
+ dragEl: dragEl,
799
+ parentEl: parentEl,
800
+ ghostEl: ghostEl,
801
+ rootEl: rootEl,
802
+ nextEl: nextEl,
803
+ lastDownEl: lastDownEl,
804
+ cloneEl: cloneEl,
805
+ cloneHidden: cloneHidden,
806
+ dragStarted: moved,
807
+ putSortable: putSortable,
808
+ activeSortable: Sortable.active,
809
+ originalEvent: originalEvent,
810
+ oldIndex: oldIndex,
811
+ oldDraggableIndex: oldDraggableIndex,
812
+ newIndex: newIndex,
813
+ newDraggableIndex: newDraggableIndex,
814
+ hideGhostForTarget: _hideGhostForTarget,
815
+ unhideGhostForTarget: _unhideGhostForTarget,
816
+ cloneNowHidden: function cloneNowHidden() {
817
+ cloneHidden = true;
818
+ },
819
+ cloneNowShown: function cloneNowShown() {
820
+ cloneHidden = false;
821
+ },
822
+ dispatchSortableEvent: function dispatchSortableEvent(name) {
823
+ _dispatchEvent({
824
+ sortable: sortable,
825
+ name: name,
826
+ originalEvent: originalEvent
827
+ });
828
+ }
829
+ }, data));
830
+ };
831
+ function _dispatchEvent(info) {
832
+ dispatchEvent(_objectSpread2({
833
+ putSortable: putSortable,
834
+ cloneEl: cloneEl,
835
+ targetEl: dragEl,
836
+ rootEl: rootEl,
837
+ oldIndex: oldIndex,
838
+ oldDraggableIndex: oldDraggableIndex,
839
+ newIndex: newIndex,
840
+ newDraggableIndex: newDraggableIndex
841
+ }, info));
842
+ }
843
+ var dragEl,
844
+ parentEl,
845
+ ghostEl,
846
+ rootEl,
847
+ nextEl,
848
+ lastDownEl,
849
+ cloneEl,
850
+ cloneHidden,
851
+ oldIndex,
852
+ newIndex,
853
+ oldDraggableIndex,
854
+ newDraggableIndex,
855
+ activeGroup,
856
+ putSortable,
857
+ awaitingDragStarted = false,
858
+ ignoreNextClick = false,
859
+ sortables = [],
860
+ tapEvt,
861
+ touchEvt,
862
+ lastDx,
863
+ lastDy,
864
+ tapDistanceLeft,
865
+ tapDistanceTop,
866
+ moved,
867
+ lastTarget,
868
+ lastDirection,
869
+ pastFirstInvertThresh = false,
870
+ isCircumstantialInvert = false,
871
+ targetMoveDistance,
872
+ // For positioning ghost absolutely
873
+ ghostRelativeParent,
874
+ ghostRelativeParentInitialScroll = [],
875
+ // (left, top)
876
+
877
+ _silent = false,
878
+ savedInputChecked = [];
879
+
880
+ /** @const */
881
+ var documentExists = typeof document !== 'undefined',
882
+ PositionGhostAbsolutely = IOS,
883
+ CSSFloatProperty = Edge || IE11OrLess ? 'cssFloat' : 'float',
884
+ // This will not pass for IE9, because IE9 DnD only works on anchors
885
+ supportDraggable = documentExists && !ChromeForAndroid && !IOS && 'draggable' in document.createElement('div'),
886
+ supportCssPointerEvents = function () {
887
+ if (!documentExists) return;
888
+ // false when <= IE11
889
+ if (IE11OrLess) {
890
+ return false;
891
+ }
892
+ var el = document.createElement('x');
893
+ el.style.cssText = 'pointer-events:auto';
894
+ return el.style.pointerEvents === 'auto';
895
+ }(),
896
+ _detectDirection = function _detectDirection(el, options) {
897
+ var elCSS = css(el),
898
+ elWidth = parseInt(elCSS.width) - parseInt(elCSS.paddingLeft) - parseInt(elCSS.paddingRight) - parseInt(elCSS.borderLeftWidth) - parseInt(elCSS.borderRightWidth),
899
+ child1 = getChild(el, 0, options),
900
+ child2 = getChild(el, 1, options),
901
+ firstChildCSS = child1 && css(child1),
902
+ secondChildCSS = child2 && css(child2),
903
+ firstChildWidth = firstChildCSS && parseInt(firstChildCSS.marginLeft) + parseInt(firstChildCSS.marginRight) + getRect(child1).width,
904
+ secondChildWidth = secondChildCSS && parseInt(secondChildCSS.marginLeft) + parseInt(secondChildCSS.marginRight) + getRect(child2).width;
905
+ if (elCSS.display === 'flex') {
906
+ return elCSS.flexDirection === 'column' || elCSS.flexDirection === 'column-reverse' ? 'vertical' : 'horizontal';
907
+ }
908
+ if (elCSS.display === 'grid') {
909
+ return elCSS.gridTemplateColumns.split(' ').length <= 1 ? 'vertical' : 'horizontal';
910
+ }
911
+ if (child1 && firstChildCSS["float"] && firstChildCSS["float"] !== 'none') {
912
+ var touchingSideChild2 = firstChildCSS["float"] === 'left' ? 'left' : 'right';
913
+ return child2 && (secondChildCSS.clear === 'both' || secondChildCSS.clear === touchingSideChild2) ? 'vertical' : 'horizontal';
914
+ }
915
+ return child1 && (firstChildCSS.display === 'block' || firstChildCSS.display === 'flex' || firstChildCSS.display === 'table' || firstChildCSS.display === 'grid' || firstChildWidth >= elWidth && elCSS[CSSFloatProperty] === 'none' || child2 && elCSS[CSSFloatProperty] === 'none' && firstChildWidth + secondChildWidth > elWidth) ? 'vertical' : 'horizontal';
916
+ },
917
+ _dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
918
+ var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
919
+ dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
920
+ dragElOppLength = vertical ? dragRect.width : dragRect.height,
921
+ targetS1Opp = vertical ? targetRect.left : targetRect.top,
922
+ targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
923
+ targetOppLength = vertical ? targetRect.width : targetRect.height;
924
+ return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
925
+ },
926
+ /**
927
+ * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
928
+ * @param {Number} x X position
929
+ * @param {Number} y Y position
930
+ * @return {HTMLElement} Element of the first found nearest Sortable
931
+ */
932
+ _detectNearestEmptySortable = function _detectNearestEmptySortable(x, y) {
933
+ var ret;
934
+ sortables.some(function (sortable) {
935
+ var threshold = sortable[expando].options.emptyInsertThreshold;
936
+ if (!threshold || lastChild(sortable)) return;
937
+ var rect = getRect(sortable),
938
+ insideHorizontally = x >= rect.left - threshold && x <= rect.right + threshold,
939
+ insideVertically = y >= rect.top - threshold && y <= rect.bottom + threshold;
940
+ if (insideHorizontally && insideVertically) {
941
+ return ret = sortable;
942
+ }
943
+ });
944
+ return ret;
945
+ },
946
+ _prepareGroup = function _prepareGroup(options) {
947
+ function toFn(value, pull) {
948
+ return function (to, from, dragEl, evt) {
949
+ var sameGroup = to.options.group.name && from.options.group.name && to.options.group.name === from.options.group.name;
950
+ if (value == null && (pull || sameGroup)) {
951
+ // Default pull value
952
+ // Default pull and put value if same group
953
+ return true;
954
+ } else if (value == null || value === false) {
955
+ return false;
956
+ } else if (pull && value === 'clone') {
957
+ return value;
958
+ } else if (typeof value === 'function') {
959
+ return toFn(value(to, from, dragEl, evt), pull)(to, from, dragEl, evt);
960
+ } else {
961
+ var otherGroup = (pull ? to : from).options.group.name;
962
+ return value === true || typeof value === 'string' && value === otherGroup || value.join && value.indexOf(otherGroup) > -1;
963
+ }
964
+ };
965
+ }
966
+ var group = {};
967
+ var originalGroup = options.group;
968
+ if (!originalGroup || _typeof(originalGroup) != 'object') {
969
+ originalGroup = {
970
+ name: originalGroup
971
+ };
972
+ }
973
+ group.name = originalGroup.name;
974
+ group.checkPull = toFn(originalGroup.pull, true);
975
+ group.checkPut = toFn(originalGroup.put);
976
+ group.revertClone = originalGroup.revertClone;
977
+ options.group = group;
978
+ },
979
+ _hideGhostForTarget = function _hideGhostForTarget() {
980
+ if (!supportCssPointerEvents && ghostEl) {
981
+ css(ghostEl, 'display', 'none');
982
+ }
983
+ },
984
+ _unhideGhostForTarget = function _unhideGhostForTarget() {
985
+ if (!supportCssPointerEvents && ghostEl) {
986
+ css(ghostEl, 'display', '');
987
+ }
988
+ };
989
+
990
+ // #1184 fix - Prevent click event on fallback if dragged but item not changed position
991
+ if (documentExists && !ChromeForAndroid) {
992
+ document.addEventListener('click', function (evt) {
993
+ if (ignoreNextClick) {
994
+ evt.preventDefault();
995
+ evt.stopPropagation && evt.stopPropagation();
996
+ evt.stopImmediatePropagation && evt.stopImmediatePropagation();
997
+ ignoreNextClick = false;
998
+ return false;
999
+ }
1000
+ }, true);
1001
+ }
1002
+ var nearestEmptyInsertDetectEvent = function nearestEmptyInsertDetectEvent(evt) {
1003
+ if (dragEl) {
1004
+ evt = evt.touches ? evt.touches[0] : evt;
1005
+ var nearest = _detectNearestEmptySortable(evt.clientX, evt.clientY);
1006
+ if (nearest) {
1007
+ // Create imitation event
1008
+ var event = {};
1009
+ for (var i in evt) {
1010
+ if (evt.hasOwnProperty(i)) {
1011
+ event[i] = evt[i];
1012
+ }
1013
+ }
1014
+ event.target = event.rootEl = nearest;
1015
+ event.preventDefault = void 0;
1016
+ event.stopPropagation = void 0;
1017
+ nearest[expando]._onDragOver(event);
1018
+ }
1019
+ }
1020
+ };
1021
+ var _checkOutsideTargetEl = function _checkOutsideTargetEl(evt) {
1022
+ if (dragEl) {
1023
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1024
+ }
1025
+ };
1026
+
1027
+ /**
1028
+ * @class Sortable
1029
+ * @param {HTMLElement} el
1030
+ * @param {Object} [options]
1031
+ */
1032
+ function Sortable(el, options) {
1033
+ if (!(el && el.nodeType && el.nodeType === 1)) {
1034
+ throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(el));
1035
+ }
1036
+ this.el = el; // root element
1037
+ this.options = options = _extends({}, options);
1038
+
1039
+ // Export instance
1040
+ el[expando] = this;
1041
+ var defaults = {
1042
+ group: null,
1043
+ sort: true,
1044
+ disabled: false,
1045
+ store: null,
1046
+ handle: null,
1047
+ draggable: /^[uo]l$/i.test(el.nodeName) ? '>li' : '>*',
1048
+ swapThreshold: 1,
1049
+ // percentage; 0 <= x <= 1
1050
+ invertSwap: false,
1051
+ // invert always
1052
+ invertedSwapThreshold: null,
1053
+ // will be set to same as swapThreshold if default
1054
+ removeCloneOnHide: true,
1055
+ direction: function direction() {
1056
+ return _detectDirection(el, this.options);
1057
+ },
1058
+ ghostClass: 'sortable-ghost',
1059
+ chosenClass: 'sortable-chosen',
1060
+ dragClass: 'sortable-drag',
1061
+ ignore: 'a, img',
1062
+ filter: null,
1063
+ preventOnFilter: true,
1064
+ animation: 0,
1065
+ easing: null,
1066
+ setData: function setData(dataTransfer, dragEl) {
1067
+ dataTransfer.setData('Text', dragEl.textContent);
1068
+ },
1069
+ dropBubble: false,
1070
+ dragoverBubble: false,
1071
+ dataIdAttr: 'data-id',
1072
+ delay: 0,
1073
+ delayOnTouchOnly: false,
1074
+ touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
1075
+ forceFallback: false,
1076
+ fallbackClass: 'sortable-fallback',
1077
+ fallbackOnBody: false,
1078
+ fallbackTolerance: 0,
1079
+ fallbackOffset: {
1080
+ x: 0,
1081
+ y: 0
1082
+ },
1083
+ // Disabled on Safari: #1571; Enabled on Safari IOS: #2244
1084
+ supportPointer: Sortable.supportPointer !== false && 'PointerEvent' in window && (!Safari || IOS),
1085
+ emptyInsertThreshold: 5
1086
+ };
1087
+ PluginManager.initializePlugins(this, el, defaults);
1088
+
1089
+ // Set default options
1090
+ for (var name in defaults) {
1091
+ !(name in options) && (options[name] = defaults[name]);
1092
+ }
1093
+ _prepareGroup(options);
1094
+
1095
+ // Bind all private methods
1096
+ for (var fn in this) {
1097
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
1098
+ this[fn] = this[fn].bind(this);
1099
+ }
1100
+ }
1101
+
1102
+ // Setup drag mode
1103
+ this.nativeDraggable = options.forceFallback ? false : supportDraggable;
1104
+ if (this.nativeDraggable) {
1105
+ // Touch start threshold cannot be greater than the native dragstart threshold
1106
+ this.options.touchStartThreshold = 1;
1107
+ }
1108
+
1109
+ // Bind events
1110
+ if (options.supportPointer) {
1111
+ on(el, 'pointerdown', this._onTapStart);
1112
+ } else {
1113
+ on(el, 'mousedown', this._onTapStart);
1114
+ on(el, 'touchstart', this._onTapStart);
1115
+ }
1116
+ if (this.nativeDraggable) {
1117
+ on(el, 'dragover', this);
1118
+ on(el, 'dragenter', this);
1119
+ }
1120
+ sortables.push(this.el);
1121
+
1122
+ // Restore sorting
1123
+ options.store && options.store.get && this.sort(options.store.get(this) || []);
1124
+
1125
+ // Add animation state manager
1126
+ _extends(this, AnimationStateManager());
1127
+ }
1128
+ Sortable.prototype = /** @lends Sortable.prototype */{
1129
+ constructor: Sortable,
1130
+ _isOutsideThisEl: function _isOutsideThisEl(target) {
1131
+ if (!this.el.contains(target) && target !== this.el) {
1132
+ lastTarget = null;
1133
+ }
1134
+ },
1135
+ _getDirection: function _getDirection(evt, target) {
1136
+ return typeof this.options.direction === 'function' ? this.options.direction.call(this, evt, target, dragEl) : this.options.direction;
1137
+ },
1138
+ _onTapStart: function _onTapStart( /** Event|TouchEvent */evt) {
1139
+ if (!evt.cancelable) return;
1140
+ var _this = this,
1141
+ el = this.el,
1142
+ options = this.options,
1143
+ preventOnFilter = options.preventOnFilter,
1144
+ type = evt.type,
1145
+ touch = evt.touches && evt.touches[0] || evt.pointerType && evt.pointerType === 'touch' && evt,
1146
+ target = (touch || evt).target,
1147
+ originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0] || evt.composedPath && evt.composedPath()[0]) || target,
1148
+ filter = options.filter;
1149
+ _saveInputCheckedState(el);
1150
+
1151
+ // Don't trigger start event when an element is been dragged, otherwise the evt.oldindex always wrong when set option.group.
1152
+ if (dragEl) {
1153
+ return;
1154
+ }
1155
+ if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) {
1156
+ return; // only left button and enabled
1157
+ }
1158
+
1159
+ // cancel dnd if original target is content editable
1160
+ if (originalTarget.isContentEditable) {
1161
+ return;
1162
+ }
1163
+
1164
+ // Safari ignores further event handling after mousedown
1165
+ if (!this.nativeDraggable && Safari && target && target.tagName.toUpperCase() === 'SELECT') {
1166
+ return;
1167
+ }
1168
+ target = closest(target, options.draggable, el, false);
1169
+ if (target && target.animated) {
1170
+ return;
1171
+ }
1172
+ if (lastDownEl === target) {
1173
+ // Ignoring duplicate `down`
1174
+ return;
1175
+ }
1176
+
1177
+ // Get the index of the dragged element within its parent
1178
+ oldIndex = index(target);
1179
+ oldDraggableIndex = index(target, options.draggable);
1180
+
1181
+ // Check filter
1182
+ if (typeof filter === 'function') {
1183
+ if (filter.call(this, evt, target, this)) {
1184
+ _dispatchEvent({
1185
+ sortable: _this,
1186
+ rootEl: originalTarget,
1187
+ name: 'filter',
1188
+ targetEl: target,
1189
+ toEl: el,
1190
+ fromEl: el
1191
+ });
1192
+ pluginEvent('filter', _this, {
1193
+ evt: evt
1194
+ });
1195
+ preventOnFilter && evt.preventDefault();
1196
+ return; // cancel dnd
1197
+ }
1198
+ } else if (filter) {
1199
+ filter = filter.split(',').some(function (criteria) {
1200
+ criteria = closest(originalTarget, criteria.trim(), el, false);
1201
+ if (criteria) {
1202
+ _dispatchEvent({
1203
+ sortable: _this,
1204
+ rootEl: criteria,
1205
+ name: 'filter',
1206
+ targetEl: target,
1207
+ fromEl: el,
1208
+ toEl: el
1209
+ });
1210
+ pluginEvent('filter', _this, {
1211
+ evt: evt
1212
+ });
1213
+ return true;
1214
+ }
1215
+ });
1216
+ if (filter) {
1217
+ preventOnFilter && evt.preventDefault();
1218
+ return; // cancel dnd
1219
+ }
1220
+ }
1221
+ if (options.handle && !closest(originalTarget, options.handle, el, false)) {
1222
+ return;
1223
+ }
1224
+
1225
+ // Prepare `dragstart`
1226
+ this._prepareDragStart(evt, touch, target);
1227
+ },
1228
+ _prepareDragStart: function _prepareDragStart( /** Event */evt, /** Touch */touch, /** HTMLElement */target) {
1229
+ var _this = this,
1230
+ el = _this.el,
1231
+ options = _this.options,
1232
+ ownerDocument = el.ownerDocument,
1233
+ dragStartFn;
1234
+ if (target && !dragEl && target.parentNode === el) {
1235
+ var dragRect = getRect(target);
1236
+ rootEl = el;
1237
+ dragEl = target;
1238
+ parentEl = dragEl.parentNode;
1239
+ nextEl = dragEl.nextSibling;
1240
+ lastDownEl = target;
1241
+ activeGroup = options.group;
1242
+ Sortable.dragged = dragEl;
1243
+ tapEvt = {
1244
+ target: dragEl,
1245
+ clientX: (touch || evt).clientX,
1246
+ clientY: (touch || evt).clientY
1247
+ };
1248
+ tapDistanceLeft = tapEvt.clientX - dragRect.left;
1249
+ tapDistanceTop = tapEvt.clientY - dragRect.top;
1250
+ this._lastX = (touch || evt).clientX;
1251
+ this._lastY = (touch || evt).clientY;
1252
+ dragEl.style['will-change'] = 'all';
1253
+ dragStartFn = function dragStartFn() {
1254
+ pluginEvent('delayEnded', _this, {
1255
+ evt: evt
1256
+ });
1257
+ if (Sortable.eventCanceled) {
1258
+ _this._onDrop();
1259
+ return;
1260
+ }
1261
+ // Delayed drag has been triggered
1262
+ // we can re-enable the events: touchmove/mousemove
1263
+ _this._disableDelayedDragEvents();
1264
+ if (!FireFox && _this.nativeDraggable) {
1265
+ dragEl.draggable = true;
1266
+ }
1267
+
1268
+ // Bind the events: dragstart/dragend
1269
+ _this._triggerDragStart(evt, touch);
1270
+
1271
+ // Drag start event
1272
+ _dispatchEvent({
1273
+ sortable: _this,
1274
+ name: 'choose',
1275
+ originalEvent: evt
1276
+ });
1277
+
1278
+ // Chosen item
1279
+ toggleClass(dragEl, options.chosenClass, true);
1280
+ };
1281
+
1282
+ // Disable "draggable"
1283
+ options.ignore.split(',').forEach(function (criteria) {
1284
+ find(dragEl, criteria.trim(), _disableDraggable);
1285
+ });
1286
+ on(ownerDocument, 'dragover', nearestEmptyInsertDetectEvent);
1287
+ on(ownerDocument, 'mousemove', nearestEmptyInsertDetectEvent);
1288
+ on(ownerDocument, 'touchmove', nearestEmptyInsertDetectEvent);
1289
+ if (options.supportPointer) {
1290
+ on(ownerDocument, 'pointerup', _this._onDrop);
1291
+ // Native D&D triggers pointercancel
1292
+ !this.nativeDraggable && on(ownerDocument, 'pointercancel', _this._onDrop);
1293
+ } else {
1294
+ on(ownerDocument, 'mouseup', _this._onDrop);
1295
+ on(ownerDocument, 'touchend', _this._onDrop);
1296
+ on(ownerDocument, 'touchcancel', _this._onDrop);
1297
+ }
1298
+
1299
+ // Make dragEl draggable (must be before delay for FireFox)
1300
+ if (FireFox && this.nativeDraggable) {
1301
+ this.options.touchStartThreshold = 4;
1302
+ dragEl.draggable = true;
1303
+ }
1304
+ pluginEvent('delayStart', this, {
1305
+ evt: evt
1306
+ });
1307
+
1308
+ // Delay is impossible for native DnD in Edge or IE
1309
+ if (options.delay && (!options.delayOnTouchOnly || touch) && (!this.nativeDraggable || !(Edge || IE11OrLess))) {
1310
+ if (Sortable.eventCanceled) {
1311
+ this._onDrop();
1312
+ return;
1313
+ }
1314
+ // If the user moves the pointer or let go the click or touch
1315
+ // before the delay has been reached:
1316
+ // disable the delayed drag
1317
+ if (options.supportPointer) {
1318
+ on(ownerDocument, 'pointerup', _this._disableDelayedDrag);
1319
+ on(ownerDocument, 'pointercancel', _this._disableDelayedDrag);
1320
+ } else {
1321
+ on(ownerDocument, 'mouseup', _this._disableDelayedDrag);
1322
+ on(ownerDocument, 'touchend', _this._disableDelayedDrag);
1323
+ on(ownerDocument, 'touchcancel', _this._disableDelayedDrag);
1324
+ }
1325
+ on(ownerDocument, 'mousemove', _this._delayedDragTouchMoveHandler);
1326
+ on(ownerDocument, 'touchmove', _this._delayedDragTouchMoveHandler);
1327
+ options.supportPointer && on(ownerDocument, 'pointermove', _this._delayedDragTouchMoveHandler);
1328
+ _this._dragStartTimer = setTimeout(dragStartFn, options.delay);
1329
+ } else {
1330
+ dragStartFn();
1331
+ }
1332
+ }
1333
+ },
1334
+ _delayedDragTouchMoveHandler: function _delayedDragTouchMoveHandler( /** TouchEvent|PointerEvent **/e) {
1335
+ var touch = e.touches ? e.touches[0] : e;
1336
+ if (Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1))) {
1337
+ this._disableDelayedDrag();
1338
+ }
1339
+ },
1340
+ _disableDelayedDrag: function _disableDelayedDrag() {
1341
+ dragEl && _disableDraggable(dragEl);
1342
+ clearTimeout(this._dragStartTimer);
1343
+ this._disableDelayedDragEvents();
1344
+ },
1345
+ _disableDelayedDragEvents: function _disableDelayedDragEvents() {
1346
+ var ownerDocument = this.el.ownerDocument;
1347
+ off(ownerDocument, 'mouseup', this._disableDelayedDrag);
1348
+ off(ownerDocument, 'touchend', this._disableDelayedDrag);
1349
+ off(ownerDocument, 'touchcancel', this._disableDelayedDrag);
1350
+ off(ownerDocument, 'pointerup', this._disableDelayedDrag);
1351
+ off(ownerDocument, 'pointercancel', this._disableDelayedDrag);
1352
+ off(ownerDocument, 'mousemove', this._delayedDragTouchMoveHandler);
1353
+ off(ownerDocument, 'touchmove', this._delayedDragTouchMoveHandler);
1354
+ off(ownerDocument, 'pointermove', this._delayedDragTouchMoveHandler);
1355
+ },
1356
+ _triggerDragStart: function _triggerDragStart( /** Event */evt, /** Touch */touch) {
1357
+ touch = touch || evt.pointerType == 'touch' && evt;
1358
+ if (!this.nativeDraggable || touch) {
1359
+ if (this.options.supportPointer) {
1360
+ on(document, 'pointermove', this._onTouchMove);
1361
+ } else if (touch) {
1362
+ on(document, 'touchmove', this._onTouchMove);
1363
+ } else {
1364
+ on(document, 'mousemove', this._onTouchMove);
1365
+ }
1366
+ } else {
1367
+ on(dragEl, 'dragend', this);
1368
+ on(rootEl, 'dragstart', this._onDragStart);
1369
+ }
1370
+ try {
1371
+ if (document.selection) {
1372
+ _nextTick(function () {
1373
+ document.selection.empty();
1374
+ });
1375
+ } else {
1376
+ window.getSelection().removeAllRanges();
1377
+ }
1378
+ } catch (err) {}
1379
+ },
1380
+ _dragStarted: function _dragStarted(fallback, evt) {
1381
+ awaitingDragStarted = false;
1382
+ if (rootEl && dragEl) {
1383
+ pluginEvent('dragStarted', this, {
1384
+ evt: evt
1385
+ });
1386
+ if (this.nativeDraggable) {
1387
+ on(document, 'dragover', _checkOutsideTargetEl);
1388
+ }
1389
+ var options = this.options;
1390
+
1391
+ // Apply effect
1392
+ !fallback && toggleClass(dragEl, options.dragClass, false);
1393
+ toggleClass(dragEl, options.ghostClass, true);
1394
+ Sortable.active = this;
1395
+ fallback && this._appendGhost();
1396
+
1397
+ // Drag start event
1398
+ _dispatchEvent({
1399
+ sortable: this,
1400
+ name: 'start',
1401
+ originalEvent: evt
1402
+ });
1403
+ } else {
1404
+ this._nulling();
1405
+ }
1406
+ },
1407
+ _emulateDragOver: function _emulateDragOver() {
1408
+ if (touchEvt) {
1409
+ this._lastX = touchEvt.clientX;
1410
+ this._lastY = touchEvt.clientY;
1411
+ _hideGhostForTarget();
1412
+ var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1413
+ var parent = target;
1414
+ while (target && target.shadowRoot) {
1415
+ target = target.shadowRoot.elementFromPoint(touchEvt.clientX, touchEvt.clientY);
1416
+ if (target === parent) break;
1417
+ parent = target;
1418
+ }
1419
+ dragEl.parentNode[expando]._isOutsideThisEl(target);
1420
+ if (parent) {
1421
+ do {
1422
+ if (parent[expando]) {
1423
+ var inserted = void 0;
1424
+ inserted = parent[expando]._onDragOver({
1425
+ clientX: touchEvt.clientX,
1426
+ clientY: touchEvt.clientY,
1427
+ target: target,
1428
+ rootEl: parent
1429
+ });
1430
+ if (inserted && !this.options.dragoverBubble) {
1431
+ break;
1432
+ }
1433
+ }
1434
+ target = parent; // store last element
1435
+ }
1436
+ /* jshint boss:true */ while (parent = getParentOrHost(parent));
1437
+ }
1438
+ _unhideGhostForTarget();
1439
+ }
1440
+ },
1441
+ _onTouchMove: function _onTouchMove( /**TouchEvent*/evt) {
1442
+ if (tapEvt) {
1443
+ var options = this.options,
1444
+ fallbackTolerance = options.fallbackTolerance,
1445
+ fallbackOffset = options.fallbackOffset,
1446
+ touch = evt.touches ? evt.touches[0] : evt,
1447
+ ghostMatrix = ghostEl && matrix(ghostEl, true),
1448
+ scaleX = ghostEl && ghostMatrix && ghostMatrix.a,
1449
+ scaleY = ghostEl && ghostMatrix && ghostMatrix.d,
1450
+ relativeScrollOffset = PositionGhostAbsolutely && ghostRelativeParent && getRelativeScrollOffset(ghostRelativeParent),
1451
+ dx = (touch.clientX - tapEvt.clientX + fallbackOffset.x) / (scaleX || 1) + (relativeScrollOffset ? relativeScrollOffset[0] - ghostRelativeParentInitialScroll[0] : 0) / (scaleX || 1),
1452
+ dy = (touch.clientY - tapEvt.clientY + fallbackOffset.y) / (scaleY || 1) + (relativeScrollOffset ? relativeScrollOffset[1] - ghostRelativeParentInitialScroll[1] : 0) / (scaleY || 1);
1453
+
1454
+ // only set the status to dragging, when we are actually dragging
1455
+ if (!Sortable.active && !awaitingDragStarted) {
1456
+ if (fallbackTolerance && Math.max(Math.abs(touch.clientX - this._lastX), Math.abs(touch.clientY - this._lastY)) < fallbackTolerance) {
1457
+ return;
1458
+ }
1459
+ this._onDragStart(evt, true);
1460
+ }
1461
+ if (ghostEl) {
1462
+ if (ghostMatrix) {
1463
+ ghostMatrix.e += dx - (lastDx || 0);
1464
+ ghostMatrix.f += dy - (lastDy || 0);
1465
+ } else {
1466
+ ghostMatrix = {
1467
+ a: 1,
1468
+ b: 0,
1469
+ c: 0,
1470
+ d: 1,
1471
+ e: dx,
1472
+ f: dy
1473
+ };
1474
+ }
1475
+ var cssMatrix = "matrix(".concat(ghostMatrix.a, ",").concat(ghostMatrix.b, ",").concat(ghostMatrix.c, ",").concat(ghostMatrix.d, ",").concat(ghostMatrix.e, ",").concat(ghostMatrix.f, ")");
1476
+ css(ghostEl, 'webkitTransform', cssMatrix);
1477
+ css(ghostEl, 'mozTransform', cssMatrix);
1478
+ css(ghostEl, 'msTransform', cssMatrix);
1479
+ css(ghostEl, 'transform', cssMatrix);
1480
+ lastDx = dx;
1481
+ lastDy = dy;
1482
+ touchEvt = touch;
1483
+ }
1484
+ evt.cancelable && evt.preventDefault();
1485
+ }
1486
+ },
1487
+ _appendGhost: function _appendGhost() {
1488
+ // Bug if using scale(): https://stackoverflow.com/questions/2637058
1489
+ // Not being adjusted for
1490
+ if (!ghostEl) {
1491
+ var container = this.options.fallbackOnBody ? document.body : rootEl,
1492
+ rect = getRect(dragEl, true, PositionGhostAbsolutely, true, container),
1493
+ options = this.options;
1494
+
1495
+ // Position absolutely
1496
+ if (PositionGhostAbsolutely) {
1497
+ // Get relatively positioned parent
1498
+ ghostRelativeParent = container;
1499
+ while (css(ghostRelativeParent, 'position') === 'static' && css(ghostRelativeParent, 'transform') === 'none' && ghostRelativeParent !== document) {
1500
+ ghostRelativeParent = ghostRelativeParent.parentNode;
1501
+ }
1502
+ if (ghostRelativeParent !== document.body && ghostRelativeParent !== document.documentElement) {
1503
+ if (ghostRelativeParent === document) ghostRelativeParent = getWindowScrollingElement();
1504
+ rect.top += ghostRelativeParent.scrollTop;
1505
+ rect.left += ghostRelativeParent.scrollLeft;
1506
+ } else {
1507
+ ghostRelativeParent = getWindowScrollingElement();
1508
+ }
1509
+ ghostRelativeParentInitialScroll = getRelativeScrollOffset(ghostRelativeParent);
1510
+ }
1511
+ ghostEl = dragEl.cloneNode(true);
1512
+ toggleClass(ghostEl, options.ghostClass, false);
1513
+ toggleClass(ghostEl, options.fallbackClass, true);
1514
+ toggleClass(ghostEl, options.dragClass, true);
1515
+ css(ghostEl, 'transition', '');
1516
+ css(ghostEl, 'transform', '');
1517
+ css(ghostEl, 'box-sizing', 'border-box');
1518
+ css(ghostEl, 'margin', 0);
1519
+ css(ghostEl, 'top', rect.top);
1520
+ css(ghostEl, 'left', rect.left);
1521
+ css(ghostEl, 'width', rect.width);
1522
+ css(ghostEl, 'height', rect.height);
1523
+ css(ghostEl, 'opacity', '0.8');
1524
+ css(ghostEl, 'position', PositionGhostAbsolutely ? 'absolute' : 'fixed');
1525
+ css(ghostEl, 'zIndex', '100000');
1526
+ css(ghostEl, 'pointerEvents', 'none');
1527
+ Sortable.ghost = ghostEl;
1528
+ container.appendChild(ghostEl);
1529
+
1530
+ // Set transform-origin
1531
+ css(ghostEl, 'transform-origin', tapDistanceLeft / parseInt(ghostEl.style.width) * 100 + '% ' + tapDistanceTop / parseInt(ghostEl.style.height) * 100 + '%');
1532
+ }
1533
+ },
1534
+ _onDragStart: function _onDragStart( /**Event*/evt, /**boolean*/fallback) {
1535
+ var _this = this;
1536
+ var dataTransfer = evt.dataTransfer;
1537
+ var options = _this.options;
1538
+ pluginEvent('dragStart', this, {
1539
+ evt: evt
1540
+ });
1541
+ if (Sortable.eventCanceled) {
1542
+ this._onDrop();
1543
+ return;
1544
+ }
1545
+ pluginEvent('setupClone', this);
1546
+ if (!Sortable.eventCanceled) {
1547
+ cloneEl = clone(dragEl);
1548
+ cloneEl.removeAttribute("id");
1549
+ cloneEl.draggable = false;
1550
+ cloneEl.style['will-change'] = '';
1551
+ this._hideClone();
1552
+ toggleClass(cloneEl, this.options.chosenClass, false);
1553
+ Sortable.clone = cloneEl;
1554
+ }
1555
+
1556
+ // #1143: IFrame support workaround
1557
+ _this.cloneId = _nextTick(function () {
1558
+ pluginEvent('clone', _this);
1559
+ if (Sortable.eventCanceled) return;
1560
+ if (!_this.options.removeCloneOnHide) {
1561
+ rootEl.insertBefore(cloneEl, dragEl);
1562
+ }
1563
+ _this._hideClone();
1564
+ _dispatchEvent({
1565
+ sortable: _this,
1566
+ name: 'clone'
1567
+ });
1568
+ });
1569
+ !fallback && toggleClass(dragEl, options.dragClass, true);
1570
+
1571
+ // Set proper drop events
1572
+ if (fallback) {
1573
+ ignoreNextClick = true;
1574
+ _this._loopId = setInterval(_this._emulateDragOver, 50);
1575
+ } else {
1576
+ // Undo what was set in _prepareDragStart before drag started
1577
+ off(document, 'mouseup', _this._onDrop);
1578
+ off(document, 'touchend', _this._onDrop);
1579
+ off(document, 'touchcancel', _this._onDrop);
1580
+ if (dataTransfer) {
1581
+ dataTransfer.effectAllowed = 'move';
1582
+ options.setData && options.setData.call(_this, dataTransfer, dragEl);
1583
+ }
1584
+ on(document, 'drop', _this);
1585
+
1586
+ // #1276 fix:
1587
+ css(dragEl, 'transform', 'translateZ(0)');
1588
+ }
1589
+ awaitingDragStarted = true;
1590
+ _this._dragStartId = _nextTick(_this._dragStarted.bind(_this, fallback, evt));
1591
+ on(document, 'selectstart', _this);
1592
+ moved = true;
1593
+ window.getSelection().removeAllRanges();
1594
+ if (Safari) {
1595
+ css(document.body, 'user-select', 'none');
1596
+ }
1597
+ },
1598
+ // Returns true - if no further action is needed (either inserted or another condition)
1599
+ _onDragOver: function _onDragOver( /**Event*/evt) {
1600
+ var el = this.el,
1601
+ target = evt.target,
1602
+ dragRect,
1603
+ targetRect,
1604
+ revert,
1605
+ options = this.options,
1606
+ group = options.group,
1607
+ activeSortable = Sortable.active,
1608
+ isOwner = activeGroup === group,
1609
+ canSort = options.sort,
1610
+ fromSortable = putSortable || activeSortable,
1611
+ vertical,
1612
+ _this = this,
1613
+ completedFired = false;
1614
+ if (_silent) return;
1615
+ function dragOverEvent(name, extra) {
1616
+ pluginEvent(name, _this, _objectSpread2({
1617
+ evt: evt,
1618
+ isOwner: isOwner,
1619
+ axis: vertical ? 'vertical' : 'horizontal',
1620
+ revert: revert,
1621
+ dragRect: dragRect,
1622
+ targetRect: targetRect,
1623
+ canSort: canSort,
1624
+ fromSortable: fromSortable,
1625
+ target: target,
1626
+ completed: completed,
1627
+ onMove: function onMove(target, after) {
1628
+ return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
1629
+ },
1630
+ changed: changed
1631
+ }, extra));
1632
+ }
1633
+
1634
+ // Capture animation state
1635
+ function capture() {
1636
+ dragOverEvent('dragOverAnimationCapture');
1637
+ _this.captureAnimationState();
1638
+ if (_this !== fromSortable) {
1639
+ fromSortable.captureAnimationState();
1640
+ }
1641
+ }
1642
+
1643
+ // Return invocation when dragEl is inserted (or completed)
1644
+ function completed(insertion) {
1645
+ dragOverEvent('dragOverCompleted', {
1646
+ insertion: insertion
1647
+ });
1648
+ if (insertion) {
1649
+ // Clones must be hidden before folding animation to capture dragRectAbsolute properly
1650
+ if (isOwner) {
1651
+ activeSortable._hideClone();
1652
+ } else {
1653
+ activeSortable._showClone(_this);
1654
+ }
1655
+ if (_this !== fromSortable) {
1656
+ // Set ghost class to new sortable's ghost class
1657
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : activeSortable.options.ghostClass, false);
1658
+ toggleClass(dragEl, options.ghostClass, true);
1659
+ }
1660
+ if (putSortable !== _this && _this !== Sortable.active) {
1661
+ putSortable = _this;
1662
+ } else if (_this === Sortable.active && putSortable) {
1663
+ putSortable = null;
1664
+ }
1665
+
1666
+ // Animation
1667
+ if (fromSortable === _this) {
1668
+ _this._ignoreWhileAnimating = target;
1669
+ }
1670
+ _this.animateAll(function () {
1671
+ dragOverEvent('dragOverAnimationComplete');
1672
+ _this._ignoreWhileAnimating = null;
1673
+ });
1674
+ if (_this !== fromSortable) {
1675
+ fromSortable.animateAll();
1676
+ fromSortable._ignoreWhileAnimating = null;
1677
+ }
1678
+ }
1679
+
1680
+ // Null lastTarget if it is not inside a previously swapped element
1681
+ if (target === dragEl && !dragEl.animated || target === el && !target.animated) {
1682
+ lastTarget = null;
1683
+ }
1684
+
1685
+ // no bubbling and not fallback
1686
+ if (!options.dragoverBubble && !evt.rootEl && target !== document) {
1687
+ dragEl.parentNode[expando]._isOutsideThisEl(evt.target);
1688
+
1689
+ // Do not detect for empty insert if already inserted
1690
+ !insertion && nearestEmptyInsertDetectEvent(evt);
1691
+ }
1692
+ !options.dragoverBubble && evt.stopPropagation && evt.stopPropagation();
1693
+ return completedFired = true;
1694
+ }
1695
+
1696
+ // Call when dragEl has been inserted
1697
+ function changed() {
1698
+ newIndex = index(dragEl);
1699
+ newDraggableIndex = index(dragEl, options.draggable);
1700
+ _dispatchEvent({
1701
+ sortable: _this,
1702
+ name: 'change',
1703
+ toEl: el,
1704
+ newIndex: newIndex,
1705
+ newDraggableIndex: newDraggableIndex,
1706
+ originalEvent: evt
1707
+ });
1708
+ }
1709
+ if (evt.preventDefault !== void 0) {
1710
+ evt.cancelable && evt.preventDefault();
1711
+ }
1712
+ target = closest(target, options.draggable, el, true);
1713
+ dragOverEvent('dragOver');
1714
+ if (Sortable.eventCanceled) return completedFired;
1715
+ if (dragEl.contains(evt.target) || target.animated && target.animatingX && target.animatingY || _this._ignoreWhileAnimating === target) {
1716
+ return completed(false);
1717
+ }
1718
+ ignoreNextClick = false;
1719
+ if (activeSortable && !options.disabled && (isOwner ? canSort || (revert = parentEl !== rootEl) // Reverting item into the original list
1720
+ : putSortable === this || (this.lastPutMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && group.checkPut(this, activeSortable, dragEl, evt))) {
1721
+ vertical = this._getDirection(evt, target) === 'vertical';
1722
+ dragRect = getRect(dragEl);
1723
+ dragOverEvent('dragOverValid');
1724
+ if (Sortable.eventCanceled) return completedFired;
1725
+ if (revert) {
1726
+ parentEl = rootEl; // actualization
1727
+ capture();
1728
+ this._hideClone();
1729
+ dragOverEvent('revert');
1730
+ if (!Sortable.eventCanceled) {
1731
+ if (nextEl) {
1732
+ rootEl.insertBefore(dragEl, nextEl);
1733
+ } else {
1734
+ rootEl.appendChild(dragEl);
1735
+ }
1736
+ }
1737
+ return completed(true);
1738
+ }
1739
+ var elLastChild = lastChild(el, options.draggable);
1740
+ if (!elLastChild || _ghostIsLast(evt, vertical, this) && !elLastChild.animated) {
1741
+ // Insert to end of list
1742
+
1743
+ // If already at end of list: Do not insert
1744
+ if (elLastChild === dragEl) {
1745
+ return completed(false);
1746
+ }
1747
+
1748
+ // if there is a last element, it is the target
1749
+ if (elLastChild && el === evt.target) {
1750
+ target = elLastChild;
1751
+ }
1752
+ if (target) {
1753
+ targetRect = getRect(target);
1754
+ }
1755
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, !!target) !== false) {
1756
+ capture();
1757
+ if (elLastChild && elLastChild.nextSibling) {
1758
+ // the last draggable element is not the last node
1759
+ el.insertBefore(dragEl, elLastChild.nextSibling);
1760
+ } else {
1761
+ el.appendChild(dragEl);
1762
+ }
1763
+ parentEl = el; // actualization
1764
+
1765
+ changed();
1766
+ return completed(true);
1767
+ }
1768
+ } else if (elLastChild && _ghostIsFirst(evt, vertical, this)) {
1769
+ // Insert to start of list
1770
+ var firstChild = getChild(el, 0, options, true);
1771
+ if (firstChild === dragEl) {
1772
+ return completed(false);
1773
+ }
1774
+ target = firstChild;
1775
+ targetRect = getRect(target);
1776
+ if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, false) !== false) {
1777
+ capture();
1778
+ el.insertBefore(dragEl, firstChild);
1779
+ parentEl = el; // actualization
1780
+
1781
+ changed();
1782
+ return completed(true);
1783
+ }
1784
+ } else if (target.parentNode === el) {
1785
+ targetRect = getRect(target);
1786
+ var direction = 0,
1787
+ targetBeforeFirstSwap,
1788
+ differentLevel = dragEl.parentNode !== el,
1789
+ differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
1790
+ side1 = vertical ? 'top' : 'left',
1791
+ scrolledPastTop = isScrolledPast(target, 'top', 'top') || isScrolledPast(dragEl, 'top', 'top'),
1792
+ scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
1793
+ if (lastTarget !== target) {
1794
+ targetBeforeFirstSwap = targetRect[side1];
1795
+ pastFirstInvertThresh = false;
1796
+ isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
1797
+ }
1798
+ direction = _getSwapDirection(evt, target, targetRect, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
1799
+ var sibling;
1800
+ if (direction !== 0) {
1801
+ // Check if target is beside dragEl in respective direction (ignoring hidden elements)
1802
+ var dragIndex = index(dragEl);
1803
+ do {
1804
+ dragIndex -= direction;
1805
+ sibling = parentEl.children[dragIndex];
1806
+ } while (sibling && (css(sibling, 'display') === 'none' || sibling === ghostEl));
1807
+ }
1808
+ // If dragEl is already beside target: Do not insert
1809
+ if (direction === 0 || sibling === target) {
1810
+ return completed(false);
1811
+ }
1812
+ lastTarget = target;
1813
+ lastDirection = direction;
1814
+ var nextSibling = target.nextElementSibling,
1815
+ after = false;
1816
+ after = direction === 1;
1817
+ var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after);
1818
+ if (moveVector !== false) {
1819
+ if (moveVector === 1 || moveVector === -1) {
1820
+ after = moveVector === 1;
1821
+ }
1822
+ _silent = true;
1823
+ setTimeout(_unsilent, 30);
1824
+ capture();
1825
+ if (after && !nextSibling) {
1826
+ el.appendChild(dragEl);
1827
+ } else {
1828
+ target.parentNode.insertBefore(dragEl, after ? nextSibling : target);
1829
+ }
1830
+
1831
+ // Undo chrome's scroll adjustment (has no effect on other browsers)
1832
+ if (scrolledPastTop) {
1833
+ scrollBy(scrolledPastTop, 0, scrollBefore - scrolledPastTop.scrollTop);
1834
+ }
1835
+ parentEl = dragEl.parentNode; // actualization
1836
+
1837
+ // must be done before animation
1838
+ if (targetBeforeFirstSwap !== undefined && !isCircumstantialInvert) {
1839
+ targetMoveDistance = Math.abs(targetBeforeFirstSwap - getRect(target)[side1]);
1840
+ }
1841
+ changed();
1842
+ return completed(true);
1843
+ }
1844
+ }
1845
+ if (el.contains(dragEl)) {
1846
+ return completed(false);
1847
+ }
1848
+ }
1849
+ return false;
1850
+ },
1851
+ _ignoreWhileAnimating: null,
1852
+ _offMoveEvents: function _offMoveEvents() {
1853
+ off(document, 'mousemove', this._onTouchMove);
1854
+ off(document, 'touchmove', this._onTouchMove);
1855
+ off(document, 'pointermove', this._onTouchMove);
1856
+ off(document, 'dragover', nearestEmptyInsertDetectEvent);
1857
+ off(document, 'mousemove', nearestEmptyInsertDetectEvent);
1858
+ off(document, 'touchmove', nearestEmptyInsertDetectEvent);
1859
+ },
1860
+ _offUpEvents: function _offUpEvents() {
1861
+ var ownerDocument = this.el.ownerDocument;
1862
+ off(ownerDocument, 'mouseup', this._onDrop);
1863
+ off(ownerDocument, 'touchend', this._onDrop);
1864
+ off(ownerDocument, 'pointerup', this._onDrop);
1865
+ off(ownerDocument, 'pointercancel', this._onDrop);
1866
+ off(ownerDocument, 'touchcancel', this._onDrop);
1867
+ off(document, 'selectstart', this);
1868
+ },
1869
+ _onDrop: function _onDrop( /**Event*/evt) {
1870
+ var el = this.el,
1871
+ options = this.options;
1872
+
1873
+ // Get the index of the dragged element within its parent
1874
+ newIndex = index(dragEl);
1875
+ newDraggableIndex = index(dragEl, options.draggable);
1876
+ pluginEvent('drop', this, {
1877
+ evt: evt
1878
+ });
1879
+ parentEl = dragEl && dragEl.parentNode;
1880
+
1881
+ // Get again after plugin event
1882
+ newIndex = index(dragEl);
1883
+ newDraggableIndex = index(dragEl, options.draggable);
1884
+ if (Sortable.eventCanceled) {
1885
+ this._nulling();
1886
+ return;
1887
+ }
1888
+ awaitingDragStarted = false;
1889
+ isCircumstantialInvert = false;
1890
+ pastFirstInvertThresh = false;
1891
+ clearInterval(this._loopId);
1892
+ clearTimeout(this._dragStartTimer);
1893
+ _cancelNextTick(this.cloneId);
1894
+ _cancelNextTick(this._dragStartId);
1895
+
1896
+ // Unbind events
1897
+ if (this.nativeDraggable) {
1898
+ off(document, 'drop', this);
1899
+ off(el, 'dragstart', this._onDragStart);
1900
+ }
1901
+ this._offMoveEvents();
1902
+ this._offUpEvents();
1903
+ if (Safari) {
1904
+ css(document.body, 'user-select', '');
1905
+ }
1906
+ css(dragEl, 'transform', '');
1907
+ if (evt) {
1908
+ if (moved) {
1909
+ evt.cancelable && evt.preventDefault();
1910
+ !options.dropBubble && evt.stopPropagation();
1911
+ }
1912
+ ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl);
1913
+ if (rootEl === parentEl || putSortable && putSortable.lastPutMode !== 'clone') {
1914
+ // Remove clone(s)
1915
+ cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl);
1916
+ }
1917
+ if (dragEl) {
1918
+ if (this.nativeDraggable) {
1919
+ off(dragEl, 'dragend', this);
1920
+ }
1921
+ _disableDraggable(dragEl);
1922
+ dragEl.style['will-change'] = '';
1923
+
1924
+ // Remove classes
1925
+ // ghostClass is added in dragStarted
1926
+ if (moved && !awaitingDragStarted) {
1927
+ toggleClass(dragEl, putSortable ? putSortable.options.ghostClass : this.options.ghostClass, false);
1928
+ }
1929
+ toggleClass(dragEl, this.options.chosenClass, false);
1930
+
1931
+ // Drag stop event
1932
+ _dispatchEvent({
1933
+ sortable: this,
1934
+ name: 'unchoose',
1935
+ toEl: parentEl,
1936
+ newIndex: null,
1937
+ newDraggableIndex: null,
1938
+ originalEvent: evt
1939
+ });
1940
+ if (rootEl !== parentEl) {
1941
+ if (newIndex >= 0) {
1942
+ // Add event
1943
+ _dispatchEvent({
1944
+ rootEl: parentEl,
1945
+ name: 'add',
1946
+ toEl: parentEl,
1947
+ fromEl: rootEl,
1948
+ originalEvent: evt
1949
+ });
1950
+
1951
+ // Remove event
1952
+ _dispatchEvent({
1953
+ sortable: this,
1954
+ name: 'remove',
1955
+ toEl: parentEl,
1956
+ originalEvent: evt
1957
+ });
1958
+
1959
+ // drag from one list and drop into another
1960
+ _dispatchEvent({
1961
+ rootEl: parentEl,
1962
+ name: 'sort',
1963
+ toEl: parentEl,
1964
+ fromEl: rootEl,
1965
+ originalEvent: evt
1966
+ });
1967
+ _dispatchEvent({
1968
+ sortable: this,
1969
+ name: 'sort',
1970
+ toEl: parentEl,
1971
+ originalEvent: evt
1972
+ });
1973
+ }
1974
+ putSortable && putSortable.save();
1975
+ } else {
1976
+ if (newIndex !== oldIndex) {
1977
+ if (newIndex >= 0) {
1978
+ // drag & drop within the same list
1979
+ _dispatchEvent({
1980
+ sortable: this,
1981
+ name: 'update',
1982
+ toEl: parentEl,
1983
+ originalEvent: evt
1984
+ });
1985
+ _dispatchEvent({
1986
+ sortable: this,
1987
+ name: 'sort',
1988
+ toEl: parentEl,
1989
+ originalEvent: evt
1990
+ });
1991
+ }
1992
+ }
1993
+ }
1994
+ if (Sortable.active) {
1995
+ /* jshint eqnull:true */
1996
+ if (newIndex == null || newIndex === -1) {
1997
+ newIndex = oldIndex;
1998
+ newDraggableIndex = oldDraggableIndex;
1999
+ }
2000
+ _dispatchEvent({
2001
+ sortable: this,
2002
+ name: 'end',
2003
+ toEl: parentEl,
2004
+ originalEvent: evt
2005
+ });
2006
+
2007
+ // Save sorting
2008
+ this.save();
2009
+ }
2010
+ }
2011
+ }
2012
+ this._nulling();
2013
+ },
2014
+ _nulling: function _nulling() {
2015
+ pluginEvent('nulling', this);
2016
+ rootEl = dragEl = parentEl = ghostEl = nextEl = cloneEl = lastDownEl = cloneHidden = tapEvt = touchEvt = moved = newIndex = newDraggableIndex = oldIndex = oldDraggableIndex = lastTarget = lastDirection = putSortable = activeGroup = Sortable.dragged = Sortable.ghost = Sortable.clone = Sortable.active = null;
2017
+ savedInputChecked.forEach(function (el) {
2018
+ el.checked = true;
2019
+ });
2020
+ savedInputChecked.length = lastDx = lastDy = 0;
2021
+ },
2022
+ handleEvent: function handleEvent( /**Event*/evt) {
2023
+ switch (evt.type) {
2024
+ case 'drop':
2025
+ case 'dragend':
2026
+ this._onDrop(evt);
2027
+ break;
2028
+ case 'dragenter':
2029
+ case 'dragover':
2030
+ if (dragEl) {
2031
+ this._onDragOver(evt);
2032
+ _globalDragOver(evt);
2033
+ }
2034
+ break;
2035
+ case 'selectstart':
2036
+ evt.preventDefault();
2037
+ break;
2038
+ }
2039
+ },
2040
+ /**
2041
+ * Serializes the item into an array of string.
2042
+ * @returns {String[]}
2043
+ */
2044
+ toArray: function toArray() {
2045
+ var order = [],
2046
+ el,
2047
+ children = this.el.children,
2048
+ i = 0,
2049
+ n = children.length,
2050
+ options = this.options;
2051
+ for (; i < n; i++) {
2052
+ el = children[i];
2053
+ if (closest(el, options.draggable, this.el, false)) {
2054
+ order.push(el.getAttribute(options.dataIdAttr) || _generateId(el));
2055
+ }
2056
+ }
2057
+ return order;
2058
+ },
2059
+ /**
2060
+ * Sorts the elements according to the array.
2061
+ * @param {String[]} order order of the items
2062
+ */
2063
+ sort: function sort(order, useAnimation) {
2064
+ var items = {},
2065
+ rootEl = this.el;
2066
+ this.toArray().forEach(function (id, i) {
2067
+ var el = rootEl.children[i];
2068
+ if (closest(el, this.options.draggable, rootEl, false)) {
2069
+ items[id] = el;
2070
+ }
2071
+ }, this);
2072
+ useAnimation && this.captureAnimationState();
2073
+ order.forEach(function (id) {
2074
+ if (items[id]) {
2075
+ rootEl.removeChild(items[id]);
2076
+ rootEl.appendChild(items[id]);
2077
+ }
2078
+ });
2079
+ useAnimation && this.animateAll();
2080
+ },
2081
+ /**
2082
+ * Save the current sorting
2083
+ */
2084
+ save: function save() {
2085
+ var store = this.options.store;
2086
+ store && store.set && store.set(this);
2087
+ },
2088
+ /**
2089
+ * For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
2090
+ * @param {HTMLElement} el
2091
+ * @param {String} [selector] default: `options.draggable`
2092
+ * @returns {HTMLElement|null}
2093
+ */
2094
+ closest: function closest$1(el, selector) {
2095
+ return closest(el, selector || this.options.draggable, this.el, false);
2096
+ },
2097
+ /**
2098
+ * Set/get option
2099
+ * @param {string} name
2100
+ * @param {*} [value]
2101
+ * @returns {*}
2102
+ */
2103
+ option: function option(name, value) {
2104
+ var options = this.options;
2105
+ if (value === void 0) {
2106
+ return options[name];
2107
+ } else {
2108
+ var modifiedValue = PluginManager.modifyOption(this, name, value);
2109
+ if (typeof modifiedValue !== 'undefined') {
2110
+ options[name] = modifiedValue;
2111
+ } else {
2112
+ options[name] = value;
2113
+ }
2114
+ if (name === 'group') {
2115
+ _prepareGroup(options);
2116
+ }
2117
+ }
2118
+ },
2119
+ /**
2120
+ * Destroy
2121
+ */
2122
+ destroy: function destroy() {
2123
+ pluginEvent('destroy', this);
2124
+ var el = this.el;
2125
+ el[expando] = null;
2126
+ off(el, 'mousedown', this._onTapStart);
2127
+ off(el, 'touchstart', this._onTapStart);
2128
+ off(el, 'pointerdown', this._onTapStart);
2129
+ if (this.nativeDraggable) {
2130
+ off(el, 'dragover', this);
2131
+ off(el, 'dragenter', this);
2132
+ }
2133
+ // Remove draggable attributes
2134
+ Array.prototype.forEach.call(el.querySelectorAll('[draggable]'), function (el) {
2135
+ el.removeAttribute('draggable');
2136
+ });
2137
+ this._onDrop();
2138
+ this._disableDelayedDragEvents();
2139
+ sortables.splice(sortables.indexOf(this.el), 1);
2140
+ this.el = el = null;
2141
+ },
2142
+ _hideClone: function _hideClone() {
2143
+ if (!cloneHidden) {
2144
+ pluginEvent('hideClone', this);
2145
+ if (Sortable.eventCanceled) return;
2146
+ css(cloneEl, 'display', 'none');
2147
+ if (this.options.removeCloneOnHide && cloneEl.parentNode) {
2148
+ cloneEl.parentNode.removeChild(cloneEl);
2149
+ }
2150
+ cloneHidden = true;
2151
+ }
2152
+ },
2153
+ _showClone: function _showClone(putSortable) {
2154
+ if (putSortable.lastPutMode !== 'clone') {
2155
+ this._hideClone();
2156
+ return;
2157
+ }
2158
+ if (cloneHidden) {
2159
+ pluginEvent('showClone', this);
2160
+ if (Sortable.eventCanceled) return;
2161
+
2162
+ // show clone at dragEl or original position
2163
+ if (dragEl.parentNode == rootEl && !this.options.group.revertClone) {
2164
+ rootEl.insertBefore(cloneEl, dragEl);
2165
+ } else if (nextEl) {
2166
+ rootEl.insertBefore(cloneEl, nextEl);
2167
+ } else {
2168
+ rootEl.appendChild(cloneEl);
2169
+ }
2170
+ if (this.options.group.revertClone) {
2171
+ this.animate(dragEl, cloneEl);
2172
+ }
2173
+ css(cloneEl, 'display', '');
2174
+ cloneHidden = false;
2175
+ }
2176
+ }
2177
+ };
2178
+ function _globalDragOver( /**Event*/evt) {
2179
+ if (evt.dataTransfer) {
2180
+ evt.dataTransfer.dropEffect = 'move';
2181
+ }
2182
+ evt.cancelable && evt.preventDefault();
2183
+ }
2184
+ function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvent, willInsertAfter) {
2185
+ var evt,
2186
+ sortable = fromEl[expando],
2187
+ onMoveFn = sortable.options.onMove,
2188
+ retVal;
2189
+ // Support for new CustomEvent feature
2190
+ if (window.CustomEvent && !IE11OrLess && !Edge) {
2191
+ evt = new CustomEvent('move', {
2192
+ bubbles: true,
2193
+ cancelable: true
2194
+ });
2195
+ } else {
2196
+ evt = document.createEvent('Event');
2197
+ evt.initEvent('move', true, true);
2198
+ }
2199
+ evt.to = toEl;
2200
+ evt.from = fromEl;
2201
+ evt.dragged = dragEl;
2202
+ evt.draggedRect = dragRect;
2203
+ evt.related = targetEl || toEl;
2204
+ evt.relatedRect = targetRect || getRect(toEl);
2205
+ evt.willInsertAfter = willInsertAfter;
2206
+ evt.originalEvent = originalEvent;
2207
+ fromEl.dispatchEvent(evt);
2208
+ if (onMoveFn) {
2209
+ retVal = onMoveFn.call(sortable, evt, originalEvent);
2210
+ }
2211
+ return retVal;
2212
+ }
2213
+ function _disableDraggable(el) {
2214
+ el.draggable = false;
2215
+ }
2216
+ function _unsilent() {
2217
+ _silent = false;
2218
+ }
2219
+ function _ghostIsFirst(evt, vertical, sortable) {
2220
+ var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
2221
+ var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
2222
+ var spacer = 10;
2223
+ return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
2224
+ }
2225
+ function _ghostIsLast(evt, vertical, sortable) {
2226
+ var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
2227
+ var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
2228
+ var spacer = 10;
2229
+ return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
2230
+ }
2231
+ function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
2232
+ var mouseOnAxis = vertical ? evt.clientY : evt.clientX,
2233
+ targetLength = vertical ? targetRect.height : targetRect.width,
2234
+ targetS1 = vertical ? targetRect.top : targetRect.left,
2235
+ targetS2 = vertical ? targetRect.bottom : targetRect.right,
2236
+ invert = false;
2237
+ if (!invertSwap) {
2238
+ // Never invert or create dragEl shadow when target movemenet causes mouse to move past the end of regular swapThreshold
2239
+ if (isLastTarget && targetMoveDistance < targetLength * swapThreshold) {
2240
+ // multiplied only by swapThreshold because mouse will already be inside target by (1 - threshold) * targetLength / 2
2241
+ // check if past first invert threshold on side opposite of lastDirection
2242
+ if (!pastFirstInvertThresh && (lastDirection === 1 ? mouseOnAxis > targetS1 + targetLength * invertedSwapThreshold / 2 : mouseOnAxis < targetS2 - targetLength * invertedSwapThreshold / 2)) {
2243
+ // past first invert threshold, do not restrict inverted threshold to dragEl shadow
2244
+ pastFirstInvertThresh = true;
2245
+ }
2246
+ if (!pastFirstInvertThresh) {
2247
+ // dragEl shadow (target move distance shadow)
2248
+ if (lastDirection === 1 ? mouseOnAxis < targetS1 + targetMoveDistance // over dragEl shadow
2249
+ : mouseOnAxis > targetS2 - targetMoveDistance) {
2250
+ return -lastDirection;
2251
+ }
2252
+ } else {
2253
+ invert = true;
2254
+ }
2255
+ } else {
2256
+ // Regular
2257
+ if (mouseOnAxis > targetS1 + targetLength * (1 - swapThreshold) / 2 && mouseOnAxis < targetS2 - targetLength * (1 - swapThreshold) / 2) {
2258
+ return _getInsertDirection(target);
2259
+ }
2260
+ }
2261
+ }
2262
+ invert = invert || invertSwap;
2263
+ if (invert) {
2264
+ // Invert of regular
2265
+ if (mouseOnAxis < targetS1 + targetLength * invertedSwapThreshold / 2 || mouseOnAxis > targetS2 - targetLength * invertedSwapThreshold / 2) {
2266
+ return mouseOnAxis > targetS1 + targetLength / 2 ? 1 : -1;
2267
+ }
2268
+ }
2269
+ return 0;
2270
+ }
2271
+
2272
+ /**
2273
+ * Gets the direction dragEl must be swapped relative to target in order to make it
2274
+ * seem that dragEl has been "inserted" into that element's position
2275
+ * @param {HTMLElement} target The target whose position dragEl is being inserted at
2276
+ * @return {Number} Direction dragEl must be swapped
2277
+ */
2278
+ function _getInsertDirection(target) {
2279
+ if (index(dragEl) < index(target)) {
2280
+ return 1;
2281
+ } else {
2282
+ return -1;
2283
+ }
2284
+ }
2285
+
2286
+ /**
2287
+ * Generate id
2288
+ * @param {HTMLElement} el
2289
+ * @returns {String}
2290
+ * @private
2291
+ */
2292
+ function _generateId(el) {
2293
+ var str = el.tagName + el.className + el.src + el.href + el.textContent,
2294
+ i = str.length,
2295
+ sum = 0;
2296
+ while (i--) {
2297
+ sum += str.charCodeAt(i);
2298
+ }
2299
+ return sum.toString(36);
2300
+ }
2301
+ function _saveInputCheckedState(root) {
2302
+ savedInputChecked.length = 0;
2303
+ var inputs = root.getElementsByTagName('input');
2304
+ var idx = inputs.length;
2305
+ while (idx--) {
2306
+ var el = inputs[idx];
2307
+ el.checked && savedInputChecked.push(el);
2308
+ }
2309
+ }
2310
+ function _nextTick(fn) {
2311
+ return setTimeout(fn, 0);
2312
+ }
2313
+ function _cancelNextTick(id) {
2314
+ return clearTimeout(id);
2315
+ }
2316
+
2317
+ // Fixed #973:
2318
+ if (documentExists) {
2319
+ on(document, 'touchmove', function (evt) {
2320
+ if ((Sortable.active || awaitingDragStarted) && evt.cancelable) {
2321
+ evt.preventDefault();
2322
+ }
2323
+ });
2324
+ }
2325
+
2326
+ // Export utils
2327
+ Sortable.utils = {
2328
+ on: on,
2329
+ off: off,
2330
+ css: css,
2331
+ find: find,
2332
+ is: function is(el, selector) {
2333
+ return !!closest(el, selector, el, false);
2334
+ },
2335
+ extend: extend,
2336
+ throttle: throttle,
2337
+ closest: closest,
2338
+ toggleClass: toggleClass,
2339
+ clone: clone,
2340
+ index: index,
2341
+ nextTick: _nextTick,
2342
+ cancelNextTick: _cancelNextTick,
2343
+ detectDirection: _detectDirection,
2344
+ getChild: getChild,
2345
+ expando: expando
2346
+ };
2347
+
2348
+ /**
2349
+ * Get the Sortable instance of an element
2350
+ * @param {HTMLElement} element The element
2351
+ * @return {Sortable|undefined} The instance of Sortable
2352
+ */
2353
+ Sortable.get = function (element) {
2354
+ return element[expando];
2355
+ };
2356
+
2357
+ /**
2358
+ * Mount a plugin to Sortable
2359
+ * @param {...SortablePlugin|SortablePlugin[]} plugins Plugins being mounted
2360
+ */
2361
+ Sortable.mount = function () {
2362
+ for (var _len = arguments.length, plugins = new Array(_len), _key = 0; _key < _len; _key++) {
2363
+ plugins[_key] = arguments[_key];
2364
+ }
2365
+ if (plugins[0].constructor === Array) plugins = plugins[0];
2366
+ plugins.forEach(function (plugin) {
2367
+ if (!plugin.prototype || !plugin.prototype.constructor) {
2368
+ throw "Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(plugin));
2369
+ }
2370
+ if (plugin.utils) Sortable.utils = _objectSpread2(_objectSpread2({}, Sortable.utils), plugin.utils);
2371
+ PluginManager.mount(plugin);
2372
+ });
2373
+ };
2374
+
2375
+ /**
2376
+ * Create sortable instance
2377
+ * @param {HTMLElement} el
2378
+ * @param {Object} [options]
2379
+ */
2380
+ Sortable.create = function (el, options) {
2381
+ return new Sortable(el, options);
2382
+ };
2383
+
2384
+ // Export
2385
+ Sortable.version = version;
2386
+
2387
+ var autoScrolls = [],
2388
+ scrollEl,
2389
+ scrollRootEl,
2390
+ scrolling = false,
2391
+ lastAutoScrollX,
2392
+ lastAutoScrollY,
2393
+ touchEvt$1,
2394
+ pointerElemChangedInterval;
2395
+ function AutoScrollPlugin() {
2396
+ function AutoScroll() {
2397
+ this.defaults = {
2398
+ scroll: true,
2399
+ forceAutoScrollFallback: false,
2400
+ scrollSensitivity: 30,
2401
+ scrollSpeed: 10,
2402
+ bubbleScroll: true
2403
+ };
2404
+
2405
+ // Bind all private methods
2406
+ for (var fn in this) {
2407
+ if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
2408
+ this[fn] = this[fn].bind(this);
2409
+ }
2410
+ }
2411
+ }
2412
+ AutoScroll.prototype = {
2413
+ dragStarted: function dragStarted(_ref) {
2414
+ var originalEvent = _ref.originalEvent;
2415
+ if (this.sortable.nativeDraggable) {
2416
+ on(document, 'dragover', this._handleAutoScroll);
2417
+ } else {
2418
+ if (this.options.supportPointer) {
2419
+ on(document, 'pointermove', this._handleFallbackAutoScroll);
2420
+ } else if (originalEvent.touches) {
2421
+ on(document, 'touchmove', this._handleFallbackAutoScroll);
2422
+ } else {
2423
+ on(document, 'mousemove', this._handleFallbackAutoScroll);
2424
+ }
2425
+ }
2426
+ },
2427
+ dragOverCompleted: function dragOverCompleted(_ref2) {
2428
+ var originalEvent = _ref2.originalEvent;
2429
+ // For when bubbling is canceled and using fallback (fallback 'touchmove' always reached)
2430
+ if (!this.options.dragOverBubble && !originalEvent.rootEl) {
2431
+ this._handleAutoScroll(originalEvent);
2432
+ }
2433
+ },
2434
+ drop: function drop() {
2435
+ if (this.sortable.nativeDraggable) {
2436
+ off(document, 'dragover', this._handleAutoScroll);
2437
+ } else {
2438
+ off(document, 'pointermove', this._handleFallbackAutoScroll);
2439
+ off(document, 'touchmove', this._handleFallbackAutoScroll);
2440
+ off(document, 'mousemove', this._handleFallbackAutoScroll);
2441
+ }
2442
+ clearPointerElemChangedInterval();
2443
+ clearAutoScrolls();
2444
+ cancelThrottle();
2445
+ },
2446
+ nulling: function nulling() {
2447
+ touchEvt$1 = scrollRootEl = scrollEl = scrolling = pointerElemChangedInterval = lastAutoScrollX = lastAutoScrollY = null;
2448
+ autoScrolls.length = 0;
2449
+ },
2450
+ _handleFallbackAutoScroll: function _handleFallbackAutoScroll(evt) {
2451
+ this._handleAutoScroll(evt, true);
2452
+ },
2453
+ _handleAutoScroll: function _handleAutoScroll(evt, fallback) {
2454
+ var _this = this;
2455
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2456
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2457
+ elem = document.elementFromPoint(x, y);
2458
+ touchEvt$1 = evt;
2459
+
2460
+ // IE does not seem to have native autoscroll,
2461
+ // Edge's autoscroll seems too conditional,
2462
+ // MACOS Safari does not have autoscroll,
2463
+ // Firefox and Chrome are good
2464
+ if (fallback || this.options.forceAutoScrollFallback || Edge || IE11OrLess || Safari) {
2465
+ autoScroll(evt, this.options, elem, fallback);
2466
+
2467
+ // Listener for pointer element change
2468
+ var ogElemScroller = getParentAutoScrollElement(elem, true);
2469
+ if (scrolling && (!pointerElemChangedInterval || x !== lastAutoScrollX || y !== lastAutoScrollY)) {
2470
+ pointerElemChangedInterval && clearPointerElemChangedInterval();
2471
+ // Detect for pointer elem change, emulating native DnD behaviour
2472
+ pointerElemChangedInterval = setInterval(function () {
2473
+ var newElem = getParentAutoScrollElement(document.elementFromPoint(x, y), true);
2474
+ if (newElem !== ogElemScroller) {
2475
+ ogElemScroller = newElem;
2476
+ clearAutoScrolls();
2477
+ }
2478
+ autoScroll(evt, _this.options, newElem, fallback);
2479
+ }, 10);
2480
+ lastAutoScrollX = x;
2481
+ lastAutoScrollY = y;
2482
+ }
2483
+ } else {
2484
+ // if DnD is enabled (and browser has good autoscrolling), first autoscroll will already scroll, so get parent autoscroll of first autoscroll
2485
+ if (!this.options.bubbleScroll || getParentAutoScrollElement(elem, true) === getWindowScrollingElement()) {
2486
+ clearAutoScrolls();
2487
+ return;
2488
+ }
2489
+ autoScroll(evt, this.options, getParentAutoScrollElement(elem, false), false);
2490
+ }
2491
+ }
2492
+ };
2493
+ return _extends(AutoScroll, {
2494
+ pluginName: 'scroll',
2495
+ initializeByDefault: true
2496
+ });
2497
+ }
2498
+ function clearAutoScrolls() {
2499
+ autoScrolls.forEach(function (autoScroll) {
2500
+ clearInterval(autoScroll.pid);
2501
+ });
2502
+ autoScrolls = [];
2503
+ }
2504
+ function clearPointerElemChangedInterval() {
2505
+ clearInterval(pointerElemChangedInterval);
2506
+ }
2507
+ var autoScroll = throttle(function (evt, options, rootEl, isFallback) {
2508
+ // Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=505521
2509
+ if (!options.scroll) return;
2510
+ var x = (evt.touches ? evt.touches[0] : evt).clientX,
2511
+ y = (evt.touches ? evt.touches[0] : evt).clientY,
2512
+ sens = options.scrollSensitivity,
2513
+ speed = options.scrollSpeed,
2514
+ winScroller = getWindowScrollingElement();
2515
+ var scrollThisInstance = false,
2516
+ scrollCustomFn;
2517
+
2518
+ // New scroll root, set scrollEl
2519
+ if (scrollRootEl !== rootEl) {
2520
+ scrollRootEl = rootEl;
2521
+ clearAutoScrolls();
2522
+ scrollEl = options.scroll;
2523
+ scrollCustomFn = options.scrollFn;
2524
+ if (scrollEl === true) {
2525
+ scrollEl = getParentAutoScrollElement(rootEl, true);
2526
+ }
2527
+ }
2528
+ var layersOut = 0;
2529
+ var currentParent = scrollEl;
2530
+ do {
2531
+ var el = currentParent,
2532
+ rect = getRect(el),
2533
+ top = rect.top,
2534
+ bottom = rect.bottom,
2535
+ left = rect.left,
2536
+ right = rect.right,
2537
+ width = rect.width,
2538
+ height = rect.height,
2539
+ canScrollX = void 0,
2540
+ canScrollY = void 0,
2541
+ scrollWidth = el.scrollWidth,
2542
+ scrollHeight = el.scrollHeight,
2543
+ elCSS = css(el),
2544
+ scrollPosX = el.scrollLeft,
2545
+ scrollPosY = el.scrollTop;
2546
+ if (el === winScroller) {
2547
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll' || elCSS.overflowX === 'visible');
2548
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll' || elCSS.overflowY === 'visible');
2549
+ } else {
2550
+ canScrollX = width < scrollWidth && (elCSS.overflowX === 'auto' || elCSS.overflowX === 'scroll');
2551
+ canScrollY = height < scrollHeight && (elCSS.overflowY === 'auto' || elCSS.overflowY === 'scroll');
2552
+ }
2553
+ var vx = canScrollX && (Math.abs(right - x) <= sens && scrollPosX + width < scrollWidth) - (Math.abs(left - x) <= sens && !!scrollPosX);
2554
+ var vy = canScrollY && (Math.abs(bottom - y) <= sens && scrollPosY + height < scrollHeight) - (Math.abs(top - y) <= sens && !!scrollPosY);
2555
+ if (!autoScrolls[layersOut]) {
2556
+ for (var i = 0; i <= layersOut; i++) {
2557
+ if (!autoScrolls[i]) {
2558
+ autoScrolls[i] = {};
2559
+ }
2560
+ }
2561
+ }
2562
+ if (autoScrolls[layersOut].vx != vx || autoScrolls[layersOut].vy != vy || autoScrolls[layersOut].el !== el) {
2563
+ autoScrolls[layersOut].el = el;
2564
+ autoScrolls[layersOut].vx = vx;
2565
+ autoScrolls[layersOut].vy = vy;
2566
+ clearInterval(autoScrolls[layersOut].pid);
2567
+ if (vx != 0 || vy != 0) {
2568
+ scrollThisInstance = true;
2569
+ /* jshint loopfunc:true */
2570
+ autoScrolls[layersOut].pid = setInterval(function () {
2571
+ // emulate drag over during autoscroll (fallback), emulating native DnD behaviour
2572
+ if (isFallback && this.layer === 0) {
2573
+ Sortable.active._onTouchMove(touchEvt$1); // To move ghost if it is positioned absolutely
2574
+ }
2575
+ var scrollOffsetY = autoScrolls[this.layer].vy ? autoScrolls[this.layer].vy * speed : 0;
2576
+ var scrollOffsetX = autoScrolls[this.layer].vx ? autoScrolls[this.layer].vx * speed : 0;
2577
+ if (typeof scrollCustomFn === 'function') {
2578
+ if (scrollCustomFn.call(Sortable.dragged.parentNode[expando], scrollOffsetX, scrollOffsetY, evt, touchEvt$1, autoScrolls[this.layer].el) !== 'continue') {
2579
+ return;
2580
+ }
2581
+ }
2582
+ scrollBy(autoScrolls[this.layer].el, scrollOffsetX, scrollOffsetY);
2583
+ }.bind({
2584
+ layer: layersOut
2585
+ }), 24);
2586
+ }
2587
+ }
2588
+ layersOut++;
2589
+ } while (options.bubbleScroll && currentParent !== winScroller && (currentParent = getParentAutoScrollElement(currentParent, false)));
2590
+ scrolling = scrollThisInstance; // in case another function catches scrolling as false in between when it is not
2591
+ }, 30);
2592
+
2593
+ var drop = function drop(_ref) {
2594
+ var originalEvent = _ref.originalEvent,
2595
+ putSortable = _ref.putSortable,
2596
+ dragEl = _ref.dragEl,
2597
+ activeSortable = _ref.activeSortable,
2598
+ dispatchSortableEvent = _ref.dispatchSortableEvent,
2599
+ hideGhostForTarget = _ref.hideGhostForTarget,
2600
+ unhideGhostForTarget = _ref.unhideGhostForTarget;
2601
+ if (!originalEvent) return;
2602
+ var toSortable = putSortable || activeSortable;
2603
+ hideGhostForTarget();
2604
+ var touch = originalEvent.changedTouches && originalEvent.changedTouches.length ? originalEvent.changedTouches[0] : originalEvent;
2605
+ var target = document.elementFromPoint(touch.clientX, touch.clientY);
2606
+ unhideGhostForTarget();
2607
+ if (toSortable && !toSortable.el.contains(target)) {
2608
+ dispatchSortableEvent('spill');
2609
+ this.onSpill({
2610
+ dragEl: dragEl,
2611
+ putSortable: putSortable
2612
+ });
2613
+ }
2614
+ };
2615
+ function Revert() {}
2616
+ Revert.prototype = {
2617
+ startIndex: null,
2618
+ dragStart: function dragStart(_ref2) {
2619
+ var oldDraggableIndex = _ref2.oldDraggableIndex;
2620
+ this.startIndex = oldDraggableIndex;
2621
+ },
2622
+ onSpill: function onSpill(_ref3) {
2623
+ var dragEl = _ref3.dragEl,
2624
+ putSortable = _ref3.putSortable;
2625
+ this.sortable.captureAnimationState();
2626
+ if (putSortable) {
2627
+ putSortable.captureAnimationState();
2628
+ }
2629
+ var nextSibling = getChild(this.sortable.el, this.startIndex, this.options);
2630
+ if (nextSibling) {
2631
+ this.sortable.el.insertBefore(dragEl, nextSibling);
2632
+ } else {
2633
+ this.sortable.el.appendChild(dragEl);
2634
+ }
2635
+ this.sortable.animateAll();
2636
+ if (putSortable) {
2637
+ putSortable.animateAll();
2638
+ }
2639
+ },
2640
+ drop: drop
2641
+ };
2642
+ _extends(Revert, {
2643
+ pluginName: 'revertOnSpill'
2644
+ });
2645
+ function Remove() {}
2646
+ Remove.prototype = {
2647
+ onSpill: function onSpill(_ref4) {
2648
+ var dragEl = _ref4.dragEl,
2649
+ putSortable = _ref4.putSortable;
2650
+ var parentSortable = putSortable || this.sortable;
2651
+ parentSortable.captureAnimationState();
2652
+ dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
2653
+ parentSortable.animateAll();
2654
+ },
2655
+ drop: drop
2656
+ };
2657
+ _extends(Remove, {
2658
+ pluginName: 'removeOnSpill'
2659
+ });
2660
+
2661
+ Sortable.mount(new AutoScrollPlugin());
2662
+ Sortable.mount(Remove, Revert);
2663
+
2664
+ export { Sortable as S };
2665
+ //# sourceMappingURL=sortable.esm.js.map
2666
+
2667
+ //# sourceMappingURL=sortable.esm.js.map