@gradio/tabs 0.5.10 → 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/Index.svelte +9 -7
- package/dist/Index.svelte +9 -7
- package/dist/shared/Tabs.svelte +10 -6
- package/package.json +1 -1
- package/shared/Tabs.svelte +10 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @gradio/tabs
|
|
2
2
|
|
|
3
|
+
## 0.5.11
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- [#13240](https://github.com/gradio-app/gradio/pull/13240) [`0d670ad`](https://github.com/gradio-app/gradio/commit/0d670adf41a0b510f7fd745495dce1664d38f0e5) - Fix browser freeze when a dataframe's value is set (e.g. via a tab select event), and only dispatch the tabs select event when the selected tab actually changes. Thanks @freddyaboulton!
|
|
8
|
+
|
|
3
9
|
## 0.5.10
|
|
4
10
|
|
|
5
11
|
### Fixes
|
package/Index.svelte
CHANGED
|
@@ -7,24 +7,26 @@
|
|
|
7
7
|
import Tabs from "./shared/Tabs.svelte";
|
|
8
8
|
import Walkthrough from "./shared/Walkthrough.svelte";
|
|
9
9
|
import type { TabsProps, TabsEvents } from "./types";
|
|
10
|
-
import { untrack } from "svelte";
|
|
11
10
|
|
|
12
11
|
let props = $props();
|
|
13
12
|
const gradio = new Gradio<TabsEvents, TabsProps>(props);
|
|
14
13
|
|
|
14
|
+
let old_selected = gradio.props.selected;
|
|
15
|
+
|
|
15
16
|
$effect(() => {
|
|
16
|
-
if (gradio.props.selected) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
if (old_selected !== gradio.props.selected) {
|
|
18
|
+
const i = gradio.props.initial_tabs.findIndex(
|
|
19
|
+
(t) => t.id === gradio.props.selected
|
|
20
|
+
);
|
|
21
|
+
if (i >= 0) {
|
|
21
22
|
gradio.dispatch("gradio_tab_select", {
|
|
22
23
|
value: gradio.props.initial_tabs[i].label,
|
|
23
24
|
index: i,
|
|
24
25
|
id: gradio.props.initial_tabs[i].id,
|
|
25
26
|
component_id: gradio.props.initial_tabs[i].component_id
|
|
26
27
|
});
|
|
27
|
-
}
|
|
28
|
+
}
|
|
29
|
+
old_selected = gradio.props.selected;
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
32
|
</script>
|
package/dist/Index.svelte
CHANGED
|
@@ -7,24 +7,26 @@
|
|
|
7
7
|
import Tabs from "./shared/Tabs.svelte";
|
|
8
8
|
import Walkthrough from "./shared/Walkthrough.svelte";
|
|
9
9
|
import type { TabsProps, TabsEvents } from "./types";
|
|
10
|
-
import { untrack } from "svelte";
|
|
11
10
|
|
|
12
11
|
let props = $props();
|
|
13
12
|
const gradio = new Gradio<TabsEvents, TabsProps>(props);
|
|
14
13
|
|
|
14
|
+
let old_selected = gradio.props.selected;
|
|
15
|
+
|
|
15
16
|
$effect(() => {
|
|
16
|
-
if (gradio.props.selected) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
if (old_selected !== gradio.props.selected) {
|
|
18
|
+
const i = gradio.props.initial_tabs.findIndex(
|
|
19
|
+
(t) => t.id === gradio.props.selected
|
|
20
|
+
);
|
|
21
|
+
if (i >= 0) {
|
|
21
22
|
gradio.dispatch("gradio_tab_select", {
|
|
22
23
|
value: gradio.props.initial_tabs[i].label,
|
|
23
24
|
index: i,
|
|
24
25
|
id: gradio.props.initial_tabs[i].id,
|
|
25
26
|
component_id: gradio.props.initial_tabs[i].component_id
|
|
26
27
|
});
|
|
27
|
-
}
|
|
28
|
+
}
|
|
29
|
+
old_selected = gradio.props.selected;
|
|
28
30
|
}
|
|
29
31
|
});
|
|
30
32
|
</script>
|
package/dist/shared/Tabs.svelte
CHANGED
|
@@ -37,16 +37,20 @@
|
|
|
37
37
|
|
|
38
38
|
// When initial_tabs changes (e.g. a non-mounted tab's props were updated),
|
|
39
39
|
// sync the internal tabs array so the tab buttons reflect the new state.
|
|
40
|
-
//
|
|
41
|
-
//
|
|
40
|
+
// The tabs mutation is deferred via tick() because in Svelte 5 legacy mode
|
|
41
|
+
// $: effects track all reads inside called functions — writing tabs[i]
|
|
42
|
+
// through the $state proxy would track `tabs` as a dependency, creating
|
|
43
|
+
// an infinite self-triggering loop.
|
|
42
44
|
$: _sync_tabs(initial_tabs);
|
|
43
45
|
|
|
44
46
|
function _sync_tabs(new_tabs: Tab[]): void {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
tick().then(() => {
|
|
48
|
+
for (let i = 0; i < new_tabs.length; i++) {
|
|
49
|
+
if (new_tabs[i] && !mounted_tab_orders.has(i)) {
|
|
50
|
+
tabs[i] = new_tabs[i];
|
|
51
|
+
}
|
|
48
52
|
}
|
|
49
|
-
}
|
|
53
|
+
});
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
$: has_tabs = tabs.length > 0;
|
package/package.json
CHANGED
package/shared/Tabs.svelte
CHANGED
|
@@ -37,16 +37,20 @@
|
|
|
37
37
|
|
|
38
38
|
// When initial_tabs changes (e.g. a non-mounted tab's props were updated),
|
|
39
39
|
// sync the internal tabs array so the tab buttons reflect the new state.
|
|
40
|
-
//
|
|
41
|
-
//
|
|
40
|
+
// The tabs mutation is deferred via tick() because in Svelte 5 legacy mode
|
|
41
|
+
// $: effects track all reads inside called functions — writing tabs[i]
|
|
42
|
+
// through the $state proxy would track `tabs` as a dependency, creating
|
|
43
|
+
// an infinite self-triggering loop.
|
|
42
44
|
$: _sync_tabs(initial_tabs);
|
|
43
45
|
|
|
44
46
|
function _sync_tabs(new_tabs: Tab[]): void {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
tick().then(() => {
|
|
48
|
+
for (let i = 0; i < new_tabs.length; i++) {
|
|
49
|
+
if (new_tabs[i] && !mounted_tab_orders.has(i)) {
|
|
50
|
+
tabs[i] = new_tabs[i];
|
|
51
|
+
}
|
|
48
52
|
}
|
|
49
|
-
}
|
|
53
|
+
});
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
$: has_tabs = tabs.length > 0;
|