@huibo-ui/react-antd 1.0.14 → 1.0.16

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,5 +1,6 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
+ import { HbConfigProvider } from '@huibo-ui/react';
3
4
  /**
4
5
  * 把 antd 的 ThemeConfig.token 映射到 huibo-ui 的 --hb-* 设计令牌。
5
6
  * 写在 document.documentElement(:root) 上,custom property 会穿透 shadow DOM,
@@ -75,22 +76,5 @@ export function ConfigProvider(props) {
75
76
  React.useEffect(() => {
76
77
  applyThemeToken(theme?.token);
77
78
  }, [theme?.token]);
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 });
79
+ return (_jsx(HbConfigProvider, { theme: theme?.dark ? 'dark' : 'light', size: props.componentSize === 'middle' ? 'default' : props.componentSize, locale: props.locale ? 'zh-CN' : 'en-US', children: _jsx("div", { style: { display: 'contents' }, children: children }) }));
96
80
  }
@@ -10,7 +10,10 @@ export function Layout(props) {
10
10
  display: 'flex',
11
11
  flexDirection: siderDetected ? 'row' : 'column',
12
12
  flex: 1,
13
- minHeight: 0,
13
+ // 对齐 antd .ant-layout { min-height: 100vh }:最外层 Layout 在非 flex 父容器
14
+ // (如 #root)里时,flex:1 不生效,用 min-height:100vh 兜底撑满视口。
15
+ // 内层 Layout 会被 flex 父的 height 约束覆盖(minHeight 仅是下限,不破坏布局)。
16
+ minHeight: '100vh',
14
17
  width: '100%',
15
18
  ...style,
16
19
  };
@@ -34,14 +37,16 @@ Layout.Sider = function Sider({ children, style, className, collapsed, theme, wi
34
37
  *
35
38
  * 对齐 antd .ant-layout-content(flex: auto + min-height: 0)。
36
39
  *
37
- * 过滤消费方传入的 height:'auto':这是常见脆弱写法,会让 flex item 的
38
- * height 指定值变成 auto,导致子元素 height:100% 解析失败(如全屏背景图
39
- * 容器)。去掉它让 flex 算法自然分配高度,子元素 height:100% 才能生效。
40
+ * 当消费方传入 height:'auto'(常见脆弱写法)时,替换为 height:0:
41
+ * flex item 的 height 指定值为 auto 会导致子元素 height:100% 解析失败
42
+ * (浏览器 quirk:flex item 的 auto height 不能被子元素百分比解析)。
43
+ * 设为 0(确定值)后,flex 算法仍会按 flex-grow 分配实际高度,且子元素
44
+ * height:100% 能正确解析为分配后的 used value(如全屏背景图场景)。
40
45
  */
41
46
  Layout.Content = function Content({ children, style, className }) {
42
47
  const { height, ...restStyle } = style || {};
43
- // 仅过滤无效的 height:'auto';显式数值/百分比仍保留
44
- const filteredStyle = height === 'auto' ? restStyle : style;
48
+ // height:'auto' → height:0(修正 flex 百分比高度解析 quirk);其它值保留
49
+ const filteredStyle = height === 'auto' ? { ...restStyle, height: 0 } : style;
45
50
  return (_jsx("div", { style: { flex: '1 1 auto', minWidth: 0, minHeight: 0, ...filteredStyle }, className: className, children: children }));
46
51
  };
47
52
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huibo-ui/react-antd",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "antd 兼容层 — 接收 antd 原生 props,内部转换为 huibo-ui,实现丝滑平替",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",