@gradio/code 0.15.1-dev.0 → 0.16.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 +40 -0
- package/Index.svelte +45 -59
- package/dist/Example.svelte +11 -9
- package/dist/Example.svelte.d.ts +20 -18
- package/dist/Index.svelte +63 -61
- package/dist/Index.svelte.d.ts +3 -42
- package/dist/shared/Code.svelte +281 -225
- package/dist/shared/Code.svelte.d.ts +36 -33
- package/dist/shared/Copy.svelte +27 -22
- package/dist/shared/Copy.svelte.d.ts +19 -16
- package/dist/shared/Download.svelte +54 -45
- package/dist/shared/Download.svelte.d.ts +20 -17
- package/dist/shared/Widgets.svelte +7 -5
- package/dist/shared/Widgets.svelte.d.ts +19 -17
- package/dist/types.d.ts +16 -0
- package/dist/types.js +1 -0
- package/package.json +22 -22
- package/shared/Code.svelte +22 -5
- package/types.ts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,44 @@
|
|
|
1
1
|
# @gradio/code
|
|
2
|
+
## 0.16.0
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
- [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Clear Error statuses
|
|
7
|
+
- [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Fix various event issues
|
|
8
|
+
- [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Add back default values for labels
|
|
9
|
+
- [#12438](https://github.com/gradio-app/gradio/pull/12438) [`25ffc03`](https://github.com/gradio-app/gradio/commit/25ffc0398f8feb43d817c02b2ab970c16de6d797) - Svelte5 migration and bugfix
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
- @gradio/atoms@0.19.0
|
|
14
|
+
- @gradio/icons@0.15.0
|
|
15
|
+
- @gradio/statustracker@0.12.0
|
|
16
|
+
- @gradio/upload@0.17.2
|
|
17
|
+
- @gradio/utils@0.10.3
|
|
18
|
+
|
|
19
|
+
## 0.16.0-dev.3
|
|
20
|
+
|
|
21
|
+
### Dependency updates
|
|
22
|
+
|
|
23
|
+
- @gradio/atoms@0.19.0-dev.1
|
|
24
|
+
- @gradio/statustracker@0.12.0-dev.1
|
|
25
|
+
- @gradio/upload@0.17.2-dev.2
|
|
26
|
+
|
|
27
|
+
## 0.16.0-dev.2
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
- [#12357](https://github.com/gradio-app/gradio/pull/12357) [`c9cf634`](https://github.com/gradio-app/gradio/commit/c9cf634a9cd34b4adadde1a6a98d60faf732639a) - Fix various event issues. Thanks @pngwn!
|
|
32
|
+
|
|
33
|
+
## 0.15.1-dev.1
|
|
34
|
+
|
|
35
|
+
### Dependency updates
|
|
36
|
+
|
|
37
|
+
- @gradio/atoms@0.18.2-dev.0
|
|
38
|
+
- @gradio/upload@0.17.2-dev.1
|
|
39
|
+
- @gradio/utils@0.10.3-dev.0
|
|
40
|
+
- @gradio/statustracker@0.12.0-dev.0
|
|
41
|
+
- @gradio/icons@0.15.0-dev.0
|
|
2
42
|
|
|
3
43
|
## 0.15.1-dev.0
|
|
4
44
|
|
package/Index.svelte
CHANGED
|
@@ -7,97 +7,83 @@
|
|
|
7
7
|
</script>
|
|
8
8
|
|
|
9
9
|
<script lang="ts">
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
import type { LoadingStatus } from "@gradio/statustracker";
|
|
10
|
+
import { Gradio } from "@gradio/utils";
|
|
11
|
+
import type { CodeProps, CodeEvents } from "./types";
|
|
12
|
+
import { StatusTracker } from "@gradio/statustracker";
|
|
14
13
|
|
|
15
14
|
import Code from "./shared/Code.svelte";
|
|
16
15
|
import Widget from "./shared/Widgets.svelte";
|
|
17
|
-
import { StatusTracker } from "@gradio/statustracker";
|
|
18
16
|
import { Block, BlockLabel, Empty } from "@gradio/atoms";
|
|
19
17
|
import { Code as CodeIcon } from "@gradio/icons";
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
input: never;
|
|
24
|
-
blur: never;
|
|
25
|
-
focus: never;
|
|
26
|
-
clear_status: LoadingStatus;
|
|
27
|
-
}>;
|
|
28
|
-
export let value = "";
|
|
29
|
-
export let value_is_output = false;
|
|
30
|
-
export let language = "";
|
|
31
|
-
export let lines = 5;
|
|
32
|
-
export let max_lines: number | undefined = undefined;
|
|
33
|
-
export let elem_id = "";
|
|
34
|
-
export let elem_classes: string[] = [];
|
|
35
|
-
export let visible: boolean | "hidden" = true;
|
|
36
|
-
export let label = gradio.i18n("code.code");
|
|
37
|
-
export let show_label = true;
|
|
38
|
-
export let loading_status: LoadingStatus;
|
|
39
|
-
export let scale: number | null = null;
|
|
40
|
-
export let min_width: number | undefined = undefined;
|
|
41
|
-
export let wrap_lines = false;
|
|
42
|
-
export let show_line_numbers = true;
|
|
43
|
-
export let autocomplete = false;
|
|
19
|
+
const props = $props();
|
|
20
|
+
const gradio = new Gradio<CodeEvents, CodeProps>(props);
|
|
44
21
|
|
|
45
|
-
|
|
22
|
+
let dark_mode = gradio.shared.theme === "dark";
|
|
46
23
|
|
|
47
|
-
let
|
|
24
|
+
let label = $derived(gradio.shared.label || gradio.i18n("code.code"));
|
|
25
|
+
let old_value = $state(gradio.props.value);
|
|
26
|
+
let first_change = true;
|
|
48
27
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
28
|
+
$effect(() => {
|
|
29
|
+
if (first_change) {
|
|
30
|
+
first_change = false;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (old_value != gradio.props.value) {
|
|
34
|
+
old_value = gradio.props.value;
|
|
35
|
+
gradio.dispatch("change");
|
|
53
36
|
}
|
|
54
|
-
}
|
|
55
|
-
afterUpdate(() => {
|
|
56
|
-
value_is_output = false;
|
|
57
37
|
});
|
|
58
|
-
$: value, handle_change();
|
|
59
38
|
</script>
|
|
60
39
|
|
|
61
40
|
<Block
|
|
62
|
-
height={max_lines && "fit-content"}
|
|
41
|
+
height={gradio.props.max_lines && "fit-content"}
|
|
63
42
|
variant={"solid"}
|
|
64
43
|
padding={false}
|
|
65
|
-
{elem_id}
|
|
66
|
-
{elem_classes}
|
|
67
|
-
{visible}
|
|
68
|
-
{scale}
|
|
69
|
-
{min_width}
|
|
44
|
+
elem_id={gradio.shared.elem_id}
|
|
45
|
+
elem_classes={gradio.shared.elem_classes}
|
|
46
|
+
visible={gradio.shared.visible}
|
|
47
|
+
scale={gradio.shared.scale}
|
|
48
|
+
min_width={gradio.shared.min_width}
|
|
70
49
|
>
|
|
71
50
|
<StatusTracker
|
|
72
|
-
autoscroll={gradio.autoscroll}
|
|
51
|
+
autoscroll={gradio.shared.autoscroll}
|
|
73
52
|
i18n={gradio.i18n}
|
|
74
|
-
{...loading_status}
|
|
75
|
-
|
|
53
|
+
{...gradio.shared.loading_status}
|
|
54
|
+
on_clear_status={() =>
|
|
55
|
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
|
76
56
|
/>
|
|
77
57
|
|
|
78
|
-
{#if show_label}
|
|
79
|
-
<BlockLabel
|
|
58
|
+
{#if gradio.shared.show_label}
|
|
59
|
+
<BlockLabel
|
|
60
|
+
Icon={CodeIcon}
|
|
61
|
+
show_label={gradio.shared.show_label}
|
|
62
|
+
{label}
|
|
63
|
+
float={false}
|
|
64
|
+
/>
|
|
80
65
|
{/if}
|
|
81
66
|
|
|
82
|
-
{#if !value && !interactive}
|
|
67
|
+
{#if !gradio.props.value && !gradio.shared.interactive}
|
|
83
68
|
<Empty unpadded_box={true} size="large">
|
|
84
69
|
<CodeIcon />
|
|
85
70
|
</Empty>
|
|
86
71
|
{:else}
|
|
87
|
-
<Widget {language} {value} />
|
|
72
|
+
<Widget language={gradio.props.language} value={gradio.props.value} />
|
|
88
73
|
|
|
89
74
|
<Code
|
|
90
|
-
bind:value
|
|
91
|
-
{language}
|
|
92
|
-
{lines}
|
|
93
|
-
{max_lines}
|
|
75
|
+
bind:value={gradio.props.value}
|
|
76
|
+
language={gradio.props.language}
|
|
77
|
+
lines={gradio.props.lines}
|
|
78
|
+
max_lines={gradio.props.max_lines}
|
|
94
79
|
{dark_mode}
|
|
95
|
-
{wrap_lines}
|
|
96
|
-
{show_line_numbers}
|
|
97
|
-
{autocomplete}
|
|
98
|
-
readonly={!interactive}
|
|
80
|
+
wrap_lines={gradio.props.wrap_lines}
|
|
81
|
+
show_line_numbers={gradio.props.show_line_numbers}
|
|
82
|
+
autocomplete={gradio.props.autocomplete}
|
|
83
|
+
readonly={!gradio.shared.interactive}
|
|
99
84
|
on:blur={() => gradio.dispatch("blur")}
|
|
100
85
|
on:focus={() => gradio.dispatch("focus")}
|
|
86
|
+
on:input={() => gradio.dispatch("input")}
|
|
101
87
|
/>
|
|
102
88
|
{/if}
|
|
103
89
|
</Block>
|
package/dist/Example.svelte
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
export let
|
|
3
|
-
export let
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export let value: string | null;
|
|
3
|
+
export let type: "gallery" | "table";
|
|
4
|
+
export let selected = false;
|
|
5
|
+
|
|
6
|
+
function truncate_text(text: string | null, max_length = 60): string {
|
|
7
|
+
if (!text) return "";
|
|
8
|
+
const str = String(text);
|
|
9
|
+
if (str.length <= max_length) return str;
|
|
10
|
+
return str.slice(0, max_length) + "...";
|
|
11
|
+
}
|
|
10
12
|
</script>
|
|
11
13
|
|
|
12
14
|
<pre
|
package/dist/Example.svelte.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
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> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
7
11
|
};
|
|
8
|
-
|
|
9
|
-
[evt: string]: CustomEvent<any>;
|
|
10
|
-
};
|
|
11
|
-
slots: {};
|
|
12
|
-
exports?: {} | undefined;
|
|
13
|
-
bindings?: string | undefined;
|
|
14
|
-
};
|
|
15
|
-
export type ExampleProps = typeof __propDef.props;
|
|
16
|
-
export type ExampleEvents = typeof __propDef.events;
|
|
17
|
-
export type ExampleSlots = typeof __propDef.slots;
|
|
18
|
-
export default class Example extends SvelteComponent<ExampleProps, ExampleEvents, ExampleSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
19
13
|
}
|
|
20
|
-
|
|
14
|
+
declare const Example: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
value: string | null;
|
|
16
|
+
type: "gallery" | "table";
|
|
17
|
+
selected?: boolean;
|
|
18
|
+
}, {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
}, {}, {}, string>;
|
|
21
|
+
type Example = InstanceType<typeof Example>;
|
|
22
|
+
export default Example;
|
package/dist/Index.svelte
CHANGED
|
@@ -1,87 +1,89 @@
|
|
|
1
|
-
<script context="module"
|
|
2
|
-
export { default as
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as
|
|
5
|
-
export { default as
|
|
1
|
+
<script context="module" lang="ts">
|
|
2
|
+
export { default as BaseCode } from "./shared/Code.svelte";
|
|
3
|
+
export { default as BaseCopy } from "./shared/Copy.svelte";
|
|
4
|
+
export { default as BaseDownload } from "./shared/Download.svelte";
|
|
5
|
+
export { default as BaseWidget } from "./shared/Widgets.svelte";
|
|
6
|
+
export { default as BaseExample } from "./Example.svelte";
|
|
6
7
|
</script>
|
|
7
8
|
|
|
8
|
-
<script
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { StatusTracker } from "@gradio/statustracker";
|
|
12
|
-
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
afterUpdate(() => {
|
|
40
|
-
value_is_output = false;
|
|
41
|
-
});
|
|
42
|
-
$: value, handle_change();
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { Gradio } from "@gradio/utils";
|
|
11
|
+
import type { CodeProps, CodeEvents } from "./types";
|
|
12
|
+
import { StatusTracker } from "@gradio/statustracker";
|
|
13
|
+
|
|
14
|
+
import Code from "./shared/Code.svelte";
|
|
15
|
+
import Widget from "./shared/Widgets.svelte";
|
|
16
|
+
import { Block, BlockLabel, Empty } from "@gradio/atoms";
|
|
17
|
+
import { Code as CodeIcon } from "@gradio/icons";
|
|
18
|
+
|
|
19
|
+
const props = $props();
|
|
20
|
+
const gradio = new Gradio<CodeEvents, CodeProps>(props);
|
|
21
|
+
|
|
22
|
+
let dark_mode = gradio.shared.theme === "dark";
|
|
23
|
+
|
|
24
|
+
let label = $derived(gradio.shared.label || gradio.i18n("code.code"));
|
|
25
|
+
let old_value = $state(gradio.props.value);
|
|
26
|
+
let first_change = true;
|
|
27
|
+
|
|
28
|
+
$effect(() => {
|
|
29
|
+
if (first_change) {
|
|
30
|
+
first_change = false;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (old_value != gradio.props.value) {
|
|
34
|
+
old_value = gradio.props.value;
|
|
35
|
+
gradio.dispatch("change");
|
|
36
|
+
}
|
|
37
|
+
});
|
|
43
38
|
</script>
|
|
44
39
|
|
|
45
40
|
<Block
|
|
46
|
-
height={max_lines && "fit-content"}
|
|
41
|
+
height={gradio.props.max_lines && "fit-content"}
|
|
47
42
|
variant={"solid"}
|
|
48
43
|
padding={false}
|
|
49
|
-
{elem_id}
|
|
50
|
-
{elem_classes}
|
|
51
|
-
{visible}
|
|
52
|
-
{scale}
|
|
53
|
-
{min_width}
|
|
44
|
+
elem_id={gradio.shared.elem_id}
|
|
45
|
+
elem_classes={gradio.shared.elem_classes}
|
|
46
|
+
visible={gradio.shared.visible}
|
|
47
|
+
scale={gradio.shared.scale}
|
|
48
|
+
min_width={gradio.shared.min_width}
|
|
54
49
|
>
|
|
55
50
|
<StatusTracker
|
|
56
|
-
autoscroll={gradio.autoscroll}
|
|
51
|
+
autoscroll={gradio.shared.autoscroll}
|
|
57
52
|
i18n={gradio.i18n}
|
|
58
|
-
{...loading_status}
|
|
59
|
-
|
|
53
|
+
{...gradio.shared.loading_status}
|
|
54
|
+
on_clear_status={() =>
|
|
55
|
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
|
60
56
|
/>
|
|
61
57
|
|
|
62
|
-
{#if show_label}
|
|
63
|
-
<BlockLabel
|
|
58
|
+
{#if gradio.shared.show_label}
|
|
59
|
+
<BlockLabel
|
|
60
|
+
Icon={CodeIcon}
|
|
61
|
+
show_label={gradio.shared.show_label}
|
|
62
|
+
{label}
|
|
63
|
+
float={false}
|
|
64
|
+
/>
|
|
64
65
|
{/if}
|
|
65
66
|
|
|
66
|
-
{#if !value && !interactive}
|
|
67
|
+
{#if !gradio.props.value && !gradio.shared.interactive}
|
|
67
68
|
<Empty unpadded_box={true} size="large">
|
|
68
69
|
<CodeIcon />
|
|
69
70
|
</Empty>
|
|
70
71
|
{:else}
|
|
71
|
-
<Widget {language} {value} />
|
|
72
|
+
<Widget language={gradio.props.language} value={gradio.props.value} />
|
|
72
73
|
|
|
73
74
|
<Code
|
|
74
|
-
bind:value
|
|
75
|
-
{language}
|
|
76
|
-
{lines}
|
|
77
|
-
{max_lines}
|
|
75
|
+
bind:value={gradio.props.value}
|
|
76
|
+
language={gradio.props.language}
|
|
77
|
+
lines={gradio.props.lines}
|
|
78
|
+
max_lines={gradio.props.max_lines}
|
|
78
79
|
{dark_mode}
|
|
79
|
-
{wrap_lines}
|
|
80
|
-
{show_line_numbers}
|
|
81
|
-
{autocomplete}
|
|
82
|
-
readonly={!interactive}
|
|
80
|
+
wrap_lines={gradio.props.wrap_lines}
|
|
81
|
+
show_line_numbers={gradio.props.show_line_numbers}
|
|
82
|
+
autocomplete={gradio.props.autocomplete}
|
|
83
|
+
readonly={!gradio.shared.interactive}
|
|
83
84
|
on:blur={() => gradio.dispatch("blur")}
|
|
84
85
|
on:focus={() => gradio.dispatch("focus")}
|
|
86
|
+
on:input={() => gradio.dispatch("input")}
|
|
85
87
|
/>
|
|
86
88
|
{/if}
|
|
87
89
|
</Block>
|
package/dist/Index.svelte.d.ts
CHANGED
|
@@ -1,47 +1,8 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
1
|
export { default as BaseCode } from "./shared/Code.svelte";
|
|
3
2
|
export { default as BaseCopy } from "./shared/Copy.svelte";
|
|
4
3
|
export { default as BaseDownload } from "./shared/Download.svelte";
|
|
5
4
|
export { default as BaseWidget } from "./shared/Widgets.svelte";
|
|
6
5
|
export { default as BaseExample } from "./Example.svelte";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
props: {
|
|
11
|
-
gradio: Gradio<{
|
|
12
|
-
change: string;
|
|
13
|
-
input: never;
|
|
14
|
-
blur: never;
|
|
15
|
-
focus: never;
|
|
16
|
-
clear_status: LoadingStatus;
|
|
17
|
-
}>;
|
|
18
|
-
value?: string;
|
|
19
|
-
value_is_output?: boolean;
|
|
20
|
-
language?: string;
|
|
21
|
-
lines?: number;
|
|
22
|
-
max_lines?: number | undefined;
|
|
23
|
-
elem_id?: string;
|
|
24
|
-
elem_classes?: string[];
|
|
25
|
-
visible?: boolean | "hidden";
|
|
26
|
-
label?: any;
|
|
27
|
-
show_label?: boolean;
|
|
28
|
-
loading_status: LoadingStatus;
|
|
29
|
-
scale?: number | null;
|
|
30
|
-
min_width?: number | undefined;
|
|
31
|
-
wrap_lines?: boolean;
|
|
32
|
-
show_line_numbers?: boolean;
|
|
33
|
-
autocomplete?: boolean;
|
|
34
|
-
interactive: boolean;
|
|
35
|
-
};
|
|
36
|
-
events: {
|
|
37
|
-
[evt: string]: CustomEvent<any>;
|
|
38
|
-
};
|
|
39
|
-
slots: {};
|
|
40
|
-
exports?: {} | undefined;
|
|
41
|
-
bindings?: string | undefined;
|
|
42
|
-
};
|
|
43
|
-
export type IndexProps = typeof __propDef.props;
|
|
44
|
-
export type IndexEvents = typeof __propDef.events;
|
|
45
|
-
export type IndexSlots = typeof __propDef.slots;
|
|
46
|
-
export default class Index extends SvelteComponent<IndexProps, IndexEvents, IndexSlots> {
|
|
47
|
-
}
|
|
6
|
+
declare const Index: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type Index = ReturnType<typeof Index>;
|
|
8
|
+
export default Index;
|