mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-12 10:34:32 +08:00
05715f5599
* dropdown * changes * add changeset * refactor * cleanup * dropdown * more refactoring * fixes * simplify, docstring * restore active_index * split into two files * new files * simplify * single select dropdown working * single select dropdown almost working * dropdown * multiselect * multiselect wip * multiselect * multiselect * multiselect * interactive working * dropdown * lint * add changeset * type * typing * fix multiselect static * dropdown * stories and tests * split stories * lint * add changeset * revert * add changeset * fix x * dropdown * lint, test * backend fixes * lint * fix tests * lint * fix final test * clean * review fixes * dropdown * lint * lint * changes * typing * fixes * active index null bug * adding filterable parameter to dropdown * dropdown * lint * add changeset * add changeset * svelte * fix test * add changeset * added warning * lint * fix tests --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
84 lines
2.1 KiB
Svelte
84 lines
2.1 KiB
Svelte
<script lang="ts">
|
|
import type { Gradio, SelectData } from "@gradio/utils";
|
|
import { Dropdown, Multiselect } from "../shared";
|
|
import { Block } from "@gradio/atoms";
|
|
import { StatusTracker } from "@gradio/statustracker";
|
|
import type { LoadingStatus } from "@gradio/statustracker";
|
|
|
|
export let label = "Dropdown";
|
|
export let info: string | undefined = undefined;
|
|
export let elem_id = "";
|
|
export let elem_classes: string[] = [];
|
|
export let visible = true;
|
|
export let value: string | string[];
|
|
export let value_is_output = false;
|
|
export let multiselect = false;
|
|
export let max_choices: number | null = null;
|
|
export let choices: [string, string | number][];
|
|
export let show_label: boolean;
|
|
export let filterable: boolean;
|
|
export let container = true;
|
|
export let scale: number | null = null;
|
|
export let min_width: number | undefined = undefined;
|
|
export let loading_status: LoadingStatus;
|
|
export let allow_custom_value = false;
|
|
export let gradio: Gradio<{
|
|
change: never;
|
|
input: never;
|
|
select: SelectData;
|
|
blur: never;
|
|
focus: never;
|
|
}>;
|
|
</script>
|
|
|
|
<Block
|
|
{visible}
|
|
{elem_id}
|
|
{elem_classes}
|
|
padding={container}
|
|
allow_overflow={false}
|
|
{scale}
|
|
{min_width}
|
|
>
|
|
<StatusTracker {...loading_status} />
|
|
|
|
{#if multiselect}
|
|
<Multiselect
|
|
bind:value
|
|
bind:value_is_output
|
|
{choices}
|
|
{max_choices}
|
|
{label}
|
|
{info}
|
|
{show_label}
|
|
{allow_custom_value}
|
|
{filterable}
|
|
{container}
|
|
on:change={() => gradio.dispatch("change")}
|
|
on:input={() => gradio.dispatch("input")}
|
|
on:select={(e) => gradio.dispatch("select", e.detail)}
|
|
on:blur={() => gradio.dispatch("blur")}
|
|
on:focus={() => gradio.dispatch("focus")}
|
|
disabled
|
|
/>
|
|
{:else}
|
|
<Dropdown
|
|
bind:value
|
|
bind:value_is_output
|
|
{choices}
|
|
{label}
|
|
{info}
|
|
{show_label}
|
|
{filterable}
|
|
{allow_custom_value}
|
|
{container}
|
|
on:change={() => gradio.dispatch("change")}
|
|
on:input={() => gradio.dispatch("input")}
|
|
on:select={(e) => gradio.dispatch("select", e.detail)}
|
|
on:blur={() => gradio.dispatch("blur")}
|
|
on:focus={() => gradio.dispatch("focus")}
|
|
disabled
|
|
/>
|
|
{/if}
|
|
</Block>
|