@gradio/tabitem 0.9.0 → 0.10.1
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 +14 -0
- package/Index.svelte +7 -1
- package/TabItem.test.ts +21 -0
- package/TabItemHarness.svelte +2 -0
- package/dist/Index.svelte +7 -1
- package/dist/TabItemHarness.svelte +2 -0
- package/dist/shared/TabItem.svelte +10 -0
- package/dist/shared/TabItem.svelte.d.ts +2 -0
- package/dist/types.d.ts +2 -0
- package/package.json +3 -3
- package/shared/TabItem.svelte +10 -0
- package/types.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @gradio/tabitem
|
|
2
2
|
|
|
3
|
+
## 0.10.1
|
|
4
|
+
|
|
5
|
+
### Dependency updates
|
|
6
|
+
|
|
7
|
+
- @gradio/utils@0.15.0
|
|
8
|
+
- @gradio/tabs@0.11.2
|
|
9
|
+
- @gradio/column@0.4.1
|
|
10
|
+
|
|
11
|
+
## 0.10.0
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
- [`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!
|
|
16
|
+
|
|
3
17
|
## 0.9.0
|
|
4
18
|
|
|
5
19
|
### Features
|
package/Index.svelte
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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
|
|
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
order={gradio.props.order}
|
|
23
23
|
alignment={gradio.props.alignment}
|
|
24
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}
|
|
25
31
|
component_id={gradio.props.component_id}
|
|
26
32
|
onselect={(data) => gradio.dispatch("select", data)}
|
|
27
33
|
>
|
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"
|
package/TabItemHarness.svelte
CHANGED
package/dist/Index.svelte
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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
|
|
|
@@ -22,6 +22,12 @@
|
|
|
22
22
|
order={gradio.props.order}
|
|
23
23
|
alignment={gradio.props.alignment}
|
|
24
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}
|
|
25
31
|
component_id={gradio.props.component_id}
|
|
26
32
|
onselect={(data) => gradio.dispatch("select", data)}
|
|
27
33
|
>
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
order,
|
|
15
15
|
alignment = "left",
|
|
16
16
|
scale,
|
|
17
|
+
height,
|
|
18
|
+
max_height,
|
|
17
19
|
component_id,
|
|
18
20
|
onselect,
|
|
19
21
|
children
|
|
@@ -27,6 +29,8 @@
|
|
|
27
29
|
order: number;
|
|
28
30
|
alignment?: "left" | "right";
|
|
29
31
|
scale: number;
|
|
32
|
+
height?: string;
|
|
33
|
+
max_height?: string;
|
|
30
34
|
component_id: number;
|
|
31
35
|
onselect?: (data: SelectData) => void;
|
|
32
36
|
children?: Snippet;
|
|
@@ -80,8 +84,11 @@
|
|
|
80
84
|
id={elem_id}
|
|
81
85
|
class="tabitem {elem_classes.join(' ')}"
|
|
82
86
|
class:grow-children={scale >= 1}
|
|
87
|
+
class:scrollable={height || max_height}
|
|
83
88
|
style:display={$selected_tab === tab_id && is_visible ? "flex" : "none"}
|
|
84
89
|
style:flex-grow={scale}
|
|
90
|
+
style:height
|
|
91
|
+
style:max-height={max_height}
|
|
85
92
|
role="tabpanel"
|
|
86
93
|
>
|
|
87
94
|
<BaseColumn scale={scale >= 1 ? scale : null}>
|
|
@@ -99,6 +106,9 @@
|
|
|
99
106
|
width: 100%;
|
|
100
107
|
box-sizing: border-box;
|
|
101
108
|
}
|
|
109
|
+
.scrollable {
|
|
110
|
+
overflow-y: auto;
|
|
111
|
+
}
|
|
102
112
|
.grow-children > :global(.column > .column) {
|
|
103
113
|
flex-grow: 1;
|
|
104
114
|
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/tabitem",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"./package.json": "./package.json"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@gradio/tabs": "^0.11.2",
|
|
19
20
|
"@gradio/column": "^0.4.1",
|
|
20
|
-
"@gradio/
|
|
21
|
-
"@gradio/utils": "^0.14.2"
|
|
21
|
+
"@gradio/utils": "^0.15.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@gradio/preview": "^0.17.1"
|
package/shared/TabItem.svelte
CHANGED
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
order,
|
|
15
15
|
alignment = "left",
|
|
16
16
|
scale,
|
|
17
|
+
height,
|
|
18
|
+
max_height,
|
|
17
19
|
component_id,
|
|
18
20
|
onselect,
|
|
19
21
|
children
|
|
@@ -27,6 +29,8 @@
|
|
|
27
29
|
order: number;
|
|
28
30
|
alignment?: "left" | "right";
|
|
29
31
|
scale: number;
|
|
32
|
+
height?: string;
|
|
33
|
+
max_height?: string;
|
|
30
34
|
component_id: number;
|
|
31
35
|
onselect?: (data: SelectData) => void;
|
|
32
36
|
children?: Snippet;
|
|
@@ -80,8 +84,11 @@
|
|
|
80
84
|
id={elem_id}
|
|
81
85
|
class="tabitem {elem_classes.join(' ')}"
|
|
82
86
|
class:grow-children={scale >= 1}
|
|
87
|
+
class:scrollable={height || max_height}
|
|
83
88
|
style:display={$selected_tab === tab_id && is_visible ? "flex" : "none"}
|
|
84
89
|
style:flex-grow={scale}
|
|
90
|
+
style:height
|
|
91
|
+
style:max-height={max_height}
|
|
85
92
|
role="tabpanel"
|
|
86
93
|
>
|
|
87
94
|
<BaseColumn scale={scale >= 1 ? scale : null}>
|
|
@@ -99,6 +106,9 @@
|
|
|
99
106
|
width: 100%;
|
|
100
107
|
box-sizing: border-box;
|
|
101
108
|
}
|
|
109
|
+
.scrollable {
|
|
110
|
+
overflow-y: auto;
|
|
111
|
+
}
|
|
102
112
|
.grow-children > :global(.column > .column) {
|
|
103
113
|
flex-grow: 1;
|
|
104
114
|
}
|