Skip to content

Commit

Permalink
feat: resolve rest props
Browse files Browse the repository at this point in the history
  • Loading branch information
Col0ring committed Sep 25, 2024
1 parent 6a9d2fd commit c49a8e1
Show file tree
Hide file tree
Showing 143 changed files with 523 additions and 281 deletions.
2 changes: 2 additions & 0 deletions backend/modelscope_studio/components/antd/affix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def __init__(
self,
props: dict | None = None,
*,
elem_target: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -37,6 +38,7 @@ def __init__(
elem_style=elem_style,
**kwargs)
self.props = props
self.elem_target = elem_target

FRONTEND_DIR = resolve_frontend_dir("affix")

Expand Down
2 changes: 0 additions & 2 deletions backend/modelscope_studio/components/antd/divider/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from typing import Any, Literal

from gradio.events import EventListener

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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def __init__(
self,
props: dict | None = None,
*,
elem_target: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -39,6 +40,7 @@ def __init__(
elem_style=elem_style,
**kwargs)
self.props = props
self.elem_target = elem_target

FRONTEND_DIR = resolve_frontend_dir("float-button", "back-top")

Expand Down
6 changes: 6 additions & 0 deletions backend/modelscope_studio/components/antd/icon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def __init__(
value: str | None = "GithubOutlined",
props: dict | None = None,
*,
spin: bool = False,
rotate: int | float | None = None,
component: str | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -44,6 +47,9 @@ def __init__(
elem_style=elem_style,
**kwargs)
self.props = props
self.spin = spin
self.rotate = rotate
self.component = component

FRONTEND_DIR = resolve_frontend_dir("icon")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(
script_url: str | list[str] | None = None,
props: dict | None = None,
*,
extra_common_props: dict | None = None,
as_item: str | None = None,
_internal: None = None,
# gradio properties
Expand All @@ -27,6 +28,7 @@ def __init__(
as_item=as_item,
**kwargs)
self.script_url = script_url
self.extra_common_props = extra_common_props
self.props = props

FRONTEND_DIR = resolve_frontend_dir("icon", "iconfont-provider")
Expand Down
28 changes: 18 additions & 10 deletions frontend/antd/affix/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,22 @@
export let elem_classes: string[] = [];
export let elem_style: React.CSSProperties = {};
const [mergedProps, update] = getSlotContext({
gradio,
props: $updatedProps,
_internal,
visible,
elem_id,
elem_classes,
elem_style,
as_item,
});
const [mergedProps, update] = getSlotContext(
{
gradio,
props: $updatedProps,
_internal,
visible,
elem_id,
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
},
{
elem_target: 'target',
}
);
const slots = getSlots();
$: update({
gradio,
Expand All @@ -48,6 +54,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
</script>

Expand All @@ -57,6 +64,7 @@
style={$mergedProps.elem_style}
className={cls($mergedProps.elem_classes, 'ms-gr-antd-affix')}
id={$mergedProps.elem_id}
{...$mergedProps.restProps}
{...$mergedProps.props}
{...bindEvents($mergedProps)}
slots={$slots}
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/alert/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -48,6 +49,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
</script>

Expand All @@ -57,6 +59,7 @@
style={$mergedProps.elem_style}
className={cls($mergedProps.elem_classes, 'ms-gr-antd-alert')}
id={$mergedProps.elem_id}
{...$mergedProps.restProps}
{...$mergedProps.props}
{...bindEvents($mergedProps)}
slots={$slots}
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/alert/error-boundary/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -50,6 +51,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
</script>

Expand All @@ -62,6 +64,7 @@
'ms-gr-antd-alert-error-boundary'
)}
id={$mergedProps.elem_id}
{...$mergedProps.restProps}
{...$mergedProps.props}
{...bindEvents($mergedProps)}
slots={$slots}
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/anchor/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -50,6 +51,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const { items, default: children } = getItems(['items', 'default']);
</script>
Expand All @@ -60,6 +62,7 @@
style={$mergedProps.elem_style}
className={cls($mergedProps.elem_classes, 'ms-gr-antd-anchor')}
id={$mergedProps.elem_id}
{...$mergedProps.restProps}
{...$mergedProps.props}
{...bindEvents($mergedProps)}
slots={$slots}
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/anchor/item/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -51,6 +52,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const setItem = getSetItemFn();
const { default: items } = getItems();
Expand All @@ -59,6 +61,7 @@
style: $mergedProps.elem_style,
className: cls($mergedProps.elem_classes, 'ms-gr-antd-anchor-item'),
id: $mergedProps.elem_id,
...$mergedProps.restProps,
...$mergedProps.props,
...bindEvents($mergedProps),
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/auto-complete/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
elem_style,
as_item,
value,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -52,6 +53,7 @@
elem_style,
as_item,
value,
restProps: $$restProps,
});
const { options, default: children } = getItems(['options', 'default']);
</script>
Expand All @@ -62,6 +64,7 @@
style={$mergedProps.elem_style}
className={cls($mergedProps.elem_classes, 'ms-gr-antd-auto-complete')}
id={$mergedProps.elem_id}
{...$mergedProps.restProps}
{...$mergedProps.props}
{...bindEvents($mergedProps)}
value={$mergedProps.props.value ?? $mergedProps.value}
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/auto-complete/option/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
as_item,
value,
label,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -57,6 +58,7 @@
as_item,
value,
label,
restProps: $$restProps,
});
const setItem = getSetItemFn();
const { default: items, options } = getItems(['default', 'options']);
Expand All @@ -71,6 +73,7 @@
id: $mergedProps.elem_id,
value: $mergedProps.value,
label: $mergedProps.label,
...$mergedProps.restProps,
...$mergedProps.props,
...bindEvents($mergedProps),
},
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/avatar/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -51,6 +52,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
</script>

Expand All @@ -61,6 +63,7 @@
style={$mergedProps.elem_style}
className={cls($mergedProps.elem_classes, 'ms-gr-antd-avatar')}
id={$mergedProps.elem_id}
{...$mergedProps.restProps}
{...$mergedProps.props}
{...bindEvents($mergedProps)}
slots={$slots}
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/avatar/group/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -48,6 +49,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
</script>

Expand All @@ -58,6 +60,7 @@
style={$mergedProps.elem_style}
className={cls($mergedProps.elem_classes, 'ms-gr-antd-avatar-group')}
id={$mergedProps.elem_id}
{...$mergedProps.restProps}
{...$mergedProps.props}
{...bindEvents($mergedProps)}
slots={$slots}
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/badge/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -51,12 +52,14 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
$: badge_props = {
style: $mergedProps.elem_style,
className: cls($mergedProps.elem_classes, 'ms-gr-antd-badge'),
id: $mergedProps.elem_id,
...$mergedProps.restProps,
...$mergedProps.props,
...bindEvents($mergedProps),
slots: $slots,
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/badge/ribbon/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
elem_style,
as_item,
text,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -50,6 +51,7 @@
elem_style,
as_item,
text,
restProps: $$restProps,
});
</script>

Expand All @@ -60,6 +62,7 @@
style={$mergedProps.elem_style}
className={cls($mergedProps.elem_classes, 'ms-gr-antd-badge-ribbon')}
id={$mergedProps.elem_id}
{...$mergedProps.restProps}
{...$mergedProps.props}
{...bindEvents($mergedProps)}
slots={$slots}
Expand Down
3 changes: 3 additions & 0 deletions frontend/antd/breadcrumb/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const slots = getSlots();
$: update({
Expand All @@ -50,6 +51,7 @@
elem_classes,
elem_style,
as_item,
restProps: $$restProps,
});
const { items, default: children } = getItems(['items', 'default']);
</script>
Expand All @@ -60,6 +62,7 @@
style={$mergedProps.elem_style}
className={cls($mergedProps.elem_classes, 'ms-gr-antd-breadcrumb')}
id={$mergedProps.elem_id}
{...$mergedProps.restProps}
{...$mergedProps.props}
{...bindEvents($mergedProps)}
slots={$slots}
Expand Down
Loading

0 comments on commit c49a8e1

Please sign in to comment.