x-ui-design 0.9.60 → 0.9.62
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/esm/types/hooks/usePopupPosition.d.ts +2 -1
- package/dist/index.esm.js +32 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +32 -14
- package/dist/index.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.tsx +1 -0
- package/lib/components/Menu/Menu.tsx +13 -6
- package/lib/components/Menu/index.css +1 -0
- package/lib/components/Select/Select.tsx +1 -1
- package/lib/hooks/usePopupPosition.ts +11 -1
- package/package.json +1 -1
- package/src/app/page.tsx +2 -2
|
@@ -7,8 +7,9 @@ type TPopupPosition = {
|
|
|
7
7
|
popupRef: RefObject<HTMLDivElement | null>;
|
|
8
8
|
placement?: Placement;
|
|
9
9
|
popupContainer?: HTMLElement | null;
|
|
10
|
+
useTargetWidth?: boolean;
|
|
10
11
|
};
|
|
11
|
-
export declare const usePopupPosition: ({ open, setOpen, popupRef, targetRef, placement, popupContainer, }: TPopupPosition) => {
|
|
12
|
+
export declare const usePopupPosition: ({ open, setOpen, popupRef, targetRef, placement, popupContainer, useTargetWidth }: TPopupPosition) => {
|
|
12
13
|
_placement: Placement;
|
|
13
14
|
popupStyle: CSSProperties;
|
|
14
15
|
};
|
package/dist/index.esm.js
CHANGED
|
@@ -2626,7 +2626,8 @@ const usePopupPosition = ({
|
|
|
2626
2626
|
popupRef,
|
|
2627
2627
|
targetRef,
|
|
2628
2628
|
placement,
|
|
2629
|
-
popupContainer
|
|
2629
|
+
popupContainer,
|
|
2630
|
+
useTargetWidth
|
|
2630
2631
|
}) => {
|
|
2631
2632
|
const [_placement, _setPlacement] = useState(placement ?? "bottomLeft");
|
|
2632
2633
|
const [popupPosition, setPopupPosition] = useState({});
|
|
@@ -2671,6 +2672,12 @@ const usePopupPosition = ({
|
|
|
2671
2672
|
}, 10);
|
|
2672
2673
|
return;
|
|
2673
2674
|
}
|
|
2675
|
+
if (targetRef.current && popupRef.current && useTargetWidth) {
|
|
2676
|
+
if (popupRect.width < container.width) {
|
|
2677
|
+
const targetWidth = targetRef.current.offsetWidth;
|
|
2678
|
+
popupRef.current.style.width = `${targetWidth}px`;
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2674
2681
|
const availableSpace = {
|
|
2675
2682
|
top: container.top - (popupRect.height + OFFSET),
|
|
2676
2683
|
bottom: (inBody ? window.innerHeight : scrollableParents?.clientHeight || 0) - (container.bottom + popupRect.height + OFFSET),
|
|
@@ -2772,7 +2779,7 @@ const usePopupPosition = ({
|
|
|
2772
2779
|
};
|
|
2773
2780
|
_calculation();
|
|
2774
2781
|
});
|
|
2775
|
-
}, [targetRef, popupContainer, popupRef, inBody, _placement, setOpen]);
|
|
2782
|
+
}, [targetRef, popupContainer, popupRef, useTargetWidth, inBody, _placement, setOpen]);
|
|
2776
2783
|
useEffect(() => {
|
|
2777
2784
|
if (!open) {
|
|
2778
2785
|
return;
|
|
@@ -4808,7 +4815,8 @@ const Select = ({
|
|
|
4808
4815
|
[`${prefixCls}-tag-container-fixHeight ${prefixClsV3}-tag-container-fixHeight`]: !tagtriggerRef.current
|
|
4809
4816
|
}])
|
|
4810
4817
|
}, hasMode ? /*#__PURE__*/React.createElement(React.Fragment, null, selectedTags.length ? /*#__PURE__*/React.createElement(React.Fragment, null, tagsToDisplay.map((tag, index) => tagRender ? /*#__PURE__*/React.createElement("div", {
|
|
4811
|
-
key: `${index}_${tag}
|
|
4818
|
+
key: `${index}_${tag}`,
|
|
4819
|
+
className: `${prefixCls}-tag-render-container`
|
|
4812
4820
|
}, tagRender?.({
|
|
4813
4821
|
label: (() => {
|
|
4814
4822
|
const option = extractedOptions.find(e => e.value === tag || e.label === tag || e.children === tag);
|
|
@@ -5291,7 +5299,7 @@ var SubMenu$1 = /*#__PURE__*/Object.freeze({
|
|
|
5291
5299
|
default: SubMenu
|
|
5292
5300
|
});
|
|
5293
5301
|
|
|
5294
|
-
var css_248z$3 = ".xUi-menu{box-shadow:0 0 4px rgba(0,0,0,.15);font-size:14px;user-select:none}.xUi-menu,.xUi-menu-sub-list{border-radius:4px;display:flex;flex-direction:column;gap:4px;list-style:none;margin:0;padding:4px}.xUi-menu-sub-list{background:var(--xui-background-color);height:max-content}.xUi-menu-item-group{padding:0 24px!important}.xUi-menu-vertical .xUi-menu-sub-list{background-color:#fff;box-shadow:0 0 4px rgba(0,0,0,.15);left:100%;position:absolute;right:-100%;top:0;width:-webkit-fill-available;z-index:1}.xUi-menu-horizontal{display:flex;flex-direction:row}.xUi-menu-item{align-items:center;border-radius:4px;color:var(--xui-text-color);cursor:pointer;display:flex;height:40px;min-height:40px;padding:0 12px;transition:background .3s}.xUi-menu-item:hover{background:rgba(0,0,0,.04)}.xUi-menu-item-icon{margin-right:8px}.xUi-menu-sub{border-radius:6px;position:relative}.xUi-menu-sub-title{align-items:center;cursor:pointer;display:flex;height:40px;padding:0 12px;&:hover{background-color:var(--xui-color-hover);border-radius:6px}}.xUi-menu-sub-label{flex:1}.xUi-menu-sub-arrow{margin-left:8px;transition:transform .2s}.xUi-menu-vertical .xUi-menu-sub-arrow{transform:rotate(-90deg)}.xUi-menu-group{list-style:none;margin:0;padding:0}.xUi-menu-group-title{color:rgba(0,0,0,.45);font-size:12px;padding:8px 12px}.xUi-menu-group-list{list-style:none;margin:0;padding:0}.xUi-menu-divider{border-bottom:1px solid var(--xui-color-disabled);display:block;margin:0 auto;width:calc(100% - 16px)}.xUi-menu-item.xUi-menu-item-disabled{cursor:auto;opacity:.6;&:hover{background-color:unset}}.xUi-menu-inline .xUi-menu-sub-list{background-color:var(--xui-background-color)}.xUi-menu-inline .xUi-menu-item{padding:0 24px}.xUi-menu-inline .xUi-menu-sub-title{padding:0 20px}.xUi-menu-inline .xUi-menu-sub-list-sub .xUi-menu-item{padding:0 30px}";
|
|
5302
|
+
var css_248z$3 = ".xUi-menu{box-shadow:0 0 4px rgba(0,0,0,.15);font-size:14px;user-select:none}.xUi-menu,.xUi-menu-sub-list{border-radius:4px;display:flex;flex-direction:column;gap:4px;list-style:none;margin:0;padding:4px}.xUi-menu-sub-list{background:var(--xui-background-color);height:max-content}.xUi-menu-item-group{padding:0 24px!important}.xUi-menu-vertical .xUi-menu-sub-list{background-color:#fff;box-shadow:0 0 4px rgba(0,0,0,.15);left:100%;position:absolute;right:-100%;top:0;width:-webkit-fill-available;z-index:1}.xUi-menu-horizontal{display:flex;flex-direction:row}.xUi-menu-item{align-items:center;border-radius:4px;color:var(--xui-text-color);cursor:pointer;display:flex;height:40px;min-height:40px;padding:0 12px;transition:background .3s}.xUi-menu-item-selected,.xUi-menu-item:hover{background:rgba(0,0,0,.04)}.xUi-menu-item-icon{margin-right:8px}.xUi-menu-sub{border-radius:6px;position:relative}.xUi-menu-sub-title{align-items:center;cursor:pointer;display:flex;height:40px;padding:0 12px;&:hover{background-color:var(--xui-color-hover);border-radius:6px}}.xUi-menu-sub-label{flex:1}.xUi-menu-sub-arrow{margin-left:8px;transition:transform .2s}.xUi-menu-vertical .xUi-menu-sub-arrow{transform:rotate(-90deg)}.xUi-menu-group{list-style:none;margin:0;padding:0}.xUi-menu-group-title{color:rgba(0,0,0,.45);font-size:12px;padding:8px 12px}.xUi-menu-group-list{list-style:none;margin:0;padding:0}.xUi-menu-divider{border-bottom:1px solid var(--xui-color-disabled);display:block;margin:0 auto;width:calc(100% - 16px)}.xUi-menu-item.xUi-menu-item-disabled{cursor:auto;opacity:.6;&:hover{background-color:unset}}.xUi-menu-inline .xUi-menu-sub-list{background-color:var(--xui-background-color)}.xUi-menu-inline .xUi-menu-item{padding:0 24px}.xUi-menu-inline .xUi-menu-sub-title{padding:0 20px}.xUi-menu-inline .xUi-menu-sub-list-sub .xUi-menu-item{padding:0 30px}";
|
|
5295
5303
|
styleInject(css_248z$3);
|
|
5296
5304
|
|
|
5297
5305
|
const MenuContext = /*#__PURE__*/createContext(null);
|
|
@@ -5399,14 +5407,18 @@ const Menu = ({
|
|
|
5399
5407
|
itemKey: it.key,
|
|
5400
5408
|
label: it.label,
|
|
5401
5409
|
icon: it.icon,
|
|
5410
|
+
selected: selectedKeys.includes(it.key),
|
|
5402
5411
|
className: `${prefixCls}-item-disabled`
|
|
5403
|
-
}), (it.children || []).map((c, i) =>
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5412
|
+
}), (it.children || []).map((c, i) => {
|
|
5413
|
+
return /*#__PURE__*/React.createElement(MenuItem, {
|
|
5414
|
+
key: `${c.key}_${i}_menu-item`,
|
|
5415
|
+
itemKey: c.key,
|
|
5416
|
+
label: c.label,
|
|
5417
|
+
icon: c.icon,
|
|
5418
|
+
selected: selectedKeys.includes(c.key),
|
|
5419
|
+
className: `${prefixCls}-item-group`
|
|
5420
|
+
});
|
|
5421
|
+
}));
|
|
5410
5422
|
}
|
|
5411
5423
|
return it.children ? /*#__PURE__*/React.createElement(SubMenu, {
|
|
5412
5424
|
key: `${it.key}_${it.label}_${index}_sub_menu`,
|
|
@@ -5423,12 +5435,14 @@ const Menu = ({
|
|
|
5423
5435
|
itemKey: c.key,
|
|
5424
5436
|
label: c.label,
|
|
5425
5437
|
icon: c.icon,
|
|
5438
|
+
selected: selectedKeys.includes(c.key),
|
|
5426
5439
|
className: `${prefixCls}-item-disabled`
|
|
5427
5440
|
}), (c.children || []).map((c, _i) => /*#__PURE__*/React.createElement(MenuItem, {
|
|
5428
5441
|
key: `${c.key}_${_i}_menu-item`,
|
|
5429
5442
|
itemKey: c.key,
|
|
5430
5443
|
label: c.label,
|
|
5431
5444
|
icon: c.icon,
|
|
5445
|
+
selected: selectedKeys.includes(c.key),
|
|
5432
5446
|
className: `${prefixCls}-item-group`
|
|
5433
5447
|
})));
|
|
5434
5448
|
}
|
|
@@ -5443,18 +5457,21 @@ const Menu = ({
|
|
|
5443
5457
|
key: `${c.key}_${_idx}_${c.label}_menu-item`,
|
|
5444
5458
|
itemKey: c.key,
|
|
5445
5459
|
label: c.label,
|
|
5446
|
-
icon: c.icon
|
|
5460
|
+
icon: c.icon,
|
|
5461
|
+
selected: selectedKeys.includes(c.key)
|
|
5447
5462
|
}))) : /*#__PURE__*/React.createElement(MenuItem, {
|
|
5448
5463
|
key: `${index}_${c.key}_${c.label}_menu-item`,
|
|
5449
5464
|
itemKey: c.key,
|
|
5450
5465
|
label: c.label,
|
|
5451
|
-
icon: c.icon
|
|
5466
|
+
icon: c.icon,
|
|
5467
|
+
selected: selectedKeys.includes(c.key)
|
|
5452
5468
|
});
|
|
5453
5469
|
})) : /*#__PURE__*/React.createElement(MenuItem, {
|
|
5454
5470
|
key: `${index}_${it.key}_menu-item`,
|
|
5455
5471
|
itemKey: it.key,
|
|
5456
5472
|
label: it.label,
|
|
5457
|
-
icon: it.icon
|
|
5473
|
+
icon: it.icon,
|
|
5474
|
+
selected: selectedKeys.includes(it.key)
|
|
5458
5475
|
});
|
|
5459
5476
|
}) : children));
|
|
5460
5477
|
};
|
|
@@ -5504,6 +5521,7 @@ const Dropdown = ({
|
|
|
5504
5521
|
popupRef,
|
|
5505
5522
|
targetRef,
|
|
5506
5523
|
placement,
|
|
5524
|
+
useTargetWidth: true,
|
|
5507
5525
|
popupContainer: getPopupContainer?.(targetRef.current)
|
|
5508
5526
|
});
|
|
5509
5527
|
useEffect(() => {
|