gradio-pr-bot commited on
Commit
3699098
·
verified ·
1 Parent(s): 208e308

Upload folder using huggingface_hub

Browse files
5.49.1/radio/Example.svelte ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script lang="ts">
2
+ export let value: string | null;
3
+ export let type: "gallery" | "table";
4
+ export let selected = false;
5
+ export let choices: [string, string | number][];
6
+
7
+ let name_string: string;
8
+
9
+ if (value === null) {
10
+ name_string = "";
11
+ } else {
12
+ let name = choices.find((pair) => pair[1] === value);
13
+ name_string = name ? name[0] : "";
14
+ }
15
+ </script>
16
+
17
+ <div
18
+ class:table={type === "table"}
19
+ class:gallery={type === "gallery"}
20
+ class:selected
21
+ >
22
+ {name_string}
23
+ </div>
24
+
25
+ <style>
26
+ .gallery {
27
+ padding: var(--size-1) var(--size-2);
28
+ }
29
+ </style>
5.49.1/radio/Index.svelte ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script context="module" lang="ts">
2
+ export { default as BaseRadio } from "./shared/Radio.svelte";
3
+ export { default as BaseExample } from "./Example.svelte";
4
+ </script>
5
+
6
+ <script lang="ts">
7
+ import type { Gradio, SelectData } from "@gradio/utils";
8
+ import { Block, BlockTitle } from "@gradio/atoms";
9
+ import { StatusTracker } from "@gradio/statustracker";
10
+ import type { LoadingStatus } from "@gradio/statustracker";
11
+ import BaseRadio from "./shared/Radio.svelte";
12
+
13
+ export let gradio: Gradio<{
14
+ change: never;
15
+ select: SelectData;
16
+ input: never;
17
+ clear_status: LoadingStatus;
18
+ }>;
19
+
20
+ export let label = gradio.i18n("radio.radio");
21
+ export let info: string | undefined = undefined;
22
+ export let elem_id = "";
23
+ export let elem_classes: string[] = [];
24
+ export let visible: boolean | "hidden" = true;
25
+ export let value: string | null = null;
26
+ export let choices: [string, string | number][] = [];
27
+ export let show_label = true;
28
+ export let container = false;
29
+ export let scale: number | null = null;
30
+ export let min_width: number | undefined = undefined;
31
+ export let loading_status: LoadingStatus;
32
+ export let interactive = true;
33
+ export let rtl = false;
34
+
35
+ let pending_select: { value: string | number; index: number } | null = null;
36
+
37
+ function handle_change(): void {
38
+ gradio.dispatch("change");
39
+ }
40
+
41
+ let old_value = value;
42
+ $: {
43
+ if (value !== old_value) {
44
+ old_value = value;
45
+ handle_change();
46
+ if (pending_select && value === pending_select.value) {
47
+ gradio.dispatch("select", {
48
+ value: pending_select.value,
49
+ index: pending_select.index
50
+ });
51
+ gradio.dispatch("input");
52
+ pending_select = null;
53
+ }
54
+ }
55
+ }
56
+ $: disabled = !interactive;
57
+ </script>
58
+
59
+ <Block
60
+ {visible}
61
+ type="fieldset"
62
+ {elem_id}
63
+ {elem_classes}
64
+ {container}
65
+ {scale}
66
+ {min_width}
67
+ {rtl}
68
+ >
69
+ <StatusTracker
70
+ autoscroll={gradio.autoscroll}
71
+ i18n={gradio.i18n}
72
+ {...loading_status}
73
+ on:clear_status={() => gradio.dispatch("clear_status", loading_status)}
74
+ />
75
+
76
+ <BlockTitle {show_label} {info}>{label}</BlockTitle>
77
+
78
+ <div class="wrap">
79
+ {#each choices as [display_value, internal_value], i (i)}
80
+ <BaseRadio
81
+ {display_value}
82
+ {internal_value}
83
+ bind:selected={value}
84
+ {disabled}
85
+ {rtl}
86
+ on:input={() => {
87
+ pending_select = { value: internal_value, index: i };
88
+ }}
89
+ />
90
+ {/each}
91
+ </div>
92
+ </Block>
93
+
94
+ <style>
95
+ .wrap {
96
+ display: flex;
97
+ flex-wrap: wrap;
98
+ gap: var(--checkbox-label-gap);
99
+ }
100
+ </style>
5.49.1/radio/package.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "@gradio/radio",
3
+ "version": "0.7.12",
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
+ ".": {
13
+ "gradio": "./Index.svelte",
14
+ "svelte": "./dist/Index.svelte",
15
+ "types": "./dist/Index.svelte.d.ts"
16
+ },
17
+ "./example": {
18
+ "gradio": "./Example.svelte",
19
+ "svelte": "./dist/Example.svelte",
20
+ "types": "./dist/Example.svelte.d.ts"
21
+ },
22
+ "./package.json": "./package.json"
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": "^4.0.0"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/gradio-app/gradio.git",
38
+ "directory": "js/radio"
39
+ }
40
+ }
5.49.1/radio/shared/Radio.svelte ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script context="module">
2
+ let id = 0;
3
+ </script>
4
+
5
+ <script lang="ts">
6
+ import { createEventDispatcher } from "svelte";
7
+ export let display_value: string;
8
+ export let internal_value: string | number;
9
+ export let disabled = false;
10
+ export let selected: string | null = null;
11
+ export let rtl = false;
12
+
13
+ const dispatch = createEventDispatcher<{ input: string | number }>();
14
+ let is_selected = false;
15
+
16
+ $: is_selected = selected === internal_value;
17
+
18
+ function handle_input(
19
+ e: Event & { currentTarget: EventTarget & HTMLInputElement }
20
+ ): void {
21
+ is_selected = e.currentTarget.checked;
22
+ if (e.currentTarget.checked) {
23
+ dispatch("input", internal_value);
24
+ }
25
+ }
26
+ </script>
27
+
28
+ <label
29
+ class:disabled
30
+ class:selected={is_selected}
31
+ data-testid="{display_value}-radio-label"
32
+ class:rtl
33
+ >
34
+ <input
35
+ {disabled}
36
+ type="radio"
37
+ name="radio-{++id}"
38
+ value={internal_value}
39
+ aria-checked={is_selected}
40
+ bind:group={selected}
41
+ on:input={handle_input}
42
+ />
43
+ <span>{display_value}</span>
44
+ </label>
45
+
46
+ <style>
47
+ label {
48
+ display: flex;
49
+ align-items: center;
50
+ transition: var(--button-transition);
51
+ cursor: pointer;
52
+ box-shadow: var(--checkbox-label-shadow);
53
+ border: var(--checkbox-label-border-width) solid
54
+ var(--checkbox-label-border-color);
55
+ border-radius: var(--checkbox-border-radius);
56
+ background: var(--checkbox-label-background-fill);
57
+ padding: var(--checkbox-label-padding);
58
+ color: var(--checkbox-label-text-color);
59
+ font-weight: var(--checkbox-label-text-weight);
60
+ font-size: var(--checkbox-label-text-size);
61
+ line-height: var(--line-md);
62
+ }
63
+
64
+ label:hover {
65
+ background: var(--checkbox-label-background-fill-hover);
66
+ }
67
+ label:focus {
68
+ background: var(--checkbox-label-background-fill-focus);
69
+ }
70
+
71
+ label.selected {
72
+ background: var(--checkbox-label-background-fill-selected);
73
+ color: var(--checkbox-label-text-color-selected);
74
+ border-color: var(--checkbox-label-border-color-selected);
75
+ }
76
+
77
+ label > * + * {
78
+ margin-left: var(--size-2);
79
+ }
80
+
81
+ label.rtl > * + * {
82
+ margin-left: 0;
83
+ margin-right: var(--size-2);
84
+ }
85
+
86
+ input {
87
+ --ring-color: transparent;
88
+ position: relative;
89
+ box-shadow: var(--checkbox-shadow);
90
+ border: var(--checkbox-border-width) solid var(--checkbox-border-color);
91
+ border-radius: var(--radius-full);
92
+ background-color: var(--checkbox-background-color);
93
+ line-height: var(--line-sm);
94
+ }
95
+
96
+ input:checked,
97
+ input:checked:hover {
98
+ border-color: var(--checkbox-border-color-selected);
99
+ background-image: var(--radio-circle);
100
+ background-color: var(--checkbox-background-color-selected);
101
+ }
102
+
103
+ input:checked::after {
104
+ content: "";
105
+ position: absolute;
106
+ top: 50%;
107
+ left: 50%;
108
+ transform: translate(-50%, -50%);
109
+ border-radius: 50%;
110
+ background-color: white;
111
+ }
112
+
113
+ input:hover {
114
+ border-color: var(--checkbox-border-color-hover);
115
+ background-color: var(--checkbox-background-color-hover);
116
+ }
117
+
118
+ input:focus {
119
+ border-color: var(--checkbox-border-color-focus);
120
+ background-color: var(--checkbox-background-color-focus);
121
+ }
122
+
123
+ input:checked:focus {
124
+ border-color: var(--checkbox-border-color-focus);
125
+ background-image: var(--radio-circle);
126
+ background-color: var(--checkbox-background-color-selected);
127
+ }
128
+
129
+ input[disabled],
130
+ .disabled {
131
+ cursor: not-allowed;
132
+ }
133
+ </style>