-
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.
create example for Vuu Blotter Feature (#684)
* create example for Vuu Blotter * add column type check function * exclude showcase index from semgrep * add semgrep ignore for showcase file * fix semgrepignore
- Loading branch information
Showing
37 changed files
with
756 additions
and
291 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
Empty file.
68 changes: 68 additions & 0 deletions
68
vuu-ui/packages/vuu-datatable/src/configurable-table/ConfigurableTable.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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { GridConfig } from "@finos/vuu-datagrid-types"; | ||
import { Table, TableProps } from "@finos/vuu-table"; | ||
import { ReactElement, useCallback, useRef, useState } from "react"; | ||
import { itemsChanged, toDataSourceColumns } from "@finos/vuu-utils"; | ||
import { Dialog } from "@finos/vuu-popups"; | ||
import { DatagridSettingsPanel } from "@finos/vuu-table-extras"; | ||
|
||
export const ConfigurableTable = ({ | ||
config, | ||
dataSource, | ||
...restProps | ||
}: TableProps) => { | ||
const [dialogContent, setDialogContent] = useState<ReactElement | null>(null); | ||
const configRef = useRef<Omit<GridConfig, "headings">>(config); | ||
const [tableConfig, setTableConfig] = | ||
useState<Omit<GridConfig, "headings">>(config); | ||
|
||
const handleSettingsConfigChange = useCallback( | ||
(config: Omit<GridConfig, "headings">, closePanel = false) => { | ||
console.log(`Table.examples config changed`, { | ||
config, | ||
}); | ||
setTableConfig((currentConfig) => { | ||
if (itemsChanged(currentConfig.columns, config.columns, "name")) { | ||
// side effect: update columns on dataSource | ||
dataSource.columns = config.columns.map(toDataSourceColumns); | ||
} | ||
return (configRef.current = config); | ||
}); | ||
closePanel && setDialogContent(null); | ||
}, | ||
[dataSource] | ||
); | ||
|
||
const showConfigEditor = useCallback(() => { | ||
setDialogContent( | ||
<DatagridSettingsPanel | ||
availableColumns={config.columns} | ||
gridConfig={configRef.current} | ||
onConfigChange={handleSettingsConfigChange} | ||
/> | ||
); | ||
}, [config.columns, handleSettingsConfigChange]); | ||
|
||
const hideSettings = useCallback(() => { | ||
setDialogContent(null); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<Table | ||
{...restProps} | ||
allowConfigEditing | ||
config={tableConfig} | ||
dataSource={dataSource} | ||
onShowConfigEditor={showConfigEditor} | ||
/> | ||
<Dialog | ||
className="vuuDialog-gridConfig" | ||
isOpen={dialogContent !== null} | ||
onClose={hideSettings} | ||
title="Grid and Column Settings" | ||
> | ||
{dialogContent} | ||
</Dialog> | ||
</> | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./ConfigurableTable"; |
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 * from "./configurable-table"; | ||
export * from "./json-table"; |
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
Oops, something went wrong.