@deque/cauldron-react 6.22.3-canary.afe87298 → 6.22.3-canary.df257c93

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.
Files changed (2) hide show
  1. package/lib/index.js +37 -1
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1776,6 +1776,38 @@ function getAutoAlignment(placement) {
1776
1776
  return null;
1777
1777
  }
1778
1778
  }
1779
+ /**
1780
+ * Prevents large overlays from shifting off-screen above the viewport. When an overlay
1781
+ * would overflow past the top edge, this middleware signals that it should flip to an
1782
+ * alternative placement to keep content visible and accessible.
1783
+ */
1784
+ var preventTopOverflowMiddleware = {
1785
+ name: 'preventTopOverflow',
1786
+ fn: function (state) {
1787
+ return tslib.__awaiter(this, void 0, void 0, function () {
1788
+ var overflow;
1789
+ return tslib.__generator(this, function (_a) {
1790
+ switch (_a.label) {
1791
+ case 0: return [4 /*yield*/, reactDom$1.detectOverflow(state, {
1792
+ rootBoundary: 'document'
1793
+ })];
1794
+ case 1:
1795
+ overflow = _a.sent();
1796
+ if ((overflow === null || overflow === void 0 ? void 0 : overflow.top) >= 0) {
1797
+ return [2 /*return*/, {
1798
+ reset: {
1799
+ // Replace the initial placement axis with 'bottom' while preserving alignment (start/end)
1800
+ // Examples: 'top' -> 'bottom', 'top-start' -> 'bottom-start'
1801
+ placement: (state.placement.replace(/\w+?(-(start|end))?$/i, 'bottom$1') || 'bottom')
1802
+ }
1803
+ }];
1804
+ }
1805
+ return [2 /*return*/, {}];
1806
+ }
1807
+ });
1808
+ });
1809
+ }
1810
+ };
1779
1811
  var AnchoredOverlay = React.forwardRef(function (_a, refProp) {
1780
1812
  var _b, _c;
1781
1813
  var as = _a.as, _d = _a.placement, initialPlacement = _d === void 0 ? 'auto' : _d, target = _a.target, children = _a.children, style = _a.style, _e = _a.open, open = _e === void 0 ? false : _e, offset = _a.offset, focusTrap = _a.focusTrap, focusTrapOptions = _a.focusTrapOptions, onOpenChange = _a.onOpenChange, onPlacementChange = _a.onPlacementChange, onShiftChange = _a.onShiftChange, portal = _a.portal, props = tslib.__rest(_a, ["as", "placement", "target", "children", "style", "open", "offset", "focusTrap", "focusTrapOptions", "onOpenChange", "onPlacementChange", "onShiftChange", "portal"]);
@@ -1795,7 +1827,11 @@ var AnchoredOverlay = React.forwardRef(function (_a, refProp) {
1795
1827
  : reactDom$1.flip({
1796
1828
  fallbackAxisSideDirection: 'start'
1797
1829
  }),
1798
- reactDom$1.shift({ crossAxis: false })
1830
+ reactDom$1.shift({
1831
+ crossAxis: false,
1832
+ boundary: 'clippingAncestors'
1833
+ }),
1834
+ preventTopOverflowMiddleware
1799
1835
  ].filter(Boolean),
1800
1836
  elements: {
1801
1837
  reference: resolveElement(target)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deque/cauldron-react",
3
- "version": "6.22.3-canary.afe87298",
3
+ "version": "6.22.3-canary.df257c93",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Fully accessible react components library for Deque Cauldron",
6
6
  "homepage": "https://cauldron.dequelabs.com/",