@vectoriox/iox-builder 1.7.8 → 1.7.9

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.
@@ -3017,6 +3017,23 @@ class RenderDirective {
3017
3017
  * Returns { element, node } if found, or null if the target is outside
3018
3018
  * all known builder components (e.g. the canvas background).
3019
3019
  */
3020
+ /**
3021
+ * The nearest ancestor node's cssId, read from the DOM `iox-node-{id}` classes (NOT the overlay
3022
+ * registry — at state-restore time the parent isn't registered yet, since it registers only
3023
+ * AFTER rendering its children). Used to key relational (parent-hover) rules. (issue #1)
3024
+ */
3025
+ resolveParentNodeId(childEl) {
3026
+ let el = childEl?.parentElement ?? null;
3027
+ while (el) {
3028
+ for (let i = 0; i < el.classList.length; i++) {
3029
+ const c = el.classList[i];
3030
+ if (c.startsWith('iox-node-'))
3031
+ return c.slice('iox-node-'.length);
3032
+ }
3033
+ el = el.parentElement;
3034
+ }
3035
+ return undefined;
3036
+ }
3020
3037
  findParentNodeElement(target) {
3021
3038
  let el = target;
3022
3039
  while (el) {
@@ -3084,17 +3101,23 @@ class RenderDirective {
3084
3101
  const childEl = componentRef.location?.nativeElement;
3085
3102
  for (const state of Object.keys(node.stateStyles)) {
3086
3103
  const stateMap = node.stateStyles[state];
3087
- if (stateMap && Object.keys(stateMap).length) {
3104
+ if (!stateMap || !Object.keys(stateMap).length)
3105
+ continue;
3106
+ if (RELATIONAL_STATES.includes(state)) {
3088
3107
  // Relational states (parent-hover) compile to
3089
3108
  // `.iox-node-{parentId}:hover .iox-node-{childId}` — they need the CURRENT parent id.
3090
- // Resolve it from the DOM on EVERY render, so the rule is correct on load AND after a
3091
- // cross-container move (which re-renders the child with a fresh instance). (issue #1)
3092
- let relativeToId;
3093
- if (RELATIONAL_STATES.includes(state) && childEl?.parentElement) {
3094
- relativeToId = this.findParentNodeElement(childEl.parentElement)?.node?.id;
3095
- }
3109
+ // Resolve it from the DOM so the rule re-resolves after a cross-container MOVE (which
3110
+ // re-renders the child). If it can't be resolved yet (initial load: the parent registers
3111
+ // its class only after rendering its children), SKIP — do NOT clobber the correct rule
3112
+ // that page-ui's applyStateEnhancements already produced from the node tree. (issue #1)
3113
+ const relativeToId = this.resolveParentNodeId(childEl);
3114
+ if (!relativeToId)
3115
+ continue;
3096
3116
  this.styleRegistry.upsert(cssId, composeVirtualTraits(stateMap, initialStyle), state, relativeToId);
3097
3117
  }
3118
+ else {
3119
+ this.styleRegistry.upsert(cssId, composeVirtualTraits(stateMap, initialStyle), state);
3120
+ }
3098
3121
  }
3099
3122
  }
3100
3123
  }