* Icon and IconName * Button and ButtonGroup * UserAvatar * AvatarGroup * Avatar * WizardLayout * Dialogs * EmptyScreen * showToast and TextField * Editor * Skeleton * Skeleton * TopBanner and showToast * Button again * more * perf: Remove app-store reference from @calcom/ui * more * Fixing types * Icon * Fixed casing * dropdown * more * Select * more * Badge * List * more * Divider * more * fix * fix type check * refactor * fix * fix * fix * fix * fix * fix * fix * fix type check * fix * fix * fix * fix * more * more * more * more * add index file to components/command * fix * fix * fix * fix imports * fix * fix * fix * fix * fix * fix * fix * fix build errors * fix build errors * fix --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com>
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import React from "react";
|
|
import type { Props } from "react-select";
|
|
|
|
import Select from "@calcom/features/form/components/Select";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { Avatar } from "@calcom/ui/components/avatar";
|
|
import { Icon } from "@calcom/ui/components/icon";
|
|
|
|
type CheckedSelectOption = {
|
|
avatar: string;
|
|
label: string;
|
|
value: string;
|
|
disabled?: boolean;
|
|
};
|
|
|
|
export const CheckedSelect = ({
|
|
options = [],
|
|
value = [],
|
|
...props
|
|
}: Omit<Props<CheckedSelectOption, true>, "value" | "onChange"> & {
|
|
value?: readonly CheckedSelectOption[];
|
|
onChange: (value: readonly CheckedSelectOption[]) => void;
|
|
}) => {
|
|
const { t } = useLocale();
|
|
return (
|
|
<>
|
|
<Select
|
|
name={props.name}
|
|
placeholder={props.placeholder || t("select")}
|
|
isSearchable={false}
|
|
options={options}
|
|
value={value}
|
|
isMulti
|
|
{...props}
|
|
/>
|
|
{value.map((option) => (
|
|
<div key={option.value} className="border p-2 font-medium">
|
|
<Avatar
|
|
className="inline ltr:mr-2 rtl:ml-2"
|
|
size="sm"
|
|
imageSrc={option.avatar}
|
|
alt={option.label}
|
|
/>
|
|
{option.label}
|
|
<Icon
|
|
name="x"
|
|
onClick={() => props.onChange(value.filter((item) => item.value !== option.value))}
|
|
className="text-subtle float-right mt-0.5 h-5 w-5 cursor-pointer"
|
|
/>
|
|
</div>
|
|
))}
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default CheckedSelect;
|