2021-11-10 11:16:32 +00:00
|
|
|
import React from "react";
|
|
|
|
import ReactSelect, { components, GroupBase, Props } from "react-select";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2021-09-14 08:45:28 +00:00
|
|
|
import classNames from "@lib/classNames";
|
|
|
|
|
2021-11-10 11:16:32 +00:00
|
|
|
function Select<
|
|
|
|
Option,
|
|
|
|
IsMulti extends boolean = false,
|
|
|
|
Group extends GroupBase<Option> = GroupBase<Option>
|
|
|
|
>({ className, ...props }: Props<Option, IsMulti, Group>) {
|
|
|
|
return (
|
|
|
|
<ReactSelect
|
|
|
|
theme={(theme) => ({
|
|
|
|
...theme,
|
|
|
|
borderRadius: 2,
|
|
|
|
colors: {
|
|
|
|
...theme.colors,
|
|
|
|
primary: "rgba(17, 17, 17, var(--tw-bg-opacity))",
|
2022-03-22 10:34:36 +00:00
|
|
|
|
|
|
|
primary50: "rgba(209 , 213, 219, var(--tw-bg-opacity))",
|
2021-11-10 11:16:32 +00:00
|
|
|
primary25: "rgba(244, 245, 246, var(--tw-bg-opacity))",
|
|
|
|
},
|
|
|
|
})}
|
2022-03-18 18:31:30 +00:00
|
|
|
styles={{
|
|
|
|
option: (base, state) => ({
|
|
|
|
...base,
|
|
|
|
":active": {
|
|
|
|
backgroundColor: state.isSelected ? "" : "rgba(17, 17, 17, var(--tw-bg-opacity))",
|
|
|
|
color: "#ffffff",
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}}
|
2021-11-10 11:16:32 +00:00
|
|
|
components={{
|
|
|
|
...components,
|
|
|
|
IndicatorSeparator: () => null,
|
|
|
|
}}
|
2022-02-09 22:32:31 +00:00
|
|
|
className={classNames("focus:border-primary-500 text-sm shadow-sm", className)}
|
2021-11-10 11:16:32 +00:00
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2021-09-14 08:45:28 +00:00
|
|
|
|
2021-11-10 11:16:32 +00:00
|
|
|
export default Select;
|