Skip to content

Commit

Permalink
inline filters
Browse files Browse the repository at this point in the history
  • Loading branch information
heswell committed Oct 22, 2024
1 parent 700f0ef commit decc7da
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
import type {
DataValueDescriptor,
SuggestionProvider,
TableSchemaTable,
} from "@finos/vuu-data-types";
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ColumnDescriptor } from "@finos/vuu-table-types";

import inlineFilteCss from "./InlineFilter.css";
import { InputProps } from "@salt-ds/core";
import { TableSchemaTable } from "@finos/vuu-data-types";

const classBase = "vuuInlineFilter";

Expand All @@ -18,6 +19,7 @@ export type FilterValueChangeHandler = (
export interface InlineFilterProps
extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
onChange: FilterValueChangeHandler;
table: TableSchemaTable;
}

const InputProps: Partial<InputProps> = {
Expand All @@ -27,6 +29,7 @@ const InputProps: Partial<InputProps> = {

export const InlineFilter = ({
onChange,
table,
...htmlAttributes
}: InlineFilterProps) => {
const targetWindow = useWindow();
Expand Down Expand Up @@ -64,6 +67,7 @@ export const InlineFilter = ({
InputProps,
dataDescriptor: column,
onCommit,
table,
})}
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import type {
SuggestionProvider,
TableSchemaTable,
} from "@finos/vuu-data-types";
import type { CommitHandler } from "@finos/vuu-utils";
import { ComboBox, Option } from "@salt-ds/core";
import { useVuuTypeaheadInput } from "./useVuuTypeaheadInput";
import { useComponentCssInjection } from "@salt-ds/styles";
import { useWindow } from "@salt-ds/window";
import { useVuuTypeaheadInput } from "./useVuuTypeaheadInput";

import vuuTypeaheadInputCss from "./VuuTypeaheadInput.css";
import { CommitHandler } from "@finos/vuu-utils";

const classBase = "vuuTypeaheadInput";

Expand All @@ -22,7 +22,6 @@ export interface VuuTypeaheadInputProps {
export const VuuTypeaheadInput = ({
column,
onCommit,
suggestionProvider,
table,
}: VuuTypeaheadInputProps) => {
const targetWindow = useWindow();
Expand All @@ -43,7 +42,6 @@ export const VuuTypeaheadInput = ({
} = useVuuTypeaheadInput({
column,
onCommit,
suggestionProvider,
table,
});
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { TypeaheadParams } from "@finos/vuu-protocol-types";
import { useTypeaheadSuggestions } from "@finos/vuu-data-react";
import type { TypeaheadParams } from "@finos/vuu-protocol-types";
import { dispatchKeyboardEvent, getVuuTable } from "@finos/vuu-utils";
import {
ChangeEventHandler,
ComponentPropsWithoutRef,
RefCallback,
SyntheticEvent,
useCallback,
useEffect,
useRef,
useState,
type ChangeEventHandler,
type RefCallback,
type SyntheticEvent,
} from "react";
import { VuuTypeaheadInputProps } from "./VuuTypeaheadInput";
import { useTypeaheadSuggestions } from "@finos/vuu-data-react";
import type { VuuTypeaheadInputProps } from "./VuuTypeaheadInput";

const NO_DATA_MATCH = ["No matching data"];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import { useMemo } from "react";
import { FilterValueChangeHandler, InlineFilter } from "@finos/vuu-filters";
import { SimulTable } from "../../Table/SIMUL.examples";
import { LocalDataSourceProvider } from "@finos/vuu-data-test";

let displaySequence = 0;

const table = { module: "SIMUL", table: "instrumentsExtended" } as const;

export const SimpleInlineFilters = () => {
const inlineFilter = useMemo(() => {
const onChange: FilterValueChangeHandler = (column, value) => {
console.log(`apply filter to column ${column.name} using value ${value}`);
};
return <InlineFilter onChange={onChange} />;
return <InlineFilter onChange={onChange} table={table} />;
}, []);

return (
<SimulTable
customHeader={inlineFilter}
height="100%"
tableName="instrumentsExtended"
/>
<LocalDataSourceProvider modules={["SIMUL"]}>
<SimulTable
customHeader={inlineFilter}
height="100%"
tableName={table.table}
/>
</LocalDataSourceProvider>
);
};
SimpleInlineFilters.displaySequence = displaySequence++;

0 comments on commit decc7da

Please sign in to comment.