diff --git a/.changeset/plenty-parks-glow.md b/.changeset/plenty-parks-glow.md
new file mode 100644
index 000000000000..7889696b5675
--- /dev/null
+++ b/.changeset/plenty-parks-glow.md
@@ -0,0 +1,10 @@
+---
+"@gradio/checkbox": minor
+"@gradio/checkboxgroup": minor
+"@gradio/number": minor
+"@gradio/radio": minor
+"@gradio/slider": minor
+"gradio": minor
+---
+
+feat:V4: Single-file implementation of form components
diff --git a/gradio/_simple_templates/simpledropdown.py b/gradio/_simple_templates/simpledropdown.py
index 14773dfdf98e..e9619969fec6 100644
--- a/gradio/_simple_templates/simpledropdown.py
+++ b/gradio/_simple_templates/simpledropdown.py
@@ -33,7 +33,9 @@ def __init__(
visible: bool = True,
elem_id: str | None = None,
elem_classes: list[str] | str | None = None,
- **kwargs,
+ render: bool = True,
+ root_url: str | None = None,
+ _skip_init_processing: bool = False,
):
"""
Parameters:
@@ -49,6 +51,9 @@ def __init__(
visible: If False, component will be hidden.
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
+ render: bool = True,
+ root_url: str | None = None,
+ _skip_init_processing: bool = False,
"""
self.choices = (
# Although we expect choices to be a list of lists, it can be a list of tuples if the Gradio app
@@ -69,7 +74,9 @@ def __init__(
elem_id=elem_id,
elem_classes=elem_classes,
value=value,
- **kwargs,
+ render=render,
+ root_url=root_url,
+ _skip_init_processing=_skip_init_processing,
)
def api_info(self) -> dict[str, Any]:
diff --git a/gradio/_simple_templates/simpletextbox.py b/gradio/_simple_templates/simpletextbox.py
index 29ea0ed0cfd5..e704f85bf232 100644
--- a/gradio/_simple_templates/simpletextbox.py
+++ b/gradio/_simple_templates/simpletextbox.py
@@ -35,7 +35,9 @@ def __init__(
rtl: bool = False,
elem_id: str | None = None,
elem_classes: list[str] | str | None = None,
- **kwargs,
+ render: bool = True,
+ root_url: str | None = None,
+ _skip_init_processing: bool = False,
):
"""
Parameters:
@@ -51,6 +53,8 @@ def __init__(
rtl: If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.
elem_id: An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
+ render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
+ root_url: The remote URL that of the Gradio app that this component belongs to. Used in `gr.load()`. Should not be set manually.
"""
self.placeholder = placeholder
self.rtl = rtl
@@ -65,7 +69,9 @@ def __init__(
elem_id=elem_id,
elem_classes=elem_classes,
value=value,
- **kwargs,
+ render=render,
+ root_url=root_url,
+ _skip_init_processing=_skip_init_processing,
)
def preprocess(self, x: str | None) -> str | None:
diff --git a/gradio/cli/commands/components/show.py b/gradio/cli/commands/components/show.py
index 6834dcf77646..afd63fb9a319 100644
--- a/gradio/cli/commands/components/show.py
+++ b/gradio/cli/commands/components/show.py
@@ -25,6 +25,8 @@
"State",
}
+_BEGINNER_FRIENDLY = {"Slider", "Radio", "Checkbox", "Number", "CheckboxGroup", "File"}
+
def _get_table_items(module):
items = []
@@ -35,12 +37,12 @@ def _get_table_items(module):
) or (name in _IGNORE):
continue
tags = []
- if "Simple" in name or name in {"File"}:
- tags.append("🌱🤝Beginner Friendly🌱🤝")
+ if "Simple" in name or name in _BEGINNER_FRIENDLY:
+ tags.append(":seedling::handshake:Beginner Friendly:seedling::handshake:")
if issubclass(gr_cls, FormComponent):
- tags.append("📝🧩Form Component📝🧩")
+ tags.append(":pencil::jigsaw:Form Component:pencil::jigsaw:")
if name in gradio.layouts.__all__:
- tags.append("📐Layout📐")
+ tags.append(":triangular_ruler:Layout:triangular_ruler:")
doc = inspect.getdoc(gr_cls) or "No description available."
doc = doc.split(".")[0]
if tags:
diff --git a/gradio/components/video.py b/gradio/components/video.py
index 128349825d0b..82679bed5e62 100644
--- a/gradio/components/video.py
+++ b/gradio/components/video.py
@@ -52,6 +52,7 @@ class Video(Component):
Events.play,
Events.pause,
Events.end,
+ Events.upload,
]
def __init__(
diff --git a/js/checkbox/Index.svelte b/js/checkbox/Index.svelte
index bd54a9ea5694..55510b2695cb 100644
--- a/js/checkbox/Index.svelte
+++ b/js/checkbox/Index.svelte
@@ -1,10 +1,15 @@
+
+
@@ -36,13 +54,11 @@
{info}
{/if}
- gradio.dispatch("change")}
- on:input={() => gradio.dispatch("input")}
+ {label}
+ {mode}
+ on:change={handle_change}
on:select={(e) => gradio.dispatch("select", e.detail)}
- disabled={mode === "static"}
/>
diff --git a/js/checkbox/package.json b/js/checkbox/package.json
index 8b372a0282b5..9ab80a54da25 100644
--- a/js/checkbox/package.json
+++ b/js/checkbox/package.json
@@ -7,6 +7,7 @@
"license": "ISC",
"private": false,
"main_changeset": true,
+ "main": "./Index.svelte",
"exports": {
".": "./Index.svelte",
"./example": "./Example.svelte",
diff --git a/js/checkbox/shared/Checkbox.svelte b/js/checkbox/shared/Checkbox.svelte
index fb2e05474257..a0f5f1553b16 100644
--- a/js/checkbox/shared/Checkbox.svelte
+++ b/js/checkbox/shared/Checkbox.svelte
@@ -1,51 +1,51 @@