@inertiaui/vanilla 1.0.2 → 1.1.0

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/index.d.ts CHANGED
@@ -148,6 +148,12 @@ declare interface PositionOptions_2 {
148
148
  placement?: Placement;
149
149
  offset?: number;
150
150
  flip?: boolean;
151
+ /**
152
+ * Constrain the floating element to the available viewport space by setting
153
+ * `max-height` and `overflow-y: auto`. Mirrors the auto-sizing Headless UI
154
+ * applied via its `anchor` prop, so long menus scroll instead of overflowing.
155
+ */
156
+ autoSize?: boolean;
151
157
  }
152
158
  export { PositionOptions_2 as PositionOptions }
153
159
 
package/dist/index.js CHANGED
@@ -595,10 +595,37 @@ function cleanupAnchorPositioning(reference, floating, className) {
595
595
  }
596
596
  }
597
597
  }
598
+ var SIZE_MARGIN = 8;
599
+ /**
600
+ * Cap the floating element's height to the space available between its anchored
601
+ * edge and the viewport edge, adding a scrollbar when the content is taller.
602
+ *
603
+ * On the JS fallback path the resolved `side` is known, so the available space is
604
+ * measured from the reference rect (the clamp may have shifted the floating rect,
605
+ * which would otherwise confuse a rect-based heuristic). On the CSS Anchor path the
606
+ * resolved side is not known to JS after a `position-try` flip, so the open
607
+ * direction is derived from the rendered rects: a menu whose top sits above the
608
+ * reference opens upward (its bottom edge is anchored); otherwise it opens downward.
609
+ */
610
+ function applySize(reference, floating, offset, side) {
611
+ const refRect = reference.getBoundingClientRect();
612
+ const vh = window.innerHeight;
613
+ let available;
614
+ if (side === "top") available = refRect.top - offset - SIZE_MARGIN;
615
+ else if (side === "bottom") available = vh - refRect.bottom - offset - SIZE_MARGIN;
616
+ else if (side === "left" || side === "right") available = vh - refRect.top - SIZE_MARGIN;
617
+ else {
618
+ const rect = floating.getBoundingClientRect();
619
+ available = rect.top < refRect.top ? rect.bottom - SIZE_MARGIN : vh - rect.top - SIZE_MARGIN;
620
+ }
621
+ floating.style.maxHeight = `min(var(--iui-max-height, 100vh), ${Math.floor(Math.max(0, available))}px)`;
622
+ floating.style.overflowY = "auto";
623
+ }
598
624
  function computePosition(reference, floating, options = {}) {
599
- const { placement = "bottom-start", offset = 0, flip = true } = options;
625
+ const { placement = "bottom-start", offset = 0, flip = true, autoSize = false } = options;
600
626
  if (supportsAnchorPositioning()) {
601
627
  if (!findAnchorClass(floating)) setupAnchorPositioning(reference, floating, placement, offset, flip);
628
+ if (autoSize) applySize(reference, floating, offset);
602
629
  const rect = floating.getBoundingClientRect();
603
630
  return {
604
631
  x: rect.left,
@@ -606,6 +633,7 @@ function computePosition(reference, floating, options = {}) {
606
633
  placement
607
634
  };
608
635
  }
636
+ if (autoSize) applySize(reference, floating, offset, placement.split("-")[0]);
609
637
  const result = computeWithFallback(reference, floating, {
610
638
  placement,
611
639
  offset,
@@ -614,6 +642,7 @@ function computePosition(reference, floating, options = {}) {
614
642
  floating.style.position = "fixed";
615
643
  floating.style.top = `${result.y}px`;
616
644
  floating.style.left = `${result.x}px`;
645
+ if (autoSize) applySize(reference, floating, offset, result.placement.split("-")[0]);
617
646
  return result;
618
647
  }
619
648
  function autoUpdate(reference, floating, update) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inertiaui/vanilla",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "author": "Pascal Baljet <pascal@protone.media>",
5
5
  "private": false,
6
6
  "license": "MIT",
@@ -35,13 +35,11 @@
35
35
  ],
36
36
  "devDependencies": {
37
37
  "@playwright/test": "^1.58.2",
38
- "@typescript-eslint/eslint-plugin": "^8.0.0",
39
- "@typescript-eslint/parser": "^8.0.0",
40
38
  "@vitest/coverage-v8": "^4.1.2",
41
39
  "@vitest/ui": "^4.1.2",
42
- "eslint": "^9.0.0",
43
40
  "happy-dom": "^20.0.0",
44
- "prettier": "^3.2.4",
41
+ "oxfmt": "^0.52.0",
42
+ "oxlint": "^1.67.0",
45
43
  "typescript": "^5.7.0",
46
44
  "vite": "^8.0.3",
47
45
  "vite-plugin-dts": "^4.5.0",
@@ -50,9 +48,9 @@
50
48
  "scripts": {
51
49
  "dev": "vite build --watch",
52
50
  "build": "vite build",
53
- "lint": "eslint src/",
54
- "format": "prettier --write src/ e2e/",
55
- "format:check": "prettier --check src/ e2e/",
51
+ "lint": "oxlint --fix",
52
+ "format": "oxfmt",
53
+ "format:check": "oxfmt --check",
56
54
  "test": "vitest",
57
55
  "test:e2e": "playwright test"
58
56
  }