@dloizides/ui-layout 1.23.0 → 1.24.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/CHANGELOG.md +19 -0
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.24.0
|
|
4
|
+
|
|
5
|
+
**The inline dropdown popover now stays inside the viewport — a floored menu can no longer spill off the right edge.**
|
|
6
|
+
|
|
7
|
+
`buildPortalPopoverStyle` positioned the fixed popover at `left: rect.left` with no horizontal
|
|
8
|
+
clamp. That was fine while the menu matched its trigger's width, but a COMPACT trigger with a
|
|
9
|
+
`menuMinWidth` floor (e.g. the `@dloizides/ui-nav` "More ▾" overflow menu, whose trigger sits near
|
|
10
|
+
the right of the bar) opens a menu WIDER than its trigger — which then extended past the right edge
|
|
11
|
+
of the viewport and clipped its lower/right content ("some items get hidden").
|
|
12
|
+
|
|
13
|
+
- **`buildPortalPopoverStyle(rect, minWidth, viewportWidth?)`** takes an optional `viewportWidth`.
|
|
14
|
+
When given, the popover's `left` is clamped so its right edge clears `MENU_VIEWPORT_MARGIN` (8px) —
|
|
15
|
+
sliding it left, right-aligning it to the trigger in the limit — while never crossing the left
|
|
16
|
+
margin. `viewportWidth = 0` (the default, and the native/pure path) keeps the exact prior
|
|
17
|
+
trigger-anchored behaviour, so every existing caller is unchanged.
|
|
18
|
+
- **`InlineMenu`** passes `window.innerWidth` on web (re-read whenever the tracked trigger rect
|
|
19
|
+
re-measures on scroll/resize); native is untouched.
|
|
20
|
+
- New export `MENU_VIEWPORT_MARGIN`.
|
|
21
|
+
|
|
3
22
|
## 1.23.0
|
|
4
23
|
|
|
5
24
|
**Modals, the dropdown popover and the accordion body now ANIMATE on web — adopts `@dloizides/ui-motion`.**
|
package/dist/index.js
CHANGED
|
@@ -328,14 +328,21 @@ var BORDER_RADIUS = 8;
|
|
|
328
328
|
var BORDER_WIDTH2 = 1;
|
|
329
329
|
var MENU_PADDING = 4;
|
|
330
330
|
var MENU_BOX_SHADOW = "0px 2px 8px rgba(0, 0, 0, 0.15)";
|
|
331
|
-
|
|
331
|
+
var MENU_VIEWPORT_MARGIN = 8;
|
|
332
|
+
function buildPortalPopoverStyle(rect, minWidth = 0, viewportWidth = 0) {
|
|
333
|
+
const width = Math.max(rect.width, minWidth);
|
|
334
|
+
let left = rect.left;
|
|
335
|
+
if (viewportWidth > 0) {
|
|
336
|
+
const maxLeft = viewportWidth - width - MENU_VIEWPORT_MARGIN;
|
|
337
|
+
left = Math.max(MENU_VIEWPORT_MARGIN, Math.min(rect.left, maxLeft));
|
|
338
|
+
}
|
|
332
339
|
return {
|
|
333
340
|
// RN's ViewStyle union omits 'fixed', but react-native-web honours it at runtime.
|
|
334
341
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- web-only position value
|
|
335
342
|
position: "fixed",
|
|
336
343
|
top: rect.bottom + MENU_TOP_GAP,
|
|
337
|
-
left
|
|
338
|
-
width
|
|
344
|
+
left,
|
|
345
|
+
width,
|
|
339
346
|
zIndex: MENU_Z_INDEX,
|
|
340
347
|
borderWidth: BORDER_WIDTH2,
|
|
341
348
|
borderRadius: BORDER_RADIUS,
|
|
@@ -616,11 +623,13 @@ var InlineMenu = ({
|
|
|
616
623
|
});
|
|
617
624
|
const popoverStyle = React10.useMemo(() => {
|
|
618
625
|
const themed = { borderColor: colors.border, backgroundColor: colors.surface };
|
|
619
|
-
if (IS_WEB2)
|
|
626
|
+
if (IS_WEB2) {
|
|
627
|
+
const viewportWidth = typeof window !== "undefined" ? window.innerWidth : 0;
|
|
620
628
|
return [
|
|
621
|
-
buildPortalPopoverStyle(rect ?? { left: 0, width: 0, bottom: 0 }, menuMinWidth),
|
|
629
|
+
buildPortalPopoverStyle(rect ?? { left: 0, width: 0, bottom: 0 }, menuMinWidth, viewportWidth),
|
|
622
630
|
themed
|
|
623
631
|
];
|
|
632
|
+
}
|
|
624
633
|
return [styles6.popover, { minWidth: menuMinWidth }, themed];
|
|
625
634
|
}, [colors.border, colors.surface, menuMinWidth, rect]);
|
|
626
635
|
const menu = /* @__PURE__ */ jsxRuntime.jsx(
|