diff --git a/vuu-ui/packages/vuu-datatable/src/configurable-table/ConfigurableTable.css b/vuu-ui/packages/vuu-datatable/src/configurable-table/ConfigurableTable.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/vuu-ui/packages/vuu-datatable/src/configurable-table/ConfigurableTable.tsx b/vuu-ui/packages/vuu-datatable/src/configurable-table/ConfigurableTable.tsx deleted file mode 100644 index 1b60895f8..000000000 --- a/vuu-ui/packages/vuu-datatable/src/configurable-table/ConfigurableTable.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { GridConfig } from "@finos/vuu-datagrid-types"; -import { Table, TablePropsDeprecated as TableProps } from "@finos/vuu-table"; -import { ReactElement, useCallback, useState } from "react"; -import { Dialog } from "@finos/vuu-popups"; - -export const ConfigurableTable = ({ - config, - dataSource, - ...restProps -}: TableProps) => { - const [dialogContent, setDialogContent] = useState(null); - const [tableConfig] = useState>(config); - - const hideSettings = useCallback(() => { - setDialogContent(null); - }, []); - - return ( - <> - - - {dialogContent} - - - ); -}; diff --git a/vuu-ui/packages/vuu-datatable/src/configurable-table/index.ts b/vuu-ui/packages/vuu-datatable/src/configurable-table/index.ts deleted file mode 100644 index 3fe444e02..000000000 --- a/vuu-ui/packages/vuu-datatable/src/configurable-table/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./ConfigurableTable"; diff --git a/vuu-ui/packages/vuu-datatable/src/index.ts b/vuu-ui/packages/vuu-datatable/src/index.ts index 2aa9e6454..6772e4a5c 100644 --- a/vuu-ui/packages/vuu-datatable/src/index.ts +++ b/vuu-ui/packages/vuu-datatable/src/index.ts @@ -1,3 +1,2 @@ -export * from "./configurable-table"; export * from "./filter-table"; export * from "./json-table"; diff --git a/vuu-ui/packages/vuu-table/src/table/index.ts b/vuu-ui/packages/vuu-table/src/table/index.ts index 27c881808..326dd2943 100644 --- a/vuu-ui/packages/vuu-table/src/table/index.ts +++ b/vuu-ui/packages/vuu-table/src/table/index.ts @@ -1,7 +1,6 @@ export * from "./ColumnResizer"; export * from "./context-menu"; export * from "./dataTableTypes"; -export * from "./Table"; export * from "./useMeasuredContainer"; export * from "./useSelection"; export * from "./useTableColumnResize"; diff --git a/vuu-ui/sample-apps/feature-basket-trading/src/useBasketTrading.tsx b/vuu-ui/sample-apps/feature-basket-trading/src/useBasketTrading.tsx index a20970a56..28aae02e1 100644 --- a/vuu-ui/sample-apps/feature-basket-trading/src/useBasketTrading.tsx +++ b/vuu-ui/sample-apps/feature-basket-trading/src/useBasketTrading.tsx @@ -109,7 +109,6 @@ export const useBasketTrading = ({ const handleMessageFromBasketTradingControl = useCallback( (message) => { if (message.type === "viewport-update") { - console.table(message.rows); if (message.size) { setBasketCount(message.size); } diff --git a/vuu-ui/sample-apps/feature-vuu-blotter/index.ts b/vuu-ui/sample-apps/feature-vuu-blotter/index.ts deleted file mode 100644 index 1e94b6afe..000000000 --- a/vuu-ui/sample-apps/feature-vuu-blotter/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import VuuBlotter from "./src/VuuBlotter"; -export default VuuBlotter; diff --git a/vuu-ui/sample-apps/feature-vuu-blotter/package.json b/vuu-ui/sample-apps/feature-vuu-blotter/package.json deleted file mode 100644 index 964636da1..000000000 --- a/vuu-ui/sample-apps/feature-vuu-blotter/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "feature-vuu-blotter", - "version": "0.0.26", - "description": "Vuu Blotter", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build": "node ../../scripts/build-feature.mjs", - "start": "serve -p 5002 ../../deployed_apps/app-vuu-example" - }, - "private": true, - "keywords": [], - "author": "heswell", - "license": "Apache-2.0", - "sideEffects": [ - "**/*.css" - ], - "devDependencies": {}, - "dependencies": { - "@finos/vuu-data": "0.0.26", - "@finos/vuu-data-react": "0.0.26", - "@finos/vuu-datagrid": "0.0.26", - "@finos/vuu-filters": "0.0.26", - "@finos/vuu-layout": "0.0.26", - "@finos/vuu-popups": "0.0.26", - "@finos/vuu-protocol-types": "0.0.26", - "@finos/vuu-shell": "0.0.26", - "@finos/vuu-theme": "0.0.26", - "@finos/vuu-utils": "0.0.26", - "@salt-ds/core": "1.8.0", - "@salt-ds/icons": "1.5.1", - "@salt-ds/lab": "1.0.0-alpha.15" - }, - "peerDependencies": { - "classnames": "^2.3.1", - "react": "^17.0.2", - "react-dom": "^17.0.2" - }, - "engines": { - "node": ">=16.0.0" - } -} diff --git a/vuu-ui/sample-apps/feature-vuu-blotter/src/VuuBlotter.css b/vuu-ui/sample-apps/feature-vuu-blotter/src/VuuBlotter.css deleted file mode 100644 index ba9ccedce..000000000 --- a/vuu-ui/sample-apps/feature-vuu-blotter/src/VuuBlotter.css +++ /dev/null @@ -1,19 +0,0 @@ -.vuDialog, /* until we correctly set the className on FilteredGrid view in a dialog */ -.vuuBlotter { - --hwDialog-margin: 200px auto 0 auto; - --hwParsedInput-background: white; - --hwParsedInput-input-font-size: 12px; - --hwParsedInput-height: 28px; - --hwParsedInput-border-style: none none none solid; - --hwParsedInput-width: calc(100% - var(--hwParsedInput-height)); - --vuuDataGrid-flex: 100% 0 0; - --vuuDataGrid-font-size: 10px; - --vuuDataGridCell-border-style: none; - --vuuDataGridRow-background-odd: var(--salt-palette-neutral-background-high); - max-height: 100%; -} - -.vuuBlotter-gridContainer { - height: calc(100% - 22px); - inset: var(--hwParsedInput-height) 0 0 0; -} diff --git a/vuu-ui/sample-apps/feature-vuu-blotter/src/VuuBlotter.tsx b/vuu-ui/sample-apps/feature-vuu-blotter/src/VuuBlotter.tsx deleted file mode 100644 index dbd16ab7a..000000000 --- a/vuu-ui/sample-apps/feature-vuu-blotter/src/VuuBlotter.tsx +++ /dev/null @@ -1,275 +0,0 @@ -import { - ConfigChangeMessage, - DataSourceVisualLinkCreatedMessage, - isViewportMenusAction, - isVisualLinkCreatedAction, - isVisualLinkRemovedAction, - isVisualLinksAction, - RemoteDataSource, - TableSchema, -} from "@finos/vuu-data"; -import { MenuActionConfig, useVuuMenuActions } from "@finos/vuu-data-react"; -import { Grid, GridProvider } from "@finos/vuu-datagrid"; -import { GridAction, KeyedColumnDescriptor } from "@finos/vuu-datagrid-types"; -import { Filter, FilterState } from "@finos/vuu-filter-types"; -import { - addFilter, - FilterInput, - useFilterSuggestionProvider, -} from "@finos/vuu-filters"; -import { useViewContext } from "@finos/vuu-layout"; -import { ContextMenuProvider } from "@finos/vuu-popups"; -import { - LinkDescriptorWithLabel, - VuuGroupBy, - VuuMenu, - VuuSort, -} from "@finos/vuu-protocol-types"; -import { - FeatureProps, - ShellContextProps, - useShellContext, -} from "@finos/vuu-shell"; -import { filterAsQuery } from "@finos/vuu-utils"; -import { Button } from "@salt-ds/core"; -import { LinkedIcon } from "@salt-ds/icons"; -import { useCallback, useEffect, useMemo, useState } from "react"; - -import "./VuuBlotter.css"; - -const classBase = "vuuBlotter"; - -const CONFIG_KEYS = ["filter", "filterQuery", "groupBy", "sort"]; - -type BlotterConfig = { - columns?: KeyedColumnDescriptor[]; - groupBy?: VuuGroupBy; - sort?: VuuSort; - "visual-link"?: DataSourceVisualLinkCreatedMessage; -}; -export interface FilteredGridProps extends FeatureProps { - schema: TableSchema; -} - -const applyDefaults = ( - { columns, table }: TableSchema, - getDefaultColumnConfig?: ShellContextProps["getDefaultColumnConfig"] -) => { - if (typeof getDefaultColumnConfig === "function") { - return columns.map((column) => { - const config = getDefaultColumnConfig(table.table, column.name); - if (config) { - return { - ...column, - ...config, - }; - } else { - return column; - } - }); - } else { - return columns; - } -}; - -const VuuBlotter = ({ schema, ...props }: FilteredGridProps) => { - const { id, dispatch, load, purge, save, loadSession, saveSession, title } = - useViewContext(); - const config = useMemo(() => load?.() as BlotterConfig | undefined, [load]); - const { getDefaultColumnConfig, handleRpcResponse } = useShellContext(); - const [filterState, setFilterState] = useState({ - filter: undefined, - filterQuery: "", - }); - - const suggestionProvider = useFilterSuggestionProvider({ - columns: schema.columns, - table: schema.table, - }); - - const dataSource: RemoteDataSource = useMemo(() => { - let ds = loadSession?.("data-source") as RemoteDataSource; - if (ds) { - return ds; - } - const columns = schema.columns.map((col) => col.name); - ds = new RemoteDataSource({ - viewport: id, - table: schema.table, - ...config, - columns, - title, - }); - saveSession?.(ds, "data-source"); - return ds; - // Note: despite the dependency array, because we load dataStore from session - // after initial load, changes to the following dependencies will not cause - // us to create a new dataSource, which is correct. - }, [config, id, loadSession, saveSession, schema, title]); - - useEffect(() => { - dataSource.enable(); - return () => { - dataSource.disable(); - }; - }, [dataSource]); - - useEffect(() => { - if (title !== dataSource.title) { - dataSource.title = title; - } - }, [dataSource, title]); - - const removeVisualLink = useCallback(() => { - dataSource.visualLink = undefined; - }, [dataSource]); - - const dispatchGridAction = useCallback( - (action: GridAction) => { - if (isVisualLinksAction(action)) { - saveSession?.(action.links, "visual-links"); - return true; - } else if (isVisualLinkCreatedAction(action)) { - dispatch?.({ - type: "add-toolbar-contribution", - location: "post-title", - content: ( - - ), - }); - save?.(action, "visual-link"); - return true; - } else if (isVisualLinkRemovedAction(action)) { - dispatch?.({ - type: "remove-toolbar-contribution", - location: "post-title", - }); - purge?.("visual-link"); - return true; - } else if (isViewportMenusAction(action)) { - saveSession?.(action.menu, "vs-context-menu"); - return true; - } - return false; - }, - [dispatch, purge, removeVisualLink, save, saveSession] - ); - - const handleConfigChange = useCallback( - (update: ConfigChangeMessage) => { - switch (update.type) { - default: - for (const [key, state] of Object.entries(update)) { - if (CONFIG_KEYS.includes(key)) { - save?.(state, key); - } - } - } - }, - [save] - ); - - // It is important that these values are not assigned in advance. They - // are accessed at the point of construction of ContextMenu - const menuActionConfig: MenuActionConfig = useMemo( - () => ({ - get visualLink() { - return load?.("visual-link") as DataSourceVisualLinkCreatedMessage; - }, - get visualLinks() { - return loadSession?.("visual-links") as LinkDescriptorWithLabel[]; - }, - get vuuMenu() { - return loadSession?.("vs-context-menu") as VuuMenu; - }, - }), - [load, loadSession] - ); - - const { buildViewserverMenuOptions, handleMenuAction } = useVuuMenuActions({ - dataSource, - menuActionConfig, - onRpcResponse: handleRpcResponse, - }); - - const namedFilters = useMemo(() => new Map(), []); - - const handleSubmitFilter = useCallback( - ( - newFilter: Filter | undefined, - filterQuery: string, - mode = "add", - filterName?: string - ) => { - let newFilterState: FilterState; - if (newFilter && (mode === "and" || mode === "or")) { - const fullFilter = addFilter(filterState.filter, newFilter, { - combineWith: mode, - }) as Filter; - newFilterState = { - filter: fullFilter, - filterQuery: filterAsQuery(fullFilter), - filterName, - }; - } else { - newFilterState = { - filter: newFilter, - filterQuery, - filterName, - }; - } - - dataSource.filter = { - filter: newFilterState.filterQuery, - filterStruct: newFilterState.filter, - }; - setFilterState(newFilterState); - if (filterName && newFilterState.filter) { - namedFilters.set(filterName, newFilterState.filterQuery); - } - }, - [dataSource, filterState.filter, namedFilters] - ); - - const configColumns = config?.columns; - - const columns = useMemo(() => { - return configColumns || applyDefaults(schema, getDefaultColumnConfig); - }, [configColumns, getDefaultColumnConfig, schema]); - - return ( - -
- - -
- -
-
-
-
- ); -}; - -VuuBlotter.displayName = "FilteredGrid"; - -export default VuuBlotter; diff --git a/vuu-ui/sample-apps/feature-vuu-table/index.ts b/vuu-ui/sample-apps/feature-vuu-table/index.ts deleted file mode 100644 index f039814e9..000000000 --- a/vuu-ui/sample-apps/feature-vuu-table/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -import VuuTable from "./src/vuuTable"; -export default VuuTable; diff --git a/vuu-ui/sample-apps/feature-vuu-table/package.json b/vuu-ui/sample-apps/feature-vuu-table/package.json deleted file mode 100644 index a35d4c398..000000000 --- a/vuu-ui/sample-apps/feature-vuu-table/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "feature-vuu-table", - "version": "0.0.26", - "description": "Vuu Table", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build": "node ../../scripts/build-feature.mjs", - "start": "serve -p 5002 ../../deployed_apps/app-vuu-example" - }, - "private": true, - "keywords": [], - "author": "heswell", - "license": "Apache-2.0", - "sideEffects": [ - "**/*.css" - ], - "devDependencies": {}, - "dependencies": { - "@finos/vuu-data": "0.0.26", - "@finos/vuu-data-react": "0.0.26", - "@finos/vuu-datagrid-types": "0.0.26", - "@finos/vuu-filters": "0.0.26", - "@finos/vuu-filter-types": "0.0.26", - "@finos/vuu-layout": "0.0.26", - "@finos/vuu-popups": "0.0.26", - "@finos/vuu-protocol-types": "0.0.26", - "@finos/vuu-shell": "0.0.26", - "@finos/vuu-table": "0.0.26", - "@finos/vuu-table-extras": "0.0.26", - "@finos/vuu-theme": "0.0.26", - "@finos/vuu-utils": "0.0.26", - "@salt-ds/core": "1.8.0", - "@salt-ds/icons": "1.5.1", - "@salt-ds/lab": "1.0.0-alpha.15" - }, - "peerDependencies": { - "classnames": "^2.3.1", - "react": "^17.0.2", - "react-dom": "^17.0.2" - }, - "engines": { - "node": ">=16.0.0" - } -} diff --git a/vuu-ui/sample-apps/feature-vuu-table/src/ConfigurableDataTable.tsx b/vuu-ui/sample-apps/feature-vuu-table/src/ConfigurableDataTable.tsx deleted file mode 100644 index cc743d6fa..000000000 --- a/vuu-ui/sample-apps/feature-vuu-table/src/ConfigurableDataTable.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { GridConfig } from "@finos/vuu-datagrid-types"; -import { Dialog } from "@finos/vuu-popups"; -import { Table, TablePropsDeprecated as TableProps } from "@finos/vuu-table"; -import { ReactElement, useCallback, useState } from "react"; - -export const ConfigurableDataTable = ({ - config, - dataSource, - ...restProps -}: TableProps) => { - const [dialogContent, setDialogContent] = useState(null); - const [tableConfig] = useState>(config); - - const hideSettings = useCallback(() => { - setDialogContent(null); - }, []); - - return ( - <> -
- - {dialogContent} - - - ); -}; diff --git a/vuu-ui/sample-apps/feature-vuu-table/src/vuuTable.css b/vuu-ui/sample-apps/feature-vuu-table/src/vuuTable.css deleted file mode 100644 index 1dc4f41e7..000000000 --- a/vuu-ui/sample-apps/feature-vuu-table/src/vuuTable.css +++ /dev/null @@ -1,35 +0,0 @@ -.vuDialog, /* until we correctly set the className on FilteredGrid view in a dialog */ -.vuuTable { - --hwDialog-margin: 200px auto 0 auto; - --hwParsedInput-background: white; - --hwParsedInput-input-font-size: 12px; - --hwParsedInput-height: 28px; - --hwParsedInput-border-style: none none none solid; - --hwParsedInput-width: calc(100% - var(--hwParsedInput-height)); - --vuuDataGrid-flex: 100% 0 0; - --vuuDataGrid-font-size: 10px; - --vuuDataGridCell-border-style: none; - --vuuDataGridRow-background-odd: var(--salt-palette-neutral-background-high); - display: flex; - flex-direction: column; -} - -.vuuTable .vuuFilterInput { - flex: 22px 0 0; -} - -.vuuTable .vuuTable-footer { - flex: 22px 0 0; - --saltToolbar-height: 20px; - --saltToolbar-background: var(--salt-container-primary-background); - border-top: solid 1px var(--salt-container-primary-borderColor); - color: var(--salt-text-secondary-foreground); - -} - - -.vuuTable-gridContainer { - height: calc(100% - 22px); - inset: var(--hwParsedInput-height) 0 0 0; -} - diff --git a/vuu-ui/sample-apps/feature-vuu-table/src/vuuTable.tsx b/vuu-ui/sample-apps/feature-vuu-table/src/vuuTable.tsx deleted file mode 100644 index de7da7910..000000000 --- a/vuu-ui/sample-apps/feature-vuu-table/src/vuuTable.tsx +++ /dev/null @@ -1,281 +0,0 @@ -import { - DataSource, - DataSourceConfig, - DataSourceVisualLinkCreatedMessage, - RemoteDataSource, - TableSchema, - VuuFeatureInvocationMessage, -} from "@finos/vuu-data"; -import { MenuActionConfig, useVuuMenuActions } from "@finos/vuu-data-react"; -import { GridConfig } from "@finos/vuu-datagrid-types"; -import { Filter, FilterState } from "@finos/vuu-filter-types"; -import { - addFilter, - FilterInput, - useFilterSuggestionProvider, -} from "@finos/vuu-filters"; -import { useViewContext } from "@finos/vuu-layout"; -import { ContextMenuProvider } from "@finos/vuu-popups"; -import { LinkDescriptorWithLabel, VuuMenu } from "@finos/vuu-protocol-types"; -import { - FeatureProps, - ShellContextProps, - useShellContext, -} from "@finos/vuu-shell"; -import { DataSourceStats } from "@finos/vuu-table-extras"; -import { filterAsQuery } from "@finos/vuu-utils"; -import { Button } from "@salt-ds/core"; -import { LinkedIcon } from "@salt-ds/icons"; -import { useCallback, useEffect, useMemo, useRef, useState } from "react"; -import { ConfigurableDataTable } from "./ConfigurableDataTable"; - -import "./vuuTable.css"; - -const classBase = "vuuTable"; - -type BlotterConfig = { - "datasource-config"?: DataSourceConfig; - "table-config"?: Omit; -}; - -const NO_CONFIG: BlotterConfig = {}; - -export interface FilteredTableProps extends FeatureProps { - schema: TableSchema; -} - -const applyDefaults = ( - { columns, table }: TableSchema, - getDefaultColumnConfig?: ShellContextProps["getDefaultColumnConfig"] -) => { - if (typeof getDefaultColumnConfig === "function") { - return columns.map((column) => { - const config = getDefaultColumnConfig(table.table, column.name); - if (config) { - return { - ...column, - ...config, - }; - } else { - return column; - } - }); - } else { - return columns; - } -}; - -const VuuTable = ({ schema, ...props }: FilteredTableProps) => { - const { id, dispatch, load, save, loadSession, saveSession, title } = - useViewContext(); - const { - "datasource-config": dataSourceConfigFromState, - "table-config": tableConfigFromState, - } = useMemo(() => (load?.() ?? NO_CONFIG) as BlotterConfig, [load]); - - const { getDefaultColumnConfig, handleRpcResponse } = useShellContext(); - const [filterState, setFilterState] = useState({ - filter: undefined, - filterQuery: "", - }); - - const configColumns = tableConfigFromState?.columns; - - const tableConfig = useMemo( - () => ({ - columns: configColumns || applyDefaults(schema, getDefaultColumnConfig), - }), - [configColumns, getDefaultColumnConfig, schema] - ); - - const tableConfigRef = useRef>(tableConfig); - - const suggestionProvider = useFilterSuggestionProvider({ - columns: schema.columns, - table: schema.table, - }); - - const handleDataSourceConfigChange = useCallback( - (config: DataSourceConfig | undefined, confirmed?: boolean) => { - // confirmed / unconfirmed messages are used for UI updates, not state saving - if (confirmed === undefined) { - save?.(config, "datasource-config"); - } - }, - [save] - ); - - const handleTableConfigChange = useCallback( - (config: Omit) => { - save?.(config, "table-config"); - tableConfigRef.current = config; - }, - [save] - ); - - const dataSource: DataSource = useMemo(() => { - let ds = loadSession?.("data-source") as RemoteDataSource; - if (ds) { - return ds; - } - const columns = - dataSourceConfigFromState?.columns ?? - schema.columns.map((col) => col.name); - - ds = new RemoteDataSource({ - bufferSize: 200, - viewport: id, - table: schema.table, - ...dataSourceConfigFromState, - columns, - title, - }); - ds.on("config", handleDataSourceConfigChange); - saveSession?.(ds, "data-source"); - return ds; - }, [ - dataSourceConfigFromState, - handleDataSourceConfigChange, - id, - loadSession, - saveSession, - schema.columns, - schema.table, - title, - ]); - - useEffect(() => { - dataSource.resume?.(); - return () => { - // suspend activity on the dataSource when component is unmounted - dataSource.suspend?.(); - }; - }, [dataSource]); - - const removeVisualLink = useCallback(() => { - dataSource.visualLink = undefined; - }, [dataSource]); - - const handleVuuFeatureInvoked = useCallback( - (message: VuuFeatureInvocationMessage) => { - if (message.type === "vuu-link-created") { - dispatch?.({ - type: "add-toolbar-contribution", - location: "post-title", - content: ( - - ), - }); - } else { - dispatch?.({ - type: "remove-toolbar-contribution", - location: "post-title", - }); - } - }, - [dispatch, removeVisualLink] - ); - - // It is important that these values are not assigned in advance. They - // are accessed at the point of construction of ContextMenu - const menuActionConfig: MenuActionConfig = useMemo( - () => ({ - get visualLink() { - return load?.("visual-link") as DataSourceVisualLinkCreatedMessage; - }, - get visualLinks() { - return loadSession?.("vuu-links") as LinkDescriptorWithLabel[]; - }, - get vuuMenu() { - return loadSession?.("vuu-menu") as VuuMenu; - }, - }), - [load, loadSession] - ); - - const { buildViewserverMenuOptions, handleMenuAction } = useVuuMenuActions({ - dataSource, - menuActionConfig, - onRpcResponse: handleRpcResponse, - }); - - useEffect(() => { - if (title !== dataSource.title) { - dataSource.title = title; - } - }, [dataSource, title]); - - const namedFilters = useMemo(() => new Map(), []); - - const handleSubmitFilter = useCallback( - ( - newFilter: Filter | undefined, - filterQuery: string, - mode = "add", - filterName?: string - ) => { - let newFilterState: FilterState; - if (newFilter && (mode === "and" || mode === "or")) { - const fullFilter = addFilter(filterState.filter, newFilter, { - combineWith: mode, - }) as Filter; - newFilterState = { - filter: fullFilter, - filterQuery: filterAsQuery(fullFilter), - filterName, - }; - } else { - newFilterState = { - filter: newFilter, - filterQuery, - filterName, - }; - } - - dataSource.filter = { - filter: newFilterState.filterQuery, - filterStruct: newFilterState.filter, - }; - setFilterState(newFilterState); - if (filterName && newFilterState.filter) { - namedFilters.set(filterName, newFilterState.filterQuery); - } - }, - [dataSource, filterState.filter, namedFilters] - ); - - return ( - -
- -
- -
-
- -
-
-
- ); -}; - -VuuTable.displayName = "VuuTable"; - -export default VuuTable; diff --git a/vuu-ui/showcase/src/examples/DataGrid/Grid.examples.css b/vuu-ui/showcase/src/examples/DataGrid/Grid.examples.css deleted file mode 100644 index 7a8b43bb1..000000000 --- a/vuu-ui/showcase/src/examples/DataGrid/Grid.examples.css +++ /dev/null @@ -1,7 +0,0 @@ -#drag-canvas { - position: absolute; -} - -.Steve { - --grid-row-height: 32px; -} diff --git a/vuu-ui/showcase/src/examples/DataGrid/Grid.examples.tsx b/vuu-ui/showcase/src/examples/DataGrid/Grid.examples.tsx deleted file mode 100644 index 951aade1d..000000000 --- a/vuu-ui/showcase/src/examples/DataGrid/Grid.examples.tsx +++ /dev/null @@ -1,673 +0,0 @@ -import { ConfigChangeHandler } from "@finos/vuu-data"; -import { Grid } from "@finos/vuu-datagrid"; -import { ColumnDescriptor } from "@finos/vuu-datagrid-types"; -import { Flexbox, View } from "@finos/vuu-layout"; -import { Dialog } from "@finos/vuu-popups"; -import { getAllSchemas } from "@finos/vuu-data-test"; -import { - Button, - FormField, - Input, - ToggleButton, - ToggleButtonGroup, -} from "@salt-ds/core"; -import { FormLabel } from "@salt-ds/lab"; -import { - ChangeEvent, - ReactElement, - SyntheticEvent, - useCallback, - useMemo, - useRef, - useState, -} from "react"; -import { ErrorDisplay, useTestDataSource } from "../utils"; -import { instrumentSchema } from "./columnMetaData"; - -import "./Grid.examples.css"; - -let displaySequence = 1; - -type GridBufferOptions = { - bufferSize: number; - renderBufferSize: number; -}; - -export const DefaultGrid = () => { - const tables = useMemo( - () => ["instruments", "orders", "parentOrders", "prices"], - [] - ); - - const calculatedColumns: ColumnDescriptor[] = useMemo( - () => [ - { - name: "notional", - expression: "=price*quantity", - serverDataType: "double", - type: { - name: "number", - formatting: { - decimals: 2, - }, - }, - }, - { - name: "isBuy", - expression: '=if(side="Sell","N","Y")', - serverDataType: "char", - }, - { - name: "CcySort", - expression: '=if(ccy="Gbp",1,if(ccy="USD",2,3))', - serverDataType: "char", - width: 60, - }, - { - name: "CcyLower", - expression: "=lower(ccy)", - serverDataType: "string", - width: 60, - }, - { - name: "AccountUpper", - expression: "=upper(account)", - label: "ACCOUNT", - serverDataType: "string", - }, - { - name: "ExchangeCcy", - expression: '=concatenate("---", exchange,"...",ccy, "---")', - serverDataType: "string", - }, - { - name: "ExchangeIsNY", - expression: '=starts(exchange,"N")', - serverDataType: "boolean", - }, - // { - // name: "Text", - // expression: "=text(quantity)", - // serverDataType: "string", - // }, - ], - [] - ); - - const [renderBufferSize, setRenderBufferSize] = useState( - 0 - ); - const [bufferSize, setBufferSize] = useState(0); - const [gridBufferOptions, setGridBufferOptions] = useState( - { - bufferSize: 100, - renderBufferSize: 0, - } - ); - const [selectedIndex, setSelectedIndex] = useState(0); - const [dialogContent, setDialogContent] = useState(null); - const schemas = getAllSchemas(); - const { columns, dataSource, error } = useTestDataSource({ - bufferSize: gridBufferOptions.renderBufferSize, - calculatedColumns: selectedIndex === 2 ? calculatedColumns : undefined, - schemas, - tablename: tables[selectedIndex], - }); - - const handleChange = (evt: SyntheticEvent) => { - const { value } = evt.target as HTMLButtonElement; - setSelectedIndex(parseInt(value)); - }; - - const hideSettings = useCallback(() => { - setDialogContent(null); - }, []); - - const handleRenderBufferSizeChange = useCallback( - (evt: ChangeEvent) => { - const value = parseInt((evt.target as HTMLInputElement).value || "-1"); - if (Number.isFinite(value) && value > 0) { - setRenderBufferSize(value); - } else { - setBufferSize(undefined); - } - }, - [] - ); - - // const handleBufferSizeChange = useCallback((evt: ChangeEvent) => { - // const value = parseInt((evt.target as HTMLInputElement).value || "-1"); - // if (Number.isFinite(value) && value > 0) { - // setBufferSize(value); - // } else { - // setBufferSize(undefined); - // } - // }, []); - - const applyBufferSizes = useCallback(() => { - setGridBufferOptions({ - bufferSize: bufferSize ?? 100, - renderBufferSize: renderBufferSize ?? 0, - }); - }, [bufferSize, renderBufferSize]); - - if (error) { - return {error}; - } - - return ( - <> -
- - Instruments - Orders - Parent Orders - Prices - -
- - - - {dialogContent} - -
-
- - {/* - - */} - -
-
- - ); -}; -DefaultGrid.displaySequence = displaySequence++; - -export const BasicGrid = () => { - const schemas = getAllSchemas(); - const { columns, dataSource, error } = useTestDataSource({ - schemas, - tablename: "instruments", - }); - const gridRef = useRef(null); - const [rowHeight, setRowHeight] = useState(18); - - const incrementProp = () => { - setRowHeight((value) => value + 1); - }; - - const decrementProp = () => { - setRowHeight((value) => value - 1); - }; - - const incrementCssProperty = () => { - if (gridRef.current) { - const rowHeight = parseInt( - getComputedStyle(gridRef.current).getPropertyValue( - "--hw-grid-row-height" - ) - ); - gridRef.current.style.setProperty( - "--grid-row-height", - `${rowHeight + 1}px` - ); - } - }; - - const decrementCssProperty = () => { - if (gridRef.current) { - const rowHeight = parseInt( - getComputedStyle(gridRef.current).getPropertyValue( - "--hw-grid-row-height" - ) - ); - gridRef.current?.style.setProperty( - "--grid-row-height", - `${rowHeight - 1}px` - ); - } - }; - - const setLowDensity = () => { - gridRef.current?.style.setProperty("--grid-row-height", `32px`); - }; - const setHighDensity = () => { - gridRef.current?.style.setProperty("--grid-row-height", `20px`); - }; - - const handleConfigChange: ConfigChangeHandler = (config) => { - console.log(`handleConfigChange ${JSON.stringify(config, null, 2)}`); - }; - - if (error) { - return {error}; - } - - return ( - <> - -
- - - - -
- - - - ); -}; - -BasicGrid.displaySequence = displaySequence++; - -export const PersistConfig = () => { - const configRef = useRef({ - columns: instrumentSchema.columns, - }); - const [configDisplay, setConfigDisplay] = useState(() => configRef.current); - const [config, setConfig] = useState(() => configRef.current); - - const applyConfig = () => { - setConfig(configRef.current); - }; - - const schemas = getAllSchemas(); - const { columns, dataSource, error } = useTestDataSource({ - schemas, - tablename: "instruments", - }); - - const handleConfigChange = useCallback( - (updates) => { - configRef.current = { ...config, ...updates }; - setConfigDisplay(configRef.current); - }, - [config] - ); - - const gridStyles = ` - .StoryGrid { - --hwDataGridCell-border-style: none; - --hwDataGridRow-background-odd: var(--surface1); - --hwDataGrid-font-size: 10px; - } - `; - - console.log(`render`, config); - - if (error) { - return {error}; - } - - return ( - <> - -
- -
- -