Upload folder using huggingface_hub
Browse files- 6.0.0-dev.6/number/Example.svelte +19 -0
- 6.0.0-dev.6/number/Index.svelte +133 -0
- 6.0.0-dev.6/number/package.json +39 -0
- 6.0.0-dev.6/number/types.ts +19 -0
6.0.0-dev.6/number/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 !== null ? value : ""}
|
| 13 |
+
</div>
|
| 14 |
+
|
| 15 |
+
<style>
|
| 16 |
+
.gallery {
|
| 17 |
+
padding: var(--size-1) var(--size-2);
|
| 18 |
+
}
|
| 19 |
+
</style>
|
6.0.0-dev.6/number/Index.svelte
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import type { NumberProps, NumberEvents } from "./types";
|
| 3 |
+
import { Gradio } from "@gradio/utils";
|
| 4 |
+
import { Block, BlockTitle } from "@gradio/atoms";
|
| 5 |
+
import { StatusTracker } from "@gradio/statustracker";
|
| 6 |
+
import { tick } from "svelte";
|
| 7 |
+
|
| 8 |
+
const props = $props();
|
| 9 |
+
const gradio = new Gradio<NumberEvents, NumberProps>(props);
|
| 10 |
+
|
| 11 |
+
gradio.props.value ??= 0;
|
| 12 |
+
|
| 13 |
+
let old_value = $state(gradio.props.value);
|
| 14 |
+
|
| 15 |
+
$effect(() => {
|
| 16 |
+
if (old_value != gradio.props.value) {
|
| 17 |
+
//@ts-ignore
|
| 18 |
+
old_value = gradio.props.value;
|
| 19 |
+
gradio.dispatch("change");
|
| 20 |
+
}
|
| 21 |
+
});
|
| 22 |
+
|
| 23 |
+
async function handle_keypress(e: KeyboardEvent): Promise<void> {
|
| 24 |
+
await tick();
|
| 25 |
+
if (e.key === "Enter") {
|
| 26 |
+
e.preventDefault();
|
| 27 |
+
gradio.dispatch("submit");
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
const disabled = $derived(!gradio.shared.interactive);
|
| 31 |
+
</script>
|
| 32 |
+
|
| 33 |
+
<Block
|
| 34 |
+
visible={gradio.shared.visible}
|
| 35 |
+
elem_id={gradio.shared.elem_id}
|
| 36 |
+
elem_classes={gradio.shared.elem_classes}
|
| 37 |
+
padding={gradio.shared.container}
|
| 38 |
+
allow_overflow={false}
|
| 39 |
+
scale={gradio.shared.scale}
|
| 40 |
+
min_width={gradio.shared.min_width}
|
| 41 |
+
>
|
| 42 |
+
<StatusTracker
|
| 43 |
+
autoscroll={gradio.shared.autoscroll}
|
| 44 |
+
i18n={gradio.i18n}
|
| 45 |
+
{...gradio.shared.loading_status}
|
| 46 |
+
show_validation_error={false}
|
| 47 |
+
on:clear_status={() =>
|
| 48 |
+
gradio.dispatch("clear_status", gradio.shared.loading_status)}
|
| 49 |
+
/>
|
| 50 |
+
<label class="block" class:container={gradio.shared.container}>
|
| 51 |
+
<BlockTitle show_label={gradio.shared.show_label} info={gradio.props.info}
|
| 52 |
+
>{gradio.shared.label || "Number"}
|
| 53 |
+
{#if gradio.shared.loading_status?.validation_error}
|
| 54 |
+
<div class="validation-error">
|
| 55 |
+
{gradio.shared.loading_status?.validation_error}
|
| 56 |
+
</div>
|
| 57 |
+
{/if}
|
| 58 |
+
</BlockTitle>
|
| 59 |
+
|
| 60 |
+
<input
|
| 61 |
+
class:validation-error={gradio.shared.loading_status?.validation_error}
|
| 62 |
+
aria-label={gradio.shared.label || "Number"}
|
| 63 |
+
type="number"
|
| 64 |
+
bind:value={gradio.props.value}
|
| 65 |
+
min={gradio.props.minimum}
|
| 66 |
+
max={gradio.props.maximum}
|
| 67 |
+
step={gradio.props.step}
|
| 68 |
+
placeholder={gradio.props.placeholder}
|
| 69 |
+
on:keypress={handle_keypress}
|
| 70 |
+
on:input={() => gradio.dispatch("input")}
|
| 71 |
+
on:blur={() => gradio.dispatch("blur")}
|
| 72 |
+
on:focus={() => gradio.dispatch("focus")}
|
| 73 |
+
{disabled}
|
| 74 |
+
/>
|
| 75 |
+
</label>
|
| 76 |
+
</Block>
|
| 77 |
+
|
| 78 |
+
<style>
|
| 79 |
+
label:not(.container),
|
| 80 |
+
label:not(.container) > input {
|
| 81 |
+
height: 100%;
|
| 82 |
+
border: none;
|
| 83 |
+
}
|
| 84 |
+
.container > input {
|
| 85 |
+
border: var(--input-border-width) solid var(--input-border-color);
|
| 86 |
+
border-radius: var(--input-radius);
|
| 87 |
+
}
|
| 88 |
+
input[type="number"] {
|
| 89 |
+
display: block;
|
| 90 |
+
position: relative;
|
| 91 |
+
outline: none !important;
|
| 92 |
+
box-shadow: var(--input-shadow);
|
| 93 |
+
background: var(--input-background-fill);
|
| 94 |
+
padding: var(--input-padding);
|
| 95 |
+
width: 100%;
|
| 96 |
+
color: var(--body-text-color);
|
| 97 |
+
font-size: var(--input-text-size);
|
| 98 |
+
line-height: var(--line-sm);
|
| 99 |
+
}
|
| 100 |
+
input:disabled {
|
| 101 |
+
-webkit-text-fill-color: var(--body-text-color);
|
| 102 |
+
-webkit-opacity: 1;
|
| 103 |
+
opacity: 1;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
input:focus {
|
| 107 |
+
box-shadow: var(--input-shadow-focus);
|
| 108 |
+
border-color: var(--input-border-color-focus);
|
| 109 |
+
background: var(--input-background-fill-focus);
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
input::placeholder {
|
| 113 |
+
color: var(--input-placeholder-color);
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
input:out-of-range {
|
| 117 |
+
border: var(--input-border-width) solid var(--error-border-color);
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
div.validation-error {
|
| 121 |
+
color: var(--error-icon-color);
|
| 122 |
+
font-size: var(--font-sans);
|
| 123 |
+
margin-top: var(--spacing-sm);
|
| 124 |
+
font-weight: var(--weight-semibold);
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
label.container input.validation-error {
|
| 128 |
+
border-color: transparent !important;
|
| 129 |
+
box-shadow:
|
| 130 |
+
0 0 3px 1px var(--error-icon-color),
|
| 131 |
+
var(--shadow-inset) !important;
|
| 132 |
+
}
|
| 133 |
+
</style>
|
6.0.0-dev.6/number/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/number",
|
| 3 |
+
"version": "0.7.2-dev.1",
|
| 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/statustracker": "workspace:^",
|
| 26 |
+
"@gradio/utils": "workspace:^"
|
| 27 |
+
},
|
| 28 |
+
"devDependencies": {
|
| 29 |
+
"@gradio/preview": "workspace:^"
|
| 30 |
+
},
|
| 31 |
+
"peerDependencies": {
|
| 32 |
+
"svelte": "^5.43.4"
|
| 33 |
+
},
|
| 34 |
+
"repository": {
|
| 35 |
+
"type": "git",
|
| 36 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 37 |
+
"directory": "js/number"
|
| 38 |
+
}
|
| 39 |
+
}
|
6.0.0-dev.6/number/types.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { LoadingStatus } from "js/statustracker";
|
| 2 |
+
|
| 3 |
+
export interface NumberProps {
|
| 4 |
+
value: number | null;
|
| 5 |
+
placeholder: string;
|
| 6 |
+
minimum: number | undefined;
|
| 7 |
+
maximum: number | undefined;
|
| 8 |
+
step: number | null;
|
| 9 |
+
info: string | undefined;
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
export interface NumberEvents {
|
| 13 |
+
change: never;
|
| 14 |
+
input: never;
|
| 15 |
+
submit: never;
|
| 16 |
+
blur: never;
|
| 17 |
+
focus: never;
|
| 18 |
+
clear_status: LoadingStatus;
|
| 19 |
+
}
|