Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/five-wings-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
'@modelscope-studio/lint-config': patch
'@modelscope-studio/changelog': patch
'@modelscope-studio/antdx': patch
'@modelscope-studio/antd': patch
'@modelscope-studio/base': patch
'@modelscope-studio/pro': patch
'@modelscope-studio/frontend': patch
'modelscope_studio': patch
---

feat: synchronize deps to antd 6.4.0 and antdx 2.7.0
4 changes: 2 additions & 2 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20
node-version: 22
- name: Install Pnpm
run: npm i pnpm@latest -g
run: npm i pnpm@^10 -g
- name: Install Node Dependencies
run: pnpm install
- name: Run Lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- name: Install Pnpm
if: |
github.event.head_commit.message == 'chore: update versions'
run: npm i pnpm@latest -g
run: npm i pnpm@^10 -g
- name: Install Node Dependencies
if: |
github.event.head_commit.message == 'chore: update versions'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,24 @@

## Table of Contents

1. [Introduction](#introduction)
2. [Project Structure](#project-structure)
3. [Core Components](#core-components)
4. [Architecture Overview](#architecture-overview)
5. [Component Details](#component-details)
6. [Dependency Analysis](#dependency-analysis)
7. [Performance and Maintainability](#performance-and-maintainability)
8. [Troubleshooting Guide](#troubleshooting-guide)
9. [Conclusion](#conclusion)
10. [Appendix: Usage Examples and Best Practices](#appendix-usage-examples-and-best-practices)
- [Bubble Chat Bubble](#bubble-chat-bubble)
- [Update Summary](#update-summary)
- [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
- [Project Structure](#project-structure)
- [Core Components](#core-components)
- [Architecture Overview](#architecture-overview)
- [Component Details](#component-details)
- [Bubble Component](#bubble-component)
- [BubbleList Component](#bubblelist-component)
- [BubbleListItem and BubbleListRole](#bubblelistitem-and-bubblelistrole)
- [useRole - Role Resolution Utility](#userole---role-resolution-utility)
- [Divider Component](#divider-component)
- [Dependency Analysis](#dependency-analysis)
- [Performance and Maintainability](#performance-and-maintainability)
- [Troubleshooting Guide](#troubleshooting-guide)
- [Conclusion](#conclusion)
- [Appendix: Usage Examples and Best Practices](#appendix-usage-examples-and-best-practices)

## Introduction

Expand Down Expand Up @@ -160,7 +168,7 @@ RenderX --> End(["Done"])
- **Purpose**: Converts role configuration (string, function, or object) to the RoleType required by @ant-design/x, with slot patching and index injection.
- **Key Points**:
- Supports `defaultRoleKeys`
- Supports `preProcess` and `defaultRolePostProcess` hooks
- Supports `preProcess` and `postProcess` hooks
- Automatically patches header/footer/avatar/extra/loadingRender/contentRender slots
- Default `contentRender` serializes objects to strings

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ RenderList --> End(["Done"])
## Key Features

- **Items merging**: Prioritizes `props.items`; if not provided, reads `slotItems.items` or `default` from context, then uses `renderItems` to normalize to an array.
- **Role resolution**: Uses `useRole` to support role as string, function, or object, with `preProcess` and `defaultRolePostProcess` hooks.
- **Role resolution**: Uses `useRole` to support role as string, function, or object, with `preProcess` and `postProcess` hooks.
- **Slot patching**: Applies patches to slots so role's avatar/header/footer/extra/loadingRender/contentRender can be overridden in advance.
- **Render and scroll**: Renders via @ant-design/x's `XBubble.List`, with auto-scroll binding and scroll event callbacks.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ L --> N

### 后端组件层

- ****init**.py**: Python 后端组件定义,继承自 ModelScopeLayoutComponent
- \***\*init**.py\*\*: Python 后端组件定义,继承自 ModelScopeLayoutComponent

### 工具函数层

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ BubbleListRole --> RoleItemHandler : "注入"
- 功能定位:将角色配置(字符串函数或对象)转换为 @ant-design/x 所需的 RoleType,并进行插槽补丁与索引注入。
- 关键点:
- 支持默认键 defaultRoleKeys
- 支持 preProcess 与 defaultRolePostProcess 钩子
- 支持 preProcess 与 postProcess 钩子
- 自动将角色配置中的 header/footer/avatar/extra/loadingRender/contentRender 等插槽与内容进行补丁合并
- 默认 contentRender 会将对象序列化为字符串

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ FrontList-->>FrontIndex : "渲染 XBubble.List"
- 优先使用外部传入的 items;若未提供,则从上下文读取 slotItems 中的 items 或 default。
- 使用 renderItems 将插槽内容转换为可渲染的数组。
- 角色解析
- useRole 支持 role 为字符串函数或对象,支持 preProcess 与 defaultRolePostProcess 钩子。
- useRole 支持 role 为字符串函数或对象,支持 preProcess 与 postProcess 钩子。
- 对插槽进行补丁处理,使角色的 avatar/header/footer/extra/loadingRender/contentRender 能前置覆盖。
- 渲染与滚动
- 通过 @ant-design/x 的 XBubble.List 渲染,支持自动滚动绑定与滚动事件回调。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ Ctx-->>Dev : 渲染完成的消息气泡
### 显示逻辑与角色类型

- 角色解析流程
- useRole 接收 role、defaultRoleKeys、preProcess、defaultRolePostProcess 等参数。
- useRole 接收 role、defaultRoleKeys、preProcess、postProcess 等参数。
- 通过 useRoleItems 获取角色项集合,构建角色映射表。
- 合并默认角色键与用户自定义角色键,按顺序解析为函数或对象。
- 对于每个消息项,先执行 preProcess,再将角色插槽通过 patchSlots 合并到消息项上,最后应用 defaultRolePostProcess 进行最终调整。
- 对于每个消息项,先执行 preProcess,再将角色插槽通过 patchSlots 合并到消息项上,最后应用 postProcess 进行最终调整。

```mermaid
flowchart TD
Expand All @@ -180,7 +180,7 @@ BuildMap --> MergeKeys["合并默认键与自定义键"]
MergeKeys --> ResolveEach["逐个解析角色键"]
ResolveEach --> PreProcess["执行 preProcess 钩子"]
PreProcess --> PatchSlots["合并角色插槽到消息项"]
PatchSlots --> PostProcess["执行 defaultRolePostProcess 钩子"]
PatchSlots --> PostProcess["执行 postProcess 钩子"]
PostProcess --> End(["结束"])
```

Expand Down Expand Up @@ -256,7 +256,7 @@ ItemHandler <.. BubbleListItem : "委托"
- 自定义角色样式
- 通过 class_names 与 styles 为不同区域设置类名与内联样式;利用 shape 与 variant 控制外观。
- 动态角色信息
- 结合 useRole 的 preProcess 与 defaultRolePostProcess,实现根据消息索引或上下文动态调整角色配置。
- 结合 useRole 的 preProcess 与 postProcess,实现根据消息索引或上下文动态调整角色配置。
- 与 Bubble.Item 的组合
- 在 BubbleList 中同时提供 items 与 roles,确保角色信息与消息内容协同渲染。

Expand Down
2 changes: 2 additions & 0 deletions backend/modelscope_studio/components/antd/alert/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
self,
additional_props: dict | None = None,
*,
variant: Literal['filled', 'outlined'] | None = None,
action: str | None = None,
after_close: str | None = None,
banner: bool | None = None,
Expand Down Expand Up @@ -63,6 +64,7 @@ def __init__(
self.class_names = class_names
self.styles = styles
self.additional_props = additional_props
self.variant = variant
self.action = action
self.after_close = after_close
self.banner = banner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(
title: str | None = None,
additional_props: dict | None = None,
*,
target_offset: int | float | None = None,
key: str | None = None,
replace: bool | None = None,
href: str | None = None,
Expand Down Expand Up @@ -53,6 +54,7 @@ def __init__(
self.additional_props = additional_props
self.title = title
self.key = key
self.target_offset = target_offset
self.replace = replace
self.href = href
self.href_target = href_target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class AntdCascader(ModelScopeDataLayoutComponent):
# supported slots
SLOTS = [
'allowClear.clearIcon', 'suffixIcon', 'maxTagPlaceholder',
'notFoundContent', 'expandIcon', 'removeIcon', 'prefix',
'displayRender', 'tagRender', 'dropdownRender', 'popupRender'
'showSearch.render', 'optionRender'
'notFoundContent', 'expandIcon', 'removeIcon', 'showSearch.searchIcon',
'prefix', 'displayRender', 'tagRender', 'dropdownRender',
'popupRender', 'showSearch.render', 'optionRender'
]

def __init__(
Expand All @@ -61,6 +61,7 @@ def __init__(
popup_render: str | None = None,
expand_icon: str | None = None,
prefix: str | None = None,
search_icon: str | None = None,
expand_trigger: Literal['click', 'hover'] = 'click',
filed_names: dict | None = None,
get_popup_container: str | None = None,
Expand Down Expand Up @@ -120,6 +121,7 @@ def __init__(
self.dropdown_render = dropdown_render
self.popup_render = popup_render
self.expand_icon = expand_icon
self.search_icon = search_icon
self.expand_trigger = expand_trigger
self.filed_names = filed_names
self.get_popup_container = get_popup_container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class AntdDatePicker(ModelScopeDataLayoutComponent):
'renderExtraFooter',
'cellRender',
'panelRender',
'tagRender',
]

def __init__(
Expand All @@ -53,6 +54,7 @@ def __init__(
*,
allow_clear: bool | dict = True,
auto_focus: bool | None = None,
tag_render: str | None = None,
cell_render: str | None = None,
components: dict | None = None,
disabled: bool | None = None,
Expand Down Expand Up @@ -127,6 +129,7 @@ def __init__(
self.locale = locale
self.allow_clear = allow_clear
self.auto_focus = auto_focus
self.tag_render = tag_render
self.cell_render = cell_render
self.disabled = disabled
self.disabled_date = disabled_date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(
icon: str | None = None,
description: str | None = None,
tooltip: str | dict | None = None,
disabled: bool | None = None,
type: Literal['default', 'primary'] = 'default',
shape: Literal['circle', 'square'] = 'circle',
href: str | None = None,
Expand Down Expand Up @@ -81,6 +82,7 @@ def __init__(
self.icon = icon
self.description = description
self.tooltip = tooltip
self.disabled = disabled
self.type = type
self.shape = shape
self.href = href
Expand Down
4 changes: 4 additions & 0 deletions backend/modelscope_studio/components/antd/image/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ def __init__(
*,
alt: str | None = None,
fallback: str | None = None,
mask: bool | dict | None = None,
height: str | int | float | None = None,
placeholder: bool | str | int | float | None = None,
preview: bool | dict | None = None,
focus_trap: bool | None = None,
width: str | int | float | None = None,
root_class_name: str | None = None,
class_names: dict | str | None = None,
Expand Down Expand Up @@ -79,6 +81,8 @@ def __init__(
self.alt = alt
self.fallback = fallback
self.height = height
self.mask = mask
self.focus_trap = focus_trap
self.placeholder = placeholder
self.preview = preview
self.width = width
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AntdInputSearch(ModelScopeDataLayoutComponent):
# supported slots
SLOTS = [
'addonAfter', 'addonBefore', 'allowClear.clearIcon', 'prefix',
'suffix', 'enterButton', 'showCount.formatter'
'suffix', 'enterButton', 'showCount.formatter', 'searchIcon'
]

def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ class AntdSplitter(ModelScopeLayoutComponent):
bind_draggerDoubleClick_event=True)),
]

# supported slots
SLOTS = ['draggerIcon', 'collapsible.icon.start', 'collapsible.icon.end']

def __init__(
self,
additional_props: dict | None = None,
*,
layout: Literal['horizontal', 'vertical'] | None = 'horizontal',
orientation: Literal['horizontal', 'vertical'] | None = None,
collapsible: dict | None = None,
dragger_icon: str | None = None,
destroy_on_hidden: bool | None = None,
vertical: bool | None = None,
lazy: bool | None = None,
root_class_name: str | None = None,
Expand Down Expand Up @@ -75,8 +81,11 @@ def __init__(
self.layout = layout
self.vertical = vertical
self.orientation = orientation
self.dragger_icon = dragger_icon
self.lazy = lazy
self.root_class_name = root_class_name
self.destroy_on_hidden = destroy_on_hidden
self.collapsible = collapsible

FRONTEND_DIR = resolve_frontend_dir("splitter")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def __init__(
min: int | str | None = None,
max: int | str | None = None,
size: int | str | None = None,
destroy_on_hidden: bool | None = None,
collapsible: bool | dict | None = None,
resizable: bool | None = None,
root_class_name: str | None = None,
Expand Down Expand Up @@ -62,6 +63,7 @@ def __init__(
self.min = min
self.max = max
self.size = size
self.destroy_on_hidden = destroy_on_hidden
self.collapsible = collapsible
self.resizable = resizable
self.root_class_name = root_class_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __init__(
value: str | None = "",
additional_props: dict | None = None,
*,
actions: dict | None = None,
href: str | None = None,
href_target: str | None = None,
code: bool | None = None,
Expand Down Expand Up @@ -112,6 +113,7 @@ def __init__(
self.styles = styles
self.value = value
self.additional_props = additional_props
self.actions = actions
self.code = code
self.copyable = copyable
self.delete = delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(
value: str | None = "",
additional_props: dict | None = None,
*,
actions: dict | None = None,
code: bool | None = None,
copyable: bool | dict = False,
delete: bool | None = None,
Expand Down Expand Up @@ -126,6 +127,7 @@ def __init__(
self.styles = styles
self.value = value
self.additional_props = additional_props
self.actions = actions
self.code = code
self.copyable = copyable
self.delete = delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(
value: str | None = "",
additional_props: dict | None = None,
*,
actions: dict | None = None,
code: bool | None = None,
copyable: bool | dict = False,
delete: bool | None = None,
Expand Down Expand Up @@ -124,6 +125,7 @@ def __init__(
self.styles = styles
self.value = value
self.additional_props = additional_props
self.actions = actions
self.code = code
self.copyable = copyable
self.delete = delete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def __init__(
value: str | None = "",
additional_props: dict | None = None,
*,
actions: dict | None = None,
code: bool | None = None,
copyable: bool | dict = False,
delete: bool | None = None,
Expand Down Expand Up @@ -124,6 +125,7 @@ def __init__(
**kwargs)
self.class_names = class_names
self.styles = styles
self.actions = actions
self.value = value
self.additional_props = additional_props
self.code = code
Expand Down
2 changes: 1 addition & 1 deletion config/changelog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"devDependencies": {
"@changesets/types": "^6.1.0",
"@types/node": "^25.5.2",
"@types/node": "^25.8.0",
"tsup": "^8.5.1"
}
}
Loading
Loading