2023-07-11 23:56:46 +08:00
|
|
|
<svelte:options accessors={true} />
|
|
|
|
|
2022-02-07 22:34:53 +08:00
|
|
|
<script lang="ts">
|
2023-08-04 06:01:18 +08:00
|
|
|
import Static from "./static";
|
|
|
|
import Interactive from "./interactive";
|
|
|
|
|
2022-03-17 00:34:30 +08:00
|
|
|
import { createEventDispatcher } from "svelte";
|
2023-08-04 06:01:18 +08:00
|
|
|
import StaticImage from "./static";
|
|
|
|
import Image from "./interactive";
|
|
|
|
|
2022-04-26 22:48:39 +08:00
|
|
|
import { Block } from "@gradio/atoms";
|
2022-04-09 02:46:00 +08:00
|
|
|
import { _ } from "svelte-i18n";
|
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";
|
2023-08-04 06:01:18 +08:00
|
|
|
import { UploadText } from "@gradio/atoms";
|
2022-02-01 21:45:55 +08:00
|
|
|
|
2023-07-20 02:00:02 +08:00
|
|
|
export let elem_id = "";
|
|
|
|
export let elem_classes: string[] = [];
|
|
|
|
export let visible = true;
|
2022-03-12 00:00:48 +08:00
|
|
|
export let value: null | string = null;
|
2022-02-07 22:34:53 +08:00
|
|
|
export let source: "canvas" | "webcam" | "upload" = "upload";
|
2023-04-11 05:27:02 +08:00
|
|
|
export let tool: "editor" | "select" | "sketch" | "color-sketch" = "editor";
|
2022-04-08 01:18:41 +08:00
|
|
|
export let label: string;
|
2022-04-27 18:47:15 +08:00
|
|
|
export let show_label: boolean;
|
2023-07-20 02:00:02 +08:00
|
|
|
export let show_download_button: boolean;
|
2022-05-17 02:51:09 +08:00
|
|
|
export let streaming: boolean;
|
|
|
|
export let pending: boolean;
|
2023-06-08 09:35:31 +08:00
|
|
|
export let height: number | undefined;
|
|
|
|
export let width: number | undefined;
|
2022-07-06 00:30:02 +08:00
|
|
|
export let mirror_webcam: boolean;
|
2023-02-23 16:46:44 +08:00
|
|
|
export let shape: [number, number];
|
|
|
|
export let brush_radius: number;
|
2023-07-26 02:39:51 +08:00
|
|
|
export let brush_color: string;
|
|
|
|
export let mask_opacity: number;
|
2023-07-20 02:00:02 +08:00
|
|
|
export let selectable = false;
|
|
|
|
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-05-06 03:05:05 +08:00
|
|
|
export let loading_status: LoadingStatus;
|
2023-08-18 03:20:19 +08:00
|
|
|
export let mode: "static" | "interactive";
|
2023-07-20 02:00:02 +08:00
|
|
|
export let show_share_button = false;
|
2022-03-17 00:34:30 +08:00
|
|
|
|
2023-04-11 05:47:33 +08:00
|
|
|
const dispatch = createEventDispatcher<{
|
|
|
|
change: undefined;
|
2023-07-06 08:50:17 +08:00
|
|
|
error: string;
|
2023-04-11 05:47:33 +08:00
|
|
|
}>();
|
2022-03-17 00:34:30 +08:00
|
|
|
|
|
|
|
$: value, dispatch("change");
|
2022-04-26 22:48:39 +08:00
|
|
|
let dragging: boolean;
|
2023-04-11 05:27:02 +08:00
|
|
|
const FIXED_HEIGHT = 240;
|
2022-07-27 02:26:00 +08:00
|
|
|
|
|
|
|
$: value = !value ? null : value;
|
2022-02-01 21:45:55 +08:00
|
|
|
</script>
|
|
|
|
|
2023-08-04 06:01:18 +08:00
|
|
|
{#if mode === "static"}
|
|
|
|
<Static
|
|
|
|
bind:value
|
|
|
|
{elem_id}
|
|
|
|
{elem_classes}
|
|
|
|
{visible}
|
|
|
|
{label}
|
|
|
|
{show_label}
|
|
|
|
{show_download_button}
|
|
|
|
{height}
|
|
|
|
{width}
|
|
|
|
{selectable}
|
|
|
|
{container}
|
|
|
|
{scale}
|
|
|
|
{min_width}
|
|
|
|
{loading_status}
|
|
|
|
{show_share_button}
|
|
|
|
on:edit
|
|
|
|
on:clear
|
|
|
|
on:stream
|
|
|
|
on:upload
|
|
|
|
on:select
|
|
|
|
on:share
|
|
|
|
on:error
|
|
|
|
></Static>
|
|
|
|
{:else}
|
|
|
|
<Interactive
|
|
|
|
bind:value
|
|
|
|
{elem_id}
|
|
|
|
{elem_classes}
|
|
|
|
{visible}
|
|
|
|
{source}
|
|
|
|
{tool}
|
|
|
|
{label}
|
|
|
|
{show_label}
|
|
|
|
{streaming}
|
|
|
|
{pending}
|
|
|
|
{height}
|
|
|
|
{width}
|
|
|
|
{mirror_webcam}
|
|
|
|
{shape}
|
|
|
|
{brush_radius}
|
|
|
|
{brush_color}
|
|
|
|
{mask_opacity}
|
|
|
|
{selectable}
|
|
|
|
{container}
|
|
|
|
{scale}
|
|
|
|
{min_width}
|
|
|
|
{loading_status}
|
|
|
|
on:edit
|
|
|
|
on:clear
|
|
|
|
on:stream
|
|
|
|
on:upload
|
|
|
|
on:select
|
|
|
|
on:share
|
|
|
|
on:error
|
|
|
|
></Interactive>
|
|
|
|
{/if}
|