aliabid94 HF staff commited on
Commit
49e427e
1 Parent(s): 30875f8

Upload folder using huggingface_hub

Browse files
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.2
5
  colorFrom: red
6
- colorTo: yellow
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.3
5
  colorFrom: red
6
+ colorTo: gray
7
  sdk: docker
8
  pinned: false
9
  license: apache-2.0
space.py CHANGED
@@ -4,7 +4,7 @@ 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
 
10
  with gr.Blocks(
@@ -47,6 +47,7 @@ with gr.Blocks() as demo:
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],
@@ -54,8 +55,13 @@ with gr.Blocks() as demo:
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()
@@ -99,7 +105,7 @@ if __name__ == "__main__":
99
  })
100
  }
101
  })
102
-
103
  Object.entries(refs).forEach(([key, refs]) => {
104
  if (refs.length > 0) {
105
  const el = document.querySelector(`.${key}`);
 
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
 
10
  with gr.Blocks(
 
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
+ show_btn2 = gr.Button("Show Modal 2")
51
  gr.Examples(
52
  [["Text 1", "Text 2"], ["Text 3", "Text 4"]],
53
  inputs=[text_1, text_2],
 
55
  with gr.Tab("Tab 2"):
56
  gr.Markdown("This is tab 2")
57
  with Modal(visible=False) as modal:
58
+ for i in range(5):
59
+ gr.Markdown("Hello world!")
60
+ with Modal(visible=False) as modal2:
61
+ for i in range(100):
62
+ gr.Markdown("Hello world!")
63
  show_btn.click(lambda: Modal(visible=True), None, modal)
64
+ show_btn2.click(lambda: Modal(visible=True), None, modal2)
65
 
66
  if __name__ == "__main__":
67
  demo.launch()
 
105
  })
106
  }
107
  })
108
+
109
  Object.entries(refs).forEach(([key, refs]) => {
110
  if (refs.length > 0) {
111
  const el = document.querySelector(`.${key}`);
src/README.md CHANGED
@@ -5,8 +5,8 @@
5
  A popup modal component
6
 
7
  ## Installation
8
-
9
- ```bash
10
  pip install gradio_modal
11
  ```
12
 
@@ -22,6 +22,7 @@ with gr.Blocks() as demo:
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],
@@ -29,8 +30,13 @@ with gr.Blocks() as demo:
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()
 
5
  A popup modal component
6
 
7
  ## Installation
8
+
9
+ ```bash
10
  pip install gradio_modal
11
  ```
12
 
 
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
+ show_btn2 = gr.Button("Show Modal 2")
26
  gr.Examples(
27
  [["Text 1", "Text 2"], ["Text 3", "Text 4"]],
28
  inputs=[text_1, text_2],
 
30
  with gr.Tab("Tab 2"):
31
  gr.Markdown("This is tab 2")
32
  with Modal(visible=False) as modal:
33
+ for i in range(5):
34
+ gr.Markdown("Hello world!")
35
+ with Modal(visible=False) as modal2:
36
+ for i in range(100):
37
+ gr.Markdown("Hello world!")
38
  show_btn.click(lambda: Modal(visible=True), None, modal)
39
+ show_btn2.click(lambda: Modal(visible=True), None, modal2)
40
 
41
  if __name__ == "__main__":
42
  demo.launch()
src/backend/gradio_modal/templates/component/index.js CHANGED
@@ -1,28 +1,28 @@
1
  const {
2
- SvelteComponent: R,
3
- assign: V,
4
- create_slot: W,
5
- detach: X,
6
- element: Y,
7
- get_all_dirty_from_scope: Z,
8
- get_slot_changes: p,
9
- get_spread_update: x,
10
- init: $,
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
19
  } = window.__gradio__svelte__internal;
20
- function fe(f) {
21
  let e, l, a;
22
  const n = (
23
  /*#slots*/
24
  f[18].default
25
- ), i = W(
26
  n,
27
  f,
28
  /*$$scope*/
@@ -44,10 +44,10 @@ function fe(f) {
44
  }
45
  ], s = {};
46
  for (let t = 0; t < d.length; t += 1)
47
- s = V(s, d[t]);
48
  return {
49
  c() {
50
- e = Y(
51
  /*tag*/
52
  f[14]
53
  ), i && i.c(), z(
@@ -105,23 +105,23 @@ function fe(f) {
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;
109
  },
110
  p(t, o) {
111
  i && i.p && (!a || o & /*$$scope*/
112
- 131072) && te(
113
  i,
114
  n,
115
  t,
116
  /*$$scope*/
117
  t[17],
118
- a ? p(
119
  n,
120
  /*$$scope*/
121
  t[17],
122
  o,
123
  null
124
- ) : Z(
125
  /*$$scope*/
126
  t[17]
127
  ),
@@ -129,7 +129,7 @@ function fe(f) {
129
  ), z(
130
  /*tag*/
131
  t[14]
132
- )(e, s = x(d, [
133
  (!a || o & /*test_id*/
134
  128) && { "data-testid": (
135
  /*test_id*/
@@ -201,20 +201,20 @@ function fe(f) {
201
  t[13]}px, 100%))`);
202
  },
203
  i(t) {
204
- a || (U(i, t), a = !0);
205
  },
206
  o(t) {
207
- F(i, t), a = !1;
208
  },
209
  d(t) {
210
- t && X(e), i && i.d(t);
211
  }
212
  };
213
  }
214
- function ne(f) {
215
  let e, l = (
216
  /*tag*/
217
- f[14] && fe(f)
218
  );
219
  return {
220
  c() {
@@ -228,19 +228,19 @@ function ne(f) {
228
  a[14] && l.p(a, n);
229
  },
230
  i(a) {
231
- e || (U(l, a), e = !0);
232
  },
233
  o(a) {
234
- F(l, a), e = !1;
235
  },
236
  d(a) {
237
  l && l.d(a);
238
  }
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")
246
  return _ + "px";
@@ -249,7 +249,7 @@ 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, 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,
@@ -258,23 +258,23 @@ function ae(f, e, l) {
258
  o,
259
  u,
260
  b,
261
- w,
262
- r,
263
- B,
264
- L,
265
  T,
266
  E,
267
  M,
268
- P,
269
  Q,
270
- c,
 
271
  n,
272
  a
273
  ];
274
  }
275
- class ie extends R {
276
  constructor(e) {
277
- super(), $(this, e, ae, ne, le, {
278
  height: 0,
279
  width: 1,
280
  elem_id: 2,
@@ -293,7 +293,7 @@ class ie extends R {
293
  });
294
  }
295
  }
296
- const se = [
297
  { color: "red", primary: 600, secondary: 100 },
298
  { color: "green", primary: 600, secondary: 100 },
299
  { color: "blue", primary: 600, secondary: 100 },
@@ -597,7 +597,7 @@ const se = [
597
  950: "#4c0519"
598
  }
599
  };
600
- se.reduce(
601
  (f, { color: e, primary: l, secondary: a }) => ({
602
  ...f,
603
  [e]: {
@@ -608,30 +608,30 @@ se.reduce(
608
  {}
609
  );
610
  const {
611
- SvelteComponent: _e,
612
- attr: y,
613
- create_slot: de,
614
- detach: oe,
615
- element: ce,
616
- get_all_dirty_from_scope: re,
617
- get_slot_changes: ue,
618
- init: me,
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
627
  } = window.__gradio__svelte__internal;
628
- function ye(f) {
629
  let e, l, a = `calc(min(${/*min_width*/
630
  f[2]}px, 100%))`, n;
631
  const i = (
632
  /*#slots*/
633
  f[8].default
634
- ), d = de(
635
  i,
636
  f,
637
  /*$$scope*/
@@ -640,12 +640,12 @@ function ye(f) {
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(
@@ -664,37 +664,37 @@ function ye(f) {
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;
676
  },
677
  p(s, [t]) {
678
  d && d.p && (!n || t & /*$$scope*/
679
- 128) && we(
680
  d,
681
  i,
682
  s,
683
  /*$$scope*/
684
  s[7],
685
- n ? ue(
686
  i,
687
  /*$$scope*/
688
  s[7],
689
  t,
690
  null
691
- ) : re(
692
  /*$$scope*/
693
  s[7]
694
  ),
695
  null
696
  ), (!n || t & /*elem_id*/
697
- 8) && y(
698
  e,
699
  "id",
700
  /*elem_id*/
@@ -703,7 +703,7 @@ function ye(f) {
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",
@@ -724,35 +724,35 @@ function ye(f) {
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);
738
  },
739
  o(s) {
740
  ve(d, s), n = !1;
741
  },
742
  d(s) {
743
- s && oe(e), d && d.d(s);
744
  }
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) {
755
- super(), me(this, e, ke, ye, ge, {
756
  scale: 0,
757
  gap: 1,
758
  min_width: 2,
@@ -764,46 +764,46 @@ let je = class extends _e {
764
  }
765
  };
766
  const {
767
- SvelteComponent: Ce,
768
- append: qe,
769
- attr: v,
770
- binding_callbacks: Ie,
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,12 +811,12 @@ function De(f) {
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,30 +828,30 @@ function De(f) {
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);
@@ -861,109 +861,115 @@ function De(f) {
861
  function He(f) {
862
  let e, l, a, n = (
863
  /*allow_user_close*/
864
- f[3] && N(f)
865
  );
866
- return l = new je({
867
  props: {
868
  $$slots: { default: [De] },
869
  $$scope: { ctx: f }
870
  }
871
  }), {
872
  c() {
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
  }
896
  function Ne(f) {
897
  let e, l, a, n, i, d, s;
898
- return a = new ie({
899
  props: {
900
- height: "100%",
 
901
  $$slots: { default: [He] },
902
  $$scope: { ctx: f }
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",
910
  /*elem_id*/
911
  f[1]
912
- ), H(e, "hide", !/*visible*/
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(
930
  e,
931
  "id",
932
  /*elem_id*/
933
  t[1]
934
  ), (!i || o & /*elem_classes, visible*/
935
- 5) && H(e, "hide", !/*visible*/
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,
@@ -971,21 +977,23 @@ function Ue(f, e, l) {
971
  t,
972
  u,
973
  b,
 
974
  o,
975
  a,
976
- c,
977
- w,
 
978
  n
979
  ];
980
  }
981
- class Ge extends Ce {
982
  constructor(e) {
983
  super(), Te(this, e, Ue, Ne, Me, {
984
  elem_id: 1,
985
  elem_classes: 2,
986
  visible: 0,
987
  allow_user_close: 3,
988
- gradio: 6
989
  });
990
  }
991
  }
 
1
  const {
2
+ SvelteComponent: V,
3
+ assign: W,
4
+ create_slot: X,
5
+ detach: Y,
6
+ element: Z,
7
+ get_all_dirty_from_scope: p,
8
+ get_slot_changes: x,
9
+ get_spread_update: $,
10
+ init: ee,
11
+ insert: le,
12
+ safe_not_equal: te,
13
  set_dynamic_element_data: z,
14
  set_style: m,
15
  toggle_class: g,
16
+ transition_in: F,
17
+ transition_out: G,
18
+ update_slot_base: fe
19
  } = window.__gradio__svelte__internal;
20
+ function ne(f) {
21
  let e, l, a;
22
  const n = (
23
  /*#slots*/
24
  f[18].default
25
+ ), i = X(
26
  n,
27
  f,
28
  /*$$scope*/
 
44
  }
45
  ], s = {};
46
  for (let t = 0; t < d.length; t += 1)
47
+ s = W(s, d[t]);
48
  return {
49
  c() {
50
+ e = Z(
51
  /*tag*/
52
  f[14]
53
  ), i && i.c(), z(
 
105
  f[13]}px, 100%))`), m(e, "border-width", "var(--block-border-width)");
106
  },
107
  m(t, o) {
108
+ le(t, e, o), i && i.m(e, null), a = !0;
109
  },
110
  p(t, o) {
111
  i && i.p && (!a || o & /*$$scope*/
112
+ 131072) && fe(
113
  i,
114
  n,
115
  t,
116
  /*$$scope*/
117
  t[17],
118
+ a ? x(
119
  n,
120
  /*$$scope*/
121
  t[17],
122
  o,
123
  null
124
+ ) : p(
125
  /*$$scope*/
126
  t[17]
127
  ),
 
129
  ), z(
130
  /*tag*/
131
  t[14]
132
+ )(e, s = $(d, [
133
  (!a || o & /*test_id*/
134
  128) && { "data-testid": (
135
  /*test_id*/
 
201
  t[13]}px, 100%))`);
202
  },
203
  i(t) {
204
+ a || (F(i, t), a = !0);
205
  },
206
  o(t) {
207
+ G(i, t), a = !1;
208
  },
209
  d(t) {
210
+ t && Y(e), i && i.d(t);
211
  }
212
  };
213
  }
214
+ function ae(f) {
215
  let e, l = (
216
  /*tag*/
217
+ f[14] && ne(f)
218
  );
219
  return {
220
  c() {
 
228
  a[14] && l.p(a, n);
229
  },
230
  i(a) {
231
+ e || (F(l, a), e = !0);
232
  },
233
  o(a) {
234
+ G(l, a), e = !1;
235
  },
236
  d(a) {
237
  l && l.d(a);
238
  }
239
  };
240
  }
241
+ function ie(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: r = "normal" } = e, { test_id: v = void 0 } = e, { explicit_call: y = !1 } = e, { container: k = !0 } = e, { visible: c = !0 } = e, { allow_overflow: T = !0 } = e, { scale: E = null } = e, { min_width: M = 0 } = e, Q = r === "fieldset" ? "fieldset" : "div";
243
+ const R = (_) => {
244
  if (_ !== void 0) {
245
  if (typeof _ == "number")
246
  return _ + "px";
 
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, r = _.type), "test_id" in _ && l(7, v = _.test_id), "explicit_call" in _ && l(8, y = _.explicit_call), "container" in _ && l(9, k = _.container), "visible" in _ && l(10, c = _.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,
 
258
  o,
259
  u,
260
  b,
261
+ v,
262
+ y,
263
+ k,
264
+ c,
265
  T,
266
  E,
267
  M,
 
268
  Q,
269
+ R,
270
+ r,
271
  n,
272
  a
273
  ];
274
  }
275
+ class se extends V {
276
  constructor(e) {
277
+ super(), ee(this, e, ie, ae, te, {
278
  height: 0,
279
  width: 1,
280
  elem_id: 2,
 
293
  });
294
  }
295
  }
296
+ const _e = [
297
  { color: "red", primary: 600, secondary: 100 },
298
  { color: "green", primary: 600, secondary: 100 },
299
  { color: "blue", primary: 600, secondary: 100 },
 
597
  950: "#4c0519"
598
  }
599
  };
600
+ _e.reduce(
601
  (f, { color: e, primary: l, secondary: a }) => ({
602
  ...f,
603
  [e]: {
 
608
  {}
609
  );
610
  const {
611
+ SvelteComponent: de,
612
+ attr: j,
613
+ create_slot: oe,
614
+ detach: ce,
615
+ element: re,
616
+ get_all_dirty_from_scope: ue,
617
+ get_slot_changes: me,
618
+ init: be,
619
+ insert: ge,
620
  null_to_empty: D,
621
+ safe_not_equal: he,
622
+ set_style: C,
623
  toggle_class: h,
624
+ transition_in: we,
625
  transition_out: ve,
626
+ update_slot_base: ye
627
  } = window.__gradio__svelte__internal;
628
+ function ke(f) {
629
  let e, l, a = `calc(min(${/*min_width*/
630
  f[2]}px, 100%))`, n;
631
  const i = (
632
  /*#slots*/
633
  f[8].default
634
+ ), d = oe(
635
  i,
636
  f,
637
  /*$$scope*/
 
640
  );
641
  return {
642
  c() {
643
+ e = re("div"), d && d.c(), j(
644
  e,
645
  "id",
646
  /*elem_id*/
647
  f[3]
648
+ ), j(e, "class", l = D(
649
  /*elem_classes*/
650
  f[4].join(" ")
651
  ) + " svelte-1m1obck"), h(
 
664
  /*variant*/
665
  f[6] === "panel"
666
  ), h(e, "hide", !/*visible*/
667
+ f[5]), C(
668
  e,
669
  "flex-grow",
670
  /*scale*/
671
  f[0]
672
+ ), C(e, "min-width", a);
673
  },
674
  m(s, t) {
675
+ ge(s, e, t), d && d.m(e, null), n = !0;
676
  },
677
  p(s, [t]) {
678
  d && d.p && (!n || t & /*$$scope*/
679
+ 128) && ye(
680
  d,
681
  i,
682
  s,
683
  /*$$scope*/
684
  s[7],
685
+ n ? me(
686
  i,
687
  /*$$scope*/
688
  s[7],
689
  t,
690
  null
691
+ ) : ue(
692
  /*$$scope*/
693
  s[7]
694
  ),
695
  null
696
  ), (!n || t & /*elem_id*/
697
+ 8) && j(
698
  e,
699
  "id",
700
  /*elem_id*/
 
703
  16 && l !== (l = D(
704
  /*elem_classes*/
705
  s[4].join(" ")
706
+ ) + " svelte-1m1obck")) && j(e, "class", l), (!n || t & /*elem_classes, gap*/
707
  18) && h(
708
  e,
709
  "gap",
 
724
  ), (!n || t & /*elem_classes, visible*/
725
  48) && h(e, "hide", !/*visible*/
726
  s[5]), t & /*scale*/
727
+ 1 && C(
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%))`) && C(e, "min-width", a);
735
  },
736
  i(s) {
737
+ n || (we(d, s), n = !0);
738
  },
739
  o(s) {
740
  ve(d, s), n = !1;
741
  },
742
  d(s) {
743
+ s && ce(e), d && d.d(s);
744
  }
745
  };
746
  }
747
+ function je(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 = (r) => {
750
+ "scale" in r && l(0, i = r.scale), "gap" in r && l(1, d = r.gap), "min_width" in r && l(2, s = r.min_width), "elem_id" in r && l(3, t = r.elem_id), "elem_classes" in r && l(4, o = r.elem_classes), "visible" in r && l(5, u = r.visible), "variant" in r && l(6, b = r.variant), "$$scope" in r && l(7, n = r.$$scope);
751
  }, [i, d, s, t, o, u, b, n, a];
752
  }
753
+ let Ce = class extends de {
754
  constructor(e) {
755
+ super(), be(this, e, je, ke, he, {
756
  scale: 0,
757
  gap: 1,
758
  min_width: 2,
 
764
  }
765
  };
766
  const {
767
+ SvelteComponent: qe,
768
+ append: Ie,
769
+ attr: w,
770
+ binding_callbacks: H,
771
+ create_component: J,
772
  create_slot: Se,
773
+ destroy_component: K,
774
+ detach: I,
775
+ element: q,
776
  get_all_dirty_from_scope: Be,
777
  get_slot_changes: Le,
778
  init: Te,
779
+ insert: S,
780
+ listen: O,
781
+ mount_component: P,
782
  noop: Ee,
783
  safe_not_equal: Me,
784
  space: ze,
785
+ toggle_class: N,
786
+ transition_in: B,
787
+ transition_out: L,
788
  update_slot_base: Ae
789
  } = window.__gradio__svelte__internal;
790
+ function U(f) {
791
  let e, l, a;
792
  return {
793
  c() {
794
+ e = q("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>', w(e, "class", "close svelte-7knbu5");
795
  },
796
  m(n, i) {
797
+ S(n, e, i), l || (a = O(
798
  e,
799
  "click",
800
  /*close*/
801
+ f[6]
802
  ), l = !0);
803
  },
804
  p: Ee,
805
  d(n) {
806
+ n && I(e), l = !1, a();
807
  }
808
  };
809
  }
 
811
  let e;
812
  const l = (
813
  /*#slots*/
814
+ f[8].default
815
  ), a = Se(
816
  l,
817
  f,
818
  /*$$scope*/
819
+ f[12],
820
  null
821
  );
822
  return {
 
828
  },
829
  p(n, i) {
830
  a && a.p && (!e || i & /*$$scope*/
831
+ 4096) && Ae(
832
  a,
833
  l,
834
  n,
835
  /*$$scope*/
836
+ n[12],
837
  e ? Le(
838
  l,
839
  /*$$scope*/
840
+ n[12],
841
  i,
842
  null
843
  ) : Be(
844
  /*$$scope*/
845
+ n[12]
846
  ),
847
  null
848
  );
849
  },
850
  i(n) {
851
+ e || (B(a, n), e = !0);
852
  },
853
  o(n) {
854
+ L(a, n), e = !1;
855
  },
856
  d(n) {
857
  a && a.d(n);
 
861
  function He(f) {
862
  let e, l, a, n = (
863
  /*allow_user_close*/
864
+ f[3] && U(f)
865
  );
866
+ return l = new Ce({
867
  props: {
868
  $$slots: { default: [De] },
869
  $$scope: { ctx: f }
870
  }
871
  }), {
872
  c() {
873
+ n && n.c(), e = ze(), J(l.$$.fragment);
874
  },
875
  m(i, d) {
876
+ n && n.m(i, d), S(i, e, d), P(l, i, d), a = !0;
877
  },
878
  p(i, d) {
879
  /*allow_user_close*/
880
+ i[3] ? n ? n.p(i, d) : (n = U(i), n.c(), n.m(e.parentNode, e)) : n && (n.d(1), n = null);
881
  const s = {};
882
  d & /*$$scope*/
883
+ 4096 && (s.$$scope = { dirty: d, ctx: i }), l.$set(s);
884
  },
885
  i(i) {
886
+ a || (B(l.$$.fragment, i), a = !0);
887
  },
888
  o(i) {
889
+ L(l.$$.fragment, i), a = !1;
890
  },
891
  d(i) {
892
+ i && I(e), n && n.d(i), K(l, i);
893
  }
894
  };
895
  }
896
  function Ne(f) {
897
  let e, l, a, n, i, d, s;
898
+ return a = new se({
899
  props: {
900
+ allow_overflow: !1,
901
+ elem_classes: ["modal-block"],
902
  $$slots: { default: [He] },
903
  $$scope: { ctx: f }
904
  }
905
  }), {
906
  c() {
907
+ e = q("div"), l = q("div"), J(a.$$.fragment), w(l, "class", "modal-container svelte-7knbu5"), w(e, "class", n = "modal " + /*elem_classes*/
908
+ f[2].join(" ") + " svelte-7knbu5"), w(
909
  e,
910
  "id",
911
  /*elem_id*/
912
  f[1]
913
+ ), N(e, "hide", !/*visible*/
914
  f[0]);
915
  },
916
  m(t, o) {
917
+ S(t, e, o), Ie(e, l), P(a, l, null), f[9](l), f[10](e), i = !0, d || (s = O(
918
  e,
919
  "click",
920
  /*click_handler*/
921
+ f[11]
922
  ), d = !0);
923
  },
924
  p(t, [o]) {
925
  const u = {};
926
  o & /*$$scope, allow_user_close*/
927
+ 4104 && (u.$$scope = { dirty: o, ctx: t }), a.$set(u), (!i || o & /*elem_classes*/
928
  4 && n !== (n = "modal " + /*elem_classes*/
929
+ t[2].join(" ") + " svelte-7knbu5")) && w(e, "class", n), (!i || o & /*elem_id*/
930
+ 2) && w(
931
  e,
932
  "id",
933
  /*elem_id*/
934
  t[1]
935
  ), (!i || o & /*elem_classes, visible*/
936
+ 5) && N(e, "hide", !/*visible*/
937
  t[0]);
938
  },
939
  i(t) {
940
+ i || (B(a.$$.fragment, t), i = !0);
941
  },
942
  o(t) {
943
+ L(a.$$.fragment, t), i = !1;
944
  },
945
  d(t) {
946
+ t && I(e), K(a), f[9](null), f[10](null), d = !1, s();
947
  }
948
  };
949
  }
950
  function Ue(f, e, l) {
951
+ 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, b = null;
952
+ const r = () => {
953
  l(0, s = !1), o.dispatch("blur");
954
  };
955
+ document.addEventListener("keydown", (c) => {
956
+ t && c.key === "Escape" && r();
957
  });
958
+ function v(c) {
959
+ H[c ? "unshift" : "push"](() => {
960
+ b = c, l(5, b);
961
+ });
962
+ }
963
+ function y(c) {
964
+ H[c ? "unshift" : "push"](() => {
965
+ u = c, l(4, u);
966
  });
967
  }
968
+ const k = (c) => {
969
+ t && (c.target === u || c.target === b) && r();
970
  };
971
+ return f.$$set = (c) => {
972
+ "elem_id" in c && l(1, i = c.elem_id), "elem_classes" in c && l(2, d = c.elem_classes), "visible" in c && l(0, s = c.visible), "allow_user_close" in c && l(3, t = c.allow_user_close), "gradio" in c && l(7, o = c.gradio), "$$scope" in c && l(12, n = c.$$scope);
973
  }, [
974
  s,
975
  i,
 
977
  t,
978
  u,
979
  b,
980
+ r,
981
  o,
982
  a,
983
+ v,
984
+ y,
985
+ k,
986
  n
987
  ];
988
  }
989
+ class Ge extends qe {
990
  constructor(e) {
991
  super(), Te(this, e, Ue, Ne, Me, {
992
  elem_id: 1,
993
  elem_classes: 2,
994
  visible: 0,
995
  allow_user_close: 3,
996
+ gradio: 7
997
  });
998
  }
999
  }
src/backend/gradio_modal/templates/component/style.css CHANGED
@@ -1 +1 @@
1
- .block.svelte-1t38q2d{position:relative;margin:0;box-shadow:var(--block-shadow);border-width:var(--block-border-width);border-color:var(--block-border-color);border-radius:var(--block-radius);background:var(--block-background-fill);width:100%;line-height:var(--line-sm)}.block.border_focus.svelte-1t38q2d{border-color:var(--color-accent)}.padded.svelte-1t38q2d{padding:var(--block-padding)}.hidden.svelte-1t38q2d{display:none}.hide-container.svelte-1t38q2d{margin:0;box-shadow:none;--block-border-width:0;background:transparent;padding:0;overflow:visible}div.svelte-1hnfib2{margin-bottom:var(--spacing-lg);color:var(--block-info-text-color);font-weight:var(--block-info-text-weight);font-size:var(--block-info-text-size);line-height:var(--line-sm)}span.has-info.svelte-22c38v{margin-bottom:var(--spacing-xs)}span.svelte-22c38v:not(.has-info){margin-bottom:var(--spacing-lg)}span.svelte-22c38v{display:inline-block;position:relative;z-index:var(--layer-4);border:solid var(--block-title-border-width) var(--block-title-border-color);border-radius:var(--block-title-radius);background:var(--block-title-background-fill);padding:var(--block-title-padding);color:var(--block-title-text-color);font-weight:var(--block-title-text-weight);font-size:var(--block-title-text-size);line-height:var(--line-sm)}.hide.svelte-22c38v{margin:0;height:0}label.svelte-9gxdi0{display:inline-flex;align-items:center;z-index:var(--layer-2);box-shadow:var(--block-label-shadow);border:var(--block-label-border-width) solid var(--border-color-primary);border-top:none;border-left:none;border-radius:var(--block-label-radius);background:var(--block-label-background-fill);padding:var(--block-label-padding);pointer-events:none;color:var(--block-label-text-color);font-weight:var(--block-label-text-weight);font-size:var(--block-label-text-size);line-height:var(--line-sm)}.gr-group label.svelte-9gxdi0{border-top-left-radius:0}label.float.svelte-9gxdi0{position:absolute;top:var(--block-label-margin);left:var(--block-label-margin)}label.svelte-9gxdi0:not(.float){position:static;margin-top:var(--block-label-margin);margin-left:var(--block-label-margin)}.hide.svelte-9gxdi0{height:0}span.svelte-9gxdi0{opacity:.8;margin-right:var(--size-2);width:calc(var(--block-label-text-size) - 1px);height:calc(var(--block-label-text-size) - 1px)}.hide-label.svelte-9gxdi0{box-shadow:none;border-width:0;background:transparent;overflow:visible}button.svelte-lpi64a{display:flex;justify-content:center;align-items:center;gap:1px;z-index:var(--layer-2);border-radius:var(--radius-sm);color:var(--block-label-text-color);border:1px solid transparent}button[disabled].svelte-lpi64a{opacity:.5;box-shadow:none}button[disabled].svelte-lpi64a:hover{cursor:not-allowed}.padded.svelte-lpi64a{padding:2px;background:var(--bg-color);box-shadow:var(--shadow-drop);border:1px solid var(--button-secondary-border-color)}button.svelte-lpi64a:hover,button.highlight.svelte-lpi64a{cursor:pointer;color:var(--color-accent)}.padded.svelte-lpi64a:hover{border:2px solid var(--button-secondary-border-color-hover);padding:1px;color:var(--block-label-text-color)}span.svelte-lpi64a{padding:0 1px;font-size:10px}div.svelte-lpi64a{padding:2px;display:flex;align-items:flex-end}.small.svelte-lpi64a{width:14px;height:14px}.large.svelte-lpi64a{width:22px;height:22px}.pending.svelte-lpi64a{animation:svelte-lpi64a-flash .5s infinite}@keyframes svelte-lpi64a-flash{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.transparent.svelte-lpi64a{background:transparent;border:none;box-shadow:none}.empty.svelte-3w3rth{display:flex;justify-content:center;align-items:center;margin-top:calc(0px - var(--size-6));height:var(--size-full)}.icon.svelte-3w3rth{opacity:.5;height:var(--size-5);color:var(--body-text-color)}.small.svelte-3w3rth{min-height:calc(var(--size-32) - 20px)}.large.svelte-3w3rth{min-height:calc(var(--size-64) - 20px)}.unpadded_box.svelte-3w3rth{margin-top:0}.small_parent.svelte-3w3rth{min-height:100%!important}.dropdown-arrow.svelte-145leq6{fill:currentColor}.wrap.svelte-kzcjhc{display:flex;flex-direction:column;justify-content:center;align-items:center;min-height:var(--size-60);color:var(--block-label-text-color);line-height:var(--line-md);height:100%;padding-top:var(--size-3)}.or.svelte-kzcjhc{color:var(--body-text-color-subdued);display:flex}.icon-wrap.svelte-kzcjhc{width:30px;margin-bottom:var(--spacing-lg)}@media (--screen-md){.wrap.svelte-kzcjhc{font-size:var(--text-lg)}}.hovered.svelte-kzcjhc{color:var(--color-accent)}div.svelte-ipfyu7{border-top:1px solid transparent;display:flex;max-height:100%;justify-content:center;gap:var(--spacing-sm);height:auto;align-items:flex-end;padding-bottom:var(--spacing-xl);color:var(--block-label-text-color);flex-shrink:0;width:95%}.show_border.svelte-ipfyu7{border-top:1px solid var(--block-border-color);margin-top:var(--spacing-xxl);box-shadow:var(--shadow-drop)}.source-selection.svelte-1jp3vgd{display:flex;align-items:center;justify-content:center;border-top:1px solid var(--border-color-primary);width:95%;bottom:0;left:0;right:0;margin-left:auto;margin-right:auto}.icon.svelte-1jp3vgd{width:22px;height:22px;margin:var(--spacing-lg) var(--spacing-xs);padding:var(--spacing-xs);color:var(--neutral-400);border-radius:var(--radius-md)}.selected.svelte-1jp3vgd{color:var(--color-accent)}.icon.svelte-1jp3vgd:hover,.icon.svelte-1jp3vgd:focus{color:var(--color-accent)}div.svelte-1m1obck{display:flex;position:relative;flex-direction:column}div.svelte-1m1obck>*,div.svelte-1m1obck>.form>*{width:var(--size-full)}.gap.svelte-1m1obck{gap:var(--layout-gap)}.hide.svelte-1m1obck{display:none}.compact.svelte-1m1obck>*,.compact.svelte-1m1obck .box{border-radius:0}.compact.svelte-1m1obck,.panel.svelte-1m1obck{border:solid var(--panel-border-width) var(--panel-border-color);border-radius:var(--container-radius);background:var(--panel-background-fill);padding:var(--spacing-lg)}@media (min-width: 640px){.modal-container.svelte-ra5mg6{max-width:640px}}@media (min-width: 768px){.modal-container.svelte-ra5mg6{max-width:768px}}@media (min-width: 1024px){.modal-container.svelte-ra5mg6{max-width:1024px}}@media (min-width: 1280px){.modal-container.svelte-ra5mg6{max-width:1280px}}@media (min-width: 1536px){.modal-container.svelte-ra5mg6{max-width:1536px}}.modal.svelte-ra5mg6{position:fixed;left:0;top:0;width:100%;height:100%;z-index:100;background-color:#000;background-color:#0006;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.modal-container.svelte-ra5mg6{padding:0 var(--size-8);margin:var(--size-8) auto;max-height:calc(100% - var(--size-8));overflow-y:hidden}.close.svelte-ra5mg6{display:flex;position:absolute;top:var(--block-label-margin);right:var(--block-label-margin);align-items:center;box-shadow:var(--shadow-drop);border:1px solid var(--border-color-primary);border-top:none;border-right:none;border-radius:var(--block-label-right-radius);background:var(--block-label-background-fill);padding:6px;height:24px;overflow:hidden;color:var(--block-label-text-color);font:var(--font);font-size:var(--button-small-text-size);cursor:pointer}.hide.svelte-ra5mg6{display:none}
 
1
+ .block.svelte-1t38q2d{position:relative;margin:0;box-shadow:var(--block-shadow);border-width:var(--block-border-width);border-color:var(--block-border-color);border-radius:var(--block-radius);background:var(--block-background-fill);width:100%;line-height:var(--line-sm)}.block.border_focus.svelte-1t38q2d{border-color:var(--color-accent)}.padded.svelte-1t38q2d{padding:var(--block-padding)}.hidden.svelte-1t38q2d{display:none}.hide-container.svelte-1t38q2d{margin:0;box-shadow:none;--block-border-width:0;background:transparent;padding:0;overflow:visible}div.svelte-1hnfib2{margin-bottom:var(--spacing-lg);color:var(--block-info-text-color);font-weight:var(--block-info-text-weight);font-size:var(--block-info-text-size);line-height:var(--line-sm)}span.has-info.svelte-22c38v{margin-bottom:var(--spacing-xs)}span.svelte-22c38v:not(.has-info){margin-bottom:var(--spacing-lg)}span.svelte-22c38v{display:inline-block;position:relative;z-index:var(--layer-4);border:solid var(--block-title-border-width) var(--block-title-border-color);border-radius:var(--block-title-radius);background:var(--block-title-background-fill);padding:var(--block-title-padding);color:var(--block-title-text-color);font-weight:var(--block-title-text-weight);font-size:var(--block-title-text-size);line-height:var(--line-sm)}.hide.svelte-22c38v{margin:0;height:0}label.svelte-9gxdi0{display:inline-flex;align-items:center;z-index:var(--layer-2);box-shadow:var(--block-label-shadow);border:var(--block-label-border-width) solid var(--border-color-primary);border-top:none;border-left:none;border-radius:var(--block-label-radius);background:var(--block-label-background-fill);padding:var(--block-label-padding);pointer-events:none;color:var(--block-label-text-color);font-weight:var(--block-label-text-weight);font-size:var(--block-label-text-size);line-height:var(--line-sm)}.gr-group label.svelte-9gxdi0{border-top-left-radius:0}label.float.svelte-9gxdi0{position:absolute;top:var(--block-label-margin);left:var(--block-label-margin)}label.svelte-9gxdi0:not(.float){position:static;margin-top:var(--block-label-margin);margin-left:var(--block-label-margin)}.hide.svelte-9gxdi0{height:0}span.svelte-9gxdi0{opacity:.8;margin-right:var(--size-2);width:calc(var(--block-label-text-size) - 1px);height:calc(var(--block-label-text-size) - 1px)}.hide-label.svelte-9gxdi0{box-shadow:none;border-width:0;background:transparent;overflow:visible}button.svelte-lpi64a{display:flex;justify-content:center;align-items:center;gap:1px;z-index:var(--layer-2);border-radius:var(--radius-sm);color:var(--block-label-text-color);border:1px solid transparent}button[disabled].svelte-lpi64a{opacity:.5;box-shadow:none}button[disabled].svelte-lpi64a:hover{cursor:not-allowed}.padded.svelte-lpi64a{padding:2px;background:var(--bg-color);box-shadow:var(--shadow-drop);border:1px solid var(--button-secondary-border-color)}button.svelte-lpi64a:hover,button.highlight.svelte-lpi64a{cursor:pointer;color:var(--color-accent)}.padded.svelte-lpi64a:hover{border:2px solid var(--button-secondary-border-color-hover);padding:1px;color:var(--block-label-text-color)}span.svelte-lpi64a{padding:0 1px;font-size:10px}div.svelte-lpi64a{padding:2px;display:flex;align-items:flex-end}.small.svelte-lpi64a{width:14px;height:14px}.large.svelte-lpi64a{width:22px;height:22px}.pending.svelte-lpi64a{animation:svelte-lpi64a-flash .5s infinite}@keyframes svelte-lpi64a-flash{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.transparent.svelte-lpi64a{background:transparent;border:none;box-shadow:none}.empty.svelte-3w3rth{display:flex;justify-content:center;align-items:center;margin-top:calc(0px - var(--size-6));height:var(--size-full)}.icon.svelte-3w3rth{opacity:.5;height:var(--size-5);color:var(--body-text-color)}.small.svelte-3w3rth{min-height:calc(var(--size-32) - 20px)}.large.svelte-3w3rth{min-height:calc(var(--size-64) - 20px)}.unpadded_box.svelte-3w3rth{margin-top:0}.small_parent.svelte-3w3rth{min-height:100%!important}.dropdown-arrow.svelte-145leq6{fill:currentColor}.wrap.svelte-kzcjhc{display:flex;flex-direction:column;justify-content:center;align-items:center;min-height:var(--size-60);color:var(--block-label-text-color);line-height:var(--line-md);height:100%;padding-top:var(--size-3)}.or.svelte-kzcjhc{color:var(--body-text-color-subdued);display:flex}.icon-wrap.svelte-kzcjhc{width:30px;margin-bottom:var(--spacing-lg)}@media (--screen-md){.wrap.svelte-kzcjhc{font-size:var(--text-lg)}}.hovered.svelte-kzcjhc{color:var(--color-accent)}div.svelte-ipfyu7{border-top:1px solid transparent;display:flex;max-height:100%;justify-content:center;gap:var(--spacing-sm);height:auto;align-items:flex-end;padding-bottom:var(--spacing-xl);color:var(--block-label-text-color);flex-shrink:0;width:95%}.show_border.svelte-ipfyu7{border-top:1px solid var(--block-border-color);margin-top:var(--spacing-xxl);box-shadow:var(--shadow-drop)}.source-selection.svelte-1jp3vgd{display:flex;align-items:center;justify-content:center;border-top:1px solid var(--border-color-primary);width:95%;bottom:0;left:0;right:0;margin-left:auto;margin-right:auto}.icon.svelte-1jp3vgd{width:22px;height:22px;margin:var(--spacing-lg) var(--spacing-xs);padding:var(--spacing-xs);color:var(--neutral-400);border-radius:var(--radius-md)}.selected.svelte-1jp3vgd{color:var(--color-accent)}.icon.svelte-1jp3vgd:hover,.icon.svelte-1jp3vgd:focus{color:var(--color-accent)}div.svelte-1m1obck{display:flex;position:relative;flex-direction:column}div.svelte-1m1obck>*,div.svelte-1m1obck>.form>*{width:var(--size-full)}.gap.svelte-1m1obck{gap:var(--layout-gap)}.hide.svelte-1m1obck{display:none}.compact.svelte-1m1obck>*,.compact.svelte-1m1obck .box{border-radius:0}.compact.svelte-1m1obck,.panel.svelte-1m1obck{border:solid var(--panel-border-width) var(--panel-border-color);border-radius:var(--container-radius);background:var(--panel-background-fill);padding:var(--spacing-lg)}@media (min-width: 640px){.modal-container.svelte-7knbu5{max-width:640px}}@media (min-width: 768px){.modal-container.svelte-7knbu5{max-width:768px}}@media (min-width: 1024px){.modal-container.svelte-7knbu5{max-width:1024px}}@media (min-width: 1280px){.modal-container.svelte-7knbu5{max-width:1280px}}@media (min-width: 1536px){.modal-container.svelte-7knbu5{max-width:1536px}}.modal.svelte-7knbu5{position:fixed;left:0;top:0;width:100%;height:100%;z-index:100;background-color:#000;background-color:#0006;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.modal-container.svelte-7knbu5{position:relative;padding:0 var(--size-8);margin:var(--size-8) auto;height:100%;max-height:calc(100% - var(--size-16));overflow-y:hidden}.close.svelte-7knbu5{display:flex;position:absolute;top:var(--block-label-margin);right:var(--block-label-margin);align-items:center;box-shadow:var(--shadow-drop);border:1px solid var(--border-color-primary);border-top:none;border-right:none;border-radius:var(--block-label-right-radius);background:var(--block-label-background-fill);padding:6px;height:24px;overflow:hidden;color:var(--block-label-text-color);font:var(--font);font-size:var(--button-small-text-size);cursor:pointer}.modal.svelte-7knbu5 .modal-block{max-height:100%;overflow-y:auto!important}.hide.svelte-7knbu5{display:none}
src/demo/space.py CHANGED
@@ -4,7 +4,7 @@ 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
 
10
  with gr.Blocks(
@@ -47,6 +47,7 @@ with gr.Blocks() as demo:
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],
@@ -54,8 +55,13 @@ with gr.Blocks() as demo:
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()
@@ -99,7 +105,7 @@ if __name__ == "__main__":
99
  })
100
  }
101
  })
102
-
103
  Object.entries(refs).forEach(([key, refs]) => {
104
  if (refs.length > 0) {
105
  const el = document.querySelector(`.${key}`);
 
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
 
10
  with gr.Blocks(
 
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
+ show_btn2 = gr.Button("Show Modal 2")
51
  gr.Examples(
52
  [["Text 1", "Text 2"], ["Text 3", "Text 4"]],
53
  inputs=[text_1, text_2],
 
55
  with gr.Tab("Tab 2"):
56
  gr.Markdown("This is tab 2")
57
  with Modal(visible=False) as modal:
58
+ for i in range(5):
59
+ gr.Markdown("Hello world!")
60
+ with Modal(visible=False) as modal2:
61
+ for i in range(100):
62
+ gr.Markdown("Hello world!")
63
  show_btn.click(lambda: Modal(visible=True), None, modal)
64
+ show_btn2.click(lambda: Modal(visible=True), None, modal2)
65
 
66
  if __name__ == "__main__":
67
  demo.launch()
 
105
  })
106
  }
107
  })
108
+
109
  Object.entries(refs).forEach(([key, refs]) => {
110
  if (refs.length > 0) {
111
  const el = document.querySelector(`.${key}`);
src/pyproject.toml CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
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,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", "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.3"
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", "backend/gradio_modal/templates"]
40
 
41
  [tool.hatch.build.targets.wheel]
42
  packages = ["/backend/gradio_modal"]