-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
Dropdown.svelte
53 lines (48 loc) 路 1.4 KB
/
Dropdown.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<script lang="ts">
import { Dropdown } from "@gradio/form";
import { Block } from "@gradio/atoms";
import StatusTracker from "../StatusTracker/StatusTracker.svelte";
import type { LoadingStatus } from "../StatusTracker/types";
export let label: string = "Dropdown";
export let info: string | undefined = undefined;
export let elem_id: string = "";
export let elem_classes: Array<string> = [];
export let visible: boolean = true;
export let value: string | Array<string>;
export let value_is_output: boolean = false;
export let multiselect: boolean = false;
export let max_choices: number;
export let choices: Array<string>;
export let show_label: boolean;
export let container: boolean = true;
export let scale: number | null = null;
export let min_width: number | undefined = undefined;
export let loading_status: LoadingStatus;
export let allow_custom_value: boolean = false;
export let mode: "static" | "dynamic";
if (multiselect && !value) {
value = [];
} else if (!value) {
value = "";
}
</script>
<Block {visible} {elem_id} {elem_classes} padding={container} allow_overflow={false} {scale} {min_width}>
<StatusTracker {...loading_status} />
<Dropdown
bind:value
bind:value_is_output
{choices}
{multiselect}
{max_choices}
{label}
{info}
{show_label}
{allow_custom_value}
{container}
on:change
on:input
on:select
on:blur
disabled={mode === "static"}
/>
</Block>