gradio-pr-bot commited on
Commit
4eca425
·
verified ·
1 Parent(s): a523f10

Upload folder using huggingface_hub

Browse files
6.2.0/file/Index.svelte CHANGED
@@ -78,6 +78,10 @@
78
  show_label={gradio.shared.show_label}
79
  height={gradio.props.height}
80
  i18n={gradio.i18n}
 
 
 
 
81
  />
82
  {:else}
83
  <FileUpload
@@ -94,6 +98,10 @@
94
  root={gradio.shared.root}
95
  allow_reordering={gradio.props.allow_reordering}
96
  max_file_size={gradio.shared.max_file_size}
 
 
 
 
97
  on:change={({ detail }) => {
98
  gradio.props.value = detail;
99
  }}
 
78
  show_label={gradio.shared.show_label}
79
  height={gradio.props.height}
80
  i18n={gradio.i18n}
81
+ buttons={gradio.props.buttons}
82
+ on_custom_button_click={(id) => {
83
+ gradio.dispatch("custom_button_click", { id });
84
+ }}
85
  />
86
  {:else}
87
  <FileUpload
 
98
  root={gradio.shared.root}
99
  allow_reordering={gradio.props.allow_reordering}
100
  max_file_size={gradio.shared.max_file_size}
101
+ buttons={gradio.props.buttons}
102
+ on_custom_button_click={(id) => {
103
+ gradio.dispatch("custom_button_click", { id });
104
+ }}
105
  on:change={({ detail }) => {
106
  gradio.props.value = detail;
107
  }}
6.2.0/file/package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "@gradio/file",
3
- "version": "0.13.1",
4
  "description": "Gradio UI packages",
5
  "type": "module",
6
  "author": "",
 
1
  {
2
  "name": "@gradio/file",
3
+ "version": "0.14.0",
4
  "description": "Gradio UI packages",
5
  "type": "module",
6
  "author": "",
6.2.0/file/shared/File.svelte CHANGED
@@ -1,7 +1,8 @@
1
  <script lang="ts">
2
- import { BlockLabel, Empty } from "@gradio/atoms";
3
  import { File } from "@gradio/icons";
4
  import FilePreview from "./FilePreview.svelte";
 
5
 
6
  let {
7
  value,
@@ -10,11 +11,16 @@
10
  selectable,
11
  i18n,
12
  height,
 
 
13
  on_select,
14
  on_download
15
  } = $props();
16
  </script>
17
 
 
 
 
18
  <BlockLabel
19
  {show_label}
20
  float={value === null}
 
1
  <script lang="ts">
2
+ import { BlockLabel, Empty, IconButtonWrapper } from "@gradio/atoms";
3
  import { File } from "@gradio/icons";
4
  import FilePreview from "./FilePreview.svelte";
5
+ import type { CustomButton as CustomButtonType } from "@gradio/utils";
6
 
7
  let {
8
  value,
 
11
  selectable,
12
  i18n,
13
  height,
14
+ buttons = null,
15
+ on_custom_button_click = null,
16
  on_select,
17
  on_download
18
  } = $props();
19
  </script>
20
 
21
+ {#if show_label && buttons && buttons.length > 0}
22
+ <IconButtonWrapper {buttons} {on_custom_button_click} />
23
+ {/if}
24
  <BlockLabel
25
  {show_label}
26
  float={value === null}
6.2.0/file/shared/FileUpload.svelte CHANGED
@@ -7,6 +7,7 @@
7
 
8
  import FilePreview from "./FilePreview.svelte";
9
  import type { I18nFormatter } from "@gradio/utils";
 
10
 
11
  export let value: null | FileData | FileData[];
12
 
@@ -24,6 +25,8 @@
24
  export let uploading = false;
25
  export let allow_reordering = false;
26
  export let upload_promise: Promise<(FileData | null)[]> | null = null;
 
 
27
 
28
  async function handle_upload({
29
  detail
@@ -59,10 +62,13 @@
59
  $: dispatch("drag", dragging);
60
  </script>
61
 
 
 
 
62
  <BlockLabel {show_label} Icon={File} float={!value} label={label || "File"} />
63
 
64
  {#if value && (Array.isArray(value) ? value.length > 0 : true)}
65
- <IconButtonWrapper>
66
  {#if !(file_count === "single" && (Array.isArray(value) ? value.length > 0 : value !== null))}
67
  <IconButton Icon={UploadIcon} label={i18n("common.upload")}>
68
  <Upload
 
7
 
8
  import FilePreview from "./FilePreview.svelte";
9
  import type { I18nFormatter } from "@gradio/utils";
10
+ import type { CustomButton as CustomButtonType } from "@gradio/utils";
11
 
12
  export let value: null | FileData | FileData[];
13
 
 
25
  export let uploading = false;
26
  export let allow_reordering = false;
27
  export let upload_promise: Promise<(FileData | null)[]> | null = null;
28
+ export let buttons: (string | CustomButtonType)[] | null = null;
29
+ export let on_custom_button_click: ((id: number) => void) | null = null;
30
 
31
  async function handle_upload({
32
  detail
 
62
  $: dispatch("drag", dragging);
63
  </script>
64
 
65
+ {#if show_label && buttons && buttons.length > 0}
66
+ <IconButtonWrapper {buttons} {on_custom_button_click} />
67
+ {/if}
68
  <BlockLabel {show_label} Icon={File} float={!value} label={label || "File"} />
69
 
70
  {#if value && (Array.isArray(value) ? value.length > 0 : true)}
71
+ <IconButtonWrapper buttons={buttons || []} {on_custom_button_click}>
72
  {#if !(file_count === "single" && (Array.isArray(value) ? value.length > 0 : value !== null))}
73
  <IconButton Icon={UploadIcon} label={i18n("common.upload")}>
74
  <Upload
6.2.0/file/types.ts CHANGED
@@ -1,6 +1,6 @@
1
  import type { FileData } from "@gradio/client";
2
  import type { LoadingStatus } from "js/statustracker";
3
- import type { SelectData } from "@gradio/utils";
4
 
5
  export interface FileProps {
6
  value: FileData | FileData[] | null;
@@ -10,6 +10,7 @@ export interface FileProps {
10
  type: "filepath" | "binary";
11
  _selectable: boolean;
12
  height: number | null;
 
13
  }
14
 
15
  export interface FileEvents {
@@ -21,4 +22,5 @@ export interface FileEvents {
21
  select: SelectData | null;
22
  change: FileData | FileData[] | null;
23
  delete: void;
 
24
  }
 
1
  import type { FileData } from "@gradio/client";
2
  import type { LoadingStatus } from "js/statustracker";
3
+ import type { SelectData, CustomButton } from "@gradio/utils";
4
 
5
  export interface FileProps {
6
  value: FileData | FileData[] | null;
 
10
  type: "filepath" | "binary";
11
  _selectable: boolean;
12
  height: number | null;
13
+ buttons: (string | CustomButton)[] | null;
14
  }
15
 
16
  export interface FileEvents {
 
22
  select: SelectData | null;
23
  change: FileData | FileData[] | null;
24
  delete: void;
25
+ custom_button_click: { id: number };
26
  }