@human-kit/ui 1.1.1 → 1.1.2

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.
@@ -16,6 +16,16 @@ export type CollapseTransition = {
16
16
  */
17
17
  setPanel: (panel: HTMLElement | null, content?: HTMLElement | null) => void;
18
18
  };
19
+ /**
20
+ * The content's size without the rounding `scrollHeight`/`scrollWidth` apply.
21
+ *
22
+ * Those are whole pixels: content 57.5px tall measures 58, so an open panel came out half a pixel
23
+ * taller than the same content laid out without the variable (on the server, before hydration),
24
+ * and everything under it moved when the page hydrated. Within a pixel of the laid-out box the
25
+ * scroll size is only that rounding, so the box's own fractional size is the answer; beyond it the
26
+ * content really overflows its box, and the scroll size is what the panel has to open to.
27
+ */
28
+ export declare function exactSize(scrollSize: number, boxSize: number): number;
19
29
  /**
20
30
  * Drives a collapsible panel's enter/exit transitions the way Base UI's Collapsible does:
21
31
  * - keeps the content mounted for the full exit animation, then unmounts it (or, with
@@ -1,4 +1,16 @@
1
1
  import { trackMotionEnd } from './motion';
2
+ /**
3
+ * The content's size without the rounding `scrollHeight`/`scrollWidth` apply.
4
+ *
5
+ * Those are whole pixels: content 57.5px tall measures 58, so an open panel came out half a pixel
6
+ * taller than the same content laid out without the variable (on the server, before hydration),
7
+ * and everything under it moved when the page hydrated. Within a pixel of the laid-out box the
8
+ * scroll size is only that rounding, so the box's own fractional size is the answer; beyond it the
9
+ * content really overflows its box, and the scroll size is what the panel has to open to.
10
+ */
11
+ export function exactSize(scrollSize, boxSize) {
12
+ return Math.abs(scrollSize - boxSize) < 1 ? boxSize : scrollSize;
13
+ }
2
14
  /**
3
15
  * Drives a collapsible panel's enter/exit transitions the way Base UI's Collapsible does:
4
16
  * - keeps the content mounted for the full exit animation, then unmounts it (or, with
@@ -26,8 +38,8 @@ export function createCollapseTransition(open, forceMount) {
26
38
  // Freeze the size while collapsing so the exit animates from the open height, not from 0.
27
39
  if (!measured || status === 'ending')
28
40
  return;
29
- height = measured.scrollHeight;
30
- width = measured.scrollWidth;
41
+ height = exactSize(measured.scrollHeight, measured.getBoundingClientRect().height);
42
+ width = exactSize(measured.scrollWidth, measured.getBoundingClientRect().width);
31
43
  }
32
44
  function cancelRelease() {
33
45
  if (releaseFrame !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@human-kit/ui",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Accessible, typed UI components for Svelte 5 — shipped as native ESM with per-component subpath exports so bundlers only include what you import.",
5
5
  "license": "MIT",
6
6
  "author": "Agustin Delgado <agustindariodelgado@gmail.com>",