mirror of https://github.com/coder/coder.git
35 lines
846 B
TypeScript
35 lines
846 B
TypeScript
import { action } from "@storybook/addon-actions";
|
|
import type { UseFilterResult } from "./filter";
|
|
import type { UseFilterMenuResult } from "./menu";
|
|
|
|
export const MockMenu: UseFilterMenuResult = {
|
|
initialOption: undefined,
|
|
isInitializing: false,
|
|
isSearching: false,
|
|
query: "",
|
|
searchOptions: [],
|
|
selectedOption: undefined,
|
|
selectOption: action("selectOption"),
|
|
setQuery: action("updateQuery"),
|
|
};
|
|
|
|
export const getDefaultFilterProps = <TFilterProps>({
|
|
query = "",
|
|
values,
|
|
menus,
|
|
}: {
|
|
query?: string;
|
|
values: Record<string, string | undefined>;
|
|
menus: Record<string, UseFilterMenuResult>;
|
|
}) =>
|
|
({
|
|
filter: {
|
|
query,
|
|
update: () => action("update"),
|
|
debounceUpdate: action("debounce") as UseFilterResult["debounceUpdate"],
|
|
used: false,
|
|
values,
|
|
},
|
|
menus,
|
|
}) as TFilterProps;
|