2022-04-19 03:26:30 +08:00
|
|
|
<script lang="ts">
|
|
|
|
import type { FileData } from "@gradio/upload";
|
|
|
|
import { normalise_file } from "@gradio/upload";
|
2023-08-04 06:01:18 +08:00
|
|
|
import Model3D from "./Model3D.svelte";
|
2023-01-18 04:47:40 +08:00
|
|
|
import { BlockLabel, Block, Empty } from "@gradio/atoms";
|
|
|
|
import { File } from "@gradio/icons";
|
2022-04-26 22:48:39 +08:00
|
|
|
|
2023-08-04 06:01:18 +08:00
|
|
|
import { StatusTracker } from "@gradio/statustracker";
|
2023-08-16 02:21:41 +08:00
|
|
|
import type { LoadingStatus } from "@gradio/statustracker";
|
2022-04-19 03:26:30 +08:00
|
|
|
import { _ } from "svelte-i18n";
|
|
|
|
|
2023-08-04 06:01:18 +08:00
|
|
|
export let elem_id = "";
|
|
|
|
export let elem_classes: string[] = [];
|
|
|
|
export let visible = true;
|
2022-04-19 03:26:30 +08:00
|
|
|
export let value: null | FileData = null;
|
|
|
|
export let root: string;
|
2022-11-04 03:35:56 +08:00
|
|
|
export let root_url: null | string;
|
2023-08-04 06:01:18 +08:00
|
|
|
export let clearColor: [number, number, number, number];
|
2022-05-06 03:05:05 +08:00
|
|
|
export let loading_status: LoadingStatus;
|
2022-04-27 18:47:15 +08:00
|
|
|
export let label: string;
|
|
|
|
export let show_label: boolean;
|
2023-08-04 06:01:18 +08:00
|
|
|
export let container = true;
|
2023-06-22 03:34:12 +08:00
|
|
|
export let scale: number | null = null;
|
2023-06-08 09:35:31 +08:00
|
|
|
export let min_width: number | undefined = undefined;
|
2022-04-26 22:48:39 +08:00
|
|
|
|
2022-04-19 03:26:30 +08:00
|
|
|
let _value: null | FileData;
|
2023-02-07 23:55:51 +08:00
|
|
|
$: _value = normalise_file(value, root, root_url);
|
2022-04-26 22:48:39 +08:00
|
|
|
|
|
|
|
let dragging = false;
|
2022-04-19 03:26:30 +08:00
|
|
|
</script>
|
|
|
|
|
2022-04-26 22:48:39 +08:00
|
|
|
<Block
|
2022-06-17 07:49:54 +08:00
|
|
|
{visible}
|
2022-04-26 22:48:39 +08:00
|
|
|
variant={value === null ? "dashed" : "solid"}
|
2023-03-07 04:52:31 +08:00
|
|
|
border_mode={dragging ? "focus" : "base"}
|
2022-04-26 22:48:39 +08:00
|
|
|
padding={false}
|
2022-05-12 12:40:41 +08:00
|
|
|
{elem_id}
|
2023-03-16 05:01:53 +08:00
|
|
|
{elem_classes}
|
2023-06-08 09:35:31 +08:00
|
|
|
{container}
|
|
|
|
{scale}
|
|
|
|
{min_width}
|
2022-04-26 22:48:39 +08:00
|
|
|
>
|
2022-05-06 03:05:05 +08:00
|
|
|
<StatusTracker {...loading_status} />
|
2022-04-26 22:48:39 +08:00
|
|
|
|
2023-08-04 06:01:18 +08:00
|
|
|
{#if value}
|
2022-05-12 12:40:41 +08:00
|
|
|
<Model3D value={_value} {clearColor} {label} {show_label} />
|
2023-01-18 04:47:40 +08:00
|
|
|
{:else}
|
|
|
|
<!-- Not ideal but some bugs to work out before we can
|
|
|
|
make this consistent with other components -->
|
|
|
|
|
|
|
|
<BlockLabel {show_label} Icon={File} label={label || "3D Model"} />
|
|
|
|
|
2023-06-08 20:24:13 +08:00
|
|
|
<Empty unpadded_box={true} size="large"><File /></Empty>
|
2022-04-26 22:48:39 +08:00
|
|
|
{/if}
|
|
|
|
</Block>
|