-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: react slots clone & unexpected style (#56)
- Loading branch information
Showing
20 changed files
with
296 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@modelscope-studio/antdx': patch | ||
'@modelscope-studio/base': patch | ||
'@modelscope-studio/frontend': patch | ||
'modelscope_studio': patch | ||
--- | ||
|
||
fix: react slots clone & unexpected style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import gradio as gr | ||
import modelscope_studio.components.antd as antd | ||
import modelscope_studio.components.antdx as antdx | ||
import modelscope_studio.components.base as ms | ||
|
||
file_list = [ | ||
{ | ||
"uid": '1', | ||
"name": 'excel-file.xlsx', | ||
"size": 111111, | ||
}, | ||
{ | ||
"uid": '2', | ||
"name": 'word-file.docx', | ||
"size": 222222, | ||
}, | ||
{ | ||
"uid": '3', | ||
"name": 'image-file.png', | ||
"size": 333333, | ||
}, | ||
{ | ||
"uid": '4', | ||
"name": 'pdf-file.pdf', | ||
"size": 444444, | ||
}, | ||
{ | ||
"uid": '5', | ||
"name": 'ppt-file.pptx', | ||
"size": 555555, | ||
}, | ||
{ | ||
"uid": '6', | ||
"name": 'video-file.mp4', | ||
"size": 666666, | ||
}, | ||
{ | ||
"uid": '7', | ||
"name": 'audio-file.mp3', | ||
"size": 777777, | ||
}, | ||
{ | ||
"uid": '8', | ||
"name": 'zip-file.zip', | ||
"size": 888888, | ||
}, | ||
{ | ||
"uid": '9', | ||
"name": 'markdown-file.md', | ||
"size": 999999, | ||
"description": 'Custom description here', | ||
}, | ||
{ | ||
"uid": '10', | ||
"name": 'image-file.png', | ||
"thumbUrl": | ||
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', | ||
"url": | ||
'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', | ||
"size": 123456, | ||
}, | ||
] | ||
with gr.Blocks() as demo: | ||
with ms.Application(): | ||
with antdx.XProvider(): | ||
with antd.Flex(vertical=True, gap="middle"): | ||
for file in file_list: | ||
antdx.Attachments.FileCard(item=file) | ||
|
||
if __name__ == "__main__": | ||
demo.queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Sender | ||
|
||
A input component for chat. See [Ant Design X](https://x.ant.design/components/sender/) for more information. | ||
|
||
## Examples | ||
|
||
<demo name="basic"></demo> | ||
<demo name="submit_type" title="Submit Type"></demo> | ||
<demo name="header_panel" title="Header Panel"></demo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Sender | ||
|
||
A input component for chat. See [Ant Design X](https://x.ant.design/components/sender/) for more information. | ||
|
||
## Examples | ||
|
||
<demo name="basic"></demo> | ||
<demo name="submit_type" title="Submit Type"></demo> | ||
<demo name="header_panel" title="Header Panel"></demo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from helper.Docs import Docs | ||
|
||
docs = Docs(__file__) | ||
|
||
if __name__ == "__main__": | ||
docs.render().queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import gradio as gr | ||
import modelscope_studio.components.antd as antd | ||
import modelscope_studio.components.antdx as antdx | ||
import modelscope_studio.components.base as ms | ||
|
||
|
||
def submit(): | ||
return gr.update(loading=True, read_only=True) | ||
|
||
|
||
def cancel(): | ||
return gr.update(loading=False, read_only=False) | ||
|
||
|
||
with gr.Blocks() as demo: | ||
with ms.Application(): | ||
with antdx.XProvider(): | ||
with antd.Flex(vertical=True, gap="middle"): | ||
sender = antdx.Sender() | ||
antdx.Sender("Force as loading", loading=True, read_only=True) | ||
antdx.Sender("Set to disabled", disabled=True) | ||
|
||
sender.submit(fn=submit, outputs=[sender]) | ||
sender.cancel(fn=cancel, outputs=[sender]) | ||
|
||
if __name__ == "__main__": | ||
demo.queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import gradio as gr | ||
import modelscope_studio.components.antd as antd | ||
import modelscope_studio.components.antdx as antdx | ||
import modelscope_studio.components.base as ms | ||
|
||
|
||
def paste_file(attachments_value, e: gr.EventData): | ||
return gr.update(value=attachments_value + e._data["payload"][0]) | ||
|
||
|
||
def toggle_open(state_value): | ||
state_value["open"] = not state_value["open"] | ||
return gr.update(open=state_value["open"]), gr.update(value=state_value) | ||
|
||
|
||
def submit(sender_value, attachments_value): | ||
print(sender_value, attachments_value) | ||
return gr.update(value=None), gr.update(value=None) | ||
|
||
|
||
with gr.Blocks() as demo: | ||
state = gr.State({"open": False}) | ||
with ms.Application(): | ||
with antdx.XProvider(): | ||
antd.Typography.Paragraph( | ||
"Use header to customize the file upload example and paste image to upload files with Attachments." | ||
) | ||
with antdx.Sender(placeholder="← Click to open") as sender: | ||
with ms.Slot("prefix"): | ||
with antd.Button(value=None, type="text") as prefix_button: | ||
with ms.Slot("icon"): | ||
antd.Icon("LinkOutlined") | ||
with ms.Slot("header"): | ||
with antdx.Sender.Header(title="Attachments", | ||
open=False, | ||
styles={ | ||
"content": { | ||
"padding": 0, | ||
}, | ||
}) as sender_header: | ||
with antdx.Attachments() as attachments: | ||
with ms.Slot( | ||
"placeholder.title", | ||
params_mapping= | ||
"""(type) => type === 'drop' ? 'Drop file here' : 'Upload files'""" | ||
): | ||
ms.Span() | ||
with ms.Slot( | ||
"placeholder.description", | ||
params_mapping= | ||
"(type) => ({ style: { display: type === 'drop'? 'none' : undefined } })" | ||
): | ||
ms.Span( | ||
"Click or drag files to this area to upload" | ||
) | ||
with ms.Slot( | ||
"placeholder.icon", | ||
params_mapping= | ||
"(type) => ({ style: { display: type === 'drop'? 'none' : undefined } })" | ||
): | ||
antd.Icon("CloudUploadOutlined") | ||
|
||
sender_header.open_change(fn=toggle_open, | ||
inputs=[state], | ||
outputs=[sender_header, state]) | ||
prefix_button.click(fn=toggle_open, | ||
inputs=[state], | ||
outputs=[sender_header, state]) | ||
sender.submit(fn=submit, | ||
inputs=[sender, attachments], | ||
outputs=[sender, attachments]) | ||
sender.paste_file(fn=paste_file, | ||
inputs=[attachments], | ||
outputs=[attachments]) | ||
|
||
if __name__ == "__main__": | ||
demo.queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import gradio as gr | ||
import modelscope_studio.components.antd as antd | ||
import modelscope_studio.components.antdx as antdx | ||
import modelscope_studio.components.base as ms | ||
|
||
|
||
def submit(): | ||
return gr.update(loading=True, read_only=True) | ||
|
||
|
||
def cancel(): | ||
return gr.update(loading=False, read_only=False) | ||
|
||
|
||
with gr.Blocks() as demo: | ||
with ms.Application(): | ||
with antdx.XProvider(): | ||
with antd.Flex(vertical=True, gap="middle"): | ||
sender = antdx.Sender( | ||
submit_type="shiftEnter", | ||
placeholder="Press Shift + Enter to send message") | ||
|
||
sender.submit(fn=submit, outputs=[sender]) | ||
sender.cancel(fn=cancel, outputs=[sender]) | ||
|
||
if __name__ == "__main__": | ||
demo.queue().launch() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.