@gradio/multimodaltextbox 0.10.22-dev.0 → 0.11.0
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 +57 -0
- package/Index.svelte +106 -114
- package/MultimodalTextbox.test.ts +20 -21
- package/README.md +1 -1
- package/dist/Example.svelte +27 -21
- package/dist/Example.svelte.d.ts +23 -21
- package/dist/Index.svelte +146 -111
- package/dist/Index.svelte.d.ts +3 -199
- package/dist/shared/MultimodalTextbox.svelte +860 -528
- package/dist/shared/MultimodalTextbox.svelte.d.ts +71 -67
- package/dist/types.d.ts +46 -0
- package/dist/types.js +1 -0
- package/package.json +12 -11
- package/shared/MultimodalTextbox.svelte +553 -300
- package/types.ts +42 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,61 @@
|
|
|
1
1
|
# @gradio/multimodaltextbox
|
|
2
|
+
## 0.11.0
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
- [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - remove_placeholder_type_here
|
|
7
|
+
- [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Clear Error statuses
|
|
8
|
+
- [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Improve gr.MultimodalTextbox in mobile
|
|
9
|
+
- [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Add minimal recording UI to gr.MultimodalTextbox
|
|
10
|
+
- [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Add back default values for labels
|
|
11
|
+
- [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Unit test fixes
|
|
12
|
+
- [#12438](https://github.com/gradio-app/gradio/pull/12438) [`25ffc03`](https://github.com/gradio-app/gradio/commit/25ffc0398f8feb43d817c02b2ab970c16de6d797) - Svelte5 migration and bugfix
|
|
13
|
+
|
|
14
|
+
### Dependencies
|
|
15
|
+
|
|
16
|
+
- @gradio/atoms@0.19.0
|
|
17
|
+
- @gradio/icons@0.15.0
|
|
18
|
+
- @gradio/statustracker@0.12.0
|
|
19
|
+
- @gradio/utils@0.10.3
|
|
20
|
+
- @gradio/upload@0.17.2
|
|
21
|
+
- @gradio/image@0.24.0
|
|
22
|
+
- @gradio/video@0.17.0
|
|
23
|
+
- @gradio/client@2.0.0
|
|
24
|
+
- @gradio/audio@0.20.0
|
|
25
|
+
|
|
26
|
+
## 0.11.0-dev.2
|
|
27
|
+
|
|
28
|
+
### Dependency updates
|
|
29
|
+
|
|
30
|
+
- @gradio/atoms@0.19.0-dev.1
|
|
31
|
+
- @gradio/client@2.0.0-dev.2
|
|
32
|
+
- @gradio/statustracker@0.12.0-dev.1
|
|
33
|
+
- @gradio/upload@0.17.2-dev.2
|
|
34
|
+
- @gradio/audio@0.20.0-dev.4
|
|
35
|
+
- @gradio/image@0.24.0-dev.2
|
|
36
|
+
- @gradio/video@0.17.0-dev.2
|
|
37
|
+
|
|
38
|
+
## 0.11.0-dev.1
|
|
39
|
+
|
|
40
|
+
### Features
|
|
41
|
+
|
|
42
|
+
- [#12088](https://github.com/gradio-app/gradio/pull/12088) [`199de34`](https://github.com/gradio-app/gradio/commit/199de3428291b799ae334474132f3d2ceef31e9d) - Improve gr.MultimodalTextbox in mobile. Thanks @hannahblair!
|
|
43
|
+
|
|
44
|
+
### Dependency updates
|
|
45
|
+
|
|
46
|
+
- @gradio/atoms@0.18.2-dev.0
|
|
47
|
+
- @gradio/upload@0.17.2-dev.1
|
|
48
|
+
- @gradio/utils@0.10.3-dev.0
|
|
49
|
+
- @gradio/image@0.23.2-dev.1
|
|
50
|
+
- @gradio/statustracker@0.12.0-dev.0
|
|
51
|
+
- @gradio/icons@0.15.0-dev.0
|
|
52
|
+
- @gradio/video@0.17.0-dev.1
|
|
53
|
+
|
|
54
|
+
## 0.10.22-dev.0
|
|
55
|
+
|
|
56
|
+
### Dependency updates
|
|
57
|
+
|
|
58
|
+
- @gradio/client@2.0.0-dev.1
|
|
2
59
|
|
|
3
60
|
## 0.10.22-dev.0
|
|
4
61
|
|
package/Index.svelte
CHANGED
|
@@ -6,84 +6,46 @@
|
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
8
|
<script lang="ts">
|
|
9
|
-
import
|
|
9
|
+
import { Gradio, type SelectData } from "@gradio/utils";
|
|
10
10
|
import MultimodalTextbox from "./shared/MultimodalTextbox.svelte";
|
|
11
11
|
import { Block } from "@gradio/atoms";
|
|
12
12
|
import { StatusTracker } from "@gradio/statustracker";
|
|
13
|
-
import
|
|
14
|
-
import type { FileData } from "@gradio/client";
|
|
15
|
-
import { onMount } from "svelte";
|
|
13
|
+
import { onMount, tick } from "svelte";
|
|
16
14
|
import type { WaveformOptions } from "../audio/shared/types";
|
|
17
|
-
import type {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
submit: never;
|
|
22
|
-
stop: never;
|
|
23
|
-
blur: never;
|
|
24
|
-
select: SelectData;
|
|
25
|
-
input: never;
|
|
26
|
-
focus: never;
|
|
27
|
-
error: string;
|
|
28
|
-
clear_status: LoadingStatus;
|
|
29
|
-
start_recording: never;
|
|
30
|
-
pause_recording: never;
|
|
31
|
-
stop_recording: never;
|
|
32
|
-
upload: FileData[] | FileData;
|
|
33
|
-
clear: undefined;
|
|
34
|
-
}>;
|
|
35
|
-
export let elem_id = "";
|
|
36
|
-
export let elem_classes: string[] = [];
|
|
37
|
-
export let visible: boolean | "hidden" = true;
|
|
38
|
-
export let value: { text: string; files: FileData[] } = {
|
|
39
|
-
text: "",
|
|
40
|
-
files: []
|
|
41
|
-
};
|
|
42
|
-
export let file_types: string[] | null = null;
|
|
43
|
-
export let lines: number;
|
|
44
|
-
export let placeholder = "";
|
|
45
|
-
export let label = "MultimodalTextbox";
|
|
46
|
-
export let info: string | undefined = undefined;
|
|
47
|
-
export let show_label: boolean;
|
|
48
|
-
export let max_lines: number;
|
|
49
|
-
export let scale: number | null = null;
|
|
50
|
-
export let min_width: number | undefined = undefined;
|
|
51
|
-
export let submit_btn: string | boolean | null = null;
|
|
52
|
-
export let stop_btn: string | boolean | null = null;
|
|
53
|
-
export let loading_status: LoadingStatus | undefined = undefined;
|
|
54
|
-
export let value_is_output = false;
|
|
55
|
-
export let rtl = false;
|
|
56
|
-
export let text_align: "left" | "right" | undefined = undefined;
|
|
57
|
-
export let autofocus = false;
|
|
58
|
-
export let autoscroll = true;
|
|
59
|
-
export let interactive: boolean;
|
|
60
|
-
export let root: string;
|
|
61
|
-
export let file_count: "single" | "multiple" | "directory";
|
|
62
|
-
export let max_plain_text_length: number;
|
|
63
|
-
export let sources: ["microphone" | "upload"] = ["upload"];
|
|
64
|
-
export let waveform_options: WaveformOptions = {};
|
|
65
|
-
export let html_attributes: InputHTMLAttributes | null = null;
|
|
66
|
-
|
|
67
|
-
let dragging: boolean;
|
|
68
|
-
let active_source: "microphone" | null = null;
|
|
69
|
-
let waveform_settings: Record<string, any>;
|
|
70
|
-
let color_accent = "darkorange";
|
|
15
|
+
import type {
|
|
16
|
+
MultimodalTextboxProps,
|
|
17
|
+
MultimodalTextboxEvents
|
|
18
|
+
} from "./types";
|
|
71
19
|
|
|
72
|
-
|
|
73
|
-
color_accent = getComputedStyle(document?.documentElement).getPropertyValue(
|
|
74
|
-
"--color-accent"
|
|
75
|
-
);
|
|
76
|
-
set_trim_region_colour();
|
|
77
|
-
waveform_settings.waveColor = waveform_options.waveform_color || "#9ca3af";
|
|
78
|
-
waveform_settings.progressColor =
|
|
79
|
-
waveform_options.waveform_progress_color || color_accent;
|
|
80
|
-
waveform_settings.mediaControls = waveform_options.show_controls;
|
|
81
|
-
waveform_settings.sampleRate = waveform_options.sample_rate || 44100;
|
|
82
|
-
});
|
|
20
|
+
let upload_promise = $state<Promise<any>>();
|
|
83
21
|
|
|
84
|
-
|
|
85
|
-
|
|
22
|
+
class MultimodalTextboxGradio extends Gradio<
|
|
23
|
+
MultimodalTextboxEvents,
|
|
24
|
+
MultimodalTextboxProps
|
|
25
|
+
> {
|
|
26
|
+
async get_data() {
|
|
27
|
+
if (upload_promise) {
|
|
28
|
+
await upload_promise;
|
|
29
|
+
await tick();
|
|
30
|
+
}
|
|
31
|
+
const data = await super.get_data();
|
|
32
|
+
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let props = $props();
|
|
38
|
+
const gradio = new MultimodalTextboxGradio(props);
|
|
86
39
|
|
|
40
|
+
const value = $derived(gradio.props.value || { text: "", files: [] });
|
|
41
|
+
|
|
42
|
+
let dragging = $state<boolean>(false);
|
|
43
|
+
let active_source = $state<"microphone" | null>(null);
|
|
44
|
+
|
|
45
|
+
let color_accent = "darkorange";
|
|
46
|
+
|
|
47
|
+
const waveform_settings = {
|
|
48
|
+
height: 50,
|
|
87
49
|
barWidth: 2,
|
|
88
50
|
barGap: 3,
|
|
89
51
|
cursorWidth: 2,
|
|
@@ -92,11 +54,30 @@
|
|
|
92
54
|
barRadius: 10,
|
|
93
55
|
dragToSeek: true,
|
|
94
56
|
normalize: true,
|
|
95
|
-
minPxPerSec: 20
|
|
57
|
+
minPxPerSec: 20,
|
|
58
|
+
waveColor: "",
|
|
59
|
+
progressColor: "",
|
|
60
|
+
mediaControls: false as boolean | undefined,
|
|
61
|
+
sampleRate: 44100
|
|
96
62
|
};
|
|
97
63
|
|
|
64
|
+
onMount(() => {
|
|
65
|
+
color_accent = getComputedStyle(document?.documentElement).getPropertyValue(
|
|
66
|
+
"--color-accent"
|
|
67
|
+
);
|
|
68
|
+
set_trim_region_colour();
|
|
69
|
+
waveform_settings.waveColor =
|
|
70
|
+
gradio.props?.waveform_options?.waveform_color || "#9ca3af";
|
|
71
|
+
waveform_settings.progressColor =
|
|
72
|
+
gradio.props?.waveform_options?.waveform_progress_color || color_accent;
|
|
73
|
+
waveform_settings.mediaControls =
|
|
74
|
+
gradio.props?.waveform_options?.show_controls;
|
|
75
|
+
waveform_settings.sampleRate =
|
|
76
|
+
gradio.props?.waveform_options?.sample_rate || 44100;
|
|
77
|
+
});
|
|
78
|
+
|
|
98
79
|
const trim_region_settings = {
|
|
99
|
-
color: waveform_options
|
|
80
|
+
color: gradio.props?.waveform_options?.trim_region_color,
|
|
100
81
|
drag: true,
|
|
101
82
|
resize: true
|
|
102
83
|
};
|
|
@@ -111,66 +92,77 @@
|
|
|
111
92
|
// Create const references to the callbacks so that afterUpdate in child is not called on every prop change
|
|
112
93
|
// in the DOM. See https://github.com/gradio-app/gradio/issues/11933
|
|
113
94
|
// 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);
|
|
95
|
+
const upload_fn = (...args: Parameters<typeof gradio.shared.client.upload>) =>
|
|
96
|
+
gradio.shared.client.upload(...args);
|
|
116
97
|
const i18n = (s: string | null | undefined): string => gradio.i18n(s);
|
|
117
98
|
const stream_handler_fn = (
|
|
118
|
-
...args: Parameters<typeof gradio.client.stream>
|
|
119
|
-
): EventSource => gradio.client.stream(...args);
|
|
99
|
+
...args: Parameters<typeof gradio.shared.client.stream>
|
|
100
|
+
): EventSource => gradio.shared.client.stream(...args);
|
|
120
101
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
102
|
+
let sources_string = $derived(
|
|
103
|
+
gradio.props.sources.join(",") as
|
|
104
|
+
| "upload"
|
|
105
|
+
| "upload,microphone"
|
|
106
|
+
| "microphone"
|
|
107
|
+
| "microphone,upload"
|
|
108
|
+
);
|
|
126
109
|
|
|
127
|
-
|
|
110
|
+
let file_types_string = $derived.by(
|
|
111
|
+
() => (gradio.props.file_types || []).join(",") || null
|
|
112
|
+
);
|
|
128
113
|
</script>
|
|
129
114
|
|
|
130
115
|
<Block
|
|
131
|
-
{visible}
|
|
132
|
-
{elem_id}
|
|
133
|
-
elem_classes={[...elem_classes, "multimodal-textbox"]}
|
|
134
|
-
{scale}
|
|
135
|
-
{min_width}
|
|
116
|
+
visible={gradio.shared.visible}
|
|
117
|
+
elem_id={gradio.shared.elem_id}
|
|
118
|
+
elem_classes={[...(gradio.shared.elem_classes || []), "multimodal-textbox"]}
|
|
119
|
+
scale={gradio.shared.scale}
|
|
120
|
+
min_width={gradio.shared.min_width}
|
|
136
121
|
allow_overflow={false}
|
|
137
122
|
padding={false}
|
|
138
123
|
border_mode={dragging ? "focus" : "base"}
|
|
139
124
|
>
|
|
140
|
-
{#if loading_status}
|
|
125
|
+
{#if gradio.shared.loading_status}
|
|
141
126
|
<StatusTracker
|
|
142
|
-
autoscroll={gradio.autoscroll}
|
|
127
|
+
autoscroll={gradio.shared.autoscroll}
|
|
143
128
|
i18n={gradio.i18n}
|
|
144
|
-
{...loading_status}
|
|
145
|
-
|
|
129
|
+
{...gradio.shared.loading_status}
|
|
130
|
+
on_clear_status={() =>
|
|
131
|
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
|
146
132
|
/>
|
|
147
133
|
{/if}
|
|
148
134
|
|
|
149
135
|
<MultimodalTextbox
|
|
150
|
-
bind:
|
|
151
|
-
|
|
136
|
+
bind:upload_promise
|
|
137
|
+
{value}
|
|
138
|
+
value_is_output
|
|
152
139
|
bind:dragging
|
|
153
140
|
bind:active_source
|
|
154
141
|
{file_types_string}
|
|
155
|
-
{root}
|
|
156
|
-
{label}
|
|
157
|
-
{info}
|
|
158
|
-
{show_label}
|
|
159
|
-
{lines}
|
|
160
|
-
{rtl}
|
|
161
|
-
{text_align}
|
|
162
|
-
{waveform_settings}
|
|
142
|
+
root={gradio.shared.root}
|
|
143
|
+
label={gradio.shared.label || "MultimodalTextbox"}
|
|
144
|
+
info={gradio.props.info}
|
|
145
|
+
show_label={gradio.shared.show_label}
|
|
146
|
+
lines={gradio.props.lines}
|
|
147
|
+
rtl={gradio.props.rtl}
|
|
148
|
+
text_align={gradio.props.text_align}
|
|
149
|
+
waveform_settings={waveform_settings as WaveformOptions}
|
|
163
150
|
{i18n}
|
|
164
|
-
max_lines={!max_lines
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
{
|
|
168
|
-
{
|
|
169
|
-
{
|
|
170
|
-
{
|
|
151
|
+
max_lines={!gradio.props.max_lines
|
|
152
|
+
? gradio.props.lines + 1
|
|
153
|
+
: gradio.props.max_lines}
|
|
154
|
+
placeholder={gradio.props.placeholder}
|
|
155
|
+
submit_btn={gradio.props.submit_btn}
|
|
156
|
+
stop_btn={gradio.props.stop_btn}
|
|
157
|
+
autofocus={gradio.props.autofocus}
|
|
158
|
+
autoscroll={gradio.shared.autoscroll}
|
|
159
|
+
file_count={gradio.props.file_count}
|
|
171
160
|
{sources_string}
|
|
172
|
-
max_file_size={gradio.max_file_size}
|
|
173
|
-
on:change={() =>
|
|
161
|
+
max_file_size={gradio.shared.max_file_size}
|
|
162
|
+
on:change={(e) => (
|
|
163
|
+
(gradio.props.value = e.detail),
|
|
164
|
+
gradio.dispatch("change", gradio.props.value)
|
|
165
|
+
)}
|
|
174
166
|
on:input={() => gradio.dispatch("input")}
|
|
175
167
|
on:submit={() => gradio.dispatch("submit")}
|
|
176
168
|
on:stop={() => gradio.dispatch("stop")}
|
|
@@ -185,10 +177,10 @@
|
|
|
185
177
|
on:stop_recording={() => gradio.dispatch("stop_recording")}
|
|
186
178
|
on:upload={(e) => gradio.dispatch("upload", e.detail)}
|
|
187
179
|
on:clear={() => gradio.dispatch("clear")}
|
|
188
|
-
disabled={!interactive}
|
|
180
|
+
disabled={!gradio.shared.interactive}
|
|
189
181
|
upload={upload_fn}
|
|
190
182
|
stream_handler={stream_handler_fn}
|
|
191
|
-
{max_plain_text_length}
|
|
192
|
-
{html_attributes}
|
|
183
|
+
max_plain_text_length={gradio.props.max_plain_text_length}
|
|
184
|
+
html_attributes={gradio.props.html_attributes}
|
|
193
185
|
/>
|
|
194
186
|
</Block>
|
|
@@ -28,7 +28,8 @@ describe("MultimodalTextbox", () => {
|
|
|
28
28
|
value: { text: "hello world", files: [] },
|
|
29
29
|
label: "Textbox",
|
|
30
30
|
interactive: false,
|
|
31
|
-
root: ""
|
|
31
|
+
root: "",
|
|
32
|
+
sources: []
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
const item: HTMLInputElement = getByDisplayValue(
|
|
@@ -38,19 +39,17 @@ describe("MultimodalTextbox", () => {
|
|
|
38
39
|
});
|
|
39
40
|
|
|
40
41
|
test("changing the text should update the value", async () => {
|
|
41
|
-
const {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
);
|
|
42
|
+
const { getByDisplayValue, listen } = await render(MultimodalTextbox, {
|
|
43
|
+
show_label: true,
|
|
44
|
+
max_lines: 10,
|
|
45
|
+
loading_status,
|
|
46
|
+
lines: 1,
|
|
47
|
+
value: { text: "hi ", files: [] },
|
|
48
|
+
label: "MultimodalTextbox",
|
|
49
|
+
interactive: true,
|
|
50
|
+
root: "",
|
|
51
|
+
sources: []
|
|
52
|
+
});
|
|
54
53
|
|
|
55
54
|
const item: HTMLInputElement = getByDisplayValue("hi") as HTMLInputElement;
|
|
56
55
|
|
|
@@ -60,14 +59,13 @@ describe("MultimodalTextbox", () => {
|
|
|
60
59
|
await event.keyboard("some text");
|
|
61
60
|
|
|
62
61
|
assert.equal(item.value, "hi some text");
|
|
63
|
-
assert.equal(component.value.text, "hi some text");
|
|
64
62
|
assert.equal(mock.callCount, 9);
|
|
65
63
|
assert.equal(mock.calls[8][0].detail.data.text, "hi some text");
|
|
66
64
|
assert.equal(mock.calls[8][0].detail.data.files.length, 0);
|
|
67
65
|
});
|
|
68
66
|
|
|
69
67
|
test("submitting should clear mic_audio", async () => {
|
|
70
|
-
const {
|
|
68
|
+
const { getByTestId, listen } = await render(MultimodalTextbox, {
|
|
71
69
|
show_label: true,
|
|
72
70
|
max_lines: 10,
|
|
73
71
|
loading_status,
|
|
@@ -76,12 +74,13 @@ describe("MultimodalTextbox", () => {
|
|
|
76
74
|
label: "MultimodalTextbox",
|
|
77
75
|
interactive: true,
|
|
78
76
|
root: "",
|
|
79
|
-
sources: ["microphone"]
|
|
77
|
+
sources: ["microphone"],
|
|
78
|
+
submit_btn: true
|
|
80
79
|
});
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
await
|
|
85
|
-
assert.equal(
|
|
81
|
+
const mock = listen("submit");
|
|
82
|
+
const submitButton = getByTestId("submit-button");
|
|
83
|
+
await event.click(submitButton);
|
|
84
|
+
assert.equal(mock.callCount, 1);
|
|
86
85
|
});
|
|
87
86
|
});
|
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ BaseMultimodalTextbox
|
|
|
11
11
|
export let value = "";
|
|
12
12
|
export let value_is_output = false;
|
|
13
13
|
export let lines = 1;
|
|
14
|
-
export let placeholder = "
|
|
14
|
+
export let placeholder = "";
|
|
15
15
|
export let label: string;
|
|
16
16
|
export let info: string | undefined = undefined;
|
|
17
17
|
export let disabled = false;
|
package/dist/Example.svelte
CHANGED
|
@@ -1,24 +1,30 @@
|
|
|
1
|
-
<script
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
let
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from "svelte";
|
|
3
|
+
import { Image } from "@gradio/image/shared";
|
|
4
|
+
import { Video } from "@gradio/video/shared";
|
|
5
|
+
import type { FileData } from "@gradio/client";
|
|
6
|
+
|
|
7
|
+
export let value: { text: string; files: FileData[] } = {
|
|
8
|
+
text: "",
|
|
9
|
+
files: []
|
|
10
|
+
};
|
|
11
|
+
export let type: "gallery" | "table";
|
|
12
|
+
export let selected = false;
|
|
13
|
+
|
|
14
|
+
let size: number;
|
|
15
|
+
let el: HTMLDivElement;
|
|
16
|
+
|
|
17
|
+
function set_styles(element: HTMLElement, el_width: number): void {
|
|
18
|
+
element.style.setProperty(
|
|
19
|
+
"--local-text-width",
|
|
20
|
+
`${el_width && el_width < 150 ? el_width : 200}px`
|
|
21
|
+
);
|
|
22
|
+
element.style.whiteSpace = "unset";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
onMount(() => {
|
|
26
|
+
set_styles(el, size);
|
|
27
|
+
});
|
|
22
28
|
</script>
|
|
23
29
|
|
|
24
30
|
<div
|
package/dist/Example.svelte.d.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
import type { FileData } from "@gradio/client";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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;
|
|
11
12
|
};
|
|
12
|
-
|
|
13
|
-
[evt: string]: CustomEvent<any>;
|
|
14
|
-
};
|
|
15
|
-
slots: {};
|
|
16
|
-
exports?: {} | undefined;
|
|
17
|
-
bindings?: string | undefined;
|
|
18
|
-
};
|
|
19
|
-
export type ExampleProps = typeof __propDef.props;
|
|
20
|
-
export type ExampleEvents = typeof __propDef.events;
|
|
21
|
-
export type ExampleSlots = typeof __propDef.slots;
|
|
22
|
-
export default class Example extends SvelteComponent<ExampleProps, ExampleEvents, ExampleSlots> {
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
23
14
|
}
|
|
24
|
-
|
|
15
|
+
declare const Example: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
value?: {
|
|
17
|
+
text: string;
|
|
18
|
+
files: FileData[];
|
|
19
|
+
};
|
|
20
|
+
type: "gallery" | "table";
|
|
21
|
+
selected?: boolean;
|
|
22
|
+
}, {
|
|
23
|
+
[evt: string]: CustomEvent<any>;
|
|
24
|
+
}, {}, {}, string>;
|
|
25
|
+
type Example = InstanceType<typeof Example>;
|
|
26
|
+
export default Example;
|