@pine-ds/core 1.2.0 → 1.3.0

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