Skip to content

Commit

Permalink
fix: foceClone
Browse files Browse the repository at this point in the history
  • Loading branch information
Col0ring committed Jan 17, 2025
1 parent f96fc76 commit 8489c5b
Show file tree
Hide file tree
Showing 17 changed files with 161 additions and 138 deletions.
34 changes: 17 additions & 17 deletions docs/components/antd/list/demos/vertical_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
import modelscope_studio.components.base as ms

data = [{
'avatar':
f'https://api.dicebear.com/7.x/miniavs/svg?seed={i}',
'avatar': {
"src": f'https://api.dicebear.com/7.x/miniavs/svg?seed={i}'
},
"link": {
"href": "https://ant.design",
"value": f"ant design part {i}"
},
"img": {
"src":
"https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png"
},
"meta": {
'description':
'Ant Design, a design language for background applications, is refined by Ant UED Team.',
Expand All @@ -26,41 +31,36 @@ def IconText(icon: str, text: str):
ms.Text(text)


def on_pagination_change(e: gr.EventData):
current = e._data["payload"][0]
return gr.update(value=data[(current - 1) * 3:current * 3])


with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
with antd.List(item_layout="vertical",
size="large",
data_source=data,
pagination=dict(total=len(data),
pageSize=page_size)) as list:
with ms.Slot("footer"):
with ms.Div():
antd.Typography.Text('ant design', strong=True)
ms.Text("footer part")
with ms.Each(value=data[0:3]) as list_items:
with ms.Slot("renderItem",
params_mapping="""(item) => item"""):
with antd.List.Item():
with ms.Slot("actions"):
IconText('StarOutlined', 156)
IconText('LikeOutlined', 156)
IconText('MessageOutlined', 2)
IconText('MessageOutlined', 3)
with ms.Slot("extra"):
antd.Image(
"https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png",
preview=False,
alt="logo",
width=272)
antd.Image(preview=False,
alt="logo",
width=272,
as_item="img")
with antd.List.Item.Meta(as_item="meta"):
with ms.Slot("avatar"):
antd.Avatar(as_item="avatar")
with ms.Slot("title"):
antd.Typography.Link(as_item="link")
ms.Text(as_item="content")
list.pagination_change(fn=on_pagination_change,
outputs=[list_items])
ms.Span(as_item="content")

if __name__ == "__main__":
demo.queue().launch()
13 changes: 7 additions & 6 deletions docs/components/antd/table/demos/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@

with gr.Blocks() as demo:
with ms.Application():
with antd.Table(data_source=data):
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
with antd.ConfigProvider():
with antd.Table(data_source=data):
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
if __name__ == "__main__":
demo.queue().launch()
33 changes: 17 additions & 16 deletions docs/components/antd/table/demos/custom_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,23 @@ def on_custom(e: gr.EventData):

with gr.Blocks() as demo:
with ms.Application() as app:
with antd.Table(data_source=data):
antd.Table.Column(title="Name",
data_index="name",
key="name",
column_render="""(text) => {
with antd.ConfigProvider():
with antd.Table(data_source=data):
antd.Table.Column(title="Name",
data_index="name",
key="name",
column_render="""(text) => {
const React = window.ms_globals.React;
return React.createElement('a', null, text);
}""")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
antd.Table.Column(title="Tags",
data_index="tags",
key="tags",
column_render="""(_, { tags }) => {
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
antd.Table.Column(title="Tags",
data_index="tags",
key="tags",
column_render="""(_, { tags }) => {
const React = window.ms_globals.React;
const antd = window.ms_globals.antd;
return tags.map((tag) => {
Expand All @@ -55,9 +56,9 @@ def on_custom(e: gr.EventData):
return React.createElement(antd.Tag, { color, key: tag }, tag.toUpperCase());
});
}""")
antd.Table.Column(title="Action",
key="action",
column_render="""(_, record) => {
antd.Table.Column(title="Action",
key="action",
column_render="""(_, record) => {
const React = window.ms_globals.React;
const antd = window.ms_globals.antd;
const dispatch = window.ms_globals.dispatch;
Expand Down
24 changes: 13 additions & 11 deletions docs/components/antd/table/demos/expandable_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@

with gr.Blocks() as demo:
with ms.Application():
with antd.Table(data_source=data):
with ms.Slot("expandable"):
antd.Table.Expandable(
expanded_row_render="""(record) => record.description""",
row_expandable=
"""(record) => record.name !== 'Not Expandable'""")
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
with antd.ConfigProvider():
with antd.Table(data_source=data):
with ms.Slot("expandable"):
antd.Table.Expandable(
expanded_row_render=
"""(record) => record.description""",
row_expandable=
"""(record) => record.name !== 'Not Expandable'""")
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
if __name__ == "__main__":
demo.queue().launch()
32 changes: 17 additions & 15 deletions docs/components/antd/table/demos/order_specific_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,22 @@

with gr.Blocks() as demo:
with ms.Application():
with antd.Table(data_source=data):
with ms.Slot("rowSelection"):
selection = antd.Table.RowSelection()
with ms.Slot("expandable"):
antd.Table.Expandable(
expanded_row_render="""(record) => record.description""",
row_expandable=
"""(record) => record.name !== 'Not Expandable'""")
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(built_in_column="EXPAND_COLUMN")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(built_in_column="SELECTION_COLUMN")
antd.Table.Column(title="Address",
data_index="address",
key="address")
with antd.ConfigProvider():
with antd.Table(data_source=data):
with ms.Slot("rowSelection"):
selection = antd.Table.RowSelection()
with ms.Slot("expandable"):
antd.Table.Expandable(
expanded_row_render=
"""(record) => record.description""",
row_expandable=
"""(record) => record.name !== 'Not Expandable'""")
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(built_in_column="EXPAND_COLUMN")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(built_in_column="SELECTION_COLUMN")
antd.Table.Column(title="Address",
data_index="address",
key="address")
if __name__ == "__main__":
demo.queue().launch()
17 changes: 9 additions & 8 deletions docs/components/antd/table/demos/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ def on_change(e: gr.EventData):

with gr.Blocks() as demo:
with ms.Application():
with antd.Table(data_source=data,
pagination=dict(pageSize=4)) as table:
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
table.change(fn=on_change)
with antd.ConfigProvider():
with antd.Table(data_source=data,
pagination=dict(pageSize=4)) as table:
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
table.change(fn=on_change)
if __name__ == "__main__":
demo.queue().launch()
55 changes: 28 additions & 27 deletions docs/components/antd/table/demos/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,33 @@ def on_selection_change(e: gr.EventData):

with gr.Blocks() as demo:
with ms.Application():
with antd.Table(data_source=data):
# add selection config
with ms.Slot("rowSelection"):
selection = antd.Table.RowSelection()
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
selection.change(on_selection_change)
antd.Divider("Custom selection")
with antd.Table(data_source=data):
# add selection config
with ms.Slot("rowSelection"):
with antd.Table.RowSelection():
with ms.Slot("selections"):
antd.Table.RowSelection.Selection(
built_in_selection='SELECT_ALL')
antd.Table.RowSelection.Selection(
built_in_selection='SELECT_INVERT')
antd.Table.RowSelection.Selection(
built_in_selection='SELECT_NONE')
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
with antd.ConfigProvider():
with antd.Table(data_source=data):
# add selection config
with ms.Slot("rowSelection"):
selection = antd.Table.RowSelection()
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
selection.change(on_selection_change)
antd.Divider("Custom selection")
with antd.Table(data_source=data):
# add selection config
with ms.Slot("rowSelection"):
with antd.Table.RowSelection():
with ms.Slot("selections"):
antd.Table.RowSelection.Selection(
built_in_selection='SELECT_ALL')
antd.Table.RowSelection.Selection(
built_in_selection='SELECT_INVERT')
antd.Table.RowSelection.Selection(
built_in_selection='SELECT_NONE')
antd.Table.Column(title="Name", data_index="name", key="name")
antd.Table.Column(title="Age", data_index="age", key="age")
antd.Table.Column(title="Address",
data_index="address",
key="address")
if __name__ == "__main__":
demo.queue().launch()
7 changes: 4 additions & 3 deletions docs/components/base/each/demos/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@

with gr.Blocks() as demo:
with ms.Application():
with antd.Space(direction="vertical"):
with ms.Each(value=data):
antd.Alert()
with antd.ConfigProvider():
with antd.Space(direction="vertical"):
with ms.Each(value=data):
antd.Alert()

if __name__ == "__main__":
demo.queue().launch()
11 changes: 6 additions & 5 deletions docs/components/base/each/demos/use_as_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@

with gr.Blocks() as demo:
with ms.Application():
with ms.Each(value=data):
with antd.Card(as_item="card"):
# Inner loop
with ms.Each(as_item="each"):
antd.Typography.Paragraph()
with antd.ConfigProvider():
with ms.Each(value=data):
with antd.Card(as_item="card"):
# Inner loop
with ms.Each(as_item="each"):
antd.Typography.Paragraph()

if __name__ == "__main__":
demo.queue().launch()
14 changes: 9 additions & 5 deletions docs/components/base/each/demos/use_context_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@

with gr.Blocks() as demo:
with ms.Application():
with ms.Each(value=data, context_value={"card": {"hoverable": True}}):
with antd.Card(as_item="card"):
# Inner loop
with ms.Each(as_item="each"):
antd.Typography.Paragraph()
with antd.ConfigProvider():
with ms.Each(value=data,
context_value={"card": {
"hoverable": True
}}):
with antd.Card(as_item="card"):
# Inner loop
with ms.Each(as_item="each"):
antd.Typography.Paragraph()

if __name__ == "__main__":
demo.queue().launch()
17 changes: 9 additions & 8 deletions docs/components/base/filter/demos/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

with gr.Blocks() as demo:
with ms.Application():
with antd.Space(direction="vertical"):
antd.Divider("Without Filter")
with ms.Each(value=data):
antd.Button()
antd.Divider("With Filter")
with ms.Each(value=data):
with ms.Filter():
antd.Button("Run")
with antd.ConfigProvider():
with antd.Space(direction="vertical"):
antd.Divider("Without Filter")
with ms.Each(value=data):
antd.Button()
antd.Divider("With Filter")
with ms.Each(value=data):
with ms.Filter():
antd.Button("Run")

if __name__ == "__main__":
demo.queue().launch()
11 changes: 6 additions & 5 deletions docs/components/base/filter/demos/use_as_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@

with gr.Blocks() as demo:
with ms.Application():
with antd.Space(direction="vertical"):
with ms.Each(value=data):
with antd.Card():
with ms.Filter(as_item="btn"):
antd.Button()
with antd.ConfigProvider():
with antd.Space(direction="vertical"):
with ms.Each(value=data):
with antd.Card():
with ms.Filter(as_item="btn"):
antd.Button()

if __name__ == "__main__":
demo.queue().launch()
Loading

0 comments on commit 8489c5b

Please sign in to comment.