Upload folder using huggingface_hub
Browse files
6.0.0/simpledropdown/Example.svelte
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let value: string | null;
|
| 3 |
+
export let type: "gallery" | "table";
|
| 4 |
+
export let selected = false;
|
| 5 |
+
</script>
|
| 6 |
+
|
| 7 |
+
<div
|
| 8 |
+
class:table={type === "table"}
|
| 9 |
+
class:gallery={type === "gallery"}
|
| 10 |
+
class:selected
|
| 11 |
+
>
|
| 12 |
+
{value ? value : ""}
|
| 13 |
+
</div>
|
| 14 |
+
|
| 15 |
+
<style>
|
| 16 |
+
.gallery {
|
| 17 |
+
padding: var(--size-1) var(--size-2);
|
| 18 |
+
}
|
| 19 |
+
</style>
|
6.0.0/simpledropdown/Index.svelte
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import type { SimpleDropdownProps, SimpleDropdownEvents } from "./types";
|
| 3 |
+
import { Gradio } from "@gradio/utils";
|
| 4 |
+
import { Block, BlockTitle } from "@gradio/atoms";
|
| 5 |
+
import { StatusTracker } from "@gradio/statustracker";
|
| 6 |
+
|
| 7 |
+
const props = $props();
|
| 8 |
+
const gradio = new Gradio<SimpleDropdownEvents, SimpleDropdownProps>(props);
|
| 9 |
+
|
| 10 |
+
let display_value = $state("");
|
| 11 |
+
let candidate: [string, string | number][] = [];
|
| 12 |
+
let old_value = $state(gradio.props.value);
|
| 13 |
+
|
| 14 |
+
const container = true;
|
| 15 |
+
|
| 16 |
+
$effect(() => {
|
| 17 |
+
if (display_value) {
|
| 18 |
+
candidate = gradio.props.choices.filter(
|
| 19 |
+
(choice) => choice[0] === display_value
|
| 20 |
+
);
|
| 21 |
+
gradio.props.value = candidate.length ? candidate[0][1] : "";
|
| 22 |
+
gradio.dispatch("input");
|
| 23 |
+
}
|
| 24 |
+
if (old_value != gradio.props.value) {
|
| 25 |
+
old_value = gradio.props.value;
|
| 26 |
+
gradio.dispatch("change");
|
| 27 |
+
}
|
| 28 |
+
});
|
| 29 |
+
</script>
|
| 30 |
+
|
| 31 |
+
<Block
|
| 32 |
+
visible={gradio.shared.visible}
|
| 33 |
+
elem_id={gradio.shared.elem_id}
|
| 34 |
+
elem_classes={gradio.shared.elem_classes}
|
| 35 |
+
padding={container}
|
| 36 |
+
allow_overflow={false}
|
| 37 |
+
scale={gradio.shared.scale}
|
| 38 |
+
min_width={gradio.shared.min_width}
|
| 39 |
+
>
|
| 40 |
+
{#if gradio.shared.loading_status}
|
| 41 |
+
<StatusTracker
|
| 42 |
+
autoscroll={gradio.shared.autoscroll}
|
| 43 |
+
i18n={gradio.i18n}
|
| 44 |
+
{...gradio.shared.loading_status}
|
| 45 |
+
on_clear_status={() =>
|
| 46 |
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
| 47 |
+
/>
|
| 48 |
+
{/if}
|
| 49 |
+
|
| 50 |
+
<label class:container>
|
| 51 |
+
<BlockTitle show_label={gradio.shared.show_label} info={undefined}
|
| 52 |
+
>{gradio.shared.label}</BlockTitle
|
| 53 |
+
>
|
| 54 |
+
<select disabled={!gradio.shared.interactive} bind:value={display_value}>
|
| 55 |
+
{#each gradio.props.choices as choice}
|
| 56 |
+
<option>{choice[0]}</option>
|
| 57 |
+
{/each}
|
| 58 |
+
</select>
|
| 59 |
+
</label>
|
| 60 |
+
</Block>
|
| 61 |
+
|
| 62 |
+
<style>
|
| 63 |
+
select {
|
| 64 |
+
--ring-color: transparent;
|
| 65 |
+
display: block;
|
| 66 |
+
position: relative;
|
| 67 |
+
outline: none !important;
|
| 68 |
+
box-shadow:
|
| 69 |
+
0 0 0 var(--shadow-spread) var(--ring-color),
|
| 70 |
+
var(--shadow-inset);
|
| 71 |
+
border: var(--input-border-width) solid var(--border-color-primary);
|
| 72 |
+
border-radius: var(--radius-lg);
|
| 73 |
+
background-color: var(--input-background-base);
|
| 74 |
+
padding: var(--size-2-5);
|
| 75 |
+
width: 100%;
|
| 76 |
+
color: var(--color-text-body);
|
| 77 |
+
font-size: var(--scale-00);
|
| 78 |
+
line-height: var(--line-sm);
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
select:focus {
|
| 82 |
+
--ring-color: var(--color-focus-ring);
|
| 83 |
+
border-color: var(--input-border-color-focus);
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
select::placeholder {
|
| 87 |
+
color: var(--color-text-placeholder);
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
select[disabled] {
|
| 91 |
+
cursor: not-allowed;
|
| 92 |
+
box-shadow: none;
|
| 93 |
+
}
|
| 94 |
+
</style>
|
6.0.0/simpledropdown/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/simpledropdown",
|
| 3 |
+
"version": "0.3.30",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"main_changeset": true,
|
| 10 |
+
"exports": {
|
| 11 |
+
".": {
|
| 12 |
+
"gradio": "./Index.svelte",
|
| 13 |
+
"svelte": "./dist/Index.svelte",
|
| 14 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 15 |
+
},
|
| 16 |
+
"./example": {
|
| 17 |
+
"gradio": "./Example.svelte",
|
| 18 |
+
"svelte": "./dist/Example.svelte",
|
| 19 |
+
"types": "./dist/Example.svelte.d.ts"
|
| 20 |
+
},
|
| 21 |
+
"./package.json": "./package.json"
|
| 22 |
+
},
|
| 23 |
+
"dependencies": {
|
| 24 |
+
"@gradio/atoms": "workspace:^",
|
| 25 |
+
"@gradio/icons": "workspace:^",
|
| 26 |
+
"@gradio/statustracker": "workspace:^",
|
| 27 |
+
"@gradio/utils": "workspace:^"
|
| 28 |
+
},
|
| 29 |
+
"devDependencies": {
|
| 30 |
+
"@gradio/preview": "workspace:^"
|
| 31 |
+
},
|
| 32 |
+
"peerDependencies": {
|
| 33 |
+
"svelte": "^5.43.4"
|
| 34 |
+
},
|
| 35 |
+
"repository": {
|
| 36 |
+
"type": "git",
|
| 37 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 38 |
+
"directory": "js/simpledropdown"
|
| 39 |
+
}
|
| 40 |
+
}
|
6.0.0/simpledropdown/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { LoadingStatus } from "@gradio/statustracker";
|
| 2 |
+
|
| 3 |
+
export interface SimpleDropdownProps {
|
| 4 |
+
value: string | number;
|
| 5 |
+
choices: [string, string | number][];
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
export interface SimpleDropdownEvents {
|
| 9 |
+
change: string;
|
| 10 |
+
input: never;
|
| 11 |
+
select: never;
|
| 12 |
+
clear_status: LoadingStatus;
|
| 13 |
+
}
|