Skip to content

Commit 38a7717

Browse files
authored
feat: upgrade to antd 5.26.0, antdx 1.4.0 (#78)
* feat: upgrade to antd 5.26.0, antdx 1.4.0 * fix: lint
1 parent 54a745f commit 38a7717

30 files changed

Lines changed: 1546 additions & 701 deletions

File tree

.changeset/clean-corners-reply.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@modelscope-studio/lint-config': patch
3+
'@modelscope-studio/changelog': patch
4+
'@modelscope-studio/antdx': patch
5+
'@modelscope-studio/pro': patch
6+
'@modelscope-studio/frontend': patch
7+
'modelscope_studio': patch
8+
---
9+
10+
feat: upgrade to antd 5.26.0, antdx 1.4.0

backend/modelscope_studio/components/antd/table/expandable/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def __init__(
4141
indent_size: int | float | None = 15,
4242
row_expandable: str | None = None,
4343
show_expand_column: bool | None = None,
44+
expanded_row_offset: int | None = None,
4445
as_item: str | None = None,
4546
_internal: None = None,
4647
# gradio properties
@@ -72,6 +73,7 @@ def __init__(
7273
self.indent_size = indent_size
7374
self.row_expandable = row_expandable
7475
self.show_expand_column = show_expand_column
76+
self.expanded_row_offset = expanded_row_offset
7577

7678
FRONTEND_DIR = resolve_frontend_dir("table", "expandable")
7779

backend/modelscope_studio/components/antdx/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from .actions import AntdXActions as Actions
2+
from .actions.item import AntdXActionsItem as ActionsItem
13
from .attachments import AntdXAttachments as Attachments
24
from .attachments.file_card import \
35
AntdXAttachmentsFileCard as AttachmentsFileCard
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from __future__ import annotations
2+
3+
from typing import Any, Literal
4+
5+
from gradio.events import EventListener
6+
7+
from ....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir
8+
from .item import AntdXActionsItem
9+
10+
11+
class AntdXActions(ModelScopeLayoutComponent):
12+
"""
13+
Ant Design X: https://x.ant.design/components/actions
14+
"""
15+
16+
Item = AntdXActionsItem
17+
18+
EVENTS = [
19+
EventListener("click",
20+
callback=lambda block: block._internal.update(
21+
bind_click_event=True),
22+
doc="Callback function when an action item is clicked."),
23+
]
24+
25+
# supported slots
26+
SLOTS = ['items']
27+
28+
def __init__(
29+
self,
30+
props: dict | None = None,
31+
*,
32+
items: list[dict] | None = None,
33+
variant: Literal['borderless', 'border'] | None = None,
34+
block: bool | None = None,
35+
prefix_cls: str | None = None,
36+
root_class_name: str | None = None,
37+
as_item: str | None = None,
38+
_internal: None = None,
39+
# gradio properties
40+
visible: bool = True,
41+
elem_id: str | None = None,
42+
elem_classes: list[str] | str | None = None,
43+
elem_style: dict | None = None,
44+
render: bool = True,
45+
**kwargs):
46+
super().__init__(visible=visible,
47+
elem_id=elem_id,
48+
elem_classes=elem_classes,
49+
render=render,
50+
as_item=as_item,
51+
elem_style=elem_style,
52+
**kwargs)
53+
self.props = props
54+
self.items = items
55+
self.prefix_cls = prefix_cls
56+
self.variant = variant
57+
self.block = block
58+
self.root_class_name = root_class_name
59+
60+
FRONTEND_DIR = resolve_frontend_dir("actions", type="antdx")
61+
62+
@property
63+
def skip_api(self):
64+
return True
65+
66+
def preprocess(self, payload: None) -> None:
67+
return payload
68+
69+
def postprocess(self, value: None) -> None:
70+
71+
return value
72+
73+
def example_payload(self) -> Any:
74+
return None
75+
76+
def example_value(self) -> Any:
77+
return None
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from __future__ import annotations
2+
3+
from typing import Any, Literal
4+
5+
from gradio.events import EventListener
6+
7+
from .....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir
8+
9+
10+
class AntdXActionsItem(ModelScopeLayoutComponent):
11+
"""
12+
Ant Design X: https://x.ant.design/components/actions
13+
"""
14+
15+
EVENTS = [
16+
EventListener(
17+
"item_click",
18+
callback=lambda block: block._internal.update(bind_itemClick_event=
19+
True),
20+
doc="Callback function when the custom action button is clicked."),
21+
]
22+
23+
# Supported slots
24+
SLOTS = ['label', 'icon']
25+
26+
def __init__(
27+
self,
28+
label: str | None = None,
29+
props: dict | None = None,
30+
*,
31+
key: str | None = None,
32+
icon: str | None = None,
33+
trigger_sub_menu_action: Literal['hover', 'click'] | None = None,
34+
danger: bool | None = None,
35+
as_item: str | None = None,
36+
_internal: None = None,
37+
# gradio properties
38+
visible: bool = True,
39+
elem_id: str | None = None,
40+
elem_classes: list[str] | str | None = None,
41+
elem_style: dict | None = None,
42+
render: bool = True,
43+
**kwargs):
44+
super().__init__(visible=visible,
45+
elem_id=elem_id,
46+
elem_classes=elem_classes,
47+
render=render,
48+
as_item=as_item,
49+
elem_style=elem_style,
50+
**kwargs)
51+
self.props = props
52+
self.label = label
53+
self.icon = icon
54+
self.trigger_sub_menu_action = trigger_sub_menu_action
55+
self.danger = danger
56+
self.key = key
57+
58+
FRONTEND_DIR = resolve_frontend_dir("actions", "item", type="antdx")
59+
60+
@property
61+
def skip_api(self):
62+
return True
63+
64+
def preprocess(self, payload: None) -> None:
65+
return payload
66+
67+
def postprocess(self, value: None) -> None:
68+
69+
return value
70+
71+
def example_payload(self) -> Any:
72+
return None
73+
74+
def example_value(self) -> Any:
75+
return None

backend/modelscope_studio/components/antdx/components.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from .actions import AntdXActions
2+
from .actions.item import AntdXActionsItem
13
from .attachments import AntdXAttachments
24
from .attachments.file_card import AntdXAttachmentsFileCard
35
from .bubble import AntdXBubble

config/changelog/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"devDependencies": {
2727
"@changesets/types": "^6.1.0",
28-
"@types/node": "^22.15.21",
28+
"@types/node": "^24.0.0",
2929
"tsup": "^8.5.0"
3030
}
3131
}

config/lint-config/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@
1717
},
1818
"dependencies": {
1919
"@eslint/compat": "^1.2.9",
20-
"@eslint/js": "^9.27.0",
21-
"@typescript-eslint/parser": "^8.32.1",
20+
"@eslint/js": "^9.28.0",
21+
"@typescript-eslint/parser": "^8.34.0",
2222
"eslint-config-prettier": "^10.1.5",
23-
"eslint-import-resolver-typescript": "^4.4.1",
23+
"eslint-import-resolver-typescript": "^4.4.3",
2424
"eslint-plugin-import": "^2.31.0",
2525
"eslint-plugin-jsx-a11y": "^6.10.2",
26-
"eslint-plugin-prettier": "5.4.0",
26+
"eslint-plugin-prettier": "5.4.1",
2727
"eslint-plugin-react": "^7.37.5",
2828
"eslint-plugin-react-hooks": "^5.2.0",
2929
"eslint-plugin-react-refresh": "^0.4.20",
3030
"eslint-plugin-simple-import-sort": "^12.1.0",
31-
"eslint-plugin-svelte": "^3.9.0",
31+
"eslint-plugin-svelte": "^3.9.2",
3232
"globals": "^16.2.0",
33-
"postcss": "^8.5.3",
33+
"postcss": "^8.5.4",
3434
"postcss-less": "^6.0.0",
3535
"stylelint-config-ali": "^2.1.2",
3636
"stylelint-config-rational-order": "^0.1.2",
@@ -39,7 +39,7 @@
3939
"stylelint-order": "^7.0.0",
4040
"stylelint-prettier": "^5.0.3",
4141
"svelte-eslint-parser": "^1.2.0",
42-
"typescript-eslint": "^8.32.1"
42+
"typescript-eslint": "^8.34.0"
4343
},
4444
"devDependencies": {
4545
"@types/eslint": "^9.6.1",

docs/app.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,15 @@ def get_layout_templates():
462462
"label": get_text("ThoughtChain", "ThoughtChain 思考链"),
463463
"key": "thought_chain"
464464
}]
465+
}, {
466+
"label":
467+
get_text("Feedback", "反馈"),
468+
"type":
469+
"group",
470+
"children": [{
471+
"label": get_text("Actions", "Actions 操作列表"),
472+
"key": "actions"
473+
}]
465474
}, {
466475
"label":
467476
get_text("Tools", "工具"),
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Actions
2+
3+
Used for quickly configuring required action buttons or features in some AI scenarios.See [Ant Design X](https://x.ant.design/components/actions/) for more information.
4+
5+
## Examples
6+
7+
<demo name="basic"></demo>

0 commit comments

Comments
 (0)