mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-12 10:34:32 +08:00
fe057300f0
* delegate gradio events via a custom event dispatcher * improve md perf + share code * fix df markdown * prevent model3d from rerending too frequently * tweaks * fix more event bugs with video * add changeset * optimise handle mount * does this do anything * fix * remove old dispatches * fix dropdown position * oops * fixes * fix tests * fix types * format * fix markdown code * add changeset * fix typecheck * fix typecheck * fix demos * notebooks * fix tests * changer * maybe this * fixes * add changeset * fix chatbot alignment mobile * fix chantbot * add changeset * changeset * changeset * storybook --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
49 lines
1.3 KiB
Svelte
49 lines
1.3 KiB
Svelte
<script lang="ts">
|
|
import type { Gradio } from "@gradio/utils";
|
|
import { afterUpdate } from "svelte";
|
|
|
|
import type { LoadingStatus } from "@gradio/statustracker";
|
|
import { _ } from "svelte-i18n";
|
|
import Code from "../shared";
|
|
import { StatusTracker } from "@gradio/statustracker";
|
|
import { Block, BlockLabel } from "@gradio/atoms";
|
|
import { Code as CodeIcon } from "@gradio/icons";
|
|
|
|
export let value = "";
|
|
export let value_is_output = false;
|
|
export let language = "";
|
|
export let lines = 5;
|
|
export let target: HTMLElement;
|
|
export let elem_id = "";
|
|
export let elem_classes: string[] = [];
|
|
export let visible = true;
|
|
export let label = $_("code.code");
|
|
export let show_label = true;
|
|
export let loading_status: LoadingStatus;
|
|
export let gradio: Gradio<{
|
|
change: typeof value;
|
|
input: never;
|
|
}>;
|
|
|
|
let dark_mode = target.classList.contains("dark");
|
|
|
|
function handle_change(): void {
|
|
gradio.dispatch("change", value);
|
|
if (!value_is_output) {
|
|
gradio.dispatch("input");
|
|
}
|
|
}
|
|
afterUpdate(() => {
|
|
value_is_output = false;
|
|
});
|
|
$: value, handle_change();
|
|
</script>
|
|
|
|
<Block variant={"solid"} padding={false} {elem_id} {elem_classes} {visible}>
|
|
<StatusTracker {...loading_status} />
|
|
|
|
<BlockLabel Icon={CodeIcon} {show_label} {label} float={false} />
|
|
|
|
<Code bind:value {language} {lines} {dark_mode} />
|
|
</Block>
|