import { ArrowRight, Filter } from "lucide-react";
import { Button } from "./button.js";
import { PropsWithChildren, useCallback, useState } from "react";
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
import {
Command,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "./command.js";
import { Icon } from "./icon.js";
import { motion, AnimatePresence } from "motion/react";
export type FilterPropertyType = "string" | "number";
export type FilterProperty = {
label: string;
icon: string;
name: string;
};
const Slide = ({ children }: PropsWithChildren) => (
{children}
);
export const Filters = ({ properties }: { properties: FilterProperty[] }) => {
const [open, setOpen] = useState(false);
const [property, setProperty] = useState();
const [operator, setOperator] = useState();
const List = useCallback(() => {
if (!property)
return ;
if (!operator) return ;
return null;
}, [properties, property, operator]);
function handleOpen(open: boolean) {
if (open) {
setOpen(open);
return;
}
if (operator) {
setOperator(undefined);
return;
}
if (property) {
setProperty(undefined);
return;
}
setOpen(false);
}
return (
<>
>
);
};
const PropertiesList = ({
properties,
onSelect,
}: {
properties: FilterProperty[];
onSelect: (property: FilterProperty) => void;
}) => {
return (
{properties.map((property) => (
onSelect(property)}
>
{property.label}
))}
);
};
const operators = {
equals: "Equals",
contains: "Contains",
startsWith: "Starts with",
endsWith: "Ends with",
};
const OperatorsList = ({
onSelect,
}: {
onSelect: (operator: string) => void;
}) => {
return (
{Object.entries(operators).map(([name, label]) => (
onSelect(name)}
>
{label}
))}
);
};