@human-kit/ui 1.4.6 → 1.4.8

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.
@@ -67,7 +67,14 @@
67
67
  // (`bottom-start`) already matches how a native context menu unfolds down and to the
68
68
  // right, and `flip`/`shift` handle the viewport edges.
69
69
  const resolvedOffset = $derived(offset ?? (ctx.isContextMenu ? 0 : 4));
70
- const anchorPoint = $derived(ctx.anchorPoint);
70
+ // The point the menu is shown at, held through its exit: the state drops the point as soon as
71
+ // the menu closes (a later keyboard open must land on the trigger), and following it then
72
+ // moved a leaving context menu onto its surface for the frames of its exit animation.
73
+ let shownAnchorPoint: typeof ctx.anchorPoint = null;
74
+ const anchorPoint = $derived.by(() => {
75
+ if (ctx.isOpen) shownAnchorPoint = ctx.anchorPoint;
76
+ return shownAnchorPoint;
77
+ });
71
78
  const resolvedAnchor = $derived(
72
79
  anchorPoint ? createPointAnchor(anchorPoint.x, anchorPoint.y, triggerRef) : triggerRef
73
80
  );
@@ -0,0 +1,2 @@
1
+ /** Whether the caller runs inside a tracking context: an effect or a derived being computed. */
2
+ export declare function insideEffect(): boolean;
@@ -0,0 +1,4 @@
1
+ /** Whether the caller runs inside a tracking context: an effect or a derived being computed. */
2
+ export function insideEffect() {
3
+ return $effect.tracking();
4
+ }
@@ -246,24 +246,24 @@
246
246
  scrollTop = scrollContainer.scrollTop;
247
247
  };
248
248
 
249
+ // Scrolls and resizes flush at once so the window of rows moves in the same frame.
249
250
  const updateMetrics = () => {
250
251
  flushSync(setMetrics);
251
252
  };
252
253
 
253
- const handleScroll = () => {
254
- flushSync(setMetrics);
255
- };
256
-
257
- updateMetrics();
254
+ // The first measure is a plain write: `flushSync` is forbidden inside an effect, and
255
+ // outside async mode it doesn't throw — it flushes the batch this effect runs in, and
256
+ // the effects after it in the same pass run without one (`schedule` of null).
257
+ setMetrics();
258
258
 
259
259
  const resizeObserver =
260
260
  typeof ResizeObserver !== 'undefined' ? new ResizeObserver(updateMetrics) : null;
261
261
 
262
- scrollContainer.addEventListener('scroll', handleScroll, { passive: true });
262
+ scrollContainer.addEventListener('scroll', updateMetrics, { passive: true });
263
263
  resizeObserver?.observe(scrollContainer);
264
264
 
265
265
  return () => {
266
- scrollContainer.removeEventListener('scroll', handleScroll);
266
+ scrollContainer.removeEventListener('scroll', updateMetrics);
267
267
  resizeObserver?.disconnect();
268
268
  };
269
269
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@human-kit/ui",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
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>",