uiik 1.3.3 → 1.3.5
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/CHANGELOG.md +3 -0
- package/index.esm.js +26 -9
- package/index.js +29 -13
- package/package.json +1 -1
- package/types.d.ts +1 -1
package/CHANGELOG.md
CHANGED
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* uiik v1.3.
|
|
2
|
+
* uiik v1.3.5
|
|
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
|
|
@@ -11,6 +11,7 @@ import { compact, findIndex } from 'myfx/array';
|
|
|
11
11
|
import { split, test } from 'myfx/string';
|
|
12
12
|
import { closest } from 'myfx/tree';
|
|
13
13
|
import { alphaId } from 'myfx/utils';
|
|
14
|
+
import { filter, last } from 'myfx';
|
|
14
15
|
|
|
15
16
|
/******************************************************************************
|
|
16
17
|
Copyright (c) Microsoft Corporation.
|
|
@@ -704,7 +705,7 @@ class Splittable extends Uii {
|
|
|
704
705
|
con.style.position = "relative";
|
|
705
706
|
}
|
|
706
707
|
con.classList.toggle(CLASS_SPLITTABLE, true);
|
|
707
|
-
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] : [];
|
|
708
709
|
const children = reject(con.children, c => {
|
|
709
710
|
if (includes(handleDoms, c))
|
|
710
711
|
return true;
|
|
@@ -746,7 +747,8 @@ class Splittable extends Uii {
|
|
|
746
747
|
let domCon = getRootEl(h, con);
|
|
747
748
|
let domL = domCon.previousElementSibling;
|
|
748
749
|
let domR = domCon.nextElementSibling;
|
|
749
|
-
|
|
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) {
|
|
750
752
|
dom1 = domL;
|
|
751
753
|
dom2 = domCon;
|
|
752
754
|
}
|
|
@@ -763,10 +765,16 @@ class Splittable extends Uii {
|
|
|
763
765
|
}
|
|
764
766
|
_Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Splittable_checkDirection(container) {
|
|
765
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;
|
|
766
773
|
const child = container.children[0];
|
|
767
774
|
let lastY = child.offsetTop;
|
|
775
|
+
let lastH = child.offsetHeight;
|
|
768
776
|
each(container.children, c => {
|
|
769
|
-
if (c.offsetTop
|
|
777
|
+
if (c.offsetTop > lastH + lastY) {
|
|
770
778
|
dir = 'v';
|
|
771
779
|
return false;
|
|
772
780
|
}
|
|
@@ -2640,6 +2648,8 @@ class Sortable extends Uii {
|
|
|
2640
2648
|
onOptionChanged() { }
|
|
2641
2649
|
}
|
|
2642
2650
|
_Sortable_removeListenItems = new WeakMap();
|
|
2651
|
+
const NextNodeMap = new Map();
|
|
2652
|
+
const FilteredNodeMap = new Map();
|
|
2643
2653
|
let DraggingData = null;
|
|
2644
2654
|
function bindContainer(registerEvent, container, opts) {
|
|
2645
2655
|
registerEvent(container, "mousedown", (e) => {
|
|
@@ -2674,6 +2684,8 @@ function bindContainer(registerEvent, container, opts) {
|
|
|
2674
2684
|
let dragging = false;
|
|
2675
2685
|
let ghostNode = null;
|
|
2676
2686
|
let removeListenItems = null;
|
|
2687
|
+
NextNodeMap.set(draggingItem, draggingItem.nextElementSibling);
|
|
2688
|
+
FilteredNodeMap.set(con, filteredItems);
|
|
2677
2689
|
const dragListener = (ev) => {
|
|
2678
2690
|
const newX = ev.clientX;
|
|
2679
2691
|
const newY = ev.clientY;
|
|
@@ -2783,7 +2795,7 @@ function bindContainer(registerEvent, container, opts) {
|
|
|
2783
2795
|
}
|
|
2784
2796
|
else if (DraggingData.spill === 'revert') {
|
|
2785
2797
|
(_b = DraggingData.item.parentElement) === null || _b === void 0 ? void 0 : _b.removeChild(DraggingData.item);
|
|
2786
|
-
const nextSibling =
|
|
2798
|
+
const nextSibling = NextNodeMap.get(DraggingData.item);
|
|
2787
2799
|
DraggingData.fromContainer.insertBefore(DraggingData.item, nextSibling);
|
|
2788
2800
|
}
|
|
2789
2801
|
}
|
|
@@ -2863,12 +2875,17 @@ function bindContainer(registerEvent, container, opts) {
|
|
|
2863
2875
|
else {
|
|
2864
2876
|
if (draggingItem.parentElement)
|
|
2865
2877
|
draggingItem.parentElement.removeChild(draggingItem);
|
|
2878
|
+
const list = filter(FilteredNodeMap.get(container), x => x !== draggingItem);
|
|
2866
2879
|
if (dir[0] === "t") {
|
|
2867
|
-
container.insertBefore(draggingItem,
|
|
2880
|
+
container.insertBefore(draggingItem, list[0]);
|
|
2868
2881
|
}
|
|
2869
2882
|
else {
|
|
2870
|
-
container.
|
|
2871
|
-
|
|
2883
|
+
if (list.length !== container.children.length) {
|
|
2884
|
+
last(list).after(draggingItem);
|
|
2885
|
+
}
|
|
2886
|
+
else {
|
|
2887
|
+
container.appendChild(draggingItem);
|
|
2888
|
+
}
|
|
2872
2889
|
}
|
|
2873
2890
|
}
|
|
2874
2891
|
}
|
|
@@ -2947,7 +2964,7 @@ function newSortable(container, opts) {
|
|
|
2947
2964
|
return new Sortable(container, opts);
|
|
2948
2965
|
}
|
|
2949
2966
|
|
|
2950
|
-
var version = "1.3.
|
|
2967
|
+
var version = "1.3.5";
|
|
2951
2968
|
var repository = {
|
|
2952
2969
|
type: "git",
|
|
2953
2970
|
url: "https://github.com/holyhigh2/uiik"
|
package/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* uiik v1.3.
|
|
2
|
+
* uiik v1.3.5
|
|
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
|
|
6
6
|
*/
|
|
7
7
|
(function (global, factory) {
|
|
8
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('myfx/collection'), require('myfx/is'), require('myfx/object'), require('myfx/array'), require('myfx/string'), require('myfx/tree'), require('myfx/utils')) :
|
|
9
|
-
typeof define === 'function' && define.amd ? define(['exports', 'myfx/collection', 'myfx/is', 'myfx/object', 'myfx/array', 'myfx/string', 'myfx/tree', 'myfx/utils'], factory) :
|
|
10
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.uiik = {}, global.collection, global.is, global.object, global.array, global.string, global.tree, global.utils));
|
|
11
|
-
})(this, (function (exports, collection, is, object, array, string, tree, utils) { 'use strict';
|
|
8
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('myfx/collection'), require('myfx/is'), require('myfx/object'), require('myfx/array'), require('myfx/string'), require('myfx/tree'), require('myfx/utils'), require('myfx')) :
|
|
9
|
+
typeof define === 'function' && define.amd ? define(['exports', 'myfx/collection', 'myfx/is', 'myfx/object', 'myfx/array', 'myfx/string', 'myfx/tree', 'myfx/utils', 'myfx'], factory) :
|
|
10
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.uiik = {}, global.collection, global.is, global.object, global.array, global.string, global.tree, global.utils, global.myfx));
|
|
11
|
+
})(this, (function (exports, collection, is, object, array, string, tree, utils, myfx) { 'use strict';
|
|
12
12
|
|
|
13
13
|
/******************************************************************************
|
|
14
14
|
Copyright (c) Microsoft Corporation.
|
|
@@ -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
|
-
|
|
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
|
|
774
|
+
if (c.offsetTop > lastH + lastY) {
|
|
768
775
|
dir = 'v';
|
|
769
776
|
return false;
|
|
770
777
|
}
|
|
@@ -2638,6 +2645,8 @@
|
|
|
2638
2645
|
onOptionChanged() { }
|
|
2639
2646
|
}
|
|
2640
2647
|
_Sortable_removeListenItems = new WeakMap();
|
|
2648
|
+
const NextNodeMap = new Map();
|
|
2649
|
+
const FilteredNodeMap = new Map();
|
|
2641
2650
|
let DraggingData = null;
|
|
2642
2651
|
function bindContainer(registerEvent, container, opts) {
|
|
2643
2652
|
registerEvent(container, "mousedown", (e) => {
|
|
@@ -2672,6 +2681,8 @@
|
|
|
2672
2681
|
let dragging = false;
|
|
2673
2682
|
let ghostNode = null;
|
|
2674
2683
|
let removeListenItems = null;
|
|
2684
|
+
NextNodeMap.set(draggingItem, draggingItem.nextElementSibling);
|
|
2685
|
+
FilteredNodeMap.set(con, filteredItems);
|
|
2675
2686
|
const dragListener = (ev) => {
|
|
2676
2687
|
const newX = ev.clientX;
|
|
2677
2688
|
const newY = ev.clientY;
|
|
@@ -2781,7 +2792,7 @@
|
|
|
2781
2792
|
}
|
|
2782
2793
|
else if (DraggingData.spill === 'revert') {
|
|
2783
2794
|
(_b = DraggingData.item.parentElement) === null || _b === void 0 ? void 0 : _b.removeChild(DraggingData.item);
|
|
2784
|
-
const nextSibling =
|
|
2795
|
+
const nextSibling = NextNodeMap.get(DraggingData.item);
|
|
2785
2796
|
DraggingData.fromContainer.insertBefore(DraggingData.item, nextSibling);
|
|
2786
2797
|
}
|
|
2787
2798
|
}
|
|
@@ -2861,12 +2872,17 @@
|
|
|
2861
2872
|
else {
|
|
2862
2873
|
if (draggingItem.parentElement)
|
|
2863
2874
|
draggingItem.parentElement.removeChild(draggingItem);
|
|
2875
|
+
const list = myfx.filter(FilteredNodeMap.get(container), x => x !== draggingItem);
|
|
2864
2876
|
if (dir[0] === "t") {
|
|
2865
|
-
container.insertBefore(draggingItem,
|
|
2877
|
+
container.insertBefore(draggingItem, list[0]);
|
|
2866
2878
|
}
|
|
2867
2879
|
else {
|
|
2868
|
-
container.
|
|
2869
|
-
|
|
2880
|
+
if (list.length !== container.children.length) {
|
|
2881
|
+
myfx.last(list).after(draggingItem);
|
|
2882
|
+
}
|
|
2883
|
+
else {
|
|
2884
|
+
container.appendChild(draggingItem);
|
|
2885
|
+
}
|
|
2870
2886
|
}
|
|
2871
2887
|
}
|
|
2872
2888
|
}
|
|
@@ -2945,7 +2961,7 @@
|
|
|
2945
2961
|
return new Sortable(container, opts);
|
|
2946
2962
|
}
|
|
2947
2963
|
|
|
2948
|
-
var version = "1.3.
|
|
2964
|
+
var version = "1.3.5";
|
|
2949
2965
|
var repository = {
|
|
2950
2966
|
type: "git",
|
|
2951
2967
|
url: "https://github.com/holyhigh2/uiik"
|
package/package.json
CHANGED
package/types.d.ts
CHANGED