Skip to content

Commit 9108580

Browse files
authored
chore: Changelog of 2.7.0 (#1891)
* chore: changelog of 2.6.0 * chore: changelog of 2.6.0 * feat: test * feat: test * feat: test * chore: changelog * chore: changelog
1 parent 93f2a16 commit 9108580

28 files changed

Lines changed: 253 additions & 56 deletions

File tree

CHANGELOG.en-US.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,27 @@ tag: vVERSION
1616

1717
---
1818

19+
## 2.7.0
20+
21+
`2026-04-30`
22+
23+
### @ant-design/x
24+
25+
- 🆕 `XProvider` adds `zeroRuntime` prop to support Zero Runtime CSS-in-JS mode, extracting styles at build time to avoid runtime style injection and improve performance. [#1737](https://github.com/ant-design/x/pull/1737) by [seanparmelee](https://github.com/seanparmelee)
26+
27+
### @ant-design/x-card
28+
29+
- 🆕 Added `resolveActionContextPathRefs` for automatic action context path resolution. Supports both v0.9 and v0.8 formats — when an action is triggered, `{ path }` references in `context` are automatically resolved to actual values from the dataModel and merged with the component's runtime context. [#1887](https://github.com/ant-design/x/pull/1887) by [kimteayon](https://github.com/kimteayon)
30+
- 📖 Added `action-context-resolve` demo documentation for both v0.8 and v0.9 formats. [#1887](https://github.com/ant-design/x/pull/1887) by [kimteayon](https://github.com/kimteayon)
31+
32+
### @ant-design/x-skill
33+
34+
- 🛠 Updated `x-card` skill ACTIONS reference documentation with path reference resolution details and corrected React usage examples. [#1887](https://github.com/ant-design/x/pull/1887) by [kimteayon](https://github.com/kimteayon)
35+
36+
### Others
37+
38+
- 📖 Added search bar to the official website to improve documentation discoverability. [#1831](https://github.com/ant-design/x/pull/1831) by [1uokun](https://github.com/1uokun)
39+
1940
## 2.6.0
2041

2142
`2026-04-17`

CHANGELOG.zh-CN.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@ tag: vVERSION
1515

1616
---
1717

18+
## 2.7.0
19+
20+
`2026-04-30`
21+
22+
### @ant-design/x
23+
24+
- 🆕 XProvider 新增 `zeroRuntime` 属性,支持 Zero Runtime CSS-in-JS 模式,在构建时提取样式,避免运行时样式注入,提升性能。[#1737](https://github.com/ant-design/x/pull/1737)[seanparmelee](https://github.com/seanparmelee) 提交
25+
26+
### @ant-design/x-card
27+
28+
- 🆕 新增 Action 上下文路径自动解析能力(`resolveActionContextPathRefs`),支持 v0.9 和 v0.8 两种格式,触发 action 时自动将 `context` 中的 `{ path }` 引用解析为 dataModel 中的实际值,并与组件运行时传入的 context 合并上报。[#1887](https://github.com/ant-design/x/pull/1887)[kimteayon](https://github.com/kimteayon) 提交
29+
- 📖 新增 v0.8 / v0.9 Action Context 解析示例文档(`action-context-resolve`)。[#1887](https://github.com/ant-design/x/pull/1887)[kimteayon](https://github.com/kimteayon) 提交
30+
31+
### @ant-design/x-skill
32+
33+
- 🛠 更新 `x-card` skill 的 ACTIONS 参考文档,补充 Path 引用自动解析说明及正确的 React 使用示例。[#1887](https://github.com/ant-design/x/pull/1887)[kimteayon](https://github.com/kimteayon) 提交
34+
35+
### 其他
36+
37+
- 📖 官网新增搜索栏,提升文档检索体验。[#1831](https://github.com/ant-design/x/pull/1831)[1uokun](https://github.com/1uokun) 提交
38+
1839
## 2.6.0
1940

2041
`2026-04-17`

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "x-mono",
3-
"version": "2.6.0",
3+
"version": "2.7.0",
44
"private": true,
55
"scripts": {
66
"presite": "npm run prestart --workspaces",

packages/x-card/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ant-design/x-card",
3-
"version": "2.6.0",
3+
"version": "2.7.0",
44
"description": "React card loader for dynamic content loading and management",
55
"keywords": [
66
"A2UI",

packages/x-card/src/A2UI/Card.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import type { Catalog } from './catalog';
66

77
// v0.8 specific logic
88
import { resolvePropsV08, extractDataUpdatesV08, applyDataModelUpdateV08 } from './Card.v0.8';
9+
import type { ActionConfigV08 } from './Card.v0.8';
910

1011
// v0.9 specific logic
1112
import { resolvePropsV09, extractDataUpdatesV09, applyDataModelUpdateV09 } from './Card.v0.9';
13+
import type { ActionConfigV09 } from './Card.v0.9';
1214

1315
// Shared logic
1416
import {
@@ -22,13 +24,16 @@ export interface CardProps {
2224
id: string;
2325
}
2426

27+
/** actionConfig 联合类型,兼容 v0.8 和 v0.9 格式 */
28+
type ActionConfig = ActionConfigV08 | ActionConfigV09;
29+
2530
/** Recursively render a single node, child nodes are found via getById */
2631
function renderNode(
2732
nodeId: string,
2833
transformer: ComponentTransformer,
2934
components: Record<string, React.ComponentType<any>>,
3035
dataModel: Record<string, any>,
31-
onAction?: (name: string, context: Record<string, any>, actionConfig?: any) => void,
36+
onAction?: (name: string, context: Record<string, any>, actionConfig?: ActionConfig) => void,
3237
onDataChange?: (path: string, value: any) => void,
3338
catalog?: Catalog,
3439
commandVersion?: 'v0.8' | 'v0.9',
@@ -56,7 +61,7 @@ interface NodeRendererProps {
5661
transformer: ComponentTransformer;
5762
components: Record<string, React.ComponentType<any>>;
5863
dataModel: Record<string, any>;
59-
onAction?: (name: string, context: Record<string, any>, actionConfig?: any) => void;
64+
onAction?: (name: string, context: Record<string, any>, actionConfig?: ActionConfig) => void;
6065
/** Callback when component writes back to dataModel via onChange, path is the binding path */
6166
onDataChange?: (path: string, value: any) => void;
6267
/** catalog for component validation */
@@ -329,7 +334,11 @@ const Card: React.FC<CardProps> = ({ id }) => {
329334
* Handler when action is triggered
330335
* Use different extractDataUpdates and resolveActionContext based on version
331336
*/
332-
const handleAction = (name: string, context: Record<string, any>, actionConfig?: any) => {
337+
const handleAction = (
338+
name: string,
339+
context: Record<string, any>,
340+
actionConfig?: ActionConfig,
341+
) => {
333342
// Use different extractDataUpdates based on version
334343
const dataUpdates =
335344
commandVersion === 'v0.9'
@@ -388,9 +397,10 @@ const Card: React.FC<CardProps> = ({ id }) => {
388397
for (const [key, val] of Object.entries(v09Context)) {
389398
if (isPathObject(val)) {
390399
// 从 dataModel 读取实际值,保留其他属性(如 label),将 path 替换为 value
400+
// 注意:value: actualValue 必须放在 ...rest 之后,防止 rest 中残留的 value 字段覆盖解析结果
391401
const actualValue = getValueByPath(dataModel, (val as { path: string }).path);
392402
const { path, ...rest } = val as { path: string; [key: string]: any };
393-
resolvedFromConfig[key] = { value: actualValue, ...rest };
403+
resolvedFromConfig[key] = { ...rest, value: actualValue };
394404
} else {
395405
resolvedFromConfig[key] = val;
396406
}

packages/x-card/src/A2UI/Card.v0.8.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,27 @@ import {
2323
validateComponentAgainstCatalog,
2424
} from './utils';
2525

26+
/** v0.8 action.context 中单个条目的类型(正常格式) */
27+
export interface ActionContextItemV08 {
28+
key: string;
29+
value: { path: string } | { literalString: string } | unknown;
30+
}
31+
32+
/** v0.8 action 配置类型 */
33+
export interface ActionConfigV08 {
34+
name?: string;
35+
/** 运行时可能收到非法值,函数内部通过 Array.isArray 防御 */
36+
context?: ActionContextItemV08[] | unknown;
37+
[key: string]: unknown;
38+
}
39+
2640
/** 判断一个值是否为 { literalString: string } 形式的字面字符串对象 */
27-
export function isLiteralStringObject(val: any): val is { literalString: string } {
28-
return val !== null && typeof val === 'object' && typeof val.literalString === 'string';
41+
export function isLiteralStringObject(val: unknown): val is { literalString: string } {
42+
return (
43+
val !== null &&
44+
typeof val === 'object' &&
45+
typeof (val as Record<string, unknown>).literalString === 'string'
46+
);
2947
}
3048

3149
/** 将 props 中的路径值替换为 dataModel 中的真实值(v0.8 版本) */
@@ -93,7 +111,7 @@ function resolveValueV08(val: any, dataModel: Record<string, any>, isActionConte
93111
* v0.8 格式: action.context 是数组 [{ key, value: { path: string } | literal }]
94112
*/
95113
export function resolveActionContextV08(
96-
action: any,
114+
action: ActionConfigV08 | undefined,
97115
dataModel: Record<string, any>,
98116
): Record<string, any> | undefined {
99117
const context = action?.context;
@@ -133,7 +151,7 @@ export function resolveActionContextV08(
133151
* @returns 需要更新的数据路径和值的数组
134152
*/
135153
export function extractDataUpdatesV08(
136-
action: any,
154+
action: ActionConfigV08 | undefined,
137155
componentContext: Record<string, any>,
138156
): Array<{ path: string; value: any }> {
139157
const context = action?.context;

packages/x-card/src/A2UI/Card.v0.9.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ import {
2020
validateComponentAgainstCatalog,
2121
} from './utils';
2222

23+
/** v0.9 action.event.context 中单个值的类型 */
24+
export type ActionContextValueV09 = { path: string } | unknown;
25+
26+
/** v0.9 action.event 类型 */
27+
export interface ActionEventV09 {
28+
name?: string;
29+
/** 运行时可能收到非法值(数组、字符串、null),函数内部通过类型守卫防御 */
30+
context?: Record<string, unknown> | unknown;
31+
[key: string]: unknown;
32+
}
33+
34+
/** v0.9 action 配置类型 */
35+
export interface ActionConfigV09 {
36+
event?: ActionEventV09;
37+
[key: string]: unknown;
38+
}
39+
2340
/** 将 props 中的路径值替换为 dataModel 中的真实值 */
2441
export function resolvePropsV09(
2542
props: Record<string, any>,
@@ -117,7 +134,7 @@ function resolveValueV09(val: any, dataModel: Record<string, any>): any {
117134
* v0.9 格式: action.event.context 是对象 { key: { path: string } | literal }
118135
*/
119136
export function resolveActionContextV09(
120-
action: any,
137+
action: ActionConfigV09 | undefined,
121138
dataModel: Record<string, any>,
122139
): Record<string, any> | undefined {
123140
const context = action?.event?.context;
@@ -147,7 +164,7 @@ export function resolveActionContextV09(
147164
* @returns 需要更新的数据路径和值的数组
148165
*/
149166
export function extractDataUpdatesV09(
150-
action: any,
167+
action: ActionConfigV09 | undefined,
151168
componentContext: Record<string, any>,
152169
): Array<{ path: string; value: any }> {
153170
const context = action?.event?.context;

0 commit comments

Comments
 (0)