Upload folder using huggingface_hub
Browse files
6.0.0-dev.6/checkbox/Example.svelte
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let value: boolean | 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 !== null ? value.toLocaleString() : ""}
|
| 13 |
+
</div>
|
| 14 |
+
|
| 15 |
+
<style>
|
| 16 |
+
.gallery {
|
| 17 |
+
padding: var(--size-1) var(--size-2);
|
| 18 |
+
}
|
| 19 |
+
</style>
|
6.0.0-dev.6/checkbox/Index.svelte
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script context="module" lang="ts">
|
| 2 |
+
export { default as BaseCheckbox } from "./shared/Checkbox.svelte";
|
| 3 |
+
</script>
|
| 4 |
+
|
| 5 |
+
<script lang="ts">
|
| 6 |
+
import { Gradio } from "@gradio/utils";
|
| 7 |
+
import { Block, Info } from "@gradio/atoms";
|
| 8 |
+
import { StatusTracker } from "@gradio/statustracker";
|
| 9 |
+
import type { CheckboxProps, CheckboxEvents } from "./types";
|
| 10 |
+
import BaseCheckbox from "./shared/Checkbox.svelte";
|
| 11 |
+
|
| 12 |
+
let props = $props();
|
| 13 |
+
const gradio = new Gradio<CheckboxEvents, CheckboxProps>(props);
|
| 14 |
+
</script>
|
| 15 |
+
|
| 16 |
+
<Block
|
| 17 |
+
visible={gradio.shared.visible}
|
| 18 |
+
elem_id={gradio.shared.elem_id}
|
| 19 |
+
elem_classes={gradio.shared.elem_classes}
|
| 20 |
+
>
|
| 21 |
+
<StatusTracker
|
| 22 |
+
autoscroll={gradio.shared.autoscroll}
|
| 23 |
+
i18n={gradio.i18n}
|
| 24 |
+
{...gradio.shared.loading_status}
|
| 25 |
+
on:clear_status={() =>
|
| 26 |
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
| 27 |
+
/>
|
| 28 |
+
<BaseCheckbox {gradio} />
|
| 29 |
+
{#if gradio.props.info}
|
| 30 |
+
<Info info={gradio.props.info} />
|
| 31 |
+
{/if}
|
| 32 |
+
</Block>
|
6.0.0-dev.6/checkbox/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/checkbox",
|
| 3 |
+
"version": "0.5.0-dev.1",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"private": false,
|
| 9 |
+
"main_changeset": true,
|
| 10 |
+
"main": "./Index.svelte",
|
| 11 |
+
"exports": {
|
| 12 |
+
"./package.json": "./package.json",
|
| 13 |
+
".": {
|
| 14 |
+
"gradio": "./Index.svelte",
|
| 15 |
+
"svelte": "./dist/Index.svelte",
|
| 16 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 17 |
+
},
|
| 18 |
+
"./example": {
|
| 19 |
+
"gradio": "./Example.svelte",
|
| 20 |
+
"svelte": "./dist/Example.svelte",
|
| 21 |
+
"types": "./dist/Example.svelte.d.ts"
|
| 22 |
+
}
|
| 23 |
+
},
|
| 24 |
+
"dependencies": {
|
| 25 |
+
"@gradio/atoms": "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/checkbox"
|
| 39 |
+
}
|
| 40 |
+
}
|
6.0.0-dev.6/checkbox/shared/Checkbox.svelte
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import type { Gradio } from "@gradio/utils";
|
| 3 |
+
import type { CheckboxProps, CheckboxEvents } from "../types";
|
| 4 |
+
|
| 5 |
+
const props = $props();
|
| 6 |
+
const gradio: Gradio<CheckboxEvents, CheckboxProps> = props.gradio;
|
| 7 |
+
|
| 8 |
+
let disabled = $derived(!gradio.shared.interactive);
|
| 9 |
+
|
| 10 |
+
let old_value = $state(gradio.props.value);
|
| 11 |
+
let label = $derived(gradio.shared.label || gradio.i18n("checkbox.checkbox"));
|
| 12 |
+
|
| 13 |
+
$effect(() => {
|
| 14 |
+
if (old_value !== gradio.props.value) {
|
| 15 |
+
old_value = gradio.props.value;
|
| 16 |
+
gradio.dispatch("change", $state.snapshot(gradio.props.value));
|
| 17 |
+
}
|
| 18 |
+
});
|
| 19 |
+
|
| 20 |
+
async function handle_enter(
|
| 21 |
+
event: KeyboardEvent & { currentTarget: EventTarget & HTMLInputElement }
|
| 22 |
+
): Promise<void> {
|
| 23 |
+
if (event.key === "Enter") {
|
| 24 |
+
gradio.props.value = !gradio.props.value;
|
| 25 |
+
gradio.dispatch("select", {
|
| 26 |
+
index: 0,
|
| 27 |
+
value: event.currentTarget.checked,
|
| 28 |
+
selected: event.currentTarget.checked
|
| 29 |
+
});
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
async function handle_input(
|
| 34 |
+
event: Event & { currentTarget: EventTarget & HTMLInputElement }
|
| 35 |
+
): Promise<void> {
|
| 36 |
+
gradio.props.value = event.currentTarget.checked;
|
| 37 |
+
gradio.dispatch("select", {
|
| 38 |
+
index: 0,
|
| 39 |
+
value: event.currentTarget.checked,
|
| 40 |
+
selected: event.currentTarget.checked
|
| 41 |
+
});
|
| 42 |
+
gradio.dispatch("input");
|
| 43 |
+
}
|
| 44 |
+
</script>
|
| 45 |
+
|
| 46 |
+
<label class="checkbox-container" class:disabled>
|
| 47 |
+
<input
|
| 48 |
+
bind:checked={gradio.props.value}
|
| 49 |
+
on:keydown={handle_enter}
|
| 50 |
+
on:input={handle_input}
|
| 51 |
+
{disabled}
|
| 52 |
+
type="checkbox"
|
| 53 |
+
name="test"
|
| 54 |
+
data-testid="checkbox"
|
| 55 |
+
/>
|
| 56 |
+
{#if gradio.shared.show_label}
|
| 57 |
+
<span class="label-text">
|
| 58 |
+
{label}
|
| 59 |
+
</span>
|
| 60 |
+
{/if}
|
| 61 |
+
</label>
|
| 62 |
+
|
| 63 |
+
<style>
|
| 64 |
+
.checkbox-container {
|
| 65 |
+
display: flex;
|
| 66 |
+
align-items: center;
|
| 67 |
+
gap: var(--spacing-lg);
|
| 68 |
+
cursor: pointer;
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
.label-text {
|
| 72 |
+
color: var(--body-text-color);
|
| 73 |
+
font-size: var(--checkbox-label-text-size);
|
| 74 |
+
line-height: var(--line-sm);
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
.info {
|
| 78 |
+
display: block;
|
| 79 |
+
color: var(--body-text-color-subdued);
|
| 80 |
+
font-size: var(--text-xs);
|
| 81 |
+
margin-top: var(--spacing-xs);
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
input {
|
| 85 |
+
--ring-color: transparent;
|
| 86 |
+
position: relative;
|
| 87 |
+
box-shadow: var(--checkbox-shadow);
|
| 88 |
+
border: 1px solid var(--checkbox-border-color);
|
| 89 |
+
border-radius: var(--checkbox-border-radius);
|
| 90 |
+
background-color: var(--checkbox-background-color);
|
| 91 |
+
line-height: var(--line-sm);
|
| 92 |
+
flex-shrink: 0;
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
input:checked,
|
| 96 |
+
input:checked:hover,
|
| 97 |
+
input:checked:focus {
|
| 98 |
+
background-image: var(--checkbox-check);
|
| 99 |
+
background-color: var(--checkbox-background-color-selected);
|
| 100 |
+
border-color: var(--checkbox-border-color-focus);
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
input:checked:focus {
|
| 104 |
+
background-image: var(--checkbox-check);
|
| 105 |
+
background-color: var(--checkbox-background-color-selected);
|
| 106 |
+
border-color: var(--checkbox-border-color-focus);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
input:hover {
|
| 110 |
+
border-color: var(--checkbox-border-color-hover);
|
| 111 |
+
background-color: var(--checkbox-background-color-hover);
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
input:focus {
|
| 115 |
+
border-color: var(--checkbox-border-color-focus);
|
| 116 |
+
background-color: var(--checkbox-background-color-focus);
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
input:indeterminate {
|
| 120 |
+
background-image: none;
|
| 121 |
+
background-color: var(--checkbox-background-color-selected);
|
| 122 |
+
border-color: var(--checkbox-border-color-focus);
|
| 123 |
+
position: relative;
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
input:indeterminate::after {
|
| 127 |
+
content: "";
|
| 128 |
+
position: absolute;
|
| 129 |
+
top: 50%;
|
| 130 |
+
left: 50%;
|
| 131 |
+
transform: translate(-50%, -50%);
|
| 132 |
+
width: 8px;
|
| 133 |
+
height: 2px;
|
| 134 |
+
background-color: white;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
input:indeterminate:hover {
|
| 138 |
+
background-color: var(--checkbox-background-color-selected);
|
| 139 |
+
border-color: var(--checkbox-border-color-hover);
|
| 140 |
+
}
|
| 141 |
+
|
| 142 |
+
input:indeterminate:focus {
|
| 143 |
+
background-color: var(--checkbox-background-color-selected);
|
| 144 |
+
border-color: var(--checkbox-border-color-focus);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
input[disabled] {
|
| 148 |
+
cursor: not-allowed;
|
| 149 |
+
opacity: 0.75;
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
label.disabled {
|
| 153 |
+
cursor: not-allowed;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
input:not([disabled]):hover {
|
| 157 |
+
cursor: pointer;
|
| 158 |
+
}
|
| 159 |
+
</style>
|
6.0.0-dev.6/checkbox/types.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { SelectData } from "@gradio/utils";
|
| 2 |
+
import type { LoadingStatus } from "js/statustracker";
|
| 3 |
+
|
| 4 |
+
export interface CheckboxProps {
|
| 5 |
+
value: boolean;
|
| 6 |
+
info: string;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
export interface CheckboxEvents {
|
| 10 |
+
change: boolean;
|
| 11 |
+
input: boolean;
|
| 12 |
+
select: SelectData;
|
| 13 |
+
clear_status: LoadingStatus;
|
| 14 |
+
}
|