Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only render visible components #10192

Open
wants to merge 263 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
263 commits
Select commit Hold shift + click to select a range
3adbe44
Merge branch 'main' into 5.0-dev
freddyaboulton Jul 25, 2024
a19a803
Merge branch 'main' into 5.0-dev
freddyaboulton Jul 29, 2024
3408dba
Remove manual ip address check and launch counter (#8884)
abidlabs Jul 29, 2024
e017706
Remove deprecated documentation (#8940)
aliabd Jul 30, 2024
03cac10
merge main
freddyaboulton Jul 31, 2024
574f507
Merge branch 'main' into 5.0-dev
abidlabs Jul 31, 2024
51b7a8b
Use HTTP Livestreaming for audio/video streaming out (#8906)
freddyaboulton Jul 31, 2024
a0aac66
Adds `strict_cors` parameter to `launch()` (#8959)
abidlabs Aug 1, 2024
4b86544
Merge main
freddyaboulton Aug 2, 2024
315bb83
Fi
freddyaboulton Aug 2, 2024
1a8bbae
Merge branch 'main' into 5.0-dev
freddyaboulton Aug 5, 2024
8805fc4
Streaming out tweaks (#8976)
freddyaboulton Aug 5, 2024
fe9d1cb
Improve url downloads for file objects (#8978)
aliabid94 Aug 6, 2024
382a561
Merge branch 'main' into 5.0-dev
freddyaboulton Aug 6, 2024
7ad19b2
merge main (#9050)
freddyaboulton Aug 7, 2024
ea38421
merge main
freddyaboulton Aug 7, 2024
e508dd6
Merge branch 'main' into 5.0-dev
abidlabs Aug 7, 2024
86fadff
Merge branch 'main' into 5.0-dev
abidlabs Aug 8, 2024
47182c1
Merge branch 'main' into 5.0-dev
abidlabs Aug 10, 2024
8b2308b
lint
freddyaboulton Aug 7, 2024
8297e17
Merge branch 'main' into 5.0-dev
abidlabs Aug 12, 2024
370e01a
Have gr.on set value at start as well (#9065)
aliabid94 Aug 12, 2024
f9f84bf
No token passed by default in `gr.load()` (#9069)
abidlabs Aug 12, 2024
db6b306
changes
Aug 12, 2024
0d8a358
Set default `format` in `gr.Audio` to be `None` to avoid unnecessary …
abidlabs Aug 13, 2024
a6b4ff1
Merge branch 'main' into 5.0-dev
pngwn Aug 13, 2024
f84116b
Merge branch 'main' into 5.0-dev
pngwn Aug 14, 2024
e6f11e6
Merge branch 'main' into 5.0-dev
pngwn Aug 14, 2024
97a7bf6
Streaming inputs for 5.0 (#8941)
freddyaboulton Aug 14, 2024
433cc04
Merge branch 'main' into 5.0-dev
pngwn Aug 15, 2024
3dbb412
Merge branch 'main' into 5.0-dev
abidlabs Aug 15, 2024
4bc495c
3.10 (#9133)
abidlabs Aug 16, 2024
5cedf16
Deprecate passing a tuple for gr.Code value (#9132)
freddyaboulton Aug 19, 2024
2672ea2
Postprocess hardening (#9122)
freddyaboulton Aug 19, 2024
c054ec8
Drop python 3.8 and 3.9 (#9140)
abidlabs Aug 19, 2024
864cd0f
Raise WasmUnsupportedError for ffmpeg usage on Lite (#9130)
whitphx Aug 20, 2024
f3652eb
Video gallery (#9052)
dawoodkhan82 Aug 20, 2024
3d7a9b8
Open audio/image input stream only when queue is ready (#9149)
freddyaboulton Aug 20, 2024
48ae28e
merge main
freddyaboulton Aug 20, 2024
72ffe0d
trigger ci
freddyaboulton Aug 20, 2024
31735da
Merge branch 'main' into 5.0-dev
abidlabs Aug 21, 2024
e675064
Merge branch 'main' into 5.0-dev
pngwn Aug 22, 2024
b038c93
Merge branch 'main' into 5.0-dev
pngwn Aug 22, 2024
4d9f665
update (#9176)
freddyaboulton Aug 22, 2024
8deeeb6
File access security guide (#9156)
freddyaboulton Aug 22, 2024
74aff6f
Merge branch 'main' into 5.0-dev
pngwn Aug 22, 2024
213211d
fix guide
freddyaboulton Aug 26, 2024
21f117d
Fix notebook (#9181)
freddyaboulton Aug 27, 2024
80c966a
DNS resolver on ip check (#9150)
aliabid94 Aug 27, 2024
69bf6ff
Merge branch 'main' into 5.0-dev
abidlabs Aug 27, 2024
74e9da3
Merge branch 'main' into 5.0-dev
abidlabs Aug 27, 2024
e6d456a
Change dark mode color theme from `gray` to `zinc` (#9175)
hannahblair Aug 28, 2024
66349fe
Streaming Guides (#9173)
freddyaboulton Aug 28, 2024
173f5b4
Fix (#9215)
freddyaboulton Aug 29, 2024
20c0836
Deprecate type='tuples for chatbot and focus chatbot docs on 'message…
freddyaboulton Aug 29, 2024
ab4580b
Remove grey background behind all components (#9213)
hannahblair Aug 29, 2024
9f4c3ee
changes
abidlabs Aug 29, 2024
9e2ae43
changes
abidlabs Aug 29, 2024
bc17479
Revert "changes"
abidlabs Aug 29, 2024
272b05c
Revert "changes"
abidlabs Aug 29, 2024
493df38
Merge branch 'main' into 5.0-dev
abidlabs Aug 29, 2024
6773c4d
Redesign `gr.Slider()` (#9197)
hannahblair Aug 29, 2024
3c73f00
🔡 Update default core Gradio font (#9204)
hannahblair Aug 29, 2024
e9e737e
Redesign `gr.Button()` (#9167)
hannahblair Aug 30, 2024
8a75559
Minor changes to flagging for 5.0 (#9166)
abidlabs Aug 30, 2024
4a832f4
Adds TLS to FRP tunnel (#9218)
abidlabs Aug 30, 2024
5492e74
Move buttons from chat_interface into Chatbot (#9201)
freddyaboulton Aug 31, 2024
227c5b9
Merge branch 'main' into 5.0-dev
abidlabs Aug 31, 2024
dd8e2e3
Improve button consistency across light/dark mode (#9236)
hannahblair Sep 1, 2024
3175c7a
Redesign `gr.Tabs()` (#9199)
hannahblair Sep 1, 2024
e137b30
Decrease component radii and remove input shadows (#9216)
hannahblair Sep 1, 2024
8bb3d34
fix py chatbot test
hannahblair Sep 2, 2024
c8cfe93
Lighten secondary button grey fill (#9245)
hannahblair Sep 2, 2024
38cf712
Stop using `multiprocessing` in `flagging.CSVLogger` on Lite v5 (#9246)
whitphx Sep 2, 2024
2e179d3
prefix api routes (#9200)
pngwn Sep 2, 2024
f8b411f
Built-in submit and stop buttons in `gr.ChatInterface(multimodal=Fals…
whitphx Sep 3, 2024
03f3735
Adds a "huggingface" button variant, and makes it the default for `gr…
abidlabs Sep 3, 2024
4db3162
chore: update versions (beta) (#8829)
pngwn Sep 4, 2024
f90dada
fix cs
pngwn Sep 4, 2024
7a36e3f
chore: update versions (beta) (#9262)
gradio-pr-bot Sep 4, 2024
350b0a5
Improve Icon Button consistency (#9250)
hannahblair Sep 4, 2024
950055e
Merge branch 'main' into 5.0-dev
abidlabs Sep 4, 2024
3b41452
format
hannahblair Sep 4, 2024
fe06141
Merge branch '5.0-dev' of github.com:gradio-app/gradio into 5.0-dev
hannahblair Sep 4, 2024
e05f568
Fix reload mode and streaming in 5.0 dev (#9269)
freddyaboulton Sep 5, 2024
c469d40
Raise error instead of warning if checksums for binary do not match (…
abidlabs Sep 5, 2024
6f5c411
Merge branch 'main' into 5.0-dev
abidlabs Sep 6, 2024
b0b8500
Fix stop recording button colors (#9270)
freddyaboulton Sep 6, 2024
7122420
Match style of textbox stop button to submit button (#9280)
freddyaboulton Sep 6, 2024
6309a48
Raise ChecksumMismatchError (#9300)
abidlabs Sep 9, 2024
54ea485
Further tweak to is_in_or_equal (#9282)
freddyaboulton Sep 10, 2024
af4f70a
changes (#9301)
abidlabs Sep 10, 2024
f3f0fef
Fixes race condition in `update_root_in_config` (#9306)
abidlabs Sep 10, 2024
d31fa59
docstring
abidlabs Sep 11, 2024
99648ec
Adds ability to block event trigger when file is uploading (#9253)
dawoodkhan82 Sep 11, 2024
8e78da9
5.0 merge (#9318)
pngwn Sep 11, 2024
7c0780b
Proposal: remove `gr.make_waveform` and remove `matplotlib` as a depe…
abidlabs Sep 11, 2024
34f46b0
Dont move files to cache automatically in chatbot postprocess (#9303)
freddyaboulton Sep 11, 2024
81a356d
Remove two dependencies: `importlib_resources` and `urllib3` (if not …
abidlabs Sep 11, 2024
299879d
Make `gr.Image` preprocessing more efficient (#9314)
abidlabs Sep 12, 2024
7afb9a1
5.0 merge take 2 (#9326)
pngwn Sep 12, 2024
fcdac9d
Add `matplotlib` requirements to several demos (#9327)
abidlabs Sep 12, 2024
157a2a7
Merge branch 'main' into 5.0-dev
pngwn Sep 12, 2024
f813154
clean
pngwn Sep 12, 2024
202c180
format
pngwn Sep 12, 2024
1fef9d9
Standardize `height` across components and add `max_height` and `min_…
abidlabs Sep 12, 2024
19f6b31
Fix typo in `tunneling.py` (#9338)
abidlabs Sep 12, 2024
6a7f631
Set the color of placeholder in a disabled textbox to gray instead of…
abidlabs Sep 12, 2024
02369b3
Improve is_in_or_equal and fuzzer (#9341)
freddyaboulton Sep 12, 2024
322ac54
Add info about Powershell client (#9343)
abidlabs Sep 12, 2024
b543465
Remove lite/theme.css from the Git-managed file tree (#9335)
whitphx Sep 13, 2024
4338f29
9227 chatinterface retry bug (#9316)
freddyaboulton Sep 13, 2024
73647a0
Move icons into `IconButtonWrapper` (#9261)
hannahblair Sep 13, 2024
960743c
Added gradio-in-r (#9340)
Ifeanyi55 Sep 13, 2024
5b86e2f
Enhance Lite E2E tests and fix a networking problem on Lite (#9333)
whitphx Sep 13, 2024
61f794b
Do not attach `content_disposition_type = "attachment"` headers for f…
abidlabs Sep 13, 2024
d47dd1f
Fix overflowing markdown in Chatbot (#9260)
hannahblair Sep 13, 2024
50c3a7f
Small tweak to how thoughts are shown in `gr.Chatbot` (#9359)
abidlabs Sep 16, 2024
1daf259
Use `container` param in `gr.Markdown` (#9356)
hannahblair Sep 16, 2024
eb90dd9
Merge branch 'main' into 5.0-dev
pngwn Sep 17, 2024
91f00de
Merge branch 'main' into 5.0-dev
aliabd Sep 17, 2024
5b079c7
Merge branch 'main' into 5.0-dev
aliabd Sep 17, 2024
55bf0f3
Merge branch 'main' into 5.0-dev
aliabd Sep 17, 2024
535a5cf
run format
hannahblair Sep 17, 2024
d1aa185
Merge branch 'main' into 5.0-dev
aliabd Sep 18, 2024
9e70832
Fixes website build in 5.0-dev (#9382)
aliabd Sep 18, 2024
16c0485
Small tweaks to improve the DX for the "tuples"/"messages" argument i…
abidlabs Sep 18, 2024
618e9fe
Update babylon.js to `v7` for `gr.Model3D` (#9377)
abidlabs Sep 18, 2024
7bf3e99
Fix `gr.ImageEditor` toolbar cutoff (#9371)
hannahblair Sep 18, 2024
6af5506
Merge branch 'main' into 5.0-dev
aliabd Sep 18, 2024
6e5b8fb
Merge branch 'main' into 5.0-dev
aliabd Sep 18, 2024
83d6189
Merge branch 'main' into 5.0-dev
aliabd Sep 18, 2024
9a85ccc
Adds LLM to the Playground (#9233)
aliabd Sep 19, 2024
5eb860f
Refactor lazy caching (#9361)
abidlabs Sep 19, 2024
3b580ce
Merge branch 'main' into 5.0-dev
abidlabs Sep 19, 2024
c4afdcd
Added max lines and overflow scrollbar for `gr.Code` (#9311)
micpst Sep 19, 2024
53ed0f0
Fix File Types for MultimodalTextbox (#9393)
dawoodkhan82 Sep 19, 2024
3ad28c7
Prevent HTML and Markdown height changing when status is hidden (#9363)
hannahblair Sep 19, 2024
736046f
Object Detection From Webcam Stream Guide (#9336)
freddyaboulton Sep 19, 2024
4be0933
Fix gradio.js aws path (#9397)
aliabd Sep 19, 2024
aa35b07
Trigger state change event on iterators (#9299)
freddyaboulton Sep 19, 2024
1c94328
add local fonts and update themes (#9367)
hannahblair Sep 19, 2024
06babda
Disable liking user message in chatbot by default but make it configu…
freddyaboulton Sep 19, 2024
6443062
Fix Cached Examples for Streamed Media (#9373)
freddyaboulton Sep 20, 2024
060acb3
Fixes annoying height bug in playground (#9402)
aliabd Sep 20, 2024
8e52b6a
Chatbot Examples (#8966)
dawoodkhan82 Sep 20, 2024
4c8c6f2
Ssr part 2 (#9339)
pngwn Sep 23, 2024
7ab0af9
chore: update versions (beta) (#9263)
gradio-pr-bot Sep 23, 2024
bf27ff4
Center icon in button when no text is present (#9405)
abidlabs Sep 23, 2024
c2c2fd9
fix SSR apps on spaces (#9412)
pngwn Sep 23, 2024
d92c26f
Small fixes to `gr.Dataframe` and chatbot docs (#9376)
abidlabs Sep 23, 2024
82e7652
chore: update versions (beta) (#9416)
gradio-pr-bot Sep 23, 2024
74f3b9d
Allow skipping an arbitrary number of output components, and also rai…
abidlabs Sep 24, 2024
b672deb
fix css (#9427)
pngwn Sep 24, 2024
278645b
Fix Python unit tests on `5.0-dev` branch (#9432)
abidlabs Sep 25, 2024
a16787a
Lite: HTTPX client improvement (#9413)
whitphx Sep 25, 2024
e7a415b
Use or `pathlib.Path` objects to indicate filepaths for `css`, `js`, …
abidlabs Sep 26, 2024
afbd8e7
Reduce analytics that are collected (#9447)
abidlabs Sep 26, 2024
0c8fafb
Fix SSR mode flag with `mount_gradio_app` and revert changes to pytes…
abidlabs Sep 26, 2024
8f469e1
Small changes to caching (#9438)
abidlabs Sep 26, 2024
4e54105
Refactoring playground (#9426)
whitphx Sep 26, 2024
56dbf77
Chatbot bug fixes (#9453)
dawoodkhan82 Sep 27, 2024
4d75f02
Update object detection guide (#9456)
freddyaboulton Sep 27, 2024
018c140
Start/stop recoding from the backend. Add guide on conversational cha…
freddyaboulton Sep 27, 2024
b622b1f
Improve UI on the Playground (#9462)
aliabd Sep 28, 2024
f7c3396
Fix. Triggered dataframe change event for header change (#9469)
Joodith Sep 29, 2024
3d93464
chore: update versions (beta) (#9420)
gradio-pr-bot Sep 29, 2024
7fc5e26
format
abidlabs Sep 30, 2024
36d6636
Fix package.json `exports` of @gradio/preview (#9468)
Col0ring Sep 30, 2024
3ac5d9c
Fix plots (#9464)
pngwn Sep 30, 2024
30d13ac
Pre/post-processing download requests (#9383)
aliabid94 Sep 30, 2024
b406139
Add support for 3rd party providers to `gr.load`, and provide a bette…
abidlabs Sep 30, 2024
2304217
chore: update versions (beta) (#9476)
gradio-pr-bot Sep 30, 2024
2510a6e
Fix `slider-color` var (#9481)
hannahblair Sep 30, 2024
7352a89
Playground requirements tab (#9460)
whitphx Oct 1, 2024
d958bfa
Fix prettierignore (#9486)
whitphx Oct 1, 2024
c307a0c
Minor fixes to docs and a demo (#9493)
abidlabs Oct 1, 2024
7065e11
Check for `file_types` parameter in the backend (#9431)
dawoodkhan82 Oct 1, 2024
a17c7b6
Ensure media queries work for SSR mode (#9428)
pngwn Oct 1, 2024
488ef76
Fix custom component CLI unit tests (#9495)
freddyaboulton Oct 1, 2024
4e6a47f
Fixes: Chatbot examples for custom chatbot + rename `suggestions` -> …
dawoodkhan82 Oct 2, 2024
1647ebd
UI theme fixes (#9496)
aliabid94 Oct 2, 2024
d054262
Centre components within `Block` when height and width are set (#9504)
hannahblair Oct 2, 2024
991883e
Improve `gr.Code` (#9450)
hannahblair Oct 2, 2024
861f5e9
Fix node process to run with correct server name (#9506)
abidlabs Oct 2, 2024
3999afa
Merge branch 'main' into 5.0-dev
abidlabs Oct 2, 2024
c46fe20
yaml lint
abidlabs Oct 2, 2024
f8de5d2
Add Bokeh plot demo (#9423)
whitphx Oct 3, 2024
3ec8e63
Expanding AI Playground Prompt for Qwen (#9452)
aliabd Oct 3, 2024
5c93a2d
Merge branch 'main' into 5.0-dev
abidlabs Oct 3, 2024
ec64dc9
docs: update 01_quickstart.md (#9515)
eltociear Oct 3, 2024
0ab6ac5
Fix change triggers for dropdown and radio (#9519)
dawoodkhan82 Oct 3, 2024
a369712
Merge branch 'main' into 5.0-dev
abidlabs Oct 4, 2024
84f4906
chore: update versions (beta) (#9485)
gradio-pr-bot Oct 5, 2024
9bb0ab8
better layer handling
pngwn Oct 5, 2024
f60bb68
Fix single select dropdown (#9526)
whitphx Oct 5, 2024
d826faa
Hide x axis labels (#9497)
aliabid94 Oct 5, 2024
098a009
Add Jinja2 language to Code component (#9545)
CISC Oct 5, 2024
8bcbd3f
Merge branch 'main' into 5.0-dev
abidlabs Oct 5, 2024
b82aa6f
Disable sagemaker_check() for now (#9546)
vmatt Oct 5, 2024
05444b2
Merge branch 'main' into 5.0-dev
abidlabs Oct 5, 2024
b70c53b
Merge branch 'main' into 5.0-dev
abidlabs Oct 6, 2024
00c6bb1
chore: update versions (beta) (#9544)
gradio-pr-bot Oct 6, 2024
e0ee3d5
Update gr.ColorPicker UI (#9570)
hannahblair Oct 7, 2024
7c367b6
Fix cut off in gr.ImageEditor (#9525)
hannahblair Oct 7, 2024
b260389
Change caching to occur not at the creation of a `gr.Examples()` but …
aliabid94 Oct 7, 2024
cf39640
Add `css_paths` and `head_paths` parameters (#9524)
abidlabs Oct 7, 2024
b0fedd7
Fix most flaky Python tests in `5.0-dev` branch (#9550)
abidlabs Oct 7, 2024
3b71ed2
Api info fix (#9522)
freddyaboulton Oct 8, 2024
8dc7c12
Send Streaming data over Websocket if possible. Also support base64 o…
freddyaboulton Oct 8, 2024
06ef22e
Allow `info=` to render markdown (#9521)
dawoodkhan82 Oct 8, 2024
9f532e0
Equal height columns (#9577)
aliabid94 Oct 8, 2024
148345d
Fix chatinterface embedding height issues (#9571)
aliabid94 Oct 8, 2024
4617e60
chore: update versions (beta) (#9572)
gradio-pr-bot Oct 8, 2024
4ec2feb
Update gr.Dataframe UI with action popover (#9575)
hannahblair Oct 8, 2024
b92a762
Disable the submit button and enter-key submit when the text is empty…
whitphx Oct 8, 2024
6f8fa54
Chat Interface Multimodal Fix & Fallback to `gr.Examples()` (#9584)
dawoodkhan82 Oct 8, 2024
17e6c84
Fix `gr.Chatbot` panels layout (#9499)
hannahblair Oct 8, 2024
139152f
Equal height in row false by default (#9591)
aliabid94 Oct 8, 2024
430a26a
Fix reload mode (#9576)
freddyaboulton Oct 8, 2024
43a7f42
Chatbot autoscroll (#9582)
whitphx Oct 8, 2024
477f45c
Only move files to the cache that have a meta key (#9589)
freddyaboulton Oct 8, 2024
cc61fe7
Some more chatbot fixes (#9593)
dawoodkhan82 Oct 8, 2024
2a4bfc3
persist imed histopry
pngwn Oct 8, 2024
b059a9a
Merge branch '5.0-dev' into render-visible
pngwn Oct 8, 2024
a1cb4f1
stoof
pngwn Oct 9, 2024
5dd4c1c
stoof
pngwn Oct 9, 2024
31b203f
Merge branch 'main' into render-visible
pngwn Nov 4, 2024
233df2a
Merge branch 'main' into render-visible
pngwn Dec 9, 2024
fb48f04
fix
pngwn Dec 13, 2024
3f155de
rende ronly visible
pngwn Dec 13, 2024
279ee25
format pythong
pngwn Dec 13, 2024
f4fc499
format js
pngwn Dec 13, 2024
a97f172
remove
pngwn Dec 13, 2024
823e1b3
fix files
pngwn Dec 13, 2024
7480287
add changeset
gradio-pr-bot Dec 13, 2024
464d614
fix files
pngwn Dec 13, 2024
967eee1
add changeset
gradio-pr-bot Dec 13, 2024
a3cc96d
fix files
pngwn Dec 13, 2024
ac12319
add changeset
gradio-pr-bot Dec 13, 2024
0a944e5
more fix
pngwn Dec 14, 2024
40865b5
format
pngwn Dec 14, 2024
49102fa
notebooks
pngwn Dec 14, 2024
6338c63
Merge branch 'main' into render-visible
pngwn Dec 14, 2024
dbdcebe
add changeset
gradio-pr-bot Dec 14, 2024
d95ce12
add changeset
gradio-pr-bot Dec 14, 2024
46e2487
lockfile
pngwn Dec 14, 2024
1bc5f1f
fix files
pngwn Dec 16, 2024
004cc9a
fix files
pngwn Dec 16, 2024
affd135
add changeset
gradio-pr-bot Dec 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .changeset/fuzzy-webs-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@gradio/atoms": minor
"@gradio/core": minor
"@gradio/imageeditor": minor
"@gradio/markdown": minor
"@gradio/markdown-code": minor
"@gradio/tabitem": minor
"@gradio/tabs": minor
"gradio": minor
---

feat:Only render visible components
1 change: 1 addition & 0 deletions demo/render_visibility/run.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: render_visibility"]}, {"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", "\n", "def greet(name):\n", " return \"Hello \" + name + \"!\"\n", "\n", "\n", "with gr.Blocks() as demo:\n", " with gr.Tabs():\n", " with gr.TabItem(\"Tab 1\"):\n", " t = gr.Textbox(\"Some value\", label=\"Name\", visible=False)\n", " btn = gr.Button(\"Show\")\n", " btn.click(lambda: gr.Textbox(visible=True), inputs=None, outputs=t)\n", " with gr.TabItem(\"Tab 2\"):\n", " t2 = gr.Textbox(\"Some other value\", label=\"Name\", visible=False)\n", " btn2 = gr.Button(\"Show\")\n", " btn2.click(lambda: gr.Textbox(visible=True), inputs=None, outputs=t2)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
20 changes: 20 additions & 0 deletions demo/render_visibility/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import gradio as gr


def greet(name):
return "Hello " + name + "!"


with gr.Blocks() as demo:
with gr.Tabs():
with gr.TabItem("Tab 1"):
t = gr.Textbox("Some value", label="Name", visible=False)
btn = gr.Button("Show")
btn.click(lambda: gr.Textbox(visible=True), inputs=None, outputs=t)
with gr.TabItem("Tab 2"):
t2 = gr.Textbox("Some other value", label="Name", visible=False)
btn2 = gr.Button("Show")
btn2.click(lambda: gr.Textbox(visible=True), inputs=None, outputs=t2)

if __name__ == "__main__":
demo.launch()
Binary file added demo/render_visibility/screenshot.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion js/atoms/src/Block.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
data-testid={test_id}
id={elem_id}
class:hidden={visible === false}
class="block {elem_classes.join(' ')}"
class="block {elem_classes?.join(' ') || ''}"
class:padded={padding}
class:flex
class:border_focus={border_mode === "focus"}
Expand Down
1 change: 1 addition & 0 deletions js/core/src/Render.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
{...node.props}
{theme_mode}
{root}
visible={typeof node.props.visible === "boolean" ? node.props.visible : true}
>
{#if node.children && node.children.length}
{#each node.children as _node (_node.id)}
Expand Down
32 changes: 18 additions & 14 deletions js/core/src/RenderComponent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
export let elem_id: string;
export let elem_classes: string[];
export let _id: number;
export let visible: boolean;

const s = (id: number, p: string, v: any): CustomEvent =>
new CustomEvent("prop_change", { detail: { id, prop: p, value: v } });
Expand Down Expand Up @@ -51,17 +52,20 @@
const _component = wrap(component);
</script>

<svelte:component
this={_component}
bind:this={instance}
bind:value
on:prop_change
{elem_id}
{elem_classes}
{target}
{...$$restProps}
{theme_mode}
{root}
>
<slot />
</svelte:component>
{#if visible}
<svelte:component
this={_component}
bind:this={instance}
bind:value
on:prop_change
{elem_id}
{elem_classes}
{target}
{visible}
{...$$restProps}
{theme_mode}
{root}
>
<slot />
</svelte:component>
{/if}
20 changes: 14 additions & 6 deletions js/core/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,15 @@ export function create_components(initial_layout: ComponentMeta | undefined): {

if (instance.type === "tabs" && !instance.props.initial_tabs) {
const tab_items_props =
node.children?.map((c) => {
node.children?.map((c, i) => {
const instance = instance_map[c.id];
// console.log("tabs", JSON.stringify(instance.props, null, 2));
instance.props.id ??= c.id;
return {
type: instance.type,
props: {
...(instance.props as any),
id: instance.props.id
id: instance.props.id,
order: i
}
};
}) || [];
Expand All @@ -321,10 +321,18 @@ export function create_components(initial_layout: ComponentMeta | undefined): {
label: child.props.label,
id: child.props.id,
visible: child.props.visible,
interactive: child.props.interactive
interactive: child.props.interactive,
order: child.props.order
}));
}

if (instance.type === "tabs") {
node.children?.forEach((c, i) => {
const child = instance_map[c.id];
child.props.order = i;
});
}

return instance;
}

Expand Down Expand Up @@ -385,7 +393,7 @@ export function create_components(initial_layout: ComponentMeta | undefined): {
if (!comp) {
return null;
}
if (comp.instance.get_value) {
if (comp.instance?.get_value) {
return comp.instance.get_value() as Promise<any>;
}
return comp.props.value;
Expand Down Expand Up @@ -414,7 +422,7 @@ export function create_components(initial_layout: ComponentMeta | undefined): {
state: "open" | "closed" | "waiting"
): void {
const comp = _component_map.get(id);
if (comp && comp.instance.modify_stream_state) {
if (comp && comp.instance?.modify_stream_state) {
comp.instance.modify_stream_state(state);
}
}
Expand Down
3 changes: 3 additions & 0 deletions js/imageeditor/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
};
export let canvas_size: [number, number] | undefined;
export let show_fullscreen_button = true;
export let full_history: any = null;

export let gradio: Gradio<{
change: never;
Expand Down Expand Up @@ -185,6 +186,7 @@
/>

<InteractiveImageEditor
on:history={(e) => (full_history = e.detail)}
bind:dragging
{canvas_size}
on:change={() => handle_history_change()}
Expand Down Expand Up @@ -221,6 +223,7 @@
upload={(...args) => gradio.client.upload(...args)}
stream_handler={(...args) => gradio.client.stream(...args)}
{placeholder}
{full_history}
></InteractiveImageEditor>
</Block>
{/if}
18 changes: 17 additions & 1 deletion js/imageeditor/shared/ImageEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { Writable, Readable } from "svelte/store";
import type { Spring } from "svelte/motion";
import { type PixiApp } from "./utils/pixi";
import { type CommandManager } from "./utils/commands";
import { type CommandManager, type CommandNode } from "./utils/commands";

export const EDITOR_KEY = Symbol("editor");
export type context_type = "bg" | "layers" | "crop" | "draw" | "erase";
Expand Down Expand Up @@ -71,10 +71,12 @@
clear?: never;
save: void;
change: void;
history: CommandManager["current_history"];
}>();
export let crop_constraint = false;
export let canvas_size: [number, number] | undefined;
export let parent_height: number;
export let full_history: CommandNode | null = null;

$: orig_canvas_size = canvas_size;

Expand Down Expand Up @@ -114,7 +116,15 @@

const { can_redo, can_undo, current_history } = CommandManager;

function get_start_history(history: any): any {
if (history.previous) {
return get_start_history(history.previous);
}
return history;
}

$: $current_history.previous, dispatch("change");
$: dispatch("history", get_start_history($current_history));

$: {
history = !!$current_history.previous || $active_tool !== "bg";
Expand Down Expand Up @@ -316,6 +326,12 @@

resize(...$dimensions);

tick().then(() => {
if (full_history) {
CommandManager.hydrate(full_history);
}
});

return () => {
$pixi?.destroy();
resizer.disconnect();
Expand Down
5 changes: 4 additions & 1 deletion js/imageeditor/shared/InteractiveImageEditor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { createEventDispatcher } from "svelte";
import { type I18nFormatter } from "@gradio/utils";
import { prepare_files, type FileData, type Client } from "@gradio/client";

import { type CommandNode } from "./utils/commands";
import ImageEditor from "./ImageEditor.svelte";
import Layers from "./layers/Layers.svelte";
import { type Brush as IBrush } from "./tools/Brush.svelte";
Expand Down Expand Up @@ -57,6 +57,7 @@
export let dragging: boolean;
export let placeholder: string | undefined = undefined;
export let height = 450;
export let full_history: CommandNode | null = null;

const dispatch = createEventDispatcher<{
clear?: never;
Expand Down Expand Up @@ -215,6 +216,7 @@
label={label || i18n("image.image")}
/>
<ImageEditor
on:history
{canvas_size}
crop_size={Array.isArray(crop_size) ? crop_size : undefined}
bind:this={editor}
Expand All @@ -228,6 +230,7 @@
bind:bg
{sources}
crop_constraint={!!crop_constraint}
{full_history}
>
<Tools {i18n}>
<Layers layer_files={value?.layers || null} enable_layers={layers} />
Expand Down
46 changes: 30 additions & 16 deletions js/imageeditor/shared/layers/Layers.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,22 @@
export let layer_files: (FileData | null)[] | null = [];
export let enable_layers = true;

const { pixi, current_layer, dimensions, register_context } =
getContext<EditorContext>(EDITOR_KEY);
const {
pixi,
current_layer,
dimensions,
register_context,
command_manager,
current_history
} = getContext<EditorContext>(EDITOR_KEY);

const { can_undo } = command_manager;

const LayerManager = layer_manager();
let layers: LayerScene[] = [];
const manager_current_layer = LayerManager.active_layer;
const layers = LayerManager.layers;

$: current_layer.set($manager_current_layer);

register_context("layers", {
init_fn: () => {
Expand All @@ -28,7 +39,7 @@
});

async function validate_layers(): Promise<void> {
let invalid = layers.some(
let invalid = $layers.some(
(layer) =>
layer.composite.texture?.width != $dimensions[0] ||
layer.composite.texture?.height != $dimensions[1]
Expand All @@ -44,14 +55,17 @@
async function new_layer(): Promise<void> {
if (!$pixi) return;

const [active_layer, all_layers] = LayerManager.add_layer(
const new_layer = LayerManager.add_layer(
$pixi.layer_container,
$pixi.renderer,
...$dimensions
);

$current_layer = active_layer;
layers = all_layers;
if ($can_undo || $layers.length > 0) {
command_manager.execute(new_layer);
} else {
new_layer.execute();
}
}

$: render_layer_files(layer_files);
Expand Down Expand Up @@ -88,20 +102,20 @@

LayerManager.reset();

let last_layer: [LayerScene, LayerScene[]] | null = null;
for (const blob of blobs.filter(is_not_null)) {
last_layer = await LayerManager.add_layer_from_blob(
const new_layer = await LayerManager.add_layer_from_blob(
$pixi.layer_container,
$pixi.renderer,
blob,
$pixi.view
);
}

if (!last_layer) return;

$current_layer = last_layer[0];
layers = last_layer[1];
if ($can_undo && $layers.length === 0) {
command_manager.execute(new_layer);
} else {
new_layer.execute();
}
}
}

onMount(async () => {
Expand All @@ -121,13 +135,13 @@
<button
aria-label="Show Layers"
on:click={() => (show_layers = !show_layers)}
><span class="icon"><Layers /></span> Layer {layers.findIndex(
><span class="icon"><Layers /></span> Layer {$layers.findIndex(
(l) => l === $current_layer
) + 1}
</button>
{#if show_layers}
<ul>
{#each layers as layer, i (i)}
{#each $layers as layer, i (i)}
<li>
<button
class:selected_layer={$current_layer === layer}
Expand Down
Loading
Loading