@gradio/dataframe 0.19.2 → 0.19.4
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 +29 -0
- package/Index.svelte +3 -1
- package/dist/Index.svelte +1 -0
- package/dist/Index.svelte.d.ts +6 -3
- package/dist/shared/BooleanCell.svelte +1 -2
- package/dist/shared/BooleanCell.svelte.d.ts +1 -1
- package/dist/shared/EditableCell.svelte +7 -18
- package/dist/shared/EditableCell.svelte.d.ts +2 -1
- package/dist/shared/Table.svelte +23 -13
- package/dist/shared/Table.svelte.d.ts +4 -2
- package/dist/shared/TableCell.svelte.d.ts +2 -1
- package/dist/shared/TableHeader.svelte +57 -0
- package/dist/shared/TableHeader.svelte.d.ts +7 -0
- package/dist/shared/context/dataframe_context.d.ts +9 -8
- package/dist/shared/context/dataframe_context.js +9 -1
- package/dist/shared/types.d.ts +2 -1
- package/dist/shared/utils/data_processing.d.ts +5 -4
- package/dist/shared/utils/data_processing.js +4 -2
- package/dist/shared/utils/filter_utils.d.ts +5 -4
- package/dist/shared/utils/keyboard_utils.js +1 -1
- package/dist/shared/utils/selection_utils.d.ts +3 -3
- package/dist/shared/utils/sort_utils.d.ts +4 -4
- package/dist/shared/utils/table_utils.d.ts +2 -2
- package/dist/shared/utils/utils.d.ts +8 -2
- package/package.json +8 -8
- package/shared/BooleanCell.svelte +2 -5
- package/shared/EditableCell.svelte +12 -20
- package/shared/Table.svelte +43 -27
- package/shared/TableCell.svelte +2 -1
- package/shared/TableHeader.svelte +62 -0
- package/shared/context/dataframe_context.ts +20 -13
- package/shared/types.ts +3 -1
- package/shared/utils/data_processing.ts +10 -5
- package/shared/utils/filter_utils.ts +5 -4
- package/shared/utils/keyboard_utils.ts +1 -6
- package/shared/utils/selection_utils.ts +3 -3
- package/shared/utils/sort_utils.ts +4 -4
- package/shared/utils/table_utils.ts +8 -2
- package/shared/utils/utils.ts +10 -5
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
CellValue,
|
|
3
|
+
Headers,
|
|
4
|
+
HeadersWithIDs,
|
|
5
|
+
TableCell,
|
|
6
|
+
TableData
|
|
7
|
+
} from "../types";
|
|
2
8
|
import { sort_data } from "./sort_utils";
|
|
3
9
|
import { filter_data } from "./filter_utils";
|
|
4
10
|
import type { SortDirection } from "./sort_utils";
|
|
@@ -173,7 +179,7 @@ export function data_uri_to_blob(data_uri: string): Blob {
|
|
|
173
179
|
export function handle_file_upload(
|
|
174
180
|
data_uri: string,
|
|
175
181
|
update_headers: (headers: Headers) => HeadersWithIDs[],
|
|
176
|
-
update_values: (values:
|
|
182
|
+
update_values: (values: CellValue[][]) => void
|
|
177
183
|
): void {
|
|
178
184
|
const blob = data_uri_to_blob(data_uri);
|
|
179
185
|
const reader = new FileReader();
|
package/shared/utils/utils.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { CellValue } from "../types";
|
|
2
|
+
|
|
1
3
|
export type Headers = string[];
|
|
2
|
-
export type Data =
|
|
4
|
+
export type Data = CellValue[][];
|
|
3
5
|
|
|
4
6
|
export type Datatype =
|
|
5
7
|
| "str"
|
|
@@ -26,10 +28,7 @@ export type DataframeValue = {
|
|
|
26
28
|
* @param t - The type to coerce to.
|
|
27
29
|
* @returns The coerced value.
|
|
28
30
|
*/
|
|
29
|
-
export function cast_value_to_type(
|
|
30
|
-
v: any,
|
|
31
|
-
t: Datatype
|
|
32
|
-
): string | number | boolean {
|
|
31
|
+
export function cast_value_to_type(v: any, t: Datatype): CellValue {
|
|
33
32
|
if (t === "number") {
|
|
34
33
|
const n = Number(v);
|
|
35
34
|
return isNaN(n) ? v : n;
|
|
@@ -48,3 +47,9 @@ export function cast_value_to_type(
|
|
|
48
47
|
}
|
|
49
48
|
return v;
|
|
50
49
|
}
|
|
50
|
+
|
|
51
|
+
export interface EditData {
|
|
52
|
+
index: number | [number, number];
|
|
53
|
+
value: string;
|
|
54
|
+
previous_value: string;
|
|
55
|
+
}
|