gradio-pr-bot commited on
Commit
17e1df7
·
verified ·
1 Parent(s): 7b8dd84

Upload folder using huggingface_hub

Browse files
6.5.0/fileexplorer/Example.svelte ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ interface Props {
3
+ value: string[] | string | null;
4
+ type: "gallery" | "table";
5
+ selected?: boolean;
6
+ }
7
+
8
+ let { value, type, selected = false }: Props = $props();
9
+ </script>
10
+
11
+ <ul
12
+ class:table={type === "table"}
13
+ class:gallery={type === "gallery"}
14
+ class:selected
15
+ >
16
+ {#if value}
17
+ {#each Array.isArray(value) ? value.slice(0, 3) : [value] as path}
18
+ <li><code>./{path}</code></li>
19
+ {/each}
20
+ {#if Array.isArray(value) && value.length > 3}
21
+ <li class="extra">...</li>
22
+ {/if}
23
+ {/if}
24
+ </ul>
25
+
26
+ <style>
27
+ ul {
28
+ white-space: nowrap;
29
+ max-height: 100px;
30
+ list-style: none;
31
+ padding: 0;
32
+ margin: 0;
33
+ }
34
+
35
+ .extra {
36
+ text-align: center;
37
+ }
38
+
39
+ .gallery {
40
+ align-items: center;
41
+ cursor: pointer;
42
+ padding: var(--size-1) var(--size-2);
43
+ text-align: left;
44
+ }
45
+ </style>
6.5.0/fileexplorer/Index.svelte ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { FileExplorerProps, FileExplorerEvents } from "./types";
3
+ import { Gradio } from "@gradio/utils";
4
+ import { File } from "@gradio/icons";
5
+
6
+ import { Block, BlockLabel, IconButtonWrapper } from "@gradio/atoms";
7
+ import DirectoryExplorer from "./shared/DirectoryExplorer.svelte";
8
+
9
+ import { StatusTracker } from "@gradio/statustracker";
10
+
11
+ import { _ } from "svelte-i18n";
12
+
13
+ const props = $props();
14
+ const gradio = new Gradio<FileExplorerEvents, FileExplorerProps>(props, {
15
+ value: []
16
+ });
17
+
18
+ let old_value = $state(gradio.props.value);
19
+
20
+ let rerender_key = $derived([
21
+ gradio.props.root_dir,
22
+ gradio.props.glob,
23
+ gradio.props.ignore_glob
24
+ ]);
25
+
26
+ // Reset value when rerender_key changes
27
+ // svelte-ignore state_referenced_locally
28
+ let old_rerender_key = $state(rerender_key);
29
+ $effect(() => {
30
+ if (
31
+ JSON.stringify(old_rerender_key) != JSON.stringify(rerender_key) &&
32
+ old_value == gradio.props.value
33
+ ) {
34
+ old_rerender_key = rerender_key;
35
+ gradio.props.value = [];
36
+ }
37
+ });
38
+
39
+ $effect(() => {
40
+ if (old_value != gradio.props.value) {
41
+ old_value = gradio.props.value;
42
+ gradio.dispatch("change");
43
+ }
44
+ });
45
+ </script>
46
+
47
+ <Block
48
+ visible={gradio.shared.visible}
49
+ variant={gradio.props.value === null ? "dashed" : "solid"}
50
+ border_mode={"base"}
51
+ padding={false}
52
+ elem_id={gradio.shared.elem_id}
53
+ elem_classes={gradio.shared.elem_classes}
54
+ container={gradio.shared.container}
55
+ scale={gradio.shared.scale}
56
+ min_width={gradio.shared.min_width}
57
+ allow_overflow={true}
58
+ overflow_behavior="auto"
59
+ height={gradio.props.height}
60
+ max_height={gradio.props.max_height}
61
+ min_height={gradio.props.min_height}
62
+ >
63
+ <StatusTracker
64
+ {...gradio.shared.loading_status}
65
+ autoscroll={gradio.shared.autoscroll}
66
+ i18n={gradio.i18n}
67
+ on_clear_status={() =>
68
+ gradio.dispatch("clear_status", gradio.shared.loading_status)}
69
+ />
70
+ {#if gradio.shared.show_label && gradio.props.buttons && gradio.props.buttons.length > 0}
71
+ <IconButtonWrapper
72
+ buttons={gradio.props.buttons}
73
+ on_custom_button_click={(id) => {
74
+ gradio.dispatch("custom_button_click", { id });
75
+ }}
76
+ />
77
+ {/if}
78
+ <BlockLabel
79
+ show_label={gradio.shared.show_label}
80
+ Icon={File}
81
+ label={gradio.shared.label || "FileExplorer"}
82
+ float={false}
83
+ />
84
+ {#key rerender_key}
85
+ <DirectoryExplorer
86
+ bind:value={gradio.props.value}
87
+ file_count={gradio.props.file_count}
88
+ interactive={gradio.shared.interactive}
89
+ selectable={gradio.props._selectable}
90
+ ls_fn={gradio.shared.server.ls}
91
+ oninput={() => gradio.dispatch("input")}
92
+ onselect={(detail) => gradio.dispatch("select", detail)}
93
+ />
94
+ {/key}
95
+ </Block>
6.5.0/fileexplorer/package.json ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/fileexplorer",
3
+ "version": "0.6.2",
4
+ "description": "Gradio UI packages",
5
+ "type": "module",
6
+ "author": "",
7
+ "license": "ISC",
8
+ "dependencies": {
9
+ "@gradio/atoms": "workspace:^",
10
+ "@gradio/checkbox": "workspace:^",
11
+ "@gradio/client": "workspace:^",
12
+ "@gradio/file": "workspace:^",
13
+ "@gradio/icons": "workspace:^",
14
+ "@gradio/statustracker": "workspace:^",
15
+ "@gradio/upload": "workspace:^",
16
+ "@gradio/utils": "workspace:^",
17
+ "dequal": "^2.0.3"
18
+ },
19
+ "devDependencies": {
20
+ "@gradio/preview": "workspace:^"
21
+ },
22
+ "main_changeset": true,
23
+ "exports": {
24
+ ".": {
25
+ "gradio": "./Index.svelte",
26
+ "svelte": "./dist/Index.svelte",
27
+ "types": "./dist/Index.svelte.d.ts"
28
+ },
29
+ "./example": {
30
+ "gradio": "./Example.svelte",
31
+ "svelte": "./dist/Example.svelte",
32
+ "types": "./dist/Example.svelte.d.ts"
33
+ },
34
+ "./package.json": "./package.json"
35
+ },
36
+ "peerDependencies": {
37
+ "svelte": "^5.48.0"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/gradio-app/gradio.git",
42
+ "directory": "js/fileexplorer"
43
+ }
44
+ }
6.5.0/fileexplorer/shared/ArrowIcon.svelte ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <svg
2
+ width="100%"
3
+ height="100%"
4
+ viewBox="0 0 14 17"
5
+ version="1.1"
6
+ style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"
7
+ >
8
+ <g transform="matrix(1,0,0,1,-10.6667,-7.73588)">
9
+ <path
10
+ d="M12.7,24.033C12.256,24.322 11.806,24.339 11.351,24.084C10.896,23.829 10.668,23.434 10.667,22.9L10.667,9.1C10.667,8.567 10.895,8.172 11.351,7.916C11.807,7.66 12.256,7.677 12.7,7.967L23.567,14.867C23.967,15.133 24.167,15.511 24.167,16C24.167,16.489 23.967,16.867 23.567,17.133L12.7,24.033Z"
11
+ style="fill:currentColor;fill-rule:nonzero;"
12
+ />
13
+ </g>
14
+ </svg>
6.5.0/fileexplorer/shared/Checkbox.svelte ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ interface Props {
3
+ value: boolean;
4
+ disabled: boolean;
5
+ onchange?: (value: boolean) => void;
6
+ }
7
+
8
+ let { value = $bindable(), disabled, onchange }: Props = $props();
9
+ </script>
10
+
11
+ <input
12
+ bind:checked={value}
13
+ oninput={() => onchange?.(!value)}
14
+ type="checkbox"
15
+ {disabled}
16
+ class:disabled={disabled && !value}
17
+ />
18
+
19
+ <style>
20
+ input {
21
+ --ring-color: transparent;
22
+ position: relative;
23
+ box-shadow: var(--input-shadow);
24
+ border: 1px solid var(--checkbox-border-color);
25
+ border-radius: var(--radius-xs);
26
+ background-color: var(--checkbox-background-color);
27
+ line-height: var(--line-sm);
28
+ width: 18px !important;
29
+ height: 18px !important;
30
+ }
31
+
32
+ input:checked,
33
+ input:checked:hover,
34
+ input:checked:focus {
35
+ border-color: var(--checkbox-border-color-selected);
36
+ background-image: var(--checkbox-check);
37
+ background-color: var(--checkbox-background-color-selected);
38
+ }
39
+
40
+ input:hover {
41
+ border-color: var(--checkbox-border-color-hover);
42
+ background-color: var(--checkbox-background-color-hover);
43
+ }
44
+
45
+ input:focus {
46
+ border-color: var(--checkbox-border-color-focus);
47
+ background-color: var(--checkbox-background-color-focus);
48
+ }
49
+
50
+ .disabled {
51
+ opacity: 0.8 !important;
52
+ cursor: not-allowed;
53
+ }
54
+ </style>
6.5.0/fileexplorer/shared/DirectoryExplorer.svelte ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import FileTree from "./FileTree.svelte";
3
+ import type { FileNode } from "./types";
4
+ import type { SelectData } from "@gradio/utils";
5
+
6
+ interface Props {
7
+ interactive: boolean;
8
+ file_count?: "single" | "multiple";
9
+ value: string[][];
10
+ selectable?: boolean;
11
+ ls_fn: (path: string[]) => Promise<FileNode[]>;
12
+ oninput?: () => void;
13
+ onselect?: (detail: SelectData) => void;
14
+ }
15
+
16
+ let {
17
+ interactive,
18
+ file_count = "multiple",
19
+ value = $bindable(),
20
+ selectable = false,
21
+ ls_fn,
22
+ oninput,
23
+ onselect
24
+ }: Props = $props();
25
+
26
+ let selected_folders = $state<string[][]>([]);
27
+
28
+ const paths_equal = (path: string[], path_2: string[]): boolean => {
29
+ return path.join("/") === path_2.join("/");
30
+ };
31
+
32
+ const path_in_set = (path: string[], set: string[][]): boolean => {
33
+ return set.some((x) => paths_equal(x, path));
34
+ };
35
+
36
+ const path_inside = (path: string[], path_2: string[]): boolean => {
37
+ return path.join("/").startsWith(path_2.join("/"));
38
+ };
39
+ </script>
40
+
41
+ <div class="file-wrap">
42
+ <FileTree
43
+ path={[]}
44
+ selected_files={value}
45
+ {selected_folders}
46
+ {interactive}
47
+ {selectable}
48
+ {ls_fn}
49
+ {file_count}
50
+ valid_for_selection={false}
51
+ oncheck={(detail) => {
52
+ const { path, checked, type } = detail;
53
+ if (checked) {
54
+ if (file_count === "single") {
55
+ value = [path];
56
+ } else if (type === "folder") {
57
+ if (!path_in_set(path, selected_folders)) {
58
+ selected_folders = [...selected_folders, path];
59
+ }
60
+ } else {
61
+ if (!path_in_set(path, value)) {
62
+ value = [...value, path];
63
+ }
64
+ }
65
+ } else {
66
+ selected_folders = selected_folders.filter(
67
+ (folder) => !path_inside(path, folder)
68
+ ); // deselect all parent folders
69
+ if (type === "folder") {
70
+ selected_folders = selected_folders.filter(
71
+ (folder) => !path_inside(folder, path)
72
+ ); // deselect all children folders
73
+ value = value.filter((file) => !path_inside(file, path)); // deselect all children files
74
+ } else {
75
+ value = value.filter((x) => !paths_equal(x, path));
76
+ }
77
+ }
78
+ oninput?.();
79
+ }}
80
+ {onselect}
81
+ />
82
+ </div>
83
+
84
+ <style>
85
+ .file-wrap {
86
+ height: calc(100% - 25px);
87
+ overflow-y: scroll;
88
+ }
89
+ </style>
6.5.0/fileexplorer/shared/FileTree.svelte ADDED
@@ -0,0 +1,320 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ import type { FileNode } from "./types";
3
+ import type { SelectData } from "@gradio/utils";
4
+
5
+ import Arrow from "./ArrowIcon.svelte";
6
+ import Checkbox from "./Checkbox.svelte";
7
+ import Self from "./FileTree.svelte";
8
+ import FileIcon from "../icons/light-file.svg";
9
+ import FolderIcon from "../icons/light-folder.svg";
10
+
11
+ interface Props {
12
+ path?: string[];
13
+ index_path?: number[];
14
+ selected_files?: string[][];
15
+ selected_folders?: string[][];
16
+ is_selected_entirely?: boolean;
17
+ interactive: boolean;
18
+ selectable?: boolean;
19
+ ls_fn: (path: string[]) => Promise<FileNode[]>;
20
+ file_count?: "single" | "multiple";
21
+ valid_for_selection: boolean;
22
+ oncheck?: (detail: {
23
+ path: string[];
24
+ checked: boolean;
25
+ type: "file" | "folder";
26
+ }) => void;
27
+ onselect?: (detail: SelectData) => void;
28
+ }
29
+
30
+ let {
31
+ path = [],
32
+ index_path = [],
33
+ selected_files = [],
34
+ selected_folders = [],
35
+ is_selected_entirely = false,
36
+ interactive,
37
+ selectable = false,
38
+ ls_fn,
39
+ file_count = "multiple",
40
+ valid_for_selection,
41
+ oncheck,
42
+ onselect
43
+ }: Props = $props();
44
+
45
+ let content = $state<FileNode[]>([]);
46
+ let opened_folders = $state<number[]>([]);
47
+
48
+ const toggle_open_folder = (i: number): void => {
49
+ if (opened_folders.includes(i)) {
50
+ opened_folders = opened_folders.filter((x) => x !== i);
51
+ } else {
52
+ opened_folders = [...opened_folders, i];
53
+ }
54
+ };
55
+
56
+ const open_folder = (i: number): void => {
57
+ if (!opened_folders.includes(i)) {
58
+ opened_folders = [...opened_folders, i];
59
+ }
60
+ };
61
+
62
+ (async () => {
63
+ content = await ls_fn(path);
64
+ if (valid_for_selection) {
65
+ content = [{ name: ".", type: "file" }, ...content];
66
+ }
67
+ opened_folders = content
68
+ .map((x, i) =>
69
+ x.type === "folder" &&
70
+ (is_selected_entirely || selected_files.some((y) => y[0] === x.name))
71
+ ? i
72
+ : null
73
+ )
74
+ .filter((x): x is number => x !== null);
75
+ })();
76
+
77
+ $effect(() => {
78
+ if (is_selected_entirely) {
79
+ content.forEach((x) => {
80
+ oncheck?.({
81
+ path: [...path, x.name],
82
+ checked: true,
83
+ type: x.type
84
+ });
85
+ });
86
+ }
87
+ });
88
+
89
+ function handle_select(
90
+ full_index_path: number[],
91
+ item_path: string[],
92
+ _type: "file" | "folder"
93
+ ): void {
94
+ onselect?.({
95
+ index: full_index_path as any,
96
+ value: item_path.join("/"),
97
+ selected: true
98
+ });
99
+ }
100
+ </script>
101
+
102
+ <ul class:no-checkboxes={!interactive} class:root={path.length === 0}>
103
+ {#each content as { type, name, valid }, i}
104
+ {@const is_selected = (
105
+ type === "file" ? selected_files : selected_folders
106
+ ).some((x) => x[0] === name && x.length === 1)}
107
+ <li>
108
+ <span
109
+ class="wrap"
110
+ class:selected={!interactive && is_selected}
111
+ class:selectable
112
+ role={selectable ? "button" : undefined}
113
+ tabindex={selectable ? 0 : undefined}
114
+ onclick={(e) => {
115
+ e.stopPropagation();
116
+ if (selectable) {
117
+ handle_select([...index_path, i], [...path, name], type);
118
+ }
119
+ }}
120
+ onkeydown={(e) => {
121
+ if (selectable && (e.key === " " || e.key === "Enter")) {
122
+ handle_select([...index_path, i], [...path, name], type);
123
+ }
124
+ }}
125
+ >
126
+ {#if interactive}
127
+ {#if type === "folder" && file_count === "single"}
128
+ <span class="no-checkbox" aria-hidden="true"></span>
129
+ {:else}
130
+ <Checkbox
131
+ disabled={false}
132
+ value={is_selected}
133
+ onchange={(checked) => {
134
+ oncheck?.({
135
+ path: [...path, name],
136
+ checked,
137
+ type
138
+ });
139
+ if (selectable) {
140
+ handle_select([...index_path, i], [...path, name], type);
141
+ }
142
+ if (type === "folder" && checked) {
143
+ open_folder(i);
144
+ }
145
+ }}
146
+ />
147
+ {/if}
148
+ {/if}
149
+
150
+ {#if type === "folder"}
151
+ <span
152
+ class="icon"
153
+ class:hidden={!opened_folders.includes(i)}
154
+ onclick={(e) => {
155
+ e.stopPropagation();
156
+ toggle_open_folder(i);
157
+ }}
158
+ role="button"
159
+ aria-label="expand directory"
160
+ tabindex="0"
161
+ onkeydown={(e) => {
162
+ if (e.key === " " || e.key === "Enter") {
163
+ toggle_open_folder(i);
164
+ }
165
+ }}><Arrow /></span
166
+ >
167
+ {:else}
168
+ <span class="file-icon">
169
+ <img src={name === "." ? FolderIcon : FileIcon} alt="file icon" />
170
+ </span>
171
+ {/if}
172
+ <span class="item-name">{name}</span>
173
+ </span>
174
+ {#if type === "folder" && opened_folders.includes(i)}
175
+ <Self
176
+ path={[...path, name]}
177
+ index_path={[...index_path, i]}
178
+ selected_files={selected_files
179
+ .filter((x) => x[0] === name)
180
+ .map((x) => x.slice(1))}
181
+ selected_folders={selected_folders
182
+ .filter((x) => x[0] === name)
183
+ .map((x) => x.slice(1))}
184
+ is_selected_entirely={selected_folders.some(
185
+ (x) => x[0] === name && x.length === 1
186
+ )}
187
+ {interactive}
188
+ {selectable}
189
+ {ls_fn}
190
+ {file_count}
191
+ valid_for_selection={valid ?? false}
192
+ {oncheck}
193
+ {onselect}
194
+ />
195
+ {/if}
196
+ </li>
197
+ {/each}
198
+ </ul>
199
+
200
+ <style>
201
+ .icon {
202
+ display: inline-block;
203
+ width: 18px;
204
+ height: 18px;
205
+ padding: 3px 2px 3px 3px;
206
+ margin: 0;
207
+ flex-grow: 0;
208
+ display: inline-flex;
209
+ justify-content: center;
210
+ align-items: center;
211
+ border-radius: 2px;
212
+ cursor: pointer;
213
+ transition: 0.1s;
214
+ flex-shrink: 0;
215
+ }
216
+
217
+ .file-icon {
218
+ display: inline-block;
219
+ height: 20px;
220
+ margin-left: -1px;
221
+ margin: 0;
222
+ flex-grow: 0;
223
+ display: inline-flex;
224
+ justify-content: center;
225
+ align-items: center;
226
+
227
+ transition: 0.1s;
228
+ }
229
+
230
+ .file-icon img {
231
+ width: 100%;
232
+ height: 100%;
233
+ }
234
+
235
+ .icon:hover {
236
+ background: #eee;
237
+ }
238
+
239
+ .icon:hover :global(> *) {
240
+ color: var(--block-info-text-color);
241
+ }
242
+
243
+ .icon :global(> *) {
244
+ transform: rotate(90deg);
245
+ transform-origin: 40% 50%;
246
+ transition: 0.2s;
247
+ color: var(--color-accent);
248
+ }
249
+
250
+ .no-checkbox {
251
+ width: 18px;
252
+ height: 18px;
253
+ }
254
+
255
+ ul.root .no-checkbox {
256
+ display: none;
257
+ }
258
+
259
+ .hidden :global(> *) {
260
+ transform: rotate(0);
261
+ color: var(--body-text-color-subdued);
262
+ }
263
+
264
+ ul {
265
+ margin-left: 26px;
266
+ padding-left: 0;
267
+ list-style: none;
268
+ }
269
+
270
+ ul.root {
271
+ margin-left: 8px;
272
+ }
273
+
274
+ ul.no-checkboxes:not(.root) {
275
+ margin-left: 20px;
276
+ }
277
+
278
+ li {
279
+ margin-left: 0;
280
+ padding-left: 0;
281
+ align-items: center;
282
+ margin: 8px 0;
283
+ font-family: var(--font-mono);
284
+ font-size: var(--scale-00);
285
+ overflow-wrap: anywhere;
286
+ word-break: break-word;
287
+ }
288
+
289
+ .wrap {
290
+ display: flex;
291
+ gap: 8px;
292
+ align-items: center;
293
+ }
294
+
295
+ .wrap.selected {
296
+ background-color: var(--color-accent-soft);
297
+ border-radius: var(--radius-sm);
298
+ margin-left: -4px;
299
+ padding-left: 4px;
300
+ }
301
+
302
+ .wrap.selectable {
303
+ cursor: pointer;
304
+ border-radius: var(--radius-sm);
305
+ margin-left: -4px;
306
+ padding-left: 4px;
307
+ padding-right: 4px;
308
+ }
309
+
310
+ .wrap.selectable:hover {
311
+ background-color: var(--border-color-accent);
312
+ }
313
+
314
+ .item-name {
315
+ flex: 1;
316
+ padding: 2px 4px;
317
+ border-radius: var(--radius-sm);
318
+ margin-right: -4px;
319
+ }
320
+ </style>
6.5.0/fileexplorer/shared/types.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ export interface FileNode {
2
+ type: "file" | "folder";
3
+ name: string;
4
+ valid?: boolean;
5
+ }
6.5.0/fileexplorer/types.ts ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { LoadingStatus } from "@gradio/statustracker";
2
+ import type { SelectData, CustomButton } from "@gradio/utils";
3
+ import type { FileNode } from "./shared/types";
4
+
5
+ export interface FileExplorerProps {
6
+ value: string[][];
7
+ height: number | string | undefined;
8
+ min_height: number | string | undefined;
9
+ max_height: number | string | undefined;
10
+ file_count: "single" | "multiple";
11
+ root_dir: string;
12
+ glob: string;
13
+ ignore_glob: string;
14
+ _selectable: boolean;
15
+ server: {
16
+ ls: (path: string[]) => Promise<FileNode[]>;
17
+ };
18
+ buttons: (string | CustomButton)[] | null;
19
+ }
20
+
21
+ export interface FileExplorerEvents {
22
+ change: never;
23
+ input: never;
24
+ select: SelectData;
25
+ clear_status: LoadingStatus;
26
+ custom_button_click: { id: number };
27
+ }