Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Col0ring committed Dec 2, 2024
1 parent 46b6f3f commit cf94e2e
Show file tree
Hide file tree
Showing 48 changed files with 2,669 additions and 1,973 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(
placeholder: str = '口',
size: Literal['large', 'middle', 'small'] | None = None,
status: Literal['error', 'warning'] | None = None,
variant: Literal['outline', 'borderless', 'filled'] | None = None,
variant: Literal['outlined', 'borderless', 'filled'] | 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 @@ -23,8 +23,6 @@ def __init__(
label: str | None = None,
props: dict | None = None,
*,
title: str | None = None,
disabled: bool | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -44,8 +42,6 @@ def __init__(
self.props = props
self.number = number
self.label = label
self.disabled = disabled
self.title = title

FRONTEND_DIR = resolve_frontend_dir("slider", "mark")

Expand Down
2 changes: 1 addition & 1 deletion backend/modelscope_studio/components/antd/tree/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AntdTree(ModelScopeLayoutComponent):
EVENTS = [
EventListener("check",
callback=lambda block: block._internal.update(
bind_click_event=True)),
bind_check_event=True)),
EventListener("drag_end",
callback=lambda block: block._internal.update(
bind_dragEnd_event=True)),
Expand Down
17 changes: 6 additions & 11 deletions backend/modelscope_studio/components/antd/tree_select/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@ class AntdTreeSelect(ModelScopeDataLayoutComponent):

# supported slots
SLOTS = [
'allowClear.clearIcon',
'maxTagPlaceholder',
'notFoundContent',
'suffixIcon',
'switcherIcon',
'dropdownRender',
'tagRender',
'treeTitleRender',
'allowClear.clearIcon', 'maxTagPlaceholder', 'notFoundContent',
'suffixIcon', 'switcherIcon', 'dropdownRender', 'tagRender',
'treeTitleRender', 'treeData'
]

def __init__(
Expand Down Expand Up @@ -78,7 +73,7 @@ def __init__(
not_found_content: str | None = None,
placeholder: str | None = None,
placement: Literal['bottomLeft', 'bottomRight', 'topLeft',
'topRight'] | None = 'bottomLeft',
'topRight'] | None = None,
search_value: str | None = None,
show_checked_strategy: Literal['SHOW_ALL', 'SHOW_PARENT',
'SHOW_CHILD'] | None = None,
Expand All @@ -102,8 +97,8 @@ def __init__(
tree_loaded_keys: list[str] | None = None,
tree_node_filter_prop: str | None = None,
tree_node_label_prop: str | None = None,
variant: Literal['outline', 'borderless', 'solid']
| None = 'outline',
variant: Literal['outlined', 'borderless', 'solid']
| None = None,
virtual: bool | None = True,
root_class_name: str | None = None,
as_item: str | None = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AntdTreeSelectTreeNode(ModelScopeLayoutComponent):
EVENTS = []

# supported slots
SLOTS = ["title"]
SLOTS = ["title", "icon"]

def __init__(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class AntdUpload(ModelScopeDataLayoutComponent):
EVENTS = [
EventListener("change",
callback=lambda block: block._internal.update(
bind_click_event=True)),
bind_change_event=True)),
EventListener("drop",
callback=lambda block: block._internal.update(
bind_drop_event=True)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AntdUploadDragger(ModelScopeDataLayoutComponent):
EVENTS = [
EventListener("change",
callback=lambda block: block._internal.update(
bind_click_event=True)),
bind_change_event=True)),
EventListener("drop",
callback=lambda block: block._internal.update(
bind_drop_event=True)),
Expand Down
4 changes: 2 additions & 2 deletions config/changelog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"devDependencies": {
"@changesets/types": "^6.0.0",
"@types/node": "^22.7.5",
"tsup": "^8.3.0"
"@types/node": "^22.10.1",
"tsup": "^8.3.5"
}
}
24 changes: 12 additions & 12 deletions config/lint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@
}
},
"dependencies": {
"@eslint/compat": "^1.2.0",
"@eslint/js": "^9.12.0",
"@typescript-eslint/parser": "^8.8.1",
"@eslint/compat": "^1.2.3",
"@eslint/js": "^9.16.0",
"@typescript-eslint/parser": "^8.16.0",
"eslint-config-prettier": "^9.0.0",
"eslint-import-resolver-typescript": "^3.6.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.9.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-react": "^7.37.1",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.12",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.14",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-svelte": "^2.44.1",
"globals": "^15.11.0",
"postcss": "^8.4.47",
"eslint-plugin-svelte": "^2.46.1",
"globals": "^15.13.0",
"postcss": "^8.4.49",
"postcss-less": "^6.0.0",
"stylelint-config-ali": "^2.1.1",
"stylelint-config-rational-order": "^0.1.2",
"stylelint-config-standard": "^36.0.1",
"stylelint-declaration-block-no-ignored-properties": "^2.8.0",
"stylelint-order": "^6.0.4",
"stylelint-prettier": "^5.0.2",
"svelte-eslint-parser": "^0.41.1",
"typescript-eslint": "^8.8.1"
"svelte-eslint-parser": "^0.43.0",
"typescript-eslint": "^8.16.0"
},
"devDependencies": {
"@types/eslint": "^9.6.1",
Expand Down
18 changes: 18 additions & 0 deletions docs/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,24 @@ def get_docs(file_path: str, type: Literal["antd", "base"]):
}, {
"label": get_text("Select", "Select 选择器"),
"key": "select"
}, {
"label": get_text("Slider", "Slider 滑动输入条"),
"key": "slider"
}, {
"label": get_text("Switch", "Switch 开关"),
"key": "switch"
}, {
"label": get_text("TimePicker", "Time Picker 时间选择器"),
"key": "time_picker"
}, {
"label": get_text("Transfer", "Transfer 穿梭框"),
"key": "transfer"
}, {
"label": get_text("TreeSelect", "TreeSelect 树选择"),
"key": "tree_select"
}, {
"label": get_text("Upload", "Upload 上传"),
"key": "upload"
}]
}, {
"label":
Expand Down
8 changes: 8 additions & 0 deletions docs/components/antd/slider/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Slider

A Slider component for displaying current value and intervals in range. See [Ant Design](https://ant.design/components/slider/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="marks" title="With Marks"></demo>
8 changes: 8 additions & 0 deletions docs/components/antd/slider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Slider

A Slider component for displaying current value and intervals in range. See [Ant Design](https://ant.design/components/slider/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="marks" title="With Marks"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/slider/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()
21 changes: 21 additions & 0 deletions docs/components/antd/slider/demos/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
antd.Slider(value=50)
antd.Slider(range=True, value=[20, 50])
antd.Divider("Vertical")
antd.Slider(range=True,
value=[20, 50],
step=5,
vertical=True,
elem_style=dict(height=200))
antd.Divider("Customize tooltip")
antd.Slider(tooltip=dict(formatter="(value) => `${value}%`"))

if __name__ == "__main__":
demo.queue().launch()
43 changes: 43 additions & 0 deletions docs/components/antd/slider/demos/marks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
antd.Slider(
marks={
"0": '0°C',
"26": '26°C',
"37": '37°C',
"100": {
"style": {
"color": '#f50'
},
"label": "100°C",
},
})
with antd.Slider():
with ms.Slot("marks"):
antd.Slider.Mark(
number=0,
label="0°C",
)
antd.Slider.Mark(
number=26,
label="26°C",
)
antd.Slider.Mark(
number=37,
label="37°C",
)
with antd.Slider.Mark(
number=100,
elem_style=dict(width=40),
):
with ms.Slot("label"):
antd.Typography.Text("100°C", type="success")

if __name__ == "__main__":
demo.queue().launch()
7 changes: 7 additions & 0 deletions docs/components/antd/switch/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Switch

Used to toggle between two states. See [Ant Design](https://ant.design/components/switch/) for more information.

## Examples

<demo name="basic"></demo>
7 changes: 7 additions & 0 deletions docs/components/antd/switch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Switch

Used to toggle between two states. See [Ant Design](https://ant.design/components/switch/) for more information.

## Examples

<demo name="basic"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/switch/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()
20 changes: 20 additions & 0 deletions docs/components/antd/switch/demos/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
with antd.Space():
antd.Switch(value=True)
antd.Switch(checked_children="Open",
un_checked_children="Close")
with antd.Switch(value=True):
with ms.Slot("checkedChildren"):
antd.Icon("CheckOutlined")
with ms.Slot("unCheckedChildren"):
antd.Icon("CloseOutlined")

if __name__ == "__main__":
demo.queue().launch()
8 changes: 8 additions & 0 deletions docs/components/antd/time_picker/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# TimePicker

To select/input a time. See [Ant Design](https://ant.design/components/time-picker/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="ranger_picker" title="Range Picker"></demo>
8 changes: 8 additions & 0 deletions docs/components/antd/time_picker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# TimePicker

To select/input a time. See [Ant Design](https://ant.design/components/time-picker/) for more information.

## Examples

<demo name="basic"></demo>
<demo name="ranger_picker" title="Range Picker"></demo>
6 changes: 6 additions & 0 deletions docs/components/antd/time_picker/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()
32 changes: 32 additions & 0 deletions docs/components/antd/time_picker/demos/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import time

import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
with antd.Space(direction='vertical'):
antd.TimePicker()
antd.TimePicker(format="HH:mm")
antd.TimePicker(minute_step=15,
second_step=10,
hour_step=1,
need_confirm=True)
antd.Divider("12 hours")
with antd.Space(direction='vertical'):
antd.TimePicker(use_12_hours=True)
antd.TimePicker(use_12_hours=True, format="h:mm:ss A")
antd.TimePicker(use_12_hours=True, format="h:mm a")
antd.Divider("Prefix and Suffix")
with antd.Space(direction='vertical'):
with antd.TimePicker():
with ms.Slot("suffixIcon"):
antd.Icon("SmileOutlined")
with antd.TimePicker():
with ms.Slot("prefix"):
antd.Icon("SmileOutlined")
if __name__ == "__main__":
demo.queue().launch()
14 changes: 14 additions & 0 deletions docs/components/antd/time_picker/demos/ranger_picker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import time

import gradio as gr

import modelscope_studio.components.antd as antd
import modelscope_studio.components.base as ms

with gr.Blocks() as demo:
with ms.Application():
with antd.ConfigProvider():
antd.TimePicker.RangePicker(
value=lambda: [time.time(), time.time()], format="HH:mm:ss")
if __name__ == "__main__":
demo.queue().launch()
7 changes: 7 additions & 0 deletions docs/components/antd/transfer/README-zh_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Transfer

Double column transfer choice box. See [Ant Design](https://ant.design/components/transfer/) for more information.

## Examples

<demo name="basic"></demo>
Loading

0 comments on commit cf94e2e

Please sign in to comment.