svelte-dnd-action 0.9.31 → 0.9.33

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.
package/dist/index.js CHANGED
@@ -972,16 +972,27 @@
972
972
  } finally {
973
973
  _iterator.f();
974
974
  }
975
- if (selects.length <= 0) {
976
- return cloned;
977
- }
978
- var clonedSelects = elIsSelect ? [cloned] : _toConsumableArray(cloned.querySelectorAll("select"));
979
- for (var i = 0; i < clonedSelects.length; i++) {
980
- var select = clonedSelects[i];
981
- var value = values[i];
982
- var optionEl = select.querySelector("option[value=\"".concat(value, "\""));
983
- if (optionEl) {
984
- optionEl.setAttribute("selected", true);
975
+ if (selects.length > 0) {
976
+ var clonedSelects = elIsSelect ? [cloned] : _toConsumableArray(cloned.querySelectorAll("select"));
977
+ for (var i = 0; i < clonedSelects.length; i++) {
978
+ var select = clonedSelects[i];
979
+ var value = values[i];
980
+ var optionEl = select.querySelector("option[value=\"".concat(value, "\""));
981
+ if (optionEl) {
982
+ optionEl.setAttribute("selected", true);
983
+ }
984
+ }
985
+ }
986
+ var elIsCanvas = el.tagName === "CANVAS";
987
+ var canvases = elIsCanvas ? [el] : _toConsumableArray(el.querySelectorAll("canvas"));
988
+ if (canvases.length > 0) {
989
+ var clonedCanvases = elIsCanvas ? [cloned] : _toConsumableArray(cloned.querySelectorAll("canvas"));
990
+ for (var _i = 0; _i < clonedCanvases.length; _i++) {
991
+ var canvas = canvases[_i];
992
+ var clonedCanvas = clonedCanvases[_i];
993
+ clonedCanvas.width = canvas.width;
994
+ clonedCanvas.height = canvas.height;
995
+ clonedCanvas.getContext("2d").drawImage(canvas, 0, 0);
985
996
  }
986
997
  }
987
998
  return cloned;
@@ -1668,8 +1679,8 @@
1668
1679
  var currentIdx = elToIdx.get(originalDragTarget);
1669
1680
  originIndex = currentIdx;
1670
1681
  originDropZone = originalDragTarget.parentElement;
1671
- /** @type {ShadowRoot | HTMLDocument} */
1672
- var rootNode = originDropZone.getRootNode();
1682
+ /** @type {ShadowRoot | HTMLDocument | Element } */
1683
+ var rootNode = originDropZone.closest("dialog") || originDropZone.getRootNode();
1673
1684
  var originDropZoneRoot = rootNode.body || rootNode;
1674
1685
  var items = config.items,
1675
1686
  type = config.type,
package/dist/index.mjs CHANGED
@@ -966,16 +966,27 @@ function svelteNodeClone(el) {
966
966
  } finally {
967
967
  _iterator.f();
968
968
  }
969
- if (selects.length <= 0) {
970
- return cloned;
971
- }
972
- var clonedSelects = elIsSelect ? [cloned] : _toConsumableArray(cloned.querySelectorAll("select"));
973
- for (var i = 0; i < clonedSelects.length; i++) {
974
- var select = clonedSelects[i];
975
- var value = values[i];
976
- var optionEl = select.querySelector("option[value=\"".concat(value, "\""));
977
- if (optionEl) {
978
- optionEl.setAttribute("selected", true);
969
+ if (selects.length > 0) {
970
+ var clonedSelects = elIsSelect ? [cloned] : _toConsumableArray(cloned.querySelectorAll("select"));
971
+ for (var i = 0; i < clonedSelects.length; i++) {
972
+ var select = clonedSelects[i];
973
+ var value = values[i];
974
+ var optionEl = select.querySelector("option[value=\"".concat(value, "\""));
975
+ if (optionEl) {
976
+ optionEl.setAttribute("selected", true);
977
+ }
978
+ }
979
+ }
980
+ var elIsCanvas = el.tagName === "CANVAS";
981
+ var canvases = elIsCanvas ? [el] : _toConsumableArray(el.querySelectorAll("canvas"));
982
+ if (canvases.length > 0) {
983
+ var clonedCanvases = elIsCanvas ? [cloned] : _toConsumableArray(cloned.querySelectorAll("canvas"));
984
+ for (var _i = 0; _i < clonedCanvases.length; _i++) {
985
+ var canvas = canvases[_i];
986
+ var clonedCanvas = clonedCanvases[_i];
987
+ clonedCanvas.width = canvas.width;
988
+ clonedCanvas.height = canvas.height;
989
+ clonedCanvas.getContext("2d").drawImage(canvas, 0, 0);
979
990
  }
980
991
  }
981
992
  return cloned;
@@ -1662,8 +1673,8 @@ function dndzone(node, options) {
1662
1673
  var currentIdx = elToIdx.get(originalDragTarget);
1663
1674
  originIndex = currentIdx;
1664
1675
  originDropZone = originalDragTarget.parentElement;
1665
- /** @type {ShadowRoot | HTMLDocument} */
1666
- var rootNode = originDropZone.getRootNode();
1676
+ /** @type {ShadowRoot | HTMLDocument | Element } */
1677
+ var rootNode = originDropZone.closest("dialog") || originDropZone.getRootNode();
1667
1678
  var originDropZoneRoot = rootNode.body || rootNode;
1668
1679
  var items = config.items,
1669
1680
  type = config.type,
package/package.json CHANGED
@@ -43,7 +43,7 @@
43
43
  "dist"
44
44
  ],
45
45
  "description": "*An awesome drag and drop library for Svelte 3 and 4 (not using the browser's built-in dnd, thanks god): Rich animations, nested containers, touch support and more *",
46
- "version": "0.9.31",
46
+ "version": "0.9.33",
47
47
  "repository": {
48
48
  "type": "git",
49
49
  "url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
@@ -17,17 +17,29 @@ export function svelteNodeClone(el) {
17
17
  values.push(select.value);
18
18
  }
19
19
 
20
- if (selects.length <= 0) {
21
- return cloned;
20
+ if (selects.length > 0) {
21
+ const clonedSelects = elIsSelect ? [cloned] : [...cloned.querySelectorAll("select")];
22
+ for (let i = 0; i < clonedSelects.length; i++) {
23
+ const select = clonedSelects[i];
24
+ const value = values[i];
25
+ const optionEl = select.querySelector(`option[value="${value}"`);
26
+ if (optionEl) {
27
+ optionEl.setAttribute("selected", true);
28
+ }
29
+ }
22
30
  }
23
31
 
24
- const clonedSelects = elIsSelect ? [cloned] : [...cloned.querySelectorAll("select")];
25
- for (let i = 0; i < clonedSelects.length; i++) {
26
- const select = clonedSelects[i];
27
- const value = values[i];
28
- const optionEl = select.querySelector(`option[value="${value}"`);
29
- if (optionEl) {
30
- optionEl.setAttribute("selected", true);
32
+ const elIsCanvas = el.tagName === "CANVAS";
33
+ const canvases = elIsCanvas ? [el] : [...el.querySelectorAll("canvas")];
34
+ if(canvases.length > 0)
35
+ {
36
+ const clonedCanvases = elIsCanvas ? [cloned] : [...cloned.querySelectorAll("canvas")];
37
+ for (let i = 0; i < clonedCanvases.length; i++) {
38
+ const canvas = canvases[i];
39
+ const clonedCanvas = clonedCanvases[i];
40
+ clonedCanvas.width = canvas.width;
41
+ clonedCanvas.height = canvas.height;
42
+ clonedCanvas.getContext("2d").drawImage(canvas,0,0);
31
43
  }
32
44
  }
33
45
 
@@ -383,8 +383,8 @@ export function dndzone(node, options) {
383
383
  const currentIdx = elToIdx.get(originalDragTarget);
384
384
  originIndex = currentIdx;
385
385
  originDropZone = originalDragTarget.parentElement;
386
- /** @type {ShadowRoot | HTMLDocument} */
387
- const rootNode = originDropZone.getRootNode();
386
+ /** @type {ShadowRoot | HTMLDocument | Element } */
387
+ const rootNode = originDropZone.closest("dialog") || originDropZone.getRootNode();
388
388
  const originDropZoneRoot = rootNode.body || rootNode;
389
389
  const {items, type, centreDraggedOnCursor} = config;
390
390
  draggedElData = {...items[currentIdx]};