@gradio/code 0.16.0-dev.3 → 0.17.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 CHANGED
@@ -1,5 +1,41 @@
1
1
  # @gradio/code
2
2
 
3
+ ## 0.17.0
4
+
5
+ ### Features
6
+
7
+ - [#12539](https://github.com/gradio-app/gradio/pull/12539) [`f1d83fa`](https://github.com/gradio-app/gradio/commit/f1d83fac3d6e4bad60cf896a026fa2d572f26073) - Add ability to add custom buttons to components. Thanks @abidlabs!
8
+
9
+ ### Dependency updates
10
+
11
+ - @gradio/atoms@0.20.0
12
+ - @gradio/utils@0.11.0
13
+ - @gradio/statustracker@0.12.1
14
+ - @gradio/upload@0.17.3
15
+
16
+ ## 0.16.0
17
+
18
+ ### Dependency updates
19
+
20
+ - @gradio/utils@0.10.4
21
+
22
+ ## 0.16.0
23
+
24
+ ### Features
25
+
26
+ - [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Clear Error statuses
27
+ - [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Fix various event issues
28
+ - [#11908](https://github.com/gradio-app/gradio/pull/11908) [`029034f`](https://github.com/gradio-app/gradio/commit/029034f7853ea018d110efe9b7e2ef7d1407091c) - Add back default values for labels
29
+ - [#12438](https://github.com/gradio-app/gradio/pull/12438) [`25ffc03`](https://github.com/gradio-app/gradio/commit/25ffc0398f8feb43d817c02b2ab970c16de6d797) - Svelte5 migration and bugfix
30
+
31
+ ### Dependencies
32
+
33
+ - @gradio/atoms@0.19.0
34
+ - @gradio/icons@0.15.0
35
+ - @gradio/statustracker@0.12.0
36
+ - @gradio/upload@0.17.2
37
+ - @gradio/utils@0.10.3
38
+
3
39
  ## 0.16.0-dev.3
4
40
 
5
41
  ### Dependency updates
package/Index.svelte CHANGED
@@ -51,7 +51,7 @@
51
51
  autoscroll={gradio.shared.autoscroll}
52
52
  i18n={gradio.i18n}
53
53
  {...gradio.shared.loading_status}
54
- on:clear_status={() =>
54
+ on_clear_status={() =>
55
55
  gradio.dispatch("clear_status", gradio.shared.loading_status)}
56
56
  />
57
57
 
@@ -69,7 +69,14 @@
69
69
  <CodeIcon />
70
70
  </Empty>
71
71
  {:else}
72
- <Widget language={gradio.props.language} value={gradio.props.value} />
72
+ <Widget
73
+ language={gradio.props.language}
74
+ value={gradio.props.value}
75
+ buttons={gradio.props.buttons ?? ["copy", "download"]}
76
+ on_custom_button_click={(id) => {
77
+ gradio.dispatch("custom_button_click", { id });
78
+ }}
79
+ />
73
80
 
74
81
  <Code
75
82
  bind:value={gradio.props.value}
package/dist/Index.svelte CHANGED
@@ -51,7 +51,7 @@
51
51
  autoscroll={gradio.shared.autoscroll}
52
52
  i18n={gradio.i18n}
53
53
  {...gradio.shared.loading_status}
54
- on:clear_status={() =>
54
+ on_clear_status={() =>
55
55
  gradio.dispatch("clear_status", gradio.shared.loading_status)}
56
56
  />
57
57
 
@@ -69,7 +69,14 @@
69
69
  <CodeIcon />
70
70
  </Empty>
71
71
  {:else}
72
- <Widget language={gradio.props.language} value={gradio.props.value} />
72
+ <Widget
73
+ language={gradio.props.language}
74
+ value={gradio.props.value}
75
+ buttons={gradio.props.buttons ?? ["copy", "download"]}
76
+ on_custom_button_click={(id) => {
77
+ gradio.dispatch("custom_button_click", { id });
78
+ }}
79
+ />
73
80
 
74
81
  <Code
75
82
  bind:value={gradio.props.value}
@@ -2,12 +2,19 @@
2
2
  import Copy from "./Copy.svelte";
3
3
  import Download from "./Download.svelte";
4
4
  import { IconButtonWrapper } from "@gradio/atoms";
5
+ import type { CustomButton as CustomButtonType } from "@gradio/utils";
5
6
 
6
7
  export let value: string;
7
8
  export let language: string;
9
+ export let buttons: (string | CustomButtonType)[] | null = null;
10
+ export let on_custom_button_click: ((id: number) => void) | null = null;
8
11
  </script>
9
12
 
10
- <IconButtonWrapper>
11
- <Download {value} {language} />
12
- <Copy {value} />
13
+ <IconButtonWrapper {buttons} {on_custom_button_click}>
14
+ {#if buttons?.some((btn) => typeof btn === "string" && btn === "download")}
15
+ <Download {value} {language} />
16
+ {/if}
17
+ {#if buttons?.some((btn) => typeof btn === "string" && btn === "copy")}
18
+ <Copy {value} />
19
+ {/if}
13
20
  </IconButtonWrapper>
@@ -1,3 +1,4 @@
1
+ import type { CustomButton as CustomButtonType } from "@gradio/utils";
1
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> {
2
3
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
4
  $$bindings?: Bindings;
@@ -14,6 +15,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
14
15
  declare const Widgets: $$__sveltets_2_IsomorphicComponent<{
15
16
  value: string;
16
17
  language: string;
18
+ buttons?: (string | CustomButtonType)[] | null;
19
+ on_custom_button_click?: ((id: number) => void) | null;
17
20
  }, {
18
21
  [evt: string]: CustomEvent<any>;
19
22
  }, {}, {}, string>;
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { CustomButton } from "@gradio/utils";
1
2
  export interface CodeProps {
2
3
  value: string;
3
4
  language: string;
@@ -6,6 +7,7 @@ export interface CodeProps {
6
7
  show_line_numbers: boolean;
7
8
  autocomplete: boolean;
8
9
  lines: number;
10
+ buttons: (string | CustomButton)[] | null;
9
11
  }
10
12
  export interface CodeEvents {
11
13
  change: any;
@@ -13,4 +15,7 @@ export interface CodeEvents {
13
15
  focus: any;
14
16
  blur: any;
15
17
  clear_status: any;
18
+ custom_button_click: {
19
+ id: number;
20
+ };
16
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/code",
3
- "version": "0.16.0-dev.3",
3
+ "version": "0.17.0",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -27,11 +27,11 @@
27
27
  "cm6-theme-basic-dark": "^0.2.0",
28
28
  "cm6-theme-basic-light": "^0.2.0",
29
29
  "codemirror": "^6.0.2",
30
- "@gradio/atoms": "^0.19.0-dev.1",
31
- "@gradio/statustracker": "^0.12.0-dev.1",
32
- "@gradio/upload": "^0.17.2-dev.2",
33
- "@gradio/icons": "^0.15.0-dev.0",
34
- "@gradio/utils": "^0.10.3-dev.0"
30
+ "@gradio/atoms": "^0.20.0",
31
+ "@gradio/icons": "^0.15.0",
32
+ "@gradio/upload": "^0.17.3",
33
+ "@gradio/statustracker": "^0.12.1",
34
+ "@gradio/utils": "^0.11.0"
35
35
  },
36
36
  "main_changeset": true,
37
37
  "main": "./Index.svelte",
@@ -51,7 +51,7 @@
51
51
  "./package.json": "./package.json"
52
52
  },
53
53
  "devDependencies": {
54
- "@gradio/preview": "^0.15.0-dev.0"
54
+ "@gradio/preview": "^0.15.1"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "svelte": "^5.43.4"
@@ -2,12 +2,19 @@
2
2
  import Copy from "./Copy.svelte";
3
3
  import Download from "./Download.svelte";
4
4
  import { IconButtonWrapper } from "@gradio/atoms";
5
+ import type { CustomButton as CustomButtonType } from "@gradio/utils";
5
6
 
6
7
  export let value: string;
7
8
  export let language: string;
9
+ export let buttons: (string | CustomButtonType)[] | null = null;
10
+ export let on_custom_button_click: ((id: number) => void) | null = null;
8
11
  </script>
9
12
 
10
- <IconButtonWrapper>
11
- <Download {value} {language} />
12
- <Copy {value} />
13
+ <IconButtonWrapper {buttons} {on_custom_button_click}>
14
+ {#if buttons?.some((btn) => typeof btn === "string" && btn === "download")}
15
+ <Download {value} {language} />
16
+ {/if}
17
+ {#if buttons?.some((btn) => typeof btn === "string" && btn === "copy")}
18
+ <Copy {value} />
19
+ {/if}
13
20
  </IconButtonWrapper>
package/types.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { CustomButton } from "@gradio/utils";
2
+
1
3
  export interface CodeProps {
2
4
  value: string;
3
5
  language: string;
@@ -6,6 +8,7 @@ export interface CodeProps {
6
8
  show_line_numbers: boolean;
7
9
  autocomplete: boolean;
8
10
  lines: number;
11
+ buttons: (string | CustomButton)[] | null;
9
12
  }
10
13
 
11
14
  export interface CodeEvents {
@@ -14,4 +17,5 @@ export interface CodeEvents {
14
17
  focus: any;
15
18
  blur: any;
16
19
  clear_status: any;
20
+ custom_button_click: { id: number };
17
21
  }