@huibo-ui/react-antd 1.0.12 → 1.0.14
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.
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { HbConfigProvider } from '@huibo-ui/react';
|
|
4
3
|
/**
|
|
5
4
|
* 把 antd 的 ThemeConfig.token 映射到 huibo-ui 的 --hb-* 设计令牌。
|
|
6
5
|
* 写在 document.documentElement(:root) 上,custom property 会穿透 shadow DOM,
|
|
@@ -76,5 +75,22 @@ export function ConfigProvider(props) {
|
|
|
76
75
|
React.useEffect(() => {
|
|
77
76
|
applyThemeToken(theme?.token);
|
|
78
77
|
}, [theme?.token]);
|
|
79
|
-
|
|
78
|
+
// 设置 data-size / data-locale / data-theme 到 documentElement
|
|
79
|
+
// (原 hb-config-provider 的 applyConfig 逻辑,改为直接写 :root,避免额外 DOM 层)
|
|
80
|
+
React.useEffect(() => {
|
|
81
|
+
const root = document.documentElement;
|
|
82
|
+
root.setAttribute('data-size', props.componentSize === 'middle' ? 'default' : (props.componentSize || 'default'));
|
|
83
|
+
root.setAttribute('data-locale', props.locale ? 'zh-CN' : 'en-US');
|
|
84
|
+
if (theme?.dark) {
|
|
85
|
+
root.setAttribute('data-theme', 'dark');
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
root.removeAttribute('data-theme');
|
|
89
|
+
}
|
|
90
|
+
}, [theme?.dark, props.componentSize, props.locale]);
|
|
91
|
+
// 直接返回 children,不包裹任何 DOM 元素 —— 对齐 antd ConfigProvider
|
|
92
|
+
// (antd 用 React Context + CSS-in-JS,零 DOM 层)。
|
|
93
|
+
// 之前渲染 hb-config-provider(display:contents)会改变 #root 子元素结构,
|
|
94
|
+
// 导致 #root { height:100% } 在某些高度链下解析失效(全屏背景图场景)。
|
|
95
|
+
return _jsx(_Fragment, { children: children });
|
|
80
96
|
}
|
package/lib/components/Layout.js
CHANGED
|
@@ -32,12 +32,17 @@ Layout.Sider = function Sider({ children, style, className, collapsed, theme, wi
|
|
|
32
32
|
/**
|
|
33
33
|
* Content —— 主内容区。flex:1 撑满剩余空间。
|
|
34
34
|
*
|
|
35
|
-
* 对齐 antd .ant-layout-content(flex: auto + min-height: 0
|
|
36
|
-
*
|
|
37
|
-
*
|
|
35
|
+
* 对齐 antd .ant-layout-content(flex: auto + min-height: 0)。
|
|
36
|
+
*
|
|
37
|
+
* 过滤消费方传入的 height:'auto':这是常见脆弱写法,会让 flex item 的
|
|
38
|
+
* height 指定值变成 auto,导致子元素 height:100% 解析失败(如全屏背景图
|
|
39
|
+
* 容器)。去掉它让 flex 算法自然分配高度,子元素 height:100% 才能生效。
|
|
38
40
|
*/
|
|
39
41
|
Layout.Content = function Content({ children, style, className }) {
|
|
40
|
-
|
|
42
|
+
const { height, ...restStyle } = style || {};
|
|
43
|
+
// 仅过滤无效的 height:'auto';显式数值/百分比仍保留
|
|
44
|
+
const filteredStyle = height === 'auto' ? restStyle : style;
|
|
45
|
+
return (_jsx("div", { style: { flex: '1 1 auto', minWidth: 0, minHeight: 0, ...filteredStyle }, className: className, children: children }));
|
|
41
46
|
};
|
|
42
47
|
/**
|
|
43
48
|
* Footer —— 页脚。固定高度。
|