Skip to content

Commit 1a91063

Browse files
committed
chore: upgrade to antd 5.27.0, antdx 1.6.0
1 parent 3ba1b96 commit 1a91063

22 files changed

Lines changed: 1407 additions & 1155 deletions

File tree

.changeset/gentle-rocks-tap.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'@modelscope-studio/legacy-multimodal-input': patch
3+
'@modelscope-studio/legacy-compiled': patch
4+
'@modelscope-studio/lint-config': patch
5+
'@modelscope-studio/changelog': patch
6+
'@modelscope-studio/antdx': patch
7+
'@modelscope-studio/antd': patch
8+
'@modelscope-studio/pro': patch
9+
'@modelscope-studio/frontend': patch
10+
'modelscope_studio': patch
11+
---
12+
13+
chore: upgrade to antd 5.27.0, antdx 1.6.0

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,8 @@
4949
},
5050
"[css]": {
5151
"editor.defaultFormatter": "esbenp.prettier-vscode"
52-
}
52+
},
53+
"python-envs.defaultEnvManager": "ms-python.python:conda",
54+
"python-envs.defaultPackageManager": "ms-python.python:conda",
55+
"python-envs.pythonProjects": []
5356
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,21 @@ class AntdCard(ModelScopeLayoutComponent):
3131

3232
# supported slots
3333
SLOTS = [
34-
"actions",
34+
'actions',
3535
'cover',
3636
'extra',
3737
'tabBarExtraContent',
38+
'tabBarExtraContent.left',
39+
'tabBarExtraContent.right',
3840
'title',
3941
'tabList',
42+
'tabProps.addIcon',
43+
'tabProps.removeIcon',
44+
'tabProps.renderTabBar',
45+
'tabProps.tabBarExtraContent',
46+
'tabProps.tabBarExtraContent.left',
47+
'tabProps.tabBarExtraContent.right',
48+
'tabProps.more.icon',
4049
]
4150

4251
def __exit__(self, *args, **kwargs):

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def __init__(
5252
column_width: int | float | str | None = None,
5353
fixed: bool | None = None,
5454
get_checkbox_props: str | None = None,
55+
get_title_checkbox_props: str | None = None,
5556
hide_select_all: bool | None = None,
5657
preserve_selected_rows_keys: bool | None = None,
5758
render_cell: str | None = None,
@@ -83,6 +84,7 @@ def __init__(
8384
self.column_width = column_width
8485
self.fixed = fixed
8586
self.get_checkbox_props = get_checkbox_props
87+
self.get_title_checkbox_props = get_title_checkbox_props
8688
self.hide_select_all = hide_select_all
8789
self.preserve_selected_rows_keys = preserve_selected_rows_keys
8890
self.render_cell = render_cell

backend/modelscope_studio/components/antd/tag/checkable_tag/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ class AntdTagCheckableTag(ModelScopeDataLayoutComponent):
2222
bind_click_event=True))
2323
]
2424

25+
# supported slots
26+
SLOTS = ["icon"]
27+
2528
def __init__(
2629
self,
2730
label: str | None = None,
2831
value: bool | None = None,
2932
props: dict | None = None,
3033
*,
34+
icon: str | None = None,
3135
root_class_name: str | None = None,
3236
as_item: str | None = None,
3337
_internal: None = None,
@@ -48,6 +52,7 @@ def __init__(
4852
**kwargs)
4953
self.props = props
5054
self.label = label
55+
self.icon = icon
5156
self.root_class_name = root_class_name
5257

5358
FRONTEND_DIR = resolve_frontend_dir("tag", 'checkable-tag')

backend/modelscope_studio/components/antdx/attachments/file_card/__init__.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
from typing import Literal, Union
4+
35
from gradio.events import EventListener
46

57
from .....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir
@@ -17,18 +19,20 @@ class AntdXAttachmentsFileCard(ModelScopeLayoutComponent):
1719

1820
# supported slots
1921
SLOTS = [
20-
'imageProps.placeholder',
21-
'imageProps.preview.mask',
22-
'imageProps.preview.closeIcon',
23-
'imageProps.preview.toolbarRender',
24-
'imageProps.preview.imageRender',
22+
'imageProps.placeholder', 'imageProps.preview.mask',
23+
'imageProps.preview.closeIcon', 'imageProps.preview.toolbarRender',
24+
'imageProps.preview.imageRender', 'icon'
2525
]
2626

2727
def __init__(
2828
self,
2929
props: dict | None = None,
3030
*,
3131
image_props: dict | None = None,
32+
icon: Union[Literal['default', 'excel', 'image', 'markdown', 'pdf',
33+
'ppt', 'word', 'zip', 'video', 'audio'], str]
34+
| None = None,
35+
type: Literal['image', 'file'] | None = None,
3236
item: dict | str | None = None,
3337
as_item: str | None = None,
3438
_internal: None = None,
@@ -47,6 +51,8 @@ def __init__(
4751
elem_style=elem_style,
4852
**kwargs)
4953
self.props = props
54+
self.icon = icon
55+
self.type = type
5056
self.image_props = image_props
5157
if isinstance(item, str):
5258
self.item = self.serve_static_file(item)

backend/modelscope_studio/utils/dev/resolve_frontend_dir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ def resolve_frontend_dir(component: str,
1111
dir = dir + f"/{c}"
1212
return f"{'../' * len(sub_component)}../../../../../frontend/{type}/{component}{dir}"
1313

14-
if (sub_component):
14+
if sub_component:
1515
return f"../../../../../../frontend/{type}/{component}/{sub_component}"
1616
return f"../../../../../frontend/{type}/{component}"

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": "^24.1.0",
28+
"@types/node": "^24.2.1",
2929
"tsup": "^8.5.0"
3030
}
3131
}

config/lint-config/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
}
1717
},
1818
"dependencies": {
19-
"@eslint/compat": "^1.3.1",
20-
"@eslint/js": "^9.32.0",
21-
"@typescript-eslint/parser": "^8.38.0",
19+
"@eslint/compat": "^1.3.2",
20+
"@eslint/js": "^9.33.0",
21+
"@typescript-eslint/parser": "^8.39.1",
2222
"eslint-config-prettier": "^10.1.8",
2323
"eslint-import-resolver-typescript": "^4.4.4",
2424
"eslint-plugin-import": "^2.32.0",
2525
"eslint-plugin-jsx-a11y": "^6.10.2",
26-
"eslint-plugin-prettier": "5.5.3",
26+
"eslint-plugin-prettier": "5.5.4",
2727
"eslint-plugin-react": "^7.37.5",
2828
"eslint-plugin-react-hooks": "^5.2.0",
2929
"eslint-plugin-react-refresh": "^0.4.20",
@@ -32,14 +32,14 @@
3232
"globals": "^16.3.0",
3333
"postcss": "^8.5.6",
3434
"postcss-less": "^6.0.0",
35-
"stylelint-config-ali": "^2.1.2",
35+
"stylelint-config-ali": "^2.2.0",
3636
"stylelint-config-rational-order": "^0.1.2",
37-
"stylelint-config-standard": "^38.0.0",
37+
"stylelint-config-standard": "^39.0.0",
3838
"stylelint-declaration-block-no-ignored-properties": "^2.8.0",
3939
"stylelint-order": "^7.0.0",
4040
"stylelint-prettier": "^5.0.3",
41-
"svelte-eslint-parser": "^1.3.0",
42-
"typescript-eslint": "^8.38.0"
41+
"svelte-eslint-parser": "^1.3.1",
42+
"typescript-eslint": "^8.39.1"
4343
},
4444
"devDependencies": {
4545
"@types/eslint": "^9.6.1",

frontend/antd/card/card.tsx

Lines changed: 85 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ import { sveltify } from '@svelte-preprocess-react';
22
import { ReactSlot } from '@svelte-preprocess-react/react-slot';
33
import type { SetSlotParams } from '@svelte-preprocess-react/slot';
44
import React, { useMemo } from 'react';
5+
import { useFunction } from '@utils/hooks/useFunction';
56
import { useTargets } from '@utils/hooks/useTargets';
7+
import { omitUndefinedProps } from '@utils/omitUndefinedProps';
68
import { renderItems } from '@utils/renderItems';
9+
import { renderParamsSlot } from '@utils/renderParamsSlot';
710
import { Card as ACard, type GetProps } from 'antd';
811

912
import {
@@ -21,6 +24,8 @@ export const Card = sveltify<
2124
'cover',
2225
'extra',
2326
'tabBarExtraContent',
27+
'tabBarExtraContent.left',
28+
'tabBarExtraContent.right',
2429
'title',
2530
'tabProps.addIcon',
2631
'tabProps.removeIcon',
@@ -33,15 +38,81 @@ export const Card = sveltify<
3338
>(
3439
withTabsItemsContextProvider(
3540
['tabList'],
36-
({ children, containsGrid, slots, tabList, tabProps, ...props }) => {
41+
({
42+
children,
43+
containsGrid,
44+
slots,
45+
tabList,
46+
tabProps,
47+
setSlotParams,
48+
...props
49+
}) => {
3750
const targets = useTargets(children, 'actions');
3851
const {
3952
items: { tabList: tabListItems },
4053
} = useTabsItems<['tabList']>();
54+
const { indicator, more, renderTabBar } = tabProps || {};
55+
const indicatorSizeFunction = useFunction(indicator?.size);
56+
const getMorePopupContainerFunction = useFunction(
57+
more?.getPopupContainer
58+
);
59+
const renderTabBarFunction = useFunction(renderTabBar);
4160
return (
4261
<ACard
4362
{...props}
44-
tabProps={tabProps}
63+
tabProps={{
64+
...(tabProps || {}),
65+
indicator: indicatorSizeFunction
66+
? {
67+
...indicator,
68+
size: indicatorSizeFunction,
69+
}
70+
: indicator,
71+
renderTabBar: slots['tabProps.renderTabBar']
72+
? renderParamsSlot({
73+
slots,
74+
setSlotParams,
75+
key: 'tabProps.renderTabBar',
76+
})
77+
: renderTabBarFunction,
78+
more: omitUndefinedProps({
79+
...(more || {}),
80+
getPopupContainer:
81+
getMorePopupContainerFunction || more?.getPopupContainer,
82+
icon: slots['tabProps.more.icon'] ? (
83+
<ReactSlot slot={slots['tabProps.more.icon']} />
84+
) : (
85+
more?.icon
86+
),
87+
}),
88+
tabBarExtraContent: slots['tabProps.tabBarExtraContent'] ? (
89+
<ReactSlot slot={slots['tabProps.tabBarExtraContent']} />
90+
) : slots['tabProps.tabBarExtraContent.left'] ||
91+
slots['tabProps.tabBarExtraContent.right'] ? (
92+
{
93+
left: slots['tabProps.tabBarExtraContent.left'] ? (
94+
<ReactSlot slot={slots['tabProps.tabBarExtraContent.left']} />
95+
) : undefined,
96+
right: slots['tabProps.tabBarExtraContent.right'] ? (
97+
<ReactSlot
98+
slot={slots['tabProps.tabBarExtraContent.right']}
99+
/>
100+
) : undefined,
101+
}
102+
) : (
103+
tabProps?.tabBarExtraContent
104+
),
105+
addIcon: slots['tabProps.addIcon'] ? (
106+
<ReactSlot slot={slots['tabProps.addIcon']} />
107+
) : (
108+
tabProps?.addIcon
109+
),
110+
removeIcon: slots['tabProps.removeIcon'] ? (
111+
<ReactSlot slot={slots['tabProps.removeIcon']} />
112+
) : (
113+
tabProps?.removeIcon
114+
),
115+
}}
45116
tabList={useMemo(() => {
46117
return (
47118
tabList ||
@@ -54,8 +125,18 @@ export const Card = sveltify<
54125
extra={slots.extra ? <ReactSlot slot={slots.extra} /> : props.extra}
55126
cover={slots.cover ? <ReactSlot slot={slots.cover} /> : props.cover}
56127
tabBarExtraContent={
57-
slots.tabBarExtraContent ? (
58-
<ReactSlot slot={slots.tabBarExtraContent} />
128+
slots['tabBarExtraContent'] ? (
129+
<ReactSlot slot={slots['tabBarExtraContent']} />
130+
) : slots['tabBarExtraContent.left'] ||
131+
slots['tabBarExtraContent.right'] ? (
132+
{
133+
left: slots['tabBarExtraContent.left'] ? (
134+
<ReactSlot slot={slots['tabBarExtraContent.left']} />
135+
) : undefined,
136+
right: slots['tabBarExtraContent.right'] ? (
137+
<ReactSlot slot={slots['tabBarExtraContent.right']} />
138+
) : undefined,
139+
}
59140
) : (
60141
props.tabBarExtraContent
61142
)

0 commit comments

Comments
 (0)