@moneyforward/mfui-components 3.10.0 → 3.10.1

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.
@@ -35,10 +35,23 @@ export function usePopoverMenuPlacement({ minWidth, maxHeight, allowedPlacements
35
35
  * autoPlacement allows the menu to be placed in the correct position
36
36
  * @see https://floating-ui.com/docs/autoPlacement
37
37
  *
38
- * Skip autoPlacement when centering in viewport, as we'll use custom positioning
38
+ * When centering in viewport, restrict to top/bottom only (no start/end alignment needed
39
+ * since horizontal position is handled by centerInViewport middleware).
39
40
  */
40
- !shouldCenterInViewport &&
41
- autoPlacement({
41
+ shouldCenterInViewport
42
+ ? autoPlacement({
43
+ // When centering, use allowedPlacements if provided (vertical only), otherwise default to top/bottom
44
+ allowedPlacements: allowedPlacements
45
+ ? (() => {
46
+ const verticalPlacements = allowedPlacements
47
+ .map((p) => placementMapping[p])
48
+ .filter((p) => p === 'top' || p === 'bottom');
49
+ return verticalPlacements.length > 0 ? verticalPlacements : ['bottom', 'top'];
50
+ })()
51
+ : ['bottom', 'top'],
52
+ crossAxis: false,
53
+ })
54
+ : autoPlacement({
42
55
  /*
43
56
  * allowedPlacements specifies the allowed placements for the menu in the order of priority
44
57
  * @see https://floating-ui.com/docs/autoPlacement#allowedPlacements
@@ -58,6 +71,7 @@ export function usePopoverMenuPlacement({ minWidth, maxHeight, allowedPlacements
58
71
  }),
59
72
  /*
60
73
  * Custom middleware for centering popover on narrow viewport
74
+ * Runs after autoPlacement to override only the horizontal (x) position.
61
75
  */
62
76
  shouldCenterInViewport &&
63
77
  {
@@ -70,7 +84,7 @@ export function usePopoverMenuPlacement({ minWidth, maxHeight, allowedPlacements
70
84
  const centeredX = Math.max(horizontalMargin, (viewportWidth - floatingWidth) / 2);
71
85
  return {
72
86
  x: centeredX,
73
- y: state.y, // Keep vertical position relative to trigger
87
+ y: state.y, // Keep vertical position determined by autoPlacement
74
88
  };
75
89
  },
76
90
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneyforward/mfui-components",
3
- "version": "3.10.0",
3
+ "version": "3.10.1",
4
4
  "description": "React UI Component Library for all Money Forward products",
5
5
  "repository": {
6
6
  "type": "git",
@@ -60,8 +60,8 @@
60
60
  "@floating-ui/react-dom": "^2.1.2",
61
61
  "@tanstack/react-virtual": "^3.13.18",
62
62
  "dayjs": "^1.11.13",
63
- "@moneyforward/mfui-design-tokens": "^3.1.0",
64
- "@moneyforward/mfui-icons-react": "^3.1.0"
63
+ "@moneyforward/mfui-icons-react": "^3.1.0",
64
+ "@moneyforward/mfui-design-tokens": "^3.1.0"
65
65
  },
66
66
  "scripts": {
67
67
  "prepare:panda": "panda codegen",