2022-04-14 14:58:23 +00:00
|
|
|
import classNames from "classnames";
|
|
|
|
import { components } from "react-select";
|
2022-05-23 11:12:41 +00:00
|
|
|
import BaseSelect, {
|
|
|
|
allTimezones,
|
|
|
|
ITimezoneOption,
|
|
|
|
ITimezone,
|
|
|
|
Props as SelectProps,
|
|
|
|
} from "react-timezone-select";
|
2022-04-14 14:58:23 +00:00
|
|
|
|
2022-10-10 18:50:43 +00:00
|
|
|
import { InputComponent } from "@calcom/ui/v2/core/form/select/components";
|
2022-04-14 14:58:23 +00:00
|
|
|
|
|
|
|
function TimezoneSelect({ className, ...props }: SelectProps) {
|
2022-09-06 22:58:16 +00:00
|
|
|
// @TODO: remove borderRadius and haveRoundedClassName logic from theme so we use only new style
|
|
|
|
const haveRoundedClassName = !!(className && className.indexOf("rounded-") > -1);
|
|
|
|
const defaultBorderRadius = 2;
|
|
|
|
|
2022-04-14 14:58:23 +00:00
|
|
|
return (
|
|
|
|
<BaseSelect
|
|
|
|
theme={(theme) => ({
|
|
|
|
...theme,
|
2022-09-06 22:58:16 +00:00
|
|
|
...(haveRoundedClassName ? {} : { borderRadius: defaultBorderRadius }),
|
2022-04-14 14:58:23 +00:00
|
|
|
colors: {
|
|
|
|
...theme.colors,
|
|
|
|
primary: "var(--brand-color)",
|
|
|
|
primary50: "rgba(209 , 213, 219, var(--tw-bg-opacity))",
|
|
|
|
primary25: "rgba(244, 245, 246, var(--tw-bg-opacity))",
|
|
|
|
},
|
|
|
|
})}
|
|
|
|
styles={{
|
|
|
|
option: (provided, state) => ({
|
|
|
|
...provided,
|
|
|
|
color: state.isSelected ? "var(--brand-text-color)" : "black",
|
|
|
|
":active": {
|
|
|
|
backgroundColor: state.isSelected ? "" : "var(--brand-color)",
|
|
|
|
color: "var(--brand-text-color)",
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}}
|
2022-05-23 11:12:41 +00:00
|
|
|
timezones={{
|
|
|
|
...allTimezones,
|
|
|
|
"America/Asuncion": "Asuncion",
|
|
|
|
}}
|
2022-04-14 14:58:23 +00:00
|
|
|
components={{
|
|
|
|
...components,
|
|
|
|
IndicatorSeparator: () => null,
|
|
|
|
Input: InputComponent,
|
|
|
|
}}
|
2022-07-15 16:39:11 +00:00
|
|
|
className={classNames("text-sm", className)}
|
2022-04-14 14:58:23 +00:00
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TimezoneSelect;
|
2022-05-23 11:12:41 +00:00
|
|
|
export type { ITimezone, ITimezoneOption };
|