@uniweb/runtime 1.5.1 → 1.5.3

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/ssr.js CHANGED
@@ -436,13 +436,11 @@ function areaWrapperProps(region, transitions, layers, sticky = null) {
436
436
  if (!style) return null;
437
437
  return sticky ? { style, "data-uw-sticky": "area" } : { style };
438
438
  }
439
- const HEADER_HEIGHT = "--uw-header-height";
440
- const MEASURED_HEADER_HEIGHT = "--uw-header-measured";
439
+ const DECLARED_HEADER_HEIGHT = "--uw-header-declared";
441
440
  function headerOverlay(page) {
442
441
  const first = page?.getBodyBlocks?.()?.[0];
443
- if (!first?.underHeader) return null;
444
- const header = page.getLayoutAreas?.()?.header;
445
- if (!Array.isArray(header) || header.length === 0) return null;
442
+ if (!first?.liesUnderHeader?.()) return null;
443
+ const header = page.getLayoutAreas().header;
446
444
  const heights = header.map((block) => block?.height).filter(Boolean);
447
445
  const height = heights.length === 0 ? "0px" : heights.length === 1 ? heights[0] : `calc(${heights.join(" + ")})`;
448
446
  return { height };
@@ -450,9 +448,16 @@ function headerOverlay(page) {
450
448
  function overlayBoxProps(props) {
451
449
  return { ...props || {}, style: { ...props?.style || {}, height: 0, minHeight: 0 }, "data-uw-header": "over" };
452
450
  }
451
+ function headerAreaProps(wrapper, overlay) {
452
+ const { viewTransitionName, ...style } = wrapper?.style || {};
453
+ const inner = viewTransitionName ? { style: { viewTransitionName } } : null;
454
+ const base = { ...wrapper || {}, style };
455
+ if (overlay) return { outer: overlayBoxProps(base), inner };
456
+ return { outer: Object.keys(style).length ? base : { ...base, style: { display: "contents" } }, inner };
457
+ }
453
458
  function underHeaderProps(overlay) {
454
459
  return {
455
- style: { [HEADER_HEIGHT]: `var(${MEASURED_HEADER_HEIGHT}, ${overlay.height})` },
460
+ style: { [DECLARED_HEADER_HEIGHT]: overlay.height },
456
461
  "data-uw-under-header": ""
457
462
  };
458
463
  }
@@ -642,8 +647,11 @@ function renderLayout(page, website) {
642
647
  const layers = resolveLayoutLayers(areaNames, layoutMeta?.layers, sticky);
643
648
  const overlay = headerOverlay(page);
644
649
  const wrapArea = (name, element) => {
645
- let props = areaWrapperProps(name, transitions, layers, RemoteLayout ? sticky[name] : null);
646
- if (overlay && RemoteLayout && name === "header") props = overlayBoxProps(props);
650
+ const props = areaWrapperProps(name, transitions, layers, RemoteLayout ? sticky[name] : null);
651
+ if (RemoteLayout && name === "header") {
652
+ const { outer, inner } = headerAreaProps(props, overlay);
653
+ return React.createElement("div", outer, inner ? React.createElement("div", inner, element) : element);
654
+ }
647
655
  return props ? React.createElement("div", props, element) : element;
648
656
  };
649
657
  const bodyElement = bodyBlocks ? wrapArea("body", renderBlocks(bodyBlocks, { stickySelf: "section" })) : null;