@gradio/multimodaltextbox 0.11.3 → 0.11.5

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,42 @@
1
1
  # @gradio/multimodaltextbox
2
2
 
3
+ ## 0.11.5
4
+
5
+ ### Fixes
6
+
7
+ - [#12789](https://github.com/gradio-app/gradio/pull/12789) [`af5e86f`](https://github.com/gradio-app/gradio/commit/af5e86f10d95cc71ee4cb950e455dbdc8e138983) - Migrate gr.MultimodalTextbox. Thanks @hannahblair!
8
+
9
+ ### Dependency updates
10
+
11
+ - @gradio/atoms@0.21.0
12
+ - @gradio/client@2.0.4
13
+ - @gradio/statustracker@0.12.3
14
+ - @gradio/image@0.25.2
15
+ - @gradio/upload@0.17.5
16
+ - @gradio/video@0.20.2
17
+ - @gradio/audio@0.22.2
18
+
19
+ ## 0.11.4
20
+
21
+ ### Fixes
22
+
23
+ - [#12800](https://github.com/gradio-app/gradio/pull/12800) [`7a1c321`](https://github.com/gradio-app/gradio/commit/7a1c321b6546ba05a353488f5133e8262c4a8a39) - Bump svelte/kit for security reasons. Thanks @freddyaboulton!
24
+ - [#12779](https://github.com/gradio-app/gradio/pull/12779) [`ea2d3e9`](https://github.com/gradio-app/gradio/commit/ea2d3e985a8b42d188e551f517c5825c00790628) - Migrate Audio + Upload + Atoms to Svelte 5. Thanks @dawoodkhan82!
25
+ - [#12795](https://github.com/gradio-app/gradio/pull/12795) [`184968a`](https://github.com/gradio-app/gradio/commit/184968aa13636b5afe78f8ae443cd7fc29635bfa) - Add fade effect to overflowing text. Thanks @hannahblair!
26
+ - [#12594](https://github.com/gradio-app/gradio/pull/12594) [`c2f0f19`](https://github.com/gradio-app/gradio/commit/c2f0f1949d453bc850fa65e5b140067008a83e22) - add conditional rendering for the upload button in multimodal textbox. Thanks @hannahblair!
27
+
28
+ ### Dependency updates
29
+
30
+ - @gradio/statustracker@0.12.2
31
+ - @gradio/atoms@0.20.1
32
+ - @gradio/utils@0.11.2
33
+ - @gradio/icons@0.15.1
34
+ - @gradio/upload@0.17.4
35
+ - @gradio/client@2.0.3
36
+ - @gradio/image@0.25.1
37
+ - @gradio/video@0.20.1
38
+ - @gradio/audio@0.22.1
39
+
3
40
  ## 0.11.3
4
41
 
5
42
  ### Fixes
package/Example.svelte CHANGED
@@ -1,17 +1,19 @@
1
1
  <script lang="ts">
2
- import { onMount } from "svelte";
3
2
  import { Image } from "@gradio/image/shared";
4
3
  import { Video } from "@gradio/video/shared";
5
4
  import type { FileData } from "@gradio/client";
6
5
 
7
- export let value: { text: string; files: FileData[] } = {
8
- text: "",
9
- files: []
10
- };
11
- export let type: "gallery" | "table";
12
- export let selected = false;
6
+ let {
7
+ value = { text: "", files: [] },
8
+ type,
9
+ selected = false
10
+ }: {
11
+ value?: { text: string; files: FileData[] };
12
+ type: "gallery" | "table";
13
+ selected?: boolean;
14
+ } = $props();
13
15
 
14
- let size: number;
16
+ let size = $state<number>(0);
15
17
  let el: HTMLDivElement;
16
18
 
17
19
  function set_styles(element: HTMLElement, el_width: number): void {
@@ -22,8 +24,10 @@
22
24
  element.style.whiteSpace = "unset";
23
25
  }
24
26
 
25
- onMount(() => {
26
- set_styles(el, size);
27
+ $effect(() => {
28
+ if (el && size) {
29
+ set_styles(el, size);
30
+ }
27
31
  });
28
32
  </script>
29
33
 
package/Index.svelte CHANGED
@@ -17,7 +17,7 @@
17
17
  MultimodalTextboxEvents
18
18
  } from "./types";
19
19
 
20
- let upload_promise = $state<Promise<any>>();
20
+ let upload_promise = $state<Promise<any> | null>(null);
21
21
 
22
22
  class MultimodalTextboxGradio extends Gradio<
23
23
  MultimodalTextboxEvents,
@@ -37,7 +37,7 @@
37
37
  let props = $props();
38
38
  const gradio = new MultimodalTextboxGradio(props);
39
39
 
40
- const value = $derived(gradio.props.value || { text: "", files: [] });
40
+ gradio.props.value = gradio.props.value ?? { text: "", files: [] };
41
41
 
42
42
  let dragging = $state<boolean>(false);
43
43
  let active_source = $state<"microphone" | null>(null);
@@ -135,7 +135,7 @@
135
135
 
136
136
  <MultimodalTextbox
137
137
  bind:upload_promise
138
- {value}
138
+ bind:value={gradio.props.value}
139
139
  value_is_output
140
140
  bind:dragging
141
141
  bind:active_source
@@ -160,24 +160,22 @@
160
160
  file_count={gradio.props.file_count}
161
161
  {sources_string}
162
162
  max_file_size={gradio.shared.max_file_size}
163
- on:change={(e) => (
164
- (gradio.props.value = e.detail),
165
- gradio.dispatch("change", gradio.props.value)
166
- )}
167
- on:input={() => gradio.dispatch("input")}
168
- on:submit={() => gradio.dispatch("submit")}
169
- on:stop={() => gradio.dispatch("stop")}
170
- on:blur={() => gradio.dispatch("blur")}
171
- on:select={(e) => gradio.dispatch("select", e.detail)}
172
- on:focus={() => gradio.dispatch("focus")}
173
- on:error={({ detail }) => {
163
+ onchange={(e) => {
164
+ gradio.props.value = e;
165
+ gradio.dispatch("change", gradio.props.value);
166
+ }}
167
+ oninput={() => gradio.dispatch("input")}
168
+ onsubmit={() => gradio.dispatch("submit")}
169
+ onstop={() => gradio.dispatch("stop")}
170
+ onblur={() => gradio.dispatch("blur")}
171
+ onselect={(e) => gradio.dispatch("select", e)}
172
+ onfocus={() => gradio.dispatch("focus")}
173
+ onerror={(detail) => {
174
174
  gradio.dispatch("error", detail);
175
175
  }}
176
- on:start_recording={() => gradio.dispatch("start_recording")}
177
- on:pause_recording={() => gradio.dispatch("pause_recording")}
178
- on:stop_recording={() => gradio.dispatch("stop_recording")}
179
- on:upload={(e) => gradio.dispatch("upload", e.detail)}
180
- on:clear={() => gradio.dispatch("clear")}
176
+ onstop_recording={() => gradio.dispatch("stop_recording")}
177
+ onupload={(e) => gradio.dispatch("upload", e)}
178
+ onclear={() => gradio.dispatch("clear")}
181
179
  disabled={!gradio.shared.interactive}
182
180
  upload={upload_fn}
183
181
  stream_handler={stream_handler_fn}
@@ -1,60 +1,63 @@
1
- <script>
2
- import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
1
+ <script module>
2
+ import { defineMeta } from "@storybook/addon-svelte-csf";
3
3
  import MultimodalTextbox from "./Index.svelte";
4
- </script>
4
+ import { wrapProps } from "../storybook/wrapProps";
5
5
 
6
- <Meta
7
- title="Components/MultimodalTextbox"
8
- component={MultimodalTextbox}
9
- argTypes={{
10
- label: {
11
- control: "text",
12
- description: "The textbox label",
13
- name: "label"
14
- },
15
- show_label: {
16
- options: [true, false],
17
- description: "Whether to show the label",
18
- control: { type: "boolean" },
19
- defaultValue: true
20
- },
21
- text_align: {
22
- options: ["left", "right"],
23
- description: "Whether to align the text left or right",
24
- control: { type: "select" },
25
- defaultValue: "left"
26
- },
27
- lines: {
28
- options: [1, 5, 10, 20],
29
- description: "The number of lines to display in the textbox",
30
- control: { type: "select" },
31
- defaultValue: 1
32
- },
33
- max_lines: {
34
- options: [1, 5, 10, 20],
35
- description:
36
- "The maximum number of lines to allow users to type in the textbox",
37
- control: { type: "select" },
38
- defaultValue: 1
39
- },
40
- rtl: {
41
- options: [true, false],
42
- description: "Whether to render right-to-left",
43
- control: { type: "boolean" },
44
- defaultValue: false
45
- },
46
- sources: {
47
- options: ["upload", "microphone"],
48
- description: "The sources to enable",
49
- control: { type: "select" },
50
- defaultValue: ["upload", "microphone"]
6
+ const cheetah = "/cheetah.jpg";
7
+
8
+ const { Story } = defineMeta({
9
+ title: "Components/MultimodalTextbox",
10
+ component: MultimodalTextbox,
11
+ argTypes: {
12
+ label: {
13
+ control: "text",
14
+ description: "The textbox label",
15
+ name: "label"
16
+ },
17
+ show_label: {
18
+ options: [true, false],
19
+ description: "Whether to show the label",
20
+ control: { type: "boolean" },
21
+ defaultValue: true
22
+ },
23
+ text_align: {
24
+ options: ["left", "right"],
25
+ description: "Whether to align the text left or right",
26
+ control: { type: "select" },
27
+ defaultValue: "left"
28
+ },
29
+ lines: {
30
+ options: [1, 5, 10, 20],
31
+ description: "The number of lines to display in the textbox",
32
+ control: { type: "select" },
33
+ defaultValue: 1
34
+ },
35
+ max_lines: {
36
+ options: [1, 5, 10, 20],
37
+ description:
38
+ "The maximum number of lines to allow users to type in the textbox",
39
+ control: { type: "select" },
40
+ defaultValue: 1
41
+ },
42
+ rtl: {
43
+ options: [true, false],
44
+ description: "Whether to render right-to-left",
45
+ control: { type: "boolean" },
46
+ defaultValue: false
47
+ },
48
+ sources: {
49
+ options: ["upload", "microphone"],
50
+ description: "The sources to enable",
51
+ control: { type: "select" },
52
+ defaultValue: ["upload", "microphone"]
53
+ }
51
54
  }
52
- }}
53
- />
55
+ });
56
+ </script>
54
57
 
55
- <Template let:args>
56
- <MultimodalTextbox {...args} />
57
- </Template>
58
+ {#snippet template(args)}
59
+ <MultimodalTextbox {...wrapProps(args)} />
60
+ {/snippet}
58
61
 
59
62
  <Story
60
63
  name="MultimodalTextbox with file and label"
@@ -63,43 +66,77 @@
63
66
  text: "sample text",
64
67
  files: [
65
68
  {
66
- path: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
67
- url: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
69
+ path: cheetah,
70
+ url: cheetah,
68
71
  orig_name: "cheetah.jpg"
69
72
  }
70
73
  ]
71
74
  },
72
75
  label: "My simple label",
73
- show_label: true
76
+ show_label: true,
77
+ sources: ["upload", "microphone"],
78
+ file_types: [],
79
+ lines: 1,
80
+ max_lines: 5
74
81
  }}
82
+ {template}
75
83
  />
76
84
  <Story
77
85
  name="MultimodalTextbox with 5 lines and max 5 lines"
78
- args={{ lines: 5, max_lines: 5 }}
86
+ args={{
87
+ lines: 5,
88
+ max_lines: 5,
89
+ sources: ["upload", "microphone"],
90
+ file_types: [],
91
+ value: { text: "", files: [] }
92
+ }}
93
+ {template}
94
+ />
95
+ <Story
96
+ name="Right aligned textbox"
97
+ args={{
98
+ text_align: "right",
99
+ sources: ["upload", "microphone"],
100
+ file_types: [],
101
+ lines: 1,
102
+ max_lines: 5,
103
+ value: { text: "", files: [] }
104
+ }}
105
+ {template}
79
106
  />
80
- <Story name="Right aligned textbox" args={{ text_align: "right" }} />
81
107
  <Story
82
108
  name="Single file upload"
83
109
  args={{
84
110
  file_count: "single",
85
111
  submit_btn: true,
112
+ sources: ["upload"],
113
+ file_types: [],
114
+ lines: 1,
115
+ max_lines: 5,
86
116
  value: {
87
117
  text: "sample text",
88
118
  files: [
89
119
  {
90
- path: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg"
120
+ path: cheetah,
121
+ url: cheetah,
122
+ orig_name: "cheetah.jpg"
91
123
  }
92
124
  ]
93
125
  }
94
126
  }}
127
+ {template}
95
128
  />
96
129
  <Story
97
130
  name="MultimodalTextbox with microphone input and right to left text"
98
131
  args={{
99
132
  label: "مرحبًا",
100
133
  sources: ["microphone"],
134
+ file_types: [],
101
135
  rtl: true,
102
136
  submit_btn: true,
137
+ lines: 1,
138
+ max_lines: 5,
103
139
  value: { text: "مرحبًا", files: [] }
104
140
  }}
141
+ {template}
105
142
  />
@@ -1,27 +1,31 @@
1
- <script>
2
- import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
1
+ <script module>
2
+ import { defineMeta } from "@storybook/addon-svelte-csf";
3
3
  import MultimodalTextbox from "./Example.svelte";
4
- </script>
5
-
6
- <Meta
7
- title="Components/MultimodalTextbox/Example"
8
- component={MultimodalTextbox}
9
- />
10
4
 
11
- <Template let:args>
12
- <MultimodalTextbox {...args} />
13
- </Template>
5
+ const { Story } = defineMeta({
6
+ title: "Components/MultimodalTextbox/Example",
7
+ component: MultimodalTextbox
8
+ });
9
+ </script>
14
10
 
15
11
  <Story
16
12
  name="Text value"
17
13
  args={{
18
14
  value: { text: "the quick brown fox", files: [] }
19
15
  }}
20
- />
16
+ >
17
+ {#snippet template(args)}
18
+ <MultimodalTextbox {...args} />
19
+ {/snippet}
20
+ </Story>
21
21
 
22
22
  <Story
23
23
  name="Empty Value"
24
24
  args={{
25
25
  value: { text: "", files: [] }
26
26
  }}
27
- />
27
+ >
28
+ {#snippet template(args)}
29
+ <MultimodalTextbox {...args} />
30
+ {/snippet}
31
+ </Story>
@@ -1,17 +1,19 @@
1
1
  <script lang="ts">
2
- import { onMount } from "svelte";
3
2
  import { Image } from "@gradio/image/shared";
4
3
  import { Video } from "@gradio/video/shared";
5
4
  import type { FileData } from "@gradio/client";
6
5
 
7
- export let value: { text: string; files: FileData[] } = {
8
- text: "",
9
- files: []
10
- };
11
- export let type: "gallery" | "table";
12
- export let selected = false;
6
+ let {
7
+ value = { text: "", files: [] },
8
+ type,
9
+ selected = false
10
+ }: {
11
+ value?: { text: string; files: FileData[] };
12
+ type: "gallery" | "table";
13
+ selected?: boolean;
14
+ } = $props();
13
15
 
14
- let size: number;
16
+ let size = $state<number>(0);
15
17
  let el: HTMLDivElement;
16
18
 
17
19
  function set_styles(element: HTMLElement, el_width: number): void {
@@ -22,8 +24,10 @@
22
24
  element.style.whiteSpace = "unset";
23
25
  }
24
26
 
25
- onMount(() => {
26
- set_styles(el, size);
27
+ $effect(() => {
28
+ if (el && size) {
29
+ set_styles(el, size);
30
+ }
27
31
  });
28
32
  </script>
29
33
 
@@ -1,26 +1,12 @@
1
1
  import type { FileData } from "@gradio/client";
2
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
- $$bindings?: Bindings;
5
- } & Exports;
6
- (internal: unknown, props: Props & {
7
- $$events?: Events;
8
- $$slots?: Slots;
9
- }): Exports & {
10
- $set?: any;
11
- $on?: any;
12
- };
13
- z_$$bindings?: Bindings;
14
- }
15
- declare const Example: $$__sveltets_2_IsomorphicComponent<{
2
+ type $$ComponentProps = {
16
3
  value?: {
17
4
  text: string;
18
5
  files: FileData[];
19
6
  };
20
7
  type: "gallery" | "table";
21
8
  selected?: boolean;
22
- }, {
23
- [evt: string]: CustomEvent<any>;
24
- }, {}, {}, string>;
25
- type Example = InstanceType<typeof Example>;
9
+ };
10
+ declare const Example: import("svelte").Component<$$ComponentProps, {}, "">;
11
+ type Example = ReturnType<typeof Example>;
26
12
  export default Example;
package/dist/Index.svelte CHANGED
@@ -17,7 +17,7 @@
17
17
  MultimodalTextboxEvents
18
18
  } from "./types";
19
19
 
20
- let upload_promise = $state<Promise<any>>();
20
+ let upload_promise = $state<Promise<any> | null>(null);
21
21
 
22
22
  class MultimodalTextboxGradio extends Gradio<
23
23
  MultimodalTextboxEvents,
@@ -37,7 +37,7 @@
37
37
  let props = $props();
38
38
  const gradio = new MultimodalTextboxGradio(props);
39
39
 
40
- const value = $derived(gradio.props.value || { text: "", files: [] });
40
+ gradio.props.value = gradio.props.value ?? { text: "", files: [] };
41
41
 
42
42
  let dragging = $state<boolean>(false);
43
43
  let active_source = $state<"microphone" | null>(null);
@@ -135,7 +135,7 @@
135
135
 
136
136
  <MultimodalTextbox
137
137
  bind:upload_promise
138
- {value}
138
+ bind:value={gradio.props.value}
139
139
  value_is_output
140
140
  bind:dragging
141
141
  bind:active_source
@@ -160,24 +160,22 @@
160
160
  file_count={gradio.props.file_count}
161
161
  {sources_string}
162
162
  max_file_size={gradio.shared.max_file_size}
163
- on:change={(e) => (
164
- (gradio.props.value = e.detail),
165
- gradio.dispatch("change", gradio.props.value)
166
- )}
167
- on:input={() => gradio.dispatch("input")}
168
- on:submit={() => gradio.dispatch("submit")}
169
- on:stop={() => gradio.dispatch("stop")}
170
- on:blur={() => gradio.dispatch("blur")}
171
- on:select={(e) => gradio.dispatch("select", e.detail)}
172
- on:focus={() => gradio.dispatch("focus")}
173
- on:error={({ detail }) => {
163
+ onchange={(e) => {
164
+ gradio.props.value = e;
165
+ gradio.dispatch("change", gradio.props.value);
166
+ }}
167
+ oninput={() => gradio.dispatch("input")}
168
+ onsubmit={() => gradio.dispatch("submit")}
169
+ onstop={() => gradio.dispatch("stop")}
170
+ onblur={() => gradio.dispatch("blur")}
171
+ onselect={(e) => gradio.dispatch("select", e)}
172
+ onfocus={() => gradio.dispatch("focus")}
173
+ onerror={(detail) => {
174
174
  gradio.dispatch("error", detail);
175
175
  }}
176
- on:start_recording={() => gradio.dispatch("start_recording")}
177
- on:pause_recording={() => gradio.dispatch("pause_recording")}
178
- on:stop_recording={() => gradio.dispatch("stop_recording")}
179
- on:upload={(e) => gradio.dispatch("upload", e.detail)}
180
- on:clear={() => gradio.dispatch("clear")}
176
+ onstop_recording={() => gradio.dispatch("stop_recording")}
177
+ onupload={(e) => gradio.dispatch("upload", e)}
178
+ onclear={() => gradio.dispatch("clear")}
181
179
  disabled={!gradio.shared.interactive}
182
180
  upload={upload_fn}
183
181
  stream_handler={stream_handler_fn}