@gradio/dataframe 0.11.0-beta.7 → 0.11.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 +36 -0
- package/Dataframe.stories.svelte +30 -1
- package/dist/shared/Arrow.svelte +9 -0
- package/dist/shared/Arrow.svelte.d.ts +16 -0
- package/dist/shared/CellMenu.svelte +101 -0
- package/dist/shared/CellMenu.svelte.d.ts +24 -0
- package/dist/shared/Table.svelte +245 -112
- package/package.json +9 -9
- package/shared/Arrow.svelte +10 -0
- package/shared/CellMenu.svelte +111 -0
- package/shared/Table.svelte +290 -121
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @gradio/dataframe
|
|
2
2
|
|
|
3
|
+
## 0.11.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - UI theme fixes
|
|
8
|
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Tweak gr.Dataframe menu UX
|
|
9
|
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Update gr.Dataframe UI with action popover
|
|
10
|
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Fix. Triggered dataframe change event for header change
|
|
11
|
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Standardize `height` across components and add `max_height` and `min_height` parameters where appropriate
|
|
12
|
+
- [#8843](https://github.com/gradio-app/gradio/pull/8843) [`6f95286`](https://github.com/gradio-app/gradio/commit/6f95286337459efbccb95c9cfac63355669df9ee) - Ssr part 2
|
|
13
|
+
|
|
14
|
+
### Dependencies
|
|
15
|
+
|
|
16
|
+
- @gradio/atoms@0.9.0
|
|
17
|
+
- @gradio/button@0.3.0
|
|
18
|
+
- @gradio/client@1.6.0
|
|
19
|
+
- @gradio/markdown@0.10.0
|
|
20
|
+
- @gradio/statustracker@0.8.0
|
|
21
|
+
- @gradio/upload@0.13.0
|
|
22
|
+
- @gradio/utils@0.7.0
|
|
23
|
+
|
|
24
|
+
## 0.11.0-beta.8
|
|
25
|
+
|
|
26
|
+
### Features
|
|
27
|
+
|
|
28
|
+
- [#9601](https://github.com/gradio-app/gradio/pull/9601) [`c078892`](https://github.com/gradio-app/gradio/commit/c07889223cb64661b17560b707b977248809470a) - Tweak gr.Dataframe menu UX. Thanks @hannahblair!
|
|
29
|
+
- [#9575](https://github.com/gradio-app/gradio/pull/9575) [`4ec2feb`](https://github.com/gradio-app/gradio/commit/4ec2feb04e452d2c77482c09543c59948567be67) - Update gr.Dataframe UI with action popover. Thanks @hannahblair!
|
|
30
|
+
|
|
31
|
+
### Dependency updates
|
|
32
|
+
|
|
33
|
+
- @gradio/upload@0.13.0-beta.7
|
|
34
|
+
- @gradio/statustracker@0.8.0-beta.5
|
|
35
|
+
- @gradio/atoms@0.9.0-beta.5
|
|
36
|
+
- @gradio/button@0.3.0-beta.7
|
|
37
|
+
- @gradio/markdown@0.10.0-beta.5
|
|
38
|
+
|
|
3
39
|
## 0.11.0-beta.7
|
|
4
40
|
|
|
5
41
|
### Dependency updates
|
package/Dataframe.stories.svelte
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
|
|
3
3
|
import Table from "./shared/Table.svelte";
|
|
4
|
+
import { within } from "@testing-library/dom";
|
|
5
|
+
import { userEvent } from "@storybook/test";
|
|
6
|
+
import { get } from "svelte/store";
|
|
7
|
+
import { format } from "svelte-i18n";
|
|
4
8
|
</script>
|
|
5
9
|
|
|
6
10
|
<Meta
|
|
@@ -17,7 +21,7 @@
|
|
|
17
21
|
/>
|
|
18
22
|
|
|
19
23
|
<Template let:args>
|
|
20
|
-
<Table {...args} i18n={(
|
|
24
|
+
<Table {...args} i18n={get(format)} />
|
|
21
25
|
</Template>
|
|
22
26
|
|
|
23
27
|
<Story
|
|
@@ -161,3 +165,28 @@
|
|
|
161
165
|
editable: false
|
|
162
166
|
}}
|
|
163
167
|
/>
|
|
168
|
+
|
|
169
|
+
<Story
|
|
170
|
+
name="Dataframe with dialog interactions"
|
|
171
|
+
args={{
|
|
172
|
+
values: [
|
|
173
|
+
[800, 100, 400],
|
|
174
|
+
[200, 800, 700]
|
|
175
|
+
],
|
|
176
|
+
col_count: [3, "dynamic"],
|
|
177
|
+
row_count: [2, "dynamic"],
|
|
178
|
+
headers: ["Math", "Reading", "Writing"],
|
|
179
|
+
editable: true
|
|
180
|
+
}}
|
|
181
|
+
play={async ({ canvasElement }) => {
|
|
182
|
+
const canvas = within(canvasElement);
|
|
183
|
+
|
|
184
|
+
const cell = canvas.getByText("200");
|
|
185
|
+
userEvent.click(cell);
|
|
186
|
+
const open_dialog_btn = canvas.getAllByText("⋮");
|
|
187
|
+
await userEvent.click(open_dialog_btn[0]);
|
|
188
|
+
|
|
189
|
+
const add_row_btn = canvas.getByText("Add row above");
|
|
190
|
+
await userEvent.click(add_row_btn);
|
|
191
|
+
}}
|
|
192
|
+
/>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
transform: string;
|
|
5
|
+
};
|
|
6
|
+
events: {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
};
|
|
9
|
+
slots: {};
|
|
10
|
+
};
|
|
11
|
+
export type ArrowProps = typeof __propDef.props;
|
|
12
|
+
export type ArrowEvents = typeof __propDef.events;
|
|
13
|
+
export type ArrowSlots = typeof __propDef.slots;
|
|
14
|
+
export default class Arrow extends SvelteComponent<ArrowProps, ArrowEvents, ArrowSlots> {
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<script>import { onMount } from "svelte";
|
|
2
|
+
import Arrow from "./Arrow.svelte";
|
|
3
|
+
export let x;
|
|
4
|
+
export let y;
|
|
5
|
+
export let on_add_row_above;
|
|
6
|
+
export let on_add_row_below;
|
|
7
|
+
export let on_add_column_left;
|
|
8
|
+
export let on_add_column_right;
|
|
9
|
+
export let row;
|
|
10
|
+
export let i18n;
|
|
11
|
+
let menu_element;
|
|
12
|
+
$:
|
|
13
|
+
is_header = row === -1;
|
|
14
|
+
onMount(() => {
|
|
15
|
+
position_menu();
|
|
16
|
+
});
|
|
17
|
+
function position_menu() {
|
|
18
|
+
if (!menu_element)
|
|
19
|
+
return;
|
|
20
|
+
const viewport_width = window.innerWidth;
|
|
21
|
+
const viewport_height = window.innerHeight;
|
|
22
|
+
const menu_rect = menu_element.getBoundingClientRect();
|
|
23
|
+
let new_x = x - 30;
|
|
24
|
+
let new_y = y - 20;
|
|
25
|
+
if (new_x + menu_rect.width > viewport_width) {
|
|
26
|
+
new_x = x - menu_rect.width + 10;
|
|
27
|
+
}
|
|
28
|
+
if (new_y + menu_rect.height > viewport_height) {
|
|
29
|
+
new_y = y - menu_rect.height + 10;
|
|
30
|
+
}
|
|
31
|
+
menu_element.style.left = `${new_x}px`;
|
|
32
|
+
menu_element.style.top = `${new_y}px`;
|
|
33
|
+
}
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<div bind:this={menu_element} class="cell-menu">
|
|
37
|
+
{#if !is_header}
|
|
38
|
+
<button on:click={() => on_add_row_above()}>
|
|
39
|
+
<Arrow transform="rotate(-90 12 12)" />
|
|
40
|
+
{i18n("dataframe.add_row_above")}
|
|
41
|
+
</button>
|
|
42
|
+
<button on:click={() => on_add_row_below()}>
|
|
43
|
+
<Arrow transform="rotate(90 12 12)" />
|
|
44
|
+
{i18n("dataframe.add_row_below")}
|
|
45
|
+
</button>
|
|
46
|
+
{/if}
|
|
47
|
+
<button on:click={() => on_add_column_left()}>
|
|
48
|
+
<Arrow transform="rotate(180 12 12)" />
|
|
49
|
+
{i18n("dataframe.add_column_left")}
|
|
50
|
+
</button>
|
|
51
|
+
<button on:click={() => on_add_column_right()}>
|
|
52
|
+
<Arrow transform="rotate(0 12 12)" />
|
|
53
|
+
{i18n("dataframe.add_column_right")}
|
|
54
|
+
</button>
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
<style>
|
|
58
|
+
.cell-menu {
|
|
59
|
+
position: fixed;
|
|
60
|
+
z-index: var(--layer-2);
|
|
61
|
+
background: var(--background-fill-primary);
|
|
62
|
+
border: 1px solid var(--border-color-primary);
|
|
63
|
+
border-radius: var(--radius-sm);
|
|
64
|
+
padding: var(--size-1);
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
gap: var(--size-1);
|
|
68
|
+
box-shadow: var(--shadow-drop-lg);
|
|
69
|
+
min-width: 150px;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.cell-menu button {
|
|
73
|
+
background: none;
|
|
74
|
+
border: none;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
text-align: left;
|
|
77
|
+
padding: var(--size-1) var(--size-2);
|
|
78
|
+
border-radius: var(--radius-sm);
|
|
79
|
+
color: var(--body-text-color);
|
|
80
|
+
font-size: var(--text-sm);
|
|
81
|
+
transition:
|
|
82
|
+
background-color 0.2s,
|
|
83
|
+
color 0.2s;
|
|
84
|
+
display: flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
gap: var(--size-2);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.cell-menu button:hover {
|
|
90
|
+
background-color: var(--background-fill-secondary);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.cell-menu button :global(svg) {
|
|
94
|
+
fill: currentColor;
|
|
95
|
+
transition: fill 0.2s;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.cell-menu button:hover :global(svg) {
|
|
99
|
+
fill: var(--color-accent);
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { I18nFormatter } from "js/utils/src";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
on_add_row_above: () => void;
|
|
8
|
+
on_add_row_below: () => void;
|
|
9
|
+
on_add_column_left: () => void;
|
|
10
|
+
on_add_column_right: () => void;
|
|
11
|
+
row: number;
|
|
12
|
+
i18n: I18nFormatter;
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {};
|
|
18
|
+
};
|
|
19
|
+
export type CellMenuProps = typeof __propDef.props;
|
|
20
|
+
export type CellMenuEvents = typeof __propDef.events;
|
|
21
|
+
export type CellMenuSlots = typeof __propDef.slots;
|
|
22
|
+
export default class CellMenu extends SvelteComponent<CellMenuProps, CellMenuEvents, CellMenuSlots> {
|
|
23
|
+
}
|
|
24
|
+
export {};
|