import React, { forwardRef } from "react"; import clxs from "clsx"; import * as RadixSelect from "@radix-ui/react-select"; import "./Select.scss"; import { tablerChevronDownIcon, tablerChevronUpIcon } from "./icons"; type SelectItems = Record; export type SelectProps = { items: SelectItems; value: keyof SelectItems; onChange: (value: keyof SelectItems) => void; placeholder?: string; ariaLabel?: string; }; const Select = ({ items, value, onChange, placeholder, ariaLabel, }: SelectProps) => ( {placeholder && } {tablerChevronDownIcon} {tablerChevronUpIcon} {Object.entries(items).map(([itemValue, itemLabel]) => ( {itemLabel.label} ))} {tablerChevronDownIcon} ); type SelectItemProps = React.ComponentProps; const SelectItem = forwardRef( ( { children, className, ...props }: SelectItemProps, forwardedRef: React.ForwardedRef, ) => { return ( {children} ); }, ); export default Select;