File size: 3,443 Bytes
a03b3ba |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
<script lang="ts">
import type { ComponentMeta, Dependency } from "../types";
import { BaseButton } from "@gradio/button";
import { Block } from "@gradio/atoms";
export let dependency: Dependency;
export let dependency_failures: boolean[][];
export let dependency_index: number;
export let instance_map: {
[id: number]: ComponentMeta;
};
export let run: (id: number) => Promise<void>;
export let dependency_inputs: string[][];
function format_label(label: unknown): string {
return label ? "'" + label + "'" : "the";
}
</script>
<h4>
<div class="toggle-icon">
<div class="toggle-dot" />
</div>
Input Payload
</h4>
<Block>
<div class="payload-details">
{
<div class="first-level">"data": [</div>
{#each dependency.inputs as component_id, component_index}
<div class="second-level">
<input
class=""
type="text"
bind:value={dependency_inputs[dependency_index][component_index]}
/>
{#if dependency_failures[dependency_index][component_index]}
<span class="error">ERROR</span>
{/if}
<span class="type">
: {instance_map[component_id].documentation?.type?.input_payload ||
instance_map[component_id].documentation?.type?.payload},
</span>
<span class="desc">
// represents {instance_map[component_id].documentation?.description
?.input_payload ||
instance_map[component_id].documentation?.description?.payload} of
{format_label(instance_map[component_id].props.label)}
<span class="name">
{instance_map[component_id].props.name}
</span>
component
</span>
</div>
{/each}
<div class="first-level">]</div>
}
</div>
</Block>
<span class="space" />
<BaseButton variant="primary" on:click={run.bind(null, dependency_index)}>
Try It Out
</BaseButton>
<style>
.payload-details {
font-family: var(--font-mono);
}
.space {
display: flex;
flex-basis: 1;
margin-top: var(--size-4);
}
h4 {
display: flex;
align-items: center;
margin-top: var(--size-6);
margin-bottom: var(--size-3);
color: var(--body-text-color);
font-weight: var(--weight-bold);
}
.toggle-icon {
display: flex;
align-items: center;
margin-right: var(--size-2);
border-radius: var(--radius-full);
background: var(--color-grey-300);
width: 12px;
height: 4px;
}
.toggle-dot {
border-radius: var(--radius-full);
background: var(--color-grey-700);
width: 6px;
height: 6px;
}
:global(.dark) .toggle-icon {
background: var(--color-grey-500);
}
:global(.dark) .toggle-dot {
background: var(--color-grey-400);
}
input[type="text"] {
--ring-color: transparent;
margin: var(--size-1) 0;
outline: none !important;
box-shadow: var(--input-shadow);
border: var(--input-border-width) solid var(--input-border-color);
border-radius: var(--radius-lg);
background: var(--input-background-fill);
padding: var(--size-1-5);
color: var(--body-text-color);
font-weight: var(--input-text-weight);
font-size: var(--input-text-size);
line-height: var(--line-sm);
}
input:focus {
box-shadow: var(--input-shadow-focus);
border-color: var(--input-border-color-focus);
}
.error {
color: var(--error-text-color);
}
.type {
color: var(--block-label-text-color);
}
.desc {
color: var(--body-text-color-subdued);
}
.name {
text-transform: capitalize;
}
.first-level {
margin-left: 1rem;
}
.second-level {
margin-left: 2rem;
}
</style>
|