Skip to content

Commit

Permalink
feat: complete components params in Python
Browse files Browse the repository at this point in the history
  • Loading branch information
Col0ring committed Oct 31, 2024
1 parent 2882753 commit 9e5da52
Show file tree
Hide file tree
Showing 104 changed files with 2,455 additions and 973 deletions.
17 changes: 17 additions & 0 deletions .changeset/five-actors-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
'@modelscope-studio/legacy-waterfall-gallery': patch
'@modelscope-studio/legacy-multimodal-input': patch
'@modelscope-studio/legacy-lifecycle': patch
'@modelscope-studio/legacy-markdown': patch
'@modelscope-studio/legacy-compiled': patch
'@modelscope-studio/legacy-chatbot': patch
'@modelscope-studio/legacy-flow': patch
'@modelscope-studio/lint-config': patch
'@modelscope-studio/changelog': patch
'@modelscope-studio/antd': patch
'@modelscope-studio/base': patch
'@modelscope-studio/frontend': patch
'modelscope_studio': patch
---

feat: complete components params in Python
23 changes: 22 additions & 1 deletion backend/modelscope_studio/components/antd/alert/__init__.py
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 gradio.events import EventListener

Expand All @@ -10,6 +10,7 @@

class AntdAlert(ModelScopeLayoutComponent):
"""
Ant Design: https://ant.design/components/alert
"""
ErrorBoundary = AntdAlertErrorBoundary
EVENTS = [
Expand All @@ -25,6 +26,16 @@ def __init__(
self,
props: dict | None = None,
*,
action: str | None = None,
after_close: str | None = None,
banner: bool | None = None,
closable: bool | dict | None = None,
description: str | None = None,
icon: str | None = None,
message: str | None = None,
show_icon: bool | None = None,
type: Literal['success', 'info', 'warning', 'error'] | None = None,
root_class_name: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -42,6 +53,16 @@ def __init__(
elem_style=elem_style,
**kwargs)
self.props = props
self.action = action
self.after_close = after_close
self.banner = banner
self.closable = closable
self.description = description
self.icon = icon
self.message = message
self.show_icon = show_icon
self.type = type
self.root_class_name = root_class_name

FRONTEND_DIR = resolve_frontend_dir("alert")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class AntdAlertErrorBoundary(ModelScopeLayoutComponent):
"""
Ant Design: https://ant.design/components/alert
"""
EVENTS = [
EventListener("close",
Expand All @@ -23,6 +24,9 @@ def __init__(
self,
props: dict | None = None,
*,
description: str | None = None,
message: str | None = None,
root_class_name: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -40,6 +44,9 @@ def __init__(
elem_style=elem_style,
**kwargs)
self.props = props
self.description = description
self.message = message
self.root_class_name = root_class_name

FRONTEND_DIR = resolve_frontend_dir("alert", "error-boundary")

Expand Down
23 changes: 22 additions & 1 deletion backend/modelscope_studio/components/antd/avatar/__init__.py
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 gradio.events import EventListener

Expand All @@ -10,6 +10,7 @@

class AntdAvatar(ModelScopeLayoutComponent):
"""
Ant Design: https://ant.design/components/avatar
"""
Group = AntdAvatarGroup

Expand All @@ -27,6 +28,17 @@ def __init__(
src: str | None = None,
props: dict | None = None,
*,
alt: str | None = None,
gap: int = 4,
icon: str | None = None,
shape: Literal['circle', 'square'] = 'circle',
size: int | Literal['large', 'small', 'default'] | dict
| None = 'default',
src_set: str | None = None,
draggable: bool | Literal['true', 'false'] | None = None,
cross_origin: Literal['anonymous', 'use-credentials', '']
| None = None,
root_class_name: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -44,6 +56,15 @@ def __init__(
elem_style=elem_style,
**kwargs)
self.src = src
self.alt = alt
self.gap = gap
self.icon = icon
self.shape = shape
self.size = size
self.src_set = src_set
self.draggable = draggable
self.cross_origin = cross_origin
self.root_class_name = root_class_name
self.props = props

FRONTEND_DIR = resolve_frontend_dir("avatar")
Expand Down
12 changes: 12 additions & 0 deletions backend/modelscope_studio/components/antd/avatar/group/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

from typing import Literal

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


class AntdAvatarGroup(ModelScopeLayoutComponent):
"""
Ant Design: https://ant.design/components/avatar
"""
EVENTS = []
# supported slots
Expand All @@ -14,6 +17,11 @@ def __init__(
self,
props: dict | None = None,
*,
max: dict | None = None,
size: int | Literal['large', 'small', 'default']
| dict = 'default',
shape: Literal['circle', 'square'] = 'circle',
root_class_name: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -31,6 +39,10 @@ def __init__(
elem_style=elem_style,
**kwargs)
self.props = props
self.max = max
self.size = size
self.shape = shape
self.root_class_name = root_class_name

FRONTEND_DIR = resolve_frontend_dir("avatar", 'group')

Expand Down
32 changes: 28 additions & 4 deletions backend/modelscope_studio/components/antd/badge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from __future__ import annotations

from typing import Any

from gradio.events import EventListener
from typing import Any, Literal

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


class AntdBadge(ModelScopeLayoutComponent):
"""
Ant Design: https://ant.design/components/badge
"""
Ribbon = AntdBadgeRibbon

Expand All @@ -20,9 +19,22 @@ class AntdBadge(ModelScopeLayoutComponent):

def __init__(
self,
count: int | None = None,
count: int | float | str | None = None,
props: dict | None = None,
*,
color: str | None = None,
class_names: dict | None = None,
dot: bool = False,
offset: tuple[int | float, int | float] | None = None,
overflow_count: int = 99,
show_zero: bool = False,
size: Literal['small', 'default'] | None = None,
status: Literal['success', 'processing', 'default', 'error',
'warning'] | None = None,
text: str | None = None,
title: str | None = None,
styles: dict | None = None,
root_class_name: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -40,6 +52,18 @@ def __init__(
elem_style=elem_style,
**kwargs)
self.count = count
self.color = color
self.class_names = class_names
self.dot = dot
self.offset = offset
self.overflow_count = overflow_count
self.show_zero = show_zero
self.size = size
self.status = status
self.text = text
self.title = title
self.styles = styles
self.root_class_name = root_class_name
self.props = props

FRONTEND_DIR = resolve_frontend_dir("badge")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import annotations

from typing import Literal

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


class AntdBadgeRibbon(ModelScopeLayoutComponent):
"""
Ant Design: https://ant.design/components/badge
"""
EVENTS = []

Expand All @@ -13,6 +16,9 @@ def __init__(
text: str | None = None,
props: dict | None = None,
*,
color: str | None = None,
placement: Literal['start', 'end'] = 'end',
root_class_name: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -30,6 +36,9 @@ def __init__(
elem_style=elem_style,
**kwargs)
self.props = props
self.color = color
self.placement = placement
self.root_class_name = root_class_name
self.text = text

FRONTEND_DIR = resolve_frontend_dir("badge", 'ribbon')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(
icon_position: Literal["start", "end"] | None = "start",
loading: bool = False,
shape: Literal["default", "circle", "round"] | None = "default",
size: Literal["large", "middle", "small"] | None = "middle",
size: Literal["large", "middle", "small"] | None = None,
styles: dict | None = None,
href_target: str | None = None,
type: Literal["primary", "dashed", "link", "text", "default"]
Expand Down
24 changes: 23 additions & 1 deletion backend/modelscope_studio/components/antd/calendar/__init__.py
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 gradio.events import EventListener

Expand All @@ -10,6 +10,7 @@
# as inputs, outputs
class AntdCalendar(ModelScopeComponent):
"""
Ant Design: https://ant.design/components/calendar
"""

EVENTS = [
Expand All @@ -32,6 +33,17 @@ def __init__(
value: int | str | float | None = None,
props: dict | None = None,
*,
cell_render: str | None = None,
full_cell_render: str | None = None,
default_value: int | str | float | None = None,
disabled_date: str | None = None,
fullscreen: bool = True,
header_render: str | None = None,
locale: dict | None = None,
mode: Literal['month', 'year'] = 'month',
valid_range: tuple[int | str | float, int | str | float]
| None = None,
root_class_name: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -50,6 +62,16 @@ def __init__(
elem_style=elem_style,
**kwargs)
self.props = props
self.cell_render = cell_render
self.full_cell_render = full_cell_render
self.default_value = default_value
self.disabled_date = disabled_date
self.fullscreen = fullscreen
self.header_render = header_render
self.locale = locale
self.mode = mode
self.valid_range = valid_range
self.root_class_name = root_class_name

FRONTEND_DIR = resolve_frontend_dir("calendar")

Expand Down
4 changes: 3 additions & 1 deletion backend/modelscope_studio/components/antd/card/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,15 @@ def __init__(
extra: str | None = None,
hoverable: bool = False,
loading: bool = False,
size: Literal["default", "small"] = "default",
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,
title: str | None = None,
type: str | None = None,
class_names: dict | None = None,
styles: dict | None = None,
root_class_name: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand Down Expand Up @@ -113,6 +114,7 @@ def __init__(
self.type = type
self.class_names = class_names
self.styles = styles
self.root_class_name = root_class_name

FRONTEND_DIR = resolve_frontend_dir("card")

Expand Down
Loading

0 comments on commit 9e5da52

Please sign in to comment.