@vuu-ui/vuu-utils 0.13.16 → 0.13.18

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.
@@ -2,8 +2,8 @@
2
2
 
3
3
  var index = require('../abstract/index.js');
4
4
  var utilities = require('./utilities.js');
5
- var index$2 = require('../state/dist/index.js');
6
- var index$1 = require('../geometry/dist/index.js');
5
+ var index$1 = require('../state/dist/index.js');
6
+ var index$2 = require('../geometry/dist/index.js');
7
7
  var index$3 = require('../collision/dist/index.js');
8
8
  var signalsCore = require('../../@preact/signals-core/dist/signals-core.js');
9
9
 
@@ -303,7 +303,7 @@ var Cursor = class extends index.Plugin {
303
303
  constructor(manager, options) {
304
304
  super(manager, options);
305
305
  this.manager = manager;
306
- const doc = index$2.computed(
306
+ const doc = index$1.computed(
307
307
  () => {
308
308
  var _a4;
309
309
  return utilities.getDocument((_a4 = this.manager.dragOperation.source) == null ? void 0 : _a4.element);
@@ -469,7 +469,7 @@ function isTableRow(element) {
469
469
  // src/core/plugins/feedback/Feedback.ts
470
470
  var styleSheetRegistry = /* @__PURE__ */ new Map();
471
471
  var _overlay_dec, _a, _init, _overlay, _Feedback_instances, render_fn, injectStyles_fn;
472
- var _Feedback = class _Feedback extends (_a = index.Plugin, _overlay_dec = [index$2.reactive], _a) {
472
+ var _Feedback = class _Feedback extends (_a = index.Plugin, _overlay_dec = [index$1.reactive], _a) {
473
473
  constructor(manager, options) {
474
474
  super(manager, options);
475
475
  __privateAdd(this, _Feedback_instances);
@@ -525,7 +525,6 @@ render_fn = function() {
525
525
  x: elementFrameTransform.scaleX / frameTransform.scaleX,
526
526
  y: elementFrameTransform.scaleY / frameTransform.scaleY
527
527
  };
528
- let cleanup;
529
528
  let { width, height, top, left } = shape;
530
529
  if (crossFrame) {
531
530
  width = width / scaleDelta.x;
@@ -750,48 +749,6 @@ render_fn = function() {
750
749
  subtree: true
751
750
  });
752
751
  }
753
- const cleanupEffect = signalsCore.effect(() => {
754
- var _a5;
755
- const { transform: transform2, status: status2 } = dragOperation;
756
- if (!transform2.x && !transform2.y && !state.current.translate) {
757
- return;
758
- }
759
- if (status2.dragging) {
760
- const initialTranslate2 = (_a5 = initial.translate) != null ? _a5 : { x: 0, y: 0 };
761
- const translate2 = {
762
- x: transform2.x / frameTransform.scaleX + initialTranslate2.x,
763
- y: transform2.y / frameTransform.scaleY + initialTranslate2.y
764
- };
765
- const previousTranslate = state.current.translate;
766
- const modifiers = signalsCore.untracked(() => dragOperation.modifiers);
767
- const currentShape = signalsCore.untracked(() => {
768
- var _a6;
769
- return (_a6 = dragOperation.shape) == null ? void 0 : _a6.current;
770
- });
771
- const translateTransition = isKeyboardOperation ? "250ms cubic-bezier(0.25, 1, 0.5, 1)" : "0ms linear";
772
- styles.set(
773
- {
774
- transition: `${transition}, translate ${translateTransition}`,
775
- translate: `${translate2.x}px ${translate2.y}px 0`
776
- },
777
- CSS_PREFIX
778
- );
779
- elementMutationObserver == null ? void 0 : elementMutationObserver.takeRecords();
780
- if (currentShape && currentShape !== initialShape && previousTranslate && !modifiers.length) {
781
- const delta2 = index$1.Point.delta(translate2, previousTranslate);
782
- dragOperation.shape = index$1.Rectangle.from(
783
- currentShape.boundingRectangle
784
- ).translate(
785
- // Need to take into account frame transform when optimistically updating shape
786
- delta2.x * frameTransform.scaleX,
787
- delta2.y * frameTransform.scaleY
788
- );
789
- } else {
790
- dragOperation.shape = new utilities.DOMRectangle(feedbackElement);
791
- }
792
- state.current.translate = translate2;
793
- }
794
- });
795
752
  const id = (_c3 = manager.dragOperation.source) == null ? void 0 : _c3.id;
796
753
  const restoreFocus = () => {
797
754
  var _a5;
@@ -804,8 +761,7 @@ render_fn = function() {
804
761
  element2.focus();
805
762
  }
806
763
  };
807
- let dropEffectCleanup;
808
- cleanup = () => {
764
+ const cleanup = () => {
809
765
  elementMutationObserver == null ? void 0 : elementMutationObserver.disconnect();
810
766
  documentMutationObserver == null ? void 0 : documentMutationObserver.disconnect();
811
767
  resizeObserver.disconnect();
@@ -825,95 +781,140 @@ render_fn = function() {
825
781
  placeholder.replaceWith(feedbackElement);
826
782
  }
827
783
  placeholder == null ? void 0 : placeholder.remove();
828
- cleanupEffect();
829
- dropEffectCleanup == null ? void 0 : dropEffectCleanup();
830
784
  };
831
- dropEffectCleanup = signalsCore.effect(() => {
832
- if (dragOperation.status.dropped) {
833
- queueMicrotask(() => dropEffectCleanup == null ? void 0 : dropEffectCleanup());
834
- const onComplete = cleanup;
835
- cleanup = void 0;
836
- source.status = "dropping";
837
- let translate2 = state.current.translate;
838
- const moved = translate2 != null;
839
- if (!translate2 && element !== feedbackElement) {
840
- translate2 = {
841
- x: 0,
842
- y: 0
843
- };
844
- }
845
- if (!translate2) {
846
- onComplete == null ? void 0 : onComplete();
785
+ const cleanupEffects = index$1.effects(
786
+ // Update transform on move
787
+ () => {
788
+ var _a5;
789
+ const { transform: transform2, status: status2 } = dragOperation;
790
+ if (!transform2.x && !transform2.y && !state.current.translate) {
847
791
  return;
848
792
  }
849
- const dropAnimation = () => {
850
- var _a5, _b3;
851
- {
852
- utilities.showPopover(feedbackElement);
853
- const [, animation] = (_a5 = utilities.getFinalKeyframe(
854
- feedbackElement,
855
- (keyframe) => "translate" in keyframe
856
- )) != null ? _a5 : [];
857
- animation == null ? void 0 : animation.pause();
858
- const target = placeholder != null ? placeholder : element;
859
- const options2 = {
860
- frameTransform: isSameFrame(feedbackElement, target) ? null : void 0
861
- };
862
- const current = new utilities.DOMRectangle(feedbackElement, options2);
863
- const currentTranslate = (_b3 = utilities.parseTranslate(utilities.getComputedStyles(feedbackElement).translate)) != null ? _b3 : translate2;
864
- const final = new utilities.DOMRectangle(target, options2);
865
- const delta2 = index$1.Rectangle.delta(current, final, source.alignment);
866
- const finalTranslate = {
867
- x: currentTranslate.x - delta2.x,
868
- y: currentTranslate.y - delta2.y
793
+ if (status2.dragging) {
794
+ const initialTranslate2 = (_a5 = initial.translate) != null ? _a5 : { x: 0, y: 0 };
795
+ const translate2 = {
796
+ x: transform2.x / frameTransform.scaleX + initialTranslate2.x,
797
+ y: transform2.y / frameTransform.scaleY + initialTranslate2.y
798
+ };
799
+ const previousTranslate = state.current.translate;
800
+ const modifiers = signalsCore.untracked(() => dragOperation.modifiers);
801
+ const currentShape = signalsCore.untracked(() => {
802
+ var _a6;
803
+ return (_a6 = dragOperation.shape) == null ? void 0 : _a6.current;
804
+ });
805
+ const translateTransition = isKeyboardOperation ? "250ms cubic-bezier(0.25, 1, 0.5, 1)" : "0ms linear";
806
+ styles.set(
807
+ {
808
+ transition: `${transition}, translate ${translateTransition}`,
809
+ translate: `${translate2.x}px ${translate2.y}px 0`
810
+ },
811
+ CSS_PREFIX
812
+ );
813
+ elementMutationObserver == null ? void 0 : elementMutationObserver.takeRecords();
814
+ if (currentShape && currentShape !== initialShape && previousTranslate && !modifiers.length) {
815
+ const delta2 = index$2.Point.delta(translate2, previousTranslate);
816
+ dragOperation.shape = index$2.Rectangle.from(
817
+ currentShape.boundingRectangle
818
+ ).translate(
819
+ // Need to take into account frame transform when optimistically updating shape
820
+ delta2.x * frameTransform.scaleX,
821
+ delta2.y * frameTransform.scaleY
822
+ );
823
+ } else {
824
+ dragOperation.shape = new utilities.DOMRectangle(feedbackElement);
825
+ }
826
+ state.current.translate = translate2;
827
+ }
828
+ },
829
+ // Drop animation
830
+ function() {
831
+ if (dragOperation.status.dropped) {
832
+ this.dispose();
833
+ source.status = "dropping";
834
+ let translate2 = state.current.translate;
835
+ const moved = translate2 != null;
836
+ if (!translate2 && element !== feedbackElement) {
837
+ translate2 = {
838
+ x: 0,
839
+ y: 0
869
840
  };
870
- const heightKeyframes = Math.round(current.intrinsicHeight) !== Math.round(final.intrinsicHeight) ? {
871
- minHeight: [
872
- `${current.intrinsicHeight}px`,
873
- `${final.intrinsicHeight}px`
874
- ],
875
- maxHeight: [
876
- `${current.intrinsicHeight}px`,
877
- `${final.intrinsicHeight}px`
878
- ]
879
- } : {};
880
- const widthKeyframes = Math.round(current.intrinsicWidth) !== Math.round(final.intrinsicWidth) ? {
881
- minWidth: [
882
- `${current.intrinsicWidth}px`,
883
- `${final.intrinsicWidth}px`
884
- ],
885
- maxWidth: [
886
- `${current.intrinsicWidth}px`,
887
- `${final.intrinsicWidth}px`
888
- ]
889
- } : {};
890
- styles.set({ transition }, CSS_PREFIX);
891
- feedbackElement.setAttribute(DROPPING_ATTRIBUTE, "");
892
- elementMutationObserver == null ? void 0 : elementMutationObserver.takeRecords();
893
- utilities.animateTransform({
894
- element: feedbackElement,
895
- keyframes: __spreadProps(__spreadValues(__spreadValues({}, heightKeyframes), widthKeyframes), {
896
- translate: [
897
- `${currentTranslate.x}px ${currentTranslate.y}px 0`,
898
- `${finalTranslate.x}px ${finalTranslate.y}px 0`
899
- ]
900
- }),
901
- options: {
902
- duration: moved || feedbackElement !== element ? 250 : 0,
903
- easing: "ease"
904
- }
905
- }).then(() => {
906
- feedbackElement.removeAttribute(DROPPING_ATTRIBUTE);
907
- animation == null ? void 0 : animation.finish();
908
- onComplete == null ? void 0 : onComplete();
909
- requestAnimationFrame(restoreFocus);
910
- });
911
841
  }
912
- };
913
- manager.renderer.rendering.then(dropAnimation);
842
+ if (!translate2) {
843
+ cleanup();
844
+ return;
845
+ }
846
+ const dropAnimation = () => {
847
+ var _a5, _b3;
848
+ {
849
+ utilities.showPopover(feedbackElement);
850
+ const [, animation] = (_a5 = utilities.getFinalKeyframe(
851
+ feedbackElement,
852
+ (keyframe) => "translate" in keyframe
853
+ )) != null ? _a5 : [];
854
+ animation == null ? void 0 : animation.pause();
855
+ const target = placeholder != null ? placeholder : element;
856
+ const options2 = {
857
+ frameTransform: isSameFrame(feedbackElement, target) ? null : void 0
858
+ };
859
+ const current = new utilities.DOMRectangle(feedbackElement, options2);
860
+ const currentTranslate = (_b3 = utilities.parseTranslate(utilities.getComputedStyles(feedbackElement).translate)) != null ? _b3 : translate2;
861
+ const final = new utilities.DOMRectangle(target, options2);
862
+ const delta2 = index$2.Rectangle.delta(current, final, source.alignment);
863
+ const finalTranslate = {
864
+ x: currentTranslate.x - delta2.x,
865
+ y: currentTranslate.y - delta2.y
866
+ };
867
+ const heightKeyframes = Math.round(current.intrinsicHeight) !== Math.round(final.intrinsicHeight) ? {
868
+ minHeight: [
869
+ `${current.intrinsicHeight}px`,
870
+ `${final.intrinsicHeight}px`
871
+ ],
872
+ maxHeight: [
873
+ `${current.intrinsicHeight}px`,
874
+ `${final.intrinsicHeight}px`
875
+ ]
876
+ } : {};
877
+ const widthKeyframes = Math.round(current.intrinsicWidth) !== Math.round(final.intrinsicWidth) ? {
878
+ minWidth: [
879
+ `${current.intrinsicWidth}px`,
880
+ `${final.intrinsicWidth}px`
881
+ ],
882
+ maxWidth: [
883
+ `${current.intrinsicWidth}px`,
884
+ `${final.intrinsicWidth}px`
885
+ ]
886
+ } : {};
887
+ styles.set({ transition }, CSS_PREFIX);
888
+ feedbackElement.setAttribute(DROPPING_ATTRIBUTE, "");
889
+ elementMutationObserver == null ? void 0 : elementMutationObserver.takeRecords();
890
+ utilities.animateTransform({
891
+ element: feedbackElement,
892
+ keyframes: __spreadProps(__spreadValues(__spreadValues({}, heightKeyframes), widthKeyframes), {
893
+ translate: [
894
+ `${currentTranslate.x}px ${currentTranslate.y}px 0`,
895
+ `${finalTranslate.x}px ${finalTranslate.y}px 0`
896
+ ]
897
+ }),
898
+ options: {
899
+ duration: moved || feedbackElement !== element ? 250 : 0,
900
+ easing: "ease"
901
+ }
902
+ }).then(() => {
903
+ feedbackElement.removeAttribute(DROPPING_ATTRIBUTE);
904
+ animation == null ? void 0 : animation.finish();
905
+ cleanup();
906
+ requestAnimationFrame(restoreFocus);
907
+ });
908
+ }
909
+ };
910
+ manager.renderer.rendering.then(dropAnimation);
911
+ }
914
912
  }
915
- });
916
- return () => cleanup == null ? void 0 : cleanup();
913
+ );
914
+ return () => {
915
+ cleanup();
916
+ cleanupEffects();
917
+ };
917
918
  };
918
919
  injectStyles_fn = function() {
919
920
  var _a4, _b2;
@@ -959,7 +960,7 @@ var Feedback = _Feedback;
959
960
  var LOCKED = true;
960
961
  var UNLOCKED = false;
961
962
  var _dec, _a2, _dec2, _b, _init2, __b, __a;
962
- _b = (_dec2 = [index$2.reactive], utilities.ScrollDirection.Forward), _a2 = (_dec = [index$2.reactive], utilities.ScrollDirection.Reverse);
963
+ _b = (_dec2 = [index$1.reactive], utilities.ScrollDirection.Forward), _a2 = (_dec = [index$1.reactive], utilities.ScrollDirection.Reverse);
963
964
  var ScrollLock = class {
964
965
  constructor() {
965
966
  __privateAdd(this, __b, __runInitializers(_init2, 8, this, LOCKED)), __runInitializers(_init2, 11, this);
@@ -1020,7 +1021,7 @@ var ScrollIntentTracker = class extends index.Plugin {
1020
1021
  };
1021
1022
  const intent = scrollIntent.peek();
1022
1023
  signalsCore.batch(() => {
1023
- for (const axis of index$1.Axes) {
1024
+ for (const axis of index$2.Axes) {
1024
1025
  for (const direction of DIRECTIONS) {
1025
1026
  if (directions[axis] === direction) {
1026
1027
  intent[axis].unlock(direction);
@@ -1043,7 +1044,7 @@ function getDirection(a, b) {
1043
1044
 
1044
1045
  // src/core/plugins/scrolling/Scroller.ts
1045
1046
  var _autoScrolling_dec, _a3, _init3, _autoScrolling, _meta, _scroll;
1046
- var Scroller = class extends (_a3 = index.CorePlugin, _autoScrolling_dec = [index$2.reactive], _a3) {
1047
+ var Scroller = class extends (_a3 = index.CorePlugin, _autoScrolling_dec = [index$1.reactive], _a3) {
1047
1048
  constructor(manager) {
1048
1049
  super(manager);
1049
1050
  __privateAdd(this, _autoScrolling, __runInitializers(_init3, 8, this, false)), __runInitializers(_init3, 11, this);
@@ -1087,7 +1088,7 @@ var Scroller = class extends (_a3 = index.CorePlugin, _autoScrolling_dec = [inde
1087
1088
  intent
1088
1089
  );
1089
1090
  if (scrollIntent) {
1090
- for (const axis of index$1.Axes) {
1091
+ for (const axis of index$2.Axes) {
1091
1092
  if (scrollIntent[axis].isLocked(direction[axis])) {
1092
1093
  speed[axis] = 0;
1093
1094
  direction[axis] = 0;
@@ -1123,7 +1124,7 @@ var Scroller = class extends (_a3 = index.CorePlugin, _autoScrolling_dec = [inde
1123
1124
  };
1124
1125
  let previousElementFromPoint = null;
1125
1126
  let previousScrollableElements = null;
1126
- const elementFromPoint = index$2.computed(() => {
1127
+ const elementFromPoint = index$1.computed(() => {
1127
1128
  const { position, source } = manager.dragOperation;
1128
1129
  if (!position) {
1129
1130
  return null;
@@ -1137,7 +1138,7 @@ var Scroller = class extends (_a3 = index.CorePlugin, _autoScrolling_dec = [inde
1137
1138
  }
1138
1139
  return element != null ? element : previousElementFromPoint;
1139
1140
  });
1140
- const scrollableElements = index$2.computed(() => {
1141
+ const scrollableElements = index$1.computed(() => {
1141
1142
  const element = elementFromPoint.value;
1142
1143
  const { documentElement } = utilities.getDocument(element);
1143
1144
  if (!element || element === documentElement) {
@@ -1163,7 +1164,7 @@ var Scroller = class extends (_a3 = index.CorePlugin, _autoScrolling_dec = [inde
1163
1164
  }
1164
1165
  previousScrollableElements = null;
1165
1166
  return null;
1166
- }, index$2.deepEqual);
1167
+ }, index$1.deepEqual);
1167
1168
  this.getScrollableElements = () => {
1168
1169
  return scrollableElements.value;
1169
1170
  };
@@ -1679,15 +1680,15 @@ var _PointerSensor = class _PointerSensor extends index.Sensor {
1679
1680
  const constraints = this.activationConstraints(event, source);
1680
1681
  const { distance, delay } = constraints != null ? constraints : {};
1681
1682
  if (distance) {
1682
- if (distance.tolerance != null && index$1.exceedsDistance(delta, distance.tolerance)) {
1683
+ if (distance.tolerance != null && index$2.exceedsDistance(delta, distance.tolerance)) {
1683
1684
  return this.handleCancel(event);
1684
1685
  }
1685
- if (index$1.exceedsDistance(delta, distance.value)) {
1686
+ if (index$2.exceedsDistance(delta, distance.value)) {
1686
1687
  return this.handleStart(source, event);
1687
1688
  }
1688
1689
  }
1689
1690
  if (delay) {
1690
- if (index$1.exceedsDistance(delta, delay.tolerance)) {
1691
+ if (index$2.exceedsDistance(delta, delay.tolerance)) {
1691
1692
  return this.handleCancel(event);
1692
1693
  }
1693
1694
  }
@@ -1826,11 +1827,11 @@ var DragDropManager = class extends index.DragDropManager {
1826
1827
  }
1827
1828
  };
1828
1829
  var _feedback_dec, _element_dec, _handle_dec, _c, _init4, _handle, _element, _feedback;
1829
- var Draggable = class extends (_c = index.Draggable, _handle_dec = [index$2.reactive], _element_dec = [index$2.reactive], _feedback_dec = [index$2.reactive], _c) {
1830
+ var Draggable = class extends (_c = index.Draggable, _handle_dec = [index$1.reactive], _element_dec = [index$1.reactive], _feedback_dec = [index$1.reactive], _c) {
1830
1831
  constructor(_a4, manager) {
1831
1832
  var _b2 = _a4, {
1832
1833
  element,
1833
- effects = () => [],
1834
+ effects: effects2 = () => [],
1834
1835
  handle,
1835
1836
  feedback = "default"
1836
1837
  } = _b2, input = __objRest(_b2, [
@@ -1842,7 +1843,7 @@ var Draggable = class extends (_c = index.Draggable, _handle_dec = [index$2.reac
1842
1843
  super(
1843
1844
  __spreadValues({
1844
1845
  effects: () => [
1845
- ...effects(),
1846
+ ...effects2(),
1846
1847
  () => {
1847
1848
  var _a5, _b3;
1848
1849
  const { manager: manager2 } = this;
@@ -1881,9 +1882,9 @@ __decorateElement(_init4, 4, "element", _element_dec, Draggable, _element);
1881
1882
  __decorateElement(_init4, 4, "feedback", _feedback_dec, Draggable, _feedback);
1882
1883
  __decoratorMetadata(_init4, Draggable);
1883
1884
  var _proxy_dec, _element_dec2, _c2, _init5, _element2, _d, element_get, element_set, _Droppable_instances, _proxy;
1884
- var Droppable = class extends (_c2 = index.Droppable, _element_dec2 = [index$2.reactive], _proxy_dec = [index$2.reactive], _c2) {
1885
+ var Droppable = class extends (_c2 = index.Droppable, _element_dec2 = [index$1.reactive], _proxy_dec = [index$1.reactive], _c2) {
1885
1886
  constructor(_a4, manager) {
1886
- var _b2 = _a4, { element, effects = () => [] } = _b2, input = __objRest(_b2, ["element", "effects"]);
1887
+ var _b2 = _a4, { element, effects: effects2 = () => [] } = _b2, input = __objRest(_b2, ["element", "effects"]);
1887
1888
  const { collisionDetector = index$3.defaultCollisionDetection } = input;
1888
1889
  const updateShape = (boundingClientRect) => {
1889
1890
  const { manager: manager2, element: element2 } = this;
@@ -1905,7 +1906,7 @@ var Droppable = class extends (_c2 = index.Droppable, _element_dec2 = [index$2.r
1905
1906
  __spreadProps(__spreadValues({}, input), {
1906
1907
  collisionDetector,
1907
1908
  effects: () => [
1908
- ...effects(),
1909
+ ...effects2(),
1909
1910
  () => {
1910
1911
  const { element: element2, manager: manager2 } = this;
1911
1912
  if (!manager2) return;