mirror of
https://github.com/gradio-app/gradio.git
synced 2025-01-30 11:00:11 +08:00
set default values as the value for components
This commit is contained in:
parent
569491f896
commit
3b452fffdd
@ -5,6 +5,8 @@
|
||||
export let theme: string;
|
||||
export let style: string | null;
|
||||
export let mode: "static" | "dynamic";
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
<Checkbox {theme} {style} bind:value on:change disabled={mode === "static"} />
|
||||
|
@ -7,6 +7,8 @@
|
||||
export let mode: "static" | "dynamic";
|
||||
export let theme: string;
|
||||
export let style: string | null;
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
<CheckboxGroup
|
||||
|
@ -3,6 +3,8 @@
|
||||
export let headers: Array<string> = [];
|
||||
export let value: Array<Array<string | number>> = [["", "", ""]];
|
||||
export let is_static: boolean;
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
<Table bind:values={value} {headers} on:change editable={!is_static} />
|
||||
|
@ -5,6 +5,8 @@
|
||||
export let theme: string;
|
||||
export let style: string | null;
|
||||
export let choices: Array<string>;
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
<Dropdown bind:value {theme} {style} {choices} {label} on:change />
|
||||
|
@ -9,6 +9,8 @@
|
||||
const dispatch = createEventDispatcher<{ change: undefined }>();
|
||||
|
||||
$: label, dispatch("change");
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
<HTML {value} {theme} {style} on:change />
|
||||
|
@ -9,6 +9,8 @@
|
||||
const dispatch = createEventDispatcher<{ change: undefined }>();
|
||||
|
||||
$: value, dispatch("change");
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
<JSON {theme} {style} {value} />
|
||||
|
@ -4,6 +4,8 @@
|
||||
export let theme: string;
|
||||
export let style: string | null;
|
||||
export let mode: "static" | "dynamic";
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
<Number
|
||||
|
@ -6,6 +6,8 @@
|
||||
export let style: string | null;
|
||||
export let choices: Array<string> = [];
|
||||
export let mode: "static" | "dynamic";
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
<Radio
|
||||
|
@ -8,6 +8,8 @@
|
||||
export let maximum: number;
|
||||
export let step: number;
|
||||
export let mode: "static" | "dynamic";
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
<Range
|
||||
|
@ -10,6 +10,8 @@
|
||||
export let placeholder: string = "";
|
||||
|
||||
export let mode: "static" | "dynamic";
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
{#if mode === "static"}
|
||||
|
@ -100,6 +100,8 @@
|
||||
$: static_data = is_static && format_value(value as StaticData);
|
||||
|
||||
$: value, dispatch("change");
|
||||
|
||||
if ($$props.default) value = $$props.default;
|
||||
</script>
|
||||
|
||||
{#if is_static && static_data}
|
||||
|
@ -17,7 +17,7 @@
|
||||
<button
|
||||
class="selector py-2 px-3 font-semibold rounded inline-flex items-center"
|
||||
>
|
||||
{label}
|
||||
{value || label || choices[0]}
|
||||
<svg class="caret ml-2 fill-current h-4 w-4" viewBox="0 0 20 20">
|
||||
<path
|
||||
d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z"
|
||||
|
Loading…
Reference in New Issue
Block a user