@gradio/multimodaltextbox 0.10.19 → 0.10.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @gradio/multimodaltextbox
2
2
 
3
+ ## 0.10.20
4
+
5
+ ### Fixes
6
+
7
+ - [#11937](https://github.com/gradio-app/gradio/pull/11937) [`1b97ed7`](https://github.com/gradio-app/gradio/commit/1b97ed760c6adc6f7eef613904b90a0bfd0e9970) - Fix bug where multimodaltextbox would focus on any app update. Thanks @freddyaboulton!
8
+
9
+ ### Dependency updates
10
+
11
+ - @gradio/image@0.23.1
12
+ - @gradio/upload@0.17.1
13
+ - @gradio/atoms@0.18.1
14
+
3
15
  ## 0.10.19
4
16
 
5
17
  ### Fixes
package/Index.svelte CHANGED
@@ -107,6 +107,22 @@
107
107
  trim_region_settings.color || color_accent
108
108
  );
109
109
  }
110
+
111
+ // Create const references to the callbacks so that afterUpdate in child is not called on every prop change
112
+ // in the DOM. See https://github.com/gradio-app/gradio/issues/11933
113
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
114
+ const upload_fn = (...args: Parameters<typeof gradio.client.upload>) =>
115
+ gradio.client.upload(...args);
116
+ const i18n = (s: string | null | undefined): string => gradio.i18n(s);
117
+ const stream_handler_fn = (
118
+ ...args: Parameters<typeof gradio.client.stream>
119
+ ): EventSource => gradio.client.stream(...args);
120
+
121
+ $: sources_string = sources.join(",") as
122
+ | "upload"
123
+ | "upload,microphone"
124
+ | "microphone"
125
+ | "microphone,upload";
110
126
  </script>
111
127
 
112
128
  <Block
@@ -142,7 +158,7 @@
142
158
  {rtl}
143
159
  {text_align}
144
160
  {waveform_settings}
145
- i18n={gradio.i18n}
161
+ {i18n}
146
162
  max_lines={!max_lines ? lines + 1 : max_lines}
147
163
  {placeholder}
148
164
  {submit_btn}
@@ -150,7 +166,7 @@
150
166
  {autofocus}
151
167
  {autoscroll}
152
168
  {file_count}
153
- {sources}
169
+ {sources_string}
154
170
  max_file_size={gradio.max_file_size}
155
171
  on:change={() => gradio.dispatch("change", value)}
156
172
  on:input={() => gradio.dispatch("input")}
@@ -168,8 +184,8 @@
168
184
  on:upload={(e) => gradio.dispatch("upload", e.detail)}
169
185
  on:clear={() => gradio.dispatch("clear")}
170
186
  disabled={!interactive}
171
- upload={(...args) => gradio.client.upload(...args)}
172
- stream_handler={(...args) => gradio.client.stream(...args)}
187
+ upload={upload_fn}
188
+ stream_handler={stream_handler_fn}
173
189
  {max_plain_text_length}
174
190
  {html_attributes}
175
191
  />
package/dist/Index.svelte CHANGED
@@ -77,6 +77,10 @@ function set_trim_region_colour() {
77
77
  trim_region_settings.color || color_accent
78
78
  );
79
79
  }
80
+ const upload_fn = (...args) => gradio.client.upload(...args);
81
+ const i18n = (s) => gradio.i18n(s);
82
+ const stream_handler_fn = (...args) => gradio.client.stream(...args);
83
+ $: sources_string = sources.join(",");
80
84
  </script>
81
85
 
82
86
  <Block
@@ -112,7 +116,7 @@ function set_trim_region_colour() {
112
116
  {rtl}
113
117
  {text_align}
114
118
  {waveform_settings}
115
- i18n={gradio.i18n}
119
+ {i18n}
116
120
  max_lines={!max_lines ? lines + 1 : max_lines}
117
121
  {placeholder}
118
122
  {submit_btn}
@@ -120,7 +124,7 @@ function set_trim_region_colour() {
120
124
  {autofocus}
121
125
  {autoscroll}
122
126
  {file_count}
123
- {sources}
127
+ {sources_string}
124
128
  max_file_size={gradio.max_file_size}
125
129
  on:change={() => gradio.dispatch("change", value)}
126
130
  on:input={() => gradio.dispatch("input")}
@@ -138,8 +142,8 @@ function set_trim_region_colour() {
138
142
  on:upload={(e) => gradio.dispatch("upload", e.detail)}
139
143
  on:clear={() => gradio.dispatch("clear")}
140
144
  disabled={!interactive}
141
- upload={(...args) => gradio.client.upload(...args)}
142
- stream_handler={(...args) => gradio.client.stream(...args)}
145
+ upload={upload_fn}
146
+ stream_handler={stream_handler_fn}
143
147
  {max_plain_text_length}
144
148
  {html_attributes}
145
149
  />
@@ -50,7 +50,7 @@ export let waveform_settings;
50
50
  export let waveform_options = {
51
51
  show_recording_waveform: true
52
52
  };
53
- export let sources = ["upload"];
53
+ export let sources_string = "upload";
54
54
  export let active_source = null;
55
55
  export let html_attributes = null;
56
56
  let upload_component;
@@ -62,6 +62,7 @@ export let dragging = false;
62
62
  let uploading = false;
63
63
  let oldValue = value?.text ?? "";
64
64
  let recording = false;
65
+ $: sources = sources_string.split(",").map((s) => s.trim()).filter((s) => s === "upload" || s === "microphone");
65
66
  $: dispatch("drag", dragging);
66
67
  let mic_audio = null;
67
68
  let full_container;
@@ -91,15 +92,15 @@ onMount(() => {
91
92
  el.focus();
92
93
  }
93
94
  });
94
- afterUpdate(() => {
95
+ const after_update = () => {
95
96
  if (can_scroll && autoscroll) {
96
97
  scroll();
97
98
  }
98
- if (autofocus && el !== null) {
99
+ if (autofocus && el) {
99
100
  el.focus();
100
101
  }
101
- value_is_output = false;
102
- });
102
+ };
103
+ afterUpdate(after_update);
103
104
  function handle_select(event) {
104
105
  const target = event.target;
105
106
  const text = target.value;
@@ -33,7 +33,7 @@ declare const __propDef: {
33
33
  max_plain_text_length?: number;
34
34
  waveform_settings: Record<string, any>;
35
35
  waveform_options?: any;
36
- sources?: ["microphone" | "upload"];
36
+ sources_string?: "upload" | "upload,microphone" | "microphone" | "microphone,upload";
37
37
  active_source?: "microphone" | null;
38
38
  html_attributes?: InputHTMLAttributes | null;
39
39
  dragging?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/multimodaltextbox",
3
- "version": "0.10.19",
3
+ "version": "0.10.20",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -22,14 +22,14 @@
22
22
  "./package.json": "./package.json"
23
23
  },
24
24
  "dependencies": {
25
- "@gradio/atoms": "^0.18.0",
26
- "@gradio/statustracker": "^0.11.1",
27
- "@gradio/utils": "^0.10.2",
28
- "@gradio/image": "^0.23.0",
25
+ "@gradio/atoms": "^0.18.1",
29
26
  "@gradio/icons": "^0.14.0",
27
+ "@gradio/utils": "^0.10.2",
28
+ "@gradio/upload": "^0.17.1",
29
+ "@gradio/image": "^0.23.1",
30
+ "@gradio/statustracker": "^0.11.1",
30
31
  "@gradio/video": "^0.16.0",
31
- "@gradio/client": "^1.19.0",
32
- "@gradio/upload": "^0.17.0"
32
+ "@gradio/client": "^1.19.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@gradio/preview": "^0.14.0"
@@ -58,7 +58,11 @@
58
58
  export let waveform_options: WaveformOptions = {
59
59
  show_recording_waveform: true
60
60
  };
61
- export let sources: ["microphone" | "upload"] = ["upload"];
61
+ export let sources_string:
62
+ | "upload"
63
+ | "upload,microphone"
64
+ | "microphone"
65
+ | "microphone,upload" = "upload";
62
66
  export let active_source: "microphone" | null = null;
63
67
  export let html_attributes: InputHTMLAttributes | null = null;
64
68
 
@@ -72,6 +76,14 @@
72
76
  // value can be null in multimodalchatinterface when loading a deep link
73
77
  let oldValue = value?.text ?? "";
74
78
  let recording = false;
79
+
80
+ $: sources = sources_string
81
+ .split(",")
82
+ .map((s) => s.trim())
83
+ .filter((s) => s === "upload" || s === "microphone") as (
84
+ | "upload"
85
+ | "microphone"
86
+ )[];
75
87
  $: dispatch("drag", dragging);
76
88
  let mic_audio: FileData | null = null;
77
89
 
@@ -126,15 +138,16 @@
126
138
  }
127
139
  });
128
140
 
129
- afterUpdate(() => {
141
+ const after_update = (): void => {
130
142
  if (can_scroll && autoscroll) {
131
143
  scroll();
132
144
  }
133
- if (autofocus && el !== null) {
145
+ if (autofocus && el) {
134
146
  el.focus();
135
147
  }
136
- value_is_output = false;
137
- });
148
+ };
149
+
150
+ afterUpdate(after_update);
138
151
 
139
152
  function handle_select(event: Event): void {
140
153
  const target: HTMLTextAreaElement | HTMLInputElement = event.target as