Skip to content

Commit 4888b2b

Browse files
authored
feat: upgrade to antd 5.28.0, antdx 1.6.1 (#111)
* feat: upgrade to antd 5.28.0, antdx 1.6.1 * chore: add changeset * fix: typo
1 parent ba43eae commit 4888b2b

31 files changed

Lines changed: 1792 additions & 1671 deletions

File tree

.changeset/good-pens-beam.md

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

backend/modelscope_studio/components/antd/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@
107107
from .splitter import AntdSplitter as Splitter
108108
from .splitter.panel import AntdSplitterPanel as SplitterPanel
109109
from .statistic import AntdStatistic as Statistic
110-
from .statistic import AntdStatisticCountdown as StatisticCountdown
110+
from .statistic.countdown import AntdStatisticCountdown as StatisticCountdown
111+
from .statistic.timer import AntdStatisticTimer as StatisticTimer
111112
from .steps import AntdSteps as Steps
112113
from .steps.item import AntdStepsItem as StepsItem
113114
from .switch import AntdSwitch as Switch

backend/modelscope_studio/components/antd/components.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@
103103
from .spin import AntdSpin
104104
from .splitter import AntdSplitter
105105
from .splitter.panel import AntdSplitterPanel
106-
from .statistic import AntdStatistic, AntdStatisticCountdown
106+
from .statistic import AntdStatistic
107+
from .statistic.countdown import AntdStatisticCountdown
108+
from .statistic.timer import AntdStatisticTimer
107109
from .steps import AntdSteps
108110
from .steps.item import AntdStepsItem
109111
from .switch import AntdSwitch

backend/modelscope_studio/components/antd/drawer/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ class AntdDrawer(ModelScopeLayoutComponent):
1818
]
1919

2020
# supported slots
21-
SLOTS = ['closeIcon', 'extra', 'footer', 'title', 'drawerRender']
21+
SLOTS = [
22+
'closeIcon', 'closable.closeIcon', 'extra', 'footer', 'title',
23+
'drawerRender'
24+
]
2225

2326
def __init__(
2427
self,
@@ -29,6 +32,7 @@ def __init__(
2932
body_style: dict | None = None,
3033
close_icon: str | None = None,
3134
class_names: dict | None = None,
35+
closable: bool | dict | None = None,
3236
destroy_on_close: bool | None = None,
3337
destroy_on_hidden: bool | None = None,
3438
extra: str | None = None,
@@ -72,6 +76,7 @@ def __init__(
7276
self.auto_focus = auto_focus
7377
self.body_style = body_style
7478
self.close_icon = close_icon
79+
self.closable = closable
7580
self.class_names = class_names
7681
self.destroy_on_close = destroy_on_close
7782
self.destroy_on_hidden = destroy_on_hidden

backend/modelscope_studio/components/antd/grid/row/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def __init__(
3333
*,
3434
align: Literal["top", "middle", "bottom", "stretch"]
3535
| dict[str, Literal["top", "middle", "bottom", "stretch"]] = "top",
36-
gutter: int | dict | list[int] = 0,
36+
gutter: int | str | dict | list = 0,
3737
justify: Literal["start", "end", "center", "space-between",
3838
'space-around', 'space-evenly']
3939
| dict[str, Literal["start", "end", "center", "space-between",

backend/modelscope_studio/components/antd/qr_code/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def __init__(
3030
bordered: bool = True,
3131
color: str | None = "#000",
3232
bg_color: str | None = 'transparent',
33+
boost_level: bool | None = True,
3334
error_level: Literal['L', 'M', 'Q', 'H'] | None = 'M',
3435
icon: str | None = None,
3536
icon_size: int | dict | None = 40,
@@ -60,6 +61,7 @@ def __init__(
6061
self.bordered = bordered
6162
self.color = color
6263
self.bg_color = bg_color
64+
self.boost_level = boost_level
6365
self.error_level = error_level
6466
self.icon = icon
6567
self.icon_size = icon_size

backend/modelscope_studio/components/antd/splitter/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class AntdSplitter(ModelScopeLayoutComponent):
3232
doc="Drag end callback.",
3333
callback=lambda block: block._internal.update(
3434
bind_resizeEnd_event=True)),
35+
EventListener("collapse",
36+
doc="Callback when expanding or collapsing.",
37+
callback=lambda block: block._internal.update(
38+
bind_collapse_event=True)),
3539
]
3640

3741
def __init__(

backend/modelscope_studio/components/antd/statistic/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
from ....utils.dev import ModelScopeDataLayoutComponent, resolve_frontend_dir
66
from .countdown import AntdStatisticCountdown
7+
from .timer import AntdStatisticTimer
78

89

910
class AntdStatistic(ModelScopeDataLayoutComponent):
1011
"""
1112
Ant Design: https://ant.design/components/statistic
1213
"""
1314
Countdown = AntdStatisticCountdown
15+
Timer = AntdStatisticTimer
1416

1517
EVENTS = []
1618

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
from __future__ import annotations
2+
3+
from typing import Any, Callable, Literal
4+
5+
from gradio.events import EventListener
6+
7+
from .....utils.dev import ModelScopeDataLayoutComponent, resolve_frontend_dir
8+
9+
10+
class AntdStatisticTimer(ModelScopeDataLayoutComponent):
11+
"""
12+
Ant Design: https://ant.design/components/statistic
13+
"""
14+
15+
EVENTS = [
16+
EventListener("finish",
17+
callback=lambda block: block._internal.update(
18+
bind_finish_event=True)),
19+
EventListener("change",
20+
callback=lambda block: block._internal.update(
21+
bind_change_event=True)),
22+
]
23+
24+
# supported slots
25+
SLOTS = ['prefix', 'suffix', 'title']
26+
27+
def __init__(
28+
self,
29+
value: Callable | int | float | None = None,
30+
props: dict | None = None,
31+
*,
32+
type: Literal['countdown', 'countup'] | None = 'countdown',
33+
format: str | None = None,
34+
prefix: str | None = None,
35+
suffix: str | None = None,
36+
title: str | None = None,
37+
value_style: dict | None = None,
38+
root_class_name: str | None = None,
39+
as_item: str | None = None,
40+
_internal: None = None,
41+
# gradio properties
42+
visible: bool = True,
43+
elem_id: str | None = None,
44+
elem_classes: list[str] | str | None = None,
45+
elem_style: dict | None = None,
46+
render: bool = True,
47+
**kwargs):
48+
super().__init__(value=value,
49+
visible=visible,
50+
elem_id=elem_id,
51+
elem_classes=elem_classes,
52+
render=render,
53+
as_item=as_item,
54+
elem_style=elem_style,
55+
**kwargs)
56+
self.props = props
57+
self.type = type
58+
self.format = format
59+
self.prefix = prefix
60+
self.suffix = suffix
61+
self.title = title
62+
self.value_style = value_style
63+
self.root_class_name = root_class_name
64+
65+
FRONTEND_DIR = resolve_frontend_dir("statistic", "timer")
66+
67+
@property
68+
def skip_api(self):
69+
return True
70+
71+
def preprocess(self, payload: int | float | None) -> int | float | None:
72+
return payload
73+
74+
def postprocess(self, value: int | float | None) -> int | float | None:
75+
return value
76+
77+
def example_payload(self) -> Any:
78+
return None
79+
80+
def example_value(self) -> Any:
81+
return None

config/changelog/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
"dependencies": {
2222
"@changesets/get-github-info": "^0.6.0",
2323
"@manypkg/get-packages": "^3.1.0",
24-
"detect-indent": "^7.0.1"
24+
"detect-indent": "^7.0.2"
2525
},
2626
"devDependencies": {
2727
"@changesets/types": "^6.1.0",
28-
"@types/node": "^24.3.1",
28+
"@types/node": "^24.10.0",
2929
"tsup": "^8.5.0"
3030
}
3131
}

0 commit comments

Comments
 (0)