@vectoriox/iox-builder 1.4.25 → 1.4.27

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.
@@ -2007,6 +2007,7 @@ class StyleRegistryService {
2007
2007
  this.changes$ = new Subject();
2008
2008
  this.rules = new Map();
2009
2009
  this.styleEl = null;
2010
+ this._flushPending = false;
2010
2011
  }
2011
2012
  /**
2012
2013
  * Properties that must live on the OUTER wrapper (.iox-outer-{id}) because they
@@ -2138,27 +2139,37 @@ class StyleRegistryService {
2138
2139
  return `.${className} {\n${entries.join('\n')}\n}`;
2139
2140
  }
2140
2141
  /**
2141
- * Rewrite bare `vh` values to `calc(N * var(--preview-vh, 1vh))` so they
2142
- * resolve to the simulated viewport height in the builder canvas.
2143
- * In production (no --preview-vh defined) the fallback `1vh` preserves the
2144
- * original behaviour: `calc(50 * 1vh)` == `50vh`.
2142
+ * Rewrite viewport-relative units so they resolve to the simulated canvas
2143
+ * dimensions rather than the real browser viewport.
2144
+ *
2145
+ * --preview-vh / --preview-vw are set by BuilderComponent via ResizeObserver
2146
+ * and viewport-state subscription. In production (no variables defined) the
2147
+ * fallbacks `1vh` / `1vw` restore the original browser behaviour.
2145
2148
  */
2146
2149
  rewriteVh(value) {
2147
- return value.replace(/(-?\d*\.?\d+)vh/g, 'calc($1 * var(--preview-vh, 1vh))');
2150
+ return value
2151
+ .replace(/(-?\d*\.?\d+)vh/g, 'calc($1 * var(--preview-vh, 1vh))')
2152
+ .replace(/(-?\d*\.?\d+)vw/g, 'calc($1 * var(--preview-vw, 1vw))');
2148
2153
  }
2149
2154
  toKebabCase(str) {
2150
2155
  return str.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`);
2151
2156
  }
2152
2157
  flush() {
2153
- if (!this.styleEl)
2158
+ if (!this.styleEl || this._flushPending)
2154
2159
  return;
2155
- // __tokens__ always first so variables are available to all subsequent rules
2156
- const tokenBlock = this.rules.get('__tokens__');
2157
- const rest = Array.from(this.rules.entries())
2158
- .filter(([k]) => k !== '__tokens__')
2159
- .map(([, v]) => v);
2160
- this.styleEl.textContent = [tokenBlock, ...rest].filter(Boolean).join('\n');
2161
- this.changes$.next();
2160
+ this._flushPending = true;
2161
+ requestAnimationFrame(() => {
2162
+ this._flushPending = false;
2163
+ if (!this.styleEl)
2164
+ return;
2165
+ // __tokens__ always first so variables are available to all subsequent rules
2166
+ const tokenBlock = this.rules.get('__tokens__');
2167
+ const rest = Array.from(this.rules.entries())
2168
+ .filter(([k]) => k !== '__tokens__')
2169
+ .map(([, v]) => v);
2170
+ this.styleEl.textContent = [tokenBlock, ...rest].filter(Boolean).join('\n');
2171
+ this.changes$.next();
2172
+ });
2162
2173
  }
2163
2174
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: StyleRegistryService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2164
2175
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.11", ngImport: i0, type: StyleRegistryService }); }
@@ -3287,18 +3298,23 @@ class BuilderComponent {
3287
3298
  }
3288
3299
  }
3289
3300
  /**
3290
- * Set --preview-vh on .preview-scroll so that 100vh fills the visible canvas
3291
- * frame at the current scale. Value = canvas frame height ÷ scale ÷ 100, so
3292
- * calc(100 * var(--preview-vh)) equals the frame height in canvas-space pixels.
3293
- * Falls back to 1vh in the live page (no --preview-vh defined there).
3301
+ * Set --preview-vh / --preview-vw on .preview-scroll so that viewport-relative
3302
+ * units (vh, vw) inside the canvas resolve to the simulated canvas dimensions
3303
+ * rather than the real browser viewport.
3304
+ *
3305
+ * --preview-vh = canvas frame height (unscaled) / 100
3306
+ * --preview-vw = canvas width from viewport state / 100
3307
+ *
3308
+ * Both fall back to their native unit in production (no variables defined).
3294
3309
  */
3295
3310
  updatePreviewVh() {
3296
3311
  const el = this.previewScrollRef?.nativeElement;
3297
3312
  if (!el)
3298
3313
  return;
3299
- const scale = this.viewportService.getState().scale;
3300
- const frameH = el.clientHeight / scale;
3314
+ const state = this.viewportService.getState();
3315
+ const frameH = el.clientHeight / state.scale;
3301
3316
  el.style.setProperty('--preview-vh', `${frameH / 100}px`);
3317
+ el.style.setProperty('--preview-vw', `${state.width / 100}px`);
3302
3318
  this.canvasFrameHeight = Math.round(frameH);
3303
3319
  }
3304
3320
  initLenis() {