diff --git a/docs/charts/charts-CHANGELOG.md b/docs/charts/charts-CHANGELOG.md
index 0403b418e..abc7b043c 100644
--- a/docs/charts/charts-CHANGELOG.md
+++ b/docs/charts/charts-CHANGELOG.md
@@ -8,6 +8,13 @@ group: 可视化图表
---
+## 0.2.22
+
+`2024-01-18`
+
+- 🆕 Stat 新增 padding 属性,用于设置图表的内间距。[#412](https://github.com/oceanbase/oceanbase-design/pull/412)
+- 🐞 修复 Pie 环图统计组件标题和内容 `formatter` 不生效的问题。[#413](https://github.com/oceanbase/oceanbase-design/pull/413)
+
## 0.2.21
`2024-01-12`
diff --git a/docs/design/design-CHANGELOG.md b/docs/design/design-CHANGELOG.md
index 047d19a80..1501208ea 100644
--- a/docs/design/design-CHANGELOG.md
+++ b/docs/design/design-CHANGELOG.md
@@ -8,6 +8,31 @@ group: 基础组件
---
+## 0.2.37
+
+`2024-01-30`
+
+- 🆕 新增 injectStaticFunction 属性,用于配置 message、notification 和 Modal 静态方法是否可以消费全局配置,默认开启。[#446](https://github.com/oceanbase/oceanbase-design/pull/446)
+- 🐞 修复 Typography 的样式优先级,保证字体和行高默认继承父元素,便于和其他组件组合使用。[#428](https://github.com/oceanbase/oceanbase-design/pull/428) [@wdyea-ya](https://github.com/wdyea-ya)
+- 🐞 修复 Table 选中行和 `hover` 行的背景色不一致的问题。[#455](https://github.com/oceanbase/oceanbase-design/pull/455)
+
+## 0.2.36
+
+`2024-01-19`
+
+- 💄 ConfigProvider 内嵌的 App 组件不再创建 DOM 节点,避免增加一层 DOM 结构影响子元素的样式表现。[#431](https://github.com/oceanbase/oceanbase-design/pull/431)
+
+## 0.2.35
+
+`2024-01-18`
+
+- 🆕 ConfigProvider 新增 table.selectionColumnWidth 属性,用于配置表格的展开列宽度。[#421](https://github.com/oceanbase/oceanbase-design/pull/421)
+- Table
+ - 🐞 修复 Table 可展开时底部出现重复边框的问题。[#420](https://github.com/oceanbase/oceanbase-design/pull/420)
+ - 💄 优化 Table 在无间距卡片内的展示样式,包括第一列和卡片标题对齐、最后一列和卡片操作区对齐、分页器左右增加间距。[#422](https://github.com/oceanbase/oceanbase-design/pull/422)
+ - 💄 减小 Table 单元格的纵向内间距,以对齐设计规范。[#425](https://github.com/oceanbase/oceanbase-design/pull/425)
+- 💄 Modal 去掉最大高度限制,高度超出时内容滚动改由上层控制。[#411](https://github.com/oceanbase/oceanbase-design/pull/411)
+
## 0.2.34
`2024-01-12`
diff --git a/docs/ui/ui-CHANGELOG.md b/docs/ui/ui-CHANGELOG.md
index 5a931147c..22936df76 100644
--- a/docs/ui/ui-CHANGELOG.md
+++ b/docs/ui/ui-CHANGELOG.md
@@ -8,6 +8,32 @@ group: 业务组件
---
+## 0.2.38
+
+`2024-01-30`
+
+- PageContainer
+ - 🐞 修复 PageContainer 页头和页脚操作区外的组件尺寸也可能被改为 large 的问题。[#443](https://github.com/oceanbase/oceanbase-design/pull/443)
+ - 💄 修复 PageContainer 页头和页脚操作区样式适配 Space.Compact 组件。[#454](https://github.com/oceanbase/oceanbase-design/pull/454)
+- 🐞 修复 FooterToolbar 子元素外的组件尺寸被改为 large 的问题。[#447](https://github.com/oceanbase/oceanbase-design/pull/447)
+
+## 0.2.37
+
+`2024-01-19`
+
+- PageContainer
+ - 💄 PageContainer 页头和页脚操作区的组件尺寸默认为 `large`、字体大小为 `middle`。[#432](https://github.com/oceanbase/oceanbase-design/pull/432)
+ - 💄 优化 PageContainer 和 Tabs 组合使用时的间距,以对齐设计规范。[#434](https://github.com/oceanbase/oceanbase-design/pull/434)
+- 💄 FooterToolbar 子元素的组件尺寸默认为 `large`、字体大小默认为 `middle`。[#433](https://github.com/oceanbase/oceanbase-design/pull/433)
+
+## 0.2.36
+
+`2024-01-18`
+
+- 🐞 修复 Password 组件快速输入时丢失字符和焦点跳跃的问题。[#424](https://github.com/oceanbase/oceanbase-design/pull/424) [@Vanleehao](https://github.com/Vanleehao)
+- 🐞 修复 Highlight 国际化不生效的问题。[#419](https://github.com/oceanbase/oceanbase-design/pull/419) [@linhf123](https://github.com/linhf123)
+- 💄 优化 PageContainer 右上角和页脚操作区中的 Input 样式,保证宽高和字体大小符合设计规范。[#426](https://github.com/oceanbase/oceanbase-design/pull/426)
+
## 0.2.35
`2024-01-12`
diff --git a/package.json b/package.json
index 97cfd885c..330cddefa 100644
--- a/package.json
+++ b/package.json
@@ -59,15 +59,15 @@
"@testing-library/jest-dom": "^6.2.0",
"@testing-library/react": "^14.1.0",
"@testing-library/react-hooks": "^8.0.1",
- "@testing-library/user-event": "^14.5.1",
+ "@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.10",
"@types/lodash": "^4.14.202",
"@types/node": "^20.10.5",
"@types/react": "^18.2.47",
"@umijs/fabric": "^4.0.1",
- "@umijs/test": "^4.0.90",
+ "@umijs/test": "^4.1.0",
"@vercel/analytics": "^1.1.1",
- "antd": "^5.11.2",
+ "antd": "^5.13.2",
"antd-style": "3.5.2",
"antd-token-previewer": "^2.0.5",
"babel-jest": "^29.7.0",
@@ -98,7 +98,7 @@
"lodash": "^4.17.21",
"lz-string": "^1.5.0",
"mockdate": "^3.0.5",
- "prettier": "^3.1.1",
+ "prettier": "^3.2.4",
"prismjs": "^1.29.0",
"rc-checkbox": "^3.1.0",
"rc-drawer": "^7.0.0",
@@ -120,7 +120,7 @@
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "^5.3.3",
- "vanilla-jsoneditor": "^0.21.1",
+ "vanilla-jsoneditor": "^0.21.2",
"web-vitals": "^3.5.0",
"yorkie": "^2.0.0"
}
diff --git a/packages/charts/package.json b/packages/charts/package.json
index af2ab26a4..cd66b6fa6 100644
--- a/packages/charts/package.json
+++ b/packages/charts/package.json
@@ -1,6 +1,6 @@
{
"name": "@oceanbase/charts",
- "version": "0.2.21",
+ "version": "0.2.22",
"description": "The Chart library for OceanBase",
"homepage": "https://github.com/oceanbase/oceanbase-design/packages/charts",
"repository": {
diff --git a/packages/charts/src/Pie/__tests__/__snapshots__/donut.test.tsx.snap b/packages/charts/src/Pie/__tests__/__snapshots__/donut.test.tsx.snap
index 7c0ca91e2..43467c8ae 100644
--- a/packages/charts/src/Pie/__tests__/__snapshots__/donut.test.tsx.snap
+++ b/packages/charts/src/Pie/__tests__/__snapshots__/donut.test.tsx.snap
@@ -2,102 +2,90 @@
exports[`donut floor number 1`] = `
+`;
+
+exports[`donut statistic title and content formatter 1`] = `
+
`;
diff --git a/packages/charts/src/Pie/__tests__/donut.test.tsx b/packages/charts/src/Pie/__tests__/donut.test.tsx
index 20602032e..f98b941f2 100644
--- a/packages/charts/src/Pie/__tests__/donut.test.tsx
+++ b/packages/charts/src/Pie/__tests__/donut.test.tsx
@@ -1,11 +1,65 @@
import React from 'react';
import { render } from '@testing-library/react';
-import DonutFloor from '../demo/donut-floor';
+import { Pie } from '@oceanbase/charts';
+import type { PieConfig } from '@oceanbase/charts';
+
+const DonutTest = (props: Partial) => {
+ const data = [
+ {
+ type: '分类一',
+ value: 1.3,
+ },
+ {
+ type: '分类二',
+ value: 3.38,
+ },
+ {
+ type: '分类三',
+ value: 4.56,
+ },
+ {
+ type: '分类四',
+ value: 5.7,
+ },
+ {
+ type: '分类五',
+ value: 6.22,
+ },
+ ];
+ const config: PieConfig = {
+ data,
+ angleField: 'value',
+ colorField: 'type',
+ isDonut: true,
+ ...props,
+ };
+ return ;
+};
describe('donut', () => {
it('floor number', () => {
- const { container, asFragment } = render();
+ const { container, asFragment } = render();
expect(container.querySelectorAll('.g2-html-annotation')?.[1].textContent).toBe('21.16');
expect(asFragment().firstChild).toMatchSnapshot();
});
+
+ it('statistic title and content formatter', () => {
+ const { container, asFragment } = render(
+ 'custom title',
+ },
+ content: {
+ formatter: () => 'custom content',
+ },
+ }}
+ />
+ );
+ expect(container.querySelectorAll('.g2-html-annotation')?.[0].textContent).toBe('custom title');
+ expect(container.querySelectorAll('.g2-html-annotation')?.[1].textContent).toBe(
+ 'custom content'
+ );
+ expect(asFragment().firstChild).toMatchSnapshot();
+ });
});
diff --git a/packages/charts/src/Pie/index.tsx b/packages/charts/src/Pie/index.tsx
index 67ed9f1b6..f86ee1230 100644
--- a/packages/charts/src/Pie/index.tsx
+++ b/packages/charts/src/Pie/index.tsx
@@ -2,7 +2,7 @@ import React, { forwardRef } from 'react';
import type { PieConfig as AntPieConfig } from '@ant-design/charts';
import { Pie as AntPie } from '@ant-design/charts';
import { formatNumber } from '@oceanbase/util';
-import { isString } from 'lodash';
+import { isFunction, toString } from 'lodash';
import { useTheme } from '../theme';
import type { Theme } from '../theme';
import { customMemo } from '../util/custom-memo';
@@ -13,7 +13,7 @@ export const measureTextSize = (text: string, font: any = {}) => {
if (ctx) {
// @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/font
ctx.font = [fontStyle, fontWeight, fontVariant, `${fontSize}px`, fontFamily].join(' ');
- const metrics = ctx?.measureText(isString(text) ? text : '');
+ const metrics = ctx?.measureText(toString(text) || '');
return {
width: metrics.width,
// ref: https://zhuanlan.zhihu.com/p/455132377
@@ -133,11 +133,16 @@ const Pie = forwardRef(
// content 为空时,默认的 customHtml 才生效
...(statistic?.title?.content === undefined
? {
- customHtml: (container, view, datum) => {
+ customHtml: (container, view, datum, filterData) => {
const { width, height } = container.getBoundingClientRect();
const d = Math.sqrt(Math.pow(width / 2, 2) + Math.pow(height / 2, 2));
// 开启 pie-statistic-active 交互时,datum[colorField] 不为空
- const text = datum ? datum[colorField] : statisticTitle;
+ const title = datum ? datum[colorField] : statisticTitle;
+
+ // format title
+ const formatter = statistic?.title && statistic?.title?.formatter;
+ const text = isFunction(formatter) ? formatter(datum, filterData) : title;
+
return renderStatistic(d, text, {
// 这里的字体大小仅用于计算文本宽高,不用于实际样式
fontSize: titleFontSize,
@@ -161,9 +166,14 @@ const Pie = forwardRef(
? {
customHtml: (container, view, datum, filterData) => {
const { width } = container.getBoundingClientRect();
- const text = datum
+ const total = datum
? `${datum[angleField]}`
: `${formatNumber(filterData?.reduce((a, b) => a + b[angleField], 0))}`;
+
+ // format content
+ const formatter = statistic?.content && statistic?.content?.formatter;
+ const text = isFunction(formatter) ? formatter(datum, filterData) : `${total}`;
+
return renderStatistic(width, text, {
// 这里的字体大小仅用于计算文本宽高,不用于实际样式
fontSize: contentFontSize,
diff --git a/packages/charts/src/Score/demo/basic.tsx b/packages/charts/src/Score/demo/basic.tsx
index d73f67f1e..329a3c82b 100644
--- a/packages/charts/src/Score/demo/basic.tsx
+++ b/packages/charts/src/Score/demo/basic.tsx
@@ -8,7 +8,7 @@ export default () => {
return (
+
setSize(e.target.value)}>
Large
Default
diff --git a/packages/charts/src/Stat/index.md b/packages/charts/src/Stat/index.md
index d77aa54d5..3a46b2987 100644
--- a/packages/charts/src/Stat/index.md
+++ b/packages/charts/src/Stat/index.md
@@ -15,6 +15,7 @@ nav:
| :---------- | :------------------- | :-------------------------------------- | :--------- | :--- |
| width | 图表宽度 | number | 容器宽度 | - |
| height | 图表高度 | number | 400 | - |
+| padding | 图表内间距 | number | 8 | - |
| title | 标题 | string | - | - |
| value | 数值 | number | - | - |
| prefix | 数值前缀 | string | - | - |
diff --git a/packages/charts/src/Stat/index.tsx b/packages/charts/src/Stat/index.tsx
index b2d889d7a..71d766333 100644
--- a/packages/charts/src/Stat/index.tsx
+++ b/packages/charts/src/Stat/index.tsx
@@ -14,6 +14,7 @@ import './index.less';
export interface StatConfig {
width?: number;
height?: number;
+ padding?: number;
title?: string;
value?: number;
prefix?: string;
@@ -50,6 +51,7 @@ function fontSizeReductionFactor(fontSize: number) {
const Stat: React.FC = ({
width,
height,
+ padding = 8,
title,
value,
prefix,
@@ -73,7 +75,6 @@ const Stat: React.FC = ({
height: containerHeight = 0,
} = useResizeObserver();
const isFlat = containerHeight < 72;
- const padding = containerHeight > 100 ? 12 : 8;
const maxWidth = containerWidth - padding * 2;
const maxHeight = containerHeight - padding * 2;
diff --git a/packages/codemod/package.json b/packages/codemod/package.json
index efe54f14e..4d499a429 100644
--- a/packages/codemod/package.json
+++ b/packages/codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@oceanbase/codemod",
- "version": "0.2.15",
+ "version": "0.2.16",
"description": "Codemod for OceanBase Design upgrade",
"keywords": [
"oceanbase",
@@ -34,7 +34,7 @@
"lodash": "^4.17.21",
"postcss": "^8.4.33",
"postcss-less": "^6.0.0",
- "prettier": "^3.1.1",
+ "prettier": "^3.2.4",
"read-pkg-up": "^10.1.0",
"semver": "^7.5.4",
"update-check": "^1.5.4",
diff --git a/packages/design/package.json b/packages/design/package.json
index d6e0e2152..3de8f941e 100644
--- a/packages/design/package.json
+++ b/packages/design/package.json
@@ -1,6 +1,6 @@
{
"name": "@oceanbase/design",
- "version": "0.2.34",
+ "version": "0.2.37",
"description": "The Design System of OceanBase",
"keywords": [
"oceanbase",
@@ -39,7 +39,7 @@
"@oceanbase/icons": "workspace:^",
"@oceanbase/util": "workspace:^",
"ahooks": "^2.10.14",
- "antd": "^5.11.2",
+ "antd": "^5.13.2",
"classnames": "^2.5.1",
"lodash": "^4.17.21",
"lottie-web": "^5.12.2",
diff --git a/packages/design/src/card/index.md b/packages/design/src/card/index.md
index a55b54b3d..549467386 100644
--- a/packages/design/src/card/index.md
+++ b/packages/design/src/card/index.md
@@ -24,6 +24,8 @@ nav:
+
+
## API
| 参数 | 说明 | 类型 | 默认值 | 版本 |
diff --git a/packages/design/src/card/index.tsx b/packages/design/src/card/index.tsx
index 9084bc91a..5afe2b426 100644
--- a/packages/design/src/card/index.tsx
+++ b/packages/design/src/card/index.tsx
@@ -24,7 +24,16 @@ export interface CardProps extends AntCardProps {
const Card = React.forwardRef(
(
- { children, divided = true, tabList, prefixCls: customizePrefixCls, className, ...restProps },
+ {
+ children,
+ size,
+ divided = true,
+ tabList,
+ prefixCls: customizePrefixCls,
+ bodyStyle,
+ className,
+ ...restProps
+ },
ref
) => {
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
@@ -32,9 +41,13 @@ const Card = React.forwardRef(
const tabsPrefixCls = getPrefixCls('tabs', customizePrefixCls);
const { wrapSSR } = useStyle(prefixCls, tabsPrefixCls);
+ // card body has no padding
+ const noBodyPadding = [0, '0', '0px'].includes(bodyStyle?.padding);
+
const cardCls = classNames(
{
[`${prefixCls}-no-divider`]: !divided,
+ [`${prefixCls}-no-body-padding`]: noBodyPadding,
},
className
);
@@ -57,15 +70,30 @@ const Card = React.forwardRef(
});
return wrapSSR(
-
- {children}
-
+
+ {children}
+
+
);
}
);
diff --git a/packages/design/src/card/style/index.ts b/packages/design/src/card/style/index.ts
index 9c1917605..a03b4fba6 100644
--- a/packages/design/src/card/style/index.ts
+++ b/packages/design/src/card/style/index.ts
@@ -8,6 +8,37 @@ export type CardToken = FullToken<'Card'> & {
tabsPrefixCls: string;
};
+export const genTableStyle = (padding: number, token: CardToken): CSSObject => {
+ const { antCls } = token;
+ const tableComponentCls = `${antCls}-table`;
+ return {
+ [`${tableComponentCls}-wrapper`]: {
+ [`${tableComponentCls}`]: {
+ // first column should align with card title
+ [`${tableComponentCls}-thead > tr > th:first-child, ${tableComponentCls}-tbody > tr > td:first-child`]:
+ {
+ paddingLeft: padding,
+ },
+ // last column should align with card extra
+ [`${tableComponentCls}-thead > tr > th:last-child, ${tableComponentCls}-tbody > tr > td:last-child`]:
+ {
+ paddingRight: padding,
+ },
+ },
+ [`${tableComponentCls}-pagination${antCls}-pagination`]: {
+ // add marginLeft for table batchOperationBar
+ [`${tableComponentCls}-batch-operation-bar`]: {
+ marginLeft: padding,
+ },
+ // add marginRight for table pagination
+ [`& > li:last-child`]: {
+ marginRight: padding,
+ },
+ },
+ },
+ };
+};
+
export const genCardStyle: GenerateStyle = (token: CardToken): CSSObject => {
const { componentCls, tabsComponentCls, tabsPrefixCls, padding, paddingSM, paddingLG } = token;
return {
@@ -51,6 +82,13 @@ export const genCardStyle: GenerateStyle = (token: CardToken): CSSObj
marginBottom: 0,
},
},
+ // no body padding card
+ [`${componentCls}${componentCls}-no-body-padding`]: genTableStyle(paddingLG, token),
+ // no body padding small card
+ [`${componentCls}${componentCls}-no-body-padding${componentCls}-small`]: genTableStyle(
+ paddingSM,
+ token
+ ),
};
};
diff --git a/packages/design/src/config-provider/__tests__/__snapshots__/prefixCls.tsx.snap b/packages/design/src/config-provider/__tests__/__snapshots__/prefixCls.tsx.snap
index b0aeee9ca..eb13988cf 100644
--- a/packages/design/src/config-provider/__tests__/__snapshots__/prefixCls.tsx.snap
+++ b/packages/design/src/config-provider/__tests__/__snapshots__/prefixCls.tsx.snap
@@ -1,121 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`ConfigProvider prefixCls prefixCls 1`] = `
-
-
-
-
-
-
-
-
-
+
+
+
+
`;
-exports[`ConfigProvider prefixCls iconPrefixCls 1`] = `
-
+
`;
diff --git a/packages/design/src/config-provider/__tests__/__snapshots__/spin.test.tsx.snap b/packages/design/src/config-provider/__tests__/__snapshots__/spin.test.tsx.snap
index b85980572..8f03ef83d 100644
--- a/packages/design/src/config-provider/__tests__/__snapshots__/spin.test.tsx.snap
+++ b/packages/design/src/config-provider/__tests__/__snapshots__/spin.test.tsx.snap
@@ -2,49 +2,24 @@
exports[`ConfigProvider spin spin.indicator should work 1`] = `
+ class="custom-indicator ant-spin-dot"
+ />
`;
exports[`ConfigProvider spin spin.indicator should work in nested ConfigProvider 1`] = `
-
+ class="custom-indicator-1 ant-spin-dot"
+ />
`;
diff --git a/packages/design/src/config-provider/__tests__/__snapshots__/styleProviderProps.test.tsx.snap b/packages/design/src/config-provider/__tests__/__snapshots__/styleProviderProps.test.tsx.snap
index bee5b4f54..c32130d61 100644
--- a/packages/design/src/config-provider/__tests__/__snapshots__/styleProviderProps.test.tsx.snap
+++ b/packages/design/src/config-provider/__tests__/__snapshots__/styleProviderProps.test.tsx.snap
@@ -1,19 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`ConfigProvider styleProviderProps ConfigProvider styleProviderProps.hashPriority 1`] = `
-
-`;
+exports[`ConfigProvider styleProviderProps ConfigProvider styleProviderProps.hashPriority 1`] = ``;
diff --git a/packages/design/src/config-provider/__tests__/spin.test.tsx b/packages/design/src/config-provider/__tests__/spin.test.tsx
index af56554ae..007d6430e 100644
--- a/packages/design/src/config-provider/__tests__/spin.test.tsx
+++ b/packages/design/src/config-provider/__tests__/spin.test.tsx
@@ -1,7 +1,6 @@
import React from 'react';
import { render } from '@testing-library/react';
-import ConfigProvider from '..';
-import Spin from '../../spin';
+import { ConfigProvider, Spin } from '@oceanbase/design';
describe('ConfigProvider spin', () => {
it('spin.indicator should work', () => {
diff --git a/packages/design/src/config-provider/__tests__/table.test.tsx b/packages/design/src/config-provider/__tests__/table.test.tsx
new file mode 100644
index 000000000..3df8c8881
--- /dev/null
+++ b/packages/design/src/config-provider/__tests__/table.test.tsx
@@ -0,0 +1,35 @@
+import React, { useContext } from 'react';
+import { ConfigProvider } from '@oceanbase/design';
+
+describe('ConfigProvider table', () => {
+ it('table.selectionColumnWidth should work', () => {
+ const Child1 = () => {
+ const { table } = useContext(ConfigProvider.ConfigContext);
+ expect(table?.selectionColumnWidth).toBe(undefined);
+ return ;
+ };
+ const Child2 = () => {
+ const { table } = useContext(ConfigProvider.ConfigContext);
+ expect(table?.selectionColumnWidth).toBe(48);
+ return ;
+ };
+ const Child3 = () => {
+ const { table } = useContext(ConfigProvider.ConfigContext);
+ expect(table?.selectionColumnWidth).toBe(48);
+ return ;
+ };
+
+
+
+
+
+
+
+
+ ;
+ });
+});
diff --git a/packages/design/src/config-provider/demo/theme.tsx b/packages/design/src/config-provider/demo/theme.tsx
index c9015bbfb..98495f50c 100644
--- a/packages/design/src/config-provider/demo/theme.tsx
+++ b/packages/design/src/config-provider/demo/theme.tsx
@@ -42,10 +42,10 @@ export default () => {
labelCol={{ span: 4 }}
wrapperCol={{ span: 20 }}
>
-
+
-
+
diff --git a/packages/design/src/config-provider/index.md b/packages/design/src/config-provider/index.md
index 89dc5ad2d..f63b0f209 100644
--- a/packages/design/src/config-provider/index.md
+++ b/packages/design/src/config-provider/index.md
@@ -7,6 +7,11 @@ nav:
- 🔥 完全继承 antd [ConfigProvider](https://ant.design/components/config-provider-cn) 的能力和 API,可无缝切换。
- 🆕 默认内嵌 [App 包裹组件](https://ant.design/components/app-cn),支持 message, notification 和 Modal 等静态方法消费 ConfigProvider 配置。
+- 🆕 新增 `table.selectionColumnWidth` 属性,用于配置表格的展开列宽度。
+- 🆕 新增 `injectStaticFunction` 属性,用于配置 `message`, `notification` 和 `Modal` 静态方法是否可以消费全局配置,默认开启。
+
+
+
- 🆕 新增 `styleProviderProps` 属性,一般用于配置 [StyleProvider](https://github.com/ant-design/cssinjs#styleprovider) 的 `hashPriority` 和 `transformers` 属性实现样式降级,来兼容 Chrome 88 以下的低版本浏览器,详见 [antd v5 样式兼容说明](https://ant-design.antgroup.com/docs/react/compatible-style-cn)。
## 代码演示
@@ -41,6 +46,8 @@ export default App;
| 参数 | 说明 | 类型 | 默认值 | 版本 |
| :-- | :-- | :-- | :-- | :-- |
| spin | Spin 全局配置 | `{ indicator?: ReactNode; className?: string; style?: React.CSSProperties; }` | undefined | - |
+| table | Table 全局配置 | `{ selectionColumnWidth?: width; className?: string; style?: React.CSSProperties; }` | undefined | - |
+| injectStaticFunction | 用于配置 `message`, `notification` 和 `Modal` 静态方法是否可以消费全局配置 | boolean | true | - |
| styleProviderProps | [StyleProvider 配置](https://github.com/ant-design/cssinjs#styleprovider),一般用于配置 `hashPriority` 和 `transformers` 属性实现样式降级 | [StyleProviderProps](https://github.com/ant-design/cssinjs/blob/master/src/StyleContext.tsx#L88) | undefined | - |
- 更多 API 详见 antd ConfigProvider 文档: https://ant.design/components/config-provider-cn
diff --git a/packages/design/src/config-provider/index.tsx b/packages/design/src/config-provider/index.tsx
index b016f8437..cad4bfa6b 100644
--- a/packages/design/src/config-provider/index.tsx
+++ b/packages/design/src/config-provider/index.tsx
@@ -33,11 +33,17 @@ export type SpinConfig = ComponentStyleConfig & {
indicator?: SpinIndicator;
};
+export type TableConfig = ComponentStyleConfig & {
+ selectionColumnWidth?: number;
+};
+
export interface ConfigConsumerProps extends AntConfigConsumerProps {
theme?: ThemeConfig;
navigate?: NavigateFunction;
hideOnSinglePage?: boolean;
spin?: SpinConfig;
+ table?: TableConfig;
+ builtInApp?: boolean;
locale?: Locale;
}
@@ -49,6 +55,9 @@ export interface ConfigProviderProps extends AntConfigProviderProps {
navigate?: NavigateFunction;
hideOnSinglePage?: boolean;
spin?: SpinConfig;
+ table?: TableConfig;
+ // inject static function to consume ConfigProvider
+ injectStaticFunction?: boolean;
// StyleProvider props
styleProviderProps?: StyleProviderProps;
}
@@ -65,16 +74,27 @@ const ExtendedConfigContext = React.createContext({
const { defaultSeed } = themeConfig;
-const ConfigProvider = ({
+export type ConfigProviderType = React.FC & {
+ ExtendedConfigContext: typeof ExtendedConfigContext;
+} & {
+ ConfigContext: React.Context;
+ SizeContext: typeof AntConfigProvider.SizeContext;
+ config: typeof AntConfigProvider.config;
+ useConfig: typeof AntConfigProvider.useConfig;
+};
+
+const ConfigProvider: ConfigProviderType = ({
children,
theme,
navigate,
hideOnSinglePage,
spin,
+ table,
tabs,
+ injectStaticFunction = true,
styleProviderProps,
...restProps
-}: ConfigProviderProps) => {
+}) => {
// inherit from parent ConfigProvider
const parentContext = React.useContext(AntConfigProvider.ConfigContext);
const parentExtendedContext =
@@ -89,6 +109,7 @@ const ConfigProvider = ({
return (
(origin >= 24 ? origin - 16 : origin),
@@ -121,9 +142,9 @@ const ConfigProvider = ({
{/* Nested App component for static function of message, notification and Modal to consume ConfigProvider config */}
{/* ref: https://ant.design/components/app */}
-
+
{children}
-
+ {injectStaticFunction && }
@@ -131,8 +152,7 @@ const ConfigProvider = ({
);
};
-ConfigProvider.ConfigContext =
- AntConfigProvider.ConfigContext as React.Context;
+ConfigProvider.ConfigContext = AntConfigProvider.ConfigContext;
ConfigProvider.ExtendedConfigContext = ExtendedConfigContext;
ConfigProvider.SizeContext = AntConfigProvider.SizeContext;
ConfigProvider.config = AntConfigProvider.config;
diff --git a/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap b/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap
index e3341a413..1deda45c6 100644
--- a/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap
+++ b/packages/design/src/drawer/__tests__/__snapshots__/index.test.tsx.snap
@@ -24,55 +24,51 @@ exports[`Drawer render correctly 1`] = `
role="dialog"
>
+
-
- Here is content of Drawer
-
+ Here is content of Drawer
@@ -110,111 +106,107 @@ exports[`Drawer render with confirmLoading and okButtonProps 1`] = `
role="dialog"
>
+
+ Here is content of Drawer
+
+