@uniweb/runtime 1.5.2 → 1.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/runtime",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "Minimal runtime for loading Uniweb foundations",
5
5
  "type": "module",
6
6
  "exports": {
@@ -36,15 +36,15 @@
36
36
  "node": ">=22.12"
37
37
  },
38
38
  "dependencies": {
39
- "@uniweb/theming": "~1.3.1",
40
- "@uniweb/core": "~1.6.7"
39
+ "@uniweb/core": "~1.6.9",
40
+ "@uniweb/theming": "~1.3.2"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@vitejs/plugin-react": "^4.5.2",
44
44
  "esbuild": "^0.21.0 || ^0.23.0 || ^0.24.0 || ^0.25.0 || ^0.27.0 || ^0.28.0",
45
45
  "vite": "^7.3.1",
46
46
  "vitest": "^4.1.7",
47
- "@uniweb/build": "1.18.1"
47
+ "@uniweb/build": "1.19.0"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "react": "^19.0.0",
package/src/sticky-top.js CHANGED
@@ -65,19 +65,16 @@ function drawnHeight(box) {
65
65
  }
66
66
 
67
67
  /**
68
- * How tall the header lying over the page's opening section is, in px — 0 when the layout drew no
69
- * header on such a page, null on a page with no section under the header.
68
+ * How tall the header lying over the page's opening section is, in px — null on a page with none.
70
69
  *
71
70
  * @param {Document} doc
72
71
  * @returns {number|null}
73
72
  */
74
73
  export function measureHeaderOverlay(doc) {
75
74
  const box = doc.querySelector('[data-uw-header="over"]')
76
- if (box) return Math.round(drawnHeight(box) * 100) / 100
77
- // A page whose opening section lies under the header, in a layout that drew no header on it:
78
- // there is nothing to clear, so the section is padded by nothing once the browser has looked.
79
- // ⛔ Until 2026-11-06 it kept the declared height, padding the section for a header not there.
80
- return doc.querySelector('[data-uw-under-header]') ? 0 : null
75
+ // A page under the header whose layout drew no header has no box to measure, and the page's
76
+ // stylesheet pads its section by nothing (`underHeaderProps`).
77
+ return box ? Math.round(drawnHeight(box) * 100) / 100 : null
81
78
  }
82
79
 
83
80
  /**
@@ -28,6 +28,9 @@ export const HEADER_HEIGHT = '--uw-header-height'
28
28
  /** What the browser measured, on the root, which the opening section's value defers to. */
29
29
  export const MEASURED_HEADER_HEIGHT = '--uw-header-measured'
30
30
 
31
+ /** The header types' declared height, on the opening section's wrapper: the value before measuring. */
32
+ export const DECLARED_HEADER_HEIGHT = '--uw-header-declared'
33
+
31
34
  /**
32
35
  * Whether the page's header lies over its opening section, and how tall the header is before the
33
36
  * browser measures it: the `height` its sections' types declare, else `0px` until measured.
@@ -37,9 +40,8 @@ export const MEASURED_HEADER_HEIGHT = '--uw-header-measured'
37
40
  */
38
41
  export function headerOverlay(page) {
39
42
  const first = page?.getBodyBlocks?.()?.[0]
40
- if (!first?.underHeader) return null
41
- const header = page.getLayoutAreas?.()?.header
42
- if (!Array.isArray(header) || header.length === 0) return null
43
+ if (!first?.liesUnderHeader?.()) return null
44
+ const header = page.getLayoutAreas().header
43
45
  const heights = header.map((block) => block?.height).filter(Boolean)
44
46
  const height = heights.length === 0 ? '0px' : heights.length === 1 ? heights[0] : `calc(${heights.join(' + ')})`
45
47
  return { height }
@@ -88,15 +90,22 @@ export function headerAreaProps(wrapper, overlay) {
88
90
  }
89
91
 
90
92
  /**
91
- * What the opening section's wrapper adds when the header lies over it: the header's height, the
92
- * declared one until the browser has measured it.
93
+ * What the opening section's wrapper adds when the header lies over it: the header type's declared
94
+ * height, and the mark the page's stylesheet keys on.
95
+ *
96
+ * ⭐ THE STYLESHEET GIVES THE SECTION ITS `--uw-header-height` (`@uniweb/theming`): what the browser
97
+ * measured, else the declared height, on a page where a header box lies over it
98
+ * (`[data-uw-header="over"]`), and `0px` on one where none does — a layout that draws no header on
99
+ * the page. A rule rather than this style, since only the rendered page holds that answer, and so
100
+ * the first paint, the prerender's included, pads by what is there. ⛔ Until 2026-11-06 the section
101
+ * was padded by the declared height whatever the layout drew, until the browser measured.
93
102
  *
94
103
  * @param {{ height: string }} overlay - `headerOverlay(page)`
95
104
  * @returns {{ style: Object, 'data-uw-under-header': string }}
96
105
  */
97
106
  export function underHeaderProps(overlay) {
98
107
  return {
99
- style: { [HEADER_HEIGHT]: `var(${MEASURED_HEADER_HEIGHT}, ${overlay.height})` },
108
+ style: { [DECLARED_HEADER_HEIGHT]: overlay.height },
100
109
  'data-uw-under-header': '',
101
110
  }
102
111
  }