-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent invalid values from being submitted to dropdown, etc. (#8810)
* prevent invalid values * error * add changeset * component * add tests * fix tests * spec ts * format --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
- Loading branch information
1 parent
21f1b89
commit 4cf8af9
Showing
11 changed files
with
143 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"gradio": minor | ||
--- | ||
|
||
feat:Prevent invalid values from being submitted to dropdown, etc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,74 @@ | ||
{ | ||
"mode": "pre", | ||
"tag": "beta", | ||
"initialVersions": { | ||
"@gradio/client": "1.3.0", | ||
"gradio_client": "1.1.0", | ||
"gradio": "4.38.1", | ||
"@gradio/cdn-test": "0.0.1", | ||
"@gradio/spaces-test": "0.0.1", | ||
"website": "0.34.0", | ||
"@gradio/accordion": "0.3.18", | ||
"@gradio/annotatedimage": "0.6.13", | ||
"@gradio/app": "1.38.1", | ||
"@gradio/atoms": "0.7.6", | ||
"@gradio/audio": "0.12.2", | ||
"@gradio/box": "0.1.20", | ||
"@gradio/button": "0.2.46", | ||
"@gradio/chatbot": "0.12.1", | ||
"@gradio/checkbox": "0.3.8", | ||
"@gradio/checkboxgroup": "0.5.8", | ||
"@gradio/code": "0.7.0", | ||
"@gradio/colorpicker": "0.3.8", | ||
"@gradio/column": "0.1.2", | ||
"@gradio/dataframe": "0.8.13", | ||
"@gradio/dataset": "0.2.0", | ||
"@gradio/datetime": "0.0.2", | ||
"@gradio/downloadbutton": "0.1.23", | ||
"@gradio/dropdown": "0.7.8", | ||
"@gradio/fallback": "0.3.8", | ||
"@gradio/file": "0.8.5", | ||
"@gradio/fileexplorer": "0.4.14", | ||
"@gradio/form": "0.1.20", | ||
"@gradio/gallery": "0.11.2", | ||
"@gradio/group": "0.1.1", | ||
"@gradio/highlightedtext": "0.7.2", | ||
"@gradio/html": "0.3.1", | ||
"@gradio/icons": "0.6.0", | ||
"@gradio/image": "0.12.2", | ||
"@gradio/imageeditor": "0.7.13", | ||
"@gradio/json": "0.2.8", | ||
"@gradio/label": "0.3.8", | ||
"@gradio/lite": "4.38.1", | ||
"@gradio/markdown": "0.8.1", | ||
"@gradio/model3d": "0.11.0", | ||
"@gradio/multimodaltextbox": "0.5.2", | ||
"@gradio/number": "0.4.8", | ||
"@gradio/paramviewer": "0.4.17", | ||
"@gradio/plot": "0.6.0", | ||
"@gradio/preview": "0.10.1", | ||
"gradio_test": "0.5.0", | ||
"@gradio/radio": "0.5.8", | ||
"@gradio/row": "0.1.3", | ||
"@gradio/simpledropdown": "0.2.8", | ||
"@gradio/simpleimage": "0.6.2", | ||
"@gradio/simpletextbox": "0.2.8", | ||
"@gradio/slider": "0.4.8", | ||
"@gradio/state": "0.1.0", | ||
"@gradio/statustracker": "0.7.1", | ||
"@gradio/storybook": "0.6.0", | ||
"@gradio/tabitem": "0.2.12", | ||
"@gradio/tabs": "0.2.11", | ||
"@gradio/textbox": "0.6.7", | ||
"@gradio/theme": "0.2.3", | ||
"@gradio/timer": "0.3.0", | ||
"@gradio/tooltip": "0.1.0", | ||
"@gradio/tootils": "0.6.0", | ||
"@gradio/upload": "0.11.5", | ||
"@gradio/uploadbutton": "0.6.14", | ||
"@gradio/utils": "0.5.1", | ||
"@gradio/video": "0.9.2", | ||
"@gradio/wasm": "0.11.0" | ||
}, | ||
"changesets": [] | ||
"mode": "pre", | ||
"tag": "beta", | ||
"initialVersions": { | ||
"@gradio/client": "1.3.0", | ||
"gradio_client": "1.1.0", | ||
"gradio": "4.38.1", | ||
"@gradio/cdn-test": "0.0.1", | ||
"@gradio/spaces-test": "0.0.1", | ||
"website": "0.34.0", | ||
"@gradio/accordion": "0.3.18", | ||
"@gradio/annotatedimage": "0.6.13", | ||
"@gradio/app": "1.38.1", | ||
"@gradio/atoms": "0.7.6", | ||
"@gradio/audio": "0.12.2", | ||
"@gradio/box": "0.1.20", | ||
"@gradio/button": "0.2.46", | ||
"@gradio/chatbot": "0.12.1", | ||
"@gradio/checkbox": "0.3.8", | ||
"@gradio/checkboxgroup": "0.5.8", | ||
"@gradio/code": "0.7.0", | ||
"@gradio/colorpicker": "0.3.8", | ||
"@gradio/column": "0.1.2", | ||
"@gradio/dataframe": "0.8.13", | ||
"@gradio/dataset": "0.2.0", | ||
"@gradio/datetime": "0.0.2", | ||
"@gradio/downloadbutton": "0.1.23", | ||
"@gradio/dropdown": "0.7.8", | ||
"@gradio/fallback": "0.3.8", | ||
"@gradio/file": "0.8.5", | ||
"@gradio/fileexplorer": "0.4.14", | ||
"@gradio/form": "0.1.20", | ||
"@gradio/gallery": "0.11.2", | ||
"@gradio/group": "0.1.1", | ||
"@gradio/highlightedtext": "0.7.2", | ||
"@gradio/html": "0.3.1", | ||
"@gradio/icons": "0.6.0", | ||
"@gradio/image": "0.12.2", | ||
"@gradio/imageeditor": "0.7.13", | ||
"@gradio/json": "0.2.8", | ||
"@gradio/label": "0.3.8", | ||
"@gradio/lite": "4.38.1", | ||
"@gradio/markdown": "0.8.1", | ||
"@gradio/model3d": "0.11.0", | ||
"@gradio/multimodaltextbox": "0.5.2", | ||
"@gradio/number": "0.4.8", | ||
"@gradio/paramviewer": "0.4.17", | ||
"@gradio/plot": "0.6.0", | ||
"@gradio/preview": "0.10.1", | ||
"gradio_test": "0.5.0", | ||
"@gradio/radio": "0.5.8", | ||
"@gradio/row": "0.1.3", | ||
"@gradio/simpledropdown": "0.2.8", | ||
"@gradio/simpleimage": "0.6.2", | ||
"@gradio/simpletextbox": "0.2.8", | ||
"@gradio/slider": "0.4.8", | ||
"@gradio/state": "0.1.0", | ||
"@gradio/statustracker": "0.7.1", | ||
"@gradio/storybook": "0.6.0", | ||
"@gradio/tabitem": "0.2.12", | ||
"@gradio/tabs": "0.2.11", | ||
"@gradio/textbox": "0.6.7", | ||
"@gradio/theme": "0.2.3", | ||
"@gradio/timer": "0.3.0", | ||
"@gradio/tooltip": "0.1.0", | ||
"@gradio/tootils": "0.6.0", | ||
"@gradio/upload": "0.11.5", | ||
"@gradio/uploadbutton": "0.6.14", | ||
"@gradio/utils": "0.5.1", | ||
"@gradio/video": "0.9.2", | ||
"@gradio/wasm": "0.11.0" | ||
}, | ||
"changesets": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: blocks_essay"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "countries_cities_dict = {\n", " \"USA\": [\"New York\", \"Los Angeles\", \"Chicago\"],\n", " \"Canada\": [\"Toronto\", \"Montreal\", \"Vancouver\"],\n", " \"Pakistan\": [\"Karachi\", \"Lahore\", \"Islamabad\"],\n", "}\n", "\n", "\n", "def change_textbox(choice):\n", " if choice == \"short\":\n", " return gr.Textbox(lines=2, visible=True), gr.Button(interactive=True)\n", " elif choice == \"long\":\n", " return gr.Textbox(lines=8, visible=True, value=\"Lorem ipsum dolor sit amet\"), gr.Button(interactive=True)\n", " else:\n", " return gr.Textbox(visible=False), gr.Button(interactive=False)\n", "\n", "\n", "with gr.Blocks() as demo:\n", " radio = gr.Radio(\n", " [\"short\", \"long\", \"none\"], label=\"What kind of essay would you like to write?\"\n", " )\n", " text = gr.Textbox(lines=2, interactive=True, show_copy_button=True)\n", "\n", " with gr.Row():\n", " num = gr.Number(minimum=0, maximum=100, label=\"input\")\n", " out = gr.Number(label=\"output\")\n", " minimum_slider = gr.Slider(0, 100, 0, label=\"min\")\n", " maximum_slider = gr.Slider(0, 100, 100, label=\"max\")\n", " submit_btn = gr.Button(\"Submit\", variant=\"primary\")\n", "\n", " with gr.Row():\n", " country = gr.Dropdown(list(countries_cities_dict.keys()), label=\"Country\")\n", " cities = gr.Dropdown([], label=\"Cities\")\n", " \n", " @country.change(inputs=country, outputs=cities)\n", " def update_cities(country):\n", " cities = list(countries_cities_dict[country])\n", " return gr.Dropdown(choices=cities, value=cities[0], interactive=True)\n", "\n", " def reset_bounds(minimum, maximum):\n", " return gr.Number(minimum=minimum, maximum=maximum)\n", "\n", " radio.change(fn=change_textbox, inputs=radio, outputs=[text, submit_btn])\n", " gr.on(\n", " [minimum_slider.change, maximum_slider.change],\n", " reset_bounds,\n", " [minimum_slider, maximum_slider],\n", " outputs=num,\n", " )\n", " num.submit(lambda x: x, num, out)\n", "\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: blocks_essay"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "countries_cities_dict = {\n", " \"USA\": [\"New York\", \"Los Angeles\", \"Chicago\"],\n", " \"Canada\": [\"Toronto\", \"Montreal\", \"Vancouver\"],\n", " \"Pakistan\": [\"Karachi\", \"Lahore\", \"Islamabad\"],\n", "}\n", "\n", "\n", "def change_textbox(choice):\n", " if choice == \"short\":\n", " return gr.Textbox(lines=2, visible=True), gr.Button(interactive=True)\n", " elif choice == \"long\":\n", " return gr.Textbox(lines=8, visible=True, value=\"Lorem ipsum dolor sit amet\"), gr.Button(interactive=True)\n", " else:\n", " return gr.Textbox(visible=False), gr.Button(interactive=False)\n", "\n", "\n", "with gr.Blocks() as demo:\n", " radio = gr.Radio(\n", " [\"short\", \"long\", \"none\"], label=\"What kind of essay would you like to write?\"\n", " )\n", " text = gr.Textbox(lines=2, interactive=True, show_copy_button=True)\n", "\n", " with gr.Row():\n", " num = gr.Number(minimum=0, maximum=100, label=\"input\")\n", " out = gr.Number(label=\"output\")\n", " minimum_slider = gr.Slider(0, 100, 0, label=\"min\")\n", " maximum_slider = gr.Slider(0, 100, 100, label=\"max\")\n", " submit_btn = gr.Button(\"Submit\", variant=\"primary\")\n", "\n", " with gr.Row():\n", " country = gr.Dropdown(list(countries_cities_dict.keys()), label=\"Country\")\n", " cities = gr.Dropdown([], label=\"Cities\")\n", " first_letter = gr.Textbox(label=\"First Letter\")\n", " \n", " @country.change(inputs=country, outputs=cities)\n", " def update_cities(country):\n", " cities = list(countries_cities_dict[country])\n", " return gr.Dropdown(choices=cities, value=cities[0], interactive=True)\n", "\n", " def reset_bounds(minimum, maximum):\n", " return gr.Number(minimum=minimum, maximum=maximum)\n", "\n", " radio.change(fn=change_textbox, inputs=radio, outputs=[text, submit_btn])\n", " gr.on(\n", " [minimum_slider.change, maximum_slider.change],\n", " reset_bounds,\n", " [minimum_slider, maximum_slider],\n", " outputs=num,\n", " )\n", " num.submit(lambda x: x, num, out)\n", "\n", " cities.change(\n", " lambda x: x[0], cities, first_letter\n", " )\n", "\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters