uiik 1.3.5 → 1.3.7

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/detector.d.ts CHANGED
@@ -12,4 +12,4 @@ export declare class CollisionDetector {
12
12
  getInclusions(): Array<HTMLElement>;
13
13
  getInclusions(x1: number, y1: number, x2: number, y2: number): Array<HTMLElement>;
14
14
  }
15
- export declare function newCollisionDetector(el: string | HTMLElement, targets: (() => Array<HTMLElement>) | string | HTMLElement | Array<HTMLElement> | NodeList | HTMLCollection, opts?: CollisionDetectorOptions): CollisionDetector;
15
+ export declare function newCollisionDetector(el: string | HTMLElement, targets: (() => Array<HTMLElement>) | string | HTMLElement | Array<HTMLElement> | NodeList | HTMLCollection | NodeListOf<Element>, opts?: CollisionDetectorOptions): CollisionDetector;
package/draggable.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { DraggableOptions, Uii } from "./types";
2
2
  export declare class Draggable extends Uii {
3
3
  #private;
4
- constructor(els: string | HTMLElement | Array<string | HTMLElement>, opts?: DraggableOptions);
4
+ constructor(els: string | HTMLElement | Array<string | HTMLElement> | NodeListOf<Element>, opts?: DraggableOptions);
5
5
  bindEvent(bindTarget: Element, opts: DraggableOptions, handleMap: WeakMap<Element, Element>): void;
6
6
  onOptionChanged(opts: Record<string, any>): void;
7
7
  }
8
- export declare function newDraggable(els: string | HTMLElement | Array<string | HTMLElement>, opts?: DraggableOptions): Draggable;
8
+ export declare function newDraggable(els: string | HTMLElement | Array<string | HTMLElement> | NodeListOf<Element>, opts?: DraggableOptions): Draggable;
package/droppable.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { DroppableOptions, Uii } from "./types";
2
2
  export declare class Droppable extends Uii {
3
3
  #private;
4
- constructor(el: string | HTMLElement | Array<string | HTMLElement>, opts?: DroppableOptions);
4
+ constructor(el: string | HTMLElement | Array<string | HTMLElement> | NodeListOf<Element>, opts?: DroppableOptions);
5
5
  bindEvent(droppable: HTMLElement, opts: DroppableOptions): void;
6
6
  active(target: HTMLElement): void;
7
7
  deactive(target: HTMLElement): void;
8
8
  }
9
- export declare function newDroppable(els: string | HTMLElement | Array<string | HTMLElement>, opts?: DroppableOptions): Droppable;
9
+ export declare function newDroppable(els: string | HTMLElement | Array<string | HTMLElement> | NodeListOf<Element>, opts?: DroppableOptions): Droppable;
package/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * uiik v1.3.5
2
+ * uiik v1.3.7
3
3
  * A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.
4
4
  * https://github.com/holyhigh2/uiik
5
5
  * c) 2021-2025 @holyhigh2 may be freely distributed under the MIT license
@@ -984,7 +984,6 @@ class Resizable extends Uii {
984
984
  super(els, assign({
985
985
  handleSize: 8,
986
986
  minSize: 50,
987
- dir: ["n", "s", "e", "w", "ne", "nw", "se", "sw"],
988
987
  ghost: false,
989
988
  offset: 0,
990
989
  }, opts));
@@ -1428,6 +1427,7 @@ class Resizable extends Uii {
1428
1427
  }
1429
1428
  lastX = x;
1430
1429
  lastY = y;
1430
+ console.log(lastX, lastY);
1431
1431
  currentW = w;
1432
1432
  currentH = h;
1433
1433
  if (onResize && onResize.call) {
@@ -1456,11 +1456,12 @@ class Resizable extends Uii {
1456
1456
  var _a, _b;
1457
1457
  const { ev } = args;
1458
1458
  if (ghost && ghostNode) {
1459
- ((_a = panel.parentNode) === null || _a === void 0 ? void 0 : _a.contains(ghostNode)) &&
1460
- ((_b = panel.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(ghostNode));
1461
1459
  panelStyle.left = ghostNode.style.left;
1462
1460
  panelStyle.top = ghostNode.style.top;
1463
- moveTo(panel, lastX / matrixInfo.scale, lastY / matrixInfo.scale);
1461
+ transform = wrapper(panel);
1462
+ transform.moveTo((lastX + sX), (lastY + sY));
1463
+ ((_a = panel.parentNode) === null || _a === void 0 ? void 0 : _a.contains(ghostNode)) &&
1464
+ ((_b = panel.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(ghostNode));
1464
1465
  resize(transform, panelStyle, parseFloat(ghostNode.style.width), parseFloat(ghostNode.style.height));
1465
1466
  }
1466
1467
  if (setOrigin)
@@ -1502,7 +1503,7 @@ class Resizable extends Uii {
1502
1503
  handles = handleStr(panel);
1503
1504
  }
1504
1505
  if (!handles) {
1505
- console.error('Can not find handles with "' + panel.outerHTML + '"');
1506
+ console.error('Can not find handles in "' + panel.outerHTML + '"');
1506
1507
  return;
1507
1508
  }
1508
1509
  handles = isArrayLike(handles) ? handles : [handles];
@@ -1779,7 +1780,7 @@ class Draggable extends Uii {
1779
1780
  let ghostParent = ghostTo ? (isString(ghostTo) ? document.querySelector(ghostTo) : ghostTo) : dragDom.parentNode;
1780
1781
  ghostParent === null || ghostParent === void 0 ? void 0 : ghostParent.appendChild(ghostNode);
1781
1782
  transform = wrapper(ghostNode, opts.useTransform);
1782
- onClone && onClone({ clone: ghostNode }, ev);
1783
+ onClone && onClone({ clone: ghostNode, draggable: dragDom }, ev);
1783
1784
  }
1784
1785
  else {
1785
1786
  transform = wrapper(dragDom, opts.useTransform);
@@ -1790,9 +1791,11 @@ class Draggable extends Uii {
1790
1791
  dragDom.classList.toggle(CLASS_DRAGGABLE_ACTIVE, true);
1791
1792
  onStart &&
1792
1793
  onStart({ draggable: dragDom, x: startPointXy.x, y: startPointXy.y, transform }, ev);
1793
- const customEv = new Event("uii-dragactive", {
1794
+ const customEv = new CustomEvent("uii-dragactive", {
1794
1795
  bubbles: true,
1796
+ composed: true,
1795
1797
  cancelable: false,
1798
+ detail: { target: dragDom }
1796
1799
  });
1797
1800
  dragDom.dispatchEvent(customEv);
1798
1801
  });
@@ -1987,9 +1990,13 @@ class Draggable extends Uii {
1987
1990
  ? false
1988
1991
  : true;
1989
1992
  }
1990
- const customEv = new Event("uii-dragdeactive", {
1993
+ const customEv = new CustomEvent("uii-dragdeactive", {
1991
1994
  bubbles: true,
1995
+ composed: true,
1992
1996
  cancelable: false,
1997
+ detail: {
1998
+ target: dragDom
1999
+ }
1993
2000
  });
1994
2001
  dragDom.dispatchEvent(customEv);
1995
2002
  if (ghost) {
@@ -2152,13 +2159,15 @@ class Droppable extends Uii {
2152
2159
  }
2153
2160
  _Droppable_active = new WeakMap();
2154
2161
  document.addEventListener("uii-dragactive", (e) => {
2162
+ let { target } = e.detail;
2155
2163
  each(Droppables, dpb => {
2156
- dpb.active(e.target);
2164
+ dpb.active(target);
2157
2165
  });
2158
2166
  });
2159
2167
  document.addEventListener("uii-dragdeactive", (e) => {
2168
+ let { target } = e.detail;
2160
2169
  each(Droppables, dpb => {
2161
- dpb.deactive(e.target);
2170
+ dpb.deactive(target);
2162
2171
  });
2163
2172
  });
2164
2173
  function newDroppable(els, opts) {
@@ -2964,7 +2973,7 @@ function newSortable(container, opts) {
2964
2973
  return new Sortable(container, opts);
2965
2974
  }
2966
2975
 
2967
- var version = "1.3.5";
2976
+ var version = "1.3.7";
2968
2977
  var repository = {
2969
2978
  type: "git",
2970
2979
  url: "https://github.com/holyhigh2/uiik"
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * uiik v1.3.5
2
+ * uiik v1.3.7
3
3
  * A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.
4
4
  * https://github.com/holyhigh2/uiik
5
5
  * c) 2021-2025 @holyhigh2 may be freely distributed under the MIT license
@@ -981,7 +981,6 @@
981
981
  super(els, object.assign({
982
982
  handleSize: 8,
983
983
  minSize: 50,
984
- dir: ["n", "s", "e", "w", "ne", "nw", "se", "sw"],
985
984
  ghost: false,
986
985
  offset: 0,
987
986
  }, opts));
@@ -1425,6 +1424,7 @@
1425
1424
  }
1426
1425
  lastX = x;
1427
1426
  lastY = y;
1427
+ console.log(lastX, lastY);
1428
1428
  currentW = w;
1429
1429
  currentH = h;
1430
1430
  if (onResize && onResize.call) {
@@ -1453,11 +1453,12 @@
1453
1453
  var _a, _b;
1454
1454
  const { ev } = args;
1455
1455
  if (ghost && ghostNode) {
1456
- ((_a = panel.parentNode) === null || _a === void 0 ? void 0 : _a.contains(ghostNode)) &&
1457
- ((_b = panel.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(ghostNode));
1458
1456
  panelStyle.left = ghostNode.style.left;
1459
1457
  panelStyle.top = ghostNode.style.top;
1460
- moveTo(panel, lastX / matrixInfo.scale, lastY / matrixInfo.scale);
1458
+ transform = wrapper(panel);
1459
+ transform.moveTo((lastX + sX), (lastY + sY));
1460
+ ((_a = panel.parentNode) === null || _a === void 0 ? void 0 : _a.contains(ghostNode)) &&
1461
+ ((_b = panel.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(ghostNode));
1461
1462
  resize(transform, panelStyle, parseFloat(ghostNode.style.width), parseFloat(ghostNode.style.height));
1462
1463
  }
1463
1464
  if (setOrigin)
@@ -1499,7 +1500,7 @@
1499
1500
  handles = handleStr(panel);
1500
1501
  }
1501
1502
  if (!handles) {
1502
- console.error('Can not find handles with "' + panel.outerHTML + '"');
1503
+ console.error('Can not find handles in "' + panel.outerHTML + '"');
1503
1504
  return;
1504
1505
  }
1505
1506
  handles = is.isArrayLike(handles) ? handles : [handles];
@@ -1776,7 +1777,7 @@
1776
1777
  let ghostParent = ghostTo ? (is.isString(ghostTo) ? document.querySelector(ghostTo) : ghostTo) : dragDom.parentNode;
1777
1778
  ghostParent === null || ghostParent === void 0 ? void 0 : ghostParent.appendChild(ghostNode);
1778
1779
  transform = wrapper(ghostNode, opts.useTransform);
1779
- onClone && onClone({ clone: ghostNode }, ev);
1780
+ onClone && onClone({ clone: ghostNode, draggable: dragDom }, ev);
1780
1781
  }
1781
1782
  else {
1782
1783
  transform = wrapper(dragDom, opts.useTransform);
@@ -1787,9 +1788,11 @@
1787
1788
  dragDom.classList.toggle(CLASS_DRAGGABLE_ACTIVE, true);
1788
1789
  onStart &&
1789
1790
  onStart({ draggable: dragDom, x: startPointXy.x, y: startPointXy.y, transform }, ev);
1790
- const customEv = new Event("uii-dragactive", {
1791
+ const customEv = new CustomEvent("uii-dragactive", {
1791
1792
  bubbles: true,
1793
+ composed: true,
1792
1794
  cancelable: false,
1795
+ detail: { target: dragDom }
1793
1796
  });
1794
1797
  dragDom.dispatchEvent(customEv);
1795
1798
  });
@@ -1984,9 +1987,13 @@
1984
1987
  ? false
1985
1988
  : true;
1986
1989
  }
1987
- const customEv = new Event("uii-dragdeactive", {
1990
+ const customEv = new CustomEvent("uii-dragdeactive", {
1988
1991
  bubbles: true,
1992
+ composed: true,
1989
1993
  cancelable: false,
1994
+ detail: {
1995
+ target: dragDom
1996
+ }
1990
1997
  });
1991
1998
  dragDom.dispatchEvent(customEv);
1992
1999
  if (ghost) {
@@ -2149,13 +2156,15 @@
2149
2156
  }
2150
2157
  _Droppable_active = new WeakMap();
2151
2158
  document.addEventListener("uii-dragactive", (e) => {
2159
+ let { target } = e.detail;
2152
2160
  collection.each(Droppables, dpb => {
2153
- dpb.active(e.target);
2161
+ dpb.active(target);
2154
2162
  });
2155
2163
  });
2156
2164
  document.addEventListener("uii-dragdeactive", (e) => {
2165
+ let { target } = e.detail;
2157
2166
  collection.each(Droppables, dpb => {
2158
- dpb.deactive(e.target);
2167
+ dpb.deactive(target);
2159
2168
  });
2160
2169
  });
2161
2170
  function newDroppable(els, opts) {
@@ -2961,7 +2970,7 @@
2961
2970
  return new Sortable(container, opts);
2962
2971
  }
2963
2972
 
2964
- var version = "1.3.5";
2973
+ var version = "1.3.7";
2965
2974
  var repository = {
2966
2975
  type: "git",
2967
2976
  url: "https://github.com/holyhigh2/uiik"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uiik",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.",
5
5
  "main": "index.js",
6
6
  "module": "index.esm.js",
package/types.d.ts CHANGED
@@ -21,10 +21,9 @@ export declare abstract class Uii {
21
21
  protected onOptionChanged(opts?: Record<string, any>): void;
22
22
  }
23
23
  export type ResizableOptions = {
24
- handle?: ((target: HTMLElement | SVGGraphicsElement) => NodeList | HTMLCollection | HTMLElement[] | HTMLElement | SVGGraphicsElement) | string | NodeList | HTMLCollection | HTMLElement[] | HTMLElement | SVGGraphicsElement;
24
+ handle: ((target: HTMLElement | SVGGraphicsElement) => NodeList | HTMLCollection | HTMLElement[] | HTMLElement | SVGGraphicsElement) | string | NodeList | HTMLCollection | HTMLElement[] | HTMLElement | SVGGraphicsElement;
25
25
  minSize?: number | Array<number>;
26
26
  maxSize?: number | Array<number>;
27
- dir?: string[];
28
27
  aspectRatio?: number;
29
28
  ghost?: boolean | Function;
30
29
  ghostClass?: string;
@@ -143,6 +142,7 @@ export type DraggableOptions = {
143
142
  }, event: MouseEvent) => boolean | void;
144
143
  onClone?: (data: {
145
144
  clone: HTMLElement | SVGGraphicsElement;
145
+ draggable: HTMLElement | SVGGraphicsElement;
146
146
  }, event: MouseEvent) => void;
147
147
  onSnap?: (data: {
148
148
  el: HTMLElement | SVGGraphicsElement;