uiik 1.3.4 → 1.3.6

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.4
2
+ * uiik v1.3.6
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
@@ -705,7 +705,7 @@ class Splittable extends Uii {
705
705
  con.style.position = "relative";
706
706
  }
707
707
  con.classList.toggle(CLASS_SPLITTABLE, true);
708
- const handleDoms = con.querySelectorAll(this.opts.handle);
708
+ const handleDoms = isString(this.opts.handle) ? con.querySelectorAll(this.opts.handle) : isArray(this.opts.handle) ? this.opts.handle : this.opts.handle ? [this.opts.handle] : [];
709
709
  const children = reject(con.children, c => {
710
710
  if (includes(handleDoms, c))
711
711
  return true;
@@ -747,7 +747,8 @@ class Splittable extends Uii {
747
747
  let domCon = getRootEl(h, con);
748
748
  let domL = domCon.previousElementSibling;
749
749
  let domR = domCon.nextElementSibling;
750
- if (domL && !domL.querySelector(this.opts.handle)) {
750
+ let hasDomLHandle = isString(this.opts.handle) ? domL === null || domL === void 0 ? void 0 : domL.querySelector(this.opts.handle) : domL === null || domL === void 0 ? void 0 : domL.contains(h);
751
+ if (domL && !hasDomLHandle) {
751
752
  dom1 = domL;
752
753
  dom2 = domCon;
753
754
  }
@@ -764,10 +765,16 @@ class Splittable extends Uii {
764
765
  }
765
766
  _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Splittable_checkDirection(container) {
766
767
  let dir = 'h';
768
+ let cStyle = window.getComputedStyle(container);
769
+ if (cStyle.display === 'inline-flex')
770
+ return dir;
771
+ if (cStyle.display === 'flex' && cStyle.flexDirection === 'row')
772
+ return dir;
767
773
  const child = container.children[0];
768
774
  let lastY = child.offsetTop;
775
+ let lastH = child.offsetHeight;
769
776
  each(container.children, c => {
770
- if (c.offsetTop != lastY) {
777
+ if (c.offsetTop > lastH + lastY) {
771
778
  dir = 'v';
772
779
  return false;
773
780
  }
@@ -1772,7 +1779,7 @@ class Draggable extends Uii {
1772
1779
  let ghostParent = ghostTo ? (isString(ghostTo) ? document.querySelector(ghostTo) : ghostTo) : dragDom.parentNode;
1773
1780
  ghostParent === null || ghostParent === void 0 ? void 0 : ghostParent.appendChild(ghostNode);
1774
1781
  transform = wrapper(ghostNode, opts.useTransform);
1775
- onClone && onClone({ clone: ghostNode }, ev);
1782
+ onClone && onClone({ clone: ghostNode, draggable: dragDom }, ev);
1776
1783
  }
1777
1784
  else {
1778
1785
  transform = wrapper(dragDom, opts.useTransform);
@@ -1783,9 +1790,11 @@ class Draggable extends Uii {
1783
1790
  dragDom.classList.toggle(CLASS_DRAGGABLE_ACTIVE, true);
1784
1791
  onStart &&
1785
1792
  onStart({ draggable: dragDom, x: startPointXy.x, y: startPointXy.y, transform }, ev);
1786
- const customEv = new Event("uii-dragactive", {
1793
+ const customEv = new CustomEvent("uii-dragactive", {
1787
1794
  bubbles: true,
1795
+ composed: true,
1788
1796
  cancelable: false,
1797
+ detail: { target: dragDom }
1789
1798
  });
1790
1799
  dragDom.dispatchEvent(customEv);
1791
1800
  });
@@ -1980,9 +1989,13 @@ class Draggable extends Uii {
1980
1989
  ? false
1981
1990
  : true;
1982
1991
  }
1983
- const customEv = new Event("uii-dragdeactive", {
1992
+ const customEv = new CustomEvent("uii-dragdeactive", {
1984
1993
  bubbles: true,
1994
+ composed: true,
1985
1995
  cancelable: false,
1996
+ detail: {
1997
+ target: dragDom
1998
+ }
1986
1999
  });
1987
2000
  dragDom.dispatchEvent(customEv);
1988
2001
  if (ghost) {
@@ -2145,13 +2158,15 @@ class Droppable extends Uii {
2145
2158
  }
2146
2159
  _Droppable_active = new WeakMap();
2147
2160
  document.addEventListener("uii-dragactive", (e) => {
2161
+ let { target } = e.detail;
2148
2162
  each(Droppables, dpb => {
2149
- dpb.active(e.target);
2163
+ dpb.active(target);
2150
2164
  });
2151
2165
  });
2152
2166
  document.addEventListener("uii-dragdeactive", (e) => {
2167
+ let { target } = e.detail;
2153
2168
  each(Droppables, dpb => {
2154
- dpb.deactive(e.target);
2169
+ dpb.deactive(target);
2155
2170
  });
2156
2171
  });
2157
2172
  function newDroppable(els, opts) {
@@ -2957,7 +2972,7 @@ function newSortable(container, opts) {
2957
2972
  return new Sortable(container, opts);
2958
2973
  }
2959
2974
 
2960
- var version = "1.3.4";
2975
+ var version = "1.3.6";
2961
2976
  var repository = {
2962
2977
  type: "git",
2963
2978
  url: "https://github.com/holyhigh2/uiik"
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * uiik v1.3.4
2
+ * uiik v1.3.6
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
@@ -702,7 +702,7 @@
702
702
  con.style.position = "relative";
703
703
  }
704
704
  con.classList.toggle(CLASS_SPLITTABLE, true);
705
- const handleDoms = con.querySelectorAll(this.opts.handle);
705
+ const handleDoms = is.isString(this.opts.handle) ? con.querySelectorAll(this.opts.handle) : is.isArray(this.opts.handle) ? this.opts.handle : this.opts.handle ? [this.opts.handle] : [];
706
706
  const children = collection.reject(con.children, c => {
707
707
  if (collection.includes(handleDoms, c))
708
708
  return true;
@@ -744,7 +744,8 @@
744
744
  let domCon = getRootEl(h, con);
745
745
  let domL = domCon.previousElementSibling;
746
746
  let domR = domCon.nextElementSibling;
747
- if (domL && !domL.querySelector(this.opts.handle)) {
747
+ let hasDomLHandle = is.isString(this.opts.handle) ? domL === null || domL === void 0 ? void 0 : domL.querySelector(this.opts.handle) : domL === null || domL === void 0 ? void 0 : domL.contains(h);
748
+ if (domL && !hasDomLHandle) {
748
749
  dom1 = domL;
749
750
  dom2 = domCon;
750
751
  }
@@ -761,10 +762,16 @@
761
762
  }
762
763
  _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Splittable_checkDirection(container) {
763
764
  let dir = 'h';
765
+ let cStyle = window.getComputedStyle(container);
766
+ if (cStyle.display === 'inline-flex')
767
+ return dir;
768
+ if (cStyle.display === 'flex' && cStyle.flexDirection === 'row')
769
+ return dir;
764
770
  const child = container.children[0];
765
771
  let lastY = child.offsetTop;
772
+ let lastH = child.offsetHeight;
766
773
  collection.each(container.children, c => {
767
- if (c.offsetTop != lastY) {
774
+ if (c.offsetTop > lastH + lastY) {
768
775
  dir = 'v';
769
776
  return false;
770
777
  }
@@ -1769,7 +1776,7 @@
1769
1776
  let ghostParent = ghostTo ? (is.isString(ghostTo) ? document.querySelector(ghostTo) : ghostTo) : dragDom.parentNode;
1770
1777
  ghostParent === null || ghostParent === void 0 ? void 0 : ghostParent.appendChild(ghostNode);
1771
1778
  transform = wrapper(ghostNode, opts.useTransform);
1772
- onClone && onClone({ clone: ghostNode }, ev);
1779
+ onClone && onClone({ clone: ghostNode, draggable: dragDom }, ev);
1773
1780
  }
1774
1781
  else {
1775
1782
  transform = wrapper(dragDom, opts.useTransform);
@@ -1780,9 +1787,11 @@
1780
1787
  dragDom.classList.toggle(CLASS_DRAGGABLE_ACTIVE, true);
1781
1788
  onStart &&
1782
1789
  onStart({ draggable: dragDom, x: startPointXy.x, y: startPointXy.y, transform }, ev);
1783
- const customEv = new Event("uii-dragactive", {
1790
+ const customEv = new CustomEvent("uii-dragactive", {
1784
1791
  bubbles: true,
1792
+ composed: true,
1785
1793
  cancelable: false,
1794
+ detail: { target: dragDom }
1786
1795
  });
1787
1796
  dragDom.dispatchEvent(customEv);
1788
1797
  });
@@ -1977,9 +1986,13 @@
1977
1986
  ? false
1978
1987
  : true;
1979
1988
  }
1980
- const customEv = new Event("uii-dragdeactive", {
1989
+ const customEv = new CustomEvent("uii-dragdeactive", {
1981
1990
  bubbles: true,
1991
+ composed: true,
1982
1992
  cancelable: false,
1993
+ detail: {
1994
+ target: dragDom
1995
+ }
1983
1996
  });
1984
1997
  dragDom.dispatchEvent(customEv);
1985
1998
  if (ghost) {
@@ -2142,13 +2155,15 @@
2142
2155
  }
2143
2156
  _Droppable_active = new WeakMap();
2144
2157
  document.addEventListener("uii-dragactive", (e) => {
2158
+ let { target } = e.detail;
2145
2159
  collection.each(Droppables, dpb => {
2146
- dpb.active(e.target);
2160
+ dpb.active(target);
2147
2161
  });
2148
2162
  });
2149
2163
  document.addEventListener("uii-dragdeactive", (e) => {
2164
+ let { target } = e.detail;
2150
2165
  collection.each(Droppables, dpb => {
2151
- dpb.deactive(e.target);
2166
+ dpb.deactive(target);
2152
2167
  });
2153
2168
  });
2154
2169
  function newDroppable(els, opts) {
@@ -2954,7 +2969,7 @@
2954
2969
  return new Sortable(container, opts);
2955
2970
  }
2956
2971
 
2957
- var version = "1.3.4";
2972
+ var version = "1.3.6";
2958
2973
  var repository = {
2959
2974
  type: "git",
2960
2975
  url: "https://github.com/holyhigh2/uiik"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uiik",
3
- "version": "1.3.4",
3
+ "version": "1.3.6",
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
@@ -66,7 +66,7 @@ export type SplittableOptions = {
66
66
  ghost?: boolean;
67
67
  ghostClass?: string;
68
68
  ghostTo?: string | HTMLElement;
69
- handle?: string;
69
+ handle?: string | HTMLElement | HTMLElement[];
70
70
  onStart?: (data: {
71
71
  size1: number;
72
72
  size2: number;
@@ -143,6 +143,7 @@ export type DraggableOptions = {
143
143
  }, event: MouseEvent) => boolean | void;
144
144
  onClone?: (data: {
145
145
  clone: HTMLElement | SVGGraphicsElement;
146
+ draggable: HTMLElement | SVGGraphicsElement;
146
147
  }, event: MouseEvent) => void;
147
148
  onSnap?: (data: {
148
149
  el: HTMLElement | SVGGraphicsElement;