gradio-pr-bot commited on
Commit
fc6e040
·
verified ·
1 Parent(s): ffd8d78

Upload folder using huggingface_hub

Browse files
6.5.0/statustracker/static/Loader.svelte CHANGED
@@ -1,13 +1,16 @@
1
  <script lang="ts">
2
- import { onMount } from "svelte";
3
  import { spring } from "svelte/motion";
4
 
5
- export let margin = true;
 
 
 
 
6
 
7
  const top = spring([0, 0]);
8
  const bottom = spring([0, 0]);
9
 
10
- let dismounted: boolean;
11
 
12
  async function animate(): Promise<void> {
13
  await Promise.all([top.set([125, 140]), bottom.set([-125, -140])]);
@@ -27,9 +30,11 @@
27
  run();
28
  }
29
 
30
- onMount(() => {
31
  loading();
32
- return (): boolean => (dismounted = true);
 
 
33
  });
34
  </script>
35
 
 
1
  <script lang="ts">
 
2
  import { spring } from "svelte/motion";
3
 
4
+ interface Props {
5
+ margin?: boolean;
6
+ }
7
+
8
+ let { margin = true }: Props = $props();
9
 
10
  const top = spring([0, 0]);
11
  const bottom = spring([0, 0]);
12
 
13
+ let dismounted = $state(false);
14
 
15
  async function animate(): Promise<void> {
16
  await Promise.all([top.set([125, 140]), bottom.set([-125, -140])]);
 
30
  run();
31
  }
32
 
33
+ $effect(() => {
34
  loading();
35
+ return () => {
36
+ dismounted = true;
37
+ };
38
  });
39
  </script>
40
 
6.5.0/statustracker/static/StreamingBar.svelte CHANGED
@@ -1,5 +1,9 @@
1
  <script lang="ts">
2
- export let time_limit: number | null;
 
 
 
 
3
  </script>
4
 
5
  {#if time_limit}
 
1
  <script lang="ts">
2
+ interface Props {
3
+ time_limit: number | null;
4
+ }
5
+
6
+ let { time_limit }: Props = $props();
7
  </script>
8
 
9
  {#if time_limit}
6.5.0/statustracker/static/Toast.svelte CHANGED
@@ -3,14 +3,23 @@
3
  import ToastContent from "./ToastContent.svelte";
4
  import { spring } from "svelte/motion";
5
 
6
- export let messages: ToastMessage[] = [];
7
- export let on_close: (id: number) => void;
 
 
 
 
8
  const top = spring(0, { stiffness: 0.4, damping: 0.5 });
9
 
10
- let grouped_messages: GroupedToastMessage[] = [];
 
 
 
 
11
 
12
- $: scroll_to_top(messages);
13
- $: grouped_messages = group_messages(messages);
 
14
 
15
  function group_messages(msgs: ToastMessage[]): GroupedToastMessage[] {
16
  const groups = new Map<string, GroupedToastMessage>();
@@ -61,8 +70,8 @@
61
  type={group.type}
62
  messages={group.messages}
63
  expanded={group.expanded}
64
- on:toggle={() => toggle_group(group.type)}
65
- on:close={(e) => on_close(e.detail)}
66
  />
67
  </div>
68
  {/each}
 
3
  import ToastContent from "./ToastContent.svelte";
4
  import { spring } from "svelte/motion";
5
 
6
+ interface Props {
7
+ messages?: ToastMessage[];
8
+ on_close: (id: number) => void;
9
+ }
10
+
11
+ let { messages = [], on_close }: Props = $props();
12
  const top = spring(0, { stiffness: 0.4, damping: 0.5 });
13
 
14
+ let grouped_messages: GroupedToastMessage[] = $state([]);
15
+
16
+ $effect(() => {
17
+ scroll_to_top(messages);
18
+ });
19
 
20
+ $effect(() => {
21
+ grouped_messages = group_messages(messages);
22
+ });
23
 
24
  function group_messages(msgs: ToastMessage[]): GroupedToastMessage[] {
25
  const groups = new Map<string, GroupedToastMessage>();
 
70
  type={group.type}
71
  messages={group.messages}
72
  expanded={group.expanded}
73
+ ontoggle={() => toggle_group(group.type)}
74
+ onclose={(id) => on_close(id)}
75
  />
76
  </div>
77
  {/each}
6.5.0/statustracker/static/ToastContent.svelte CHANGED
@@ -1,35 +1,46 @@
1
  <script lang="ts">
2
  import { Error, Info, Warning, Success, ChevronDown } from "@gradio/icons";
3
  import { sanitize } from "@gradio/sanitize";
4
- import { createEventDispatcher, onMount } from "svelte";
5
  import { fade, slide } from "svelte/transition";
6
  import type { ToastMessage } from "./types";
7
 
8
- export let type: ToastMessage["type"];
9
- export let messages: ToastMessage[] = [];
10
- export let expanded = true;
11
-
12
- const dispatch = createEventDispatcher();
13
-
14
- let touch_start_x = 0;
15
- let touch_start_y = 0;
16
- let offset_x = 0;
17
- let is_dragging = false;
 
 
 
 
 
 
 
 
 
 
18
  let toast_element: HTMLElement;
19
 
20
- $: count = messages.length;
21
- $: first_message = messages[0];
22
- $: type_label = type.charAt(0).toUpperCase() + type.slice(1);
23
- $: has_duration = first_message?.duration !== null;
24
- $: timer_duration = has_duration ? `${first_message.duration}s` : "0s";
 
 
25
 
26
  function handle_toggle(): void {
27
- dispatch("toggle");
28
  }
29
 
30
  function close_all(): void {
31
  messages.forEach((msg) => {
32
- dispatch("close", msg.id);
33
  });
34
  }
35
 
@@ -65,7 +76,7 @@
65
  is_dragging = false;
66
  }
67
 
68
- onMount(() => {
69
  if (has_duration && messages.length === 1) {
70
  setTimeout(close_all, first_message.duration! * 1000);
71
  }
@@ -78,9 +89,9 @@
78
  role="status"
79
  aria-live="polite"
80
  data-testid="toast-body"
81
- on:touchstart={handle_touch_start}
82
- on:touchmove={handle_touch_move}
83
- on:touchend={handle_touch_end}
84
  in:fade={{ duration: 200, delay: 100 }}
85
  out:fade={{ duration: 200 }}
86
  style="transform: translateX({offset_x}px); opacity: {1 -
@@ -88,10 +99,10 @@
88
  >
89
  <div
90
  class="toast-header"
91
- on:click={handle_toggle}
92
  role="button"
93
  tabindex="0"
94
- on:keydown={(e) => {
95
  if (e.key === "Enter" || e.key === " ") {
96
  handle_toggle();
97
  }
@@ -122,7 +133,10 @@
122
  </div>
123
 
124
  <button
125
- on:click|stopPropagation={close_all}
 
 
 
126
  class="toast-close {type}"
127
  type="button"
128
  aria-label="Close"
 
1
  <script lang="ts">
2
  import { Error, Info, Warning, Success, ChevronDown } from "@gradio/icons";
3
  import { sanitize } from "@gradio/sanitize";
 
4
  import { fade, slide } from "svelte/transition";
5
  import type { ToastMessage } from "./types";
6
 
7
+ interface Props {
8
+ type: ToastMessage["type"];
9
+ messages?: ToastMessage[];
10
+ expanded?: boolean;
11
+ ontoggle?: () => void;
12
+ onclose?: (id: number) => void;
13
+ }
14
+
15
+ let {
16
+ type,
17
+ messages = [],
18
+ expanded = true,
19
+ ontoggle,
20
+ onclose
21
+ }: Props = $props();
22
+
23
+ let touch_start_x = $state(0);
24
+ let touch_start_y = $state(0);
25
+ let offset_x = $state(0);
26
+ let is_dragging = $state(false);
27
  let toast_element: HTMLElement;
28
 
29
+ let count = $derived(messages.length);
30
+ let first_message = $derived(messages[0]);
31
+ let type_label = $derived(type.charAt(0).toUpperCase() + type.slice(1));
32
+ let has_duration = $derived(first_message?.duration !== null);
33
+ let timer_duration = $derived(
34
+ has_duration ? `${first_message.duration}s` : "0s"
35
+ );
36
 
37
  function handle_toggle(): void {
38
+ ontoggle?.();
39
  }
40
 
41
  function close_all(): void {
42
  messages.forEach((msg) => {
43
+ onclose?.(msg.id);
44
  });
45
  }
46
 
 
76
  is_dragging = false;
77
  }
78
 
79
+ $effect(() => {
80
  if (has_duration && messages.length === 1) {
81
  setTimeout(close_all, first_message.duration! * 1000);
82
  }
 
89
  role="status"
90
  aria-live="polite"
91
  data-testid="toast-body"
92
+ ontouchstart={handle_touch_start}
93
+ ontouchmove={handle_touch_move}
94
+ ontouchend={handle_touch_end}
95
  in:fade={{ duration: 200, delay: 100 }}
96
  out:fade={{ duration: 200 }}
97
  style="transform: translateX({offset_x}px); opacity: {1 -
 
99
  >
100
  <div
101
  class="toast-header"
102
+ onclick={handle_toggle}
103
  role="button"
104
  tabindex="0"
105
+ onkeydown={(e) => {
106
  if (e.key === "Enter" || e.key === " ") {
107
  handle_toggle();
108
  }
 
133
  </div>
134
 
135
  <button
136
+ onclick={(e) => {
137
+ e.stopPropagation();
138
+ close_all();
139
+ }}
140
  class="toast-close {type}"
141
  type="button"
142
  aria-label="Close"