@vvfx/sdk 0.2.2-beta.6 → 0.2.2-beta.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/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: TODO
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 赤芍,何即,不择,意绮
6
- * Version: v0.2.2-beta.6
6
+ * Version: v0.2.2-beta.7
7
7
  */
8
8
 
9
9
  'use strict';
@@ -91932,8 +91932,8 @@ function mountHTMLShell(container, content, shell) {
91932
91932
  var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
91933
91933
  var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
91934
91934
  var CONTENT_INTERACTIVE_SELECTOR = [
91935
- '[data-interaction-zone="self"]',
91936
91935
  '[data-vvfx-html-interaction-zone="self"]',
91936
+ '[data-vvfx-html-interaction-zone="subtree"]',
91937
91937
  'a[href]',
91938
91938
  'button:not([disabled])',
91939
91939
  'input:not([disabled])',
@@ -91949,7 +91949,6 @@ var CONTENT_INTERACTIVE_SELECTOR = [
91949
91949
  '[tabindex]:not([tabindex="-1"])'
91950
91950
  ].join(', ');
91951
91951
  var CONTENT_INTERACTION_NONE_SELECTOR = [
91952
- '[data-interaction-zone="none"]',
91953
91952
  '[data-vvfx-html-interaction-zone="none"]'
91954
91953
  ].join(', ');
91955
91954
  var EDITING_VIEWPORT_PADDING = 48;
@@ -92023,7 +92022,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92023
92022
  _this.syncContentInteraction(hoverShellInteractiveId);
92024
92023
  }
92025
92024
  };
92026
- this.handleContainerMouseLeave = function() {
92025
+ this.handleContainerMouseLeave = function(event) {
92026
+ if (_this.isMouseLeaveWithinContainer(event)) {
92027
+ return;
92028
+ }
92027
92029
  if (_this.contentInteractionFrame !== undefined) {
92028
92030
  cancelAnimationFrame(_this.contentInteractionFrame);
92029
92031
  _this.contentInteractionFrame = undefined;
@@ -92264,6 +92266,17 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92264
92266
  this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
92265
92267
  this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
92266
92268
  };
92269
+ _proto.isMouseLeaveWithinContainer = function isMouseLeaveWithinContainer(event) {
92270
+ var relatedTarget = event.relatedTarget;
92271
+ if (!relatedTarget) {
92272
+ return false;
92273
+ }
92274
+ try {
92275
+ return this.options.container.contains(relatedTarget);
92276
+ } catch (unused) {
92277
+ return false;
92278
+ }
92279
+ };
92267
92280
  _proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
92268
92281
  if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
92269
92282
  return false;
@@ -92559,8 +92572,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92559
92572
  return undefined;
92560
92573
  };
92561
92574
  _proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
92562
- var zone = this.getContentInteractiveZoneByEvent(event);
92563
- this.setActiveContentInteraction(zone);
92575
+ var decision = this.resolveHTMLInteractionTarget(event);
92576
+ this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
92564
92577
  };
92565
92578
  _proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
92566
92579
  var _this = this;
@@ -92584,7 +92597,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92584
92597
  _proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
92585
92598
  var _this = this;
92586
92599
  var previous = this.state.activeContentInteraction;
92587
- if ((previous == null ? void 0 : previous.id) === (zone == null ? void 0 : zone.id) && (previous == null ? void 0 : previous.element) === (zone == null ? void 0 : zone.element)) {
92600
+ if ((previous == null ? void 0 : previous.id) === (zone == null ? void 0 : zone.id) && (previous == null ? void 0 : previous.element) === (zone == null ? void 0 : zone.element) && (previous == null ? void 0 : previous.zone) === (zone == null ? void 0 : zone.zone)) {
92588
92601
  return;
92589
92602
  }
92590
92603
  this.state.activeContentInteraction = zone;
@@ -92599,22 +92612,65 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92599
92612
  _this.syncContentInteraction(id);
92600
92613
  });
92601
92614
  };
92602
- _proto.getContentInteractiveZoneByEvent = function getContentInteractiveZoneByEvent(event) {
92615
+ _proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
92603
92616
  var id = this.getHTMLCardIdByEvent(event);
92604
92617
  if (!id || this.isEditableCard(id)) {
92605
- return undefined;
92618
+ return {
92619
+ kind: 'canvas',
92620
+ id: id
92621
+ };
92606
92622
  }
92607
92623
  var contentOverlay = this.state.contentElements.get(id);
92608
92624
  if (!contentOverlay) {
92609
- return undefined;
92625
+ return {
92626
+ kind: 'canvas',
92627
+ id: id
92628
+ };
92610
92629
  }
92611
- var zone = this.getContentInteractionZones(id, contentOverlay).find(function(zone) {
92630
+ var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
92631
+ if (activeSubtree) {
92632
+ return {
92633
+ kind: 'html',
92634
+ interaction: activeSubtree
92635
+ };
92636
+ }
92637
+ var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
92612
92638
  return isMouseEventInsideRect(event, zone.rect);
92613
92639
  });
92614
- return zone ? {
92615
- id: id,
92616
- element: zone.element
92617
- } : undefined;
92640
+ var zone = this.resolveContentInteractionZone(matchedZones);
92641
+ if (zone) {
92642
+ return {
92643
+ kind: 'html',
92644
+ interaction: {
92645
+ id: id,
92646
+ element: zone.element,
92647
+ zone: zone.zone
92648
+ }
92649
+ };
92650
+ }
92651
+ return {
92652
+ kind: 'canvas',
92653
+ id: id
92654
+ };
92655
+ };
92656
+ _proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
92657
+ var activeInteraction = this.state.activeContentInteraction;
92658
+ if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
92659
+ return undefined;
92660
+ }
92661
+ var rect = activeInteraction.element.getBoundingClientRect();
92662
+ return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
92663
+ };
92664
+ _proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
92665
+ if (zones.length <= 1) {
92666
+ return zones[0];
92667
+ }
92668
+ var subtreeRoot = zones.find(function(candidate) {
92669
+ return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
92670
+ return zone.element !== candidate.element && candidate.element.contains(zone.element);
92671
+ });
92672
+ });
92673
+ return subtreeRoot != null ? subtreeRoot : zones[0];
92618
92674
  };
92619
92675
  _proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
92620
92676
  var _this = this;
@@ -92627,7 +92683,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92627
92683
  }).map(function(element) {
92628
92684
  return {
92629
92685
  element: element,
92630
- rect: element.getBoundingClientRect()
92686
+ rect: element.getBoundingClientRect(),
92687
+ zone: _this.getContentInteractionZoneMode(element)
92631
92688
  };
92632
92689
  });
92633
92690
  this.state.contentInteractionZones.set(id, zones);
@@ -92657,6 +92714,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92657
92714
  }
92658
92715
  return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
92659
92716
  };
92717
+ _proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
92718
+ var zone = element.dataset.vvfxHtmlInteractionZone;
92719
+ return zone === 'subtree' ? 'subtree' : 'self';
92720
+ };
92660
92721
  _proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
92661
92722
  if (id) {
92662
92723
  var _this_state_contentInteractionResizeCleanups_get;
@@ -92769,11 +92830,11 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92769
92830
  var _this_state_editing, _this_state_activeContentInteraction;
92770
92831
  var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
92771
92832
  var activeInteraction = ((_this_state_activeContentInteraction = this.state.activeContentInteraction) == null ? void 0 : _this_state_activeContentInteraction.id) === id ? this.state.activeContentInteraction : undefined;
92772
- var isInteractive = isEditing || !!activeInteraction;
92773
92833
  var overlay = this.state.elements.get(id);
92774
92834
  var scaleOverlay = this.state.contentScaleElements.get(id);
92775
92835
  var contentOverlay = this.state.contentElements.get(id);
92776
92836
  var contentMount = this.state.contentMountElements.get(id);
92837
+ var isInteractive = isEditing || !!activeInteraction;
92777
92838
  if (overlay) {
92778
92839
  overlay.dataset.editing = isEditing ? 'true' : 'false';
92779
92840
  overlay.style.pointerEvents = 'none';
@@ -92791,7 +92852,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92791
92852
  iframe.tabIndex = isActiveIframe ? 0 : -1;
92792
92853
  });
92793
92854
  this.syncShellInteraction(id, contentOverlay, isInteractive);
92794
- this.syncContentInteractionZones(id, contentOverlay, activeInteraction == null ? void 0 : activeInteraction.element, isEditing, isInteractive);
92855
+ this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
92795
92856
  }
92796
92857
  if (contentMount) {
92797
92858
  contentMount.dataset.editing = isEditing ? 'true' : 'false';
@@ -92804,19 +92865,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92804
92865
  }
92805
92866
  }
92806
92867
  };
92807
- _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeElement, isEditing, isInteractive) {
92868
+ _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
92808
92869
  var _this = this;
92870
+ var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
92809
92871
  contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
92810
- if (!isInteractive || _this.isContentInteractionDisabled(element)) {
92872
+ if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
92873
+ _this.clearContentInteractionState(element);
92874
+ return;
92875
+ }
92876
+ if (!isInteractive) {
92877
+ _this.clearContentInteractionState(element);
92878
+ return;
92879
+ }
92880
+ if (_this.isContentInteractionDisabled(element)) {
92811
92881
  element.dataset.vvfxHtmlInteractionActive = 'false';
92812
92882
  element.style.pointerEvents = 'none';
92813
92883
  return;
92814
92884
  }
92815
- var isElementInteractive = isEditing || activeElement === element;
92885
+ var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
92816
92886
  element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
92817
92887
  element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
92818
92888
  });
92819
92889
  };
92890
+ _proto.clearContentInteractionState = function clearContentInteractionState(element) {
92891
+ delete element.dataset.vvfxHtmlInteractionActive;
92892
+ element.style.pointerEvents = '';
92893
+ };
92820
92894
  _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
92821
92895
  var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
92822
92896
  var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;