abidlabs HF staff commited on
Commit
f57a544
1 Parent(s): 3e6eb1c

Upload folder using huggingface_hub

Browse files
.gitignore ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ .eggs/
2
+ dist/
3
+ *.pyc
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+ __tmp/*
8
+ *.pyi
9
+ node_modules
README.md CHANGED
@@ -1,17 +1,251 @@
1
 
2
- ---
3
- tags: [gradio-custom-component,machine learning,reproducibility,visualization,gradio,gradio-template-SimpleTextbox]
4
- title: gradio_rich_textbox V0.4.2
5
- colorFrom: indigo
6
- colorTo: purple
7
- sdk: docker
8
- pinned: false
9
- license: apache-2.0
10
- ---
11
 
 
12
 
13
- # Name: gradio_rich_textbox
14
 
15
- Description: Gradio custom component for rich text input
 
 
16
 
17
- Install with: pip install gradio_rich_textbox
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ # `gradio_rich_textbox`
3
+ <a href="https://pypi.org/project/gradio_rich_textbox/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_rich_textbox"></a>
 
 
 
 
 
 
 
4
 
5
+ Gradio custom component for rich text input
6
 
7
+ ## Installation
8
 
9
+ ```bash
10
+ pip install gradio_rich_textbox
11
+ ```
12
 
13
+ ## Usage
14
+
15
+ ```python
16
+
17
+ import gradio as gr
18
+ from gradio_rich_textbox import RichTextbox
19
+
20
+
21
+ example = RichTextbox().example_inputs()
22
+
23
+ demo = gr.Interface(
24
+ lambda x:x,
25
+ RichTextbox(), # interactive version of your component
26
+ RichTextbox(), # static version of your component
27
+ examples=[[example]], # uncomment this line to view the "example version" of your component
28
+ )
29
+
30
+
31
+ if __name__ == "__main__":
32
+ demo.launch()
33
+
34
+ ```
35
+
36
+ ## `RichTextbox`
37
+
38
+ ### Initialization
39
+
40
+ <table>
41
+ <thead>
42
+ <tr>
43
+ <th align="left">name</th>
44
+ <th align="left" style="width: 25%;">type</th>
45
+ <th align="left">default</th>
46
+ <th align="left">description</th>
47
+ </tr>
48
+ </thead>
49
+ <tbody>
50
+ <tr>
51
+ <td align="left"><code>value</code></td>
52
+ <td align="left" style="width: 25%;">
53
+
54
+ ```python
55
+ typing.Union[str, typing.Callable, NoneType][
56
+ str, Callable, None
57
+ ]
58
+ ```
59
+
60
+ </td>
61
+ <td align="left"><code>""</code></td>
62
+ <td align="left">default text to provide in textbox. If callable, the function will be called whenever the app loads to set the initial value of the component.</td>
63
+ </tr>
64
+
65
+ <tr>
66
+ <td align="left"><code>placeholder</code></td>
67
+ <td align="left" style="width: 25%;">
68
+
69
+ ```python
70
+ str | None
71
+ ```
72
+
73
+ </td>
74
+ <td align="left"><code>None</code></td>
75
+ <td align="left">placeholder hint to provide behind textbox.</td>
76
+ </tr>
77
+
78
+ <tr>
79
+ <td align="left"><code>label</code></td>
80
+ <td align="left" style="width: 25%;">
81
+
82
+ ```python
83
+ str | None
84
+ ```
85
+
86
+ </td>
87
+ <td align="left"><code>None</code></td>
88
+ <td align="left">component name in interface.</td>
89
+ </tr>
90
+
91
+ <tr>
92
+ <td align="left"><code>every</code></td>
93
+ <td align="left" style="width: 25%;">
94
+
95
+ ```python
96
+ float | None
97
+ ```
98
+
99
+ </td>
100
+ <td align="left"><code>None</code></td>
101
+ <td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
102
+ </tr>
103
+
104
+ <tr>
105
+ <td align="left"><code>show_label</code></td>
106
+ <td align="left" style="width: 25%;">
107
+
108
+ ```python
109
+ bool | None
110
+ ```
111
+
112
+ </td>
113
+ <td align="left"><code>None</code></td>
114
+ <td align="left">if True, will display label.</td>
115
+ </tr>
116
+
117
+ <tr>
118
+ <td align="left"><code>scale</code></td>
119
+ <td align="left" style="width: 25%;">
120
+
121
+ ```python
122
+ int | None
123
+ ```
124
+
125
+ </td>
126
+ <td align="left"><code>None</code></td>
127
+ <td align="left">relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.</td>
128
+ </tr>
129
+
130
+ <tr>
131
+ <td align="left"><code>min_width</code></td>
132
+ <td align="left" style="width: 25%;">
133
+
134
+ ```python
135
+ int
136
+ ```
137
+
138
+ </td>
139
+ <td align="left"><code>160</code></td>
140
+ <td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
141
+ </tr>
142
+
143
+ <tr>
144
+ <td align="left"><code>interactive</code></td>
145
+ <td align="left" style="width: 25%;">
146
+
147
+ ```python
148
+ bool | None
149
+ ```
150
+
151
+ </td>
152
+ <td align="left"><code>None</code></td>
153
+ <td align="left">if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.</td>
154
+ </tr>
155
+
156
+ <tr>
157
+ <td align="left"><code>visible</code></td>
158
+ <td align="left" style="width: 25%;">
159
+
160
+ ```python
161
+ bool
162
+ ```
163
+
164
+ </td>
165
+ <td align="left"><code>True</code></td>
166
+ <td align="left">If False, component will be hidden.</td>
167
+ </tr>
168
+
169
+ <tr>
170
+ <td align="left"><code>rtl</code></td>
171
+ <td align="left" style="width: 25%;">
172
+
173
+ ```python
174
+ bool
175
+ ```
176
+
177
+ </td>
178
+ <td align="left"><code>False</code></td>
179
+ <td align="left">If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.</td>
180
+ </tr>
181
+
182
+ <tr>
183
+ <td align="left"><code>elem_id</code></td>
184
+ <td align="left" style="width: 25%;">
185
+
186
+ ```python
187
+ str | None
188
+ ```
189
+
190
+ </td>
191
+ <td align="left"><code>None</code></td>
192
+ <td align="left">An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
193
+ </tr>
194
+
195
+ <tr>
196
+ <td align="left"><code>elem_classes</code></td>
197
+ <td align="left" style="width: 25%;">
198
+
199
+ ```python
200
+ list[str] | str | None
201
+ ```
202
+
203
+ </td>
204
+ <td align="left"><code>None</code></td>
205
+ <td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
206
+ </tr>
207
+
208
+ <tr>
209
+ <td align="left"><code>render</code></td>
210
+ <td align="left" style="width: 25%;">
211
+
212
+ ```python
213
+ bool
214
+ ```
215
+
216
+ </td>
217
+ <td align="left"><code>True</code></td>
218
+ <td align="left">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.</td>
219
+ </tr>
220
+ </tbody></table>
221
+
222
+
223
+ ### Events
224
+
225
+ | name | description |
226
+ |:-----|:------------|
227
+ | `change` | Triggered when the value of the RichTextbox changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
228
+ | `input` | This listener is triggered when the user changes the value of the RichTextbox. |
229
+ | `submit` | This listener is triggered when the user presses the Enter key while the RichTextbox is focused. |
230
+
231
+
232
+
233
+ ### User function
234
+
235
+ The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
236
+
237
+ - When used as an Input, the component only impacts the input signature of the user function.
238
+ - When used as an output, the component only impacts the return signature of the user function.
239
+
240
+ The code snippet below is accurate in cases where the component is used as both an input and an output.
241
+
242
+ - **As output:** Is passed, text.
243
+ - **As input:** Should return, function output to postprocess.
244
+
245
+ ```python
246
+ def predict(
247
+ value: str | None
248
+ ) -> str | None:
249
+ return value
250
+ ```
251
+
space.py CHANGED
@@ -3,8 +3,8 @@ import gradio as gr
3
  from app import demo as app
4
  import os
5
 
6
- _docs = {'RichTextbox': {'description': 'Creates a very simple textbox for user to enter string input or display string output.', 'members': {'__init__': {'value': {'type': 'str | Callable | None', 'default': '""', 'description': 'default text to provide in textbox. If callable, the function will be called whenever the app loads to set the initial value of the component.'}, 'placeholder': {'type': 'str | None', 'default': 'None', 'description': 'placeholder hint to provide behind textbox.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'component name in interface.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'rtl': {'type': 'bool', 'default': 'False', 'description': 'If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.'}, 'elem_id': {'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 list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, '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': {'y': {'type': 'str | None', 'description': 'function output to postprocess.'}, 'value': {'type': 'str | None', 'description': 'function output to postprocess.'}}, 'preprocess': {'return': {'type': 'str | None', 'description': 'text'}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the RichTextbox changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'input': {'type': None, 'default': None, 'description': 'This listener is triggered when the user changes the value of the RichTextbox.'}, 'submit': {'type': None, 'default': None, 'description': 'This listener is triggered when the user presses the Enter key while the RichTextbox is focused.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'RichTextbox': []}}}
7
-
8
  abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
 
10
  with gr.Blocks(
@@ -81,8 +81,8 @@ if __name__ == "__main__":
81
 
82
  The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
83
 
84
- - When used as an Input, the component only impacts the input signature of the user function.
85
- - When used as an output, the component only impacts the return signature of the user function.
86
 
87
  The code snippet below is accurate in cases where the component is used as both an input and an output.
88
 
@@ -118,7 +118,7 @@ def predict(
118
  })
119
  }
120
  })
121
-
122
  Object.entries(refs).forEach(([key, refs]) => {
123
  if (refs.length > 0) {
124
  const el = document.querySelector(`.${key}`);
 
3
  from app import demo as app
4
  import os
5
 
6
+ _docs = {'RichTextbox': {'description': 'Creates a very simple textbox for user to enter string input or display string output.', 'members': {'__init__': {'value': {'type': 'typing.Union[str, typing.Callable, NoneType][\n str, Callable, None\n]', 'default': '""', 'description': 'default text to provide in textbox. If callable, the function will be called whenever the app loads to set the initial value of the component.'}, 'placeholder': {'type': 'str | None', 'default': 'None', 'description': 'placeholder hint to provide behind textbox.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'component name in interface.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'rtl': {'type': 'bool', 'default': 'False', 'description': 'If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.'}, 'elem_id': {'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 list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, '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': {'y': {'type': 'str | None', 'description': 'function output to postprocess.'}, 'value': {'type': 'str | None', 'description': 'function output to postprocess.'}}, 'preprocess': {'return': {'type': 'str | None', 'description': 'text'}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the RichTextbox changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'input': {'type': None, 'default': None, 'description': 'This listener is triggered when the user changes the value of the RichTextbox.'}, 'submit': {'type': None, 'default': None, 'description': 'This listener is triggered when the user presses the Enter key while the RichTextbox is focused.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'RichTextbox': []}}}
7
+
8
  abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
 
10
  with gr.Blocks(
 
81
 
82
  The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
83
 
84
+ - When used as an Input, the component only impacts the input signature of the user function.
85
+ - When used as an output, the component only impacts the return signature of the user function.
86
 
87
  The code snippet below is accurate in cases where the component is used as both an input and an output.
88
 
 
118
  })
119
  }
120
  })
121
+
122
  Object.entries(refs).forEach(([key, refs]) => {
123
  if (refs.length > 0) {
124
  const el = document.querySelector(`.${key}`);
src/README.md CHANGED
@@ -5,8 +5,8 @@
5
  Gradio custom component for rich text input
6
 
7
  ## Installation
8
-
9
- ```bash
10
  pip install gradio_rich_textbox
11
  ```
12
 
@@ -52,7 +52,9 @@ if __name__ == "__main__":
52
  <td align="left" style="width: 25%;">
53
 
54
  ```python
55
- str | Callable | None
 
 
56
  ```
57
 
58
  </td>
@@ -232,8 +234,8 @@ bool
232
 
233
  The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
234
 
235
- - When used as an Input, the component only impacts the input signature of the user function.
236
- - When used as an output, the component only impacts the return signature of the user function.
237
 
238
  The code snippet below is accurate in cases where the component is used as both an input and an output.
239
 
 
5
  Gradio custom component for rich text input
6
 
7
  ## Installation
8
+
9
+ ```bash
10
  pip install gradio_rich_textbox
11
  ```
12
 
 
52
  <td align="left" style="width: 25%;">
53
 
54
  ```python
55
+ typing.Union[str, typing.Callable, NoneType][
56
+ str, Callable, None
57
+ ]
58
  ```
59
 
60
  </td>
 
234
 
235
  The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
236
 
237
+ - When used as an Input, the component only impacts the input signature of the user function.
238
+ - When used as an output, the component only impacts the return signature of the user function.
239
 
240
  The code snippet below is accurate in cases where the component is used as both an input and an output.
241
 
src/backend/gradio_rich_textbox/templates/component/index.js CHANGED
The diff for this file is too large to render. See raw diff
 
src/backend/gradio_rich_textbox/templates/component/style.css CHANGED
The diff for this file is too large to render. See raw diff
 
src/backend/gradio_rich_textbox/templates/example/index.js CHANGED
@@ -1,110 +1,125 @@
1
  const {
2
  SvelteComponent: y,
3
  add_iframe_resize_listener: b,
4
- add_render_callback: v,
5
- append: m,
6
- attr: h,
7
- binding_callbacks: p,
8
- detach: w,
9
- element: z,
10
- init: k,
11
- insert: E,
 
 
 
12
  noop: f,
13
- safe_not_equal: S,
14
- set_data: q,
15
- text: C,
16
  toggle_class: _
17
- } = window.__gradio__svelte__internal, { onMount: M } = window.__gradio__svelte__internal;
18
- function P(t) {
19
- let e, s, r;
20
  return {
21
  c() {
22
- e = z("div"), s = C(
23
  /*value*/
24
- t[0]
25
- ), h(e, "class", "svelte-84cxb8"), v(() => (
 
 
 
 
 
 
 
 
 
 
 
 
26
  /*div_elementresize_handler*/
27
- t[5].call(e)
28
  )), _(
29
  e,
30
  "table",
31
  /*type*/
32
- t[1] === "table"
33
  ), _(
34
  e,
35
  "gallery",
36
  /*type*/
37
- t[1] === "gallery"
38
  ), _(
39
  e,
40
  "selected",
41
  /*selected*/
42
- t[2]
43
  );
44
  },
45
- m(l, i) {
46
- E(l, e, i), m(e, s), r = b(
47
  e,
48
  /*div_elementresize_handler*/
49
- t[5].bind(e)
50
- ), t[6](e);
51
  },
52
- p(l, [i]) {
53
- i & /*value*/
54
- 1 && q(
55
- s,
56
  /*value*/
57
- l[0]
58
- ), i & /*type*/
59
  2 && _(
60
  e,
61
  "table",
62
  /*type*/
63
- l[1] === "table"
64
- ), i & /*type*/
65
  2 && _(
66
  e,
67
  "gallery",
68
  /*type*/
69
- l[1] === "gallery"
70
- ), i & /*selected*/
71
  4 && _(
72
  e,
73
  "selected",
74
  /*selected*/
75
- l[2]
76
  );
77
  },
78
  i: f,
79
  o: f,
80
- d(l) {
81
- l && w(e), r(), t[6](null);
82
  }
83
  };
84
  }
85
- function W(t, e, s) {
86
- let { value: r } = e, { type: l } = e, { selected: i = !1 } = e, c, a;
87
- function u(n, d) {
88
- !n || !d || (a.style.setProperty("--local-text-width", `${d < 150 ? d : 200}px`), s(4, a.style.whiteSpace = "unset", a));
89
  }
90
- M(() => {
91
- u(a, c);
92
  });
93
- function o() {
94
- c = this.clientWidth, s(3, c);
95
  }
96
- function g(n) {
97
- p[n ? "unshift" : "push"](() => {
98
- a = n, s(4, a);
99
  });
100
  }
101
- return t.$$set = (n) => {
102
- "value" in n && s(0, r = n.value), "type" in n && s(1, l = n.type), "selected" in n && s(2, i = n.selected);
103
- }, [r, l, i, c, a, o, g];
104
  }
105
  class j extends y {
106
  constructor(e) {
107
- super(), k(this, e, W, P, S, { value: 0, type: 1, selected: 2 });
108
  }
109
  }
110
  export {
 
1
  const {
2
  SvelteComponent: y,
3
  add_iframe_resize_listener: b,
4
+ add_render_callback: m,
5
+ append_hydration: v,
6
+ attr: w,
7
+ binding_callbacks: z,
8
+ children: k,
9
+ claim_element: p,
10
+ claim_text: E,
11
+ detach: o,
12
+ element: S,
13
+ init: q,
14
+ insert_hydration: C,
15
  noop: f,
16
+ safe_not_equal: D,
17
+ set_data: I,
18
+ text: M,
19
  toggle_class: _
20
+ } = window.__gradio__svelte__internal, { onMount: P } = window.__gradio__svelte__internal;
21
+ function V(l) {
22
+ let e, i, r;
23
  return {
24
  c() {
25
+ e = S("div"), i = M(
26
  /*value*/
27
+ l[0]
28
+ ), this.h();
29
+ },
30
+ l(t) {
31
+ e = p(t, "DIV", { class: !0 });
32
+ var n = k(e);
33
+ i = E(
34
+ n,
35
+ /*value*/
36
+ l[0]
37
+ ), n.forEach(o), this.h();
38
+ },
39
+ h() {
40
+ w(e, "class", "svelte-84cxb8"), m(() => (
41
  /*div_elementresize_handler*/
42
+ l[5].call(e)
43
  )), _(
44
  e,
45
  "table",
46
  /*type*/
47
+ l[1] === "table"
48
  ), _(
49
  e,
50
  "gallery",
51
  /*type*/
52
+ l[1] === "gallery"
53
  ), _(
54
  e,
55
  "selected",
56
  /*selected*/
57
+ l[2]
58
  );
59
  },
60
+ m(t, n) {
61
+ C(t, e, n), v(e, i), r = b(
62
  e,
63
  /*div_elementresize_handler*/
64
+ l[5].bind(e)
65
+ ), l[6](e);
66
  },
67
+ p(t, [n]) {
68
+ n & /*value*/
69
+ 1 && I(
70
+ i,
71
  /*value*/
72
+ t[0]
73
+ ), n & /*type*/
74
  2 && _(
75
  e,
76
  "table",
77
  /*type*/
78
+ t[1] === "table"
79
+ ), n & /*type*/
80
  2 && _(
81
  e,
82
  "gallery",
83
  /*type*/
84
+ t[1] === "gallery"
85
+ ), n & /*selected*/
86
  4 && _(
87
  e,
88
  "selected",
89
  /*selected*/
90
+ t[2]
91
  );
92
  },
93
  i: f,
94
  o: f,
95
+ d(t) {
96
+ t && o(e), r(), l[6](null);
97
  }
98
  };
99
  }
100
+ function W(l, e, i) {
101
+ let { value: r } = e, { type: t } = e, { selected: n = !1 } = e, d, a;
102
+ function u(s, c) {
103
+ !s || !c || (a.style.setProperty("--local-text-width", `${c < 150 ? c : 200}px`), i(4, a.style.whiteSpace = "unset", a));
104
  }
105
+ P(() => {
106
+ u(a, d);
107
  });
108
+ function h() {
109
+ d = this.clientWidth, i(3, d);
110
  }
111
+ function g(s) {
112
+ z[s ? "unshift" : "push"](() => {
113
+ a = s, i(4, a);
114
  });
115
  }
116
+ return l.$$set = (s) => {
117
+ "value" in s && i(0, r = s.value), "type" in s && i(1, t = s.type), "selected" in s && i(2, n = s.selected);
118
+ }, [r, t, n, d, a, h, g];
119
  }
120
  class j extends y {
121
  constructor(e) {
122
+ super(), q(this, e, W, V, D, { value: 0, type: 1, selected: 2 });
123
  }
124
  }
125
  export {
src/demo/space.py CHANGED
@@ -3,8 +3,8 @@ import gradio as gr
3
  from app import demo as app
4
  import os
5
 
6
- _docs = {'RichTextbox': {'description': 'Creates a very simple textbox for user to enter string input or display string output.', 'members': {'__init__': {'value': {'type': 'str | Callable | None', 'default': '""', 'description': 'default text to provide in textbox. If callable, the function will be called whenever the app loads to set the initial value of the component.'}, 'placeholder': {'type': 'str | None', 'default': 'None', 'description': 'placeholder hint to provide behind textbox.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'component name in interface.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'rtl': {'type': 'bool', 'default': 'False', 'description': 'If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.'}, 'elem_id': {'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 list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, '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': {'y': {'type': 'str | None', 'description': 'function output to postprocess.'}, 'value': {'type': 'str | None', 'description': 'function output to postprocess.'}}, 'preprocess': {'return': {'type': 'str | None', 'description': 'text'}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the RichTextbox changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'input': {'type': None, 'default': None, 'description': 'This listener is triggered when the user changes the value of the RichTextbox.'}, 'submit': {'type': None, 'default': None, 'description': 'This listener is triggered when the user presses the Enter key while the RichTextbox is focused.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'RichTextbox': []}}}
7
-
8
  abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
 
10
  with gr.Blocks(
@@ -81,8 +81,8 @@ if __name__ == "__main__":
81
 
82
  The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
83
 
84
- - When used as an Input, the component only impacts the input signature of the user function.
85
- - When used as an output, the component only impacts the return signature of the user function.
86
 
87
  The code snippet below is accurate in cases where the component is used as both an input and an output.
88
 
@@ -118,7 +118,7 @@ def predict(
118
  })
119
  }
120
  })
121
-
122
  Object.entries(refs).forEach(([key, refs]) => {
123
  if (refs.length > 0) {
124
  const el = document.querySelector(`.${key}`);
 
3
  from app import demo as app
4
  import os
5
 
6
+ _docs = {'RichTextbox': {'description': 'Creates a very simple textbox for user to enter string input or display string output.', 'members': {'__init__': {'value': {'type': 'typing.Union[str, typing.Callable, NoneType][\n str, Callable, None\n]', 'default': '""', 'description': 'default text to provide in textbox. If callable, the function will be called whenever the app loads to set the initial value of the component.'}, 'placeholder': {'type': 'str | None', 'default': 'None', 'description': 'placeholder hint to provide behind textbox.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'component name in interface.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. Queue must be enabled. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative width compared to adjacent Components in a Row. For example, if Component A has scale=2, and Component B has scale=1, A will be twice as wide as B. Should be an integer.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'interactive': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will be rendered as an editable textbox; if False, editing will be disabled. If not provided, this is inferred based on whether the component is used as an input or output.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'rtl': {'type': 'bool', 'default': 'False', 'description': 'If True and `type` is "text", sets the direction of the text to right-to-left (cursor appears on the left of the text). Default is False, which renders cursor on the right.'}, 'elem_id': {'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 list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, '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': {'y': {'type': 'str | None', 'description': 'function output to postprocess.'}, 'value': {'type': 'str | None', 'description': 'function output to postprocess.'}}, 'preprocess': {'return': {'type': 'str | None', 'description': 'text'}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the RichTextbox changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}, 'input': {'type': None, 'default': None, 'description': 'This listener is triggered when the user changes the value of the RichTextbox.'}, 'submit': {'type': None, 'default': None, 'description': 'This listener is triggered when the user presses the Enter key while the RichTextbox is focused.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'RichTextbox': []}}}
7
+
8
  abs_path = os.path.join(os.path.dirname(__file__), "css.css")
9
 
10
  with gr.Blocks(
 
81
 
82
  The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
83
 
84
+ - When used as an Input, the component only impacts the input signature of the user function.
85
+ - When used as an output, the component only impacts the return signature of the user function.
86
 
87
  The code snippet below is accurate in cases where the component is used as both an input and an output.
88
 
 
118
  })
119
  }
120
  })
121
+
122
  Object.entries(refs).forEach(([key, refs]) => {
123
  if (refs.length > 0) {
124
  const el = document.querySelector(`.${key}`);
src/frontend/package-lock.json CHANGED
The diff for this file is too large to render. See raw diff
 
src/frontend/package.json CHANGED
@@ -8,14 +8,21 @@
8
  "private": false,
9
  "main_changeset": true,
10
  "exports": {
11
- ".": "./Index.svelte",
12
- "./example": "./Example.svelte",
 
 
 
 
13
  "./package.json": "./package.json"
14
  },
15
  "dependencies": {
16
- "@gradio/atoms": "0.2.0-beta.5",
17
- "@gradio/icons": "0.2.0-beta.2",
18
- "@gradio/statustracker": "0.3.0-beta.7",
19
- "@gradio/utils": "0.2.0-beta.5"
 
 
 
20
  }
21
- }
 
8
  "private": false,
9
  "main_changeset": true,
10
  "exports": {
11
+ ".": {
12
+ "gradio": "./Index.svelte"
13
+ },
14
+ "./example": {
15
+ "gradio": "./Example.svelte"
16
+ },
17
  "./package.json": "./package.json"
18
  },
19
  "dependencies": {
20
+ "@gradio/atoms": "0.9.2",
21
+ "@gradio/icons": "0.8.0",
22
+ "@gradio/statustracker": "0.9.1",
23
+ "@gradio/utils": "0.7.0"
24
+ },
25
+ "devDependencies": {
26
+ "@gradio/preview": "^0.12.0"
27
  }
28
+ }
src/pyproject.toml CHANGED
@@ -8,7 +8,7 @@ build-backend = "hatchling.build"
8
 
9
  [project]
10
  name = "gradio_rich_textbox"
11
- version = "0.4.2"
12
  description = "Gradio custom component for rich text input"
13
  readme = "README.md"
14
  license = "Apache-2.0"
@@ -23,7 +23,7 @@ keywords = [
23
  "gradio-template-SimpleTextbox"
24
  ]
25
  # Add dependencies here
26
- dependencies = ["gradio>=4.0,<5.0"]
27
  classifiers = [
28
  'Development Status :: 3 - Alpha',
29
  'License :: OSI Approved :: Apache Software License',
 
8
 
9
  [project]
10
  name = "gradio_rich_textbox"
11
+ version = "0.4.3"
12
  description = "Gradio custom component for rich text input"
13
  readme = "README.md"
14
  license = "Apache-2.0"
 
23
  "gradio-template-SimpleTextbox"
24
  ]
25
  # Add dependencies here
26
+ dependencies = ["gradio>=4.0,<6.0"]
27
  classifiers = [
28
  'Development Status :: 3 - Alpha',
29
  'License :: OSI Approved :: Apache Software License',