Compare commits

...

4 Commits

Author SHA1 Message Date
github-actions[bot]
5d3c93bdd6 chore: auto merge branches (#56929)
chore: sync master into feature
2026-02-10 12:46:22 +00:00
二货爱吃白萝卜
61729477bb feat: Space.Addon supprot design token (#56915)
* feat(Space.Addon): add ComponentToken interface and init function

- Create token.ts with 6 customizable tokens
- Add paddingInline, paddingInlineSM, borderRadius, borderRadiusSM, borderRadiusLG, lineWidth
- Include JSDoc comments with Chinese and English descriptions

* feat(Space.Addon): consume component tokens in addon styles

- Update addon.ts to use ComponentToken from token.ts
- Replace global token usage with component tokens (paddingSM -> paddingInline, etc.)
- Register with genStyleHooks using 'Addon' and initComponentToken

* feat(theme): register Addon component in ComponentTokenMap

- Add AddonComponentToken import
- Add Addon entry to ComponentTokenMap interface

* docs(Space.Addon): add demo, tests and documentation for theme customization

- Add component-token.tsx demo showing ConfigProvider usage
- Add demo descriptions in English and Chinese
- Add demo references to index.en-US.md and index.zh-CN.md
- Add test for Addon component token in theme.test.tsx

* fix(Space.Addon): correct type signature for prepareComponentToken

- Use GetDefaultToken<'Addon'> type instead of (token: FullToken<'Addon'>) => ComponentToken
- Import GetDefaultToken from theme/internal
- Update function name from initComponentToken to prepareComponentToken
- Update genStyleHooks call to use prepareComponentToken

* test(Space.Addon): update snapshots for new component-token demo

* test(Space.Addon): use toHaveStyle to check CSS variable

- Add cssVar: true to enable CSS variable generation for Addon tokens
- Use toHaveStyle to verify --ant-addon-padding-inline CSS variable
- Follow the pattern from Select component token test

* docs(Space.Addon): merge zh-CN and en-US into single demo md file

- Remove redundant component-token.zh-CN.md
- Update component-token.md to include both zh-CN and en-US sections
- Follow the pattern used by other demo md files

* refactor(Space.Addon): remove component token system

Remove the ComponentToken interface and prepareComponentToken function as they are no longer needed for the Addon component styling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* refactor(Space.Addon): use Space component tokens instead of separate token system

Register Addon as a subcomponent of Space and directly use Space's padding tokens instead of maintaining a separate component token system.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs(Space.Addon): mark component-token demo as debug

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* test: update Space demo snapshots

* test(Space.Addon): update snapshot for component-token demo simplification

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(ConfigProvider): test should use Addon component token instead of Space

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-10 14:33:03 +08:00
二货爱吃白萝卜
fdb0d6ca6e fix: adjust Select option active style priority higher than selected (#56924) 2026-02-10 14:32:53 +08:00
github-actions[bot]
e93868198b chore: auto merge branches (#56914)
merge feature into master
2026-02-09 09:54:16 +00:00
10 changed files with 98 additions and 9 deletions

View File

@@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
import { Modal } from 'antd';
import ConfigProvider from '..';
import { Button, InputNumber, Select } from '../..';
import { Button, InputNumber, Select, Space } from '../..';
import { render, waitFakeTimer } from '../../../tests/utils';
import theme from '../../theme';
import type { GlobalToken } from '../../theme/internal';
@@ -113,6 +113,21 @@ describe('ConfigProvider.Theme', () => {
).toBeTruthy();
});
it('should support Addon component token', () => {
const { container } = render(
<ConfigProvider theme={{ components: { Addon: { colorText: '#0000FF', algorithm: true } } }}>
<Space.Compact>
<Space.Addon className="test-addon">Addon Content</Space.Addon>
</Space.Compact>
</ConfigProvider>,
);
const addon = container.querySelector('.test-addon')!;
expect(addon).toHaveStyle({
'--ant-color-text': '#0000FF',
});
});
it('hashed should be true if not changed', () => {
let hashId = 'hashId';

View File

@@ -121,10 +121,6 @@ const genSingleStyle: GenerateStyle<SelectToken> = (token) => {
alignItems: 'center',
},
[`&-active:not(${selectItemCls}-option-disabled)`]: {
backgroundColor: token.optionActiveBg,
},
[`&-selected:not(${selectItemCls}-option-disabled)`]: {
color: token.optionSelectedColor,
fontWeight: token.optionSelectedFontWeight,
@@ -135,6 +131,10 @@ const genSingleStyle: GenerateStyle<SelectToken> = (token) => {
},
},
[`&-active:not(${selectItemCls}-option-disabled)`]: {
backgroundColor: token.optionActiveBg,
},
'&-disabled': {
[`&${selectItemCls}-option-selected`]: {
backgroundColor: token.colorBgContainerDisabled,

View File

@@ -16066,6 +16066,28 @@ exports[`renders components/space/demo/compact-nested.tsx extend context correct
exports[`renders components/space/demo/compact-nested.tsx extend context correctly 2`] = `[]`;
exports[`renders components/space/demo/component-token.tsx extend context correctly 1`] = `
<div
class="ant-space-compact"
>
<div
class="ant-space-addon ant-space-addon-compact-item ant-space-addon-compact-first-item css-var-test-id ant-space-addon-variant-outlined"
>
Addon
</div>
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid ant-btn-compact-item ant-btn-compact-last-item"
type="button"
>
<span>
Button
</span>
</button>
</div>
`;
exports[`renders components/space/demo/component-token.tsx extend context correctly 2`] = `[]`;
exports[`renders components/space/demo/debug.tsx extend context correctly 1`] = `
<div
class="ant-space ant-space-horizontal ant-space-align-center ant-space-gap-row-small ant-space-gap-col-small css-var-test-id"

View File

@@ -4097,6 +4097,26 @@ exports[`renders components/space/demo/compact-nested.tsx correctly 1`] = `
</div>
`;
exports[`renders components/space/demo/component-token.tsx correctly 1`] = `
<div
class="ant-space-compact"
>
<div
class="ant-space-addon ant-space-addon-compact-item ant-space-addon-compact-first-item css-var-test-id ant-space-addon-variant-outlined"
>
Addon
</div>
<button
class="ant-btn css-var-test-id ant-btn-primary ant-btn-color-primary ant-btn-variant-solid ant-btn-compact-item ant-btn-compact-last-item"
type="button"
>
<span>
Button
</span>
</button>
</div>
`;
exports[`renders components/space/demo/debug.tsx correctly 1`] = `
<div
class="ant-space ant-space-horizontal ant-space-align-center ant-space-gap-row-small ant-space-gap-col-small css-var-test-id"

View File

@@ -0,0 +1,7 @@
## zh-CN
使用 `ConfigProvider` 自定义 `Space.Addon` 的主题样式。
## en-US
Use `ConfigProvider` to customize the theme of `Space.Addon`.

View File

@@ -0,0 +1,19 @@
import React from 'react';
import { Button, ConfigProvider, Space } from 'antd';
const App: React.FC = () => (
<ConfigProvider
theme={{
components: {
Addon: { colorText: 'blue', algorithm: true },
},
}}
>
<Space.Compact>
<Space.Addon>Addon</Space.Addon>
<Button type="primary">Button</Button>
</Space.Compact>
</ConfigProvider>
);
export default App;

View File

@@ -34,6 +34,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*37T2R6O9oi0AAA
<code src="./demo/debug.tsx" debug>Diverse Child</code>
<code src="./demo/gap-in-line.tsx" debug>Flex gap style</code>
<code src="./demo/style-class.tsx" version="6.0.0">Custom semantic dom styling</code>
<code src="./demo/component-token.tsx" debug>Customize Addon with theme</code>
## API

View File

@@ -38,6 +38,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*37T2R6O9oi0AAA
<code src="./demo/debug.tsx" debug>多样的 Child</code>
<code src="./demo/gap-in-line.tsx" debug>Flex gap 样式</code>
<code src="./demo/style-class.tsx" version="6.0.0">自定义语义结构的样式和类</code>
<code src="./demo/component-token.tsx" debug>自定义主题</code>
## API

View File

@@ -1,3 +1,4 @@
import { resetComponent } from '../../style';
import { genCompactItemStyle } from '../../style/compact-item';
import { genStyleHooks } from '../../theme/internal';
import type { FullToken, GenerateStyle } from '../../theme/internal';
@@ -7,11 +8,11 @@ import { genCssVar } from '../../theme/util/genStyleUtils';
// biome-ignore lint/suspicious/noEmptyInterface: ComponentToken need to be empty by default
export interface ComponentToken {}
interface SpaceToken extends FullToken<'Space'> {
interface AddonToken extends FullToken<'Space'> {
// Custom token here
}
const genSpaceAddonStyle: GenerateStyle<SpaceToken> = (token) => {
const genSpaceAddonStyle: GenerateStyle<AddonToken> = (token) => {
const {
componentCls,
borderRadius,
@@ -27,7 +28,7 @@ const genSpaceAddonStyle: GenerateStyle<SpaceToken> = (token) => {
antCls,
} = token;
const [varName, varRef] = genCssVar(antCls, 'space');
const [varName, varRef] = genCssVar(antCls, 'space-addon');
return {
[componentCls]: [
@@ -35,6 +36,7 @@ const genSpaceAddonStyle: GenerateStyle<SpaceToken> = (token) => {
// == Base ==
// ==========================================================
{
...resetComponent(token),
display: 'inline-flex',
alignItems: 'center',
gap: 0,
@@ -144,7 +146,7 @@ const genSpaceAddonStyle: GenerateStyle<SpaceToken> = (token) => {
};
// ============================== Export ==============================
export default genStyleHooks(['Space', 'Addon'], (token) => [
export default genStyleHooks('Addon', (token) => [
genSpaceAddonStyle(token),
genCompactItemStyle(token, { focus: false }),
]);

View File

@@ -49,6 +49,7 @@ import type { ComponentToken as SelectComponentToken } from '../../select/style'
import type { ComponentToken as SkeletonComponentToken } from '../../skeleton/style';
import type { ComponentToken as SliderComponentToken } from '../../slider/style';
import type { ComponentToken as SpaceComponentToken } from '../../space/style';
import type { ComponentToken as AddonComponentToken } from '../../space/style/addon';
import type { ComponentToken as SpinComponentToken } from '../../spin/style';
import type { ComponentToken as SplitterComponentToken } from '../../splitter/style';
import type { ComponentToken as StatisticComponentToken } from '../../statistic/style';
@@ -68,6 +69,7 @@ import type { ComponentToken as UploadComponentToken } from '../../upload/style'
export interface ComponentTokenMap {
Affix?: AffixComponentToken;
Addon?: AddonComponentToken;
Alert?: AlertComponentToken;
Anchor?: AnchorComponentToken;
Avatar?: AvatarComponentToken;