-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* enable json display in TableNext * rename JSONTableNext
- Loading branch information
Showing
12 changed files
with
52 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 15 additions & 10 deletions
25
vuu-ui/packages/vuu-datatable/src/json-table/JsonTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
import { TableProps } from "@finos/vuu-table"; | ||
import { JsonData } from "@finos/vuu-utils"; | ||
import { Table } from "@finos/vuu-table"; | ||
import { TableNext } from "@finos/vuu-table"; | ||
import { JsonDataSource } from "@finos/vuu-data"; | ||
import { useMemo } from "react"; | ||
import { ColumnDescriptor } from "@finos/vuu-datagrid-types"; | ||
import { TableConfig } from "@finos/vuu-datagrid-types"; | ||
|
||
export interface JsonTableProps | ||
extends Omit<TableProps, "config" | "dataSource"> { | ||
config: Pick< | ||
TableConfig, | ||
"columns" | "columnSeparators" | "rowSeparators" | "zebraStripes" | ||
>; | ||
source: JsonData | undefined; | ||
} | ||
|
||
export const JsonTable = ({ | ||
config, | ||
source = { "": "" }, | ||
...tableProps | ||
}: JsonTableProps) => { | ||
const [dataSource, tableConfig] = useMemo((): [ | ||
JsonDataSource, | ||
{ columns: ColumnDescriptor[] } | ||
] => { | ||
const [dataSource, tableConfig] = useMemo< | ||
[JsonDataSource, JsonTableProps["config"]] | ||
>(() => { | ||
const ds = new JsonDataSource({ | ||
data: source, | ||
}); | ||
|
||
return [ds, { columns: ds.columnDescriptors }]; | ||
}, [source]); | ||
|
||
return <Table {...tableProps} config={tableConfig} dataSource={dataSource} />; | ||
return [ds, { ...config, columns: ds.columnDescriptors }]; | ||
}, [config, source]); | ||
return ( | ||
<TableNext {...tableProps} config={tableConfig} dataSource={dataSource} /> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * as FilterTable from "./FilterTable.examples"; | ||
export * as JsonTable from "./JsonTable.examples"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export * as TableArrayData from "./TableArrayData.examples"; | ||
export * as TableVuuData from "./TableVuuData.examples"; | ||
export * as JsonTable from "./JsonTable.examples"; | ||
export * as TableExtras from "./TableExtras.examples"; | ||
export * as TableList from "./TableList.examples"; | ||
export * as TableNext from "./TableNext.examples"; |