@gradio/tabitem 0.8.3 → 0.10.0
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 +23 -0
- package/Index.svelte +10 -3
- package/TabItem.test.ts +35 -0
- package/TabItemHarness.svelte +3 -0
- package/dist/Index.svelte +10 -3
- package/dist/Index.svelte.d.ts +2 -19
- package/dist/TabItemHarness.svelte +3 -0
- package/dist/shared/TabItem.svelte +18 -3
- package/dist/shared/TabItem.svelte.d.ts +7 -26
- package/dist/types.d.ts +3 -0
- package/package.json +4 -4
- package/shared/TabItem.svelte +18 -3
- package/types.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @gradio/tabitem
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [`3111c06`](https://github.com/gradio-app/gradio/commit/3111c069d59ccd4ed5b4d2118baa8ada62569bfd) - Add height/max_height to gr.Accordion and gr.Tab, fix gr.Code max_lines. Thanks @dawoodkhan82!
|
|
8
|
+
|
|
9
|
+
## 0.9.0
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
- [#13851](https://github.com/gradio-app/gradio/pull/13851) [`afffecc`](https://github.com/gradio-app/gradio/commit/afffeccf69262a8070a091b50206c1e33b8c06c4) - Add configurable tab overflow and alignment. Thanks @abidlabs!
|
|
14
|
+
|
|
15
|
+
### Dependency updates
|
|
16
|
+
|
|
17
|
+
- @gradio/utils@0.14.2
|
|
18
|
+
- @gradio/tabs@0.11.0
|
|
19
|
+
|
|
20
|
+
## 0.8.3
|
|
21
|
+
|
|
22
|
+
### Dependency updates
|
|
23
|
+
|
|
24
|
+
- @gradio/utils@0.14.1
|
|
25
|
+
|
|
3
26
|
## 0.8.3
|
|
4
27
|
|
|
5
28
|
### Fixes
|
package/Index.svelte
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
export { default as BaseTabItem } from "./shared/TabItem.svelte";
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
-
import { Gradio } from "@gradio/utils";
|
|
6
|
+
import { Gradio, css_units } from "@gradio/utils";
|
|
7
7
|
import TabItem from "./shared/TabItem.svelte";
|
|
8
8
|
import type { TabItemProps, TabItemEvents } from "./types";
|
|
9
9
|
|
|
@@ -20,9 +20,16 @@
|
|
|
20
20
|
interactive={gradio.shared.interactive}
|
|
21
21
|
id={gradio.props.id}
|
|
22
22
|
order={gradio.props.order}
|
|
23
|
+
alignment={gradio.props.alignment}
|
|
23
24
|
scale={gradio.shared.scale}
|
|
25
|
+
height={gradio.props.height != null
|
|
26
|
+
? css_units(gradio.props.height)
|
|
27
|
+
: undefined}
|
|
28
|
+
max_height={gradio.props.max_height != null
|
|
29
|
+
? css_units(gradio.props.max_height)
|
|
30
|
+
: undefined}
|
|
24
31
|
component_id={gradio.props.component_id}
|
|
25
32
|
onselect={(data) => gradio.dispatch("select", data)}
|
|
26
33
|
>
|
|
27
|
-
|
|
34
|
+
{@render props.children?.()}
|
|
28
35
|
</TabItem>
|
package/TabItem.test.ts
CHANGED
|
@@ -15,6 +15,27 @@ describe("TabItem", () => {
|
|
|
15
15
|
expect(getByTestId("tab-content")).toHaveTextContent("tab panel content");
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
+
test("max_height caps the panel height and makes it scrollable", async () => {
|
|
19
|
+
const { getByRole } = await render(TabItemHarness, {
|
|
20
|
+
tab_selected: "t1",
|
|
21
|
+
tab_max_height: "100px"
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const panel = getByRole("tabpanel", { hidden: true });
|
|
25
|
+
expect(panel.style.maxHeight).toBe("100px");
|
|
26
|
+
expect(getComputedStyle(panel).overflowY).toBe("auto");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("panel is not scrollable when no height is set", async () => {
|
|
30
|
+
const { getByRole } = await render(TabItemHarness, {
|
|
31
|
+
tab_selected: "t1"
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const panel = getByRole("tabpanel", { hidden: true });
|
|
35
|
+
expect(panel.style.maxHeight).toBe("");
|
|
36
|
+
expect(getComputedStyle(panel).overflowY).toBe("visible");
|
|
37
|
+
});
|
|
38
|
+
|
|
18
39
|
test("content is visible when this tab is the selected tab", async () => {
|
|
19
40
|
const { getByTestId } = await render(TabItemHarness, {
|
|
20
41
|
tab_selected: "t1"
|
|
@@ -87,6 +108,20 @@ describe("TabItem", () => {
|
|
|
87
108
|
);
|
|
88
109
|
});
|
|
89
110
|
});
|
|
111
|
+
|
|
112
|
+
test("registers its alignment with the parent tabs", async () => {
|
|
113
|
+
const on_register = vi.fn();
|
|
114
|
+
await render(TabItemHarness, {
|
|
115
|
+
tab_alignment: "right",
|
|
116
|
+
on_register
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await waitFor(() => {
|
|
120
|
+
expect(on_register).toHaveBeenCalledWith(
|
|
121
|
+
expect.objectContaining({ alignment: "right" })
|
|
122
|
+
);
|
|
123
|
+
});
|
|
124
|
+
});
|
|
90
125
|
});
|
|
91
126
|
|
|
92
127
|
describe("Events: select", () => {
|
package/TabItemHarness.svelte
CHANGED
|
@@ -29,7 +29,10 @@
|
|
|
29
29
|
order={0}
|
|
30
30
|
visible={cfg.tab_visible ?? true}
|
|
31
31
|
interactive={true}
|
|
32
|
+
alignment={cfg.tab_alignment ?? "left"}
|
|
32
33
|
scale={0}
|
|
34
|
+
height={cfg.tab_height}
|
|
35
|
+
max_height={cfg.tab_max_height}
|
|
33
36
|
component_id={1}
|
|
34
37
|
onselect={(data) => cfg.on_tab_select?.(data)}
|
|
35
38
|
>
|
package/dist/Index.svelte
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script module lang="ts">
|
|
2
2
|
export { default as BaseTabItem } from "./shared/TabItem.svelte";
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
<script lang="ts">
|
|
6
|
-
import { Gradio } from "@gradio/utils";
|
|
6
|
+
import { Gradio, css_units } from "@gradio/utils";
|
|
7
7
|
import TabItem from "./shared/TabItem.svelte";
|
|
8
8
|
import type { TabItemProps, TabItemEvents } from "./types";
|
|
9
9
|
|
|
@@ -20,9 +20,16 @@
|
|
|
20
20
|
interactive={gradio.shared.interactive}
|
|
21
21
|
id={gradio.props.id}
|
|
22
22
|
order={gradio.props.order}
|
|
23
|
+
alignment={gradio.props.alignment}
|
|
23
24
|
scale={gradio.shared.scale}
|
|
25
|
+
height={gradio.props.height != null
|
|
26
|
+
? css_units(gradio.props.height)
|
|
27
|
+
: undefined}
|
|
28
|
+
max_height={gradio.props.max_height != null
|
|
29
|
+
? css_units(gradio.props.max_height)
|
|
30
|
+
: undefined}
|
|
24
31
|
component_id={gradio.props.component_id}
|
|
25
32
|
onselect={(data) => gradio.dispatch("select", data)}
|
|
26
33
|
>
|
|
27
|
-
|
|
34
|
+
{@render props.children?.()}
|
|
28
35
|
</TabItem>
|
package/dist/Index.svelte.d.ts
CHANGED
|
@@ -1,21 +1,4 @@
|
|
|
1
1
|
export { default as BaseTabItem } from "./shared/TabItem.svelte";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports & {
|
|
10
|
-
$set?: any;
|
|
11
|
-
$on?: any;
|
|
12
|
-
};
|
|
13
|
-
z_$$bindings?: Bindings;
|
|
14
|
-
}
|
|
15
|
-
declare const Index: $$__sveltets_2_IsomorphicComponent<any, {
|
|
16
|
-
[evt: string]: CustomEvent<any>;
|
|
17
|
-
}, {
|
|
18
|
-
default: {};
|
|
19
|
-
}, {}, "">;
|
|
20
|
-
type Index = InstanceType<typeof Index>;
|
|
2
|
+
declare const Index: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
3
|
+
type Index = ReturnType<typeof Index>;
|
|
21
4
|
export default Index;
|
|
@@ -29,7 +29,10 @@
|
|
|
29
29
|
order={0}
|
|
30
30
|
visible={cfg.tab_visible ?? true}
|
|
31
31
|
interactive={true}
|
|
32
|
+
alignment={cfg.tab_alignment ?? "left"}
|
|
32
33
|
scale={0}
|
|
34
|
+
height={cfg.tab_height}
|
|
35
|
+
max_height={cfg.tab_max_height}
|
|
33
36
|
component_id={1}
|
|
34
37
|
onselect={(data) => cfg.on_tab_select?.(data)}
|
|
35
38
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { getContext, tick, untrack } from "svelte";
|
|
2
|
+
import { getContext, tick, untrack, type Snippet } from "svelte";
|
|
3
3
|
import { TABS } from "@gradio/tabs";
|
|
4
4
|
import { BaseColumn } from "@gradio/column";
|
|
5
5
|
import type { SelectData } from "@gradio/utils";
|
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
visible,
|
|
13
13
|
interactive,
|
|
14
14
|
order,
|
|
15
|
+
alignment = "left",
|
|
15
16
|
scale,
|
|
17
|
+
height,
|
|
18
|
+
max_height,
|
|
16
19
|
component_id,
|
|
17
|
-
onselect
|
|
20
|
+
onselect,
|
|
21
|
+
children
|
|
18
22
|
}: {
|
|
19
23
|
elem_id?: string;
|
|
20
24
|
elem_classes?: string[];
|
|
@@ -23,9 +27,13 @@
|
|
|
23
27
|
visible: boolean | "hidden";
|
|
24
28
|
interactive: boolean;
|
|
25
29
|
order: number;
|
|
30
|
+
alignment?: "left" | "right";
|
|
26
31
|
scale: number;
|
|
32
|
+
height?: string;
|
|
33
|
+
max_height?: string;
|
|
27
34
|
component_id: number;
|
|
28
35
|
onselect?: (data: SelectData) => void;
|
|
36
|
+
children?: Snippet;
|
|
29
37
|
} = $props();
|
|
30
38
|
|
|
31
39
|
const { register_tab, unregister_tab, selected_tab, selected_tab_index } =
|
|
@@ -47,6 +55,7 @@
|
|
|
47
55
|
elem_id,
|
|
48
56
|
visible,
|
|
49
57
|
interactive,
|
|
58
|
+
alignment,
|
|
50
59
|
scale,
|
|
51
60
|
component_id
|
|
52
61
|
})
|
|
@@ -75,12 +84,15 @@
|
|
|
75
84
|
id={elem_id}
|
|
76
85
|
class="tabitem {elem_classes.join(' ')}"
|
|
77
86
|
class:grow-children={scale >= 1}
|
|
87
|
+
class:scrollable={height || max_height}
|
|
78
88
|
style:display={$selected_tab === tab_id && is_visible ? "flex" : "none"}
|
|
79
89
|
style:flex-grow={scale}
|
|
90
|
+
style:height
|
|
91
|
+
style:max-height={max_height}
|
|
80
92
|
role="tabpanel"
|
|
81
93
|
>
|
|
82
94
|
<BaseColumn scale={scale >= 1 ? scale : null}>
|
|
83
|
-
|
|
95
|
+
{@render children?.()}
|
|
84
96
|
</BaseColumn>
|
|
85
97
|
</div>
|
|
86
98
|
|
|
@@ -94,6 +106,9 @@
|
|
|
94
106
|
width: 100%;
|
|
95
107
|
box-sizing: border-box;
|
|
96
108
|
}
|
|
109
|
+
.scrollable {
|
|
110
|
+
overflow-y: auto;
|
|
111
|
+
}
|
|
97
112
|
.grow-children > :global(.column > .column) {
|
|
98
113
|
flex-grow: 1;
|
|
99
114
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Snippet } from "svelte";
|
|
1
2
|
import type { SelectData } from "@gradio/utils";
|
|
2
3
|
type $$ComponentProps = {
|
|
3
4
|
elem_id?: string;
|
|
@@ -7,34 +8,14 @@ type $$ComponentProps = {
|
|
|
7
8
|
visible: boolean | "hidden";
|
|
8
9
|
interactive: boolean;
|
|
9
10
|
order: number;
|
|
11
|
+
alignment?: "left" | "right";
|
|
10
12
|
scale: number;
|
|
13
|
+
height?: string;
|
|
14
|
+
max_height?: string;
|
|
11
15
|
component_id: number;
|
|
12
16
|
onselect?: (data: SelectData) => void;
|
|
17
|
+
children?: Snippet;
|
|
13
18
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
$$bindings?: Bindings;
|
|
17
|
-
} & Exports;
|
|
18
|
-
(internal: unknown, props: Props & {
|
|
19
|
-
$$events?: Events;
|
|
20
|
-
$$slots?: Slots;
|
|
21
|
-
}): Exports & {
|
|
22
|
-
$set?: any;
|
|
23
|
-
$on?: any;
|
|
24
|
-
};
|
|
25
|
-
z_$$bindings?: Bindings;
|
|
26
|
-
}
|
|
27
|
-
type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
|
|
28
|
-
default: any;
|
|
29
|
-
} ? Props extends Record<string, never> ? any : {
|
|
30
|
-
children?: any;
|
|
31
|
-
} : {});
|
|
32
|
-
declare const TabItem: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<$$ComponentProps, {
|
|
33
|
-
default: {};
|
|
34
|
-
}>, {
|
|
35
|
-
[evt: string]: CustomEvent<any>;
|
|
36
|
-
}, {
|
|
37
|
-
default: {};
|
|
38
|
-
}, {}, "">;
|
|
39
|
-
type TabItem = InstanceType<typeof TabItem>;
|
|
19
|
+
declare const TabItem: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
20
|
+
type TabItem = ReturnType<typeof TabItem>;
|
|
40
21
|
export default TabItem;
|
package/dist/types.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export interface TabItemProps {
|
|
|
7
7
|
visible: boolean | "hidden";
|
|
8
8
|
interactive: boolean;
|
|
9
9
|
order: number;
|
|
10
|
+
alignment?: "left" | "right";
|
|
11
|
+
height?: number | string | null;
|
|
12
|
+
max_height?: number | string | null;
|
|
10
13
|
component_id: number;
|
|
11
14
|
}
|
|
12
15
|
export interface TabItemEvents {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/tabitem",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"./package.json": "./package.json"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@gradio/tabs": "^0.11.0",
|
|
19
20
|
"@gradio/column": "^0.4.1",
|
|
20
|
-
"@gradio/
|
|
21
|
-
"@gradio/utils": "^0.14.0"
|
|
21
|
+
"@gradio/utils": "^0.14.2"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@gradio/preview": "^0.17.
|
|
24
|
+
"@gradio/preview": "^0.17.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"svelte": "^5.48.0"
|
package/shared/TabItem.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { getContext, tick, untrack } from "svelte";
|
|
2
|
+
import { getContext, tick, untrack, type Snippet } from "svelte";
|
|
3
3
|
import { TABS } from "@gradio/tabs";
|
|
4
4
|
import { BaseColumn } from "@gradio/column";
|
|
5
5
|
import type { SelectData } from "@gradio/utils";
|
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
visible,
|
|
13
13
|
interactive,
|
|
14
14
|
order,
|
|
15
|
+
alignment = "left",
|
|
15
16
|
scale,
|
|
17
|
+
height,
|
|
18
|
+
max_height,
|
|
16
19
|
component_id,
|
|
17
|
-
onselect
|
|
20
|
+
onselect,
|
|
21
|
+
children
|
|
18
22
|
}: {
|
|
19
23
|
elem_id?: string;
|
|
20
24
|
elem_classes?: string[];
|
|
@@ -23,9 +27,13 @@
|
|
|
23
27
|
visible: boolean | "hidden";
|
|
24
28
|
interactive: boolean;
|
|
25
29
|
order: number;
|
|
30
|
+
alignment?: "left" | "right";
|
|
26
31
|
scale: number;
|
|
32
|
+
height?: string;
|
|
33
|
+
max_height?: string;
|
|
27
34
|
component_id: number;
|
|
28
35
|
onselect?: (data: SelectData) => void;
|
|
36
|
+
children?: Snippet;
|
|
29
37
|
} = $props();
|
|
30
38
|
|
|
31
39
|
const { register_tab, unregister_tab, selected_tab, selected_tab_index } =
|
|
@@ -47,6 +55,7 @@
|
|
|
47
55
|
elem_id,
|
|
48
56
|
visible,
|
|
49
57
|
interactive,
|
|
58
|
+
alignment,
|
|
50
59
|
scale,
|
|
51
60
|
component_id
|
|
52
61
|
})
|
|
@@ -75,12 +84,15 @@
|
|
|
75
84
|
id={elem_id}
|
|
76
85
|
class="tabitem {elem_classes.join(' ')}"
|
|
77
86
|
class:grow-children={scale >= 1}
|
|
87
|
+
class:scrollable={height || max_height}
|
|
78
88
|
style:display={$selected_tab === tab_id && is_visible ? "flex" : "none"}
|
|
79
89
|
style:flex-grow={scale}
|
|
90
|
+
style:height
|
|
91
|
+
style:max-height={max_height}
|
|
80
92
|
role="tabpanel"
|
|
81
93
|
>
|
|
82
94
|
<BaseColumn scale={scale >= 1 ? scale : null}>
|
|
83
|
-
|
|
95
|
+
{@render children?.()}
|
|
84
96
|
</BaseColumn>
|
|
85
97
|
</div>
|
|
86
98
|
|
|
@@ -94,6 +106,9 @@
|
|
|
94
106
|
width: 100%;
|
|
95
107
|
box-sizing: border-box;
|
|
96
108
|
}
|
|
109
|
+
.scrollable {
|
|
110
|
+
overflow-y: auto;
|
|
111
|
+
}
|
|
97
112
|
.grow-children > :global(.column > .column) {
|
|
98
113
|
flex-grow: 1;
|
|
99
114
|
}
|
package/types.ts
CHANGED