Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Col0ring committed Dec 3, 2024
1 parent 0d07cec commit e815be1
Show file tree
Hide file tree
Showing 59 changed files with 828 additions and 73 deletions.
6 changes: 3 additions & 3 deletions backend/modelscope_studio/components/antd/avatar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def __init__(
props: dict | None = None,
*,
alt: str | None = None,
gap: int = 4,
gap: int | None = None,
icon: str | None = None,
shape: Literal['circle', 'square'] = 'circle',
shape: Literal['circle', 'square'] | None = None,
size: int | Literal['large', 'small', 'default'] | dict
| None = 'default',
| None = None,
src_set: str | None = None,
draggable: bool | Literal['true', 'false'] | None = None,
cross_origin: Literal['anonymous', 'use-credentials', '']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def __init__(
*,
max: dict | None = None,
size: int | Literal['large', 'small', 'default']
| dict = 'default',
shape: Literal['circle', 'square'] = 'circle',
| dict | None = None,
shape: Literal['circle', 'square'] | None = None,
root_class_name: str | None = None,
as_item: str | None = None,
_internal: None = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
fullscreen: bool = True,
header_render: str | None = None,
locale: dict | None = None,
mode: Literal['month', 'year'] = 'month',
mode: Literal['month', 'year'] | None = None,
valid_range: tuple[int | str | float, int | str | float]
| None = None,
root_class_name: str | None = None,
Expand Down
5 changes: 3 additions & 2 deletions backend/modelscope_studio/components/antd/card/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AntdCard(ModelScopeLayoutComponent):
'extra',
'tabBarExtraContent',
'title',
'tabList',
]

def __exit__(self, *args, **kwargs):
Expand All @@ -49,7 +50,7 @@ def __init__(
*,
actions: str | None = None,
active_tab_key: str | None = None,
bordered: bool = True,
bordered: bool | None = None,
cover: str | None = None,
default_active_tab_key: str | None = None,
extra: str | None = None,
Expand All @@ -58,7 +59,7 @@ def __init__(
size: Literal["default", "small"] | None = None,
tab_bar_extra_content: str | None = None,
tab_list: list[str] | str | None = None,
tab_props: str | None = None,
tab_props: dict | None = None,
title: str | None = None,
type: str | None = None,
class_names: dict | None = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(
self,
props: dict | None = None,
*,
hoverable: bool = True,
hoverable: bool | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class AntdCascader(ModelScopeDataLayoutComponent):
'notFoundContent',
'expandIcon',
'removeIcon',
'prefix',
'displayRender',
'tagRender',
'dropdownRender',
Expand All @@ -62,6 +63,7 @@ def __init__(
popup_class_name: str | None = None,
dropdown_render: str | None = None,
expand_icon: str | None = None,
prefix: str | None = None,
expand_trigger: Literal['click', 'hover'] = 'click',
filed_names: dict | None = None,
get_popup_container: str | None = None,
Expand Down Expand Up @@ -114,6 +116,7 @@ def __init__(
self.disabled = disabled
self.display_render = display_render
self.tag_render = tag_render
self.prefix = prefix
self.popup_class_name = popup_class_name
self.dropdown_render = dropdown_render
self.expand_icon = expand_icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(
presets: list[dict] | None = None,
disabled: bool | None = None,
disabled_alpha: bool | None = None,
disabled_format: bool | None = None,
destroy_tooltip_on_hide: bool | None = None,
format: Literal['hex', 'rgb', 'hsb'] | None = 'hex',
mode: Literal['single', 'gradient']
Expand Down Expand Up @@ -85,6 +86,7 @@ def __init__(
self.presets = presets
self.disabled = disabled
self.disabled_alpha = disabled_alpha
self.disabled_format = disabled_format
self.destroy_tooltip_on_hide = destroy_tooltip_on_hide
self.format = format
self.mode = mode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class AntdDatePicker(ModelScopeDataLayoutComponent):
# supported slots
SLOTS = [
'allowClear.clearIcon',
'prefix',
'prevIcon',
'nextIcon',
'suffixIcon',
Expand Down Expand Up @@ -77,6 +78,7 @@ def __init__(
get_popup_container: str | None = None,
min_date: str | int | float | None = None,
max_date: str | int | float | None = None,
prefix: str | None = None,
prev_icon: str | None = None,
size: Literal['large', 'middle', 'small'] | None = None,
presets: list[dict] | None = None,
Expand Down Expand Up @@ -137,6 +139,7 @@ def __init__(
self.get_popup_container = get_popup_container
self.min_date = min_date
self.max_date = max_date
self.prefix = prefix
self.prev_icon = prev_icon
self.size = size
self.presets = presets
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any
from typing import Any, Literal

from .....utils.dev import ModelScopeLayoutComponent, resolve_frontend_dir

Expand All @@ -17,12 +17,12 @@ class AntdDescriptionsItem(ModelScopeLayoutComponent):

def __init__(
self,
label: str | None = "",
label: str | None = None,
props: dict | None = None,
*,
content_style: dict | None = None,
label_style: dict | None = None,
span: int | dict | None = 1,
span: int | dict | Literal['filled'] | None = 1,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand Down
1 change: 0 additions & 1 deletion backend/modelscope_studio/components/antd/form/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class AntdForm(ModelScopeDataLayoutComponent):
"""
Item = AntdFormItem
Provider = AntdFormProvider

EVENTS = [
EventListener("fields_change",
callback=lambda block: block._internal.update(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class AntdInputOTP(ModelScopeDataLayoutComponent):
EventListener("change",
callback=lambda block: block._internal.update(
bind_change_event=True)),
EventListener("input",
callback=lambda block: block._internal.update(
bind_input_event=True)),
]

# supported slots
Expand Down
4 changes: 3 additions & 1 deletion backend/modelscope_studio/components/antd/select/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class AntdSelect(ModelScopeDataLayoutComponent):
SLOTS = [
'allowClear.clearIcon', 'maxTagPlaceholder', 'menuItemSelectedIcon',
'dropdownRender', 'optionRender', 'tagRender', 'labelRender',
'notFoundContent', 'removeIcon', 'suffixIcon', 'options'
'notFoundContent', 'removeIcon', 'suffixIcon', 'prefix', 'options'
]

def __init__(
Expand Down Expand Up @@ -94,6 +94,7 @@ def __init__(
size: Literal['large', 'middle', 'small'] | None = None,
status: Literal['error', 'warning'] | None = None,
suffix_icon: str | None = None,
prefix: str | None = None,
tag_render: str | None = None,
label_render: str | None = None,
token_separators: list[str] | None = None,
Expand Down Expand Up @@ -128,6 +129,7 @@ def __init__(
self.default_open = default_open
self.default_value = default_value
self.disabled = disabled
self.prefix = prefix
self.popup_class_name = popup_class_name
self.popup_match_select_width = popup_match_select_width
self.get_popup_container = get_popup_container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ class AntdTableColumn(ModelScopeLayoutComponent):

# supported slots
SLOTS = [
'filterDropdown', 'filterIcon', 'render', 'title', 'sortIcon',
'showSorterTooltip.title'
'filterDropdown', "filterDropdownProps.dropdownRender",
"filterDropdownProps.menu.expandIcon",
'filterDropdownProps.menu.overflowedIndicator',
"filterDropdownProps.menu.items", 'filterIcon', 'render', 'title',
'sortIcon', 'showSorterTooltip.title'
]

def __init__(
Expand All @@ -46,6 +49,7 @@ def __init__(
filter_mode: Literal['menu', 'tree'] | None = None,
filter_search: bool | str | None = None,
filters: list[dict] | None = None,
filter_dropdown_props: dict | None = None,
fixed: str | bool | None = None,
key: str | None = None,
column_render: str | None = None,
Expand Down Expand Up @@ -96,6 +100,7 @@ def __init__(
self.filter_mode = filter_mode
self.filter_search = filter_search
self.filters = filters
self.filter_dropdown_props = filter_dropdown_props
self.fixed = fixed
self.key = key
self.column_render = column_render
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AntdTreeSelect(ModelScopeDataLayoutComponent):
# supported slots
SLOTS = [
'allowClear.clearIcon', 'maxTagPlaceholder', 'notFoundContent',
'suffixIcon', 'switcherIcon', 'dropdownRender', 'tagRender',
'prefix', 'suffixIcon', 'switcherIcon', 'dropdownRender', 'tagRender',
'treeTitleRender', 'treeData'
]

Expand Down Expand Up @@ -71,6 +71,7 @@ def __init__(
max_tag_text_length: int | None = None,
multiple: bool | None = None,
not_found_content: str | None = None,
prefix: str | None = None,
placeholder: str | None = None,
placement: Literal['bottomLeft', 'bottomRight', 'topLeft',
'topRight'] | None = None,
Expand Down Expand Up @@ -128,6 +129,7 @@ def __init__(
self.popup_match_select_width = popup_match_select_width
self.dropdown_render = dropdown_render
self.dropdown_style = dropdown_style
self.prefix = prefix
self.field_names = field_names
self.filter_tree_node = filter_tree_node
self.get_popup_container = get_popup_container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import tempfile
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable
from typing import TYPE_CHECKING, Any, Callable, Literal

import gradio_client.utils as client_utils
from gradio import processing_utils
Expand Down Expand Up @@ -57,6 +57,31 @@ def __init__(
value: list[str] | Callable | None = None,
props: dict | None = None,
*,
accept: str | None = None,
action: str | None = None,
before_upload: str | None = None,
custom_request: str | None = None,
data: dict | str | None = None,
default_file_list: list[dict] | None = None,
directory: bool | None = None,
disabled: bool | None = None,
file_list: list[dict] | None = None,
headers: dict | None = None,
icon_render: str | None = None,
is_image_url: str | None = None,
item_render: str | None = None,
list_type: Literal['text', 'picture', 'picture-card',
'picture-circle'] | None = None,
max_count: int | None = None,
method: str | None = None,
multiple: bool | None = None,
form_name: str | None = None,
open_file_dialog_on_click: bool | None = True,
preview_file: str | None = None,
progress: dict | None = None,
show_upload_list: bool | dict | None = True,
with_credentials: bool | None = None,
root_class_name: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -83,6 +108,30 @@ def __init__(
**kwargs)

self.props = props
self.accept = accept
self.action = action
self.before_upload = before_upload
self.custom_request = custom_request
self.data = data
self.default_file_list = default_file_list
self.directory = directory
self.disabled = disabled
self.file_list = file_list
self.headers = headers
self.icon_render = icon_render
self.is_image_url = is_image_url
self.item_render = item_render
self.list_type = list_type
self.max_count = max_count
self.method = method
self.multiple = multiple
self.form_name = form_name
self.open_file_dialog_on_click = open_file_dialog_on_click
self.preview_file = preview_file
self.progress = progress
self.show_upload_list = show_upload_list
self.with_credentials = with_credentials
self.root_class_name = root_class_name

FRONTEND_DIR = resolve_frontend_dir("upload", "dragger")

Expand Down
24 changes: 24 additions & 0 deletions docs/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,33 @@ def get_docs(file_path: str, type: Literal["antd", "base"]):
"type":
"group",
"children": [{
"label": get_text("Avatar", "Avatar 头像"),
"key": "avatar"
}, {
"label": get_text("Badge", "Badge 徽标数"),
"key": "badge"
}, {
"label": get_text("Calendar", "Calendar 日历"),
"key": "calendar"
}, {
"label": get_text("Card", "Card 卡片"),
"key": "card"
}, {
"label": get_text("Carousel", "Carousel 走马灯"),
"key": "carousel"
}, {
"label": get_text("Tour", "Tour 漫游式引导"),
"key": "tour"
}]
}, {
"label":
get_text("Feedback", "反馈"),
"type":
"group",
"children": [{
"label": get_text("Alert", "Alert 警告提示"),
"key": "alert"
}]
}, {
"label":
get_text("Other", "其他"),
Expand Down
8 changes: 8 additions & 0 deletions docs/components/antd/avatar/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Avatar

Used to represent users or things, supporting the display of images, icons, or characters. See [Ant Design](https://ant.design/components/avatar/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="group" title="Avatar.Group"></demo>
8 changes: 8 additions & 0 deletions docs/components/antd/avatar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Avatar

Used to represent users or things, supporting the display of images, icons, or characters. See [Ant Design](https://ant.design/components/avatar/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="group" title="Avatar.Group"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/avatar/app.py
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()
Loading

0 comments on commit e815be1

Please sign in to comment.