2022-03-08 21:35:42 +08:00
|
|
|
<script lang="ts">
|
2022-03-17 00:34:30 +08:00
|
|
|
import { createEventDispatcher } from "svelte";
|
2022-03-08 21:35:42 +08:00
|
|
|
import { Label } from "@gradio/label";
|
2022-04-26 22:48:39 +08:00
|
|
|
import { Block } from "@gradio/atoms";
|
|
|
|
import StatusTracker from "../StatusTracker/StatusTracker.svelte";
|
2022-03-08 21:35:42 +08:00
|
|
|
|
|
|
|
export let value: {
|
|
|
|
label: string;
|
|
|
|
confidences?: Array<{ label: string; confidence: number }>;
|
|
|
|
};
|
2022-03-29 21:10:35 +08:00
|
|
|
|
|
|
|
export let default_value: {
|
|
|
|
label: string;
|
|
|
|
confidences?: Array<{ label: string; confidence: number }>;
|
|
|
|
};
|
2022-04-09 02:46:00 +08:00
|
|
|
|
|
|
|
export let style: string = "";
|
2022-04-26 22:48:39 +08:00
|
|
|
export let loading_status: "complete" | "pending" | "error";
|
2022-04-27 18:47:15 +08:00
|
|
|
export let show_label: boolean;
|
2022-03-17 00:34:30 +08:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher<{ change: undefined }>();
|
|
|
|
|
2022-03-29 21:10:35 +08:00
|
|
|
if (default_value) value = default_value;
|
|
|
|
|
2022-03-17 00:34:30 +08:00
|
|
|
$: value, dispatch("change");
|
2022-03-08 21:35:42 +08:00
|
|
|
</script>
|
|
|
|
|
2022-04-26 22:48:39 +08:00
|
|
|
<Block>
|
|
|
|
<StatusTracker tracked_status={loading_status} />
|
|
|
|
|
|
|
|
{#if value !== undefined && value !== null}
|
2022-04-27 18:47:15 +08:00
|
|
|
<Label {style} {value} {show_label} />
|
2022-04-26 22:48:39 +08:00
|
|
|
{/if}
|
|
|
|
</Block>
|