uiik 1.3.2 → 1.3.4

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 CHANGED
@@ -1,4 +1,7 @@
1
1
  # Changelog
2
+ ## [1.3.4] - 2025/8/24
3
+ ### 修复
4
+ - Sortable filter数据后spill表现异常
2
5
 
3
6
  ## [1.3.2] - 2024/4/6
4
7
  ### 修复
package/index.esm.js CHANGED
@@ -1,16 +1,17 @@
1
1
  /**
2
- * uiik v1.3.2
2
+ * uiik v1.3.4
3
3
  * A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.
4
4
  * https://github.com/holyhigh2/uiik
5
- * c) 2021-2024 @holyhigh2 may be freely distributed under the MIT license
5
+ * c) 2021-2025 @holyhigh2 may be freely distributed under the MIT license
6
6
  */
7
- import { isDefined, isNumber, isNaN, isString, isArrayLike, isElement, isEmpty, isArray, isFunction, isBoolean, isUndefined } from 'myfx/is';
8
7
  import { find, map, toArray, each, reject, includes, some, flatMap, size } from 'myfx/collection';
8
+ import { isDefined, isNumber, isNaN, isString, isArrayLike, isElement, isEmpty, isBlank, isArray, isFunction, isBoolean, isUndefined } from 'myfx/is';
9
9
  import { get, assign, merge } from 'myfx/object';
10
- import { split, test } from 'myfx/string';
11
10
  import { compact, findIndex } from 'myfx/array';
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.
@@ -486,6 +487,13 @@ function parseOxy(ox, oy, w, h, el) {
486
487
  function normalizeVector(x, y) {
487
488
  let len = Math.sqrt(x * x + y * y);
488
489
  return { x: x / len, y: y / len };
490
+ }
491
+ function isVisible(el) {
492
+ let rect = el.getBoundingClientRect();
493
+ if (rect.width === 0 || rect.height === 0) {
494
+ return false;
495
+ }
496
+ return true;
489
497
  }
490
498
 
491
499
  var _Uii_listeners;
@@ -693,7 +701,7 @@ class Splittable extends Uii {
693
701
  _Splittable_instances.add(this);
694
702
  each(this.ele, con => {
695
703
  const pos = window.getComputedStyle(con).position;
696
- if (pos === "static") {
704
+ if (pos === "static" || isBlank(pos)) {
697
705
  con.style.position = "relative";
698
706
  }
699
707
  con.classList.toggle(CLASS_SPLITTABLE, true);
@@ -766,7 +774,7 @@ _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Sp
766
774
  });
767
775
  return dir;
768
776
  }, _Splittable_bindHandle = function _Splittable_bindHandle(minSizeAry, stickyAry, opts, dir, dom1, dom2, handle) {
769
- var _a;
777
+ var _a, _b;
770
778
  const handleSize = opts.handleSize;
771
779
  if (!handle) {
772
780
  handle = document.createElement('div');
@@ -774,6 +782,12 @@ _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Sp
774
782
  if (!opts.inside) {
775
783
  initPos = (dir === 'v' ? dom2.offsetTop : dom2.offsetLeft);
776
784
  }
785
+ if (!isVisible(dom2)) {
786
+ (_a = dom2.parentElement) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', () => {
787
+ initPos = (dir === 'v' ? dom2.offsetTop : dom2.offsetLeft);
788
+ handle.style.left = initPos - handleSize / 2 + 'px';
789
+ }, { once: true });
790
+ }
777
791
  const sensorHCss = `width:${handleSize}px;height:100%;top:0;left:${initPos - handleSize / 2}px;z-index:9;`;
778
792
  const sensorVCss = `height:${handleSize}px;width:100%;left:0;top:${initPos - handleSize / 2}px;z-index:9;`;
779
793
  handle.style.cssText =
@@ -781,7 +795,7 @@ _Splittable_instances = new WeakSet(), _Splittable_checkDirection = function _Sp
781
795
  if (opts.inside) {
782
796
  dom2.appendChild(handle);
783
797
  }
784
- (_a = dom2.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(handle, dom2);
798
+ (_b = dom2.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(handle, dom2);
785
799
  }
786
800
  handle.style.cursor = dir === 'v' ? 's-resize' : 'e-resize';
787
801
  handle.dataset.cursor = handle.style.cursor;
@@ -2627,6 +2641,8 @@ class Sortable extends Uii {
2627
2641
  onOptionChanged() { }
2628
2642
  }
2629
2643
  _Sortable_removeListenItems = new WeakMap();
2644
+ const NextNodeMap = new Map();
2645
+ const FilteredNodeMap = new Map();
2630
2646
  let DraggingData = null;
2631
2647
  function bindContainer(registerEvent, container, opts) {
2632
2648
  registerEvent(container, "mousedown", (e) => {
@@ -2661,6 +2677,8 @@ function bindContainer(registerEvent, container, opts) {
2661
2677
  let dragging = false;
2662
2678
  let ghostNode = null;
2663
2679
  let removeListenItems = null;
2680
+ NextNodeMap.set(draggingItem, draggingItem.nextElementSibling);
2681
+ FilteredNodeMap.set(con, filteredItems);
2664
2682
  const dragListener = (ev) => {
2665
2683
  const newX = ev.clientX;
2666
2684
  const newY = ev.clientY;
@@ -2770,7 +2788,7 @@ function bindContainer(registerEvent, container, opts) {
2770
2788
  }
2771
2789
  else if (DraggingData.spill === 'revert') {
2772
2790
  (_b = DraggingData.item.parentElement) === null || _b === void 0 ? void 0 : _b.removeChild(DraggingData.item);
2773
- const nextSibling = DraggingData.fromContainer.children[DraggingData.fromIndex];
2791
+ const nextSibling = NextNodeMap.get(DraggingData.item);
2774
2792
  DraggingData.fromContainer.insertBefore(DraggingData.item, nextSibling);
2775
2793
  }
2776
2794
  }
@@ -2850,12 +2868,17 @@ function bindContainer(registerEvent, container, opts) {
2850
2868
  else {
2851
2869
  if (draggingItem.parentElement)
2852
2870
  draggingItem.parentElement.removeChild(draggingItem);
2871
+ const list = filter(FilteredNodeMap.get(container), x => x !== draggingItem);
2853
2872
  if (dir[0] === "t") {
2854
- container.insertBefore(draggingItem, container.children[0]);
2873
+ container.insertBefore(draggingItem, list[0]);
2855
2874
  }
2856
2875
  else {
2857
- container.appendChild(draggingItem);
2858
- container.children.length - 1;
2876
+ if (list.length !== container.children.length) {
2877
+ last(list).after(draggingItem);
2878
+ }
2879
+ else {
2880
+ container.appendChild(draggingItem);
2881
+ }
2859
2882
  }
2860
2883
  }
2861
2884
  }
@@ -2934,7 +2957,7 @@ function newSortable(container, opts) {
2934
2957
  return new Sortable(container, opts);
2935
2958
  }
2936
2959
 
2937
- var version = "1.3.2";
2960
+ var version = "1.3.4";
2938
2961
  var repository = {
2939
2962
  type: "git",
2940
2963
  url: "https://github.com/holyhigh2/uiik"
@@ -2967,4 +2990,4 @@ var index = {
2967
2990
  newSortable
2968
2991
  };
2969
2992
 
2970
- export { CollisionDetector, DRAGGING_RULE, Draggable, Droppable, EDGE_THRESHOLD, ONE_ANG, ONE_RAD, Resizable, Rotatable, Selectable, Sortable, Splittable, THRESHOLD, Uii, UiiTransform, VERSION, calcVertex, index as default, getBox, getCenterXy, getCenterXySVG, getMatrixInfo, getPointInContainer, getPointOffset, getRectCenter, getRectInContainer, getStyleSize, getStyleXy, getTranslate, getVertex, isSVGEl, lockPage, moveBy, moveTo, newCollisionDetector, newDraggable, newDroppable, newResizable, newRotatable, newSelectable, newSortable, newSplittable, normalizeVector, parseOxy, restoreCursor, rotateTo, saveCursor, setCursor, transformMoveTo, unlockPage, wrapper };
2993
+ export { CollisionDetector, DRAGGING_RULE, Draggable, Droppable, EDGE_THRESHOLD, ONE_ANG, ONE_RAD, Resizable, Rotatable, Selectable, Sortable, Splittable, THRESHOLD, Uii, UiiTransform, VERSION, calcVertex, index as default, getBox, getCenterXy, getCenterXySVG, getMatrixInfo, getPointInContainer, getPointOffset, getRectCenter, getRectInContainer, getStyleSize, getStyleXy, getTranslate, getVertex, isSVGEl, isVisible, lockPage, moveBy, moveTo, newCollisionDetector, newDraggable, newDroppable, newResizable, newRotatable, newSelectable, newSortable, newSplittable, normalizeVector, parseOxy, restoreCursor, rotateTo, saveCursor, setCursor, transformMoveTo, unlockPage, wrapper };
package/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  /**
2
- * uiik v1.3.2
2
+ * uiik v1.3.4
3
3
  * A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.
4
4
  * https://github.com/holyhigh2/uiik
5
- * c) 2021-2024 @holyhigh2 may be freely distributed under the MIT license
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/is'), require('myfx/collection'), require('myfx/object'), require('myfx/string'), require('myfx/array'), require('myfx/tree'), require('myfx/utils')) :
9
- typeof define === 'function' && define.amd ? define(['exports', 'myfx/is', 'myfx/collection', 'myfx/object', 'myfx/string', 'myfx/array', 'myfx/tree', 'myfx/utils'], factory) :
10
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.uiik = {}, global.is, global.collection, global.object, global.string, global.array, global.tree, global.utils));
11
- })(this, (function (exports, is, collection, object, string, array, 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.
@@ -484,6 +484,13 @@
484
484
  function normalizeVector(x, y) {
485
485
  let len = Math.sqrt(x * x + y * y);
486
486
  return { x: x / len, y: y / len };
487
+ }
488
+ function isVisible(el) {
489
+ let rect = el.getBoundingClientRect();
490
+ if (rect.width === 0 || rect.height === 0) {
491
+ return false;
492
+ }
493
+ return true;
487
494
  }
488
495
 
489
496
  var _Uii_listeners;
@@ -691,7 +698,7 @@
691
698
  _Splittable_instances.add(this);
692
699
  collection.each(this.ele, con => {
693
700
  const pos = window.getComputedStyle(con).position;
694
- if (pos === "static") {
701
+ if (pos === "static" || is.isBlank(pos)) {
695
702
  con.style.position = "relative";
696
703
  }
697
704
  con.classList.toggle(CLASS_SPLITTABLE, true);
@@ -764,7 +771,7 @@
764
771
  });
765
772
  return dir;
766
773
  }, _Splittable_bindHandle = function _Splittable_bindHandle(minSizeAry, stickyAry, opts, dir, dom1, dom2, handle) {
767
- var _a;
774
+ var _a, _b;
768
775
  const handleSize = opts.handleSize;
769
776
  if (!handle) {
770
777
  handle = document.createElement('div');
@@ -772,6 +779,12 @@
772
779
  if (!opts.inside) {
773
780
  initPos = (dir === 'v' ? dom2.offsetTop : dom2.offsetLeft);
774
781
  }
782
+ if (!isVisible(dom2)) {
783
+ (_a = dom2.parentElement) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', () => {
784
+ initPos = (dir === 'v' ? dom2.offsetTop : dom2.offsetLeft);
785
+ handle.style.left = initPos - handleSize / 2 + 'px';
786
+ }, { once: true });
787
+ }
775
788
  const sensorHCss = `width:${handleSize}px;height:100%;top:0;left:${initPos - handleSize / 2}px;z-index:9;`;
776
789
  const sensorVCss = `height:${handleSize}px;width:100%;left:0;top:${initPos - handleSize / 2}px;z-index:9;`;
777
790
  handle.style.cssText =
@@ -779,7 +792,7 @@
779
792
  if (opts.inside) {
780
793
  dom2.appendChild(handle);
781
794
  }
782
- (_a = dom2.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(handle, dom2);
795
+ (_b = dom2.parentNode) === null || _b === void 0 ? void 0 : _b.insertBefore(handle, dom2);
783
796
  }
784
797
  handle.style.cursor = dir === 'v' ? 's-resize' : 'e-resize';
785
798
  handle.dataset.cursor = handle.style.cursor;
@@ -2625,6 +2638,8 @@
2625
2638
  onOptionChanged() { }
2626
2639
  }
2627
2640
  _Sortable_removeListenItems = new WeakMap();
2641
+ const NextNodeMap = new Map();
2642
+ const FilteredNodeMap = new Map();
2628
2643
  let DraggingData = null;
2629
2644
  function bindContainer(registerEvent, container, opts) {
2630
2645
  registerEvent(container, "mousedown", (e) => {
@@ -2659,6 +2674,8 @@
2659
2674
  let dragging = false;
2660
2675
  let ghostNode = null;
2661
2676
  let removeListenItems = null;
2677
+ NextNodeMap.set(draggingItem, draggingItem.nextElementSibling);
2678
+ FilteredNodeMap.set(con, filteredItems);
2662
2679
  const dragListener = (ev) => {
2663
2680
  const newX = ev.clientX;
2664
2681
  const newY = ev.clientY;
@@ -2768,7 +2785,7 @@
2768
2785
  }
2769
2786
  else if (DraggingData.spill === 'revert') {
2770
2787
  (_b = DraggingData.item.parentElement) === null || _b === void 0 ? void 0 : _b.removeChild(DraggingData.item);
2771
- const nextSibling = DraggingData.fromContainer.children[DraggingData.fromIndex];
2788
+ const nextSibling = NextNodeMap.get(DraggingData.item);
2772
2789
  DraggingData.fromContainer.insertBefore(DraggingData.item, nextSibling);
2773
2790
  }
2774
2791
  }
@@ -2848,12 +2865,17 @@
2848
2865
  else {
2849
2866
  if (draggingItem.parentElement)
2850
2867
  draggingItem.parentElement.removeChild(draggingItem);
2868
+ const list = myfx.filter(FilteredNodeMap.get(container), x => x !== draggingItem);
2851
2869
  if (dir[0] === "t") {
2852
- container.insertBefore(draggingItem, container.children[0]);
2870
+ container.insertBefore(draggingItem, list[0]);
2853
2871
  }
2854
2872
  else {
2855
- container.appendChild(draggingItem);
2856
- container.children.length - 1;
2873
+ if (list.length !== container.children.length) {
2874
+ myfx.last(list).after(draggingItem);
2875
+ }
2876
+ else {
2877
+ container.appendChild(draggingItem);
2878
+ }
2857
2879
  }
2858
2880
  }
2859
2881
  }
@@ -2932,7 +2954,7 @@
2932
2954
  return new Sortable(container, opts);
2933
2955
  }
2934
2956
 
2935
- var version = "1.3.2";
2957
+ var version = "1.3.4";
2936
2958
  var repository = {
2937
2959
  type: "git",
2938
2960
  url: "https://github.com/holyhigh2/uiik"
@@ -2996,6 +3018,7 @@
2996
3018
  exports.getTranslate = getTranslate;
2997
3019
  exports.getVertex = getVertex;
2998
3020
  exports.isSVGEl = isSVGEl;
3021
+ exports.isVisible = isVisible;
2999
3022
  exports.lockPage = lockPage;
3000
3023
  exports.moveBy = moveBy;
3001
3024
  exports.moveTo = moveTo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uiik",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "A UI interactions kit includes draggable, splittable, rotatable, selectable, etc.",
5
5
  "main": "index.js",
6
6
  "module": "index.esm.js",
@@ -32,7 +32,7 @@
32
32
  "doc": "npx typedoc"
33
33
  },
34
34
  "dependencies": {
35
- "myfx":">=1.1.0"
35
+ "myfx": ">=1.1.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@babel/core": "^7.12.3",
package/utils.d.ts CHANGED
@@ -89,3 +89,4 @@ export declare function normalizeVector(x: number, y: number): {
89
89
  x: number;
90
90
  y: number;
91
91
  };
92
+ export declare function isVisible(el: Element): boolean;