@aloudata/aloudata-design 2.19.4 → 2.19.6

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.
@@ -86,5 +86,10 @@ export interface IDropdownProps {
86
86
  * @default false
87
87
  */
88
88
  popupMatchTriggerWidth?: boolean | number;
89
+ /**
90
+ * @description 空间不足时自动计算菜单最大高度并启用滚动,启用后 offset 固定为 0
91
+ * @default false
92
+ */
93
+ allowOverlap?: boolean;
89
94
  }
90
95
  export default function Dropdown(props: IDropdownProps): React.JSX.Element;
@@ -45,7 +45,9 @@ export default function Dropdown(props) {
45
45
  _props$initialFocus = props.initialFocus,
46
46
  initialFocus = _props$initialFocus === void 0 ? -1 : _props$initialFocus,
47
47
  _props$popupMatchTrig = props.popupMatchTriggerWidth,
48
- popupMatchTriggerWidth = _props$popupMatchTrig === void 0 ? false : _props$popupMatchTrig;
48
+ popupMatchTriggerWidth = _props$popupMatchTrig === void 0 ? false : _props$popupMatchTrig,
49
+ _props$allowOverlap = props.allowOverlap,
50
+ allowOverlap = _props$allowOverlap === void 0 ? false : _props$allowOverlap;
49
51
  var _useState = useState(open || false),
50
52
  _useState2 = _slicedToArray(_useState, 2),
51
53
  isOpen = _useState2[0],
@@ -69,24 +71,31 @@ export default function Dropdown(props) {
69
71
  placement: placement,
70
72
  open: isOpen,
71
73
  onOpenChange: onChangeOpen,
72
- middleware: [offset(offsetProps), flip({
74
+ middleware: [offset(allowOverlap ? 0 : offsetProps), flip(_objectSpread({
73
75
  fallbackAxisSideDirection: 'end'
74
- }), shift(), popupMatchTriggerWidth ? size({
76
+ }, allowOverlap && {
77
+ fallbackStrategy: 'bestFit'
78
+ })), shift(allowOverlap ? {
79
+ mainAxis: true
80
+ } : undefined), size(_objectSpread(_objectSpread({}, allowOverlap && {
81
+ padding: 8
82
+ }), {}, {
75
83
  apply: function apply(_ref) {
76
- var rects = _ref.rects,
84
+ var availableHeight = _ref.availableHeight,
85
+ rects = _ref.rects,
77
86
  elements = _ref.elements;
78
- Object.assign(elements.floating.style, {
87
+ var widthStyle = popupMatchTriggerWidth ? {
79
88
  width: typeof popupMatchTriggerWidth === 'number' ? "".concat(popupMatchTriggerWidth, "px") : "".concat(rects.reference.width, "px")
80
- });
81
- }
82
- }) : size({
83
- apply: function apply(_ref2) {
84
- var elements = _ref2.elements;
85
- Object.assign(elements.floating.style, {
89
+ } : {
86
90
  minWidth: '144px'
87
- });
91
+ };
92
+ var heightStyle = allowOverlap ? {
93
+ maxHeight: "".concat(Math.max(100, availableHeight), "px"),
94
+ overflowY: 'auto'
95
+ } : {};
96
+ Object.assign(elements.floating.style, _objectSpread(_objectSpread({}, widthStyle), heightStyle));
88
97
  }
89
- })],
98
+ }))],
90
99
  whileElementsMounted: autoUpdatePos ? autoUpdate : undefined
91
100
  }),
92
101
  refs = _useFloating.refs,
@@ -150,9 +159,10 @@ export default function Dropdown(props) {
150
159
  items: (menu === null || menu === void 0 ? void 0 : menu.items) || []
151
160
  });
152
161
  return /*#__PURE__*/React.createElement(Menu, _extends({}, menuProps, {
153
- onClick: onMenuItemClick
162
+ onClick: onMenuItemClick,
163
+ externalOverflow: allowOverlap
154
164
  }));
155
- }, [menu, onMenuItemClick]);
165
+ }, [menu, onMenuItemClick, allowOverlap]);
156
166
  var popupElement = useMemo(function () {
157
167
  return typeof dropdownRender === 'function' ? dropdownRender(menuInstance) : menuInstance;
158
168
  }, [dropdownRender, menuInstance]);
@@ -5,6 +5,8 @@ export interface MenuProps {
5
5
  items: MenuItemType[];
6
6
  selectedKeys?: string[];
7
7
  menuStyle?: React.CSSProperties;
8
+ /** @internal 由 Dropdown 注入,禁用内部定位/overflow 计算。不支持含 SubMenu 的菜单 */
9
+ externalOverflow?: boolean;
8
10
  }
9
11
  export default function Menu(props: MenuProps): React.JSX.Element;
10
12
  export declare function isHeaderMenuItem(menuItem: MenuItemType): menuItem is MenuHeaderType;
@@ -20,7 +20,8 @@ export default function Menu(props) {
20
20
  items = props.items,
21
21
  onMenuClick = props.onClick,
22
22
  selectedKeys = props.selectedKeys,
23
- menuStyle = props.menuStyle;
23
+ menuStyle = props.menuStyle,
24
+ externalOverflow = props.externalOverflow;
24
25
  var getMenuItems = function getMenuItems(items) {
25
26
  var parentPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
26
27
  return items.map(function (item, index) {
@@ -95,6 +96,7 @@ export default function Menu(props) {
95
96
  });
96
97
  };
97
98
  var ref = useRef(null);
99
+ var leafOverflow = isLeafMenu(items) ? 'auto' : undefined;
98
100
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
99
101
  style: {
100
102
  display: 'none '
@@ -103,14 +105,14 @@ export default function Menu(props) {
103
105
  }), /*#__PURE__*/React.createElement(ControlledMenu, {
104
106
  state: "open",
105
107
  menuStyle: _objectSpread(_objectSpread({}, menuStyle), {}, {
106
- overflow: isLeafMenu(items) ? 'auto' : undefined
108
+ overflow: externalOverflow ? undefined : leafOverflow
107
109
  }),
108
110
  anchorRef: ref,
109
111
  className: classNames(className, 'ald-menu'),
110
- position: "auto",
112
+ position: externalOverflow ? 'initial' : 'auto',
111
113
  captureFocus: false,
112
- viewScroll: "auto",
113
- overflow: isLeafMenu(items) ? 'auto' : undefined
114
+ viewScroll: externalOverflow ? 'initial' : 'auto',
115
+ overflow: externalOverflow ? 'visible' : leafOverflow
114
116
  }, getMenuItems(items || [])));
115
117
  }
116
118
  export function isHeaderMenuItem(menuItem) {
package/dist/Tag/index.js CHANGED
@@ -68,7 +68,7 @@ export default function Tag(props) {
68
68
  }
69
69
  onClose === null || onClose === void 0 ? void 0 : onClose(e);
70
70
  }, [disabled, onClose]);
71
- var DEFAULT_MAX_WIDTH = 160;
71
+ var DEFAULT_MAX_WIDTH = 400;
72
72
  var domTitle = title !== undefined ? title : typeof children === 'string' ? children : '';
73
73
  return /*#__PURE__*/React.createElement("span", {
74
74
  className: classNames(prefixCls('container'), (_classNames = {}, _defineProperty(_classNames, prefixCls('small'), size === 'small'), _defineProperty(_classNames, prefixCls('large'), size === 'large'), _defineProperty(_classNames, prefixCls('disabled'), disabled), _classNames), className || ''),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloudata/aloudata-design",
3
- "version": "2.19.4",
3
+ "version": "2.19.6",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -60,7 +60,7 @@
60
60
  ],
61
61
  "dependencies": {
62
62
  "@ant-design/cssinjs": "^1.9.1",
63
- "@floating-ui/react": "^0.26.15",
63
+ "@floating-ui/react": "^0.27.19",
64
64
  "@radix-ui/react-scroll-area": "^1.0.4",
65
65
  "@rc-component/color-picker": "^2.0.1",
66
66
  "@szhsin/react-menu": "^4.1.0",