Spaces:
Running
Running
Upload folder using huggingface_hub
Browse files- README.md +3 -3
- app.py +2 -1
- requirements.txt +1 -1
- space.py +19 -15
- src/README.md +21 -15
- src/backend/gradio_modal/templates/component/index.js +98 -94
- src/demo/app.py +2 -1
- src/demo/space.py +19 -15
- src/pyproject.toml +2 -2
README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
|
2 |
---
|
3 |
tags: [gradio-custom-component,gradio-template-Column,Modal, Popup]
|
4 |
-
title: gradio_modal V0.0.
|
5 |
-
colorFrom:
|
6 |
-
colorTo:
|
7 |
sdk: docker
|
8 |
pinned: false
|
9 |
license: apache-2.0
|
|
|
1 |
|
2 |
---
|
3 |
tags: [gradio-custom-component,gradio-template-Column,Modal, Popup]
|
4 |
+
title: gradio_modal V0.0.2
|
5 |
+
colorFrom: gray
|
6 |
+
colorTo: indigo
|
7 |
sdk: docker
|
8 |
pinned: false
|
9 |
license: apache-2.0
|
app.py
CHANGED
@@ -17,4 +17,5 @@ with gr.Blocks() as demo:
|
|
17 |
gr.Markdown("Hello world!")
|
18 |
show_btn.click(lambda: Modal(visible=True), None, modal)
|
19 |
|
20 |
-
|
|
|
|
17 |
gr.Markdown("Hello world!")
|
18 |
show_btn.click(lambda: Modal(visible=True), None, modal)
|
19 |
|
20 |
+
if __name__ == "__main__":
|
21 |
+
demo.launch()
|
requirements.txt
CHANGED
@@ -1 +1 @@
|
|
1 |
-
gradio_modal==0.0.
|
|
|
1 |
+
gradio_modal==0.0.2
|
space.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
from app import demo as app
|
4 |
import os
|
5 |
|
6 |
-
_docs = {'Modal': {'description': 'Modal is a layout element within Blocks that will show its content in a popup above other content.\n from gradio_modal import Modal\n with gr.Blocks() as demo:\n with Modal():\n text1 = gr.Textbox()\n text2 = gr.Textbox()\n btn = gr.Button("Button")', 'members': {'__init__': {'visible': {'type': 'bool', 'default': 'False', 'description': 'If False,
|
7 |
|
8 |
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
9 |
|
@@ -21,7 +21,7 @@ with gr.Blocks(
|
|
21 |
# `gradio_modal`
|
22 |
|
23 |
<div style="display: flex; gap: 7px;">
|
24 |
-
<img alt="
|
25 |
</div>
|
26 |
|
27 |
A popup modal component
|
@@ -38,25 +38,25 @@ pip install gradio_modal
|
|
38 |
## Usage
|
39 |
|
40 |
```python
|
41 |
-
|
42 |
import gradio as gr
|
43 |
from gradio_modal import Modal
|
44 |
|
45 |
-
|
46 |
with gr.Blocks() as demo:
|
47 |
-
gr.
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
gr.
|
52 |
-
gr.
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
57 |
show_btn.click(lambda: Modal(visible=True), None, modal)
|
58 |
|
59 |
-
|
60 |
if __name__ == "__main__":
|
61 |
demo.launch()
|
62 |
|
@@ -73,6 +73,10 @@ if __name__ == "__main__":
|
|
73 |
gr.ParamViewer(value=_docs["Modal"]["members"]["__init__"], linkify=[])
|
74 |
|
75 |
|
|
|
|
|
|
|
|
|
76 |
|
77 |
|
78 |
|
|
|
3 |
from app import demo as app
|
4 |
import os
|
5 |
|
6 |
+
_docs = {'Modal': {'description': 'Modal is a layout element within Blocks that will show its content in a popup above other content.\n from gradio_modal import Modal\n with gr.Blocks() as demo:\n with Modal():\n text1 = gr.Textbox()\n text2 = gr.Textbox()\n btn = gr.Button("Button")', 'members': {'__init__': {'visible': {'type': 'bool', 'default': 'False', 'description': 'If False, modal will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': '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': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional string or list of strings that are assigned as the class of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'allow_user_close': {'type': 'bool', 'default': 'True', 'description': 'If True, user can close the modal (by clicking outside, clicking the X, or the escape key).'}, 'render': {'type': 'bool', 'default': 'True', 'description': '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.'}}, 'postprocess': {}}, 'events': {'blur': {'type': None, 'default': None, 'description': 'This listener is triggered when the Modal is unfocused/blurred.'}}}, '__meta__': {'additional_interfaces': {}}}
|
7 |
|
8 |
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
9 |
|
|
|
21 |
# `gradio_modal`
|
22 |
|
23 |
<div style="display: flex; gap: 7px;">
|
24 |
+
<a href="https://pypi.org/project/gradio_modal/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_modal"></a>
|
25 |
</div>
|
26 |
|
27 |
A popup modal component
|
|
|
38 |
## Usage
|
39 |
|
40 |
```python
|
|
|
41 |
import gradio as gr
|
42 |
from gradio_modal import Modal
|
43 |
|
|
|
44 |
with gr.Blocks() as demo:
|
45 |
+
with gr.Tab("Tab 1"):
|
46 |
+
text_1 = gr.Textbox(label="Input 1")
|
47 |
+
text_2 = gr.Textbox(label="Input 2")
|
48 |
+
text_1.submit(lambda x:x, text_1, text_2)
|
49 |
+
show_btn = gr.Button("Show Modal")
|
50 |
+
gr.Examples(
|
51 |
+
[["Text 1", "Text 2"], ["Text 3", "Text 4"]],
|
52 |
+
inputs=[text_1, text_2],
|
53 |
+
)
|
54 |
+
with gr.Tab("Tab 2"):
|
55 |
+
gr.Markdown("This is tab 2")
|
56 |
+
with Modal(visible=False) as modal:
|
57 |
+
gr.Markdown("Hello world!")
|
58 |
show_btn.click(lambda: Modal(visible=True), None, modal)
|
59 |
|
|
|
60 |
if __name__ == "__main__":
|
61 |
demo.launch()
|
62 |
|
|
|
73 |
gr.ParamViewer(value=_docs["Modal"]["members"]["__init__"], linkify=[])
|
74 |
|
75 |
|
76 |
+
gr.Markdown("### Events")
|
77 |
+
gr.ParamViewer(value=_docs["Modal"]["events"], linkify=['Event'])
|
78 |
+
|
79 |
+
|
80 |
|
81 |
|
82 |
|
src/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
|
2 |
# `gradio_modal`
|
3 |
-
<img alt="
|
4 |
|
5 |
A popup modal component
|
6 |
|
@@ -13,25 +13,25 @@ pip install gradio_modal
|
|
13 |
## Usage
|
14 |
|
15 |
```python
|
16 |
-
|
17 |
import gradio as gr
|
18 |
from gradio_modal import Modal
|
19 |
|
20 |
-
|
21 |
with gr.Blocks() as demo:
|
22 |
-
gr.
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
gr.
|
27 |
-
gr.
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
32 |
show_btn.click(lambda: Modal(visible=True), None, modal)
|
33 |
|
34 |
-
|
35 |
if __name__ == "__main__":
|
36 |
demo.launch()
|
37 |
|
@@ -61,7 +61,7 @@ bool
|
|
61 |
|
62 |
</td>
|
63 |
<td align="left"><code>False</code></td>
|
64 |
-
<td align="left">If False,
|
65 |
</tr>
|
66 |
|
67 |
<tr>
|
@@ -118,5 +118,11 @@ bool
|
|
118 |
</tbody></table>
|
119 |
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
|
|
|
1 |
|
2 |
# `gradio_modal`
|
3 |
+
<a href="https://pypi.org/project/gradio_modal/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_modal"></a>
|
4 |
|
5 |
A popup modal component
|
6 |
|
|
|
13 |
## Usage
|
14 |
|
15 |
```python
|
|
|
16 |
import gradio as gr
|
17 |
from gradio_modal import Modal
|
18 |
|
|
|
19 |
with gr.Blocks() as demo:
|
20 |
+
with gr.Tab("Tab 1"):
|
21 |
+
text_1 = gr.Textbox(label="Input 1")
|
22 |
+
text_2 = gr.Textbox(label="Input 2")
|
23 |
+
text_1.submit(lambda x:x, text_1, text_2)
|
24 |
+
show_btn = gr.Button("Show Modal")
|
25 |
+
gr.Examples(
|
26 |
+
[["Text 1", "Text 2"], ["Text 3", "Text 4"]],
|
27 |
+
inputs=[text_1, text_2],
|
28 |
+
)
|
29 |
+
with gr.Tab("Tab 2"):
|
30 |
+
gr.Markdown("This is tab 2")
|
31 |
+
with Modal(visible=False) as modal:
|
32 |
+
gr.Markdown("Hello world!")
|
33 |
show_btn.click(lambda: Modal(visible=True), None, modal)
|
34 |
|
|
|
35 |
if __name__ == "__main__":
|
36 |
demo.launch()
|
37 |
|
|
|
61 |
|
62 |
</td>
|
63 |
<td align="left"><code>False</code></td>
|
64 |
+
<td align="left">If False, modal will be hidden.</td>
|
65 |
</tr>
|
66 |
|
67 |
<tr>
|
|
|
118 |
</tbody></table>
|
119 |
|
120 |
|
121 |
+
### Events
|
122 |
+
|
123 |
+
| name | description |
|
124 |
+
|:-----|:------------|
|
125 |
+
| `blur` | This listener is triggered when the Modal is unfocused/blurred. |
|
126 |
+
|
127 |
|
128 |
|
src/backend/gradio_modal/templates/component/index.js
CHANGED
@@ -11,8 +11,8 @@ const {
|
|
11 |
insert: ee,
|
12 |
safe_not_equal: le,
|
13 |
set_dynamic_element_data: z,
|
14 |
-
set_style:
|
15 |
-
toggle_class:
|
16 |
transition_in: U,
|
17 |
transition_out: F,
|
18 |
update_slot_base: te
|
@@ -53,24 +53,24 @@ function fe(f) {
|
|
53 |
), i && i.c(), z(
|
54 |
/*tag*/
|
55 |
f[14]
|
56 |
-
)(e, s),
|
57 |
e,
|
58 |
"hidden",
|
59 |
/*visible*/
|
60 |
f[10] === !1
|
61 |
-
),
|
62 |
e,
|
63 |
"padded",
|
64 |
/*padding*/
|
65 |
f[6]
|
66 |
-
),
|
67 |
e,
|
68 |
"border_focus",
|
69 |
/*border_mode*/
|
70 |
f[5] === "focus"
|
71 |
-
),
|
72 |
f[8] && !/*container*/
|
73 |
-
f[9]),
|
74 |
e,
|
75 |
"height",
|
76 |
/*get_dimension*/
|
@@ -78,7 +78,7 @@ function fe(f) {
|
|
78 |
/*height*/
|
79 |
f[0]
|
80 |
)
|
81 |
-
),
|
82 |
f[1] == "number" ? `calc(min(${/*width*/
|
83 |
f[1]}px, 100%))` : (
|
84 |
/*get_dimension*/
|
@@ -86,23 +86,23 @@ function fe(f) {
|
|
86 |
/*width*/
|
87 |
f[1]
|
88 |
)
|
89 |
-
)),
|
90 |
e,
|
91 |
"border-style",
|
92 |
/*variant*/
|
93 |
f[4]
|
94 |
-
),
|
95 |
e,
|
96 |
"overflow",
|
97 |
/*allow_overflow*/
|
98 |
f[11] ? "visible" : "hidden"
|
99 |
-
),
|
100 |
e,
|
101 |
"flex-grow",
|
102 |
/*scale*/
|
103 |
f[12]
|
104 |
-
),
|
105 |
-
f[13]}px, 100%))`),
|
106 |
},
|
107 |
m(t, o) {
|
108 |
ee(t, e, o), i && i.m(e, null), a = !0;
|
@@ -143,25 +143,25 @@ function fe(f) {
|
|
143 |
(!a || o & /*elem_classes*/
|
144 |
8 && l !== (l = "block " + /*elem_classes*/
|
145 |
t[3].join(" ") + " svelte-1t38q2d")) && { class: l }
|
146 |
-
])),
|
147 |
e,
|
148 |
"hidden",
|
149 |
/*visible*/
|
150 |
t[10] === !1
|
151 |
-
),
|
152 |
e,
|
153 |
"padded",
|
154 |
/*padding*/
|
155 |
t[6]
|
156 |
-
),
|
157 |
e,
|
158 |
"border_focus",
|
159 |
/*border_mode*/
|
160 |
t[5] === "focus"
|
161 |
-
),
|
162 |
t[8] && !/*container*/
|
163 |
t[9]), o & /*height*/
|
164 |
-
1 &&
|
165 |
e,
|
166 |
"height",
|
167 |
/*get_dimension*/
|
@@ -170,7 +170,7 @@ function fe(f) {
|
|
170 |
t[0]
|
171 |
)
|
172 |
), o & /*width*/
|
173 |
-
2 &&
|
174 |
t[1] == "number" ? `calc(min(${/*width*/
|
175 |
t[1]}px, 100%))` : (
|
176 |
/*get_dimension*/
|
@@ -179,25 +179,25 @@ function fe(f) {
|
|
179 |
t[1]
|
180 |
)
|
181 |
)), o & /*variant*/
|
182 |
-
16 &&
|
183 |
e,
|
184 |
"border-style",
|
185 |
/*variant*/
|
186 |
t[4]
|
187 |
), o & /*allow_overflow*/
|
188 |
-
2048 &&
|
189 |
e,
|
190 |
"overflow",
|
191 |
/*allow_overflow*/
|
192 |
t[11] ? "visible" : "hidden"
|
193 |
), o & /*scale*/
|
194 |
-
4096 &&
|
195 |
e,
|
196 |
"flex-grow",
|
197 |
/*scale*/
|
198 |
t[12]
|
199 |
), o & /*min_width*/
|
200 |
-
8192 &&
|
201 |
t[13]}px, 100%))`);
|
202 |
},
|
203 |
i(t) {
|
@@ -239,7 +239,7 @@ function ne(f) {
|
|
239 |
};
|
240 |
}
|
241 |
function ae(f, e, l) {
|
242 |
-
let { $$slots: a = {}, $$scope: n } = e, { height: i = void 0 } = e, { width: d = void 0 } = e, { elem_id: s = "" } = e, { elem_classes: t = [] } = e, { variant: o = "solid" } = e, { border_mode:
|
243 |
const Q = (_) => {
|
244 |
if (_ !== void 0) {
|
245 |
if (typeof _ == "number")
|
@@ -249,17 +249,17 @@ function ae(f, e, l) {
|
|
249 |
}
|
250 |
};
|
251 |
return f.$$set = (_) => {
|
252 |
-
"height" in _ && l(0, i = _.height), "width" in _ && l(1, d = _.width), "elem_id" in _ && l(2, s = _.elem_id), "elem_classes" in _ && l(3, t = _.elem_classes), "variant" in _ && l(4, o = _.variant), "border_mode" in _ && l(5,
|
253 |
}, [
|
254 |
i,
|
255 |
d,
|
256 |
s,
|
257 |
t,
|
258 |
o,
|
259 |
-
|
260 |
-
|
|
|
261 |
r,
|
262 |
-
S,
|
263 |
B,
|
264 |
L,
|
265 |
T,
|
@@ -609,7 +609,7 @@ se.reduce(
|
|
609 |
);
|
610 |
const {
|
611 |
SvelteComponent: _e,
|
612 |
-
attr:
|
613 |
create_slot: de,
|
614 |
detach: oe,
|
615 |
element: ce,
|
@@ -619,8 +619,8 @@ const {
|
|
619 |
insert: be,
|
620 |
null_to_empty: D,
|
621 |
safe_not_equal: ge,
|
622 |
-
set_style:
|
623 |
-
toggle_class:
|
624 |
transition_in: he,
|
625 |
transition_out: ve,
|
626 |
update_slot_base: we
|
@@ -640,36 +640,36 @@ function ye(f) {
|
|
640 |
);
|
641 |
return {
|
642 |
c() {
|
643 |
-
e = ce("div"), d && d.c(),
|
644 |
e,
|
645 |
"id",
|
646 |
/*elem_id*/
|
647 |
f[3]
|
648 |
-
),
|
649 |
/*elem_classes*/
|
650 |
f[4].join(" ")
|
651 |
-
) + " svelte-1m1obck"),
|
652 |
e,
|
653 |
"gap",
|
654 |
/*gap*/
|
655 |
f[1]
|
656 |
-
),
|
657 |
e,
|
658 |
"compact",
|
659 |
/*variant*/
|
660 |
f[6] === "compact"
|
661 |
-
),
|
662 |
e,
|
663 |
"panel",
|
664 |
/*variant*/
|
665 |
f[6] === "panel"
|
666 |
-
),
|
667 |
-
f[5]),
|
668 |
e,
|
669 |
"flex-grow",
|
670 |
/*scale*/
|
671 |
f[0]
|
672 |
-
),
|
673 |
},
|
674 |
m(s, t) {
|
675 |
be(s, e, t), d && d.m(e, null), n = !0;
|
@@ -694,7 +694,7 @@ function ye(f) {
|
|
694 |
),
|
695 |
null
|
696 |
), (!n || t & /*elem_id*/
|
697 |
-
8) &&
|
698 |
e,
|
699 |
"id",
|
700 |
/*elem_id*/
|
@@ -703,35 +703,35 @@ function ye(f) {
|
|
703 |
16 && l !== (l = D(
|
704 |
/*elem_classes*/
|
705 |
s[4].join(" ")
|
706 |
-
) + " svelte-1m1obck")) &&
|
707 |
-
18) &&
|
708 |
e,
|
709 |
"gap",
|
710 |
/*gap*/
|
711 |
s[1]
|
712 |
), (!n || t & /*elem_classes, variant*/
|
713 |
-
80) &&
|
714 |
e,
|
715 |
"compact",
|
716 |
/*variant*/
|
717 |
s[6] === "compact"
|
718 |
), (!n || t & /*elem_classes, variant*/
|
719 |
-
80) &&
|
720 |
e,
|
721 |
"panel",
|
722 |
/*variant*/
|
723 |
s[6] === "panel"
|
724 |
), (!n || t & /*elem_classes, visible*/
|
725 |
-
48) &&
|
726 |
s[5]), t & /*scale*/
|
727 |
-
1 &&
|
728 |
e,
|
729 |
"flex-grow",
|
730 |
/*scale*/
|
731 |
s[0]
|
732 |
), t & /*min_width*/
|
733 |
4 && a !== (a = `calc(min(${/*min_width*/
|
734 |
-
s[2]}px, 100%))`) &&
|
735 |
},
|
736 |
i(s) {
|
737 |
n || (he(d, s), n = !0);
|
@@ -745,10 +745,10 @@ function ye(f) {
|
|
745 |
};
|
746 |
}
|
747 |
function ke(f, e, l) {
|
748 |
-
let { $$slots: a = {}, $$scope: n } = e, { scale: i = null } = e, { gap: d = !0 } = e, { min_width: s = 0 } = e, { elem_id: t = "" } = e, { elem_classes: o = [] } = e, { visible:
|
749 |
return f.$$set = (c) => {
|
750 |
-
"scale" in c && l(0, i = c.scale), "gap" in c && l(1, d = c.gap), "min_width" in c && l(2, s = c.min_width), "elem_id" in c && l(3, t = c.elem_id), "elem_classes" in c && l(4, o = c.elem_classes), "visible" in c && l(5,
|
751 |
-
}, [i, d, s, t, o,
|
752 |
}
|
753 |
let je = class extends _e {
|
754 |
constructor(e) {
|
@@ -771,39 +771,39 @@ const {
|
|
771 |
create_component: G,
|
772 |
create_slot: Se,
|
773 |
destroy_component: J,
|
774 |
-
detach:
|
775 |
-
element:
|
776 |
get_all_dirty_from_scope: Be,
|
777 |
get_slot_changes: Le,
|
778 |
init: Te,
|
779 |
-
insert:
|
780 |
listen: K,
|
781 |
mount_component: O,
|
782 |
noop: Ee,
|
783 |
safe_not_equal: Me,
|
784 |
space: ze,
|
785 |
toggle_class: H,
|
786 |
-
transition_in:
|
787 |
-
transition_out:
|
788 |
update_slot_base: Ae
|
789 |
} = window.__gradio__svelte__internal;
|
790 |
function N(f) {
|
791 |
let e, l, a;
|
792 |
return {
|
793 |
c() {
|
794 |
-
e =
|
795 |
},
|
796 |
m(n, i) {
|
797 |
-
|
798 |
e,
|
799 |
"click",
|
800 |
-
/*
|
801 |
-
f[
|
802 |
), l = !0);
|
803 |
},
|
804 |
p: Ee,
|
805 |
d(n) {
|
806 |
-
n &&
|
807 |
}
|
808 |
};
|
809 |
}
|
@@ -811,12 +811,12 @@ function De(f) {
|
|
811 |
let e;
|
812 |
const l = (
|
813 |
/*#slots*/
|
814 |
-
f[
|
815 |
), a = Se(
|
816 |
l,
|
817 |
f,
|
818 |
/*$$scope*/
|
819 |
-
f[
|
820 |
null
|
821 |
);
|
822 |
return {
|
@@ -828,30 +828,30 @@ function De(f) {
|
|
828 |
},
|
829 |
p(n, i) {
|
830 |
a && a.p && (!e || i & /*$$scope*/
|
831 |
-
|
832 |
a,
|
833 |
l,
|
834 |
n,
|
835 |
/*$$scope*/
|
836 |
-
n[
|
837 |
e ? Le(
|
838 |
l,
|
839 |
/*$$scope*/
|
840 |
-
n[
|
841 |
i,
|
842 |
null
|
843 |
) : Be(
|
844 |
/*$$scope*/
|
845 |
-
n[
|
846 |
),
|
847 |
null
|
848 |
);
|
849 |
},
|
850 |
i(n) {
|
851 |
-
e || (
|
852 |
},
|
853 |
o(n) {
|
854 |
-
|
855 |
},
|
856 |
d(n) {
|
857 |
a && a.d(n);
|
@@ -873,23 +873,23 @@ function He(f) {
|
|
873 |
n && n.c(), e = ze(), G(l.$$.fragment);
|
874 |
},
|
875 |
m(i, d) {
|
876 |
-
n && n.m(i, d),
|
877 |
},
|
878 |
p(i, d) {
|
879 |
/*allow_user_close*/
|
880 |
i[3] ? n ? n.p(i, d) : (n = N(i), n.c(), n.m(e.parentNode, e)) : n && (n.d(1), n = null);
|
881 |
const s = {};
|
882 |
d & /*$$scope*/
|
883 |
-
|
884 |
},
|
885 |
i(i) {
|
886 |
-
a || (
|
887 |
},
|
888 |
o(i) {
|
889 |
-
|
890 |
},
|
891 |
d(i) {
|
892 |
-
i &&
|
893 |
}
|
894 |
};
|
895 |
}
|
@@ -903,7 +903,7 @@ function Ne(f) {
|
|
903 |
}
|
904 |
}), {
|
905 |
c() {
|
906 |
-
e =
|
907 |
f[2].join(" ") + " svelte-ra5mg6"), v(
|
908 |
e,
|
909 |
"id",
|
@@ -913,17 +913,17 @@ function Ne(f) {
|
|
913 |
f[0]);
|
914 |
},
|
915 |
m(t, o) {
|
916 |
-
|
917 |
e,
|
918 |
"click",
|
919 |
-
/*
|
920 |
-
f[
|
921 |
), d = !0);
|
922 |
},
|
923 |
p(t, [o]) {
|
924 |
-
const
|
925 |
-
o & /*$$scope,
|
926 |
-
|
927 |
4 && n !== (n = "modal " + /*elem_classes*/
|
928 |
t[2].join(" ") + " svelte-ra5mg6")) && v(e, "class", n), (!i || o & /*elem_id*/
|
929 |
2) && v(
|
@@ -936,42 +936,45 @@ function Ne(f) {
|
|
936 |
t[0]);
|
937 |
},
|
938 |
i(t) {
|
939 |
-
i || (
|
940 |
},
|
941 |
o(t) {
|
942 |
-
|
943 |
},
|
944 |
d(t) {
|
945 |
-
t &&
|
946 |
}
|
947 |
};
|
948 |
}
|
949 |
function Ue(f, e, l) {
|
950 |
-
let { $$slots: a = {}, $$scope: n } = e, { elem_id: i = "" } = e, { elem_classes: d = [] } = e, { visible: s = !1 } = e, { allow_user_close: t = !0 } = e, o = null;
|
|
|
|
|
|
|
951 |
document.addEventListener("keydown", (r) => {
|
952 |
-
t && r.key === "Escape" &&
|
953 |
});
|
954 |
-
|
955 |
-
function h(r) {
|
956 |
Ie[r ? "unshift" : "push"](() => {
|
957 |
-
|
958 |
});
|
959 |
}
|
960 |
-
const
|
961 |
-
t && r.target ===
|
962 |
};
|
963 |
return f.$$set = (r) => {
|
964 |
-
"elem_id" in r && l(1, i = r.elem_id), "elem_classes" in r && l(2, d = r.elem_classes), "visible" in r && l(0, s = r.visible), "allow_user_close" in r && l(3, t = r.allow_user_close), "$$scope" in r && l(
|
965 |
}, [
|
966 |
s,
|
967 |
i,
|
968 |
d,
|
969 |
t,
|
|
|
|
|
970 |
o,
|
971 |
a,
|
972 |
-
m,
|
973 |
-
h,
|
974 |
c,
|
|
|
975 |
n
|
976 |
];
|
977 |
}
|
@@ -981,7 +984,8 @@ class Ge extends Ce {
|
|
981 |
elem_id: 1,
|
982 |
elem_classes: 2,
|
983 |
visible: 0,
|
984 |
-
allow_user_close: 3
|
|
|
985 |
});
|
986 |
}
|
987 |
}
|
|
|
11 |
insert: ee,
|
12 |
safe_not_equal: le,
|
13 |
set_dynamic_element_data: z,
|
14 |
+
set_style: m,
|
15 |
+
toggle_class: g,
|
16 |
transition_in: U,
|
17 |
transition_out: F,
|
18 |
update_slot_base: te
|
|
|
53 |
), i && i.c(), z(
|
54 |
/*tag*/
|
55 |
f[14]
|
56 |
+
)(e, s), g(
|
57 |
e,
|
58 |
"hidden",
|
59 |
/*visible*/
|
60 |
f[10] === !1
|
61 |
+
), g(
|
62 |
e,
|
63 |
"padded",
|
64 |
/*padding*/
|
65 |
f[6]
|
66 |
+
), g(
|
67 |
e,
|
68 |
"border_focus",
|
69 |
/*border_mode*/
|
70 |
f[5] === "focus"
|
71 |
+
), g(e, "hide-container", !/*explicit_call*/
|
72 |
f[8] && !/*container*/
|
73 |
+
f[9]), m(
|
74 |
e,
|
75 |
"height",
|
76 |
/*get_dimension*/
|
|
|
78 |
/*height*/
|
79 |
f[0]
|
80 |
)
|
81 |
+
), m(e, "width", typeof /*width*/
|
82 |
f[1] == "number" ? `calc(min(${/*width*/
|
83 |
f[1]}px, 100%))` : (
|
84 |
/*get_dimension*/
|
|
|
86 |
/*width*/
|
87 |
f[1]
|
88 |
)
|
89 |
+
)), m(
|
90 |
e,
|
91 |
"border-style",
|
92 |
/*variant*/
|
93 |
f[4]
|
94 |
+
), m(
|
95 |
e,
|
96 |
"overflow",
|
97 |
/*allow_overflow*/
|
98 |
f[11] ? "visible" : "hidden"
|
99 |
+
), m(
|
100 |
e,
|
101 |
"flex-grow",
|
102 |
/*scale*/
|
103 |
f[12]
|
104 |
+
), m(e, "min-width", `calc(min(${/*min_width*/
|
105 |
+
f[13]}px, 100%))`), m(e, "border-width", "var(--block-border-width)");
|
106 |
},
|
107 |
m(t, o) {
|
108 |
ee(t, e, o), i && i.m(e, null), a = !0;
|
|
|
143 |
(!a || o & /*elem_classes*/
|
144 |
8 && l !== (l = "block " + /*elem_classes*/
|
145 |
t[3].join(" ") + " svelte-1t38q2d")) && { class: l }
|
146 |
+
])), g(
|
147 |
e,
|
148 |
"hidden",
|
149 |
/*visible*/
|
150 |
t[10] === !1
|
151 |
+
), g(
|
152 |
e,
|
153 |
"padded",
|
154 |
/*padding*/
|
155 |
t[6]
|
156 |
+
), g(
|
157 |
e,
|
158 |
"border_focus",
|
159 |
/*border_mode*/
|
160 |
t[5] === "focus"
|
161 |
+
), g(e, "hide-container", !/*explicit_call*/
|
162 |
t[8] && !/*container*/
|
163 |
t[9]), o & /*height*/
|
164 |
+
1 && m(
|
165 |
e,
|
166 |
"height",
|
167 |
/*get_dimension*/
|
|
|
170 |
t[0]
|
171 |
)
|
172 |
), o & /*width*/
|
173 |
+
2 && m(e, "width", typeof /*width*/
|
174 |
t[1] == "number" ? `calc(min(${/*width*/
|
175 |
t[1]}px, 100%))` : (
|
176 |
/*get_dimension*/
|
|
|
179 |
t[1]
|
180 |
)
|
181 |
)), o & /*variant*/
|
182 |
+
16 && m(
|
183 |
e,
|
184 |
"border-style",
|
185 |
/*variant*/
|
186 |
t[4]
|
187 |
), o & /*allow_overflow*/
|
188 |
+
2048 && m(
|
189 |
e,
|
190 |
"overflow",
|
191 |
/*allow_overflow*/
|
192 |
t[11] ? "visible" : "hidden"
|
193 |
), o & /*scale*/
|
194 |
+
4096 && m(
|
195 |
e,
|
196 |
"flex-grow",
|
197 |
/*scale*/
|
198 |
t[12]
|
199 |
), o & /*min_width*/
|
200 |
+
8192 && m(e, "min-width", `calc(min(${/*min_width*/
|
201 |
t[13]}px, 100%))`);
|
202 |
},
|
203 |
i(t) {
|
|
|
239 |
};
|
240 |
}
|
241 |
function ae(f, e, l) {
|
242 |
+
let { $$slots: a = {}, $$scope: n } = e, { height: i = void 0 } = e, { width: d = void 0 } = e, { elem_id: s = "" } = e, { elem_classes: t = [] } = e, { variant: o = "solid" } = e, { border_mode: u = "base" } = e, { padding: b = !0 } = e, { type: c = "normal" } = e, { test_id: w = void 0 } = e, { explicit_call: r = !1 } = e, { container: B = !0 } = e, { visible: L = !0 } = e, { allow_overflow: T = !0 } = e, { scale: E = null } = e, { min_width: M = 0 } = e, P = c === "fieldset" ? "fieldset" : "div";
|
243 |
const Q = (_) => {
|
244 |
if (_ !== void 0) {
|
245 |
if (typeof _ == "number")
|
|
|
249 |
}
|
250 |
};
|
251 |
return f.$$set = (_) => {
|
252 |
+
"height" in _ && l(0, i = _.height), "width" in _ && l(1, d = _.width), "elem_id" in _ && l(2, s = _.elem_id), "elem_classes" in _ && l(3, t = _.elem_classes), "variant" in _ && l(4, o = _.variant), "border_mode" in _ && l(5, u = _.border_mode), "padding" in _ && l(6, b = _.padding), "type" in _ && l(16, c = _.type), "test_id" in _ && l(7, w = _.test_id), "explicit_call" in _ && l(8, r = _.explicit_call), "container" in _ && l(9, B = _.container), "visible" in _ && l(10, L = _.visible), "allow_overflow" in _ && l(11, T = _.allow_overflow), "scale" in _ && l(12, E = _.scale), "min_width" in _ && l(13, M = _.min_width), "$$scope" in _ && l(17, n = _.$$scope);
|
253 |
}, [
|
254 |
i,
|
255 |
d,
|
256 |
s,
|
257 |
t,
|
258 |
o,
|
259 |
+
u,
|
260 |
+
b,
|
261 |
+
w,
|
262 |
r,
|
|
|
263 |
B,
|
264 |
L,
|
265 |
T,
|
|
|
609 |
);
|
610 |
const {
|
611 |
SvelteComponent: _e,
|
612 |
+
attr: y,
|
613 |
create_slot: de,
|
614 |
detach: oe,
|
615 |
element: ce,
|
|
|
619 |
insert: be,
|
620 |
null_to_empty: D,
|
621 |
safe_not_equal: ge,
|
622 |
+
set_style: k,
|
623 |
+
toggle_class: h,
|
624 |
transition_in: he,
|
625 |
transition_out: ve,
|
626 |
update_slot_base: we
|
|
|
640 |
);
|
641 |
return {
|
642 |
c() {
|
643 |
+
e = ce("div"), d && d.c(), y(
|
644 |
e,
|
645 |
"id",
|
646 |
/*elem_id*/
|
647 |
f[3]
|
648 |
+
), y(e, "class", l = D(
|
649 |
/*elem_classes*/
|
650 |
f[4].join(" ")
|
651 |
+
) + " svelte-1m1obck"), h(
|
652 |
e,
|
653 |
"gap",
|
654 |
/*gap*/
|
655 |
f[1]
|
656 |
+
), h(
|
657 |
e,
|
658 |
"compact",
|
659 |
/*variant*/
|
660 |
f[6] === "compact"
|
661 |
+
), h(
|
662 |
e,
|
663 |
"panel",
|
664 |
/*variant*/
|
665 |
f[6] === "panel"
|
666 |
+
), h(e, "hide", !/*visible*/
|
667 |
+
f[5]), k(
|
668 |
e,
|
669 |
"flex-grow",
|
670 |
/*scale*/
|
671 |
f[0]
|
672 |
+
), k(e, "min-width", a);
|
673 |
},
|
674 |
m(s, t) {
|
675 |
be(s, e, t), d && d.m(e, null), n = !0;
|
|
|
694 |
),
|
695 |
null
|
696 |
), (!n || t & /*elem_id*/
|
697 |
+
8) && y(
|
698 |
e,
|
699 |
"id",
|
700 |
/*elem_id*/
|
|
|
703 |
16 && l !== (l = D(
|
704 |
/*elem_classes*/
|
705 |
s[4].join(" ")
|
706 |
+
) + " svelte-1m1obck")) && y(e, "class", l), (!n || t & /*elem_classes, gap*/
|
707 |
+
18) && h(
|
708 |
e,
|
709 |
"gap",
|
710 |
/*gap*/
|
711 |
s[1]
|
712 |
), (!n || t & /*elem_classes, variant*/
|
713 |
+
80) && h(
|
714 |
e,
|
715 |
"compact",
|
716 |
/*variant*/
|
717 |
s[6] === "compact"
|
718 |
), (!n || t & /*elem_classes, variant*/
|
719 |
+
80) && h(
|
720 |
e,
|
721 |
"panel",
|
722 |
/*variant*/
|
723 |
s[6] === "panel"
|
724 |
), (!n || t & /*elem_classes, visible*/
|
725 |
+
48) && h(e, "hide", !/*visible*/
|
726 |
s[5]), t & /*scale*/
|
727 |
+
1 && k(
|
728 |
e,
|
729 |
"flex-grow",
|
730 |
/*scale*/
|
731 |
s[0]
|
732 |
), t & /*min_width*/
|
733 |
4 && a !== (a = `calc(min(${/*min_width*/
|
734 |
+
s[2]}px, 100%))`) && k(e, "min-width", a);
|
735 |
},
|
736 |
i(s) {
|
737 |
n || (he(d, s), n = !0);
|
|
|
745 |
};
|
746 |
}
|
747 |
function ke(f, e, l) {
|
748 |
+
let { $$slots: a = {}, $$scope: n } = e, { scale: i = null } = e, { gap: d = !0 } = e, { min_width: s = 0 } = e, { elem_id: t = "" } = e, { elem_classes: o = [] } = e, { visible: u = !0 } = e, { variant: b = "default" } = e;
|
749 |
return f.$$set = (c) => {
|
750 |
+
"scale" in c && l(0, i = c.scale), "gap" in c && l(1, d = c.gap), "min_width" in c && l(2, s = c.min_width), "elem_id" in c && l(3, t = c.elem_id), "elem_classes" in c && l(4, o = c.elem_classes), "visible" in c && l(5, u = c.visible), "variant" in c && l(6, b = c.variant), "$$scope" in c && l(7, n = c.$$scope);
|
751 |
+
}, [i, d, s, t, o, u, b, n, a];
|
752 |
}
|
753 |
let je = class extends _e {
|
754 |
constructor(e) {
|
|
|
771 |
create_component: G,
|
772 |
create_slot: Se,
|
773 |
destroy_component: J,
|
774 |
+
detach: C,
|
775 |
+
element: j,
|
776 |
get_all_dirty_from_scope: Be,
|
777 |
get_slot_changes: Le,
|
778 |
init: Te,
|
779 |
+
insert: q,
|
780 |
listen: K,
|
781 |
mount_component: O,
|
782 |
noop: Ee,
|
783 |
safe_not_equal: Me,
|
784 |
space: ze,
|
785 |
toggle_class: H,
|
786 |
+
transition_in: I,
|
787 |
+
transition_out: S,
|
788 |
update_slot_base: Ae
|
789 |
} = window.__gradio__svelte__internal;
|
790 |
function N(f) {
|
791 |
let e, l, a;
|
792 |
return {
|
793 |
c() {
|
794 |
+
e = j("div"), e.innerHTML = '<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L9 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path><path d="M9 1L1 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path></svg>', v(e, "class", "close svelte-ra5mg6");
|
795 |
},
|
796 |
m(n, i) {
|
797 |
+
q(n, e, i), l || (a = K(
|
798 |
e,
|
799 |
"click",
|
800 |
+
/*close*/
|
801 |
+
f[5]
|
802 |
), l = !0);
|
803 |
},
|
804 |
p: Ee,
|
805 |
d(n) {
|
806 |
+
n && C(e), l = !1, a();
|
807 |
}
|
808 |
};
|
809 |
}
|
|
|
811 |
let e;
|
812 |
const l = (
|
813 |
/*#slots*/
|
814 |
+
f[7].default
|
815 |
), a = Se(
|
816 |
l,
|
817 |
f,
|
818 |
/*$$scope*/
|
819 |
+
f[10],
|
820 |
null
|
821 |
);
|
822 |
return {
|
|
|
828 |
},
|
829 |
p(n, i) {
|
830 |
a && a.p && (!e || i & /*$$scope*/
|
831 |
+
1024) && Ae(
|
832 |
a,
|
833 |
l,
|
834 |
n,
|
835 |
/*$$scope*/
|
836 |
+
n[10],
|
837 |
e ? Le(
|
838 |
l,
|
839 |
/*$$scope*/
|
840 |
+
n[10],
|
841 |
i,
|
842 |
null
|
843 |
) : Be(
|
844 |
/*$$scope*/
|
845 |
+
n[10]
|
846 |
),
|
847 |
null
|
848 |
);
|
849 |
},
|
850 |
i(n) {
|
851 |
+
e || (I(a, n), e = !0);
|
852 |
},
|
853 |
o(n) {
|
854 |
+
S(a, n), e = !1;
|
855 |
},
|
856 |
d(n) {
|
857 |
a && a.d(n);
|
|
|
873 |
n && n.c(), e = ze(), G(l.$$.fragment);
|
874 |
},
|
875 |
m(i, d) {
|
876 |
+
n && n.m(i, d), q(i, e, d), O(l, i, d), a = !0;
|
877 |
},
|
878 |
p(i, d) {
|
879 |
/*allow_user_close*/
|
880 |
i[3] ? n ? n.p(i, d) : (n = N(i), n.c(), n.m(e.parentNode, e)) : n && (n.d(1), n = null);
|
881 |
const s = {};
|
882 |
d & /*$$scope*/
|
883 |
+
1024 && (s.$$scope = { dirty: d, ctx: i }), l.$set(s);
|
884 |
},
|
885 |
i(i) {
|
886 |
+
a || (I(l.$$.fragment, i), a = !0);
|
887 |
},
|
888 |
o(i) {
|
889 |
+
S(l.$$.fragment, i), a = !1;
|
890 |
},
|
891 |
d(i) {
|
892 |
+
i && C(e), n && n.d(i), J(l, i);
|
893 |
}
|
894 |
};
|
895 |
}
|
|
|
903 |
}
|
904 |
}), {
|
905 |
c() {
|
906 |
+
e = j("div"), l = j("div"), G(a.$$.fragment), v(l, "class", "modal-container svelte-ra5mg6"), v(e, "class", n = "modal " + /*elem_classes*/
|
907 |
f[2].join(" ") + " svelte-ra5mg6"), v(
|
908 |
e,
|
909 |
"id",
|
|
|
913 |
f[0]);
|
914 |
},
|
915 |
m(t, o) {
|
916 |
+
q(t, e, o), qe(e, l), O(a, l, null), f[8](e), i = !0, d || (s = K(
|
917 |
e,
|
918 |
"click",
|
919 |
+
/*click_handler*/
|
920 |
+
f[9]
|
921 |
), d = !0);
|
922 |
},
|
923 |
p(t, [o]) {
|
924 |
+
const u = {};
|
925 |
+
o & /*$$scope, allow_user_close*/
|
926 |
+
1032 && (u.$$scope = { dirty: o, ctx: t }), a.$set(u), (!i || o & /*elem_classes*/
|
927 |
4 && n !== (n = "modal " + /*elem_classes*/
|
928 |
t[2].join(" ") + " svelte-ra5mg6")) && v(e, "class", n), (!i || o & /*elem_id*/
|
929 |
2) && v(
|
|
|
936 |
t[0]);
|
937 |
},
|
938 |
i(t) {
|
939 |
+
i || (I(a.$$.fragment, t), i = !0);
|
940 |
},
|
941 |
o(t) {
|
942 |
+
S(a.$$.fragment, t), i = !1;
|
943 |
},
|
944 |
d(t) {
|
945 |
+
t && C(e), J(a), f[8](null), d = !1, s();
|
946 |
}
|
947 |
};
|
948 |
}
|
949 |
function Ue(f, e, l) {
|
950 |
+
let { $$slots: a = {}, $$scope: n } = e, { elem_id: i = "" } = e, { elem_classes: d = [] } = e, { visible: s = !1 } = e, { allow_user_close: t = !0 } = e, { gradio: o } = e, u = null;
|
951 |
+
const b = () => {
|
952 |
+
l(0, s = !1), o.dispatch("blur");
|
953 |
+
};
|
954 |
document.addEventListener("keydown", (r) => {
|
955 |
+
t && r.key === "Escape" && b();
|
956 |
});
|
957 |
+
function c(r) {
|
|
|
958 |
Ie[r ? "unshift" : "push"](() => {
|
959 |
+
u = r, l(4, u);
|
960 |
});
|
961 |
}
|
962 |
+
const w = (r) => {
|
963 |
+
t && r.target === u && b();
|
964 |
};
|
965 |
return f.$$set = (r) => {
|
966 |
+
"elem_id" in r && l(1, i = r.elem_id), "elem_classes" in r && l(2, d = r.elem_classes), "visible" in r && l(0, s = r.visible), "allow_user_close" in r && l(3, t = r.allow_user_close), "gradio" in r && l(6, o = r.gradio), "$$scope" in r && l(10, n = r.$$scope);
|
967 |
}, [
|
968 |
s,
|
969 |
i,
|
970 |
d,
|
971 |
t,
|
972 |
+
u,
|
973 |
+
b,
|
974 |
o,
|
975 |
a,
|
|
|
|
|
976 |
c,
|
977 |
+
w,
|
978 |
n
|
979 |
];
|
980 |
}
|
|
|
984 |
elem_id: 1,
|
985 |
elem_classes: 2,
|
986 |
visible: 0,
|
987 |
+
allow_user_close: 3,
|
988 |
+
gradio: 6
|
989 |
});
|
990 |
}
|
991 |
}
|
src/demo/app.py
CHANGED
@@ -17,4 +17,5 @@ with gr.Blocks() as demo:
|
|
17 |
gr.Markdown("Hello world!")
|
18 |
show_btn.click(lambda: Modal(visible=True), None, modal)
|
19 |
|
20 |
-
|
|
|
|
17 |
gr.Markdown("Hello world!")
|
18 |
show_btn.click(lambda: Modal(visible=True), None, modal)
|
19 |
|
20 |
+
if __name__ == "__main__":
|
21 |
+
demo.launch()
|
src/demo/space.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
from app import demo as app
|
4 |
import os
|
5 |
|
6 |
-
_docs = {'Modal': {'description': 'Modal is a layout element within Blocks that will show its content in a popup above other content.\n from gradio_modal import Modal\n with gr.Blocks() as demo:\n with Modal():\n text1 = gr.Textbox()\n text2 = gr.Textbox()\n btn = gr.Button("Button")', 'members': {'__init__': {'visible': {'type': 'bool', 'default': 'False', 'description': 'If False,
|
7 |
|
8 |
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
9 |
|
@@ -21,7 +21,7 @@ with gr.Blocks(
|
|
21 |
# `gradio_modal`
|
22 |
|
23 |
<div style="display: flex; gap: 7px;">
|
24 |
-
<img alt="
|
25 |
</div>
|
26 |
|
27 |
A popup modal component
|
@@ -38,25 +38,25 @@ pip install gradio_modal
|
|
38 |
## Usage
|
39 |
|
40 |
```python
|
41 |
-
|
42 |
import gradio as gr
|
43 |
from gradio_modal import Modal
|
44 |
|
45 |
-
|
46 |
with gr.Blocks() as demo:
|
47 |
-
gr.
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
gr.
|
52 |
-
gr.
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
|
|
|
|
|
|
57 |
show_btn.click(lambda: Modal(visible=True), None, modal)
|
58 |
|
59 |
-
|
60 |
if __name__ == "__main__":
|
61 |
demo.launch()
|
62 |
|
@@ -73,6 +73,10 @@ if __name__ == "__main__":
|
|
73 |
gr.ParamViewer(value=_docs["Modal"]["members"]["__init__"], linkify=[])
|
74 |
|
75 |
|
|
|
|
|
|
|
|
|
76 |
|
77 |
|
78 |
|
|
|
3 |
from app import demo as app
|
4 |
import os
|
5 |
|
6 |
+
_docs = {'Modal': {'description': 'Modal is a layout element within Blocks that will show its content in a popup above other content.\n from gradio_modal import Modal\n with gr.Blocks() as demo:\n with Modal():\n text1 = gr.Textbox()\n text2 = gr.Textbox()\n btn = gr.Button("Button")', 'members': {'__init__': {'visible': {'type': 'bool', 'default': 'False', 'description': 'If False, modal will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': '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': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional string or list of strings that are assigned as the class of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'allow_user_close': {'type': 'bool', 'default': 'True', 'description': 'If True, user can close the modal (by clicking outside, clicking the X, or the escape key).'}, 'render': {'type': 'bool', 'default': 'True', 'description': '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.'}}, 'postprocess': {}}, 'events': {'blur': {'type': None, 'default': None, 'description': 'This listener is triggered when the Modal is unfocused/blurred.'}}}, '__meta__': {'additional_interfaces': {}}}
|
7 |
|
8 |
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
9 |
|
|
|
21 |
# `gradio_modal`
|
22 |
|
23 |
<div style="display: flex; gap: 7px;">
|
24 |
+
<a href="https://pypi.org/project/gradio_modal/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_modal"></a>
|
25 |
</div>
|
26 |
|
27 |
A popup modal component
|
|
|
38 |
## Usage
|
39 |
|
40 |
```python
|
|
|
41 |
import gradio as gr
|
42 |
from gradio_modal import Modal
|
43 |
|
|
|
44 |
with gr.Blocks() as demo:
|
45 |
+
with gr.Tab("Tab 1"):
|
46 |
+
text_1 = gr.Textbox(label="Input 1")
|
47 |
+
text_2 = gr.Textbox(label="Input 2")
|
48 |
+
text_1.submit(lambda x:x, text_1, text_2)
|
49 |
+
show_btn = gr.Button("Show Modal")
|
50 |
+
gr.Examples(
|
51 |
+
[["Text 1", "Text 2"], ["Text 3", "Text 4"]],
|
52 |
+
inputs=[text_1, text_2],
|
53 |
+
)
|
54 |
+
with gr.Tab("Tab 2"):
|
55 |
+
gr.Markdown("This is tab 2")
|
56 |
+
with Modal(visible=False) as modal:
|
57 |
+
gr.Markdown("Hello world!")
|
58 |
show_btn.click(lambda: Modal(visible=True), None, modal)
|
59 |
|
|
|
60 |
if __name__ == "__main__":
|
61 |
demo.launch()
|
62 |
|
|
|
73 |
gr.ParamViewer(value=_docs["Modal"]["members"]["__init__"], linkify=[])
|
74 |
|
75 |
|
76 |
+
gr.Markdown("### Events")
|
77 |
+
gr.ParamViewer(value=_docs["Modal"]["events"], linkify=['Event'])
|
78 |
+
|
79 |
+
|
80 |
|
81 |
|
82 |
|
src/pyproject.toml
CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
|
|
8 |
|
9 |
[project]
|
10 |
name = "gradio_modal"
|
11 |
-
version = "0.0.
|
12 |
description = "A popup modal component"
|
13 |
readme = "README.md"
|
14 |
license = "MIT"
|
@@ -36,7 +36,7 @@ classifiers = [
|
|
36 |
dev = ["build", "twine"]
|
37 |
|
38 |
[tool.hatch.build]
|
39 |
-
artifacts = ["/backend/gradio_modal/templates", "*.pyi", "backend/gradio_modal/templates", "backend/gradio_modal/templates"]
|
40 |
|
41 |
[tool.hatch.build.targets.wheel]
|
42 |
packages = ["/backend/gradio_modal"]
|
|
|
8 |
|
9 |
[project]
|
10 |
name = "gradio_modal"
|
11 |
+
version = "0.0.2"
|
12 |
description = "A popup modal component"
|
13 |
readme = "README.md"
|
14 |
license = "MIT"
|
|
|
36 |
dev = ["build", "twine"]
|
37 |
|
38 |
[tool.hatch.build]
|
39 |
+
artifacts = ["/backend/gradio_modal/templates", "*.pyi", "backend/gradio_modal/templates", "backend/gradio_modal/templates", "backend/gradio_modal/templates", "backend/gradio_modal/templates"]
|
40 |
|
41 |
[tool.hatch.build.targets.wheel]
|
42 |
packages = ["/backend/gradio_modal"]
|