Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- .gitignore +12 -0
- README.md +322 -7
- __init__.py +0 -0
- app.py +48 -0
- css.css +157 -0
- requirements.txt +1 -0
- space.py +170 -0
- src/.gitignore +12 -0
- src/README.md +327 -0
- src/backend/gradio_datetimerange/__init__.py +4 -0
- src/backend/gradio_datetimerange/datetimerange.py +158 -0
- src/backend/gradio_datetimerange/templates/component/index.js +2250 -0
- src/backend/gradio_datetimerange/templates/component/style.css +1 -0
- src/backend/gradio_datetimerange/templates/example/index.js +48 -0
- src/demo/__init__.py +0 -0
- src/demo/app.py +48 -0
- src/demo/css.css +157 -0
- src/demo/requirements.txt +1 -0
- src/demo/space.py +170 -0
- src/frontend/Example.svelte +5 -0
- src/frontend/Index.svelte +106 -0
- src/frontend/gradio.config.js +9 -0
- src/frontend/package-lock.json +0 -0
- src/frontend/package.json +26 -0
- src/package-lock.json +6 -0
- src/pyproject.toml +51 -0
.gitignore
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.eggs/
|
2 |
+
dist/
|
3 |
+
*.pyc
|
4 |
+
__pycache__/
|
5 |
+
*.py[cod]
|
6 |
+
*$py.class
|
7 |
+
__tmp/*
|
8 |
+
*.pyi
|
9 |
+
.mypycache
|
10 |
+
.ruff_cache
|
11 |
+
node_modules
|
12 |
+
backend/**/templates/
|
README.md
CHANGED
@@ -1,12 +1,327 @@
|
|
1 |
---
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 4.39.0
|
8 |
-
app_file: app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
tags: [gradio-custom-component, DateTime]
|
3 |
+
title: gradio_datetimerange
|
4 |
+
short_description: Component to create time ranges.
|
5 |
+
colorFrom: blue
|
6 |
+
colorTo: yellow
|
7 |
sdk: gradio
|
|
|
|
|
8 |
pinned: false
|
9 |
+
app_file: space.py
|
10 |
---
|
11 |
|
12 |
+
# `gradio_datetimerange`
|
13 |
+
<a href="https://pypi.org/project/gradio_datetimerange/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_datetimerange"></a>
|
14 |
+
|
15 |
+
Component to create time ranges.
|
16 |
+
|
17 |
+
## Installation
|
18 |
+
|
19 |
+
```bash
|
20 |
+
pip install gradio_datetimerange
|
21 |
+
```
|
22 |
+
|
23 |
+
## Usage
|
24 |
+
|
25 |
+
```python
|
26 |
+
|
27 |
+
import gradio as gr
|
28 |
+
from gradio_datetimerange import DateTimeRange
|
29 |
+
import pandas as pd
|
30 |
+
from random import randint
|
31 |
+
|
32 |
+
temp_sensor_data = pd.DataFrame(
|
33 |
+
{
|
34 |
+
"time": pd.date_range("2021-01-01", end="2021-01-05", periods=200),
|
35 |
+
"temperature": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
36 |
+
"humidity": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
37 |
+
"location": ["indoor", "outdoor"] * 100,
|
38 |
+
}
|
39 |
+
)
|
40 |
+
|
41 |
+
with gr.Blocks() as demo:
|
42 |
+
date = DateTimeRange(["2021-01-01 00:00:00", "2021-01-07 00:00:00"])
|
43 |
+
merged_temp_plot = gr.LinePlot(
|
44 |
+
temp_sensor_data,
|
45 |
+
x="time",
|
46 |
+
y="temperature",
|
47 |
+
)
|
48 |
+
split_temp_plot = gr.LinePlot(
|
49 |
+
temp_sensor_data,
|
50 |
+
x="time",
|
51 |
+
y="temperature",
|
52 |
+
color="location",
|
53 |
+
)
|
54 |
+
with gr.Row():
|
55 |
+
humidity_bar_plot = gr.BarPlot(
|
56 |
+
temp_sensor_data,
|
57 |
+
x="time",
|
58 |
+
y="humidity",
|
59 |
+
color="location",
|
60 |
+
x_bin="1h",
|
61 |
+
)
|
62 |
+
humidity_scatter_plot = gr.ScatterPlot(
|
63 |
+
temp_sensor_data,
|
64 |
+
x="time",
|
65 |
+
y="humidity",
|
66 |
+
color="location",
|
67 |
+
)
|
68 |
+
|
69 |
+
date.bind([merged_temp_plot, split_temp_plot, humidity_bar_plot, humidity_scatter_plot])
|
70 |
+
|
71 |
+
|
72 |
+
if __name__ == "__main__":
|
73 |
+
demo.launch()
|
74 |
+
|
75 |
+
```
|
76 |
+
|
77 |
+
## `DateTimeRange`
|
78 |
+
|
79 |
+
### Initialization
|
80 |
+
|
81 |
+
<table>
|
82 |
+
<thead>
|
83 |
+
<tr>
|
84 |
+
<th align="left">name</th>
|
85 |
+
<th align="left" style="width: 25%;">type</th>
|
86 |
+
<th align="left">default</th>
|
87 |
+
<th align="left">description</th>
|
88 |
+
</tr>
|
89 |
+
</thead>
|
90 |
+
<tbody>
|
91 |
+
<tr>
|
92 |
+
<td align="left"><code>value</code></td>
|
93 |
+
<td align="left" style="width: 25%;">
|
94 |
+
|
95 |
+
```python
|
96 |
+
tuple[float | str | datetime, float | str | datetime] | None
|
97 |
+
```
|
98 |
+
|
99 |
+
</td>
|
100 |
+
<td align="left"><code>None</code></td>
|
101 |
+
<td align="left">default value for datetime.</td>
|
102 |
+
</tr>
|
103 |
+
|
104 |
+
<tr>
|
105 |
+
<td align="left"><code>include_time</code></td>
|
106 |
+
<td align="left" style="width: 25%;">
|
107 |
+
|
108 |
+
```python
|
109 |
+
bool
|
110 |
+
```
|
111 |
+
|
112 |
+
</td>
|
113 |
+
<td align="left"><code>True</code></td>
|
114 |
+
<td align="left">If True, the component will include time selection. If False, only date selection will be available.</td>
|
115 |
+
</tr>
|
116 |
+
|
117 |
+
<tr>
|
118 |
+
<td align="left"><code>type</code></td>
|
119 |
+
<td align="left" style="width: 25%;">
|
120 |
+
|
121 |
+
```python
|
122 |
+
Literal["timestamp", "datetime", "string"]
|
123 |
+
```
|
124 |
+
|
125 |
+
</td>
|
126 |
+
<td align="left"><code>"timestamp"</code></td>
|
127 |
+
<td align="left">The type of the value. Can be "timestamp", "datetime", or "string". If "timestamp", the value will be a number representing the start and end date in seconds since epoch. If "datetime", the value will be a datetime object. If "string", the value will be the date entered by the user.</td>
|
128 |
+
</tr>
|
129 |
+
|
130 |
+
<tr>
|
131 |
+
<td align="left"><code>timezone</code></td>
|
132 |
+
<td align="left" style="width: 25%;">
|
133 |
+
|
134 |
+
```python
|
135 |
+
str | None
|
136 |
+
```
|
137 |
+
|
138 |
+
</td>
|
139 |
+
<td align="left"><code>None</code></td>
|
140 |
+
<td align="left">The timezone to use for timestamps, such as "US/Pacific" or "Europe/Paris". If None, the timezone will be the local timezone.</td>
|
141 |
+
</tr>
|
142 |
+
|
143 |
+
<tr>
|
144 |
+
<td align="left"><code>quick_ranges</code></td>
|
145 |
+
<td align="left" style="width: 25%;">
|
146 |
+
|
147 |
+
```python
|
148 |
+
list[str] | None
|
149 |
+
```
|
150 |
+
|
151 |
+
</td>
|
152 |
+
<td align="left"><code>None</code></td>
|
153 |
+
<td align="left">List of strings representing quick ranges to display, such as ["30s", "1h", "24h", "7d"]. Set to [] to clear.</td>
|
154 |
+
</tr>
|
155 |
+
|
156 |
+
<tr>
|
157 |
+
<td align="left"><code>label</code></td>
|
158 |
+
<td align="left" style="width: 25%;">
|
159 |
+
|
160 |
+
```python
|
161 |
+
str | None
|
162 |
+
```
|
163 |
+
|
164 |
+
</td>
|
165 |
+
<td align="left"><code>None</code></td>
|
166 |
+
<td align="left">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>
|
167 |
+
</tr>
|
168 |
+
|
169 |
+
<tr>
|
170 |
+
<td align="left"><code>show_label</code></td>
|
171 |
+
<td align="left" style="width: 25%;">
|
172 |
+
|
173 |
+
```python
|
174 |
+
bool | None
|
175 |
+
```
|
176 |
+
|
177 |
+
</td>
|
178 |
+
<td align="left"><code>None</code></td>
|
179 |
+
<td align="left">if True, will display label.</td>
|
180 |
+
</tr>
|
181 |
+
|
182 |
+
<tr>
|
183 |
+
<td align="left"><code>info</code></td>
|
184 |
+
<td align="left" style="width: 25%;">
|
185 |
+
|
186 |
+
```python
|
187 |
+
str | None
|
188 |
+
```
|
189 |
+
|
190 |
+
</td>
|
191 |
+
<td align="left"><code>None</code></td>
|
192 |
+
<td align="left">additional component description.</td>
|
193 |
+
</tr>
|
194 |
+
|
195 |
+
<tr>
|
196 |
+
<td align="left"><code>every</code></td>
|
197 |
+
<td align="left" style="width: 25%;">
|
198 |
+
|
199 |
+
```python
|
200 |
+
float | None
|
201 |
+
```
|
202 |
+
|
203 |
+
</td>
|
204 |
+
<td align="left"><code>None</code></td>
|
205 |
+
<td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
|
206 |
+
</tr>
|
207 |
+
|
208 |
+
<tr>
|
209 |
+
<td align="left"><code>scale</code></td>
|
210 |
+
<td align="left" style="width: 25%;">
|
211 |
+
|
212 |
+
```python
|
213 |
+
int | None
|
214 |
+
```
|
215 |
+
|
216 |
+
</td>
|
217 |
+
<td align="left"><code>None</code></td>
|
218 |
+
<td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
|
219 |
+
</tr>
|
220 |
+
|
221 |
+
<tr>
|
222 |
+
<td align="left"><code>min_width</code></td>
|
223 |
+
<td align="left" style="width: 25%;">
|
224 |
+
|
225 |
+
```python
|
226 |
+
int
|
227 |
+
```
|
228 |
+
|
229 |
+
</td>
|
230 |
+
<td align="left"><code>160</code></td>
|
231 |
+
<td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
|
232 |
+
</tr>
|
233 |
+
|
234 |
+
<tr>
|
235 |
+
<td align="left"><code>visible</code></td>
|
236 |
+
<td align="left" style="width: 25%;">
|
237 |
+
|
238 |
+
```python
|
239 |
+
bool
|
240 |
+
```
|
241 |
+
|
242 |
+
</td>
|
243 |
+
<td align="left"><code>True</code></td>
|
244 |
+
<td align="left">If False, component will be hidden.</td>
|
245 |
+
</tr>
|
246 |
+
|
247 |
+
<tr>
|
248 |
+
<td align="left"><code>elem_id</code></td>
|
249 |
+
<td align="left" style="width: 25%;">
|
250 |
+
|
251 |
+
```python
|
252 |
+
str | None
|
253 |
+
```
|
254 |
+
|
255 |
+
</td>
|
256 |
+
<td align="left"><code>None</code></td>
|
257 |
+
<td align="left">None</td>
|
258 |
+
</tr>
|
259 |
+
|
260 |
+
<tr>
|
261 |
+
<td align="left"><code>elem_classes</code></td>
|
262 |
+
<td align="left" style="width: 25%;">
|
263 |
+
|
264 |
+
```python
|
265 |
+
list[str] | str | None
|
266 |
+
```
|
267 |
+
|
268 |
+
</td>
|
269 |
+
<td align="left"><code>None</code></td>
|
270 |
+
<td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
|
271 |
+
</tr>
|
272 |
+
|
273 |
+
<tr>
|
274 |
+
<td align="left"><code>render</code></td>
|
275 |
+
<td align="left" style="width: 25%;">
|
276 |
+
|
277 |
+
```python
|
278 |
+
bool
|
279 |
+
```
|
280 |
+
|
281 |
+
</td>
|
282 |
+
<td align="left"><code>True</code></td>
|
283 |
+
<td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
|
284 |
+
</tr>
|
285 |
+
|
286 |
+
<tr>
|
287 |
+
<td align="left"><code>key</code></td>
|
288 |
+
<td align="left" style="width: 25%;">
|
289 |
+
|
290 |
+
```python
|
291 |
+
int | str | None
|
292 |
+
```
|
293 |
+
|
294 |
+
</td>
|
295 |
+
<td align="left"><code>None</code></td>
|
296 |
+
<td align="left">if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved.</td>
|
297 |
+
</tr>
|
298 |
+
</tbody></table>
|
299 |
+
|
300 |
+
|
301 |
+
### Events
|
302 |
+
|
303 |
+
| name | description |
|
304 |
+
|:-----|:------------|
|
305 |
+
| `change` | Triggered when the value of the DateTimeRange changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
|
306 |
+
|
307 |
+
|
308 |
+
|
309 |
+
### User function
|
310 |
+
|
311 |
+
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
|
312 |
+
|
313 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
314 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
315 |
+
|
316 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
317 |
+
|
318 |
+
- **As output:** Is passed, passes text value as a {str} into the function.
|
319 |
+
- **As input:** Should return, expects a tuple pair of datetimes.
|
320 |
+
|
321 |
+
```python
|
322 |
+
def predict(
|
323 |
+
value: tuple[str | float | datetime, str | float | datetime] | None
|
324 |
+
) -> tuple[float | datetime | str, float | datetime | str] | None:
|
325 |
+
return value
|
326 |
+
```
|
327 |
+
|
__init__.py
ADDED
File without changes
|
app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_datetimerange import DateTimeRange
|
4 |
+
import pandas as pd
|
5 |
+
from random import randint
|
6 |
+
|
7 |
+
temp_sensor_data = pd.DataFrame(
|
8 |
+
{
|
9 |
+
"time": pd.date_range("2021-01-01", end="2021-01-05", periods=200),
|
10 |
+
"temperature": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
11 |
+
"humidity": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
12 |
+
"location": ["indoor", "outdoor"] * 100,
|
13 |
+
}
|
14 |
+
)
|
15 |
+
|
16 |
+
with gr.Blocks() as demo:
|
17 |
+
date = DateTimeRange(["2021-01-01 00:00:00", "2021-01-07 00:00:00"])
|
18 |
+
merged_temp_plot = gr.LinePlot(
|
19 |
+
temp_sensor_data,
|
20 |
+
x="time",
|
21 |
+
y="temperature",
|
22 |
+
)
|
23 |
+
split_temp_plot = gr.LinePlot(
|
24 |
+
temp_sensor_data,
|
25 |
+
x="time",
|
26 |
+
y="temperature",
|
27 |
+
color="location",
|
28 |
+
)
|
29 |
+
with gr.Row():
|
30 |
+
humidity_bar_plot = gr.BarPlot(
|
31 |
+
temp_sensor_data,
|
32 |
+
x="time",
|
33 |
+
y="humidity",
|
34 |
+
color="location",
|
35 |
+
x_bin="1h",
|
36 |
+
)
|
37 |
+
humidity_scatter_plot = gr.ScatterPlot(
|
38 |
+
temp_sensor_data,
|
39 |
+
x="time",
|
40 |
+
y="humidity",
|
41 |
+
color="location",
|
42 |
+
)
|
43 |
+
|
44 |
+
date.bind([merged_temp_plot, split_temp_plot, humidity_bar_plot, humidity_scatter_plot])
|
45 |
+
|
46 |
+
|
47 |
+
if __name__ == "__main__":
|
48 |
+
demo.launch()
|
css.css
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
html {
|
2 |
+
font-family: Inter;
|
3 |
+
font-size: 16px;
|
4 |
+
font-weight: 400;
|
5 |
+
line-height: 1.5;
|
6 |
+
-webkit-text-size-adjust: 100%;
|
7 |
+
background: #fff;
|
8 |
+
color: #323232;
|
9 |
+
-webkit-font-smoothing: antialiased;
|
10 |
+
-moz-osx-font-smoothing: grayscale;
|
11 |
+
text-rendering: optimizeLegibility;
|
12 |
+
}
|
13 |
+
|
14 |
+
:root {
|
15 |
+
--space: 1;
|
16 |
+
--vspace: calc(var(--space) * 1rem);
|
17 |
+
--vspace-0: calc(3 * var(--space) * 1rem);
|
18 |
+
--vspace-1: calc(2 * var(--space) * 1rem);
|
19 |
+
--vspace-2: calc(1.5 * var(--space) * 1rem);
|
20 |
+
--vspace-3: calc(0.5 * var(--space) * 1rem);
|
21 |
+
}
|
22 |
+
|
23 |
+
.app {
|
24 |
+
max-width: 748px !important;
|
25 |
+
}
|
26 |
+
|
27 |
+
.prose p {
|
28 |
+
margin: var(--vspace) 0;
|
29 |
+
line-height: var(--vspace * 2);
|
30 |
+
font-size: 1rem;
|
31 |
+
}
|
32 |
+
|
33 |
+
code {
|
34 |
+
font-family: "Inconsolata", sans-serif;
|
35 |
+
font-size: 16px;
|
36 |
+
}
|
37 |
+
|
38 |
+
h1,
|
39 |
+
h1 code {
|
40 |
+
font-weight: 400;
|
41 |
+
line-height: calc(2.5 / var(--space) * var(--vspace));
|
42 |
+
}
|
43 |
+
|
44 |
+
h1 code {
|
45 |
+
background: none;
|
46 |
+
border: none;
|
47 |
+
letter-spacing: 0.05em;
|
48 |
+
padding-bottom: 5px;
|
49 |
+
position: relative;
|
50 |
+
padding: 0;
|
51 |
+
}
|
52 |
+
|
53 |
+
h2 {
|
54 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
55 |
+
line-height: 1em;
|
56 |
+
}
|
57 |
+
|
58 |
+
h3,
|
59 |
+
h3 code {
|
60 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
61 |
+
line-height: 1em;
|
62 |
+
}
|
63 |
+
|
64 |
+
h4,
|
65 |
+
h5,
|
66 |
+
h6 {
|
67 |
+
margin: var(--vspace-3) 0 var(--vspace-3) 0;
|
68 |
+
line-height: var(--vspace);
|
69 |
+
}
|
70 |
+
|
71 |
+
.bigtitle,
|
72 |
+
h1,
|
73 |
+
h1 code {
|
74 |
+
font-size: calc(8px * 4.5);
|
75 |
+
word-break: break-word;
|
76 |
+
}
|
77 |
+
|
78 |
+
.title,
|
79 |
+
h2,
|
80 |
+
h2 code {
|
81 |
+
font-size: calc(8px * 3.375);
|
82 |
+
font-weight: lighter;
|
83 |
+
word-break: break-word;
|
84 |
+
border: none;
|
85 |
+
background: none;
|
86 |
+
}
|
87 |
+
|
88 |
+
.subheading1,
|
89 |
+
h3,
|
90 |
+
h3 code {
|
91 |
+
font-size: calc(8px * 1.8);
|
92 |
+
font-weight: 600;
|
93 |
+
border: none;
|
94 |
+
background: none;
|
95 |
+
letter-spacing: 0.1em;
|
96 |
+
text-transform: uppercase;
|
97 |
+
}
|
98 |
+
|
99 |
+
h2 code {
|
100 |
+
padding: 0;
|
101 |
+
position: relative;
|
102 |
+
letter-spacing: 0.05em;
|
103 |
+
}
|
104 |
+
|
105 |
+
blockquote {
|
106 |
+
font-size: calc(8px * 1.1667);
|
107 |
+
font-style: italic;
|
108 |
+
line-height: calc(1.1667 * var(--vspace));
|
109 |
+
margin: var(--vspace-2) var(--vspace-2);
|
110 |
+
}
|
111 |
+
|
112 |
+
.subheading2,
|
113 |
+
h4 {
|
114 |
+
font-size: calc(8px * 1.4292);
|
115 |
+
text-transform: uppercase;
|
116 |
+
font-weight: 600;
|
117 |
+
}
|
118 |
+
|
119 |
+
.subheading3,
|
120 |
+
h5 {
|
121 |
+
font-size: calc(8px * 1.2917);
|
122 |
+
line-height: calc(1.2917 * var(--vspace));
|
123 |
+
|
124 |
+
font-weight: lighter;
|
125 |
+
text-transform: uppercase;
|
126 |
+
letter-spacing: 0.15em;
|
127 |
+
}
|
128 |
+
|
129 |
+
h6 {
|
130 |
+
font-size: calc(8px * 1.1667);
|
131 |
+
font-size: 1.1667em;
|
132 |
+
font-weight: normal;
|
133 |
+
font-style: italic;
|
134 |
+
font-family: "le-monde-livre-classic-byol", serif !important;
|
135 |
+
letter-spacing: 0px !important;
|
136 |
+
}
|
137 |
+
|
138 |
+
#start .md > *:first-child {
|
139 |
+
margin-top: 0;
|
140 |
+
}
|
141 |
+
|
142 |
+
h2 + h3 {
|
143 |
+
margin-top: 0;
|
144 |
+
}
|
145 |
+
|
146 |
+
.md hr {
|
147 |
+
border: none;
|
148 |
+
border-top: 1px solid var(--block-border-color);
|
149 |
+
margin: var(--vspace-2) 0 var(--vspace-2) 0;
|
150 |
+
}
|
151 |
+
.prose ul {
|
152 |
+
margin: var(--vspace-2) 0 var(--vspace-1) 0;
|
153 |
+
}
|
154 |
+
|
155 |
+
.gap {
|
156 |
+
gap: 0;
|
157 |
+
}
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradio_datetimerange
|
space.py
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from app import demo as app
|
4 |
+
import os
|
5 |
+
|
6 |
+
_docs = {'DateTimeRange': {'description': 'Component to select range of time.', 'members': {'__init__': {'value': {'type': 'tuple[float | str | datetime, float | str | datetime] | None', 'default': 'None', 'description': 'default value for datetime.'}, 'include_time': {'type': 'bool', 'default': 'True', 'description': 'If True, the component will include time selection. If False, only date selection will be available.'}, 'type': {'type': 'Literal["timestamp", "datetime", "string"]', 'default': '"timestamp"', 'description': 'The type of the value. Can be "timestamp", "datetime", or "string". If "timestamp", the value will be a number representing the start and end date in seconds since epoch. If "datetime", the value will be a datetime object. If "string", the value will be the date entered by the user.'}, 'timezone': {'type': 'str | None', 'default': 'None', 'description': 'The timezone to use for timestamps, such as "US/Pacific" or "Europe/Paris". If None, the timezone will be the local timezone.'}, 'quick_ranges': {'type': 'list[str] | None', 'default': 'None', 'description': 'List of strings representing quick ranges to display, such as ["30s", "1h", "24h", "7d"]. Set to [] to clear.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'info': {'type': 'str | None', 'default': 'None', 'description': 'additional component description.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': None}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'key': {'type': 'int | str | None', 'default': 'None', 'description': 'if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved.'}}, 'postprocess': {'value': {'type': 'tuple[float | datetime | str, float | datetime | str] | None', 'description': 'Expects a tuple pair of datetimes.'}}, 'preprocess': {'return': {'type': 'tuple[str | float | datetime, str | float | datetime] | None', 'description': 'Passes text value as a {str} into the function.'}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the DateTimeRange changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'DateTimeRange': []}}}
|
7 |
+
|
8 |
+
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
9 |
+
|
10 |
+
with gr.Blocks(
|
11 |
+
css=abs_path,
|
12 |
+
theme=gr.themes.Default(
|
13 |
+
font_mono=[
|
14 |
+
gr.themes.GoogleFont("Inconsolata"),
|
15 |
+
"monospace",
|
16 |
+
],
|
17 |
+
),
|
18 |
+
) as demo:
|
19 |
+
gr.Markdown(
|
20 |
+
"""
|
21 |
+
# `gradio_datetimerange`
|
22 |
+
|
23 |
+
<div style="display: flex; gap: 7px;">
|
24 |
+
<a href="https://pypi.org/project/gradio_datetimerange/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_datetimerange"></a>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
Component to create time ranges.
|
28 |
+
""", elem_classes=["md-custom"], header_links=True)
|
29 |
+
app.render()
|
30 |
+
gr.Markdown(
|
31 |
+
"""
|
32 |
+
## Installation
|
33 |
+
|
34 |
+
```bash
|
35 |
+
pip install gradio_datetimerange
|
36 |
+
```
|
37 |
+
|
38 |
+
## Usage
|
39 |
+
|
40 |
+
```python
|
41 |
+
|
42 |
+
import gradio as gr
|
43 |
+
from gradio_datetimerange import DateTimeRange
|
44 |
+
import pandas as pd
|
45 |
+
from random import randint
|
46 |
+
|
47 |
+
temp_sensor_data = pd.DataFrame(
|
48 |
+
{
|
49 |
+
"time": pd.date_range("2021-01-01", end="2021-01-05", periods=200),
|
50 |
+
"temperature": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
51 |
+
"humidity": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
52 |
+
"location": ["indoor", "outdoor"] * 100,
|
53 |
+
}
|
54 |
+
)
|
55 |
+
|
56 |
+
with gr.Blocks() as demo:
|
57 |
+
date = DateTimeRange(["2021-01-01 00:00:00", "2021-01-07 00:00:00"])
|
58 |
+
merged_temp_plot = gr.LinePlot(
|
59 |
+
temp_sensor_data,
|
60 |
+
x="time",
|
61 |
+
y="temperature",
|
62 |
+
)
|
63 |
+
split_temp_plot = gr.LinePlot(
|
64 |
+
temp_sensor_data,
|
65 |
+
x="time",
|
66 |
+
y="temperature",
|
67 |
+
color="location",
|
68 |
+
)
|
69 |
+
with gr.Row():
|
70 |
+
humidity_bar_plot = gr.BarPlot(
|
71 |
+
temp_sensor_data,
|
72 |
+
x="time",
|
73 |
+
y="humidity",
|
74 |
+
color="location",
|
75 |
+
x_bin="1h",
|
76 |
+
)
|
77 |
+
humidity_scatter_plot = gr.ScatterPlot(
|
78 |
+
temp_sensor_data,
|
79 |
+
x="time",
|
80 |
+
y="humidity",
|
81 |
+
color="location",
|
82 |
+
)
|
83 |
+
|
84 |
+
date.bind([merged_temp_plot, split_temp_plot, humidity_bar_plot, humidity_scatter_plot])
|
85 |
+
|
86 |
+
|
87 |
+
if __name__ == "__main__":
|
88 |
+
demo.launch()
|
89 |
+
|
90 |
+
```
|
91 |
+
""", elem_classes=["md-custom"], header_links=True)
|
92 |
+
|
93 |
+
|
94 |
+
gr.Markdown("""
|
95 |
+
## `DateTimeRange`
|
96 |
+
|
97 |
+
### Initialization
|
98 |
+
""", elem_classes=["md-custom"], header_links=True)
|
99 |
+
|
100 |
+
gr.ParamViewer(value=_docs["DateTimeRange"]["members"]["__init__"], linkify=[])
|
101 |
+
|
102 |
+
|
103 |
+
gr.Markdown("### Events")
|
104 |
+
gr.ParamViewer(value=_docs["DateTimeRange"]["events"], linkify=['Event'])
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
|
109 |
+
gr.Markdown("""
|
110 |
+
|
111 |
+
### User function
|
112 |
+
|
113 |
+
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
|
114 |
+
|
115 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
116 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
117 |
+
|
118 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
119 |
+
|
120 |
+
- **As input:** Is passed, passes text value as a {str} into the function.
|
121 |
+
- **As output:** Should return, expects a tuple pair of datetimes.
|
122 |
+
|
123 |
+
```python
|
124 |
+
def predict(
|
125 |
+
value: tuple[str | float | datetime, str | float | datetime] | None
|
126 |
+
) -> tuple[float | datetime | str, float | datetime | str] | None:
|
127 |
+
return value
|
128 |
+
```
|
129 |
+
""", elem_classes=["md-custom", "DateTimeRange-user-fn"], header_links=True)
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
|
134 |
+
demo.load(None, js=r"""function() {
|
135 |
+
const refs = {};
|
136 |
+
const user_fn_refs = {
|
137 |
+
DateTimeRange: [], };
|
138 |
+
requestAnimationFrame(() => {
|
139 |
+
|
140 |
+
Object.entries(user_fn_refs).forEach(([key, refs]) => {
|
141 |
+
if (refs.length > 0) {
|
142 |
+
const el = document.querySelector(`.${key}-user-fn`);
|
143 |
+
if (!el) return;
|
144 |
+
refs.forEach(ref => {
|
145 |
+
el.innerHTML = el.innerHTML.replace(
|
146 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
147 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
148 |
+
);
|
149 |
+
})
|
150 |
+
}
|
151 |
+
})
|
152 |
+
|
153 |
+
Object.entries(refs).forEach(([key, refs]) => {
|
154 |
+
if (refs.length > 0) {
|
155 |
+
const el = document.querySelector(`.${key}`);
|
156 |
+
if (!el) return;
|
157 |
+
refs.forEach(ref => {
|
158 |
+
el.innerHTML = el.innerHTML.replace(
|
159 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
160 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
161 |
+
);
|
162 |
+
})
|
163 |
+
}
|
164 |
+
})
|
165 |
+
})
|
166 |
+
}
|
167 |
+
|
168 |
+
""")
|
169 |
+
|
170 |
+
demo.launch()
|
src/.gitignore
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.eggs/
|
2 |
+
dist/
|
3 |
+
*.pyc
|
4 |
+
__pycache__/
|
5 |
+
*.py[cod]
|
6 |
+
*$py.class
|
7 |
+
__tmp/*
|
8 |
+
*.pyi
|
9 |
+
.mypycache
|
10 |
+
.ruff_cache
|
11 |
+
node_modules
|
12 |
+
backend/**/templates/
|
src/README.md
ADDED
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags: [gradio-custom-component, DateTime]
|
3 |
+
title: gradio_datetimerange
|
4 |
+
short_description: Component to create time ranges.
|
5 |
+
colorFrom: blue
|
6 |
+
colorTo: yellow
|
7 |
+
sdk: gradio
|
8 |
+
pinned: false
|
9 |
+
app_file: space.py
|
10 |
+
---
|
11 |
+
|
12 |
+
# `gradio_datetimerange`
|
13 |
+
<a href="https://pypi.org/project/gradio_datetimerange/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_datetimerange"></a>
|
14 |
+
|
15 |
+
Component to create time ranges.
|
16 |
+
|
17 |
+
## Installation
|
18 |
+
|
19 |
+
```bash
|
20 |
+
pip install gradio_datetimerange
|
21 |
+
```
|
22 |
+
|
23 |
+
## Usage
|
24 |
+
|
25 |
+
```python
|
26 |
+
|
27 |
+
import gradio as gr
|
28 |
+
from gradio_datetimerange import DateTimeRange
|
29 |
+
import pandas as pd
|
30 |
+
from random import randint
|
31 |
+
|
32 |
+
temp_sensor_data = pd.DataFrame(
|
33 |
+
{
|
34 |
+
"time": pd.date_range("2021-01-01", end="2021-01-05", periods=200),
|
35 |
+
"temperature": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
36 |
+
"humidity": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
37 |
+
"location": ["indoor", "outdoor"] * 100,
|
38 |
+
}
|
39 |
+
)
|
40 |
+
|
41 |
+
with gr.Blocks() as demo:
|
42 |
+
date = DateTimeRange(["2021-01-01 00:00:00", "2021-01-07 00:00:00"])
|
43 |
+
merged_temp_plot = gr.LinePlot(
|
44 |
+
temp_sensor_data,
|
45 |
+
x="time",
|
46 |
+
y="temperature",
|
47 |
+
)
|
48 |
+
split_temp_plot = gr.LinePlot(
|
49 |
+
temp_sensor_data,
|
50 |
+
x="time",
|
51 |
+
y="temperature",
|
52 |
+
color="location",
|
53 |
+
)
|
54 |
+
with gr.Row():
|
55 |
+
humidity_bar_plot = gr.BarPlot(
|
56 |
+
temp_sensor_data,
|
57 |
+
x="time",
|
58 |
+
y="humidity",
|
59 |
+
color="location",
|
60 |
+
x_bin="1h",
|
61 |
+
)
|
62 |
+
humidity_scatter_plot = gr.ScatterPlot(
|
63 |
+
temp_sensor_data,
|
64 |
+
x="time",
|
65 |
+
y="humidity",
|
66 |
+
color="location",
|
67 |
+
)
|
68 |
+
|
69 |
+
date.bind([merged_temp_plot, split_temp_plot, humidity_bar_plot, humidity_scatter_plot])
|
70 |
+
|
71 |
+
|
72 |
+
if __name__ == "__main__":
|
73 |
+
demo.launch()
|
74 |
+
|
75 |
+
```
|
76 |
+
|
77 |
+
## `DateTimeRange`
|
78 |
+
|
79 |
+
### Initialization
|
80 |
+
|
81 |
+
<table>
|
82 |
+
<thead>
|
83 |
+
<tr>
|
84 |
+
<th align="left">name</th>
|
85 |
+
<th align="left" style="width: 25%;">type</th>
|
86 |
+
<th align="left">default</th>
|
87 |
+
<th align="left">description</th>
|
88 |
+
</tr>
|
89 |
+
</thead>
|
90 |
+
<tbody>
|
91 |
+
<tr>
|
92 |
+
<td align="left"><code>value</code></td>
|
93 |
+
<td align="left" style="width: 25%;">
|
94 |
+
|
95 |
+
```python
|
96 |
+
tuple[float | str | datetime, float | str | datetime] | None
|
97 |
+
```
|
98 |
+
|
99 |
+
</td>
|
100 |
+
<td align="left"><code>None</code></td>
|
101 |
+
<td align="left">default value for datetime.</td>
|
102 |
+
</tr>
|
103 |
+
|
104 |
+
<tr>
|
105 |
+
<td align="left"><code>include_time</code></td>
|
106 |
+
<td align="left" style="width: 25%;">
|
107 |
+
|
108 |
+
```python
|
109 |
+
bool
|
110 |
+
```
|
111 |
+
|
112 |
+
</td>
|
113 |
+
<td align="left"><code>True</code></td>
|
114 |
+
<td align="left">If True, the component will include time selection. If False, only date selection will be available.</td>
|
115 |
+
</tr>
|
116 |
+
|
117 |
+
<tr>
|
118 |
+
<td align="left"><code>type</code></td>
|
119 |
+
<td align="left" style="width: 25%;">
|
120 |
+
|
121 |
+
```python
|
122 |
+
Literal["timestamp", "datetime", "string"]
|
123 |
+
```
|
124 |
+
|
125 |
+
</td>
|
126 |
+
<td align="left"><code>"timestamp"</code></td>
|
127 |
+
<td align="left">The type of the value. Can be "timestamp", "datetime", or "string". If "timestamp", the value will be a number representing the start and end date in seconds since epoch. If "datetime", the value will be a datetime object. If "string", the value will be the date entered by the user.</td>
|
128 |
+
</tr>
|
129 |
+
|
130 |
+
<tr>
|
131 |
+
<td align="left"><code>timezone</code></td>
|
132 |
+
<td align="left" style="width: 25%;">
|
133 |
+
|
134 |
+
```python
|
135 |
+
str | None
|
136 |
+
```
|
137 |
+
|
138 |
+
</td>
|
139 |
+
<td align="left"><code>None</code></td>
|
140 |
+
<td align="left">The timezone to use for timestamps, such as "US/Pacific" or "Europe/Paris". If None, the timezone will be the local timezone.</td>
|
141 |
+
</tr>
|
142 |
+
|
143 |
+
<tr>
|
144 |
+
<td align="left"><code>quick_ranges</code></td>
|
145 |
+
<td align="left" style="width: 25%;">
|
146 |
+
|
147 |
+
```python
|
148 |
+
list[str] | None
|
149 |
+
```
|
150 |
+
|
151 |
+
</td>
|
152 |
+
<td align="left"><code>None</code></td>
|
153 |
+
<td align="left">List of strings representing quick ranges to display, such as ["30s", "1h", "24h", "7d"]. Set to [] to clear.</td>
|
154 |
+
</tr>
|
155 |
+
|
156 |
+
<tr>
|
157 |
+
<td align="left"><code>label</code></td>
|
158 |
+
<td align="left" style="width: 25%;">
|
159 |
+
|
160 |
+
```python
|
161 |
+
str | None
|
162 |
+
```
|
163 |
+
|
164 |
+
</td>
|
165 |
+
<td align="left"><code>None</code></td>
|
166 |
+
<td align="left">The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.</td>
|
167 |
+
</tr>
|
168 |
+
|
169 |
+
<tr>
|
170 |
+
<td align="left"><code>show_label</code></td>
|
171 |
+
<td align="left" style="width: 25%;">
|
172 |
+
|
173 |
+
```python
|
174 |
+
bool | None
|
175 |
+
```
|
176 |
+
|
177 |
+
</td>
|
178 |
+
<td align="left"><code>None</code></td>
|
179 |
+
<td align="left">if True, will display label.</td>
|
180 |
+
</tr>
|
181 |
+
|
182 |
+
<tr>
|
183 |
+
<td align="left"><code>info</code></td>
|
184 |
+
<td align="left" style="width: 25%;">
|
185 |
+
|
186 |
+
```python
|
187 |
+
str | None
|
188 |
+
```
|
189 |
+
|
190 |
+
</td>
|
191 |
+
<td align="left"><code>None</code></td>
|
192 |
+
<td align="left">additional component description.</td>
|
193 |
+
</tr>
|
194 |
+
|
195 |
+
<tr>
|
196 |
+
<td align="left"><code>every</code></td>
|
197 |
+
<td align="left" style="width: 25%;">
|
198 |
+
|
199 |
+
```python
|
200 |
+
float | None
|
201 |
+
```
|
202 |
+
|
203 |
+
</td>
|
204 |
+
<td align="left"><code>None</code></td>
|
205 |
+
<td align="left">If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.</td>
|
206 |
+
</tr>
|
207 |
+
|
208 |
+
<tr>
|
209 |
+
<td align="left"><code>scale</code></td>
|
210 |
+
<td align="left" style="width: 25%;">
|
211 |
+
|
212 |
+
```python
|
213 |
+
int | None
|
214 |
+
```
|
215 |
+
|
216 |
+
</td>
|
217 |
+
<td align="left"><code>None</code></td>
|
218 |
+
<td align="left">relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.</td>
|
219 |
+
</tr>
|
220 |
+
|
221 |
+
<tr>
|
222 |
+
<td align="left"><code>min_width</code></td>
|
223 |
+
<td align="left" style="width: 25%;">
|
224 |
+
|
225 |
+
```python
|
226 |
+
int
|
227 |
+
```
|
228 |
+
|
229 |
+
</td>
|
230 |
+
<td align="left"><code>160</code></td>
|
231 |
+
<td align="left">minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.</td>
|
232 |
+
</tr>
|
233 |
+
|
234 |
+
<tr>
|
235 |
+
<td align="left"><code>visible</code></td>
|
236 |
+
<td align="left" style="width: 25%;">
|
237 |
+
|
238 |
+
```python
|
239 |
+
bool
|
240 |
+
```
|
241 |
+
|
242 |
+
</td>
|
243 |
+
<td align="left"><code>True</code></td>
|
244 |
+
<td align="left">If False, component will be hidden.</td>
|
245 |
+
</tr>
|
246 |
+
|
247 |
+
<tr>
|
248 |
+
<td align="left"><code>elem_id</code></td>
|
249 |
+
<td align="left" style="width: 25%;">
|
250 |
+
|
251 |
+
```python
|
252 |
+
str | None
|
253 |
+
```
|
254 |
+
|
255 |
+
</td>
|
256 |
+
<td align="left"><code>None</code></td>
|
257 |
+
<td align="left">None</td>
|
258 |
+
</tr>
|
259 |
+
|
260 |
+
<tr>
|
261 |
+
<td align="left"><code>elem_classes</code></td>
|
262 |
+
<td align="left" style="width: 25%;">
|
263 |
+
|
264 |
+
```python
|
265 |
+
list[str] | str | None
|
266 |
+
```
|
267 |
+
|
268 |
+
</td>
|
269 |
+
<td align="left"><code>None</code></td>
|
270 |
+
<td align="left">An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.</td>
|
271 |
+
</tr>
|
272 |
+
|
273 |
+
<tr>
|
274 |
+
<td align="left"><code>render</code></td>
|
275 |
+
<td align="left" style="width: 25%;">
|
276 |
+
|
277 |
+
```python
|
278 |
+
bool
|
279 |
+
```
|
280 |
+
|
281 |
+
</td>
|
282 |
+
<td align="left"><code>True</code></td>
|
283 |
+
<td align="left">If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.</td>
|
284 |
+
</tr>
|
285 |
+
|
286 |
+
<tr>
|
287 |
+
<td align="left"><code>key</code></td>
|
288 |
+
<td align="left" style="width: 25%;">
|
289 |
+
|
290 |
+
```python
|
291 |
+
int | str | None
|
292 |
+
```
|
293 |
+
|
294 |
+
</td>
|
295 |
+
<td align="left"><code>None</code></td>
|
296 |
+
<td align="left">if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved.</td>
|
297 |
+
</tr>
|
298 |
+
</tbody></table>
|
299 |
+
|
300 |
+
|
301 |
+
### Events
|
302 |
+
|
303 |
+
| name | description |
|
304 |
+
|:-----|:------------|
|
305 |
+
| `change` | Triggered when the value of the DateTimeRange changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input. |
|
306 |
+
|
307 |
+
|
308 |
+
|
309 |
+
### User function
|
310 |
+
|
311 |
+
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
|
312 |
+
|
313 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
314 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
315 |
+
|
316 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
317 |
+
|
318 |
+
- **As output:** Is passed, passes text value as a {str} into the function.
|
319 |
+
- **As input:** Should return, expects a tuple pair of datetimes.
|
320 |
+
|
321 |
+
```python
|
322 |
+
def predict(
|
323 |
+
value: tuple[str | float | datetime, str | float | datetime] | None
|
324 |
+
) -> tuple[float | datetime | str, float | datetime | str] | None:
|
325 |
+
return value
|
326 |
+
```
|
327 |
+
|
src/backend/gradio_datetimerange/__init__.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from .datetimerange import DateTimeRange
|
3 |
+
|
4 |
+
__all__ = ['DateTimeRange']
|
src/backend/gradio_datetimerange/datetimerange.py
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""gr.DateTime() component."""
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
from datetime import datetime
|
6 |
+
from typing import Any, Literal, TYPE_CHECKING, cast
|
7 |
+
|
8 |
+
from gradio.components import DateTime
|
9 |
+
from gradio.events import Events, SelectData, on
|
10 |
+
from gradio.helpers import skip
|
11 |
+
|
12 |
+
if TYPE_CHECKING:
|
13 |
+
from gradio.components.native_plot import NativePlot
|
14 |
+
|
15 |
+
|
16 |
+
class DateTimeRange(DateTime):
|
17 |
+
"""
|
18 |
+
Component to select range of time.
|
19 |
+
"""
|
20 |
+
|
21 |
+
EVENTS = [
|
22 |
+
Events.change,
|
23 |
+
]
|
24 |
+
|
25 |
+
def __init__(
|
26 |
+
self,
|
27 |
+
value: tuple[float | str | datetime, float | str | datetime] | None = None,
|
28 |
+
*,
|
29 |
+
include_time: bool = True,
|
30 |
+
type: Literal["timestamp", "datetime", "string"] = "timestamp",
|
31 |
+
timezone: str | None = None,
|
32 |
+
quick_ranges: list[str] | None = None,
|
33 |
+
label: str | None = None,
|
34 |
+
show_label: bool | None = None,
|
35 |
+
info: str | None = None,
|
36 |
+
every: float | None = None,
|
37 |
+
scale: int | None = None,
|
38 |
+
min_width: int = 160,
|
39 |
+
visible: bool = True,
|
40 |
+
elem_id: str | None = None,
|
41 |
+
elem_classes: list[str] | str | None = None,
|
42 |
+
render: bool = True,
|
43 |
+
key: int | str | None = None,
|
44 |
+
):
|
45 |
+
"""
|
46 |
+
Parameters:
|
47 |
+
value: default value for datetime.
|
48 |
+
label: The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.
|
49 |
+
show_label: if True, will display label.
|
50 |
+
include_time: If True, the component will include time selection. If False, only date selection will be available.
|
51 |
+
type: The type of the value. Can be "timestamp", "datetime", or "string". If "timestamp", the value will be a number representing the start and end date in seconds since epoch. If "datetime", the value will be a datetime object. If "string", the value will be the date entered by the user.
|
52 |
+
timezone: The timezone to use for timestamps, such as "US/Pacific" or "Europe/Paris". If None, the timezone will be the local timezone.
|
53 |
+
info: additional component description.
|
54 |
+
every: If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute.
|
55 |
+
scale: relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.
|
56 |
+
min_width: minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.
|
57 |
+
visible: If False, component will be hidden.
|
58 |
+
elem_classes: An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.
|
59 |
+
render: If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
|
60 |
+
key: if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved.
|
61 |
+
quick_ranges: List of strings representing quick ranges to display, such as ["30s", "1h", "24h", "7d"]. Set to [] to clear.
|
62 |
+
"""
|
63 |
+
super().__init__(
|
64 |
+
every=every,
|
65 |
+
scale=scale,
|
66 |
+
min_width=min_width,
|
67 |
+
visible=visible,
|
68 |
+
label=label,
|
69 |
+
show_label=show_label,
|
70 |
+
info=info,
|
71 |
+
elem_id=elem_id,
|
72 |
+
elem_classes=elem_classes,
|
73 |
+
render=render,
|
74 |
+
key=key,
|
75 |
+
value=value,
|
76 |
+
type=type,
|
77 |
+
include_time=include_time,
|
78 |
+
timezone=timezone,
|
79 |
+
)
|
80 |
+
|
81 |
+
self.quick_ranges = (
|
82 |
+
["15m", "1h", "24h"] if quick_ranges is None else quick_ranges
|
83 |
+
)
|
84 |
+
self._init_value = None
|
85 |
+
if value:
|
86 |
+
init_range = self.postprocess(value)
|
87 |
+
self._init_value = (self.get_datetime_from_str(init_range[0]).timestamp(), self.get_datetime_from_str(init_range[1]).timestamp()) if value else None
|
88 |
+
|
89 |
+
def preprocess(self, payload: tuple[str, str] | None) -> tuple[str | float | datetime, str | float | datetime] | None:
|
90 |
+
"""
|
91 |
+
Parameters:
|
92 |
+
payload: the text entered in the textarea.
|
93 |
+
Returns:
|
94 |
+
Passes text value as a {str} into the function.
|
95 |
+
"""
|
96 |
+
if payload is None:
|
97 |
+
return None
|
98 |
+
start, end = super().preprocess(payload[0]), super().preprocess(payload[1])
|
99 |
+
if start is None or end is None:
|
100 |
+
return None
|
101 |
+
return start, end
|
102 |
+
|
103 |
+
def postprocess(self, value: tuple[float | datetime | str, float | datetime | str] | None) -> tuple[str, str] | None:
|
104 |
+
"""
|
105 |
+
Parameters:
|
106 |
+
value: Expects a tuple pair of datetimes.
|
107 |
+
Returns:
|
108 |
+
A tuple pair of timestamps.
|
109 |
+
"""
|
110 |
+
if value is None:
|
111 |
+
return None
|
112 |
+
|
113 |
+
start, end = super().postprocess(value[0]), super().postprocess(value[1])
|
114 |
+
if start is None or end is None:
|
115 |
+
return None
|
116 |
+
return start, end
|
117 |
+
|
118 |
+
|
119 |
+
def api_info(self) -> dict[str, Any]:
|
120 |
+
return {
|
121 |
+
"type": {},
|
122 |
+
"description": f"Two strings formatted as YYYY-MM-DD{' HH:MM:SS' if self.include_time else ''}",
|
123 |
+
}
|
124 |
+
|
125 |
+
def example_payload(self) -> list[str]:
|
126 |
+
return ["2020-10-01 05:20:15", "2020-10-01 06:20:15"]
|
127 |
+
|
128 |
+
def example_value(self) -> list[str]:
|
129 |
+
return ["2020-10-01 05:20:15", "2020-10-01 06:20:15"]
|
130 |
+
|
131 |
+
def bind(self, plots: NativePlot | list[NativePlot]) -> None:
|
132 |
+
from gradio.components.native_plot import NativePlot
|
133 |
+
|
134 |
+
if not isinstance(plots, list):
|
135 |
+
plots = [plots]
|
136 |
+
plot_count = len(plots)
|
137 |
+
|
138 |
+
def reset_range(select: SelectData):
|
139 |
+
if select.selected:
|
140 |
+
a, b = cast("tuple[float, float]", select.index)
|
141 |
+
dt_a, dt_b = datetime.fromtimestamp(a), datetime.fromtimestamp(b)
|
142 |
+
return dt_a, dt_b
|
143 |
+
else:
|
144 |
+
return skip()
|
145 |
+
|
146 |
+
for plot in plots:
|
147 |
+
if self._init_value is not None:
|
148 |
+
plot.x_lim = self._init_value
|
149 |
+
plot.select(reset_range, None, self, show_api=False)
|
150 |
+
|
151 |
+
def update_plots(domain: tuple[int, int]):
|
152 |
+
changes = [
|
153 |
+
NativePlot(x_lim=domain)
|
154 |
+
for _ in range(plot_count)
|
155 |
+
]
|
156 |
+
return changes if len(changes) > 1 else changes[0]
|
157 |
+
|
158 |
+
self.change(update_plots, self, plots, show_api=False) # type: ignore
|
src/backend/gradio_datetimerange/templates/component/index.js
ADDED
@@ -0,0 +1,2250 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const {
|
2 |
+
SvelteComponent: it,
|
3 |
+
assign: ft,
|
4 |
+
create_slot: st,
|
5 |
+
detach: at,
|
6 |
+
element: ot,
|
7 |
+
get_all_dirty_from_scope: _t,
|
8 |
+
get_slot_changes: ut,
|
9 |
+
get_spread_update: rt,
|
10 |
+
init: dt,
|
11 |
+
insert: ct,
|
12 |
+
safe_not_equal: mt,
|
13 |
+
set_dynamic_element_data: ve,
|
14 |
+
set_style: B,
|
15 |
+
toggle_class: T,
|
16 |
+
transition_in: Pe,
|
17 |
+
transition_out: Ye,
|
18 |
+
update_slot_base: bt
|
19 |
+
} = window.__gradio__svelte__internal;
|
20 |
+
function ht(n) {
|
21 |
+
let e, t, l;
|
22 |
+
const i = (
|
23 |
+
/*#slots*/
|
24 |
+
n[18].default
|
25 |
+
), s = st(
|
26 |
+
i,
|
27 |
+
n,
|
28 |
+
/*$$scope*/
|
29 |
+
n[17],
|
30 |
+
null
|
31 |
+
);
|
32 |
+
let _ = [
|
33 |
+
{ "data-testid": (
|
34 |
+
/*test_id*/
|
35 |
+
n[7]
|
36 |
+
) },
|
37 |
+
{ id: (
|
38 |
+
/*elem_id*/
|
39 |
+
n[2]
|
40 |
+
) },
|
41 |
+
{
|
42 |
+
class: t = "block " + /*elem_classes*/
|
43 |
+
n[3].join(" ") + " svelte-nl1om8"
|
44 |
+
}
|
45 |
+
], a = {};
|
46 |
+
for (let f = 0; f < _.length; f += 1)
|
47 |
+
a = ft(a, _[f]);
|
48 |
+
return {
|
49 |
+
c() {
|
50 |
+
e = ot(
|
51 |
+
/*tag*/
|
52 |
+
n[14]
|
53 |
+
), s && s.c(), ve(
|
54 |
+
/*tag*/
|
55 |
+
n[14]
|
56 |
+
)(e, a), T(
|
57 |
+
e,
|
58 |
+
"hidden",
|
59 |
+
/*visible*/
|
60 |
+
n[10] === !1
|
61 |
+
), T(
|
62 |
+
e,
|
63 |
+
"padded",
|
64 |
+
/*padding*/
|
65 |
+
n[6]
|
66 |
+
), T(
|
67 |
+
e,
|
68 |
+
"border_focus",
|
69 |
+
/*border_mode*/
|
70 |
+
n[5] === "focus"
|
71 |
+
), T(
|
72 |
+
e,
|
73 |
+
"border_contrast",
|
74 |
+
/*border_mode*/
|
75 |
+
n[5] === "contrast"
|
76 |
+
), T(e, "hide-container", !/*explicit_call*/
|
77 |
+
n[8] && !/*container*/
|
78 |
+
n[9]), B(
|
79 |
+
e,
|
80 |
+
"height",
|
81 |
+
/*get_dimension*/
|
82 |
+
n[15](
|
83 |
+
/*height*/
|
84 |
+
n[0]
|
85 |
+
)
|
86 |
+
), B(e, "width", typeof /*width*/
|
87 |
+
n[1] == "number" ? `calc(min(${/*width*/
|
88 |
+
n[1]}px, 100%))` : (
|
89 |
+
/*get_dimension*/
|
90 |
+
n[15](
|
91 |
+
/*width*/
|
92 |
+
n[1]
|
93 |
+
)
|
94 |
+
)), B(
|
95 |
+
e,
|
96 |
+
"border-style",
|
97 |
+
/*variant*/
|
98 |
+
n[4]
|
99 |
+
), B(
|
100 |
+
e,
|
101 |
+
"overflow",
|
102 |
+
/*allow_overflow*/
|
103 |
+
n[11] ? "visible" : "hidden"
|
104 |
+
), B(
|
105 |
+
e,
|
106 |
+
"flex-grow",
|
107 |
+
/*scale*/
|
108 |
+
n[12]
|
109 |
+
), B(e, "min-width", `calc(min(${/*min_width*/
|
110 |
+
n[13]}px, 100%))`), B(e, "border-width", "var(--block-border-width)");
|
111 |
+
},
|
112 |
+
m(f, o) {
|
113 |
+
ct(f, e, o), s && s.m(e, null), l = !0;
|
114 |
+
},
|
115 |
+
p(f, o) {
|
116 |
+
s && s.p && (!l || o & /*$$scope*/
|
117 |
+
131072) && bt(
|
118 |
+
s,
|
119 |
+
i,
|
120 |
+
f,
|
121 |
+
/*$$scope*/
|
122 |
+
f[17],
|
123 |
+
l ? ut(
|
124 |
+
i,
|
125 |
+
/*$$scope*/
|
126 |
+
f[17],
|
127 |
+
o,
|
128 |
+
null
|
129 |
+
) : _t(
|
130 |
+
/*$$scope*/
|
131 |
+
f[17]
|
132 |
+
),
|
133 |
+
null
|
134 |
+
), ve(
|
135 |
+
/*tag*/
|
136 |
+
f[14]
|
137 |
+
)(e, a = rt(_, [
|
138 |
+
(!l || o & /*test_id*/
|
139 |
+
128) && { "data-testid": (
|
140 |
+
/*test_id*/
|
141 |
+
f[7]
|
142 |
+
) },
|
143 |
+
(!l || o & /*elem_id*/
|
144 |
+
4) && { id: (
|
145 |
+
/*elem_id*/
|
146 |
+
f[2]
|
147 |
+
) },
|
148 |
+
(!l || o & /*elem_classes*/
|
149 |
+
8 && t !== (t = "block " + /*elem_classes*/
|
150 |
+
f[3].join(" ") + " svelte-nl1om8")) && { class: t }
|
151 |
+
])), T(
|
152 |
+
e,
|
153 |
+
"hidden",
|
154 |
+
/*visible*/
|
155 |
+
f[10] === !1
|
156 |
+
), T(
|
157 |
+
e,
|
158 |
+
"padded",
|
159 |
+
/*padding*/
|
160 |
+
f[6]
|
161 |
+
), T(
|
162 |
+
e,
|
163 |
+
"border_focus",
|
164 |
+
/*border_mode*/
|
165 |
+
f[5] === "focus"
|
166 |
+
), T(
|
167 |
+
e,
|
168 |
+
"border_contrast",
|
169 |
+
/*border_mode*/
|
170 |
+
f[5] === "contrast"
|
171 |
+
), T(e, "hide-container", !/*explicit_call*/
|
172 |
+
f[8] && !/*container*/
|
173 |
+
f[9]), o & /*height*/
|
174 |
+
1 && B(
|
175 |
+
e,
|
176 |
+
"height",
|
177 |
+
/*get_dimension*/
|
178 |
+
f[15](
|
179 |
+
/*height*/
|
180 |
+
f[0]
|
181 |
+
)
|
182 |
+
), o & /*width*/
|
183 |
+
2 && B(e, "width", typeof /*width*/
|
184 |
+
f[1] == "number" ? `calc(min(${/*width*/
|
185 |
+
f[1]}px, 100%))` : (
|
186 |
+
/*get_dimension*/
|
187 |
+
f[15](
|
188 |
+
/*width*/
|
189 |
+
f[1]
|
190 |
+
)
|
191 |
+
)), o & /*variant*/
|
192 |
+
16 && B(
|
193 |
+
e,
|
194 |
+
"border-style",
|
195 |
+
/*variant*/
|
196 |
+
f[4]
|
197 |
+
), o & /*allow_overflow*/
|
198 |
+
2048 && B(
|
199 |
+
e,
|
200 |
+
"overflow",
|
201 |
+
/*allow_overflow*/
|
202 |
+
f[11] ? "visible" : "hidden"
|
203 |
+
), o & /*scale*/
|
204 |
+
4096 && B(
|
205 |
+
e,
|
206 |
+
"flex-grow",
|
207 |
+
/*scale*/
|
208 |
+
f[12]
|
209 |
+
), o & /*min_width*/
|
210 |
+
8192 && B(e, "min-width", `calc(min(${/*min_width*/
|
211 |
+
f[13]}px, 100%))`);
|
212 |
+
},
|
213 |
+
i(f) {
|
214 |
+
l || (Pe(s, f), l = !0);
|
215 |
+
},
|
216 |
+
o(f) {
|
217 |
+
Ye(s, f), l = !1;
|
218 |
+
},
|
219 |
+
d(f) {
|
220 |
+
f && at(e), s && s.d(f);
|
221 |
+
}
|
222 |
+
};
|
223 |
+
}
|
224 |
+
function gt(n) {
|
225 |
+
let e, t = (
|
226 |
+
/*tag*/
|
227 |
+
n[14] && ht(n)
|
228 |
+
);
|
229 |
+
return {
|
230 |
+
c() {
|
231 |
+
t && t.c();
|
232 |
+
},
|
233 |
+
m(l, i) {
|
234 |
+
t && t.m(l, i), e = !0;
|
235 |
+
},
|
236 |
+
p(l, [i]) {
|
237 |
+
/*tag*/
|
238 |
+
l[14] && t.p(l, i);
|
239 |
+
},
|
240 |
+
i(l) {
|
241 |
+
e || (Pe(t, l), e = !0);
|
242 |
+
},
|
243 |
+
o(l) {
|
244 |
+
Ye(t, l), e = !1;
|
245 |
+
},
|
246 |
+
d(l) {
|
247 |
+
t && t.d(l);
|
248 |
+
}
|
249 |
+
};
|
250 |
+
}
|
251 |
+
function wt(n, e, t) {
|
252 |
+
let { $$slots: l = {}, $$scope: i } = e, { height: s = void 0 } = e, { width: _ = void 0 } = e, { elem_id: a = "" } = e, { elem_classes: f = [] } = e, { variant: o = "solid" } = e, { border_mode: d = "base" } = e, { padding: g = !0 } = e, { type: w = "normal" } = e, { test_id: C = void 0 } = e, { explicit_call: q = !1 } = e, { container: k = !0 } = e, { visible: m = !0 } = e, { allow_overflow: r = !0 } = e, { scale: v = null } = e, { min_width: y = 0 } = e, j = w === "fieldset" ? "fieldset" : "div";
|
253 |
+
const S = (u) => {
|
254 |
+
if (u !== void 0) {
|
255 |
+
if (typeof u == "number")
|
256 |
+
return u + "px";
|
257 |
+
if (typeof u == "string")
|
258 |
+
return u;
|
259 |
+
}
|
260 |
+
};
|
261 |
+
return n.$$set = (u) => {
|
262 |
+
"height" in u && t(0, s = u.height), "width" in u && t(1, _ = u.width), "elem_id" in u && t(2, a = u.elem_id), "elem_classes" in u && t(3, f = u.elem_classes), "variant" in u && t(4, o = u.variant), "border_mode" in u && t(5, d = u.border_mode), "padding" in u && t(6, g = u.padding), "type" in u && t(16, w = u.type), "test_id" in u && t(7, C = u.test_id), "explicit_call" in u && t(8, q = u.explicit_call), "container" in u && t(9, k = u.container), "visible" in u && t(10, m = u.visible), "allow_overflow" in u && t(11, r = u.allow_overflow), "scale" in u && t(12, v = u.scale), "min_width" in u && t(13, y = u.min_width), "$$scope" in u && t(17, i = u.$$scope);
|
263 |
+
}, [
|
264 |
+
s,
|
265 |
+
_,
|
266 |
+
a,
|
267 |
+
f,
|
268 |
+
o,
|
269 |
+
d,
|
270 |
+
g,
|
271 |
+
C,
|
272 |
+
q,
|
273 |
+
k,
|
274 |
+
m,
|
275 |
+
r,
|
276 |
+
v,
|
277 |
+
y,
|
278 |
+
j,
|
279 |
+
S,
|
280 |
+
w,
|
281 |
+
i,
|
282 |
+
l
|
283 |
+
];
|
284 |
+
}
|
285 |
+
let vt = class extends it {
|
286 |
+
constructor(e) {
|
287 |
+
super(), dt(this, e, wt, gt, mt, {
|
288 |
+
height: 0,
|
289 |
+
width: 1,
|
290 |
+
elem_id: 2,
|
291 |
+
elem_classes: 3,
|
292 |
+
variant: 4,
|
293 |
+
border_mode: 5,
|
294 |
+
padding: 6,
|
295 |
+
type: 16,
|
296 |
+
test_id: 7,
|
297 |
+
explicit_call: 8,
|
298 |
+
container: 9,
|
299 |
+
visible: 10,
|
300 |
+
allow_overflow: 11,
|
301 |
+
scale: 12,
|
302 |
+
min_width: 13
|
303 |
+
});
|
304 |
+
}
|
305 |
+
};
|
306 |
+
const {
|
307 |
+
SvelteComponent: kt,
|
308 |
+
attr: yt,
|
309 |
+
create_slot: qt,
|
310 |
+
detach: Ct,
|
311 |
+
element: St,
|
312 |
+
get_all_dirty_from_scope: jt,
|
313 |
+
get_slot_changes: Bt,
|
314 |
+
init: It,
|
315 |
+
insert: Tt,
|
316 |
+
safe_not_equal: Dt,
|
317 |
+
transition_in: Et,
|
318 |
+
transition_out: Nt,
|
319 |
+
update_slot_base: Mt
|
320 |
+
} = window.__gradio__svelte__internal;
|
321 |
+
function zt(n) {
|
322 |
+
let e, t;
|
323 |
+
const l = (
|
324 |
+
/*#slots*/
|
325 |
+
n[1].default
|
326 |
+
), i = qt(
|
327 |
+
l,
|
328 |
+
n,
|
329 |
+
/*$$scope*/
|
330 |
+
n[0],
|
331 |
+
null
|
332 |
+
);
|
333 |
+
return {
|
334 |
+
c() {
|
335 |
+
e = St("div"), i && i.c(), yt(e, "class", "svelte-1hnfib2");
|
336 |
+
},
|
337 |
+
m(s, _) {
|
338 |
+
Tt(s, e, _), i && i.m(e, null), t = !0;
|
339 |
+
},
|
340 |
+
p(s, [_]) {
|
341 |
+
i && i.p && (!t || _ & /*$$scope*/
|
342 |
+
1) && Mt(
|
343 |
+
i,
|
344 |
+
l,
|
345 |
+
s,
|
346 |
+
/*$$scope*/
|
347 |
+
s[0],
|
348 |
+
t ? Bt(
|
349 |
+
l,
|
350 |
+
/*$$scope*/
|
351 |
+
s[0],
|
352 |
+
_,
|
353 |
+
null
|
354 |
+
) : jt(
|
355 |
+
/*$$scope*/
|
356 |
+
s[0]
|
357 |
+
),
|
358 |
+
null
|
359 |
+
);
|
360 |
+
},
|
361 |
+
i(s) {
|
362 |
+
t || (Et(i, s), t = !0);
|
363 |
+
},
|
364 |
+
o(s) {
|
365 |
+
Nt(i, s), t = !1;
|
366 |
+
},
|
367 |
+
d(s) {
|
368 |
+
s && Ct(e), i && i.d(s);
|
369 |
+
}
|
370 |
+
};
|
371 |
+
}
|
372 |
+
function Ft(n, e, t) {
|
373 |
+
let { $$slots: l = {}, $$scope: i } = e;
|
374 |
+
return n.$$set = (s) => {
|
375 |
+
"$$scope" in s && t(0, i = s.$$scope);
|
376 |
+
}, [i, l];
|
377 |
+
}
|
378 |
+
let Ht = class extends kt {
|
379 |
+
constructor(e) {
|
380 |
+
super(), It(this, e, Ft, zt, Dt, {});
|
381 |
+
}
|
382 |
+
};
|
383 |
+
const {
|
384 |
+
SvelteComponent: Jt,
|
385 |
+
attr: ke,
|
386 |
+
check_outros: Lt,
|
387 |
+
create_component: Ot,
|
388 |
+
create_slot: Pt,
|
389 |
+
destroy_component: Yt,
|
390 |
+
detach: X,
|
391 |
+
element: At,
|
392 |
+
empty: Gt,
|
393 |
+
get_all_dirty_from_scope: Kt,
|
394 |
+
get_slot_changes: Qt,
|
395 |
+
group_outros: Rt,
|
396 |
+
init: Ut,
|
397 |
+
insert: Z,
|
398 |
+
mount_component: Vt,
|
399 |
+
safe_not_equal: Wt,
|
400 |
+
set_data: Xt,
|
401 |
+
space: Zt,
|
402 |
+
text: pt,
|
403 |
+
toggle_class: z,
|
404 |
+
transition_in: K,
|
405 |
+
transition_out: p,
|
406 |
+
update_slot_base: xt
|
407 |
+
} = window.__gradio__svelte__internal;
|
408 |
+
function ye(n) {
|
409 |
+
let e, t;
|
410 |
+
return e = new Ht({
|
411 |
+
props: {
|
412 |
+
$$slots: { default: [$t] },
|
413 |
+
$$scope: { ctx: n }
|
414 |
+
}
|
415 |
+
}), {
|
416 |
+
c() {
|
417 |
+
Ot(e.$$.fragment);
|
418 |
+
},
|
419 |
+
m(l, i) {
|
420 |
+
Vt(e, l, i), t = !0;
|
421 |
+
},
|
422 |
+
p(l, i) {
|
423 |
+
const s = {};
|
424 |
+
i & /*$$scope, info*/
|
425 |
+
10 && (s.$$scope = { dirty: i, ctx: l }), e.$set(s);
|
426 |
+
},
|
427 |
+
i(l) {
|
428 |
+
t || (K(e.$$.fragment, l), t = !0);
|
429 |
+
},
|
430 |
+
o(l) {
|
431 |
+
p(e.$$.fragment, l), t = !1;
|
432 |
+
},
|
433 |
+
d(l) {
|
434 |
+
Yt(e, l);
|
435 |
+
}
|
436 |
+
};
|
437 |
+
}
|
438 |
+
function $t(n) {
|
439 |
+
let e;
|
440 |
+
return {
|
441 |
+
c() {
|
442 |
+
e = pt(
|
443 |
+
/*info*/
|
444 |
+
n[1]
|
445 |
+
);
|
446 |
+
},
|
447 |
+
m(t, l) {
|
448 |
+
Z(t, e, l);
|
449 |
+
},
|
450 |
+
p(t, l) {
|
451 |
+
l & /*info*/
|
452 |
+
2 && Xt(
|
453 |
+
e,
|
454 |
+
/*info*/
|
455 |
+
t[1]
|
456 |
+
);
|
457 |
+
},
|
458 |
+
d(t) {
|
459 |
+
t && X(e);
|
460 |
+
}
|
461 |
+
};
|
462 |
+
}
|
463 |
+
function en(n) {
|
464 |
+
let e, t, l, i;
|
465 |
+
const s = (
|
466 |
+
/*#slots*/
|
467 |
+
n[2].default
|
468 |
+
), _ = Pt(
|
469 |
+
s,
|
470 |
+
n,
|
471 |
+
/*$$scope*/
|
472 |
+
n[3],
|
473 |
+
null
|
474 |
+
);
|
475 |
+
let a = (
|
476 |
+
/*info*/
|
477 |
+
n[1] && ye(n)
|
478 |
+
);
|
479 |
+
return {
|
480 |
+
c() {
|
481 |
+
e = At("span"), _ && _.c(), t = Zt(), a && a.c(), l = Gt(), ke(e, "data-testid", "block-info"), ke(e, "class", "svelte-22c38v"), z(e, "sr-only", !/*show_label*/
|
482 |
+
n[0]), z(e, "hide", !/*show_label*/
|
483 |
+
n[0]), z(
|
484 |
+
e,
|
485 |
+
"has-info",
|
486 |
+
/*info*/
|
487 |
+
n[1] != null
|
488 |
+
);
|
489 |
+
},
|
490 |
+
m(f, o) {
|
491 |
+
Z(f, e, o), _ && _.m(e, null), Z(f, t, o), a && a.m(f, o), Z(f, l, o), i = !0;
|
492 |
+
},
|
493 |
+
p(f, [o]) {
|
494 |
+
_ && _.p && (!i || o & /*$$scope*/
|
495 |
+
8) && xt(
|
496 |
+
_,
|
497 |
+
s,
|
498 |
+
f,
|
499 |
+
/*$$scope*/
|
500 |
+
f[3],
|
501 |
+
i ? Qt(
|
502 |
+
s,
|
503 |
+
/*$$scope*/
|
504 |
+
f[3],
|
505 |
+
o,
|
506 |
+
null
|
507 |
+
) : Kt(
|
508 |
+
/*$$scope*/
|
509 |
+
f[3]
|
510 |
+
),
|
511 |
+
null
|
512 |
+
), (!i || o & /*show_label*/
|
513 |
+
1) && z(e, "sr-only", !/*show_label*/
|
514 |
+
f[0]), (!i || o & /*show_label*/
|
515 |
+
1) && z(e, "hide", !/*show_label*/
|
516 |
+
f[0]), (!i || o & /*info*/
|
517 |
+
2) && z(
|
518 |
+
e,
|
519 |
+
"has-info",
|
520 |
+
/*info*/
|
521 |
+
f[1] != null
|
522 |
+
), /*info*/
|
523 |
+
f[1] ? a ? (a.p(f, o), o & /*info*/
|
524 |
+
2 && K(a, 1)) : (a = ye(f), a.c(), K(a, 1), a.m(l.parentNode, l)) : a && (Rt(), p(a, 1, 1, () => {
|
525 |
+
a = null;
|
526 |
+
}), Lt());
|
527 |
+
},
|
528 |
+
i(f) {
|
529 |
+
i || (K(_, f), K(a), i = !0);
|
530 |
+
},
|
531 |
+
o(f) {
|
532 |
+
p(_, f), p(a), i = !1;
|
533 |
+
},
|
534 |
+
d(f) {
|
535 |
+
f && (X(e), X(t), X(l)), _ && _.d(f), a && a.d(f);
|
536 |
+
}
|
537 |
+
};
|
538 |
+
}
|
539 |
+
function tn(n, e, t) {
|
540 |
+
let { $$slots: l = {}, $$scope: i } = e, { show_label: s = !0 } = e, { info: _ = void 0 } = e;
|
541 |
+
return n.$$set = (a) => {
|
542 |
+
"show_label" in a && t(0, s = a.show_label), "info" in a && t(1, _ = a.info), "$$scope" in a && t(3, i = a.$$scope);
|
543 |
+
}, [s, _, l, i];
|
544 |
+
}
|
545 |
+
let nn = class extends Jt {
|
546 |
+
constructor(e) {
|
547 |
+
super(), Ut(this, e, tn, en, Wt, { show_label: 0, info: 1 });
|
548 |
+
}
|
549 |
+
};
|
550 |
+
const {
|
551 |
+
SvelteComponent: ln,
|
552 |
+
append: V,
|
553 |
+
attr: h,
|
554 |
+
detach: fn,
|
555 |
+
init: sn,
|
556 |
+
insert: an,
|
557 |
+
noop: _e,
|
558 |
+
safe_not_equal: on,
|
559 |
+
svg_element: G
|
560 |
+
} = window.__gradio__svelte__internal;
|
561 |
+
function _n(n) {
|
562 |
+
let e, t, l, i, s;
|
563 |
+
return {
|
564 |
+
c() {
|
565 |
+
e = G("svg"), t = G("rect"), l = G("line"), i = G("line"), s = G("line"), h(t, "x", "2"), h(t, "y", "4"), h(t, "width", "20"), h(t, "height", "18"), h(t, "stroke", "currentColor"), h(t, "stroke-width", "2"), h(t, "stroke-linecap", "round"), h(t, "stroke-linejoin", "round"), h(t, "fill", "none"), h(l, "x1", "2"), h(l, "y1", "9"), h(l, "x2", "22"), h(l, "y2", "9"), h(l, "stroke", "currentColor"), h(l, "stroke-width", "2"), h(l, "stroke-linecap", "round"), h(l, "stroke-linejoin", "round"), h(l, "fill", "none"), h(i, "x1", "7"), h(i, "y1", "2"), h(i, "x2", "7"), h(i, "y2", "6"), h(i, "stroke", "currentColor"), h(i, "stroke-width", "2"), h(i, "stroke-linecap", "round"), h(i, "stroke-linejoin", "round"), h(i, "fill", "none"), h(s, "x1", "17"), h(s, "y1", "2"), h(s, "x2", "17"), h(s, "y2", "6"), h(s, "stroke", "currentColor"), h(s, "stroke-width", "2"), h(s, "stroke-linecap", "round"), h(s, "stroke-linejoin", "round"), h(s, "fill", "none"), h(e, "xmlns", "http://www.w3.org/2000/svg"), h(e, "width", "24px"), h(e, "height", "24px"), h(e, "viewBox", "0 0 24 24");
|
566 |
+
},
|
567 |
+
m(_, a) {
|
568 |
+
an(_, e, a), V(e, t), V(e, l), V(e, i), V(e, s);
|
569 |
+
},
|
570 |
+
p: _e,
|
571 |
+
i: _e,
|
572 |
+
o: _e,
|
573 |
+
d(_) {
|
574 |
+
_ && fn(e);
|
575 |
+
}
|
576 |
+
};
|
577 |
+
}
|
578 |
+
class un extends ln {
|
579 |
+
constructor(e) {
|
580 |
+
super(), sn(this, e, null, _n, on, {});
|
581 |
+
}
|
582 |
+
}
|
583 |
+
const rn = [
|
584 |
+
{ color: "red", primary: 600, secondary: 100 },
|
585 |
+
{ color: "green", primary: 600, secondary: 100 },
|
586 |
+
{ color: "blue", primary: 600, secondary: 100 },
|
587 |
+
{ color: "yellow", primary: 500, secondary: 100 },
|
588 |
+
{ color: "purple", primary: 600, secondary: 100 },
|
589 |
+
{ color: "teal", primary: 600, secondary: 100 },
|
590 |
+
{ color: "orange", primary: 600, secondary: 100 },
|
591 |
+
{ color: "cyan", primary: 600, secondary: 100 },
|
592 |
+
{ color: "lime", primary: 500, secondary: 100 },
|
593 |
+
{ color: "pink", primary: 600, secondary: 100 }
|
594 |
+
], qe = {
|
595 |
+
inherit: "inherit",
|
596 |
+
current: "currentColor",
|
597 |
+
transparent: "transparent",
|
598 |
+
black: "#000",
|
599 |
+
white: "#fff",
|
600 |
+
slate: {
|
601 |
+
50: "#f8fafc",
|
602 |
+
100: "#f1f5f9",
|
603 |
+
200: "#e2e8f0",
|
604 |
+
300: "#cbd5e1",
|
605 |
+
400: "#94a3b8",
|
606 |
+
500: "#64748b",
|
607 |
+
600: "#475569",
|
608 |
+
700: "#334155",
|
609 |
+
800: "#1e293b",
|
610 |
+
900: "#0f172a",
|
611 |
+
950: "#020617"
|
612 |
+
},
|
613 |
+
gray: {
|
614 |
+
50: "#f9fafb",
|
615 |
+
100: "#f3f4f6",
|
616 |
+
200: "#e5e7eb",
|
617 |
+
300: "#d1d5db",
|
618 |
+
400: "#9ca3af",
|
619 |
+
500: "#6b7280",
|
620 |
+
600: "#4b5563",
|
621 |
+
700: "#374151",
|
622 |
+
800: "#1f2937",
|
623 |
+
900: "#111827",
|
624 |
+
950: "#030712"
|
625 |
+
},
|
626 |
+
zinc: {
|
627 |
+
50: "#fafafa",
|
628 |
+
100: "#f4f4f5",
|
629 |
+
200: "#e4e4e7",
|
630 |
+
300: "#d4d4d8",
|
631 |
+
400: "#a1a1aa",
|
632 |
+
500: "#71717a",
|
633 |
+
600: "#52525b",
|
634 |
+
700: "#3f3f46",
|
635 |
+
800: "#27272a",
|
636 |
+
900: "#18181b",
|
637 |
+
950: "#09090b"
|
638 |
+
},
|
639 |
+
neutral: {
|
640 |
+
50: "#fafafa",
|
641 |
+
100: "#f5f5f5",
|
642 |
+
200: "#e5e5e5",
|
643 |
+
300: "#d4d4d4",
|
644 |
+
400: "#a3a3a3",
|
645 |
+
500: "#737373",
|
646 |
+
600: "#525252",
|
647 |
+
700: "#404040",
|
648 |
+
800: "#262626",
|
649 |
+
900: "#171717",
|
650 |
+
950: "#0a0a0a"
|
651 |
+
},
|
652 |
+
stone: {
|
653 |
+
50: "#fafaf9",
|
654 |
+
100: "#f5f5f4",
|
655 |
+
200: "#e7e5e4",
|
656 |
+
300: "#d6d3d1",
|
657 |
+
400: "#a8a29e",
|
658 |
+
500: "#78716c",
|
659 |
+
600: "#57534e",
|
660 |
+
700: "#44403c",
|
661 |
+
800: "#292524",
|
662 |
+
900: "#1c1917",
|
663 |
+
950: "#0c0a09"
|
664 |
+
},
|
665 |
+
red: {
|
666 |
+
50: "#fef2f2",
|
667 |
+
100: "#fee2e2",
|
668 |
+
200: "#fecaca",
|
669 |
+
300: "#fca5a5",
|
670 |
+
400: "#f87171",
|
671 |
+
500: "#ef4444",
|
672 |
+
600: "#dc2626",
|
673 |
+
700: "#b91c1c",
|
674 |
+
800: "#991b1b",
|
675 |
+
900: "#7f1d1d",
|
676 |
+
950: "#450a0a"
|
677 |
+
},
|
678 |
+
orange: {
|
679 |
+
50: "#fff7ed",
|
680 |
+
100: "#ffedd5",
|
681 |
+
200: "#fed7aa",
|
682 |
+
300: "#fdba74",
|
683 |
+
400: "#fb923c",
|
684 |
+
500: "#f97316",
|
685 |
+
600: "#ea580c",
|
686 |
+
700: "#c2410c",
|
687 |
+
800: "#9a3412",
|
688 |
+
900: "#7c2d12",
|
689 |
+
950: "#431407"
|
690 |
+
},
|
691 |
+
amber: {
|
692 |
+
50: "#fffbeb",
|
693 |
+
100: "#fef3c7",
|
694 |
+
200: "#fde68a",
|
695 |
+
300: "#fcd34d",
|
696 |
+
400: "#fbbf24",
|
697 |
+
500: "#f59e0b",
|
698 |
+
600: "#d97706",
|
699 |
+
700: "#b45309",
|
700 |
+
800: "#92400e",
|
701 |
+
900: "#78350f",
|
702 |
+
950: "#451a03"
|
703 |
+
},
|
704 |
+
yellow: {
|
705 |
+
50: "#fefce8",
|
706 |
+
100: "#fef9c3",
|
707 |
+
200: "#fef08a",
|
708 |
+
300: "#fde047",
|
709 |
+
400: "#facc15",
|
710 |
+
500: "#eab308",
|
711 |
+
600: "#ca8a04",
|
712 |
+
700: "#a16207",
|
713 |
+
800: "#854d0e",
|
714 |
+
900: "#713f12",
|
715 |
+
950: "#422006"
|
716 |
+
},
|
717 |
+
lime: {
|
718 |
+
50: "#f7fee7",
|
719 |
+
100: "#ecfccb",
|
720 |
+
200: "#d9f99d",
|
721 |
+
300: "#bef264",
|
722 |
+
400: "#a3e635",
|
723 |
+
500: "#84cc16",
|
724 |
+
600: "#65a30d",
|
725 |
+
700: "#4d7c0f",
|
726 |
+
800: "#3f6212",
|
727 |
+
900: "#365314",
|
728 |
+
950: "#1a2e05"
|
729 |
+
},
|
730 |
+
green: {
|
731 |
+
50: "#f0fdf4",
|
732 |
+
100: "#dcfce7",
|
733 |
+
200: "#bbf7d0",
|
734 |
+
300: "#86efac",
|
735 |
+
400: "#4ade80",
|
736 |
+
500: "#22c55e",
|
737 |
+
600: "#16a34a",
|
738 |
+
700: "#15803d",
|
739 |
+
800: "#166534",
|
740 |
+
900: "#14532d",
|
741 |
+
950: "#052e16"
|
742 |
+
},
|
743 |
+
emerald: {
|
744 |
+
50: "#ecfdf5",
|
745 |
+
100: "#d1fae5",
|
746 |
+
200: "#a7f3d0",
|
747 |
+
300: "#6ee7b7",
|
748 |
+
400: "#34d399",
|
749 |
+
500: "#10b981",
|
750 |
+
600: "#059669",
|
751 |
+
700: "#047857",
|
752 |
+
800: "#065f46",
|
753 |
+
900: "#064e3b",
|
754 |
+
950: "#022c22"
|
755 |
+
},
|
756 |
+
teal: {
|
757 |
+
50: "#f0fdfa",
|
758 |
+
100: "#ccfbf1",
|
759 |
+
200: "#99f6e4",
|
760 |
+
300: "#5eead4",
|
761 |
+
400: "#2dd4bf",
|
762 |
+
500: "#14b8a6",
|
763 |
+
600: "#0d9488",
|
764 |
+
700: "#0f766e",
|
765 |
+
800: "#115e59",
|
766 |
+
900: "#134e4a",
|
767 |
+
950: "#042f2e"
|
768 |
+
},
|
769 |
+
cyan: {
|
770 |
+
50: "#ecfeff",
|
771 |
+
100: "#cffafe",
|
772 |
+
200: "#a5f3fc",
|
773 |
+
300: "#67e8f9",
|
774 |
+
400: "#22d3ee",
|
775 |
+
500: "#06b6d4",
|
776 |
+
600: "#0891b2",
|
777 |
+
700: "#0e7490",
|
778 |
+
800: "#155e75",
|
779 |
+
900: "#164e63",
|
780 |
+
950: "#083344"
|
781 |
+
},
|
782 |
+
sky: {
|
783 |
+
50: "#f0f9ff",
|
784 |
+
100: "#e0f2fe",
|
785 |
+
200: "#bae6fd",
|
786 |
+
300: "#7dd3fc",
|
787 |
+
400: "#38bdf8",
|
788 |
+
500: "#0ea5e9",
|
789 |
+
600: "#0284c7",
|
790 |
+
700: "#0369a1",
|
791 |
+
800: "#075985",
|
792 |
+
900: "#0c4a6e",
|
793 |
+
950: "#082f49"
|
794 |
+
},
|
795 |
+
blue: {
|
796 |
+
50: "#eff6ff",
|
797 |
+
100: "#dbeafe",
|
798 |
+
200: "#bfdbfe",
|
799 |
+
300: "#93c5fd",
|
800 |
+
400: "#60a5fa",
|
801 |
+
500: "#3b82f6",
|
802 |
+
600: "#2563eb",
|
803 |
+
700: "#1d4ed8",
|
804 |
+
800: "#1e40af",
|
805 |
+
900: "#1e3a8a",
|
806 |
+
950: "#172554"
|
807 |
+
},
|
808 |
+
indigo: {
|
809 |
+
50: "#eef2ff",
|
810 |
+
100: "#e0e7ff",
|
811 |
+
200: "#c7d2fe",
|
812 |
+
300: "#a5b4fc",
|
813 |
+
400: "#818cf8",
|
814 |
+
500: "#6366f1",
|
815 |
+
600: "#4f46e5",
|
816 |
+
700: "#4338ca",
|
817 |
+
800: "#3730a3",
|
818 |
+
900: "#312e81",
|
819 |
+
950: "#1e1b4b"
|
820 |
+
},
|
821 |
+
violet: {
|
822 |
+
50: "#f5f3ff",
|
823 |
+
100: "#ede9fe",
|
824 |
+
200: "#ddd6fe",
|
825 |
+
300: "#c4b5fd",
|
826 |
+
400: "#a78bfa",
|
827 |
+
500: "#8b5cf6",
|
828 |
+
600: "#7c3aed",
|
829 |
+
700: "#6d28d9",
|
830 |
+
800: "#5b21b6",
|
831 |
+
900: "#4c1d95",
|
832 |
+
950: "#2e1065"
|
833 |
+
},
|
834 |
+
purple: {
|
835 |
+
50: "#faf5ff",
|
836 |
+
100: "#f3e8ff",
|
837 |
+
200: "#e9d5ff",
|
838 |
+
300: "#d8b4fe",
|
839 |
+
400: "#c084fc",
|
840 |
+
500: "#a855f7",
|
841 |
+
600: "#9333ea",
|
842 |
+
700: "#7e22ce",
|
843 |
+
800: "#6b21a8",
|
844 |
+
900: "#581c87",
|
845 |
+
950: "#3b0764"
|
846 |
+
},
|
847 |
+
fuchsia: {
|
848 |
+
50: "#fdf4ff",
|
849 |
+
100: "#fae8ff",
|
850 |
+
200: "#f5d0fe",
|
851 |
+
300: "#f0abfc",
|
852 |
+
400: "#e879f9",
|
853 |
+
500: "#d946ef",
|
854 |
+
600: "#c026d3",
|
855 |
+
700: "#a21caf",
|
856 |
+
800: "#86198f",
|
857 |
+
900: "#701a75",
|
858 |
+
950: "#4a044e"
|
859 |
+
},
|
860 |
+
pink: {
|
861 |
+
50: "#fdf2f8",
|
862 |
+
100: "#fce7f3",
|
863 |
+
200: "#fbcfe8",
|
864 |
+
300: "#f9a8d4",
|
865 |
+
400: "#f472b6",
|
866 |
+
500: "#ec4899",
|
867 |
+
600: "#db2777",
|
868 |
+
700: "#be185d",
|
869 |
+
800: "#9d174d",
|
870 |
+
900: "#831843",
|
871 |
+
950: "#500724"
|
872 |
+
},
|
873 |
+
rose: {
|
874 |
+
50: "#fff1f2",
|
875 |
+
100: "#ffe4e6",
|
876 |
+
200: "#fecdd3",
|
877 |
+
300: "#fda4af",
|
878 |
+
400: "#fb7185",
|
879 |
+
500: "#f43f5e",
|
880 |
+
600: "#e11d48",
|
881 |
+
700: "#be123c",
|
882 |
+
800: "#9f1239",
|
883 |
+
900: "#881337",
|
884 |
+
950: "#4c0519"
|
885 |
+
}
|
886 |
+
};
|
887 |
+
rn.reduce(
|
888 |
+
(n, { color: e, primary: t, secondary: l }) => ({
|
889 |
+
...n,
|
890 |
+
[e]: {
|
891 |
+
primary: qe[e][t],
|
892 |
+
secondary: qe[e][l]
|
893 |
+
}
|
894 |
+
}),
|
895 |
+
{}
|
896 |
+
);
|
897 |
+
const {
|
898 |
+
SvelteComponent: dn,
|
899 |
+
assign: cn,
|
900 |
+
create_slot: mn,
|
901 |
+
detach: bn,
|
902 |
+
element: hn,
|
903 |
+
get_all_dirty_from_scope: gn,
|
904 |
+
get_slot_changes: wn,
|
905 |
+
get_spread_update: vn,
|
906 |
+
init: kn,
|
907 |
+
insert: yn,
|
908 |
+
safe_not_equal: qn,
|
909 |
+
set_dynamic_element_data: Ce,
|
910 |
+
set_style: I,
|
911 |
+
toggle_class: D,
|
912 |
+
transition_in: Ae,
|
913 |
+
transition_out: Ge,
|
914 |
+
update_slot_base: Cn
|
915 |
+
} = window.__gradio__svelte__internal;
|
916 |
+
function Sn(n) {
|
917 |
+
let e, t, l;
|
918 |
+
const i = (
|
919 |
+
/*#slots*/
|
920 |
+
n[18].default
|
921 |
+
), s = mn(
|
922 |
+
i,
|
923 |
+
n,
|
924 |
+
/*$$scope*/
|
925 |
+
n[17],
|
926 |
+
null
|
927 |
+
);
|
928 |
+
let _ = [
|
929 |
+
{ "data-testid": (
|
930 |
+
/*test_id*/
|
931 |
+
n[7]
|
932 |
+
) },
|
933 |
+
{ id: (
|
934 |
+
/*elem_id*/
|
935 |
+
n[2]
|
936 |
+
) },
|
937 |
+
{
|
938 |
+
class: t = "block " + /*elem_classes*/
|
939 |
+
n[3].join(" ") + " svelte-nl1om8"
|
940 |
+
}
|
941 |
+
], a = {};
|
942 |
+
for (let f = 0; f < _.length; f += 1)
|
943 |
+
a = cn(a, _[f]);
|
944 |
+
return {
|
945 |
+
c() {
|
946 |
+
e = hn(
|
947 |
+
/*tag*/
|
948 |
+
n[14]
|
949 |
+
), s && s.c(), Ce(
|
950 |
+
/*tag*/
|
951 |
+
n[14]
|
952 |
+
)(e, a), D(
|
953 |
+
e,
|
954 |
+
"hidden",
|
955 |
+
/*visible*/
|
956 |
+
n[10] === !1
|
957 |
+
), D(
|
958 |
+
e,
|
959 |
+
"padded",
|
960 |
+
/*padding*/
|
961 |
+
n[6]
|
962 |
+
), D(
|
963 |
+
e,
|
964 |
+
"border_focus",
|
965 |
+
/*border_mode*/
|
966 |
+
n[5] === "focus"
|
967 |
+
), D(
|
968 |
+
e,
|
969 |
+
"border_contrast",
|
970 |
+
/*border_mode*/
|
971 |
+
n[5] === "contrast"
|
972 |
+
), D(e, "hide-container", !/*explicit_call*/
|
973 |
+
n[8] && !/*container*/
|
974 |
+
n[9]), I(
|
975 |
+
e,
|
976 |
+
"height",
|
977 |
+
/*get_dimension*/
|
978 |
+
n[15](
|
979 |
+
/*height*/
|
980 |
+
n[0]
|
981 |
+
)
|
982 |
+
), I(e, "width", typeof /*width*/
|
983 |
+
n[1] == "number" ? `calc(min(${/*width*/
|
984 |
+
n[1]}px, 100%))` : (
|
985 |
+
/*get_dimension*/
|
986 |
+
n[15](
|
987 |
+
/*width*/
|
988 |
+
n[1]
|
989 |
+
)
|
990 |
+
)), I(
|
991 |
+
e,
|
992 |
+
"border-style",
|
993 |
+
/*variant*/
|
994 |
+
n[4]
|
995 |
+
), I(
|
996 |
+
e,
|
997 |
+
"overflow",
|
998 |
+
/*allow_overflow*/
|
999 |
+
n[11] ? "visible" : "hidden"
|
1000 |
+
), I(
|
1001 |
+
e,
|
1002 |
+
"flex-grow",
|
1003 |
+
/*scale*/
|
1004 |
+
n[12]
|
1005 |
+
), I(e, "min-width", `calc(min(${/*min_width*/
|
1006 |
+
n[13]}px, 100%))`), I(e, "border-width", "var(--block-border-width)");
|
1007 |
+
},
|
1008 |
+
m(f, o) {
|
1009 |
+
yn(f, e, o), s && s.m(e, null), l = !0;
|
1010 |
+
},
|
1011 |
+
p(f, o) {
|
1012 |
+
s && s.p && (!l || o & /*$$scope*/
|
1013 |
+
131072) && Cn(
|
1014 |
+
s,
|
1015 |
+
i,
|
1016 |
+
f,
|
1017 |
+
/*$$scope*/
|
1018 |
+
f[17],
|
1019 |
+
l ? wn(
|
1020 |
+
i,
|
1021 |
+
/*$$scope*/
|
1022 |
+
f[17],
|
1023 |
+
o,
|
1024 |
+
null
|
1025 |
+
) : gn(
|
1026 |
+
/*$$scope*/
|
1027 |
+
f[17]
|
1028 |
+
),
|
1029 |
+
null
|
1030 |
+
), Ce(
|
1031 |
+
/*tag*/
|
1032 |
+
f[14]
|
1033 |
+
)(e, a = vn(_, [
|
1034 |
+
(!l || o & /*test_id*/
|
1035 |
+
128) && { "data-testid": (
|
1036 |
+
/*test_id*/
|
1037 |
+
f[7]
|
1038 |
+
) },
|
1039 |
+
(!l || o & /*elem_id*/
|
1040 |
+
4) && { id: (
|
1041 |
+
/*elem_id*/
|
1042 |
+
f[2]
|
1043 |
+
) },
|
1044 |
+
(!l || o & /*elem_classes*/
|
1045 |
+
8 && t !== (t = "block " + /*elem_classes*/
|
1046 |
+
f[3].join(" ") + " svelte-nl1om8")) && { class: t }
|
1047 |
+
])), D(
|
1048 |
+
e,
|
1049 |
+
"hidden",
|
1050 |
+
/*visible*/
|
1051 |
+
f[10] === !1
|
1052 |
+
), D(
|
1053 |
+
e,
|
1054 |
+
"padded",
|
1055 |
+
/*padding*/
|
1056 |
+
f[6]
|
1057 |
+
), D(
|
1058 |
+
e,
|
1059 |
+
"border_focus",
|
1060 |
+
/*border_mode*/
|
1061 |
+
f[5] === "focus"
|
1062 |
+
), D(
|
1063 |
+
e,
|
1064 |
+
"border_contrast",
|
1065 |
+
/*border_mode*/
|
1066 |
+
f[5] === "contrast"
|
1067 |
+
), D(e, "hide-container", !/*explicit_call*/
|
1068 |
+
f[8] && !/*container*/
|
1069 |
+
f[9]), o & /*height*/
|
1070 |
+
1 && I(
|
1071 |
+
e,
|
1072 |
+
"height",
|
1073 |
+
/*get_dimension*/
|
1074 |
+
f[15](
|
1075 |
+
/*height*/
|
1076 |
+
f[0]
|
1077 |
+
)
|
1078 |
+
), o & /*width*/
|
1079 |
+
2 && I(e, "width", typeof /*width*/
|
1080 |
+
f[1] == "number" ? `calc(min(${/*width*/
|
1081 |
+
f[1]}px, 100%))` : (
|
1082 |
+
/*get_dimension*/
|
1083 |
+
f[15](
|
1084 |
+
/*width*/
|
1085 |
+
f[1]
|
1086 |
+
)
|
1087 |
+
)), o & /*variant*/
|
1088 |
+
16 && I(
|
1089 |
+
e,
|
1090 |
+
"border-style",
|
1091 |
+
/*variant*/
|
1092 |
+
f[4]
|
1093 |
+
), o & /*allow_overflow*/
|
1094 |
+
2048 && I(
|
1095 |
+
e,
|
1096 |
+
"overflow",
|
1097 |
+
/*allow_overflow*/
|
1098 |
+
f[11] ? "visible" : "hidden"
|
1099 |
+
), o & /*scale*/
|
1100 |
+
4096 && I(
|
1101 |
+
e,
|
1102 |
+
"flex-grow",
|
1103 |
+
/*scale*/
|
1104 |
+
f[12]
|
1105 |
+
), o & /*min_width*/
|
1106 |
+
8192 && I(e, "min-width", `calc(min(${/*min_width*/
|
1107 |
+
f[13]}px, 100%))`);
|
1108 |
+
},
|
1109 |
+
i(f) {
|
1110 |
+
l || (Ae(s, f), l = !0);
|
1111 |
+
},
|
1112 |
+
o(f) {
|
1113 |
+
Ge(s, f), l = !1;
|
1114 |
+
},
|
1115 |
+
d(f) {
|
1116 |
+
f && bn(e), s && s.d(f);
|
1117 |
+
}
|
1118 |
+
};
|
1119 |
+
}
|
1120 |
+
function jn(n) {
|
1121 |
+
let e, t = (
|
1122 |
+
/*tag*/
|
1123 |
+
n[14] && Sn(n)
|
1124 |
+
);
|
1125 |
+
return {
|
1126 |
+
c() {
|
1127 |
+
t && t.c();
|
1128 |
+
},
|
1129 |
+
m(l, i) {
|
1130 |
+
t && t.m(l, i), e = !0;
|
1131 |
+
},
|
1132 |
+
p(l, [i]) {
|
1133 |
+
/*tag*/
|
1134 |
+
l[14] && t.p(l, i);
|
1135 |
+
},
|
1136 |
+
i(l) {
|
1137 |
+
e || (Ae(t, l), e = !0);
|
1138 |
+
},
|
1139 |
+
o(l) {
|
1140 |
+
Ge(t, l), e = !1;
|
1141 |
+
},
|
1142 |
+
d(l) {
|
1143 |
+
t && t.d(l);
|
1144 |
+
}
|
1145 |
+
};
|
1146 |
+
}
|
1147 |
+
function Bn(n, e, t) {
|
1148 |
+
let { $$slots: l = {}, $$scope: i } = e, { height: s = void 0 } = e, { width: _ = void 0 } = e, { elem_id: a = "" } = e, { elem_classes: f = [] } = e, { variant: o = "solid" } = e, { border_mode: d = "base" } = e, { padding: g = !0 } = e, { type: w = "normal" } = e, { test_id: C = void 0 } = e, { explicit_call: q = !1 } = e, { container: k = !0 } = e, { visible: m = !0 } = e, { allow_overflow: r = !0 } = e, { scale: v = null } = e, { min_width: y = 0 } = e, j = w === "fieldset" ? "fieldset" : "div";
|
1149 |
+
const S = (u) => {
|
1150 |
+
if (u !== void 0) {
|
1151 |
+
if (typeof u == "number")
|
1152 |
+
return u + "px";
|
1153 |
+
if (typeof u == "string")
|
1154 |
+
return u;
|
1155 |
+
}
|
1156 |
+
};
|
1157 |
+
return n.$$set = (u) => {
|
1158 |
+
"height" in u && t(0, s = u.height), "width" in u && t(1, _ = u.width), "elem_id" in u && t(2, a = u.elem_id), "elem_classes" in u && t(3, f = u.elem_classes), "variant" in u && t(4, o = u.variant), "border_mode" in u && t(5, d = u.border_mode), "padding" in u && t(6, g = u.padding), "type" in u && t(16, w = u.type), "test_id" in u && t(7, C = u.test_id), "explicit_call" in u && t(8, q = u.explicit_call), "container" in u && t(9, k = u.container), "visible" in u && t(10, m = u.visible), "allow_overflow" in u && t(11, r = u.allow_overflow), "scale" in u && t(12, v = u.scale), "min_width" in u && t(13, y = u.min_width), "$$scope" in u && t(17, i = u.$$scope);
|
1159 |
+
}, [
|
1160 |
+
s,
|
1161 |
+
_,
|
1162 |
+
a,
|
1163 |
+
f,
|
1164 |
+
o,
|
1165 |
+
d,
|
1166 |
+
g,
|
1167 |
+
C,
|
1168 |
+
q,
|
1169 |
+
k,
|
1170 |
+
m,
|
1171 |
+
r,
|
1172 |
+
v,
|
1173 |
+
y,
|
1174 |
+
j,
|
1175 |
+
S,
|
1176 |
+
w,
|
1177 |
+
i,
|
1178 |
+
l
|
1179 |
+
];
|
1180 |
+
}
|
1181 |
+
class In extends dn {
|
1182 |
+
constructor(e) {
|
1183 |
+
super(), kn(this, e, Bn, jn, qn, {
|
1184 |
+
height: 0,
|
1185 |
+
width: 1,
|
1186 |
+
elem_id: 2,
|
1187 |
+
elem_classes: 3,
|
1188 |
+
variant: 4,
|
1189 |
+
border_mode: 5,
|
1190 |
+
padding: 6,
|
1191 |
+
type: 16,
|
1192 |
+
test_id: 7,
|
1193 |
+
explicit_call: 8,
|
1194 |
+
container: 9,
|
1195 |
+
visible: 10,
|
1196 |
+
allow_overflow: 11,
|
1197 |
+
scale: 12,
|
1198 |
+
min_width: 13
|
1199 |
+
});
|
1200 |
+
}
|
1201 |
+
}
|
1202 |
+
const {
|
1203 |
+
SvelteComponent: Tn,
|
1204 |
+
attr: Dn,
|
1205 |
+
create_slot: En,
|
1206 |
+
detach: Nn,
|
1207 |
+
element: Mn,
|
1208 |
+
get_all_dirty_from_scope: zn,
|
1209 |
+
get_slot_changes: Fn,
|
1210 |
+
init: Hn,
|
1211 |
+
insert: Jn,
|
1212 |
+
safe_not_equal: Ln,
|
1213 |
+
transition_in: On,
|
1214 |
+
transition_out: Pn,
|
1215 |
+
update_slot_base: Yn
|
1216 |
+
} = window.__gradio__svelte__internal;
|
1217 |
+
function An(n) {
|
1218 |
+
let e, t;
|
1219 |
+
const l = (
|
1220 |
+
/*#slots*/
|
1221 |
+
n[1].default
|
1222 |
+
), i = En(
|
1223 |
+
l,
|
1224 |
+
n,
|
1225 |
+
/*$$scope*/
|
1226 |
+
n[0],
|
1227 |
+
null
|
1228 |
+
);
|
1229 |
+
return {
|
1230 |
+
c() {
|
1231 |
+
e = Mn("div"), i && i.c(), Dn(e, "class", "svelte-1hnfib2");
|
1232 |
+
},
|
1233 |
+
m(s, _) {
|
1234 |
+
Jn(s, e, _), i && i.m(e, null), t = !0;
|
1235 |
+
},
|
1236 |
+
p(s, [_]) {
|
1237 |
+
i && i.p && (!t || _ & /*$$scope*/
|
1238 |
+
1) && Yn(
|
1239 |
+
i,
|
1240 |
+
l,
|
1241 |
+
s,
|
1242 |
+
/*$$scope*/
|
1243 |
+
s[0],
|
1244 |
+
t ? Fn(
|
1245 |
+
l,
|
1246 |
+
/*$$scope*/
|
1247 |
+
s[0],
|
1248 |
+
_,
|
1249 |
+
null
|
1250 |
+
) : zn(
|
1251 |
+
/*$$scope*/
|
1252 |
+
s[0]
|
1253 |
+
),
|
1254 |
+
null
|
1255 |
+
);
|
1256 |
+
},
|
1257 |
+
i(s) {
|
1258 |
+
t || (On(i, s), t = !0);
|
1259 |
+
},
|
1260 |
+
o(s) {
|
1261 |
+
Pn(i, s), t = !1;
|
1262 |
+
},
|
1263 |
+
d(s) {
|
1264 |
+
s && Nn(e), i && i.d(s);
|
1265 |
+
}
|
1266 |
+
};
|
1267 |
+
}
|
1268 |
+
function Gn(n, e, t) {
|
1269 |
+
let { $$slots: l = {}, $$scope: i } = e;
|
1270 |
+
return n.$$set = (s) => {
|
1271 |
+
"$$scope" in s && t(0, i = s.$$scope);
|
1272 |
+
}, [i, l];
|
1273 |
+
}
|
1274 |
+
class Kn extends Tn {
|
1275 |
+
constructor(e) {
|
1276 |
+
super(), Hn(this, e, Gn, An, Ln, {});
|
1277 |
+
}
|
1278 |
+
}
|
1279 |
+
const {
|
1280 |
+
SvelteComponent: Qn,
|
1281 |
+
attr: Se,
|
1282 |
+
check_outros: Rn,
|
1283 |
+
create_component: Un,
|
1284 |
+
create_slot: Vn,
|
1285 |
+
destroy_component: Wn,
|
1286 |
+
detach: x,
|
1287 |
+
element: Xn,
|
1288 |
+
empty: Zn,
|
1289 |
+
get_all_dirty_from_scope: pn,
|
1290 |
+
get_slot_changes: xn,
|
1291 |
+
group_outros: $n,
|
1292 |
+
init: el,
|
1293 |
+
insert: $,
|
1294 |
+
mount_component: tl,
|
1295 |
+
safe_not_equal: nl,
|
1296 |
+
set_data: ll,
|
1297 |
+
space: il,
|
1298 |
+
text: fl,
|
1299 |
+
toggle_class: F,
|
1300 |
+
transition_in: Q,
|
1301 |
+
transition_out: ee,
|
1302 |
+
update_slot_base: sl
|
1303 |
+
} = window.__gradio__svelte__internal;
|
1304 |
+
function je(n) {
|
1305 |
+
let e, t;
|
1306 |
+
return e = new Kn({
|
1307 |
+
props: {
|
1308 |
+
$$slots: { default: [al] },
|
1309 |
+
$$scope: { ctx: n }
|
1310 |
+
}
|
1311 |
+
}), {
|
1312 |
+
c() {
|
1313 |
+
Un(e.$$.fragment);
|
1314 |
+
},
|
1315 |
+
m(l, i) {
|
1316 |
+
tl(e, l, i), t = !0;
|
1317 |
+
},
|
1318 |
+
p(l, i) {
|
1319 |
+
const s = {};
|
1320 |
+
i & /*$$scope, info*/
|
1321 |
+
10 && (s.$$scope = { dirty: i, ctx: l }), e.$set(s);
|
1322 |
+
},
|
1323 |
+
i(l) {
|
1324 |
+
t || (Q(e.$$.fragment, l), t = !0);
|
1325 |
+
},
|
1326 |
+
o(l) {
|
1327 |
+
ee(e.$$.fragment, l), t = !1;
|
1328 |
+
},
|
1329 |
+
d(l) {
|
1330 |
+
Wn(e, l);
|
1331 |
+
}
|
1332 |
+
};
|
1333 |
+
}
|
1334 |
+
function al(n) {
|
1335 |
+
let e;
|
1336 |
+
return {
|
1337 |
+
c() {
|
1338 |
+
e = fl(
|
1339 |
+
/*info*/
|
1340 |
+
n[1]
|
1341 |
+
);
|
1342 |
+
},
|
1343 |
+
m(t, l) {
|
1344 |
+
$(t, e, l);
|
1345 |
+
},
|
1346 |
+
p(t, l) {
|
1347 |
+
l & /*info*/
|
1348 |
+
2 && ll(
|
1349 |
+
e,
|
1350 |
+
/*info*/
|
1351 |
+
t[1]
|
1352 |
+
);
|
1353 |
+
},
|
1354 |
+
d(t) {
|
1355 |
+
t && x(e);
|
1356 |
+
}
|
1357 |
+
};
|
1358 |
+
}
|
1359 |
+
function ol(n) {
|
1360 |
+
let e, t, l, i;
|
1361 |
+
const s = (
|
1362 |
+
/*#slots*/
|
1363 |
+
n[2].default
|
1364 |
+
), _ = Vn(
|
1365 |
+
s,
|
1366 |
+
n,
|
1367 |
+
/*$$scope*/
|
1368 |
+
n[3],
|
1369 |
+
null
|
1370 |
+
);
|
1371 |
+
let a = (
|
1372 |
+
/*info*/
|
1373 |
+
n[1] && je(n)
|
1374 |
+
);
|
1375 |
+
return {
|
1376 |
+
c() {
|
1377 |
+
e = Xn("span"), _ && _.c(), t = il(), a && a.c(), l = Zn(), Se(e, "data-testid", "block-info"), Se(e, "class", "svelte-22c38v"), F(e, "sr-only", !/*show_label*/
|
1378 |
+
n[0]), F(e, "hide", !/*show_label*/
|
1379 |
+
n[0]), F(
|
1380 |
+
e,
|
1381 |
+
"has-info",
|
1382 |
+
/*info*/
|
1383 |
+
n[1] != null
|
1384 |
+
);
|
1385 |
+
},
|
1386 |
+
m(f, o) {
|
1387 |
+
$(f, e, o), _ && _.m(e, null), $(f, t, o), a && a.m(f, o), $(f, l, o), i = !0;
|
1388 |
+
},
|
1389 |
+
p(f, [o]) {
|
1390 |
+
_ && _.p && (!i || o & /*$$scope*/
|
1391 |
+
8) && sl(
|
1392 |
+
_,
|
1393 |
+
s,
|
1394 |
+
f,
|
1395 |
+
/*$$scope*/
|
1396 |
+
f[3],
|
1397 |
+
i ? xn(
|
1398 |
+
s,
|
1399 |
+
/*$$scope*/
|
1400 |
+
f[3],
|
1401 |
+
o,
|
1402 |
+
null
|
1403 |
+
) : pn(
|
1404 |
+
/*$$scope*/
|
1405 |
+
f[3]
|
1406 |
+
),
|
1407 |
+
null
|
1408 |
+
), (!i || o & /*show_label*/
|
1409 |
+
1) && F(e, "sr-only", !/*show_label*/
|
1410 |
+
f[0]), (!i || o & /*show_label*/
|
1411 |
+
1) && F(e, "hide", !/*show_label*/
|
1412 |
+
f[0]), (!i || o & /*info*/
|
1413 |
+
2) && F(
|
1414 |
+
e,
|
1415 |
+
"has-info",
|
1416 |
+
/*info*/
|
1417 |
+
f[1] != null
|
1418 |
+
), /*info*/
|
1419 |
+
f[1] ? a ? (a.p(f, o), o & /*info*/
|
1420 |
+
2 && Q(a, 1)) : (a = je(f), a.c(), Q(a, 1), a.m(l.parentNode, l)) : a && ($n(), ee(a, 1, 1, () => {
|
1421 |
+
a = null;
|
1422 |
+
}), Rn());
|
1423 |
+
},
|
1424 |
+
i(f) {
|
1425 |
+
i || (Q(_, f), Q(a), i = !0);
|
1426 |
+
},
|
1427 |
+
o(f) {
|
1428 |
+
ee(_, f), ee(a), i = !1;
|
1429 |
+
},
|
1430 |
+
d(f) {
|
1431 |
+
f && (x(e), x(t), x(l)), _ && _.d(f), a && a.d(f);
|
1432 |
+
}
|
1433 |
+
};
|
1434 |
+
}
|
1435 |
+
function _l(n, e, t) {
|
1436 |
+
let { $$slots: l = {}, $$scope: i } = e, { show_label: s = !0 } = e, { info: _ = void 0 } = e;
|
1437 |
+
return n.$$set = (a) => {
|
1438 |
+
"show_label" in a && t(0, s = a.show_label), "info" in a && t(1, _ = a.info), "$$scope" in a && t(3, i = a.$$scope);
|
1439 |
+
}, [s, _, l, i];
|
1440 |
+
}
|
1441 |
+
class ul extends Qn {
|
1442 |
+
constructor(e) {
|
1443 |
+
super(), el(this, e, _l, ol, nl, { show_label: 0, info: 1 });
|
1444 |
+
}
|
1445 |
+
}
|
1446 |
+
const {
|
1447 |
+
SvelteComponent: rl,
|
1448 |
+
append: W,
|
1449 |
+
attr: E,
|
1450 |
+
binding_callbacks: Be,
|
1451 |
+
create_component: re,
|
1452 |
+
destroy_component: de,
|
1453 |
+
detach: J,
|
1454 |
+
element: H,
|
1455 |
+
init: dl,
|
1456 |
+
insert: L,
|
1457 |
+
listen: N,
|
1458 |
+
mount_component: ce,
|
1459 |
+
run_all: ge,
|
1460 |
+
safe_not_equal: cl,
|
1461 |
+
set_data: ml,
|
1462 |
+
set_input_value: Y,
|
1463 |
+
space: ue,
|
1464 |
+
text: bl,
|
1465 |
+
toggle_class: Ie,
|
1466 |
+
transition_in: me,
|
1467 |
+
transition_out: be
|
1468 |
+
} = window.__gradio__svelte__internal;
|
1469 |
+
function hl(n) {
|
1470 |
+
let e;
|
1471 |
+
return {
|
1472 |
+
c() {
|
1473 |
+
e = bl(
|
1474 |
+
/*label*/
|
1475 |
+
n[1]
|
1476 |
+
);
|
1477 |
+
},
|
1478 |
+
m(t, l) {
|
1479 |
+
L(t, e, l);
|
1480 |
+
},
|
1481 |
+
p(t, l) {
|
1482 |
+
l & /*label*/
|
1483 |
+
2 && ml(
|
1484 |
+
e,
|
1485 |
+
/*label*/
|
1486 |
+
t[1]
|
1487 |
+
);
|
1488 |
+
},
|
1489 |
+
d(t) {
|
1490 |
+
t && J(e);
|
1491 |
+
}
|
1492 |
+
};
|
1493 |
+
}
|
1494 |
+
function gl(n) {
|
1495 |
+
let e, t, l;
|
1496 |
+
return {
|
1497 |
+
c() {
|
1498 |
+
e = H("input"), E(e, "type", "date"), E(e, "class", "datetime svelte-1rjvq1p"), E(e, "step", "1");
|
1499 |
+
},
|
1500 |
+
m(i, s) {
|
1501 |
+
L(i, e, s), n[23](e), Y(
|
1502 |
+
e,
|
1503 |
+
/*datevalue*/
|
1504 |
+
n[12]
|
1505 |
+
), t || (l = [
|
1506 |
+
N(
|
1507 |
+
e,
|
1508 |
+
"input",
|
1509 |
+
/*input_input_handler_2*/
|
1510 |
+
n[24]
|
1511 |
+
),
|
1512 |
+
N(
|
1513 |
+
e,
|
1514 |
+
"input",
|
1515 |
+
/*input_handler_1*/
|
1516 |
+
n[25]
|
1517 |
+
)
|
1518 |
+
], t = !0);
|
1519 |
+
},
|
1520 |
+
p(i, s) {
|
1521 |
+
s & /*datevalue*/
|
1522 |
+
4096 && Y(
|
1523 |
+
e,
|
1524 |
+
/*datevalue*/
|
1525 |
+
i[12]
|
1526 |
+
);
|
1527 |
+
},
|
1528 |
+
d(i) {
|
1529 |
+
i && J(e), n[23](null), t = !1, ge(l);
|
1530 |
+
}
|
1531 |
+
};
|
1532 |
+
}
|
1533 |
+
function wl(n) {
|
1534 |
+
let e, t, l;
|
1535 |
+
return {
|
1536 |
+
c() {
|
1537 |
+
e = H("input"), E(e, "type", "datetime-local"), E(e, "class", "datetime svelte-1rjvq1p"), E(e, "step", "1");
|
1538 |
+
},
|
1539 |
+
m(i, s) {
|
1540 |
+
L(i, e, s), n[20](e), Y(
|
1541 |
+
e,
|
1542 |
+
/*datevalue*/
|
1543 |
+
n[12]
|
1544 |
+
), t || (l = [
|
1545 |
+
N(
|
1546 |
+
e,
|
1547 |
+
"input",
|
1548 |
+
/*input_input_handler_1*/
|
1549 |
+
n[21]
|
1550 |
+
),
|
1551 |
+
N(
|
1552 |
+
e,
|
1553 |
+
"input",
|
1554 |
+
/*input_handler*/
|
1555 |
+
n[22]
|
1556 |
+
)
|
1557 |
+
], t = !0);
|
1558 |
+
},
|
1559 |
+
p(i, s) {
|
1560 |
+
s & /*datevalue*/
|
1561 |
+
4096 && Y(
|
1562 |
+
e,
|
1563 |
+
/*datevalue*/
|
1564 |
+
i[12]
|
1565 |
+
);
|
1566 |
+
},
|
1567 |
+
d(i) {
|
1568 |
+
i && J(e), n[20](null), t = !1, ge(l);
|
1569 |
+
}
|
1570 |
+
};
|
1571 |
+
}
|
1572 |
+
function vl(n) {
|
1573 |
+
let e, t, l, i, s, _, a, f, o, d, g, w;
|
1574 |
+
t = new ul({
|
1575 |
+
props: {
|
1576 |
+
show_label: (
|
1577 |
+
/*show_label*/
|
1578 |
+
n[2]
|
1579 |
+
),
|
1580 |
+
info: (
|
1581 |
+
/*info*/
|
1582 |
+
n[3]
|
1583 |
+
),
|
1584 |
+
$$slots: { default: [hl] },
|
1585 |
+
$$scope: { ctx: n }
|
1586 |
+
}
|
1587 |
+
});
|
1588 |
+
function C(m, r) {
|
1589 |
+
return (
|
1590 |
+
/*include_time*/
|
1591 |
+
m[9] ? wl : gl
|
1592 |
+
);
|
1593 |
+
}
|
1594 |
+
let q = C(n), k = q(n);
|
1595 |
+
return o = new un({}), {
|
1596 |
+
c() {
|
1597 |
+
e = H("div"), re(t.$$.fragment), l = ue(), i = H("div"), s = H("input"), _ = ue(), k.c(), a = ue(), f = H("button"), re(o.$$.fragment), E(e, "class", "label-content svelte-1rjvq1p"), E(s, "class", "time svelte-1rjvq1p"), Ie(s, "invalid", !/*valid*/
|
1598 |
+
n[13]), E(f, "class", "calendar svelte-1rjvq1p"), E(i, "class", "timebox svelte-1rjvq1p");
|
1599 |
+
},
|
1600 |
+
m(m, r) {
|
1601 |
+
L(m, e, r), ce(t, e, null), L(m, l, r), L(m, i, r), W(i, s), Y(
|
1602 |
+
s,
|
1603 |
+
/*entered_value*/
|
1604 |
+
n[10]
|
1605 |
+
), W(i, _), k.m(i, null), W(i, a), W(i, f), ce(o, f, null), d = !0, g || (w = [
|
1606 |
+
N(
|
1607 |
+
s,
|
1608 |
+
"input",
|
1609 |
+
/*input_input_handler*/
|
1610 |
+
n[18]
|
1611 |
+
),
|
1612 |
+
N(
|
1613 |
+
s,
|
1614 |
+
"keydown",
|
1615 |
+
/*keydown_handler*/
|
1616 |
+
n[19]
|
1617 |
+
),
|
1618 |
+
N(
|
1619 |
+
s,
|
1620 |
+
"blur",
|
1621 |
+
/*submit_values*/
|
1622 |
+
n[15]
|
1623 |
+
),
|
1624 |
+
N(
|
1625 |
+
f,
|
1626 |
+
"click",
|
1627 |
+
/*click_handler*/
|
1628 |
+
n[26]
|
1629 |
+
)
|
1630 |
+
], g = !0);
|
1631 |
+
},
|
1632 |
+
p(m, r) {
|
1633 |
+
const v = {};
|
1634 |
+
r & /*show_label*/
|
1635 |
+
4 && (v.show_label = /*show_label*/
|
1636 |
+
m[2]), r & /*info*/
|
1637 |
+
8 && (v.info = /*info*/
|
1638 |
+
m[3]), r & /*$$scope, label*/
|
1639 |
+
268435458 && (v.$$scope = { dirty: r, ctx: m }), t.$set(v), r & /*entered_value*/
|
1640 |
+
1024 && s.value !== /*entered_value*/
|
1641 |
+
m[10] && Y(
|
1642 |
+
s,
|
1643 |
+
/*entered_value*/
|
1644 |
+
m[10]
|
1645 |
+
), (!d || r & /*valid*/
|
1646 |
+
8192) && Ie(s, "invalid", !/*valid*/
|
1647 |
+
m[13]), q === (q = C(m)) && k ? k.p(m, r) : (k.d(1), k = q(m), k && (k.c(), k.m(i, a)));
|
1648 |
+
},
|
1649 |
+
i(m) {
|
1650 |
+
d || (me(t.$$.fragment, m), me(o.$$.fragment, m), d = !0);
|
1651 |
+
},
|
1652 |
+
o(m) {
|
1653 |
+
be(t.$$.fragment, m), be(o.$$.fragment, m), d = !1;
|
1654 |
+
},
|
1655 |
+
d(m) {
|
1656 |
+
m && (J(e), J(l), J(i)), de(t), k.d(), de(o), g = !1, ge(w);
|
1657 |
+
}
|
1658 |
+
};
|
1659 |
+
}
|
1660 |
+
function kl(n) {
|
1661 |
+
let e, t;
|
1662 |
+
return e = new In({
|
1663 |
+
props: {
|
1664 |
+
visible: (
|
1665 |
+
/*visible*/
|
1666 |
+
n[6]
|
1667 |
+
),
|
1668 |
+
elem_id: (
|
1669 |
+
/*elem_id*/
|
1670 |
+
n[4]
|
1671 |
+
),
|
1672 |
+
elem_classes: (
|
1673 |
+
/*elem_classes*/
|
1674 |
+
n[5]
|
1675 |
+
),
|
1676 |
+
scale: (
|
1677 |
+
/*scale*/
|
1678 |
+
n[7]
|
1679 |
+
),
|
1680 |
+
min_width: (
|
1681 |
+
/*min_width*/
|
1682 |
+
n[8]
|
1683 |
+
),
|
1684 |
+
allow_overflow: !1,
|
1685 |
+
padding: !0,
|
1686 |
+
$$slots: { default: [vl] },
|
1687 |
+
$$scope: { ctx: n }
|
1688 |
+
}
|
1689 |
+
}), {
|
1690 |
+
c() {
|
1691 |
+
re(e.$$.fragment);
|
1692 |
+
},
|
1693 |
+
m(l, i) {
|
1694 |
+
ce(e, l, i), t = !0;
|
1695 |
+
},
|
1696 |
+
p(l, [i]) {
|
1697 |
+
const s = {};
|
1698 |
+
i & /*visible*/
|
1699 |
+
64 && (s.visible = /*visible*/
|
1700 |
+
l[6]), i & /*elem_id*/
|
1701 |
+
16 && (s.elem_id = /*elem_id*/
|
1702 |
+
l[4]), i & /*elem_classes*/
|
1703 |
+
32 && (s.elem_classes = /*elem_classes*/
|
1704 |
+
l[5]), i & /*scale*/
|
1705 |
+
128 && (s.scale = /*scale*/
|
1706 |
+
l[7]), i & /*min_width*/
|
1707 |
+
256 && (s.min_width = /*min_width*/
|
1708 |
+
l[8]), i & /*$$scope, datetime, datevalue, entered_value, include_time, valid, gradio, show_label, info, label*/
|
1709 |
+
268451343 && (s.$$scope = { dirty: i, ctx: l }), e.$set(s);
|
1710 |
+
},
|
1711 |
+
i(l) {
|
1712 |
+
t || (me(e.$$.fragment, l), t = !0);
|
1713 |
+
},
|
1714 |
+
o(l) {
|
1715 |
+
be(e.$$.fragment, l), t = !1;
|
1716 |
+
},
|
1717 |
+
d(l) {
|
1718 |
+
de(e, l);
|
1719 |
+
}
|
1720 |
+
};
|
1721 |
+
}
|
1722 |
+
function yl(n, e, t) {
|
1723 |
+
let l, { gradio: i } = e, { label: s = "Time" } = e, { show_label: _ = !0 } = e, { info: a = void 0 } = e, { elem_id: f = "" } = e, { elem_classes: o = [] } = e, { visible: d = !0 } = e, { value: g = "" } = e, w = g, { scale: C = null } = e, { min_width: q = void 0 } = e, { include_time: k = !0 } = e;
|
1724 |
+
const m = (c) => {
|
1725 |
+
if (c.toJSON() === null) return "";
|
1726 |
+
const M = (lt) => lt.toString().padStart(2, "0"), ae = c.getFullYear(), oe = M(c.getMonth() + 1), xe = M(c.getDate()), $e = M(c.getHours()), et = M(c.getMinutes()), tt = M(c.getSeconds()), we = `${ae}-${oe}-${xe}`, nt = `${$e}:${et}:${tt}`;
|
1727 |
+
return k ? `${we} ${nt}` : we;
|
1728 |
+
};
|
1729 |
+
let r = g, v, y = g;
|
1730 |
+
const j = (c) => {
|
1731 |
+
if (c === "") return !1;
|
1732 |
+
const M = k ? /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/ : /^\d{4}-\d{2}-\d{2}$/, ae = c.match(M) !== null, oe = c.match(/^(?:\s*now\s*(?:-\s*\d+\s*[dmhs])?)?\s*$/) !== null;
|
1733 |
+
return ae || oe;
|
1734 |
+
}, S = () => {
|
1735 |
+
r !== g && j(r) && (t(17, w = t(16, g = r)), i.dispatch("change"));
|
1736 |
+
};
|
1737 |
+
function u() {
|
1738 |
+
r = this.value, t(10, r), t(16, g), t(17, w), t(0, i);
|
1739 |
+
}
|
1740 |
+
const b = (c) => {
|
1741 |
+
c.key === "Enter" && (S(), i.dispatch("submit"));
|
1742 |
+
};
|
1743 |
+
function Re(c) {
|
1744 |
+
Be[c ? "unshift" : "push"](() => {
|
1745 |
+
v = c, t(11, v);
|
1746 |
+
});
|
1747 |
+
}
|
1748 |
+
function Ue() {
|
1749 |
+
y = this.value, t(12, y), t(16, g), t(17, w), t(0, i);
|
1750 |
+
}
|
1751 |
+
const Ve = () => {
|
1752 |
+
const c = new Date(y);
|
1753 |
+
t(10, r = m(c)), S();
|
1754 |
+
};
|
1755 |
+
function We(c) {
|
1756 |
+
Be[c ? "unshift" : "push"](() => {
|
1757 |
+
v = c, t(11, v);
|
1758 |
+
});
|
1759 |
+
}
|
1760 |
+
function Xe() {
|
1761 |
+
y = this.value, t(12, y), t(16, g), t(17, w), t(0, i);
|
1762 |
+
}
|
1763 |
+
const Ze = () => {
|
1764 |
+
const c = new Date(y);
|
1765 |
+
t(10, r = m(c)), S();
|
1766 |
+
}, pe = () => {
|
1767 |
+
v.showPicker();
|
1768 |
+
};
|
1769 |
+
return n.$$set = (c) => {
|
1770 |
+
"gradio" in c && t(0, i = c.gradio), "label" in c && t(1, s = c.label), "show_label" in c && t(2, _ = c.show_label), "info" in c && t(3, a = c.info), "elem_id" in c && t(4, f = c.elem_id), "elem_classes" in c && t(5, o = c.elem_classes), "visible" in c && t(6, d = c.visible), "value" in c && t(16, g = c.value), "scale" in c && t(7, C = c.scale), "min_width" in c && t(8, q = c.min_width), "include_time" in c && t(9, k = c.include_time);
|
1771 |
+
}, n.$$.update = () => {
|
1772 |
+
n.$$.dirty & /*value, old_value, gradio*/
|
1773 |
+
196609 && g !== w && (t(17, w = g), t(10, r = g), t(12, y = g), i.dispatch("change")), n.$$.dirty & /*entered_value*/
|
1774 |
+
1024 && t(13, l = j(r));
|
1775 |
+
}, [
|
1776 |
+
i,
|
1777 |
+
s,
|
1778 |
+
_,
|
1779 |
+
a,
|
1780 |
+
f,
|
1781 |
+
o,
|
1782 |
+
d,
|
1783 |
+
C,
|
1784 |
+
q,
|
1785 |
+
k,
|
1786 |
+
r,
|
1787 |
+
v,
|
1788 |
+
y,
|
1789 |
+
l,
|
1790 |
+
m,
|
1791 |
+
S,
|
1792 |
+
g,
|
1793 |
+
w,
|
1794 |
+
u,
|
1795 |
+
b,
|
1796 |
+
Re,
|
1797 |
+
Ue,
|
1798 |
+
Ve,
|
1799 |
+
We,
|
1800 |
+
Xe,
|
1801 |
+
Ze,
|
1802 |
+
pe
|
1803 |
+
];
|
1804 |
+
}
|
1805 |
+
let Te = class extends rl {
|
1806 |
+
constructor(e) {
|
1807 |
+
super(), dl(this, e, yl, kl, cl, {
|
1808 |
+
gradio: 0,
|
1809 |
+
label: 1,
|
1810 |
+
show_label: 2,
|
1811 |
+
info: 3,
|
1812 |
+
elem_id: 4,
|
1813 |
+
elem_classes: 5,
|
1814 |
+
visible: 6,
|
1815 |
+
value: 16,
|
1816 |
+
scale: 7,
|
1817 |
+
min_width: 8,
|
1818 |
+
include_time: 9
|
1819 |
+
});
|
1820 |
+
}
|
1821 |
+
};
|
1822 |
+
const {
|
1823 |
+
SvelteComponent: ql,
|
1824 |
+
detach: Cl,
|
1825 |
+
init: Sl,
|
1826 |
+
insert: jl,
|
1827 |
+
noop: De,
|
1828 |
+
safe_not_equal: Bl,
|
1829 |
+
set_data: Il,
|
1830 |
+
text: Tl
|
1831 |
+
} = window.__gradio__svelte__internal;
|
1832 |
+
function Dl(n) {
|
1833 |
+
let e = (
|
1834 |
+
/*value*/
|
1835 |
+
(n[0] || "") + ""
|
1836 |
+
), t;
|
1837 |
+
return {
|
1838 |
+
c() {
|
1839 |
+
t = Tl(e);
|
1840 |
+
},
|
1841 |
+
m(l, i) {
|
1842 |
+
jl(l, t, i);
|
1843 |
+
},
|
1844 |
+
p(l, [i]) {
|
1845 |
+
i & /*value*/
|
1846 |
+
1 && e !== (e = /*value*/
|
1847 |
+
(l[0] || "") + "") && Il(t, e);
|
1848 |
+
},
|
1849 |
+
i: De,
|
1850 |
+
o: De,
|
1851 |
+
d(l) {
|
1852 |
+
l && Cl(t);
|
1853 |
+
}
|
1854 |
+
};
|
1855 |
+
}
|
1856 |
+
function El(n, e, t) {
|
1857 |
+
let { value: l } = e;
|
1858 |
+
return n.$$set = (i) => {
|
1859 |
+
"value" in i && t(0, l = i.value);
|
1860 |
+
}, [l];
|
1861 |
+
}
|
1862 |
+
class Kl extends ql {
|
1863 |
+
constructor(e) {
|
1864 |
+
super(), Sl(this, e, El, Dl, Bl, { value: 0 });
|
1865 |
+
}
|
1866 |
+
}
|
1867 |
+
const {
|
1868 |
+
SvelteComponent: Nl,
|
1869 |
+
add_flush_callback: Ee,
|
1870 |
+
append: A,
|
1871 |
+
attr: R,
|
1872 |
+
bind: Ne,
|
1873 |
+
binding_callbacks: Me,
|
1874 |
+
bubble: ze,
|
1875 |
+
create_component: te,
|
1876 |
+
destroy_component: ne,
|
1877 |
+
destroy_each: Ml,
|
1878 |
+
detach: O,
|
1879 |
+
element: U,
|
1880 |
+
ensure_array_like: Fe,
|
1881 |
+
init: zl,
|
1882 |
+
insert: P,
|
1883 |
+
listen: Ke,
|
1884 |
+
mount_component: le,
|
1885 |
+
safe_not_equal: Fl,
|
1886 |
+
set_data: Qe,
|
1887 |
+
set_style: He,
|
1888 |
+
space: ie,
|
1889 |
+
text: he,
|
1890 |
+
transition_in: fe,
|
1891 |
+
transition_out: se
|
1892 |
+
} = window.__gradio__svelte__internal;
|
1893 |
+
function Je(n, e, t) {
|
1894 |
+
const l = n.slice();
|
1895 |
+
return l[20] = e[t], l;
|
1896 |
+
}
|
1897 |
+
function Hl(n) {
|
1898 |
+
let e;
|
1899 |
+
return {
|
1900 |
+
c() {
|
1901 |
+
e = he(
|
1902 |
+
/*label*/
|
1903 |
+
n[2]
|
1904 |
+
);
|
1905 |
+
},
|
1906 |
+
m(t, l) {
|
1907 |
+
P(t, e, l);
|
1908 |
+
},
|
1909 |
+
p(t, l) {
|
1910 |
+
l & /*label*/
|
1911 |
+
4 && Qe(
|
1912 |
+
e,
|
1913 |
+
/*label*/
|
1914 |
+
t[2]
|
1915 |
+
);
|
1916 |
+
},
|
1917 |
+
d(t) {
|
1918 |
+
t && O(e);
|
1919 |
+
}
|
1920 |
+
};
|
1921 |
+
}
|
1922 |
+
function Le(n) {
|
1923 |
+
let e, t, l, i, s, _ = Fe(
|
1924 |
+
/*quick_ranges*/
|
1925 |
+
n[11]
|
1926 |
+
), a = [];
|
1927 |
+
for (let f = 0; f < _.length; f += 1)
|
1928 |
+
a[f] = Oe(Je(n, _, f));
|
1929 |
+
return {
|
1930 |
+
c() {
|
1931 |
+
e = U("div"), t = U("button"), t.textContent = "Back", l = ie();
|
1932 |
+
for (let f = 0; f < a.length; f += 1)
|
1933 |
+
a[f].c();
|
1934 |
+
R(t, "class", "quick-range svelte-ra6nvt"), He(
|
1935 |
+
t,
|
1936 |
+
"display",
|
1937 |
+
/*range_history*/
|
1938 |
+
n[12].length <= 1 ? "none" : "block"
|
1939 |
+
), R(e, "class", "quick-ranges svelte-ra6nvt");
|
1940 |
+
},
|
1941 |
+
m(f, o) {
|
1942 |
+
P(f, e, o), A(e, t), A(e, l);
|
1943 |
+
for (let d = 0; d < a.length; d += 1)
|
1944 |
+
a[d] && a[d].m(e, null);
|
1945 |
+
i || (s = Ke(
|
1946 |
+
t,
|
1947 |
+
"click",
|
1948 |
+
/*back_in_history*/
|
1949 |
+
n[13]
|
1950 |
+
), i = !0);
|
1951 |
+
},
|
1952 |
+
p(f, o) {
|
1953 |
+
if (o & /*range_history*/
|
1954 |
+
4096 && He(
|
1955 |
+
t,
|
1956 |
+
"display",
|
1957 |
+
/*range_history*/
|
1958 |
+
f[12].length <= 1 ? "none" : "block"
|
1959 |
+
), o & /*value, quick_ranges*/
|
1960 |
+
2049) {
|
1961 |
+
_ = Fe(
|
1962 |
+
/*quick_ranges*/
|
1963 |
+
f[11]
|
1964 |
+
);
|
1965 |
+
let d;
|
1966 |
+
for (d = 0; d < _.length; d += 1) {
|
1967 |
+
const g = Je(f, _, d);
|
1968 |
+
a[d] ? a[d].p(g, o) : (a[d] = Oe(g), a[d].c(), a[d].m(e, null));
|
1969 |
+
}
|
1970 |
+
for (; d < a.length; d += 1)
|
1971 |
+
a[d].d(1);
|
1972 |
+
a.length = _.length;
|
1973 |
+
}
|
1974 |
+
},
|
1975 |
+
d(f) {
|
1976 |
+
f && O(e), Ml(a, f), i = !1, s();
|
1977 |
+
}
|
1978 |
+
};
|
1979 |
+
}
|
1980 |
+
function Oe(n) {
|
1981 |
+
let e, t, l = (
|
1982 |
+
/*quick_range*/
|
1983 |
+
n[20] + ""
|
1984 |
+
), i, s, _;
|
1985 |
+
function a() {
|
1986 |
+
return (
|
1987 |
+
/*click_handler*/
|
1988 |
+
n[15](
|
1989 |
+
/*quick_range*/
|
1990 |
+
n[20]
|
1991 |
+
)
|
1992 |
+
);
|
1993 |
+
}
|
1994 |
+
return {
|
1995 |
+
c() {
|
1996 |
+
e = U("button"), t = he("Last "), i = he(l), R(e, "class", "quick-range svelte-ra6nvt");
|
1997 |
+
},
|
1998 |
+
m(f, o) {
|
1999 |
+
P(f, e, o), A(e, t), A(e, i), s || (_ = Ke(e, "click", a), s = !0);
|
2000 |
+
},
|
2001 |
+
p(f, o) {
|
2002 |
+
n = f, o & /*quick_ranges*/
|
2003 |
+
2048 && l !== (l = /*quick_range*/
|
2004 |
+
n[20] + "") && Qe(i, l);
|
2005 |
+
},
|
2006 |
+
d(f) {
|
2007 |
+
f && O(e), s = !1, _();
|
2008 |
+
}
|
2009 |
+
};
|
2010 |
+
}
|
2011 |
+
function Jl(n) {
|
2012 |
+
let e, t, l, i, s, _, a, f, o, d, g;
|
2013 |
+
t = new nn({
|
2014 |
+
props: {
|
2015 |
+
show_label: (
|
2016 |
+
/*show_label*/
|
2017 |
+
n[3]
|
2018 |
+
),
|
2019 |
+
info: (
|
2020 |
+
/*info*/
|
2021 |
+
n[4]
|
2022 |
+
),
|
2023 |
+
$$slots: { default: [Hl] },
|
2024 |
+
$$scope: { ctx: n }
|
2025 |
+
}
|
2026 |
+
});
|
2027 |
+
let w = (
|
2028 |
+
/*show_label*/
|
2029 |
+
n[3] && Le(n)
|
2030 |
+
);
|
2031 |
+
function C(r) {
|
2032 |
+
n[16](r);
|
2033 |
+
}
|
2034 |
+
let q = {
|
2035 |
+
show_label: !1,
|
2036 |
+
include_time: (
|
2037 |
+
/*include_time*/
|
2038 |
+
n[10]
|
2039 |
+
),
|
2040 |
+
gradio: (
|
2041 |
+
/*gradio*/
|
2042 |
+
n[1]
|
2043 |
+
)
|
2044 |
+
};
|
2045 |
+
/*value*/
|
2046 |
+
n[0][0] !== void 0 && (q.value = /*value*/
|
2047 |
+
n[0][0]), _ = new Te({ props: q }), Me.push(() => Ne(_, "value", C)), _.$on(
|
2048 |
+
"gradio",
|
2049 |
+
/*gradio_handler*/
|
2050 |
+
n[17]
|
2051 |
+
);
|
2052 |
+
function k(r) {
|
2053 |
+
n[18](r);
|
2054 |
+
}
|
2055 |
+
let m = {
|
2056 |
+
show_label: !1,
|
2057 |
+
include_time: (
|
2058 |
+
/*include_time*/
|
2059 |
+
n[10]
|
2060 |
+
),
|
2061 |
+
gradio: (
|
2062 |
+
/*gradio*/
|
2063 |
+
n[1]
|
2064 |
+
)
|
2065 |
+
};
|
2066 |
+
return (
|
2067 |
+
/*value*/
|
2068 |
+
n[0][1] !== void 0 && (m.value = /*value*/
|
2069 |
+
n[0][1]), o = new Te({ props: m }), Me.push(() => Ne(o, "value", k)), o.$on(
|
2070 |
+
"gradio",
|
2071 |
+
/*gradio_handler_1*/
|
2072 |
+
n[19]
|
2073 |
+
), {
|
2074 |
+
c() {
|
2075 |
+
e = U("div"), te(t.$$.fragment), l = ie(), w && w.c(), i = ie(), s = U("div"), te(_.$$.fragment), f = ie(), te(o.$$.fragment), R(e, "class", "label-content svelte-ra6nvt"), R(s, "class", "times svelte-ra6nvt");
|
2076 |
+
},
|
2077 |
+
m(r, v) {
|
2078 |
+
P(r, e, v), le(t, e, null), A(e, l), w && w.m(e, null), P(r, i, v), P(r, s, v), le(_, s, null), A(s, f), le(o, s, null), g = !0;
|
2079 |
+
},
|
2080 |
+
p(r, v) {
|
2081 |
+
const y = {};
|
2082 |
+
v & /*show_label*/
|
2083 |
+
8 && (y.show_label = /*show_label*/
|
2084 |
+
r[3]), v & /*info*/
|
2085 |
+
16 && (y.info = /*info*/
|
2086 |
+
r[4]), v & /*$$scope, label*/
|
2087 |
+
8388612 && (y.$$scope = { dirty: v, ctx: r }), t.$set(y), /*show_label*/
|
2088 |
+
r[3] ? w ? w.p(r, v) : (w = Le(r), w.c(), w.m(e, null)) : w && (w.d(1), w = null);
|
2089 |
+
const j = {};
|
2090 |
+
v & /*include_time*/
|
2091 |
+
1024 && (j.include_time = /*include_time*/
|
2092 |
+
r[10]), v & /*gradio*/
|
2093 |
+
2 && (j.gradio = /*gradio*/
|
2094 |
+
r[1]), !a && v & /*value*/
|
2095 |
+
1 && (a = !0, j.value = /*value*/
|
2096 |
+
r[0][0], Ee(() => a = !1)), _.$set(j);
|
2097 |
+
const S = {};
|
2098 |
+
v & /*include_time*/
|
2099 |
+
1024 && (S.include_time = /*include_time*/
|
2100 |
+
r[10]), v & /*gradio*/
|
2101 |
+
2 && (S.gradio = /*gradio*/
|
2102 |
+
r[1]), !d && v & /*value*/
|
2103 |
+
1 && (d = !0, S.value = /*value*/
|
2104 |
+
r[0][1], Ee(() => d = !1)), o.$set(S);
|
2105 |
+
},
|
2106 |
+
i(r) {
|
2107 |
+
g || (fe(t.$$.fragment, r), fe(_.$$.fragment, r), fe(o.$$.fragment, r), g = !0);
|
2108 |
+
},
|
2109 |
+
o(r) {
|
2110 |
+
se(t.$$.fragment, r), se(_.$$.fragment, r), se(o.$$.fragment, r), g = !1;
|
2111 |
+
},
|
2112 |
+
d(r) {
|
2113 |
+
r && (O(e), O(i), O(s)), ne(t), w && w.d(), ne(_), ne(o);
|
2114 |
+
}
|
2115 |
+
}
|
2116 |
+
);
|
2117 |
+
}
|
2118 |
+
function Ll(n) {
|
2119 |
+
let e, t;
|
2120 |
+
return e = new vt({
|
2121 |
+
props: {
|
2122 |
+
visible: (
|
2123 |
+
/*visible*/
|
2124 |
+
n[7]
|
2125 |
+
),
|
2126 |
+
elem_id: (
|
2127 |
+
/*elem_id*/
|
2128 |
+
n[5]
|
2129 |
+
),
|
2130 |
+
elem_classes: (
|
2131 |
+
/*elem_classes*/
|
2132 |
+
n[6]
|
2133 |
+
),
|
2134 |
+
scale: (
|
2135 |
+
/*scale*/
|
2136 |
+
n[8]
|
2137 |
+
),
|
2138 |
+
min_width: (
|
2139 |
+
/*min_width*/
|
2140 |
+
n[9]
|
2141 |
+
),
|
2142 |
+
allow_overflow: !1,
|
2143 |
+
padding: !0,
|
2144 |
+
$$slots: { default: [Jl] },
|
2145 |
+
$$scope: { ctx: n }
|
2146 |
+
}
|
2147 |
+
}), {
|
2148 |
+
c() {
|
2149 |
+
te(e.$$.fragment);
|
2150 |
+
},
|
2151 |
+
m(l, i) {
|
2152 |
+
le(e, l, i), t = !0;
|
2153 |
+
},
|
2154 |
+
p(l, [i]) {
|
2155 |
+
const s = {};
|
2156 |
+
i & /*visible*/
|
2157 |
+
128 && (s.visible = /*visible*/
|
2158 |
+
l[7]), i & /*elem_id*/
|
2159 |
+
32 && (s.elem_id = /*elem_id*/
|
2160 |
+
l[5]), i & /*elem_classes*/
|
2161 |
+
64 && (s.elem_classes = /*elem_classes*/
|
2162 |
+
l[6]), i & /*scale*/
|
2163 |
+
256 && (s.scale = /*scale*/
|
2164 |
+
l[8]), i & /*min_width*/
|
2165 |
+
512 && (s.min_width = /*min_width*/
|
2166 |
+
l[9]), i & /*$$scope, include_time, gradio, value, quick_ranges, range_history, show_label, info, label*/
|
2167 |
+
8395807 && (s.$$scope = { dirty: i, ctx: l }), e.$set(s);
|
2168 |
+
},
|
2169 |
+
i(l) {
|
2170 |
+
t || (fe(e.$$.fragment, l), t = !0);
|
2171 |
+
},
|
2172 |
+
o(l) {
|
2173 |
+
se(e.$$.fragment, l), t = !1;
|
2174 |
+
},
|
2175 |
+
d(l) {
|
2176 |
+
ne(e, l);
|
2177 |
+
}
|
2178 |
+
};
|
2179 |
+
}
|
2180 |
+
function Ol(n, e, t) {
|
2181 |
+
let { gradio: l } = e, { label: i = "Time" } = e, { show_label: s = !0 } = e, { info: _ = void 0 } = e, { elem_id: a = "" } = e, { elem_classes: f = [] } = e, { visible: o = !0 } = e, { value: d = ["", ""] } = e, g = d, { scale: w = null } = e, { min_width: C = void 0 } = e, { include_time: q = !0 } = e, { quick_ranges: k = [] } = e, m = [d];
|
2182 |
+
const r = () => {
|
2183 |
+
m.pop();
|
2184 |
+
const b = m.pop();
|
2185 |
+
b === void 0 ? (t(0, d = ["", ""]), t(12, m = [])) : (t(0, d = b), l.dispatch("change"), t(12, m = [...m]));
|
2186 |
+
}, v = (b) => {
|
2187 |
+
t(0, d = ["now - " + b, "now"]);
|
2188 |
+
};
|
2189 |
+
function y(b) {
|
2190 |
+
n.$$.not_equal(d[0], b) && (d[0] = b, t(0, d));
|
2191 |
+
}
|
2192 |
+
function j(b) {
|
2193 |
+
ze.call(this, n, b);
|
2194 |
+
}
|
2195 |
+
function S(b) {
|
2196 |
+
n.$$.not_equal(d[1], b) && (d[1] = b, t(0, d));
|
2197 |
+
}
|
2198 |
+
function u(b) {
|
2199 |
+
ze.call(this, n, b);
|
2200 |
+
}
|
2201 |
+
return n.$$set = (b) => {
|
2202 |
+
"gradio" in b && t(1, l = b.gradio), "label" in b && t(2, i = b.label), "show_label" in b && t(3, s = b.show_label), "info" in b && t(4, _ = b.info), "elem_id" in b && t(5, a = b.elem_id), "elem_classes" in b && t(6, f = b.elem_classes), "visible" in b && t(7, o = b.visible), "value" in b && t(0, d = b.value), "scale" in b && t(8, w = b.scale), "min_width" in b && t(9, C = b.min_width), "include_time" in b && t(10, q = b.include_time), "quick_ranges" in b && t(11, k = b.quick_ranges);
|
2203 |
+
}, n.$$.update = () => {
|
2204 |
+
n.$$.dirty & /*value, old_value, range_history*/
|
2205 |
+
20481 && (d[0] !== g[0] || d[1] !== g[1]) && (t(14, g = d), t(12, m = [...m, d]));
|
2206 |
+
}, [
|
2207 |
+
d,
|
2208 |
+
l,
|
2209 |
+
i,
|
2210 |
+
s,
|
2211 |
+
_,
|
2212 |
+
a,
|
2213 |
+
f,
|
2214 |
+
o,
|
2215 |
+
w,
|
2216 |
+
C,
|
2217 |
+
q,
|
2218 |
+
k,
|
2219 |
+
m,
|
2220 |
+
r,
|
2221 |
+
g,
|
2222 |
+
v,
|
2223 |
+
y,
|
2224 |
+
j,
|
2225 |
+
S,
|
2226 |
+
u
|
2227 |
+
];
|
2228 |
+
}
|
2229 |
+
class Ql extends Nl {
|
2230 |
+
constructor(e) {
|
2231 |
+
super(), zl(this, e, Ol, Ll, Fl, {
|
2232 |
+
gradio: 1,
|
2233 |
+
label: 2,
|
2234 |
+
show_label: 3,
|
2235 |
+
info: 4,
|
2236 |
+
elem_id: 5,
|
2237 |
+
elem_classes: 6,
|
2238 |
+
visible: 7,
|
2239 |
+
value: 0,
|
2240 |
+
scale: 8,
|
2241 |
+
min_width: 9,
|
2242 |
+
include_time: 10,
|
2243 |
+
quick_ranges: 11
|
2244 |
+
});
|
2245 |
+
}
|
2246 |
+
}
|
2247 |
+
export {
|
2248 |
+
Kl as BaseExample,
|
2249 |
+
Ql as default
|
2250 |
+
};
|
src/backend/gradio_datetimerange/templates/component/style.css
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.dropdown-arrow.svelte-145leq6{fill:currentColor}.source-selection.svelte-1jp3vgd{display:flex;align-items:center;justify-content:center;border-top:1px solid var(--border-color-primary);width:95%;bottom:0;left:0;right:0;margin-left:auto;margin-right:auto}.icon.svelte-1jp3vgd{width:22px;height:22px;margin:var(--spacing-lg) var(--spacing-xs);padding:var(--spacing-xs);color:var(--neutral-400);border-radius:var(--radius-md)}.selected.svelte-1jp3vgd{color:var(--color-accent)}.icon.svelte-1jp3vgd:hover,.icon.svelte-1jp3vgd:focus{color:var(--color-accent)}.block.svelte-nl1om8{position:relative;margin:0;box-shadow:var(--block-shadow);border-width:var(--block-border-width);border-color:var(--block-border-color);border-radius:var(--block-radius);background:var(--block-background-fill);width:100%;line-height:var(--line-sm)}.block.border_focus.svelte-nl1om8{border-color:var(--color-accent)}.block.border_contrast.svelte-nl1om8{border-color:var(--body-text-color)}.padded.svelte-nl1om8{padding:var(--block-padding)}.hidden.svelte-nl1om8{display:none}.hide-container.svelte-nl1om8{margin:0;box-shadow:none;--block-border-width:0;background:transparent;padding:0;overflow:visible}div.svelte-1hnfib2{margin-bottom:var(--spacing-lg);color:var(--block-info-text-color);font-weight:var(--block-info-text-weight);font-size:var(--block-info-text-size);line-height:var(--line-sm)}span.has-info.svelte-22c38v{margin-bottom:var(--spacing-xs)}span.svelte-22c38v:not(.has-info){margin-bottom:var(--spacing-lg)}span.svelte-22c38v{display:inline-block;position:relative;z-index:var(--layer-4);border:solid var(--block-title-border-width) var(--block-title-border-color);border-radius:var(--block-title-radius);background:var(--block-title-background-fill);padding:var(--block-title-padding);color:var(--block-title-text-color);font-weight:var(--block-title-text-weight);font-size:var(--block-title-text-size);line-height:var(--line-sm)}.hide.svelte-22c38v{margin:0;height:0}label.svelte-9gxdi0{display:inline-flex;align-items:center;z-index:var(--layer-2);box-shadow:var(--block-label-shadow);border:var(--block-label-border-width) solid var(--border-color-primary);border-top:none;border-left:none;border-radius:var(--block-label-radius);background:var(--block-label-background-fill);padding:var(--block-label-padding);pointer-events:none;color:var(--block-label-text-color);font-weight:var(--block-label-text-weight);font-size:var(--block-label-text-size);line-height:var(--line-sm)}.gr-group label.svelte-9gxdi0{border-top-left-radius:0}label.float.svelte-9gxdi0{position:absolute;top:var(--block-label-margin);left:var(--block-label-margin)}label.svelte-9gxdi0:not(.float){position:static;margin-top:var(--block-label-margin);margin-left:var(--block-label-margin)}.hide.svelte-9gxdi0{height:0}span.svelte-9gxdi0{opacity:.8;margin-right:var(--size-2);width:calc(var(--block-label-text-size) - 1px);height:calc(var(--block-label-text-size) - 1px)}.hide-label.svelte-9gxdi0{box-shadow:none;border-width:0;background:transparent;overflow:visible}button.svelte-1lrphxw{display:flex;justify-content:center;align-items:center;gap:1px;z-index:var(--layer-2);border-radius:var(--radius-sm);color:var(--block-label-text-color);border:1px solid transparent}button[disabled].svelte-1lrphxw{opacity:.5;box-shadow:none}button[disabled].svelte-1lrphxw:hover{cursor:not-allowed}.padded.svelte-1lrphxw{padding:2px;background:var(--bg-color);box-shadow:var(--shadow-drop);border:1px solid var(--button-secondary-border-color)}button.svelte-1lrphxw:hover,button.highlight.svelte-1lrphxw{cursor:pointer;color:var(--color-accent)}.padded.svelte-1lrphxw:hover{border:2px solid var(--button-secondary-border-color-hover);padding:1px;color:var(--block-label-text-color)}span.svelte-1lrphxw{padding:0 1px;font-size:10px}div.svelte-1lrphxw{padding:2px;display:flex;align-items:flex-end}.small.svelte-1lrphxw{width:14px;height:14px}.medium.svelte-1lrphxw{width:20px;height:20px}.large.svelte-1lrphxw{width:22px;height:22px}.pending.svelte-1lrphxw{animation:svelte-1lrphxw-flash .5s infinite}@keyframes svelte-1lrphxw-flash{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.transparent.svelte-1lrphxw{background:transparent;border:none;box-shadow:none}.empty.svelte-3w3rth{display:flex;justify-content:center;align-items:center;margin-top:calc(0px - var(--size-6));height:var(--size-full)}.icon.svelte-3w3rth{opacity:.5;height:var(--size-5);color:var(--body-text-color)}.small.svelte-3w3rth{min-height:calc(var(--size-32) - 20px)}.large.svelte-3w3rth{min-height:calc(var(--size-64) - 20px)}.unpadded_box.svelte-3w3rth{margin-top:0}.small_parent.svelte-3w3rth{min-height:100%!important}.wrap.svelte-kzcjhc{display:flex;flex-direction:column;justify-content:center;align-items:center;min-height:var(--size-60);color:var(--block-label-text-color);line-height:var(--line-md);height:100%;padding-top:var(--size-3)}.or.svelte-kzcjhc{color:var(--body-text-color-subdued);display:flex}.icon-wrap.svelte-kzcjhc{width:30px;margin-bottom:var(--spacing-lg)}@media (--screen-md){.wrap.svelte-kzcjhc{font-size:var(--text-lg)}}.hovered.svelte-kzcjhc{color:var(--color-accent)}div.svelte-q32hvf{border-top:1px solid transparent;display:flex;max-height:100%;justify-content:center;align-items:center;gap:var(--spacing-sm);height:auto;align-items:flex-end;color:var(--block-label-text-color);flex-shrink:0}.show_border.svelte-q32hvf{border-top:1px solid var(--block-border-color);margin-top:var(--spacing-xxl);box-shadow:var(--shadow-drop)}.source-selection.svelte-15ls1gu{display:flex;align-items:center;justify-content:center;border-top:1px solid var(--border-color-primary);width:100%;margin-left:auto;margin-right:auto;height:var(--size-10)}.icon.svelte-15ls1gu{width:22px;height:22px;margin:var(--spacing-lg) var(--spacing-xs);padding:var(--spacing-xs);color:var(--neutral-400);border-radius:var(--radius-md)}.selected.svelte-15ls1gu{color:var(--color-accent)}.icon.svelte-15ls1gu:hover,.icon.svelte-15ls1gu:focus{color:var(--color-accent)}.label-content.svelte-1rjvq1p{display:flex;justify-content:space-between;align-items:flex-start}button.svelte-1rjvq1p{cursor:pointer;color:var(--body-text-color-subdued)}button.svelte-1rjvq1p:hover{color:var(--body-text-color)}.svelte-1rjvq1p::placeholder{color:var(--input-placeholder-color)}.timebox.svelte-1rjvq1p{flex-grow:1;flex-shrink:1;display:flex;position:relative;background:var(--input-background-fill)}.timebox.svelte-1rjvq1p svg{height:18px}.time.svelte-1rjvq1p{padding:var(--input-padding);color:var(--body-text-color);font-weight:var(--input-text-weight);font-size:var(--input-text-size);line-height:var(--line-sm);outline:none;flex-grow:1;background:none;border:var(--input-border-width) solid var(--input-border-color);border-right:none;border-top-left-radius:var(--input-radius);border-bottom-left-radius:var(--input-radius);box-shadow:var(--input-shadow)}.time.invalid.svelte-1rjvq1p{color:var(--body-text-color-subdued)}.calendar.svelte-1rjvq1p{display:inline-flex;justify-content:center;align-items:center;transition:var(--button-transition);box-shadow:var(--button-shadow);text-align:center;background:var(--button-secondary-background-fill);color:var(--button-secondary-text-color);font-weight:var(--button-large-text-weight);font-size:var(--button-large-text-size);border-top-right-radius:var(--input-radius);border-bottom-right-radius:var(--input-radius);padding:var(--size-2);border:var(--input-border-width) solid var(--input-border-color)}.calendar.svelte-1rjvq1p:hover{background:var(--button-secondary-background-fill-hover)}.calendar.svelte-1rjvq1p:active{box-shadow:var(--button-shadow-active)}.datetime.svelte-1rjvq1p{width:0px;padding:0;border:0;margin:0;background:none}.times.svelte-ra6nvt{display:flex;gap:10px}.times.svelte-ra6nvt>.block{margin:0;padding:0}.label-content.svelte-ra6nvt{display:flex;justify-content:space-between;align-items:flex-start}.quick-ranges.svelte-ra6nvt{display:inline-flex;gap:var(--size-3)}button.svelte-ra6nvt{color:var(--body-text-color-subdued);cursor:pointer}button.svelte-ra6nvt:hover{color:var(--body-text-color)}
|
src/backend/gradio_datetimerange/templates/example/index.js
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const {
|
2 |
+
SvelteComponent: o,
|
3 |
+
detach: s,
|
4 |
+
init: u,
|
5 |
+
insert: r,
|
6 |
+
noop: l,
|
7 |
+
safe_not_equal: _,
|
8 |
+
set_data: c,
|
9 |
+
text: f
|
10 |
+
} = window.__gradio__svelte__internal;
|
11 |
+
function d(i) {
|
12 |
+
let e = (
|
13 |
+
/*value*/
|
14 |
+
(i[0] || "") + ""
|
15 |
+
), n;
|
16 |
+
return {
|
17 |
+
c() {
|
18 |
+
n = f(e);
|
19 |
+
},
|
20 |
+
m(t, a) {
|
21 |
+
r(t, n, a);
|
22 |
+
},
|
23 |
+
p(t, [a]) {
|
24 |
+
a & /*value*/
|
25 |
+
1 && e !== (e = /*value*/
|
26 |
+
(t[0] || "") + "") && c(n, e);
|
27 |
+
},
|
28 |
+
i: l,
|
29 |
+
o: l,
|
30 |
+
d(t) {
|
31 |
+
t && s(n);
|
32 |
+
}
|
33 |
+
};
|
34 |
+
}
|
35 |
+
function v(i, e, n) {
|
36 |
+
let { value: t } = e;
|
37 |
+
return i.$$set = (a) => {
|
38 |
+
"value" in a && n(0, t = a.value);
|
39 |
+
}, [t];
|
40 |
+
}
|
41 |
+
class m extends o {
|
42 |
+
constructor(e) {
|
43 |
+
super(), u(this, e, v, d, _, { value: 0 });
|
44 |
+
}
|
45 |
+
}
|
46 |
+
export {
|
47 |
+
m as default
|
48 |
+
};
|
src/demo/__init__.py
ADDED
File without changes
|
src/demo/app.py
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from gradio_datetimerange import DateTimeRange
|
4 |
+
import pandas as pd
|
5 |
+
from random import randint
|
6 |
+
|
7 |
+
temp_sensor_data = pd.DataFrame(
|
8 |
+
{
|
9 |
+
"time": pd.date_range("2021-01-01", end="2021-01-05", periods=200),
|
10 |
+
"temperature": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
11 |
+
"humidity": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
12 |
+
"location": ["indoor", "outdoor"] * 100,
|
13 |
+
}
|
14 |
+
)
|
15 |
+
|
16 |
+
with gr.Blocks() as demo:
|
17 |
+
date = DateTimeRange(["2021-01-01 00:00:00", "2021-01-07 00:00:00"])
|
18 |
+
merged_temp_plot = gr.LinePlot(
|
19 |
+
temp_sensor_data,
|
20 |
+
x="time",
|
21 |
+
y="temperature",
|
22 |
+
)
|
23 |
+
split_temp_plot = gr.LinePlot(
|
24 |
+
temp_sensor_data,
|
25 |
+
x="time",
|
26 |
+
y="temperature",
|
27 |
+
color="location",
|
28 |
+
)
|
29 |
+
with gr.Row():
|
30 |
+
humidity_bar_plot = gr.BarPlot(
|
31 |
+
temp_sensor_data,
|
32 |
+
x="time",
|
33 |
+
y="humidity",
|
34 |
+
color="location",
|
35 |
+
x_bin="1h",
|
36 |
+
)
|
37 |
+
humidity_scatter_plot = gr.ScatterPlot(
|
38 |
+
temp_sensor_data,
|
39 |
+
x="time",
|
40 |
+
y="humidity",
|
41 |
+
color="location",
|
42 |
+
)
|
43 |
+
|
44 |
+
date.bind([merged_temp_plot, split_temp_plot, humidity_bar_plot, humidity_scatter_plot])
|
45 |
+
|
46 |
+
|
47 |
+
if __name__ == "__main__":
|
48 |
+
demo.launch()
|
src/demo/css.css
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
html {
|
2 |
+
font-family: Inter;
|
3 |
+
font-size: 16px;
|
4 |
+
font-weight: 400;
|
5 |
+
line-height: 1.5;
|
6 |
+
-webkit-text-size-adjust: 100%;
|
7 |
+
background: #fff;
|
8 |
+
color: #323232;
|
9 |
+
-webkit-font-smoothing: antialiased;
|
10 |
+
-moz-osx-font-smoothing: grayscale;
|
11 |
+
text-rendering: optimizeLegibility;
|
12 |
+
}
|
13 |
+
|
14 |
+
:root {
|
15 |
+
--space: 1;
|
16 |
+
--vspace: calc(var(--space) * 1rem);
|
17 |
+
--vspace-0: calc(3 * var(--space) * 1rem);
|
18 |
+
--vspace-1: calc(2 * var(--space) * 1rem);
|
19 |
+
--vspace-2: calc(1.5 * var(--space) * 1rem);
|
20 |
+
--vspace-3: calc(0.5 * var(--space) * 1rem);
|
21 |
+
}
|
22 |
+
|
23 |
+
.app {
|
24 |
+
max-width: 748px !important;
|
25 |
+
}
|
26 |
+
|
27 |
+
.prose p {
|
28 |
+
margin: var(--vspace) 0;
|
29 |
+
line-height: var(--vspace * 2);
|
30 |
+
font-size: 1rem;
|
31 |
+
}
|
32 |
+
|
33 |
+
code {
|
34 |
+
font-family: "Inconsolata", sans-serif;
|
35 |
+
font-size: 16px;
|
36 |
+
}
|
37 |
+
|
38 |
+
h1,
|
39 |
+
h1 code {
|
40 |
+
font-weight: 400;
|
41 |
+
line-height: calc(2.5 / var(--space) * var(--vspace));
|
42 |
+
}
|
43 |
+
|
44 |
+
h1 code {
|
45 |
+
background: none;
|
46 |
+
border: none;
|
47 |
+
letter-spacing: 0.05em;
|
48 |
+
padding-bottom: 5px;
|
49 |
+
position: relative;
|
50 |
+
padding: 0;
|
51 |
+
}
|
52 |
+
|
53 |
+
h2 {
|
54 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
55 |
+
line-height: 1em;
|
56 |
+
}
|
57 |
+
|
58 |
+
h3,
|
59 |
+
h3 code {
|
60 |
+
margin: var(--vspace-1) 0 var(--vspace-2) 0;
|
61 |
+
line-height: 1em;
|
62 |
+
}
|
63 |
+
|
64 |
+
h4,
|
65 |
+
h5,
|
66 |
+
h6 {
|
67 |
+
margin: var(--vspace-3) 0 var(--vspace-3) 0;
|
68 |
+
line-height: var(--vspace);
|
69 |
+
}
|
70 |
+
|
71 |
+
.bigtitle,
|
72 |
+
h1,
|
73 |
+
h1 code {
|
74 |
+
font-size: calc(8px * 4.5);
|
75 |
+
word-break: break-word;
|
76 |
+
}
|
77 |
+
|
78 |
+
.title,
|
79 |
+
h2,
|
80 |
+
h2 code {
|
81 |
+
font-size: calc(8px * 3.375);
|
82 |
+
font-weight: lighter;
|
83 |
+
word-break: break-word;
|
84 |
+
border: none;
|
85 |
+
background: none;
|
86 |
+
}
|
87 |
+
|
88 |
+
.subheading1,
|
89 |
+
h3,
|
90 |
+
h3 code {
|
91 |
+
font-size: calc(8px * 1.8);
|
92 |
+
font-weight: 600;
|
93 |
+
border: none;
|
94 |
+
background: none;
|
95 |
+
letter-spacing: 0.1em;
|
96 |
+
text-transform: uppercase;
|
97 |
+
}
|
98 |
+
|
99 |
+
h2 code {
|
100 |
+
padding: 0;
|
101 |
+
position: relative;
|
102 |
+
letter-spacing: 0.05em;
|
103 |
+
}
|
104 |
+
|
105 |
+
blockquote {
|
106 |
+
font-size: calc(8px * 1.1667);
|
107 |
+
font-style: italic;
|
108 |
+
line-height: calc(1.1667 * var(--vspace));
|
109 |
+
margin: var(--vspace-2) var(--vspace-2);
|
110 |
+
}
|
111 |
+
|
112 |
+
.subheading2,
|
113 |
+
h4 {
|
114 |
+
font-size: calc(8px * 1.4292);
|
115 |
+
text-transform: uppercase;
|
116 |
+
font-weight: 600;
|
117 |
+
}
|
118 |
+
|
119 |
+
.subheading3,
|
120 |
+
h5 {
|
121 |
+
font-size: calc(8px * 1.2917);
|
122 |
+
line-height: calc(1.2917 * var(--vspace));
|
123 |
+
|
124 |
+
font-weight: lighter;
|
125 |
+
text-transform: uppercase;
|
126 |
+
letter-spacing: 0.15em;
|
127 |
+
}
|
128 |
+
|
129 |
+
h6 {
|
130 |
+
font-size: calc(8px * 1.1667);
|
131 |
+
font-size: 1.1667em;
|
132 |
+
font-weight: normal;
|
133 |
+
font-style: italic;
|
134 |
+
font-family: "le-monde-livre-classic-byol", serif !important;
|
135 |
+
letter-spacing: 0px !important;
|
136 |
+
}
|
137 |
+
|
138 |
+
#start .md > *:first-child {
|
139 |
+
margin-top: 0;
|
140 |
+
}
|
141 |
+
|
142 |
+
h2 + h3 {
|
143 |
+
margin-top: 0;
|
144 |
+
}
|
145 |
+
|
146 |
+
.md hr {
|
147 |
+
border: none;
|
148 |
+
border-top: 1px solid var(--block-border-color);
|
149 |
+
margin: var(--vspace-2) 0 var(--vspace-2) 0;
|
150 |
+
}
|
151 |
+
.prose ul {
|
152 |
+
margin: var(--vspace-2) 0 var(--vspace-1) 0;
|
153 |
+
}
|
154 |
+
|
155 |
+
.gap {
|
156 |
+
gap: 0;
|
157 |
+
}
|
src/demo/requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
gradio_datetimerange
|
src/demo/space.py
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import gradio as gr
|
3 |
+
from app import demo as app
|
4 |
+
import os
|
5 |
+
|
6 |
+
_docs = {'DateTimeRange': {'description': 'Component to select range of time.', 'members': {'__init__': {'value': {'type': 'tuple[float | str | datetime, float | str | datetime] | None', 'default': 'None', 'description': 'default value for datetime.'}, 'include_time': {'type': 'bool', 'default': 'True', 'description': 'If True, the component will include time selection. If False, only date selection will be available.'}, 'type': {'type': 'Literal["timestamp", "datetime", "string"]', 'default': '"timestamp"', 'description': 'The type of the value. Can be "timestamp", "datetime", or "string". If "timestamp", the value will be a number representing the start and end date in seconds since epoch. If "datetime", the value will be a datetime object. If "string", the value will be the date entered by the user.'}, 'timezone': {'type': 'str | None', 'default': 'None', 'description': 'The timezone to use for timestamps, such as "US/Pacific" or "Europe/Paris". If None, the timezone will be the local timezone.'}, 'quick_ranges': {'type': 'list[str] | None', 'default': 'None', 'description': 'List of strings representing quick ranges to display, such as ["30s", "1h", "24h", "7d"]. Set to [] to clear.'}, 'label': {'type': 'str | None', 'default': 'None', 'description': 'The label for this component. Appears above the component and is also used as the header if there are a table of examples for this component. If None and used in a `gr.Interface`, the label will be the name of the parameter this component is assigned to.'}, 'show_label': {'type': 'bool | None', 'default': 'None', 'description': 'if True, will display label.'}, 'info': {'type': 'str | None', 'default': 'None', 'description': 'additional component description.'}, 'every': {'type': 'float | None', 'default': 'None', 'description': "If `value` is a callable, run the function 'every' number of seconds while the client connection is open. Has no effect otherwise. The event can be accessed (e.g. to cancel it) via this component's .load_event attribute."}, 'scale': {'type': 'int | None', 'default': 'None', 'description': 'relative size compared to adjacent Components. For example if Components A and B are in a Row, and A has scale=2, and B has scale=1, A will be twice as wide as B. Should be an integer. scale applies in Rows, and to top-level Components in Blocks where fill_height=True.'}, 'min_width': {'type': 'int', 'default': '160', 'description': 'minimum pixel width, will wrap if not sufficient screen space to satisfy this value. If a certain scale value results in this Component being narrower than min_width, the min_width parameter will be respected first.'}, 'visible': {'type': 'bool', 'default': 'True', 'description': 'If False, component will be hidden.'}, 'elem_id': {'type': 'str | None', 'default': 'None', 'description': None}, 'elem_classes': {'type': 'list[str] | str | None', 'default': 'None', 'description': 'An optional list of strings that are assigned as the classes of this component in the HTML DOM. Can be used for targeting CSS styles.'}, 'render': {'type': 'bool', 'default': 'True', 'description': 'If False, component will not render be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.'}, 'key': {'type': 'int | str | None', 'default': 'None', 'description': 'if assigned, will be used to assume identity across a re-render. Components that have the same key across a re-render will have their value preserved.'}}, 'postprocess': {'value': {'type': 'tuple[float | datetime | str, float | datetime | str] | None', 'description': 'Expects a tuple pair of datetimes.'}}, 'preprocess': {'return': {'type': 'tuple[str | float | datetime, str | float | datetime] | None', 'description': 'Passes text value as a {str} into the function.'}, 'value': None}}, 'events': {'change': {'type': None, 'default': None, 'description': 'Triggered when the value of the DateTimeRange changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See `.input()` for a listener that is only triggered by user input.'}}}, '__meta__': {'additional_interfaces': {}, 'user_fn_refs': {'DateTimeRange': []}}}
|
7 |
+
|
8 |
+
abs_path = os.path.join(os.path.dirname(__file__), "css.css")
|
9 |
+
|
10 |
+
with gr.Blocks(
|
11 |
+
css=abs_path,
|
12 |
+
theme=gr.themes.Default(
|
13 |
+
font_mono=[
|
14 |
+
gr.themes.GoogleFont("Inconsolata"),
|
15 |
+
"monospace",
|
16 |
+
],
|
17 |
+
),
|
18 |
+
) as demo:
|
19 |
+
gr.Markdown(
|
20 |
+
"""
|
21 |
+
# `gradio_datetimerange`
|
22 |
+
|
23 |
+
<div style="display: flex; gap: 7px;">
|
24 |
+
<a href="https://pypi.org/project/gradio_datetimerange/" target="_blank"><img alt="PyPI - Version" src="https://img.shields.io/pypi/v/gradio_datetimerange"></a>
|
25 |
+
</div>
|
26 |
+
|
27 |
+
Component to create time ranges.
|
28 |
+
""", elem_classes=["md-custom"], header_links=True)
|
29 |
+
app.render()
|
30 |
+
gr.Markdown(
|
31 |
+
"""
|
32 |
+
## Installation
|
33 |
+
|
34 |
+
```bash
|
35 |
+
pip install gradio_datetimerange
|
36 |
+
```
|
37 |
+
|
38 |
+
## Usage
|
39 |
+
|
40 |
+
```python
|
41 |
+
|
42 |
+
import gradio as gr
|
43 |
+
from gradio_datetimerange import DateTimeRange
|
44 |
+
import pandas as pd
|
45 |
+
from random import randint
|
46 |
+
|
47 |
+
temp_sensor_data = pd.DataFrame(
|
48 |
+
{
|
49 |
+
"time": pd.date_range("2021-01-01", end="2021-01-05", periods=200),
|
50 |
+
"temperature": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
51 |
+
"humidity": [randint(50 + 10 * (i % 2), 65 + 15 * (i % 2)) for i in range(200)],
|
52 |
+
"location": ["indoor", "outdoor"] * 100,
|
53 |
+
}
|
54 |
+
)
|
55 |
+
|
56 |
+
with gr.Blocks() as demo:
|
57 |
+
date = DateTimeRange(["2021-01-01 00:00:00", "2021-01-07 00:00:00"])
|
58 |
+
merged_temp_plot = gr.LinePlot(
|
59 |
+
temp_sensor_data,
|
60 |
+
x="time",
|
61 |
+
y="temperature",
|
62 |
+
)
|
63 |
+
split_temp_plot = gr.LinePlot(
|
64 |
+
temp_sensor_data,
|
65 |
+
x="time",
|
66 |
+
y="temperature",
|
67 |
+
color="location",
|
68 |
+
)
|
69 |
+
with gr.Row():
|
70 |
+
humidity_bar_plot = gr.BarPlot(
|
71 |
+
temp_sensor_data,
|
72 |
+
x="time",
|
73 |
+
y="humidity",
|
74 |
+
color="location",
|
75 |
+
x_bin="1h",
|
76 |
+
)
|
77 |
+
humidity_scatter_plot = gr.ScatterPlot(
|
78 |
+
temp_sensor_data,
|
79 |
+
x="time",
|
80 |
+
y="humidity",
|
81 |
+
color="location",
|
82 |
+
)
|
83 |
+
|
84 |
+
date.bind([merged_temp_plot, split_temp_plot, humidity_bar_plot, humidity_scatter_plot])
|
85 |
+
|
86 |
+
|
87 |
+
if __name__ == "__main__":
|
88 |
+
demo.launch()
|
89 |
+
|
90 |
+
```
|
91 |
+
""", elem_classes=["md-custom"], header_links=True)
|
92 |
+
|
93 |
+
|
94 |
+
gr.Markdown("""
|
95 |
+
## `DateTimeRange`
|
96 |
+
|
97 |
+
### Initialization
|
98 |
+
""", elem_classes=["md-custom"], header_links=True)
|
99 |
+
|
100 |
+
gr.ParamViewer(value=_docs["DateTimeRange"]["members"]["__init__"], linkify=[])
|
101 |
+
|
102 |
+
|
103 |
+
gr.Markdown("### Events")
|
104 |
+
gr.ParamViewer(value=_docs["DateTimeRange"]["events"], linkify=['Event'])
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
|
109 |
+
gr.Markdown("""
|
110 |
+
|
111 |
+
### User function
|
112 |
+
|
113 |
+
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
|
114 |
+
|
115 |
+
- When used as an Input, the component only impacts the input signature of the user function.
|
116 |
+
- When used as an output, the component only impacts the return signature of the user function.
|
117 |
+
|
118 |
+
The code snippet below is accurate in cases where the component is used as both an input and an output.
|
119 |
+
|
120 |
+
- **As input:** Is passed, passes text value as a {str} into the function.
|
121 |
+
- **As output:** Should return, expects a tuple pair of datetimes.
|
122 |
+
|
123 |
+
```python
|
124 |
+
def predict(
|
125 |
+
value: tuple[str | float | datetime, str | float | datetime] | None
|
126 |
+
) -> tuple[float | datetime | str, float | datetime | str] | None:
|
127 |
+
return value
|
128 |
+
```
|
129 |
+
""", elem_classes=["md-custom", "DateTimeRange-user-fn"], header_links=True)
|
130 |
+
|
131 |
+
|
132 |
+
|
133 |
+
|
134 |
+
demo.load(None, js=r"""function() {
|
135 |
+
const refs = {};
|
136 |
+
const user_fn_refs = {
|
137 |
+
DateTimeRange: [], };
|
138 |
+
requestAnimationFrame(() => {
|
139 |
+
|
140 |
+
Object.entries(user_fn_refs).forEach(([key, refs]) => {
|
141 |
+
if (refs.length > 0) {
|
142 |
+
const el = document.querySelector(`.${key}-user-fn`);
|
143 |
+
if (!el) return;
|
144 |
+
refs.forEach(ref => {
|
145 |
+
el.innerHTML = el.innerHTML.replace(
|
146 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
147 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
148 |
+
);
|
149 |
+
})
|
150 |
+
}
|
151 |
+
})
|
152 |
+
|
153 |
+
Object.entries(refs).forEach(([key, refs]) => {
|
154 |
+
if (refs.length > 0) {
|
155 |
+
const el = document.querySelector(`.${key}`);
|
156 |
+
if (!el) return;
|
157 |
+
refs.forEach(ref => {
|
158 |
+
el.innerHTML = el.innerHTML.replace(
|
159 |
+
new RegExp("\\b"+ref+"\\b", "g"),
|
160 |
+
`<a href="#h-${ref.toLowerCase()}">${ref}</a>`
|
161 |
+
);
|
162 |
+
})
|
163 |
+
}
|
164 |
+
})
|
165 |
+
})
|
166 |
+
}
|
167 |
+
|
168 |
+
""")
|
169 |
+
|
170 |
+
demo.launch()
|
src/frontend/Example.svelte
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script lang="ts">
|
2 |
+
export let value: string | null;
|
3 |
+
</script>
|
4 |
+
|
5 |
+
{value || ""}
|
src/frontend/Index.svelte
ADDED
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<script context="module" lang="ts">
|
2 |
+
export { default as BaseExample } from "./Example.svelte";
|
3 |
+
</script>
|
4 |
+
|
5 |
+
<script lang="ts">
|
6 |
+
import type { Gradio } from "@gradio/utils";
|
7 |
+
import { Block, BlockTitle } from "@gradio/atoms";
|
8 |
+
import DateTime from "@gradio/datetime";
|
9 |
+
|
10 |
+
export let gradio: Gradio<{
|
11 |
+
change: undefined;
|
12 |
+
}>;
|
13 |
+
export let label = "Time";
|
14 |
+
export let show_label = true;
|
15 |
+
export let info: string | undefined = undefined;
|
16 |
+
export let elem_id = "";
|
17 |
+
export let elem_classes: string[] = [];
|
18 |
+
export let visible = true;
|
19 |
+
export let value: [string, string] = ["", ""];
|
20 |
+
let old_value = value;
|
21 |
+
export let scale: number | null = null;
|
22 |
+
export let min_width: number | undefined = undefined;
|
23 |
+
export let include_time = true;
|
24 |
+
export let quick_ranges: string[] = [];
|
25 |
+
let range_history: [string, string][] = [value];
|
26 |
+
|
27 |
+
$: if (value[0] !== old_value[0] || value[1] !== old_value[1]) {
|
28 |
+
old_value = value;
|
29 |
+
range_history = [...range_history, value];
|
30 |
+
}
|
31 |
+
|
32 |
+
const back_in_history = (): void => {
|
33 |
+
range_history.pop();
|
34 |
+
const last_range = range_history.pop();
|
35 |
+
if (last_range === undefined) {
|
36 |
+
value = ["", ""];
|
37 |
+
range_history = [];
|
38 |
+
} else {
|
39 |
+
value = last_range;
|
40 |
+
gradio.dispatch("change");
|
41 |
+
range_history = [...range_history];
|
42 |
+
}
|
43 |
+
};
|
44 |
+
</script>
|
45 |
+
|
46 |
+
<Block
|
47 |
+
{visible}
|
48 |
+
{elem_id}
|
49 |
+
{elem_classes}
|
50 |
+
{scale}
|
51 |
+
{min_width}
|
52 |
+
allow_overflow={false}
|
53 |
+
padding={true}
|
54 |
+
>
|
55 |
+
<div class="label-content">
|
56 |
+
<BlockTitle {show_label} {info}>{label}</BlockTitle>
|
57 |
+
{#if show_label}
|
58 |
+
<div class="quick-ranges">
|
59 |
+
<button
|
60 |
+
class="quick-range"
|
61 |
+
style:display={range_history.length <= 1 ? "none" : "block"}
|
62 |
+
on:click={back_in_history}>Back</button
|
63 |
+
>
|
64 |
+
|
65 |
+
{#each quick_ranges as quick_range}
|
66 |
+
<button
|
67 |
+
class="quick-range"
|
68 |
+
on:click={() => {
|
69 |
+
value = ["now - " + quick_range, "now"];
|
70 |
+
}}>Last {quick_range}</button
|
71 |
+
>
|
72 |
+
{/each}
|
73 |
+
</div>
|
74 |
+
{/if} </div>
|
75 |
+
<div class="times">
|
76 |
+
<DateTime show_label={false} bind:value={value[0]} {include_time} {gradio} on:gradio></DateTime>
|
77 |
+
<DateTime show_label={false} bind:value={value[1]} {include_time} {gradio} on:gradio></DateTime>
|
78 |
+
</div>
|
79 |
+
</Block>
|
80 |
+
|
81 |
+
<style>
|
82 |
+
.times {
|
83 |
+
display: flex;
|
84 |
+
gap: 10px;
|
85 |
+
}
|
86 |
+
.times > :global(.block) {
|
87 |
+
margin: 0;
|
88 |
+
padding: 0;
|
89 |
+
}
|
90 |
+
.label-content {
|
91 |
+
display: flex;
|
92 |
+
justify-content: space-between;
|
93 |
+
align-items: flex-start;
|
94 |
+
}
|
95 |
+
.quick-ranges {
|
96 |
+
display: inline-flex;
|
97 |
+
gap: var(--size-3);
|
98 |
+
}
|
99 |
+
button {
|
100 |
+
color: var(--body-text-color-subdued);
|
101 |
+
cursor: pointer;
|
102 |
+
}
|
103 |
+
button:hover {
|
104 |
+
color: var(--body-text-color);
|
105 |
+
}
|
106 |
+
</style>
|
src/frontend/gradio.config.js
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export default {
|
2 |
+
plugins: [],
|
3 |
+
svelte: {
|
4 |
+
preprocess: [],
|
5 |
+
},
|
6 |
+
build: {
|
7 |
+
target: "modules",
|
8 |
+
},
|
9 |
+
};
|
src/frontend/package-lock.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
src/frontend/package.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "gradio_datetimerange",
|
3 |
+
"version": "0.0.2",
|
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 |
+
".": "./Index.svelte",
|
13 |
+
"./example": "./Example.svelte",
|
14 |
+
"./package.json": "./package.json"
|
15 |
+
},
|
16 |
+
"dependencies": {
|
17 |
+
"@gradio/atoms": "0.7.6",
|
18 |
+
"@gradio/icons": "0.6.0",
|
19 |
+
"@gradio/statustracker": "0.7.1",
|
20 |
+
"@gradio/datetime": "0.1.0",
|
21 |
+
"@gradio/utils": "0.5.1"
|
22 |
+
},
|
23 |
+
"devDependencies": {
|
24 |
+
"@gradio/preview": "0.10.1"
|
25 |
+
}
|
26 |
+
}
|
src/package-lock.json
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "datetimerange",
|
3 |
+
"lockfileVersion": 3,
|
4 |
+
"requires": true,
|
5 |
+
"packages": {}
|
6 |
+
}
|
src/pyproject.toml
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[build-system]
|
2 |
+
requires = [
|
3 |
+
"hatchling",
|
4 |
+
"hatch-requirements-txt",
|
5 |
+
"hatch-fancy-pypi-readme>=22.5.0",
|
6 |
+
]
|
7 |
+
build-backend = "hatchling.build"
|
8 |
+
|
9 |
+
[project]
|
10 |
+
name = "gradio_datetimerange"
|
11 |
+
version = "0.0.1"
|
12 |
+
description = "Component to create time ranges."
|
13 |
+
readme = "README.md"
|
14 |
+
license = "apache-2.0"
|
15 |
+
requires-python = ">=3.8"
|
16 |
+
authors = [{ name = "YOUR NAME", email = "[email protected]" }]
|
17 |
+
keywords = ["gradio-custom-component", "gradio-template-DateTime"]
|
18 |
+
# Add dependencies here
|
19 |
+
dependencies = ["gradio>=4.0,<5.0"]
|
20 |
+
classifiers = [
|
21 |
+
'Development Status :: 3 - Alpha',
|
22 |
+
'Operating System :: OS Independent',
|
23 |
+
'Programming Language :: Python :: 3',
|
24 |
+
'Programming Language :: Python :: 3 :: Only',
|
25 |
+
'Programming Language :: Python :: 3.8',
|
26 |
+
'Programming Language :: Python :: 3.9',
|
27 |
+
'Programming Language :: Python :: 3.10',
|
28 |
+
'Programming Language :: Python :: 3.11',
|
29 |
+
'Topic :: Scientific/Engineering',
|
30 |
+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
|
31 |
+
'Topic :: Scientific/Engineering :: Visualization',
|
32 |
+
]
|
33 |
+
|
34 |
+
# The repository and space URLs are optional, but recommended.
|
35 |
+
# Adding a repository URL will create a badge in the auto-generated README that links to the repository.
|
36 |
+
# Adding a space URL will create a badge in the auto-generated README that links to the space.
|
37 |
+
# This will make it easy for people to find your deployed demo or source code when they
|
38 |
+
# encounter your project in the wild.
|
39 |
+
|
40 |
+
# [project.urls]
|
41 |
+
# repository = "your github repository"
|
42 |
+
# space = "your space url"
|
43 |
+
|
44 |
+
[project.optional-dependencies]
|
45 |
+
dev = ["build", "twine"]
|
46 |
+
|
47 |
+
[tool.hatch.build]
|
48 |
+
artifacts = ["/backend/gradio_datetimerange/templates", "*.pyi"]
|
49 |
+
|
50 |
+
[tool.hatch.build.targets.wheel]
|
51 |
+
packages = ["/backend/gradio_datetimerange"]
|